code
stringlengths 10
174k
| nl
stringlengths 3
129k
|
---|---|
public static <NodeType extends ZyGraphNode<?>>String createTooltip(final AbstractZyGraph<NodeType,?> graph,final Edge edge){
Preconditions.checkNotNull(graph,"Error: Graph argument can not be null");
Preconditions.checkNotNull(edge,"Error: Edge argument can not be null");
String text=createTooltip(graph,edge.source()).replace("</html>","");
final ZyEdgeRealizer<?> realizer=(ZyEdgeRealizer<?>)graph.getGraph().getRealizer(edge);
if (realizer.labelCount() > 0) {
final ZyEdgeLabel edgeLabel=(ZyEdgeLabel)realizer.getLabel();
final ZyLabelContent content=edgeLabel.getLabelContent();
text+="<hr>" + HtmlGenerator.getHtml(content,GuiHelper.getMonospaceFont(),false).replace("<html>","").replace("</html>","");
}
text+="<hr>" + createTooltip(graph,edge.target()).replace("<html>","");
return text;
}
| Creates the tooltip for an edge in the graph. |
private static LocalSearchSuiteType chooseLocalSearchSuiteType(){
final LocalSearchSuiteType localSearchType;
if (Properties.DSE_PROBABILITY <= 0.0) {
localSearchType=LocalSearchSuiteType.ALWAYS_AVM;
}
else if (Properties.LOCAL_SEARCH_DSE == Properties.DSEType.SUITE) {
if (Randomness.nextDouble() <= Properties.DSE_PROBABILITY) {
localSearchType=LocalSearchSuiteType.ALWAYS_DSE;
}
else {
localSearchType=LocalSearchSuiteType.ALWAYS_AVM;
}
}
else {
assert (Properties.LOCAL_SEARCH_DSE == Properties.DSEType.TEST);
localSearchType=LocalSearchSuiteType.DSE_AND_AVM;
}
return localSearchType;
}
| Selects the type of local search according to the <code>LOCAL_SEARCH_DSE</code> and the <code>DSE_PROBABILITY</code> properties. |
public static Remove featureSelectionMultilabel(TaskContext aContext,Instances trainData,List<String> attributeEvaluator,String labelTransformationMethod,int numLabelsToKeep) throws TextClassificationException {
File fsResultsFile=getFile(aContext,TEST_TASK_OUTPUT_KEY,AdapterNameEntries.featureSelectionFile,AccessMode.READWRITE);
Remove filterRemove=new Remove();
try {
MultiLabelInstances mulanInstances=convertMekaInstancesToMulanInstances(trainData);
ASEvaluation eval=ASEvaluation.forName(attributeEvaluator.get(0),attributeEvaluator.subList(1,attributeEvaluator.size()).toArray(new String[0]));
AttributeEvaluator attributeSelectionFilter;
if (labelTransformationMethod.equals("LabelPowersetAttributeEvaluator")) {
attributeSelectionFilter=new LabelPowersetAttributeEvaluator(eval,mulanInstances);
}
else if (labelTransformationMethod.equals("BinaryRelevanceAttributeEvaluator")) {
attributeSelectionFilter=new BinaryRelevanceAttributeEvaluator(eval,mulanInstances,"max","none","rank");
}
else {
throw new TextClassificationException("This Label Transformation Method is not supported.");
}
Ranker r=new Ranker();
int[] result=r.search(attributeSelectionFilter,mulanInstances);
StringBuffer evalFile=new StringBuffer();
for ( Attribute att : mulanInstances.getFeatureAttributes()) {
evalFile.append(att.name() + ": " + attributeSelectionFilter.evaluateAttribute(att.index() - mulanInstances.getNumLabels())+ "\n");
}
FileUtils.writeStringToFile(fsResultsFile,evalFile.toString());
int[] toKeep=new int[numLabelsToKeep + mulanInstances.getNumLabels()];
System.arraycopy(result,0,toKeep,0,numLabelsToKeep);
int[] labelIndices=mulanInstances.getLabelIndices();
System.arraycopy(labelIndices,0,toKeep,numLabelsToKeep,mulanInstances.getNumLabels());
filterRemove.setAttributeIndicesArray(toKeep);
filterRemove.setInvertSelection(true);
filterRemove.setInputFormat(mulanInstances.getDataSet());
}
catch ( ArrayIndexOutOfBoundsException e) {
return null;
}
catch ( Exception e) {
throw new TextClassificationException(e);
}
return filterRemove;
}
| Feature selection using Mulan. |
private static void configureLogLevel(String loggerName,String levelValue){
final Level level=LoggerUtil.parseLogLevel(levelValue,Level.OFF);
final Logger logger=Logger.getLogger(loggerName);
logger.setLevel(level);
}
| Parses the levelValue into a Level instance and assigns to the Logger instance named by loggerName; if the the levelValue is invalid (e.g. misspelled), assigns Level.OFF to the logger. |
private void onUnloadSoundEffects(){
synchronized (mSoundEffectsLock) {
if (mSoundPool == null) {
return;
}
int[] poolId=new int[SOUND_EFFECT_FILES.size()];
for (int fileIdx=0; fileIdx < SOUND_EFFECT_FILES.size(); fileIdx++) {
poolId[fileIdx]=0;
}
for (int effect=0; effect < AudioManager.NUM_SOUND_EFFECTS; effect++) {
if (SOUND_EFFECT_FILES_MAP[effect][1] <= 0) {
continue;
}
if (poolId[SOUND_EFFECT_FILES_MAP[effect][0]] == 0) {
mSoundPool.unload(SOUND_EFFECT_FILES_MAP[effect][1]);
SOUND_EFFECT_FILES_MAP[effect][1]=-1;
poolId[SOUND_EFFECT_FILES_MAP[effect][0]]=-1;
}
}
mSoundPool.release();
mSoundPool=null;
}
}
| Unloads samples from the sound pool. This method can be called to free some memory when sound effects are disabled. |
private synchronized void loadTrustManager(){
try {
TrustManagerFactory tmf=TrustManagerFactory.getInstance(X509_ALGORITHM);
tmf.init(keystore);
for ( TrustManager trustManager : tmf.getTrustManagers()) {
if (trustManager instanceof X509TrustManager) {
defaultViPRTrustManager=(X509TrustManager)trustManager;
log.debug("found a X509TrustManager instance");
break;
}
}
log.info("renew trust manager. the # of certificates in trust store is {}",defaultViPRTrustManager.getAcceptedIssuers().length);
}
catch ( GeneralSecurityException e) {
log.error(e.getMessage(),e);
}
}
| loads the trust manager using the vipr keystore. |
public YearMonth addToCopy(int valueToAdd){
int[] newValues=iBase.getValues();
newValues=getField().add(iBase,iFieldIndex,newValues,valueToAdd);
return new YearMonth(iBase,newValues);
}
| Adds to the value of this field in a copy of this YearMonth. <p> The value will be added to this field. If the value is too large to be added solely to this field then it will affect larger fields. Smaller fields are unaffected. <p> If the result would be too large, beyond the maximum year, then an IllegalArgumentException is thrown. <p> The YearMonth attached to this property is unchanged by this call. Instead, a new instance is returned. |
public static String formatMessage(final String bundle,final String msgCode,final Object[] args){
String message=msgCode + ": " + ApplicationMessages.getString(bundle,msgCode);
if ((args != null) && (message != null) && (args.length > 0)) {
message=MessageFormat.format(message,args);
}
return message;
}
| Formatea un mensaje con sus parametros |
protected synchronized TopicConnectionFactory lookupTopicConnectionFactoryFromJNDI(String uri) throws NamingException {
final InitialContext jndiContext=getInitialContext();
return (TopicConnectionFactory)jndiContext.lookup(uri);
}
| <b>JMS 1.0.2</b> Look up the named TopicConnectionFactory object. |
public MapMetaBuilder start(final MapMeta meta){
return new MapMetaBuilder(meta);
}
| Returns new builder of item meta data, based on given one. |
@DSGenerator(tool_name="Doppelganger",tool_version="2.0",generated_on="2013-12-30 12:28:12.985 -0500",hash_original_method="BEECDC91516286CCE30494A55398B48A",hash_generated_method="67BEFFC721666B9B08A92F0A726B4D45") public DynamicLayout(CharSequence base,CharSequence display,TextPaint paint,int width,Alignment align,float spacingmult,float spacingadd,boolean includepad){
this(base,display,paint,width,align,spacingmult,spacingadd,includepad,null,0);
}
| Make a layout for the transformed text (password transformation being the primary example of a transformation) that will be updated as the base text is changed. |
public String toString(String enc) throws UnsupportedEncodingException {
return new String(toByteArray(),enc);
}
| Gets the curent contents of this byte stream as a string using the specified encoding. |
public boolean isPreLinkingPhase(){
return preLinkingPhase;
}
| <!-- begin-user-doc --> <!-- end-user-doc --> |
public FloatBuffer tessellate(ArrayList<ReadOnlyVector3> outerVertex,List<List<ReadOnlyVector3>> innerVertex){
if ((outerVertex == null) || (outerVertex.size() == 0)) {
return (null);
}
ArrayList<ReadOnlyVector3> positions=new ArrayList<ReadOnlyVector3>();
referencePoint=new Vector3(outerVertex.get(0));
for ( ReadOnlyVector3 vert : outerVertex) {
Vector3 pos=vert.subtract(referencePoint,null);
positions.add(pos);
}
this.outerVertex=positions;
if (innerVertex != null) {
this.innerVertex=new ArrayList<List<ReadOnlyVector3>>();
for (int i=0; i < innerVertex.size(); ++i) {
List<ReadOnlyVector3> innerVert=innerVertex.get(i);
positions=new ArrayList<ReadOnlyVector3>();
for ( ReadOnlyVector3 vert : innerVert) {
Vector3 pos=vert.subtract(referencePoint,null);
positions.add(pos);
}
this.innerVertex.add(positions);
}
}
tessellatedPolygon.clear();
this.tessellateInterior(new TessellatorCallback());
return (vertexBuffer);
}
| Uses the first coordinate as a reference point that is subtracted from all others to reduce the size of the number. The polygon is also tessellated and the vertex buffer is set for rendering. |
static public boolean removeAuxiliaryLookAndFeel(LookAndFeel laf){
maybeInitialize();
boolean result;
Vector<LookAndFeel> v=getLAFState().auxLookAndFeels;
if ((v == null) || (v.size() == 0)) {
return false;
}
result=v.removeElement(laf);
if (result) {
if (v.size() == 0) {
getLAFState().auxLookAndFeels=null;
getLAFState().multiLookAndFeel=null;
}
else {
getLAFState().auxLookAndFeels=v;
}
}
laf.uninitialize();
return result;
}
| Removes a <code>LookAndFeel</code> from the list of auxiliary look and feels. The auxiliary look and feels tell the multiplexing look and feel what other <code>LookAndFeel</code> classes for a component instance are to be used in addition to the default <code>LookAndFeel</code> class when creating a multiplexing UI. The change will only take effect when a new UI class is created or when the default look and feel is changed on a component instance. <p>Note these are not the same as the installed look and feels. |
public static void init(final Context context,final FileDownloadHelper.OkHttpClientCustomMaker okHttpClientCustomMaker,final int maxNetworkThreadCount){
init(context,new DownloadMgrInitialParams.InitCustomMaker().okHttpClient(okHttpClientCustomMaker).maxNetworkThreadCount(maxNetworkThreadCount));
}
| Initialize the FileDownloader. <p> <strong>Note:</strong> this method consumes 4~28ms in nexus 5. the most cost used for loading classes. |
private void processIndexes(QueryEntity qryEntity,TypeDescriptor d) throws IgniteCheckedException {
if (!F.isEmpty(qryEntity.getIndexes())) {
Map<String,String> aliases=qryEntity.getAliases();
if (aliases == null) aliases=Collections.emptyMap();
for ( QueryIndex idx : qryEntity.getIndexes()) {
String idxName=idx.getName();
if (idxName == null) idxName=QueryEntity.defaultIndexName(idx);
if (idx.getIndexType() == QueryIndexType.SORTED || idx.getIndexType() == QueryIndexType.GEOSPATIAL) {
d.addIndex(idxName,idx.getIndexType() == QueryIndexType.SORTED ? SORTED : GEO_SPATIAL);
int i=0;
for ( Map.Entry<String,Boolean> entry : idx.getFields().entrySet()) {
String field=entry.getKey();
boolean asc=entry.getValue();
String alias=aliases.get(field);
if (alias != null) field=alias;
d.addFieldToIndex(idxName,field,i++,!asc);
}
}
else {
assert idx.getIndexType() == QueryIndexType.FULLTEXT;
for ( String field : idx.getFields().keySet()) {
String alias=aliases.get(field);
if (alias != null) field=alias;
d.addFieldToTextIndex(field);
}
}
}
}
}
| Processes indexes based on query entity. |
private static char whitespaceToSpace(char c){
return Character.isWhitespace(c) ? ' ' : c;
}
| Turns every whitespace character into a space character. |
public static Integer size(){
return PM.size();
}
| Returns the size (number of cached replay processors) or the replay processor cache. |
public void visitTypeInsn(int opcode,String type){
if (mv != null) {
mv.visitTypeInsn(opcode,type);
}
}
| Visits a type instruction. A type instruction is an instruction that takes the internal name of a class as parameter. |
private String parseValue(String value){
value=value.trim();
if (value.charAt(0) == '\'' && value.charAt(value.length() - 1) == '\'') {
value=value.substring(1,value.length() - 1);
value=value.replaceAll("''","'");
}
return value;
}
| Parse a value (the second half of a column match expression). |
public SolrQueryResponse(){
}
| // another way of returning an error int errCode; String errMsg; |
@LargeTest public void testNavigationByWord() throws Exception {
sExecutedTestCount++;
String html="<html>" + "<head>" + "</head>"+ "<body>"+ "<p>"+ "This is <b>a</b> sentence"+ "</p>"+ "<p>"+ " scattered "+ "<p/>"+ " all over "+ "</p>"+ "<div>"+ "<p>the place.</p>"+ "</div>"+ "</body>"+ "</html>";
WebView webView=loadHTML(html);
sendKeyEvent(webView,KeyEvent.KEYCODE_DPAD_DOWN,META_STATE_ALT_LEFT_ON);
assertSelectionString("1");
sendKeyEvent(webView,KeyEvent.KEYCODE_DPAD_DOWN,0);
assertSelectionString("This");
sendKeyEvent(webView,KeyEvent.KEYCODE_DPAD_DOWN,0);
assertSelectionString("is");
sendKeyEvent(webView,KeyEvent.KEYCODE_DPAD_DOWN,0);
assertSelectionString("<b>a</b>");
sendKeyEvent(webView,KeyEvent.KEYCODE_DPAD_DOWN,0);
assertSelectionString("sentence");
sendKeyEvent(webView,KeyEvent.KEYCODE_DPAD_DOWN,0);
assertSelectionString("scattered");
sendKeyEvent(webView,KeyEvent.KEYCODE_DPAD_DOWN,0);
assertSelectionString("all");
sendKeyEvent(webView,KeyEvent.KEYCODE_DPAD_DOWN,0);
assertSelectionString("over");
sendKeyEvent(webView,KeyEvent.KEYCODE_DPAD_DOWN,0);
assertSelectionString("the");
sendKeyEvent(webView,KeyEvent.KEYCODE_DPAD_DOWN,0);
assertSelectionString("place");
sendKeyEvent(webView,KeyEvent.KEYCODE_DPAD_DOWN,0);
assertSelectionString(".");
sendKeyEvent(webView,KeyEvent.KEYCODE_DPAD_DOWN,0);
assertSelectionString(null);
sendKeyEvent(webView,KeyEvent.KEYCODE_DPAD_UP,0);
assertSelectionString("place.");
sendKeyEvent(webView,KeyEvent.KEYCODE_DPAD_UP,0);
assertSelectionString("the");
sendKeyEvent(webView,KeyEvent.KEYCODE_DPAD_UP,0);
assertSelectionString("over");
sendKeyEvent(webView,KeyEvent.KEYCODE_DPAD_UP,0);
assertSelectionString("all");
sendKeyEvent(webView,KeyEvent.KEYCODE_DPAD_UP,0);
assertSelectionString("scattered");
sendKeyEvent(webView,KeyEvent.KEYCODE_DPAD_UP,0);
assertSelectionString("sentence");
sendKeyEvent(webView,KeyEvent.KEYCODE_DPAD_UP,0);
assertSelectionString("<b>a</b>");
sendKeyEvent(webView,KeyEvent.KEYCODE_DPAD_UP,0);
assertSelectionString("is");
sendKeyEvent(webView,KeyEvent.KEYCODE_DPAD_UP,0);
assertSelectionString("This");
sendKeyEvent(webView,KeyEvent.KEYCODE_DPAD_UP,0);
assertSelectionString(null);
sendKeyEvent(webView,KeyEvent.KEYCODE_DPAD_DOWN,0);
assertSelectionString("This");
sendKeyEvent(webView,KeyEvent.KEYCODE_DPAD_DOWN,0);
assertSelectionString("is");
}
| Tests navigation by word. |
public boolean shouldCollide(Fixture fixtureA,Fixture fixtureB){
Filter filterA=fixtureA.getFilterData();
Filter filterB=fixtureB.getFilterData();
if (filterA.groupIndex == filterB.groupIndex && filterA.groupIndex != 0) {
return filterA.groupIndex > 0;
}
boolean collide=(filterA.maskBits & filterB.categoryBits) != 0 && (filterA.categoryBits & filterB.maskBits) != 0;
return collide;
}
| Return true if contact calculations should be performed between these two shapes. |
public boolean newWorkersRequired(int completionTargetMillis){
if (stats == null) {
return false;
}
LOGGER.debug("+ stats.toString() = " + stats.toString());
return stats.expectedCompletionTime() > completionTargetMillis;
}
| check if a new worker is required for the worker or the master. ount=0, consumerCount=4, enqueueCount=4, averageEnqueueTime=1.5, expectedCompletionTime=0, destinationName=jms.queue.worker_job_request_queue} |
public Subscription registerController(Class<?> controllerClass,String controllerId,ModelProvider modelProvider){
Assert.requireNonNull(controllerClass,"controllerClass");
Assert.requireNonBlank(controllerId,"controllerId");
Assert.requireNonNull(modelProvider,"modelProvider");
DolphinControllerInfoMBean mBean=new DolphinControllerInfo(dolphinContextId,controllerClass,controllerId,modelProvider);
return MBeanRegistry.getInstance().register(mBean,new MBeanDescription("com.canoo.dolphin",controllerClass.getSimpleName(),"controller"));
}
| Register a new Dolphin Platform controller as a MBean |
private void dropDownstreamTo(long absolutePosition){
int relativePosition=(int)(absolutePosition - totalBytesDropped);
int allocationIndex=relativePosition / allocationLength;
for (int i=0; i < allocationIndex; i++) {
allocator.release(dataQueue.remove());
totalBytesDropped+=allocationLength;
}
}
| Discard any allocations that hold data prior to the specified absolute position, returning them to the allocator. |
protected Pair(K first,V second){
this.first=first;
this.second=second;
}
| Creates a new instance of Pair |
@Override public final boolean hasSource(String sourceId) throws AdeException {
refreshDictionaryIfNeeded();
return m_dictionary.getWordId(sourceId) != DbDictionary.InvalidID;
}
| This method determines whether or not the input sourceID is associated with a source |
public static int longlongHashCode(long key1,long key2){
int h=(int)(key1 ^ (key1 >>> 32));
return h * 31 + (int)(key2 ^ (key2 >>> 32));
}
| Returns the hash code for a long-long pair. This is the default hash function for the keys of a distributed matrix in MR/Spark. |
public static void println(int priority,String tag,String msg,Throwable tr){
if (mLogNode != null) {
mLogNode.println(priority,tag,msg,tr);
}
}
| Instructs the LogNode to print the log data provided. Other LogNodes can be chained to the end of the LogNode as desired. |
@Override public Object eInvoke(int operationID,EList<?> arguments) throws InvocationTargetException {
switch (operationID) {
case TypesPackage.ARRAY_LIKE___GET_ELEMENT_TYPE:
return getElementType();
}
return super.eInvoke(operationID,arguments);
}
| <!-- begin-user-doc --> <!-- end-user-doc --> |
private static void cutIndent(IDocument document,int line,int toDelete,int tabSize,boolean[] commentLines,int relative) throws BadLocationException {
IRegion region=document.getLineInformation(line);
int from=region.getOffset();
int endOffset=region.getOffset() + region.getLength();
while (from < endOffset - 2 && document.get(from,2).equals(SLASHES)) from+=2;
int to=from;
while (toDelete > 0 && to < endOffset) {
char ch=document.getChar(to);
if (!Character.isWhitespace(ch)) break;
toDelete-=computeVisualLength(ch,tabSize);
if (toDelete >= 0) to++;
else break;
}
if (endOffset > to + 1 && document.get(to,2).equals(SLASHES)) commentLines[relative]=true;
document.replace(from,to - from,null);
}
| Cuts the visual equivalent of <code>toDelete</code> characters out of the indentation of line <code>line</code> in <code>document</code>. Leaves leading comment signs alone. |
public static void createPRWithRedundantCopyWithAsyncEventQueue(String regionName,String asyncEventQueueId,Boolean offHeap){
IgnoredException exp=IgnoredException.addIgnoredException(ForceReattemptException.class.getName());
try {
AttributesFactory fact=new AttributesFactory();
PartitionAttributesFactory pfact=new PartitionAttributesFactory();
pfact.setTotalNumBuckets(16);
pfact.setRedundantCopies(1);
fact.setPartitionAttributes(pfact.create());
fact.setOffHeap(offHeap);
Region r=cache.createRegionFactory(fact.create()).addAsyncEventQueueId(asyncEventQueueId).create(regionName);
assertNotNull(r);
}
finally {
exp.remove();
}
}
| Create PartitionedRegion with 1 redundant copy |
public EObject basicGetReference(){
return reference;
}
| <!-- begin-user-doc --> <!-- end-user-doc --> |
public static Object deepCopy(Object obj){
ObjectOutputStream oos=null;
ObjectInputStream ois=null;
Object newObject=null;
try {
ByteArrayOutputStream baos=new ByteArrayOutputStream();
oos=new ObjectOutputStream(baos);
oos.writeObject(obj);
oos.flush();
ByteArrayInputStream bais=new ByteArrayInputStream(baos.toByteArray());
ois=new ObjectInputStream(bais);
newObject=ois.readObject();
}
catch ( Exception e) {
}
finally {
try {
if (oos != null) oos.close();
}
catch ( IOException e) {
}
try {
if (ois != null) ois.close();
}
catch ( IOException e) {
}
}
return newObject;
}
| Realiza una copia en profundidad de un objeto. |
public static double blackFormulaImpliedStdDevApproximation(final PlainVanillaPayoff payoff,@Real final double strike,@Real final double forward,@Real final double blackPrice,@DiscountFactor final double discount,@Real final double displacement){
return blackFormulaImpliedStdDevApproximation(payoff.optionType(),payoff.strike(),forward,blackPrice,discount,displacement);
}
| Approximated Black 1976 implied standard deviation, i.e. volatility*sqrt(timeToMaturity). <p> It is calculated using Brenner and Subrahmanyan (1988) and Feinstein (1988) approximation for at-the-money forward option, with the extended moneyness approximation by Corrado and Miller (1996) |
private final static void usage(String msg){
System.err.println(msg);
System.err.println("Usage: java Base64 -e|-d inputfile outputfile");
}
| Prints command line usage. |
public void stderrShouldContain(String expectedString){
if (!stderr.contains(expectedString)) {
reportDiagnosticSummary();
throw new RuntimeException("'" + expectedString + "' missing from stderr \n");
}
}
| Verify that the stderr contents of output buffer contains the string |
public AlgorithmIdentifier(String algorithm,String algorithmName){
this(algorithm,null,null);
this.algorithmName=algorithmName;
}
| For testing when algorithmName is not known, but algorithm OID is. |
public static ContentManifest fromJson(String json){
ContentManifest manifest=new ContentManifest();
try {
JsonNode filesListNode=new ObjectMapper().readTree(json);
for ( JsonNode fileNode : filesListNode) {
String fileName=fileNode.get(JsonKeys.FILE_PATH).asText();
String fileHash=fileNode.get(JsonKeys.FILE_HASH).asText();
manifest.files.add(new ManifestFile(fileName,fileHash));
}
}
catch ( Exception e) {
e.printStackTrace();
}
manifest.jsonString=json;
return manifest;
}
| Create instance of the object from JSON string. JSON string is a content of the chcp.manifest file. |
public Bindings add(String property,JToggleButton c){
registerPropertyChangeListener(c);
return add(new JToggleButtonBinding(property,c,false));
}
| Handles JToggleButton, JCheckBox |
public void draw(){
GLES20.glUseProgram(getProgram());
int positionHandle=GLES20.glGetAttribLocation(getProgram(),VERTEX_POSITION);
GLES20.glEnableVertexAttribArray(positionHandle);
GLES20.glVertexAttribPointer(positionHandle,COORDS_PER_VERTEX,GLES20.GL_FLOAT,false,COORDS_PER_VERTEX * SIZE_OF_FLOAT,vertexBuffer);
int colorHandle=GLES20.glGetUniformLocation(getProgram(),VERTEX_COLOR);
GLES20.glEnable(GLES20.GL_BLEND);
GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA,GLES20.GL_ONE_MINUS_SRC_ALPHA);
GLES20.glUniform4fv(colorHandle,1,getColor(),0);
GLES20.glDrawElements(GLES20.GL_TRIANGLE_FAN,shortBuffer.capacity(),GLES20.GL_UNSIGNED_SHORT,shortBuffer);
GLES20.glDisableVertexAttribArray(positionHandle);
GLES20.glDisable(GLES20.GL_BLEND);
}
| Draw bubble. |
public static int findRowIdColumnIndex(String[] columnNames){
int length=columnNames.length;
for (int i=0; i < length; i++) {
if (columnNames[i].equals("_id")) {
return i;
}
}
return -1;
}
| Returns column index of "_id" column, or -1 if not found. |
private void growByOne(){
int adding=0;
if (capacityIncrement <= 0) {
if ((adding=elementData.length) == 0) {
adding=1;
}
}
else {
adding=capacityIncrement;
}
E[] newData=newElementArray(elementData.length + adding);
System.arraycopy(elementData,0,newData,0,elementCount);
elementData=newData;
}
| JIT optimization |
public boolean isInstantiable(){
return detail.isInstantiable();
}
| This is used to determine if the class is an inner class. If the class is a inner class and not static then this returns false. Only static inner classes can be instantiated using reflection as they do not require a "this" argument. |
@Override public String toString(){
String result=toString;
if (result == null) {
result=computeToString();
toString=result;
}
return result;
}
| Returns the string representation of this media type in the format described in <a href="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045</a>. |
public JavaSource addSource(File file) throws IOException {
return classLibraryBuilder.addSource(file);
}
| Add a java source from a file to this JavaProjectBuilder |
private DynamicApkInfo parseBaseApk(Resources res,XmlResourceParser parser,String[] outError) throws XmlPullParserException, IOException {
AttributeSet attrs=parser;
mParseInstrumentationArgs=null;
mParseActivityArgs=null;
mParseServiceArgs=null;
mParseProviderArgs=null;
final String pkgName;
try {
String packageName=parsePackageNames(parser,attrs);
pkgName=packageName;
}
catch ( DynamicApkParserException e) {
mParseError=INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME;
return null;
}
int type;
final DynamicApkInfo pkg=new DynamicApkInfo(pkgName);
boolean foundApp=false;
TypedArray sa=res.obtainAttributes(attrs,Hooks.getStyleableArray("AndroidManifest"));
pkg.coreApp=attrs.getAttributeBooleanValue(null,"coreApp",false);
sa.recycle();
int supportsSmallScreens=1;
int supportsNormalScreens=1;
int supportsLargeScreens=1;
int supportsXLargeScreens=1;
int resizeable=1;
int anyDensity=1;
int outerDepth=parser.getDepth();
while ((type=parser.next()) != XmlPullParser.END_DOCUMENT && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
continue;
}
String tagName=parser.getName();
if (tagName.equals("application")) {
if (foundApp) {
if (RIGID_PARSER) {
outError[0]="<manifest> has more than one <application>";
mParseError=INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
return null;
}
else {
Log.w(TAG,"<manifest> has more than one <application>");
XmlUtils.skipCurrentTag(parser);
continue;
}
}
foundApp=true;
if (!parseBaseApplication(pkg,res,parser,attrs,outError)) {
return null;
}
}
else if (tagName.equals("overlay")) {
sa=res.obtainAttributes(attrs,Hooks.getStyleableArray("AndroidManifestResourceOverlay"));
pkg.mOverlayTarget=sa.getString(Hooks.getStyleable("AndroidManifestResourceOverlay_targetPackage"));
pkg.mOverlayPriority=sa.getInt(Hooks.getStyleable("AndroidManifestResourceOverlay_priority"),-1);
sa.recycle();
if (pkg.mOverlayTarget == null) {
outError[0]="<overlay> does not specify a target package";
mParseError=INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
return null;
}
if (pkg.mOverlayPriority < 0 || pkg.mOverlayPriority > 9999) {
outError[0]="<overlay> priority must be between 0 and 9999";
mParseError=INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
return null;
}
XmlUtils.skipCurrentTag(parser);
}
else if (tagName.equals("key-sets")) {
if (!parseKeySets(pkg,res,parser,attrs,outError)) {
return null;
}
}
else if (tagName.equals("permission-group")) {
if (parsePermissionGroup(pkg,res,parser,attrs,outError) == null) {
return null;
}
}
else if (tagName.equals("permission")) {
if (parsePermission(pkg,res,parser,attrs,outError) == null) {
return null;
}
}
else if (tagName.equals("permission-tree")) {
if (parsePermissionTree(pkg,res,parser,attrs,outError) == null) {
return null;
}
}
else if (tagName.equals("uses-permission")) {
if (!parseUsesPermission(pkg,res,parser,attrs)) {
return null;
}
}
else if (tagName.equals("uses-permission-sdk-m") || tagName.equals("uses-permission-sdk-23")) {
if (!parseUsesPermission(pkg,res,parser,attrs)) {
return null;
}
}
else if (tagName.equals("uses-configuration")) {
ConfigurationInfo cPref=new ConfigurationInfo();
sa=res.obtainAttributes(attrs,Hooks.getStyleableArray("AndroidManifestUsesConfiguration"));
cPref.reqTouchScreen=sa.getInt(Hooks.getStyleable("AndroidManifestUsesConfiguration_reqTouchScreen"),Configuration.TOUCHSCREEN_UNDEFINED);
cPref.reqKeyboardType=sa.getInt(Hooks.getStyleable("AndroidManifestUsesConfiguration_reqKeyboardType"),Configuration.KEYBOARD_UNDEFINED);
if (sa.getBoolean(Hooks.getStyleable("AndroidManifestUsesConfiguration_reqHardKeyboard"),false)) {
cPref.reqInputFeatures|=ConfigurationInfo.INPUT_FEATURE_HARD_KEYBOARD;
}
cPref.reqNavigation=sa.getInt(Hooks.getStyleable("AndroidManifestUsesConfiguration_reqNavigation"),Configuration.NAVIGATION_UNDEFINED);
if (sa.getBoolean(Hooks.getStyleable("AndroidManifestUsesConfiguration_reqFiveWayNav"),false)) {
cPref.reqInputFeatures|=ConfigurationInfo.INPUT_FEATURE_FIVE_WAY_NAV;
}
sa.recycle();
pkg.configPreferences=ArrayUtils.add(pkg.configPreferences,cPref);
XmlUtils.skipCurrentTag(parser);
}
else if (tagName.equals("uses-feature")) {
FeatureInfo fi=parseUsesFeature(res,attrs);
pkg.reqFeatures=ArrayUtils.add(pkg.reqFeatures,fi);
if (fi.name == null) {
ConfigurationInfo cPref=new ConfigurationInfo();
cPref.reqGlEsVersion=fi.reqGlEsVersion;
pkg.configPreferences=ArrayUtils.add(pkg.configPreferences,cPref);
}
XmlUtils.skipCurrentTag(parser);
}
else if (tagName.equals("uses-sdk")) {
XmlUtils.skipCurrentTag(parser);
}
else if (tagName.equals("supports-screens")) {
sa=res.obtainAttributes(attrs,Hooks.getStyleableArray("AndroidManifestSupportsScreens"));
pkg.applicationInfo.requiresSmallestWidthDp=sa.getInteger(Hooks.getStyleable("AndroidManifestSupportsScreens_requiresSmallestWidthDp"),0);
pkg.applicationInfo.compatibleWidthLimitDp=sa.getInteger(Hooks.getStyleable("AndroidManifestSupportsScreens_compatibleWidthLimitDp"),0);
pkg.applicationInfo.largestWidthLimitDp=sa.getInteger(Hooks.getStyleable("AndroidManifestSupportsScreens_largestWidthLimitDp"),0);
supportsSmallScreens=sa.getInteger(Hooks.getStyleable("AndroidManifestSupportsScreens_smallScreens"),supportsSmallScreens);
supportsNormalScreens=sa.getInteger(Hooks.getStyleable("AndroidManifestSupportsScreens_normalScreens"),supportsNormalScreens);
supportsLargeScreens=sa.getInteger(Hooks.getStyleable("AndroidManifestSupportsScreens_largeScreens"),supportsLargeScreens);
supportsXLargeScreens=sa.getInteger(Hooks.getStyleable("AndroidManifestSupportsScreens_xlargeScreens"),supportsXLargeScreens);
resizeable=sa.getInteger(Hooks.getStyleable("AndroidManifestSupportsScreens_resizeable"),resizeable);
anyDensity=sa.getInteger(Hooks.getStyleable("AndroidManifestSupportsScreens_anyDensity"),anyDensity);
sa.recycle();
XmlUtils.skipCurrentTag(parser);
}
else if (tagName.equals("protected-broadcast")) {
sa=res.obtainAttributes(attrs,Hooks.getStyleableArray("AndroidManifestProtectedBroadcast"));
String name=sa.getNonResourceString(Hooks.getStyleable("AndroidManifestProtectedBroadcast_name"));
sa.recycle();
if (name != null) {
if (pkg.protectedBroadcasts == null) {
pkg.protectedBroadcasts=new ArrayList<String>();
}
if (!pkg.protectedBroadcasts.contains(name)) {
pkg.protectedBroadcasts.add(name.intern());
}
}
XmlUtils.skipCurrentTag(parser);
}
else if (tagName.equals("instrumentation")) {
if (parseInstrumentation(pkg,res,parser,attrs,outError) == null) {
return null;
}
}
else if (tagName.equals("original-package")) {
XmlUtils.skipCurrentTag(parser);
continue;
}
else if (tagName.equals("adopt-permissions")) {
XmlUtils.skipCurrentTag(parser);
continue;
}
else if (tagName.equals("uses-gl-texture")) {
XmlUtils.skipCurrentTag(parser);
continue;
}
else if (tagName.equals("compatible-screens")) {
XmlUtils.skipCurrentTag(parser);
continue;
}
else if (tagName.equals("supports-input")) {
XmlUtils.skipCurrentTag(parser);
continue;
}
else if (tagName.equals("eat-comment")) {
XmlUtils.skipCurrentTag(parser);
continue;
}
else if (RIGID_PARSER) {
outError[0]="Bad element under <manifest>: " + parser.getName();
mParseError=INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
return null;
}
else {
Log.w(TAG,"Unknown element under <manifest>: " + parser.getName() + " at "+ mArchiveSourcePath+ " "+ parser.getPositionDescription());
XmlUtils.skipCurrentTag(parser);
continue;
}
}
if (!foundApp && pkg.instrumentation.size() == 0) {
outError[0]="<manifest> does not contain an <application> or <instrumentation>";
mParseError=INSTALL_PARSE_FAILED_MANIFEST_EMPTY;
}
final int NP=DynamicApkParser.NEW_PERMISSIONS.length;
StringBuilder implicitPerms=null;
for (int ip=0; ip < NP; ip++) {
final DynamicApkParser.NewPermissionInfo npi=DynamicApkParser.NEW_PERMISSIONS[ip];
if (pkg.applicationInfo.targetSdkVersion >= npi.sdkVersion) {
break;
}
if (!pkg.requestedPermissions.contains(npi.name)) {
if (implicitPerms == null) {
implicitPerms=new StringBuilder(128);
implicitPerms.append(pkg.packageName);
implicitPerms.append(": compat added ");
}
else {
implicitPerms.append(' ');
}
implicitPerms.append(npi.name);
pkg.requestedPermissions.add(npi.name);
}
}
if (implicitPerms != null) {
Log.i(TAG,implicitPerms.toString());
}
if (supportsSmallScreens < 0 || (supportsSmallScreens > 0 && pkg.applicationInfo.targetSdkVersion >= android.os.Build.VERSION_CODES.DONUT)) {
pkg.applicationInfo.flags|=ApplicationInfo.FLAG_SUPPORTS_SMALL_SCREENS;
}
if (supportsNormalScreens != 0) {
pkg.applicationInfo.flags|=ApplicationInfo.FLAG_SUPPORTS_NORMAL_SCREENS;
}
if (supportsLargeScreens < 0 || (supportsLargeScreens > 0 && pkg.applicationInfo.targetSdkVersion >= android.os.Build.VERSION_CODES.DONUT)) {
pkg.applicationInfo.flags|=ApplicationInfo.FLAG_SUPPORTS_LARGE_SCREENS;
}
if (supportsXLargeScreens < 0 || (supportsXLargeScreens > 0 && pkg.applicationInfo.targetSdkVersion >= android.os.Build.VERSION_CODES.GINGERBREAD)) {
pkg.applicationInfo.flags|=ApplicationInfo.FLAG_SUPPORTS_XLARGE_SCREENS;
}
if (resizeable < 0 || (resizeable > 0 && pkg.applicationInfo.targetSdkVersion >= android.os.Build.VERSION_CODES.DONUT)) {
pkg.applicationInfo.flags|=ApplicationInfo.FLAG_RESIZEABLE_FOR_SCREENS;
}
if (anyDensity < 0 || (anyDensity > 0 && pkg.applicationInfo.targetSdkVersion >= android.os.Build.VERSION_CODES.DONUT)) {
pkg.applicationInfo.flags|=ApplicationInfo.FLAG_SUPPORTS_SCREEN_DENSITIES;
}
return pkg;
}
| Parse the manifest of a <em>base APK</em>. <p> When adding new features, carefully consider if they should also be supported by split APKs. |
@Parameterized.Parameters public static Collection<Object[]> methods(){
return Arrays.asList(new Object[][]{{RqMethod.POST,"hello, post!"},{RqMethod.GET,"hello, get!"},{RqMethod.PUT,"hello, put!"},{RqMethod.DELETE,"hello, delete!"},{RqMethod.TRACE,"hello, trace!"}});
}
| Http methods for testing. |
public static int intersection(int a[],int lena,int b[],int lenb,int[] target){
if (lena > lenb) {
int ti=lena;
lena=lenb;
lenb=ti;
int[] ta=a;
a=b;
b=ta;
}
if (lena == 0) return 0;
if ((lenb >> 3) >= lena) {
return intersectionBinarySearch(a,lena,b,lenb,target);
}
int icount=0;
int i=0, j=0;
int doca=a[i], docb=b[j];
for (; ; ) {
if (doca > docb) {
if (++j >= lenb) break;
docb=b[j];
}
else if (doca < docb) {
if (++i >= lena) break;
doca=a[i];
}
else {
target[icount++]=doca;
if (++i >= lena) break;
doca=a[i];
if (++j >= lenb) break;
docb=b[j];
}
}
return icount;
}
| puts the intersection of a and b into the target array and returns the size |
private Map<Value,Double> createTable(String variable){
Map<Value,Double> values=new HashMap<Value,Double>();
int maxPriority=Integer.MAX_VALUE;
Set<Value> toRemove=new HashSet<Value>();
toRemove.add(ValueFactory.none());
for ( BasicEffect e : subeffects) {
if (e.getVariable().equals(variable)) {
if (e.priority < maxPriority) {
maxPriority=e.priority;
}
if (e.negated) {
toRemove.add(e.getValue());
}
}
}
for ( BasicEffect e : subeffects) {
String var=e.getVariable();
if (var.equals(variable)) {
Value value=e.getValue();
if (e.priority > maxPriority || e.negated || toRemove.contains(value)) {
continue;
}
if (toRemove.size() > 1 && value instanceof SetVal) {
Collection<Value> subvalues=((SetVal)value).getSubValues();
subvalues.removeAll(toRemove);
value=ValueFactory.create(subvalues);
}
values.merge(value,e.weight,null);
}
}
return values;
}
| Extracts the values (along with their weight) specified in the effect. |
public static boolean passesSmallPrimeTest(BigInteger candidate){
final int[] smallPrime={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997,1009,1013,1019,1021,1031,1033,1039,1049,1051,1061,1063,1069,1087,1091,1093,1097,1103,1109,1117,1123,1129,1151,1153,1163,1171,1181,1187,1193,1201,1213,1217,1223,1229,1231,1237,1249,1259,1277,1279,1283,1289,1291,1297,1301,1303,1307,1319,1321,1327,1361,1367,1373,1381,1399,1409,1423,1427,1429,1433,1439,1447,1451,1453,1459,1471,1481,1483,1487,1489,1493,1499};
for (int i=0; i < smallPrime.length; i++) {
if (candidate.mod(BigInteger.valueOf(smallPrime[i])).equals(ZERO)) {
return false;
}
}
return true;
}
| Short trial-division test to find out whether a number is not prime. This test is usually used before a Miller-Rabin primality test. |
public KeywordAttributeImpl(){
}
| Initialize this attribute with the keyword value as false. |
void unexecuteNSDecls(TransformerImpl transformer) throws TransformerException {
unexecuteNSDecls(transformer,null);
}
| Send endPrefixMapping events to the result tree handler for all declared prefix mappings in the stylesheet. |
public static void sign(File jadFile,File outputJadFile,File jarFile,RSAPrivateKey privateKey,X509Certificate[] certificateChain,int certificateNumber) throws IOException, CryptoException {
Properties jadProperties=readJadFile(jadFile);
Properties newJadProperties=new Properties();
for (Enumeration enumPropNames=jadProperties.propertyNames(); enumPropNames.hasMoreElements(); ) {
String propName=(String)enumPropNames.nextElement();
if (propName.equals(MIDLET_JAR_RSA_SHA1_ATTR)) {
continue;
}
if (propName.startsWith(MessageFormat.format(SUB_MIDLET_CERTIFICATE_ATTR,certificateNumber))) {
continue;
}
newJadProperties.put(propName,jadProperties.getProperty(propName));
}
for (int i=0; i < certificateChain.length; i++) {
X509Certificate certificate=certificateChain[i];
String base64Cert=null;
try {
base64Cert=new String(Base64.encode(certificate.getEncoded()));
}
catch ( CertificateEncodingException ex) {
throw new CryptoException(res.getString("Base64CertificateFailed.exception.message"),ex);
}
String midletCertificateAttr=MessageFormat.format(MIDLET_CERTIFICATE_ATTR,certificateNumber,(i + 1));
newJadProperties.put(midletCertificateAttr,base64Cert);
}
byte[] signedJarDigest=signJarDigest(jarFile,privateKey);
String base64SignedJarDigest=new String(Base64.encode(signedJarDigest));
newJadProperties.put(MIDLET_JAR_RSA_SHA1_ATTR,base64SignedJarDigest);
TreeMap<String,String> sortedJadProperties=new TreeMap<String,String>();
for (Enumeration names=newJadProperties.propertyNames(); names.hasMoreElements(); ) {
String name=(String)names.nextElement();
String value=newJadProperties.getProperty(name);
sortedJadProperties.put(name,value);
}
FileWriter fw=null;
try {
fw=new FileWriter(outputJadFile);
for (Iterator itrSorted=sortedJadProperties.entrySet().iterator(); itrSorted.hasNext(); ) {
Map.Entry property=(Map.Entry)itrSorted.next();
fw.write(MessageFormat.format(JAD_ATTR_TEMPLATE,property.getKey(),property.getValue()));
fw.write(CRLF);
}
}
finally {
IOUtils.closeQuietly(fw);
}
}
| Sign a JAD file outputting the modified JAD to a different file. |
public final void insertElementAt(E element,int index){
add(index,element);
}
| Inserts an element at the given position. |
private String buildStartMessage(RecognizeOptions options){
JsonObject startMessage=new JsonParser().parse(new Gson().toJson(options)).getAsJsonObject();
startMessage.remove(MODEL);
startMessage.addProperty(ACTION,START);
return startMessage.toString();
}
| Builds the start message. |
protected boolean isBlacklistedRecipient(){
return fieldBlacklistedRecipient;
}
| Returns the Blacklisted. |
public IA32ConditionOperand flipOperands(){
switch (value) {
case LLT:
value=LGT;
break;
case LGE:
value=LLE;
break;
case LLE:
value=LGE;
break;
case LGT:
value=LLT;
break;
case LT:
value=GT;
break;
case GE:
value=LE;
break;
case LE:
value=GE;
break;
case GT:
value=LT;
break;
default :
OptimizingCompilerException.TODO();
}
return this;
}
| change the condition when operands are flipped |
public void addTable(String tagString,TrueTypeTable table){
tables.put(tagString,table);
}
| Add a table to the font |
@Deprecated public PtCountSimComparisonKMLWriter(final List<CountSimComparison> boardCountSimCompList,final List<CountSimComparison> alightCountSimCompList,final List<CountSimComparison> occupancyCountSimCompList,final CoordinateTransformation coordTransform,final Counts boradCounts,final Counts alightCounts,final Counts occupancyCounts){
super(boardCountSimCompList,alightCountSimCompList,occupancyCountSimCompList);
this.coordTransform=coordTransform;
this.boardCounts=boradCounts;
this.alightCounts=alightCounts;
this.occupancyCounts=occupancyCounts;
}
| Sets the data to the fields of this class |
private boolean testInProgress(){
return mTestInProgress;
}
| Returns whether we're in the middle of running a test. |
public T javaEnabled(Boolean value){
setBoolean(JAVA_ENABLED,value);
return (T)this;
}
| <div class="ind"> <p> Optional. </p> <p>Specifies whether Java was enabled.</p> <table border="1"> <tbody> <tr> <th>Parameter</th> <th>Value Type</th> <th>Default Value</th> <th>Max Length</th> <th>Supported Hit Types</th> </tr> <tr> <td><code>je</code></td> <td>boolean</td> <td><span class="none">None</span> </td> <td><span class="none">None</span> </td> <td>all</td> </tr> </tbody> </table> <div> Example value: <code>1</code><br> Example usage: <code>je=1</code> </div> </div> |
public static GregorianCalendar createCalendar(){
return new GregorianCalendar();
}
| Creates a calendar object representing the current date and time. |
public void endRequest(){
repository.logout(mailboxSession);
}
| Logout from open JCR Session |
public int code(){
return rawResponse.code();
}
| HTTP status code. |
protected PrimitiveTypeImpl(){
super();
}
| <!-- begin-user-doc --> <!-- end-user-doc --> |
private BezierPath[] toPath(String str) throws IOException {
LinkedList<BezierPath> paths=new LinkedList<BezierPath>();
BezierPath path=null;
Point2D.Double p=new Point2D.Double();
Point2D.Double c1=new Point2D.Double();
Point2D.Double c2=new Point2D.Double();
StreamPosTokenizer tt=new StreamPosTokenizer(new StringReader(str));
tt.resetSyntax();
tt.parseNumbers();
tt.parseExponents();
tt.parsePlusAsNumber();
tt.whitespaceChars(0,' ');
tt.whitespaceChars(',',',');
char nextCommand='M';
char command='M';
Commands: while (tt.nextToken() != StreamPosTokenizer.TT_EOF) {
if (tt.ttype > 0) {
command=(char)tt.ttype;
}
else {
command=nextCommand;
tt.pushBack();
}
BezierPath.Node node;
switch (command) {
case 'M':
if (path != null) {
paths.add(path);
}
path=new BezierPath();
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("x coordinate missing for 'M' at position " + tt.getStartPosition() + " in "+ str);
}
p.x=tt.nval;
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("y coordinate missing for 'M' at position " + tt.getStartPosition() + " in "+ str);
}
p.y=tt.nval;
path.moveTo(p.x,p.y);
nextCommand='L';
break;
case 'm':
if (path != null) {
paths.add(path);
}
path=new BezierPath();
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("dx coordinate missing for 'm' at position " + tt.getStartPosition() + " in "+ str);
}
p.x+=tt.nval;
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("dy coordinate missing for 'm' at position " + tt.getStartPosition() + " in "+ str);
}
p.y+=tt.nval;
path.moveTo(p.x,p.y);
nextCommand='l';
break;
case 'Z':
case 'z':
p.x=path.get(0).x[0];
p.y=path.get(0).y[0];
if (path.size() > 1) {
BezierPath.Node first=path.get(0);
BezierPath.Node last=path.get(path.size() - 1);
if (first.x[0] == last.x[0] && first.y[0] == last.y[0]) {
if ((last.mask & BezierPath.C1_MASK) != 0) {
first.mask|=BezierPath.C1_MASK;
first.x[1]=last.x[1];
first.y[1]=last.y[1];
}
path.remove(path.size() - 1);
}
}
path.setClosed(true);
break;
case 'L':
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("x coordinate missing for 'L' at position " + tt.getStartPosition() + " in "+ str);
}
p.x=tt.nval;
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("y coordinate missing for 'L' at position " + tt.getStartPosition() + " in "+ str);
}
p.y=tt.nval;
path.lineTo(p.x,p.y);
nextCommand='L';
break;
case 'l':
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("dx coordinate missing for 'l' at position " + tt.getStartPosition() + " in "+ str);
}
p.x+=tt.nval;
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("dy coordinate missing for 'l' at position " + tt.getStartPosition() + " in "+ str);
}
p.y+=tt.nval;
path.lineTo(p.x,p.y);
nextCommand='l';
break;
case 'H':
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("x coordinate missing for 'H' at position " + tt.getStartPosition() + " in "+ str);
}
p.x=tt.nval;
path.lineTo(p.x,p.y);
nextCommand='H';
break;
case 'h':
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("dx coordinate missing for 'h' at position " + tt.getStartPosition() + " in "+ str);
}
p.x+=tt.nval;
path.lineTo(p.x,p.y);
nextCommand='h';
break;
case 'V':
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("y coordinate missing for 'V' at position " + tt.getStartPosition() + " in "+ str);
}
p.y=tt.nval;
path.lineTo(p.x,p.y);
nextCommand='V';
break;
case 'v':
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("dy coordinate missing for 'v' at position " + tt.getStartPosition() + " in "+ str);
}
p.y+=tt.nval;
path.lineTo(p.x,p.y);
nextCommand='v';
break;
case 'C':
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("x1 coordinate missing for 'C' at position " + tt.getStartPosition() + " in "+ str);
}
c1.x=tt.nval;
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("y1 coordinate missing for 'C' at position " + tt.getStartPosition() + " in "+ str);
}
c1.y=tt.nval;
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("x2 coordinate missing for 'C' at position " + tt.getStartPosition() + " in "+ str);
}
c2.x=tt.nval;
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("y2 coordinate missing for 'C' at position " + tt.getStartPosition() + " in "+ str);
}
c2.y=tt.nval;
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("x coordinate missing for 'C' at position " + tt.getStartPosition() + " in "+ str);
}
p.x=tt.nval;
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("y coordinate missing for 'C' at position " + tt.getStartPosition() + " in "+ str);
}
p.y=tt.nval;
path.curveTo(c1.x,c1.y,c2.x,c2.y,p.x,p.y);
nextCommand='C';
break;
case 'c':
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("dx1 coordinate missing for 'c' at position " + tt.getStartPosition() + " in "+ str);
}
c1.x=p.x + tt.nval;
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("dy1 coordinate missing for 'c' at position " + tt.getStartPosition() + " in "+ str);
}
c1.y=p.y + tt.nval;
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("dx2 coordinate missing for 'c' at position " + tt.getStartPosition() + " in "+ str);
}
c2.x=p.x + tt.nval;
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("dy2 coordinate missing for 'c' at position " + tt.getStartPosition() + " in "+ str);
}
c2.y=p.y + tt.nval;
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("dx coordinate missing for 'c' at position " + tt.getStartPosition() + " in "+ str);
}
p.x+=tt.nval;
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("dy coordinate missing for 'c' at position " + tt.getStartPosition() + " in "+ str);
}
p.y+=tt.nval;
path.curveTo(c1.x,c1.y,c2.x,c2.y,p.x,p.y);
nextCommand='c';
break;
case 'S':
node=path.get(path.size() - 1);
c1.x=node.x[0] * 2d - node.x[1];
c1.y=node.y[0] * 2d - node.y[1];
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("x2 coordinate missing for 'S' at position " + tt.getStartPosition() + " in "+ str);
}
c2.x=tt.nval;
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("y2 coordinate missing for 'S' at position " + tt.getStartPosition() + " in "+ str);
}
c2.y=tt.nval;
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("x coordinate missing for 'S' at position " + tt.getStartPosition() + " in "+ str);
}
p.x=tt.nval;
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("y coordinate missing for 'S' at position " + tt.getStartPosition() + " in "+ str);
}
p.y=tt.nval;
path.curveTo(c1.x,c1.y,c2.x,c2.y,p.x,p.y);
nextCommand='S';
break;
case 's':
node=path.get(path.size() - 1);
c1.x=node.x[0] * 2d - node.x[1];
c1.y=node.y[0] * 2d - node.y[1];
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("dx2 coordinate missing for 's' at position " + tt.getStartPosition() + " in "+ str);
}
c2.x=p.x + tt.nval;
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("dy2 coordinate missing for 's' at position " + tt.getStartPosition() + " in "+ str);
}
c2.y=p.y + tt.nval;
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("dx coordinate missing for 's' at position " + tt.getStartPosition() + " in "+ str);
}
p.x+=tt.nval;
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("dy coordinate missing for 's' at position " + tt.getStartPosition() + " in "+ str);
}
p.y+=tt.nval;
path.curveTo(c1.x,c1.y,c2.x,c2.y,p.x,p.y);
nextCommand='s';
break;
case 'Q':
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("x1 coordinate missing for 'Q' at position " + tt.getStartPosition() + " in "+ str);
}
c1.x=tt.nval;
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("y1 coordinate missing for 'Q' at position " + tt.getStartPosition() + " in "+ str);
}
c1.y=tt.nval;
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("x coordinate missing for 'Q' at position " + tt.getStartPosition() + " in "+ str);
}
p.x=tt.nval;
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("y coordinate missing for 'Q' at position " + tt.getStartPosition() + " in "+ str);
}
p.y=tt.nval;
path.quadTo(c1.x,c1.y,p.x,p.y);
nextCommand='Q';
break;
case 'q':
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("dx1 coordinate missing for 'q' at position " + tt.getStartPosition() + " in "+ str);
}
c1.x=p.x + tt.nval;
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("dy1 coordinate missing for 'q' at position " + tt.getStartPosition() + " in "+ str);
}
c1.y=p.y + tt.nval;
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("dx coordinate missing for 'q' at position " + tt.getStartPosition() + " in "+ str);
}
p.x+=tt.nval;
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("dy coordinate missing for 'q' at position " + tt.getStartPosition() + " in "+ str);
}
p.y+=tt.nval;
path.quadTo(c1.x,c1.y,p.x,p.y);
nextCommand='q';
break;
case 'T':
node=path.get(path.size() - 1);
c1.x=node.x[0] * 2d - node.x[1];
c1.y=node.y[0] * 2d - node.y[1];
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("x coordinate missing for 'T' at position " + tt.getStartPosition() + " in "+ str);
}
p.x=tt.nval;
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("y coordinate missing for 'T' at position " + tt.getStartPosition() + " in "+ str);
}
p.y=tt.nval;
path.quadTo(c1.x,c1.y,p.x,p.y);
nextCommand='T';
break;
case 't':
node=path.get(path.size() - 1);
c1.x=node.x[0] * 2d - node.x[1];
c1.y=node.y[0] * 2d - node.y[1];
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("dx coordinate missing for 't' at position " + tt.getStartPosition() + " in "+ str);
}
p.x+=tt.nval;
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("dy coordinate missing for 't' at position " + tt.getStartPosition() + " in "+ str);
}
p.y+=tt.nval;
path.quadTo(c1.x,c1.y,p.x,p.y);
nextCommand='s';
break;
case 'A':
{
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("rx coordinate missing for 'A' at position " + tt.getStartPosition() + " in "+ str);
}
double rx=tt.nval;
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("ry coordinate missing for 'A' at position " + tt.getStartPosition() + " in "+ str);
}
double ry=tt.nval;
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("x-axis-rotation missing for 'A' at position " + tt.getStartPosition() + " in "+ str);
}
double xAxisRotation=tt.nval;
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("large-arc-flag missing for 'A' at position " + tt.getStartPosition() + " in "+ str);
}
boolean largeArcFlag=tt.nval != 0;
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("sweep-flag missing for 'A' at position " + tt.getStartPosition() + " in "+ str);
}
boolean sweepFlag=tt.nval != 0;
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("x coordinate missing for 'A' at position " + tt.getStartPosition() + " in "+ str);
}
p.x=tt.nval;
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("y coordinate missing for 'A' at position " + tt.getStartPosition() + " in "+ str);
}
p.y=tt.nval;
path.arcTo(rx,ry,xAxisRotation,largeArcFlag,sweepFlag,p.x,p.y);
nextCommand='A';
break;
}
case 'a':
{
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("rx coordinate missing for 'A' at position " + tt.getStartPosition() + " in "+ str);
}
double rx=tt.nval;
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("ry coordinate missing for 'A' at position " + tt.getStartPosition() + " in "+ str);
}
double ry=tt.nval;
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("x-axis-rotation missing for 'A' at position " + tt.getStartPosition() + " in "+ str);
}
double xAxisRotation=tt.nval;
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("large-arc-flag missing for 'A' at position " + tt.getStartPosition() + " in "+ str);
}
boolean largeArcFlag=tt.nval != 0;
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("sweep-flag missing for 'A' at position " + tt.getStartPosition() + " in "+ str);
}
boolean sweepFlag=tt.nval != 0;
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("x coordinate missing for 'A' at position " + tt.getStartPosition() + " in "+ str);
}
p.x+=tt.nval;
if (tt.nextToken() != StreamPosTokenizer.TT_NUMBER) {
throw new IOException("y coordinate missing for 'A' at position " + tt.getStartPosition() + " in "+ str);
}
p.y+=tt.nval;
path.arcTo(rx,ry,xAxisRotation,largeArcFlag,sweepFlag,p.x,p.y);
nextCommand='a';
break;
}
default :
if (DEBUG) {
System.out.println("SVGInputFormat.toPath aborting after illegal path command: " + command + " found in path "+ str);
}
break Commands;
}
}
if (path != null) {
paths.add(path);
}
return paths.toArray(new BezierPath[paths.size()]);
}
| Returns a value as a BezierPath array. as specified in http://www.w3.org/TR/SVGMobile12/shapes.html#PointsBNF Also supports elliptical arc commands 'a' and 'A' as specified in http://www.w3.org/TR/SVG/paths.html#PathDataEllipticalArcCommands |
public RefinedSoundex(){
this(US_ENGLISH_MAPPING);
}
| Creates an instance of the RefinedSoundex object using the default US English mapping. |
public Builder html(Boolean isHtml){
this.isHtml=isHtml;
return this;
}
| Sets the text as HTML. |
public SaaSSystemException(String arg0,Throwable arg1){
super(arg0,arg1);
genId();
this.setCauseStackTrace(arg1);
}
| Constructs a new exception with the specified detail message and cause. |
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(value="EI_EXPOSE_REP") public String[] validBaudRates(){
return validSpeeds;
}
| Get an array of valid baud rates. |
private static String escapeSequence(char ch,int radix,int nDigits){
StringBuilder sb=new StringBuilder(nDigits);
sb.append(Integer.toString(ch,radix));
while (sb.length() < nDigits) {
sb.insert(0,'0');
}
return sb.toString();
}
| Generates the numeric portion of an octal, hex, or unicode escape sequence. |
public final boolean isStatic(){
return Modifier.isStatic(getModifiers());
}
| Returns true if the element is static. |
public void onTextTrackLocaleChanged(Locale locale){
LOGD(TAG,"onTextTrackLocaleChanged() reached");
for ( VideoCastConsumer consumer : mVideoConsumers) {
consumer.onTextTrackLocaleChanged(locale);
}
}
| Signals a change in the Text Track locale. Clients should not call this directly. |
@DSGenerator(tool_name="Doppelganger",tool_version="2.0",generated_on="2013-12-30 12:34:16.602 -0500",hash_original_method="48FF7A4A9E39F0BE519CF2AE778248C7",hash_generated_method="39F2C28974131F406B092D9E374533EF") public GradientDrawable(Orientation orientation,int[] colors){
this(new GradientState(orientation,colors));
}
| Create a new gradient drawable given an orientation and an array of colors for the gradient. |
private static boolean isUnexpectedBug(BugInstance bug){
return FB_MISSING_EXPECTED_WARNING.equals(bug.getType()) || FB_UNEXPECTED_WARNING.equals(bug.getType());
}
| Returns if a bug instance is unexpected for this test. |
public RegionItemProvider(AdapterFactory adapterFactory){
super(adapterFactory);
}
| This constructs an instance from a factory and a notifier. <!-- begin-user-doc --> <!-- end-user-doc --> |
private LossAction(String name){
this.name=name;
}
| Creates a new instance of LossAction. |
public Builder streams(List<String> streams){
this._streams=streams;
return this;
}
| Set the list of streams to write to. |
private void verifyErrorPayload(JavaResult javaResult) throws Exception {
EchoCommand command=javaResult.getBean(EchoCommand.class);
if (null == command || null == command.getStatus() || HDSConstants.FAILED_STR.equalsIgnoreCase(command.getStatus())) {
Error error=javaResult.getBean(Error.class);
log.info("Error response received for messageID",command.getMessageID());
log.info("command failed with error code: {} with message {}",error.getCode(),error.getDescription());
throw HDSException.exceptions.errorResponseReceived(error.getCode(),error.getDescription());
}
}
| Utility method to check if there are any errors or not. |
protected StoragePool checkStoragePoolExistsInDB(String nativeGuid) throws IOException {
StoragePool pool=null;
@SuppressWarnings("deprecation") List<URI> poolURIs=_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePoolByNativeGuidConstraint(nativeGuid));
for ( URI poolURI : poolURIs) {
pool=_dbClient.queryObject(StoragePool.class,poolURI);
if (pool != null && !pool.getInactive()) {
return pool;
}
}
return null;
}
| Check if Pool exists in DB. |
protected static String _escapeQuotesAndBackslashes(String s){
final StringBuilder buf=new StringBuilder(s);
for (int i=s.length() - 1; i >= 0; i--) {
char c=s.charAt(i);
if ((c == '\\') || (c == '"')) {
buf.insert(i,'\\');
}
else if (c == '\n') {
buf.deleteCharAt(i);
buf.insert(i,"\\n");
}
else if (c == '\t') {
buf.deleteCharAt(i);
buf.insert(i,"\\t");
}
else if (c == '\r') {
buf.deleteCharAt(i);
buf.insert(i,"\\r");
}
else if (c == '\b') {
buf.deleteCharAt(i);
buf.insert(i,"\\b");
}
else if (c == '\f') {
buf.deleteCharAt(i);
buf.insert(i,"\\f");
}
}
return buf.toString();
}
| Inserts backslashes before any occurrences of a backslash or quote in the given string. Also converts any special characters appropriately. |
public static boolean verify(JSONObject obj,PublicKey key) throws SignatureException, InvalidKeyException {
if (!obj.has(signatureString)) throw new SignatureException("No signature supplied");
Signature signature;
try {
signature=Signature.getInstance("SHA256withRSA");
}
catch ( NoSuchAlgorithmException e) {
return false;
}
String sigString=obj.getString(signatureString);
byte[] sig=Base64.getDecoder().decode(sigString);
obj.remove(signatureString);
signature.initVerify(key);
signature.update(obj.toString().getBytes(StandardCharsets.UTF_8));
boolean res=signature.verify(sig);
obj.put(signatureString,sigString);
return res;
}
| Verfies if the signature of a JSONObject is valid |
@Override public int eDerivedStructuralFeatureID(int baseFeatureID,Class<?> baseClass){
if (baseClass == TypableElement.class) {
switch (baseFeatureID) {
default :
return -1;
}
}
if (baseClass == TypeDefiningElement.class) {
switch (baseFeatureID) {
case N4JSPackage.TYPE_DEFINING_ELEMENT__DEFINED_TYPE:
return N4JSPackage.N4_TYPE_DEFINITION__DEFINED_TYPE;
default :
return -1;
}
}
return super.eDerivedStructuralFeatureID(baseFeatureID,baseClass);
}
| <!-- begin-user-doc --> <!-- end-user-doc --> |
public void clearParameters(){
m_Rows.clear();
m_Labels.clear();
m_Parameters.clear();
update();
}
| Removes all parameters. |
public boolean writeNextPart(byte[] data) throws JPlagException {
if (remainingBytes < data.length) {
throw new JPlagException("uploadException","More data sent " + "than expected!","");
}
try {
FileOutputStream out=new FileOutputStream(file,true);
out.write(data);
out.close();
remainingBytes-=data.length;
}
catch ( IOException e) {
e.printStackTrace();
throw new JPlagException("uploadException","Unable to save " + "submission part on the server!","Server out of disk space??");
}
return remainingBytes == 0;
}
| Writes the next part of the related file |
public boolean equals(Object o){
if (o == null) return false;
if (o instanceof OnePuzzle) {
OnePuzzle op=(OnePuzzle)o;
return op.s == s;
}
return false;
}
| Must implement equals |
public void addAttribute(String name,final String value){
if (m_elemContext.m_startTagOpen) {
final String patchedName=patchName(name);
final String localName=getLocalName(patchedName);
final String uri=getNamespaceURI(patchedName,false);
addAttributeAlways(uri,localName,patchedName,"CDATA",value,false);
}
}
| Adds the given attribute to the set of collected attributes, but only if there is a currently open element. |
protected synchronized byte[] engineGenerateSeed(int numBytes){
byte[] myBytes;
if (numBytes < 0) {
throw new NegativeArraySizeException(Integer.toString(numBytes));
}
if (numBytes == 0) {
return EmptyArray.BYTE;
}
if (myRandom == null) {
myRandom=new SHA1PRNG_SecureRandomImpl();
myRandom.engineSetSeed(getRandomBytes(DIGEST_LENGTH));
}
myBytes=new byte[numBytes];
myRandom.engineNextBytes(myBytes);
return myBytes;
}
| Returns a required number of random bytes. <BR> The method overrides "engineGenerateSeed (int)" in class SecureRandomSpi. <BR> |
public static String saltString(byte[] salt){
return Base64.encodeToString(salt,BASE64_FLAGS);
}
| Converts the given salt into a base64 encoded string suitable for storage. |
public static int confirmPrint(MPaySelectionCheck[] checks,MPaymentBatch batch){
int lastDocumentNo=0;
for (int i=0; i < checks.length; i++) {
MPaySelectionCheck check=checks[i];
MPayment payment=new MPayment(check.getCtx(),check.getC_Payment_ID(),check.get_TrxName());
if (check.getC_Payment_ID() != 0) {
if (check.getPaymentRule().equals(PAYMENTRULE_Check)) {
payment.setCheckNo(check.getDocumentNo());
if (!payment.save()) s_log.log(Level.SEVERE,"Payment not saved: " + payment);
}
}
else {
payment=new MPayment(check.getCtx(),0,check.get_TrxName());
payment.setAD_Org_ID(check.getAD_Org_ID());
if (check.getPaymentRule().equals(PAYMENTRULE_Check)) payment.setBankCheck(check.getParent().getC_BankAccount_ID(),false,check.getDocumentNo());
else if (check.getPaymentRule().equals(PAYMENTRULE_CreditCard)) payment.setTenderType(X_C_Payment.TENDERTYPE_CreditCard);
else if (check.getPaymentRule().equals(PAYMENTRULE_DirectDeposit) || check.getPaymentRule().equals(PAYMENTRULE_DirectDebit)) payment.setBankACH(check);
else {
s_log.log(Level.SEVERE,"Unsupported Payment Rule=" + check.getPaymentRule());
continue;
}
payment.setTrxType(X_C_Payment.TRXTYPE_CreditPayment);
payment.setAmount(check.getParent().getC_Currency_ID(),check.getPayAmt());
payment.setDiscountAmt(check.getDiscountAmt());
payment.setDateTrx(check.getParent().getPayDate());
payment.setDateAcct(payment.getDateTrx());
payment.setC_BPartner_ID(check.getC_BPartner_ID());
if (batch != null) {
if (batch.getC_PaymentBatch_ID() == 0) batch.saveEx();
payment.setC_PaymentBatch_ID(batch.getC_PaymentBatch_ID());
}
MPaySelectionLine[] psls=check.getPaySelectionLines(false);
s_log.fine("confirmPrint - " + check + " (#SelectionLines="+ psls.length+ ")");
if (check.getQty() == 1 && psls != null && psls.length == 1) {
MPaySelectionLine psl=psls[0];
s_log.fine("Map to Invoice " + psl);
payment.setC_Invoice_ID(psl.getC_Invoice_ID());
payment.setDiscountAmt(psl.getDiscountAmt());
payment.setWriteOffAmt(psl.getDifferenceAmt());
BigDecimal overUnder=psl.getOpenAmt().subtract(psl.getPayAmt()).subtract(psl.getDiscountAmt()).subtract(psl.getDifferenceAmt());
payment.setOverUnderAmt(overUnder);
}
else payment.setDiscountAmt(Env.ZERO);
payment.setWriteOffAmt(Env.ZERO);
if (!payment.save()) s_log.log(Level.SEVERE,"Payment not saved: " + payment);
int C_Payment_ID=payment.get_ID();
if (C_Payment_ID < 1) s_log.log(Level.SEVERE,"Payment not created=" + check);
else {
check.setC_Payment_ID(C_Payment_ID);
check.saveEx();
payment.processIt(DocAction.ACTION_Complete);
if (!payment.save()) s_log.log(Level.SEVERE,"Payment not saved: " + payment);
}
}
try {
int no=Integer.parseInt(check.getDocumentNo());
if (lastDocumentNo < no) lastDocumentNo=no;
}
catch ( NumberFormatException ex) {
s_log.log(Level.SEVERE,"DocumentNo=" + check.getDocumentNo(),ex);
}
check.setIsPrinted(true);
check.setProcessed(true);
if (!check.save()) s_log.log(Level.SEVERE,"Check not saved: " + check);
}
s_log.fine("Last Document No = " + lastDocumentNo);
return lastDocumentNo;
}
| Confirm Print. Create Payments the first time |
private Instruction do_iload(int index){
Operand r=getLocal(index);
if (VM.VerifyAssertions) opt_assert(r.isIntLike());
if (LOCALS_ON_STACK) {
push(r);
return null;
}
else {
return _moveHelper(INT_MOVE,r,TypeReference.Int);
}
}
| Simulates a load from a given local variable of an int. |
private StringBuffer buildStartContents(String period,String url){
StringBuffer out=new StringBuffer();
out.append("<script language='javascript'>\n");
out.append("// FUNCIONES KEEP-ALIVE\n");
out.append("var xmlhttp=false;\n");
out.append("function xmlHttpResquestInit () {\n");
out.append("if (window.XMLHttpRequest) {\n");
out.append("xmlhttp = new XMLHttpRequest();\n");
out.append("if (xmlhttp.overrideMimeType)\n");
out.append("xmlhttp.overrideMimeType('text/xml');\n");
out.append("}else if (window.ActiveXObject) {\n");
out.append("try {\n");
out.append("xmlhttp = new ActiveXObject ('Msxml2.XMLHTTP');\n");
out.append("} catch (e) {\n");
out.append("try {\n");
out.append("xmlhttp = new ActiveXObject ('Microsoft.XMLHTTP');\n");
out.append("} catch (E) {\n");
out.append("xmlhttp = false; \n} \n} \n} \n}\n");
out.append("function keepAliveInit()\n{\n");
out.append("xmlHttpResquestInit ();\n");
out.append("window.setInterval ('keepAliveRefresh()',");
out.append(period + "); \n}\n");
out.append("function keepAliveRefresh() {\n");
out.append("xmlhttp.open ('GET', '" + url + "', true);\n");
out.append("xmlhttp.onreadystatechange=function () {\n");
out.append("if (xmlhttp.readyState==4) {}\n");
out.append("\n}\n");
out.append("xmlhttp.send (null); \n}\n");
out.append("// FIN FUNCIONES KEEP-ALIVE\n");
out.append("keepAliveInit();");
out.append("</script>\n");
return out;
}
| Genera el js que realiza la recarga de la pagiga cada cierto tiempo |
private int update(){
int counter=0;
String sql="SELECT * FROM M_Cost c WHERE M_CostElement_ID=?";
if (p_M_Product_Category_ID != 0) sql+=" AND EXISTS (SELECT * FROM M_Product p " + "WHERE c.M_Product_ID=p.M_Product_ID AND p.M_Product_Category_ID=?)";
PreparedStatement pstmt=null;
try {
pstmt=DB.prepareStatement(sql,null);
pstmt.setInt(1,m_ce.getM_CostElement_ID());
if (p_M_Product_Category_ID != 0) pstmt.setInt(2,p_M_Product_Category_ID);
ResultSet rs=pstmt.executeQuery();
while (rs.next()) {
MCost cost=new MCost(getCtx(),rs,get_TrxName());
for (int i=0; i < m_ass.length; i++) {
if (m_ass[i].getC_AcctSchema_ID() == cost.getC_AcctSchema_ID() && m_ass[i].getM_CostType_ID() == cost.getM_CostType_ID()) {
if (update(cost)) counter++;
}
}
}
rs.close();
pstmt.close();
pstmt=null;
}
catch ( Exception e) {
log.log(Level.SEVERE,sql,e);
}
try {
if (pstmt != null) pstmt.close();
pstmt=null;
}
catch ( Exception e) {
pstmt=null;
}
log.info("#" + counter);
addLog(0,null,new BigDecimal(counter),"@Updated@");
return counter;
}
| Update Cost Records |
@POST @Produces({MediaType.APPLICATION_XML,MediaType.APPLICATION_JSON}) @Path("/{id}/protection/continuous-copies/resume") @CheckPermission(roles={Role.TENANT_ADMIN},acls={ACL.OWN,ACL.ALL}) public TaskList resumeContinuousCopies(@PathParam("id") URI id,FileReplicationParam param) throws ControllerException {
ArgValidator.checkFieldUriType(id,FileShare.class,"id");
return performFileProtectionAction(param,id,ProtectionOp.RESUME.getRestOp());
}
| Resume continuous copies for given source fileshare NOTE: This is an asynchronous operation. |
@Override public void write(DataOutput out) throws IOException {
this.key.write(out);
this.value.write(out);
}
| Serialize the fields of this object to <code>out</code>. |
private void validateTagTypeCreateRequest(TagTypeCreateRequest request){
Assert.notNull(request,"A tag type create request must be specified.");
tagTypeHelper.validateTagTypeKey(request.getTagTypeKey());
request.setDisplayName(alternateKeyHelper.validateStringParameter("display name",request.getDisplayName()));
Assert.notNull(request.getTagTypeOrder(),"A tag type order must be specified.");
}
| Validates the tag type create request. This method also trims the request parameters. |
protected Entry<Integer,List<Solution>> draw(){
int index=PRNG.nextInt(gridMap.size());
Iterator<Entry<Integer,List<Solution>>> iterator=gridMap.entrySet().iterator();
while (iterator.hasNext()) {
Entry<Integer,List<Solution>> entry=iterator.next();
if (index == 0) {
return entry;
}
else {
index--;
}
}
throw new NoSuchElementException();
}
| Draws a random entry from the map. |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.