code
stringlengths 10
174k
| nl
stringlengths 3
129k
|
---|---|
public void evaluate(ClassificationTester tester,View goldView,View predictionView){
super.cleanAttributes(goldView,predictionView);
this.gold=(CoreferenceView)goldView;
this.prediction=(CoreferenceView)predictionView;
List<Constituent> allGoldConstituents=gold.getConstituents();
for ( Constituent cons : allGoldConstituents) {
HashSet<Constituent> overlappingGoldCanonicalCons=gold.getOverlappingChainsCanonicalMentions(cons);
HashSet<Constituent> overlappingPredCanonicalCons=prediction.getOverlappingChainsCanonicalMentions(cons);
int overlapCount=0;
int predCount=0;
int goldCount=0;
for ( Constituent predCanonicalCons : overlappingPredCanonicalCons) {
HashSet consInPredCluster=new HashSet(prediction.getCoreferentMentionsViaRelations(predCanonicalCons));
for ( Constituent goldCanonicalCons : overlappingGoldCanonicalCons) {
HashSet consInGoldCluster=new HashSet(gold.getCoreferentMentionsViaRelations(goldCanonicalCons));
Set<String> intersection=new HashSet(consInGoldCluster);
intersection.retainAll(consInPredCluster);
overlapCount+=intersection.size();
predCount+=consInPredCluster.size();
goldCount+=consInGoldCluster.size();
}
}
tester.recordCount(cons.toString(),goldCount,predCount,overlapCount);
}
}
| The result will be populated in a ClassificationTester. Note that you can either use "micro" or "macro" statistics. It is more common to use "macro" statistics for BCubed metric. |
public static String encodeValue(Instance x,int indices[]){
int values[]=new int[indices.length];
for (int j=0; j < indices.length; j++) {
values[j]=(int)x.value(indices[j]);
}
return new LabelVector(values).toString();
}
| Encode a vector of integer values to a string |
public static @Nonnull SourceLineAnnotation fromVisitedInstructionRange(ClassContext classContext,PreorderVisitor visitor,int startPC,int endPC){
if (startPC > endPC) {
throw new IllegalArgumentException("Start pc " + startPC + " greater than end pc "+ endPC);
}
LineNumberTable lineNumberTable=getLineNumberTable(visitor);
String className=visitor.getDottedClassName();
String sourceFile=visitor.getSourceFile();
if (lineNumberTable == null) {
return createUnknown(className,sourceFile,startPC,endPC);
}
int startLine=lineNumberTable.getSourceLine(startPC);
int endLine=lineNumberTable.getSourceLine(endPC);
return new SourceLineAnnotation(className,sourceFile,startLine,endLine,startPC,endPC);
}
| Factory method for creating a source line annotation describing the source line numbers for a range of instructions in the method being visited by the given visitor. |
public static Builder createBuilder(Header header,WritableFontData data){
return new Builder(header,data);
}
| Create a new builder using the header information and data provided. |
public static <T>String join(T[] array,String separator){
return join(Arrays.asList(array),separator);
}
| Creates a String of all elements of an array, separated by a separator. |
private void traverseAndResolveTree(FilterResolverIntf filterResolverTree,AbsoluteTableIdentifier tableIdentifier) throws FilterUnsupportedException {
if (null == filterResolverTree) {
return;
}
traverseAndResolveTree(filterResolverTree.getLeft(),tableIdentifier);
filterResolverTree.resolve(tableIdentifier);
traverseAndResolveTree(filterResolverTree.getRight(),tableIdentifier);
}
| constructing the filter resolver tree based on filter expression. this method will visit each node of the filter resolver and prepares the surrogates of the filter members which are involved filter expression. |
@DSSpec(DSCat.IO) @DSSource({DSSourceKind.IO}) @DSGenerator(tool_name="Doppelganger",tool_version="2.0",generated_on="2013-12-30 12:56:45.243 -0500",hash_original_method="856B18E0C9E8549741083F490D54C8D8",hash_generated_method="D61B634BAB1210C26ADCEAB5B21DE464") public final int readUnsignedShort() throws IOException {
return ((int)readShort()) & 0xffff;
}
| Reads an unsigned big-endian 16-bit short from the current position in this file and returns it as an integer. Blocks until two bytes have been read, the end of the file is reached or an exception is thrown. |
public void init() throws IOException {
active=true;
for ( SelectorThread t : selectorThreads) {
t.start();
}
listenersMap.entrySet().forEach(null);
}
| Initializes the communication core, starting its communication listeners. This method is asynchronous. When it returns, every communication listener has been issued to start, but they are not guaranteed to be ready to receive messages. This method throws an exception if some listener cannot be issued to start; other errors will be logged by the listener through the interpreter logger. |
public String[] validBaudRates(){
log.debug("validBaudRates should not have been invoked");
return null;
}
| Get an array of valid baud rates. |
@Override public UserSession findSession(UUID sessionId){
return sessions.get(sessionId,false);
}
| Search for session in cache. |
private void showFeedback(String message){
if (myHost != null) {
myHost.showFeedback(message);
}
else {
System.out.println(message);
}
}
| Used to communicate feedback pop-up messages between a plugin tool and the main Whitebox user-interface. |
public List<Annotation> batchCopyAnnotations(List<Annotation> annoList){
batchCopyAnnoList=annoList;
List<Annotation> returnList=new ArrayList<Annotation>();
for ( Annotation anno : batchCopyAnnoList) {
returnList.add((Annotation)copyFs(anno));
}
batchCopyAnnoList=null;
return returnList;
}
| Performs batch-copying of Annotations (could also be generalized to FeatureStructures) While copying the annotations, the whole batch is held in a class attribute. This way, we can cope with referenced annotations that have not been copied/recovered yet. |
protected void addNamePropertyDescriptor(Object object){
itemPropertyDescriptors.add(createItemPropertyDescriptor(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),getResourceLocator(),getString("_UI_NamedElement_name_feature"),getString("_UI_PropertyDescriptor_description","_UI_NamedElement_name_feature","_UI_NamedElement_type"),BasePackage.Literals.NAMED_ELEMENT__NAME,true,false,false,ItemPropertyDescriptor.GENERIC_VALUE_IMAGE,null,null));
}
| This adds a property descriptor for the Name feature. <!-- begin-user-doc --> <!-- end-user-doc --> |
public void sendPacket(byte[] packet,int count){
}
| CommandStation implementation, not yet supported |
public <T extends DataObject>Iterator<T> iterator(String alias,URI joinMapKey){
JClass jc=lookupAlias(alias);
Map<URI,Set<URI>> joinMap=jc.getJoinMap();
if (joinMap == null) {
return new HashSet<T>().iterator();
}
Set<URI> uriSet=joinMap.get(joinMapKey);
if (joinMap.get(joinMapKey) == null) {
return new HashSet<T>().iterator();
}
return new JClassIterator(jc,engine,uriSet.iterator());
}
| Returns a partial result iterator for the given Class Query by looking up the URIs for a given join map key (i.e. the id from the joinTo). So for example if A is directly joined to B, and you invoke this on the bAlias, then the joinMapKey would be a URI from A. All the corresponding B results for for given A key are returned. |
protected <E>RepositoryResult<E> createRepositoryResult(Iterable<? extends E> elements){
return new RepositoryResult<E>(new CloseableIteratorIteration<E,RepositoryException>(elements.iterator()));
}
| Creates a RepositoryResult for the supplied element set. |
@Override public void increment(double coord,long value){
if (cachefill >= 0) {
if (cachefill < cachec.length) {
cachec[cachefill]=coord;
cachev[cachefill]=value;
cachefill++;
return;
}
else {
materialize();
}
}
testResample(coord);
super.increment(coord,value);
}
| Put fresh data into the histogram (or into the cache) |
public PlaylistGrouperMediaNode(BasicMediaSource inSource,BasicMediaNode inParent,sage.Playlist inGroupObject,boolean showKids){
super(inSource,inParent,inGroupObject.getName(),DATATYPE_PLAYLIST,inGroupObject);
myPlaylist=inGroupObject;
this.showKids=showKids;
}
| Creates a new instance of SimpleGrouperMediaFileNode |
protected Size2D arrangeFN(BlockContainer container,Graphics2D g2,RectangleConstraint constraint){
List blocks=container.getBlocks();
double width=constraint.getWidth();
double x=0.0;
double y=0.0;
double maxHeight=0.0;
List itemsInRow=new ArrayList();
for (int i=0; i < blocks.size(); i++) {
Block block=(Block)blocks.get(i);
Size2D size=block.arrange(g2,RectangleConstraint.NONE);
if (x + size.width <= width) {
itemsInRow.add(block);
block.setBounds(new Rectangle2D.Double(x,y,size.width,size.height));
x=x + size.width + this.horizontalGap;
maxHeight=Math.max(maxHeight,size.height);
}
else {
if (itemsInRow.isEmpty()) {
block.setBounds(new Rectangle2D.Double(x,y,Math.min(size.width,width - x),size.height));
x=0.0;
y=y + size.height + this.verticalGap;
}
else {
itemsInRow.clear();
x=0.0;
y=y + maxHeight + this.verticalGap;
maxHeight=size.height;
block.setBounds(new Rectangle2D.Double(x,y,Math.min(size.width,width),size.height));
x=size.width + this.horizontalGap;
itemsInRow.add(block);
}
}
}
return new Size2D(constraint.getWidth(),y + maxHeight);
}
| Arranges the blocks in the container with a fixed width and no height constraint. |
public String toString(){
long diff=diff();
long millis=diff % 1000;
long secs=(diff / 1000) % 60;
long mins=(diff / (1000 * 60)) % 60;
long hs=(diff / (1000 * 3600)) % 24;
long days=diff / (1000 * 3600 * 24);
if (days > 0) return days + "d " + hs+ "h "+ mins+ "m "+ secs+ "s "+ millis+ "ms";
if (hs > 0) return hs + "h " + mins+ "m "+ secs+ "s "+ millis+ "ms";
if (mins > 0) return mins + "m " + secs+ "s "+ millis+ "ms";
if (secs > 0) return secs + "s " + millis+ "ms";
return millis + "ms";
}
| Return a string representation of the timer. |
private static SslError verifyServerDomainAndCertificates(X509Certificate[] chain,String domain,String authType) throws IOException {
X509Certificate currCertificate=chain[0];
if (currCertificate == null) {
throw new IllegalArgumentException("certificate for this site is null");
}
boolean valid=domain != null && !domain.isEmpty() && sVerifier.verify(domain,currCertificate);
if (!valid) {
if (HttpLog.LOGV) {
HttpLog.v("certificate not for this host: " + domain);
}
return new SslError(SslError.SSL_IDMISMATCH,currCertificate);
}
try {
X509TrustManager x509TrustManager=SSLParametersImpl.getDefaultTrustManager();
if (x509TrustManager instanceof TrustManagerImpl) {
TrustManagerImpl trustManager=(TrustManagerImpl)x509TrustManager;
trustManager.checkServerTrusted(chain,authType,domain);
}
else {
x509TrustManager.checkServerTrusted(chain,authType);
}
return null;
}
catch ( GeneralSecurityException e) {
if (HttpLog.LOGV) {
HttpLog.v("failed to validate the certificate chain, error: " + e.getMessage());
}
return new SslError(SslError.SSL_UNTRUSTED,currCertificate);
}
}
| Common code of doHandshakeAndValidateServerCertificates and verifyServerCertificates. Calls DomainNamevalidator to verify the domain, and TrustManager to verify the certs. |
public Entity defineEntity(String name,int type,char data[]){
Entity ent=entityHash.get(name);
if (ent == null) {
ent=new Entity(name,type,data);
entityHash.put(name,ent);
if (((type & GENERAL) != 0) && (data.length == 1)) {
switch (type & ~GENERAL) {
case CDATA:
case SDATA:
entityHash.put(Integer.valueOf(data[0]),ent);
break;
}
}
}
return ent;
}
| Defines an entity. If the <code>Entity</code> specified by <code>name</code>, <code>type</code>, and <code>data</code> exists, it is returned; otherwise a new <code>Entity</code> is created and is returned. |
@DSGenerator(tool_name="Doppelganger",tool_version="2.0",generated_on="2014-02-24 14:42:09.179 -0500",hash_original_method="5FE57D2E7B335A053FA4B0E269FB9FA5",hash_generated_method="9F0D9977F43D85DB151F9F0E50619FCB") @DSVerified @DSSafe(DSCat.SAFE_LIST) @Override public V put(K key,V value){
return super.put(key,value);
}
| Maps the specified key to the specified value. |
protected void init(List srcs){
touch();
this.srcs=new Vector(srcs);
}
| Initialize an Abstract Rable from a list of sources, and possibly a bounds. This can be called long after the object is constructed to reset the state of the Renderable. |
private static String decodeFileName(String fileName){
String decodedFile=fileName;
try {
decodedFile=URLDecoder.decode(fileName,"UTF-8");
}
catch ( UnsupportedEncodingException e) {
System.err.println("Encountered an invalid encoding scheme when trying to use URLDecoder.decode() inside of the GroovyClassLoader.decodeFileName() method. Returning the unencoded URL.");
System.err.println("Please note that if you encounter this error and you have spaces in your directory you will run into issues. Refer to GROOVY-1787 for description of this bug.");
}
return decodedFile;
}
| This method will take a file name and try to "decode" any URL encoded characters. For example if the file name contains any spaces this method call will take the resulting %20 encoded values and convert them to spaces. <p> This method was added specifically to fix defect: Groovy-1787. The defect involved a situation where two scripts were sitting in a directory with spaces in its name. The code would fail when the class loader tried to resolve the file name and would choke on the URLEncoded space values. |
public static boolean isNetworkUri(@Nullable Uri uri){
final String scheme=getSchemeOrNull(uri);
return HTTPS_SCHEME.equals(scheme) || HTTP_SCHEME.equals(scheme);
}
| / Check if uri represents network resource |
@Contract("null,_ -> false") public static boolean checkAnnotatedUsingPatterns(@Nullable PsiModifierListOwner owner,@NotNull Collection<String> annotations){
final PsiModifierList modList;
if (owner == null || (modList=owner.getModifierList()) == null) return false;
List<String> fqns=null;
for ( String fqn : annotations) {
boolean isPattern=fqn.endsWith("*");
if (!isPattern && isAnnotated(owner,fqn,false)) {
return true;
}
else if (isPattern) {
if (fqns == null) {
fqns=new ArrayList<String>();
final PsiAnnotation[] annos=modList.getAnnotations();
for ( PsiAnnotation anno : annos) {
final String qName=anno.getQualifiedName();
if (qName != null) {
fqns.add(qName);
}
}
if (fqns.isEmpty()) return false;
}
fqn=fqn.substring(0,fqn.length() - 2);
for ( String annoFQN : fqns) {
if (annoFQN.startsWith(fqn)) {
return true;
}
}
}
}
return false;
}
| Works similar to #isAnnotated(PsiModifierListOwner, Collection<String>) but supports FQN patters like "javax.ws.rs.*". Supports ending "*" only. |
public RPRecord(Name name,int dclass,long ttl,Name mailbox,Name textDomain){
super(name,Type.RP,dclass,ttl);
this.mailbox=checkName("mailbox",mailbox);
this.textDomain=checkName("textDomain",textDomain);
}
| Creates an RP Record from the given data |
public FilterQuery(final long[] follow){
this();
count=0;
this.follow=follow;
}
| Creates a new FilterQuery |
public LoadFileAction(Application app,@Nullable View view){
super(app,view);
ResourceBundleUtil labels=ResourceBundleUtil.getBundle("org.jhotdraw.app.Labels");
labels.configureAction(this,ID);
}
| Creates a new instance. |
public void removeNetworkListener(NetworkListener networkListener){
networkListeners.remove(networkListener);
}
| Remove a network listener. |
public static <K,V>HashMap<K,V> hashMapNonRehash(int initialCapacity){
int size=(int)(initialCapacity / 0.75) + 1;
return new HashMap<K,V>(size);
}
| Create a new HashMap. |
private void updateProgress(int progress){
if (myHost != null && progress != previousProgress) {
myHost.updateProgress(progress);
}
previousProgress=progress;
}
| Used to communicate a progress update between a plugin tool and the main Whitebox user interface. |
public void runTest() throws Throwable {
Document doc;
NodeList elementList;
Node nameNode;
CharacterData child;
String childData;
doc=(Document)load("staff",true);
elementList=doc.getElementsByTagName("address");
nameNode=elementList.item(0);
child=(CharacterData)nameNode.getFirstChild();
child.deleteData(0,16);
childData=child.getData();
assertEquals("characterdataDeleteDataBeginingAssert","Dallas, Texas 98551",childData);
}
| Runs the test case. |
public static synchronized boolean isOriginLabeled(){
return originLabeled;
}
| Returns true if the origin and origin label should be shown. |
public void createSoldiers(StendhalRPZone zone){
createSoldier(zone,"Soldier",55,47);
createSoldier(zone,"Soldier",56,47);
createSoldier(zone,"Soldier",57,47);
createSoldier(zone,"Soldier",43,23);
}
| Creates three soldiers to block the entrance |
@Override protected void rehash(int newCapacity){
int oldCapacity=_set.length;
int[] oldKeys=_set;
long[] oldVals=_values;
byte[] oldStates=_states;
_set=new int[newCapacity];
_values=new long[newCapacity];
_states=new byte[newCapacity];
for (int i=oldCapacity; i-- > 0; ) {
if (oldStates[i] == FULL) {
int o=oldKeys[i];
int index=insertionIndex(o);
_set[index]=o;
_values[index]=oldVals[i];
_states[index]=FULL;
}
}
}
| rehashes the map to the new capacity. |
private void updateProgress(String progressLabel,int progress){
if (myHost != null && ((progress != previousProgress) || (!progressLabel.equals(previousProgressLabel)))) {
myHost.updateProgress(progressLabel,progress);
}
previousProgress=progress;
previousProgressLabel=progressLabel;
}
| Used to communicate a progress update between a plugin tool and the main Whitebox user interface. |
public static byte[] toByteArray(URL url) throws IOException {
return asByteSource(url).read();
}
| Reads all bytes from a URL into a byte array. |
public static float impulse(float k,float t){
float h=k * t;
return (float)(h * Math.exp(1.0f - h));
}
| Creates a single normalized impulse signal with its peak at t=1/k. The attack and decay period is configurable via the k parameter. Code from: http://www.iquilezles.org/www/articles/functions/functions.htm |
public Adapter createEObjectAdapter(){
return null;
}
| Creates a new adapter for the default case. <!-- begin-user-doc --> This default implementation returns null. <!-- end-user-doc --> |
@Override public void merge(MeasureAggregator aggregator){
MaxAggregator maxAggregator=(MaxAggregator)aggregator;
if (!aggregator.isFirstTime()) {
agg(maxAggregator.aggVal);
firstTime=false;
}
}
| Merge the value, it will update the max aggregate value if aggregator passed as an argument will have value greater than aggVal |
public static void deletePage(final IdocScanInterface ui){
FileVO ele=(FileVO)ui.getFileVO();
List<ImageVO> listImage=ele.getListImage();
if (listImage != null && listImage.size() > 0 && ele.getImageSelectIndex() > -1) {
ImageVO imageVO=(ImageVO)listImage.get(ele.getImageSelectIndex());
listImage.remove(ele.getImageSelectIndex());
ele.setImageSelectIndex(0);
delete(imageVO.getImage());
}
}
| Evento que borra la foto escaneada. |
static CompilationWatchDog watch(ResolvedJavaMethod method){
if (ENABLED) {
CompilationWatchDog watchDog=WATCH_DOGS.get();
if (watchDog == null) {
Thread currentThread=currentThread();
watchDog=new CompilationWatchDog(currentThread);
WATCH_DOGS.set(watchDog);
watchDog.start();
}
watchDog.startCompilation(method);
return watchDog;
}
return null;
}
| Opens a scope for watching the compilation of a given method. |
@DSGenerator(tool_name="Doppelganger",tool_version="2.0",generated_on="2013-12-30 13:00:55.706 -0500",hash_original_method="8A03D4A0A8F771BBDCBB48C7AE384ACF",hash_generated_method="2F7D3B508C8CE668C31890B26F7A3F6F") public static void validateOid(int[] oid){
if (oid == null) {
throw new NullPointerException("oid == null");
}
if (oid.length < 2) {
throw new IllegalArgumentException("OID MUST have at least 2 subidentifiers");
}
if (oid[0] > 2) {
throw new IllegalArgumentException("Valid values for first subidentifier are 0, 1 and 2");
}
else if (oid[0] != 2 && oid[1] > 39) {
throw new IllegalArgumentException("If the first subidentifier has 0 or 1 value the second subidentifier value MUST be less than 40");
}
}
| Validates ObjectIdentifier (OID). |
public void addRecurring(DateTimeZoneBuilder builder,String nameFormat){
String nameKey=formatName(nameFormat);
iDateTimeOfYear.addRecurring(builder,nameKey,iSaveMillis,iFromYear,iToYear);
}
| Adds a recurring savings rule to the builder. |
public void actionPerformed(ActionEvent e){
log.fine("Event:" + e.getSource());
panel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL)) {
dispose();
return;
}
if (e.getSource().equals(Process)) {
if (getMovementDate() == null) {
JOptionPane.showMessageDialog(null,Msg.getMsg(Env.getCtx(),"NoDate"),"Info",JOptionPane.INFORMATION_MESSAGE);
return;
}
if ((isOnlyReceipt() || isBackflush()) && getM_Locator_ID() <= 0) {
JOptionPane.showMessageDialog(null,Msg.getMsg(Env.getCtx(),"NoLocator"),"Info",JOptionPane.INFORMATION_MESSAGE);
return;
}
TabsReceiptsIssue.setSelectedIndex(1);
generateSummaryTable();
if (ADialog.ask(m_WindowNo,panel,"Update")) {
panel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
final boolean isCloseDocument=ADialog.ask(m_WindowNo,panel,Msg.parseTranslation(Env.getCtx(),"@IsCloseDocument@ : " + getPP_Order().getDocumentNo()));
if (cmd_process(isCloseDocument,issue)) {
dispose();
return;
}
panel.setCursor(Cursor.getDefaultCursor());
}
TabsReceiptsIssue.setSelectedIndex(0);
}
if (e.getSource().equals(toDeliverQty) || e.getSource().equals(scrapQtyField)) {
if (getPP_Order_ID() > 0 && isBackflush()) {
executeQuery();
}
}
if (e.getSource().equals(pickcombo)) {
if (isOnlyReceipt()) {
enableToDeliver();
locatorLabel.setVisible(true);
locatorField.setVisible(true);
attribute.setVisible(true);
attributeLabel.setVisible(true);
issue.setVisible(false);
}
else if (isOnlyIssue()) {
disableToDeliver();
locatorLabel.setVisible(false);
locatorField.setVisible(false);
attribute.setVisible(false);
attributeLabel.setVisible(false);
issue.setVisible(true);
executeQuery();
}
else if (isBackflush()) {
enableToDeliver();
locatorLabel.setVisible(true);
locatorField.setVisible(true);
attribute.setVisible(true);
attributeLabel.setVisible(true);
issue.setVisible(true);
executeQuery();
}
setToDeliverQty(getOpenQty());
}
}
| Called when events occur in the window |
public void testRandomAccessClones() throws IOException {
Directory dir=newDirectory();
Directory cr=createLargeCFS(dir);
IndexInput e1=cr.openInput("_123.f11",newIOContext(random()));
IndexInput e2=cr.openInput("_123.f3",newIOContext(random()));
IndexInput a1=e1.clone();
IndexInput a2=e2.clone();
e1.seek(100);
a1.seek(100);
assertEquals(100,e1.getFilePointer());
assertEquals(100,a1.getFilePointer());
byte be1=e1.readByte();
byte ba1=a1.readByte();
assertEquals(be1,ba1);
e2.seek(1027);
a2.seek(1027);
assertEquals(1027,e2.getFilePointer());
assertEquals(1027,a2.getFilePointer());
byte be2=e2.readByte();
byte ba2=a2.readByte();
assertEquals(be2,ba2);
assertEquals(101,e1.getFilePointer());
assertEquals(101,a1.getFilePointer());
be1=e1.readByte();
ba1=a1.readByte();
assertEquals(be1,ba1);
e1.seek(1910);
a1.seek(1910);
assertEquals(1910,e1.getFilePointer());
assertEquals(1910,a1.getFilePointer());
be1=e1.readByte();
ba1=a1.readByte();
assertEquals(be1,ba1);
assertEquals(1028,e2.getFilePointer());
assertEquals(1028,a2.getFilePointer());
be2=e2.readByte();
ba2=a2.readByte();
assertEquals(be2,ba2);
e2.seek(17);
a2.seek(17);
assertEquals(17,e2.getFilePointer());
assertEquals(17,a2.getFilePointer());
be2=e2.readByte();
ba2=a2.readByte();
assertEquals(be2,ba2);
assertEquals(1911,e1.getFilePointer());
assertEquals(1911,a1.getFilePointer());
be1=e1.readByte();
ba1=a1.readByte();
assertEquals(be1,ba1);
e1.close();
e2.close();
a1.close();
a2.close();
cr.close();
dir.close();
}
| This test opens two files from a compound stream and verifies that their file positions are independent of each other. |
public void tableSwitch(final int[] keys,final TableSwitchGenerator generator){
float density;
if (keys.length == 0) {
density=0;
}
else {
density=(float)keys.length / (keys[keys.length - 1] - keys[0] + 1);
}
tableSwitch(keys,generator,density >= 0.5f);
}
| Generates the instructions for a switch statement. |
private boolean isFaceletsDisabled(WebConfiguration webconfig,FacesConfigInfo facesConfigInfo){
boolean isFaceletsDisabled=webconfig.isOptionEnabled(DisableFaceletJSFViewHandler) || webconfig.isOptionEnabled(DisableFaceletJSFViewHandlerDeprecated);
if (!isFaceletsDisabled) {
isFaceletsDisabled=!facesConfigInfo.isVersionGreaterOrEqual(2.0);
webconfig.overrideContextInitParameter(DisableFaceletJSFViewHandler,isFaceletsDisabled);
}
return isFaceletsDisabled;
}
| <p> Utility method to check if JSF 2.0 Facelets should be disabled. If it's not explicitly disabled by the context init parameter, then check the version of the WEB-INF/faces-config.xml document. If the version is less than 2.0, then override the default value for the context init parameter so that other parts of the system that use that config option will know it has been disabled. </p> <p> NOTE: Since this method overrides a configuration value, it should be called before *any* document parsing is performed the configuration value may be queried by the <code>ConfigParser</code>s. </p> |
public static String[] sort(String[] inputs){
return sort(inputs,0);
}
| Return inputs in sorted order, where a < z, and is nondestructive. |
public static Collection<ICalDataType> all(){
return enums.all();
}
| Gets all of the parameter values that are defined as static constants in this class. |
public void enableTlsExtensions(SSLSocket socket,String uriHost){
}
| Attempt a TLS connection with useful extensions enabled. This mode supports more features, but is less likely to be compatible with older HTTPS servers. |
@Override public void eSet(int featureID,Object newValue){
switch (featureID) {
case UmplePackage.WORD___SINGULAR_1:
setSingular_1((String)newValue);
return;
case UmplePackage.WORD___PLURAL_1:
setPlural_1((String)newValue);
return;
}
super.eSet(featureID,newValue);
}
| <!-- begin-user-doc --> <!-- end-user-doc --> |
public static String jsonExtractSubnetMask(String fmJson) throws IOException {
String subnet_mask="";
MappingJsonFactory f=new MappingJsonFactory();
JsonParser jp;
try {
jp=f.createJsonParser(fmJson);
}
catch ( JsonParseException e) {
throw new IOException(e);
}
jp.nextToken();
if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
throw new IOException("Expected START_OBJECT");
}
while (jp.nextToken() != JsonToken.END_OBJECT) {
if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
throw new IOException("Expected FIELD_NAME");
}
String n=jp.getCurrentName();
jp.nextToken();
if (jp.getText().equals("")) continue;
if (n == "subnet-mask") {
subnet_mask=jp.getText();
break;
}
}
return subnet_mask;
}
| Extracts subnet mask from a JSON string |
public void intersectClipBox(int clox,int cloy,int chix,int chiy){
if (clox > lox) {
lox=clox;
}
if (cloy > loy) {
loy=cloy;
}
if (chix < hix) {
hix=chix;
}
if (chiy < hiy) {
hiy=chiy;
}
done=lox >= hix || loy >= hiy;
}
| Intersect the box used for clipping the output spans with the given box. |
protected boolean afterDelete(boolean success){
if (success) delete_Tree(MTree_Base.TREETYPE_SalesRegion);
return success;
}
| After Delete |
public static void tintMenuItemIcon(@ColorInt int color,MenuItem item){
final Drawable drawable=item.getIcon();
if (drawable != null) {
final Drawable wrapped=DrawableCompat.wrap(drawable);
drawable.mutate();
DrawableCompat.setTint(wrapped,color);
item.setIcon(drawable);
}
}
| Tints the color of the icon of the specified MenuItem. See http://stackoverflow.com/questions/28219178/toolbar-icon-tinting-on-android |
public int parseMonth() throws ParseException {
char curr;
try {
switch (orig[index++]) {
case 'J':
case 'j':
switch (orig[index++]) {
case 'A':
case 'a':
curr=orig[index++];
if (curr == 'N' || curr == 'n') {
return 0;
}
break;
case 'U':
case 'u':
curr=orig[index++];
if (curr == 'N' || curr == 'n') {
return 5;
}
else if (curr == 'L' || curr == 'l') {
return 6;
}
break;
}
break;
case 'F':
case 'f':
curr=orig[index++];
if (curr == 'E' || curr == 'e') {
curr=orig[index++];
if (curr == 'B' || curr == 'b') {
return 1;
}
}
break;
case 'M':
case 'm':
curr=orig[index++];
if (curr == 'A' || curr == 'a') {
curr=orig[index++];
if (curr == 'R' || curr == 'r') {
return 2;
}
else if (curr == 'Y' || curr == 'y') {
return 4;
}
}
break;
case 'A':
case 'a':
curr=orig[index++];
if (curr == 'P' || curr == 'p') {
curr=orig[index++];
if (curr == 'R' || curr == 'r') {
return 3;
}
}
else if (curr == 'U' || curr == 'u') {
curr=orig[index++];
if (curr == 'G' || curr == 'g') {
return 7;
}
}
break;
case 'S':
case 's':
curr=orig[index++];
if (curr == 'E' || curr == 'e') {
curr=orig[index++];
if (curr == 'P' || curr == 'p') {
return 8;
}
}
break;
case 'O':
case 'o':
curr=orig[index++];
if (curr == 'C' || curr == 'c') {
curr=orig[index++];
if (curr == 'T' || curr == 't') {
return 9;
}
}
break;
case 'N':
case 'n':
curr=orig[index++];
if (curr == 'O' || curr == 'o') {
curr=orig[index++];
if (curr == 'V' || curr == 'v') {
return 10;
}
}
break;
case 'D':
case 'd':
curr=orig[index++];
if (curr == 'E' || curr == 'e') {
curr=orig[index++];
if (curr == 'C' || curr == 'c') {
return 11;
}
}
break;
}
}
catch (ArrayIndexOutOfBoundsException e) {
}
throw new ParseException("Bad Month",index);
}
| will look for one of "Jan/Feb/Mar/Apr/May/Jun/Jul/Aug/Sep/Oct/Nov/Dev" and return the numerical version of the month. (0-11). a ParseException error is thrown if a month cannot be found. |
public Object trapFieldRead(String name){
Class jc=getJavaClass();
try {
return jc.getField(name).get(null);
}
catch ( NoSuchFieldException e) {
throw new RuntimeException(e.toString());
}
catch ( IllegalAccessException e) {
throw new RuntimeException(e.toString());
}
}
| Is invoked when <code>static</code> fields of the base-level class are read and the runtime system intercepts it. This method simply returns the value of the field. <p>Every subclass of this class should redefine this method. |
private void normalizeCommandLength(){
System.arraycopy(OctetUtil.intToBytes(bytesLength),0,bytes,0,4);
}
| Assign the proper command length to the first 4 octet. |
private void doClosure(){
while (markStack.size() > 0) {
ObjectReference object=markStack.remove(markStack.size() - 1);
scan(object);
}
blackSet.clear();
markStack.clear();
}
| Iterate over the heap depth-first, scanning objects until the mark stack is empty. |
public void textLeft(double x,double y,String s){
offscreen.setFont(font);
FontMetrics metrics=offscreen.getFontMetrics();
double xs=scaleX(x);
double ys=scaleY(y);
int hs=metrics.getDescent();
offscreen.drawString(s,(float)xs,(float)(ys + hs));
draw();
}
| Writes the given text string in the current font, left-aligned at (x, y). |
public ElasticAttributeProvider(List<ElasticAttribute> attributes){
this.attributes=attributes;
}
| Build attribute provider |
public TreeNode deserialize(String data){
Deque<String> nodes=new LinkedList<>();
nodes.addAll(Arrays.asList(data.split(SPLITER)));
return buildTree(nodes);
}
| Recursive. Same as pre-order traversal. Split data and create a queue of string values first. Each time, poll a node from the queue, create the current root. Then build left and right subtree recursively. |
public static String toTimeString(int hour,int minute,int second){
String hourStr;
String minuteStr;
String secondStr;
if (hour < 10) {
hourStr="0" + hour;
}
else {
hourStr="" + hour;
}
if (minute < 10) {
minuteStr="0" + minute;
}
else {
minuteStr="" + minute;
}
if (second < 10) {
secondStr="0" + second;
}
else {
secondStr="" + second;
}
if (second == 0) {
return hourStr + ":" + minuteStr;
}
else {
return hourStr + ":" + minuteStr+ ":"+ secondStr;
}
}
| Makes a time String in the format HH:MM:SS from a separate ints for hour, minute, and second. If the seconds are 0, then the output is in HH:MM. |
private static Object maskNull(Object key){
return (key == null ? NULL_KEY : key);
}
| Use NULL_KEY for key if it is null. |
private Job randomizeManyInputFiles(Configuration baseConfig,Path fullInputList,Path outputStep2Dir,int numLinesPerSplit) throws IOException {
Job job2=Job.getInstance(baseConfig);
job2.setJarByClass(getClass());
job2.setJobName(getClass().getName() + "/" + Utils.getShortClassName(LineRandomizerMapper.class));
job2.setInputFormatClass(NLineInputFormat.class);
NLineInputFormat.addInputPath(job2,fullInputList);
NLineInputFormat.setNumLinesPerSplit(job2,numLinesPerSplit);
job2.setMapperClass(LineRandomizerMapper.class);
job2.setReducerClass(LineRandomizerReducer.class);
job2.setOutputFormatClass(TextOutputFormat.class);
FileOutputFormat.setOutputPath(job2,outputStep2Dir);
job2.setNumReduceTasks(1);
job2.setOutputKeyClass(LongWritable.class);
job2.setOutputValueClass(Text.class);
return job2;
}
| To uniformly spread load across all mappers we randomize fullInputList with a separate small Mapper & Reducer preprocessing step. This way each input line ends up on a random position in the output file list. Each mapper indexes a disjoint consecutive set of files such that each set has roughly the same size, at least from a probabilistic perspective. For example an input file with the following input list of URLs: A B C D might be randomized into the following output list of URLs: C A D B The implementation sorts the list of lines by randomly generated numbers. |
public static void restoreDefaultOutAndErrStream(){
System.setOut(DEFAULT_OUT);
System.setErr(DEFAULT_ERR);
}
| Allow again printing to System.out and System.err |
@Override public void run(){
amIActive=true;
try {
String inputFilesString=null;
String idrisiHeaderFile=null;
String idrisiDataFile=null;
String whiteboxHeaderFile=null;
String whiteboxDataFile=null;
WhiteboxRaster output=null;
int i=0;
int row, col, rows, cols;
String[] imageFiles;
int numImages=0;
double noData=-32768;
int progress=0;
if (args.length <= 0) {
showFeedback("Plugin parameters have not been set.");
return;
}
inputFilesString=args[0];
if ((inputFilesString == null)) {
showFeedback("One or more of the input parameters have not been set properly.");
return;
}
imageFiles=inputFilesString.split(";");
numImages=imageFiles.length;
for (i=0; i < numImages; i++) {
if (numImages > 1) {
progress=(int)(100f * i / (numImages - 1));
updateProgress("Loop " + (i + 1) + " of "+ numImages+ ":",progress);
}
whiteboxHeaderFile=imageFiles[i];
if (!((new File(whiteboxHeaderFile)).exists())) {
showFeedback("Whitebox raster file does not exist.");
break;
}
WhiteboxRaster wbr=new WhiteboxRaster(whiteboxHeaderFile,"r");
rows=wbr.getNumberRows();
cols=wbr.getNumberColumns();
noData=wbr.getNoDataValue();
idrisiHeaderFile=whiteboxHeaderFile.replace(".dep",".rdc");
idrisiDataFile=whiteboxHeaderFile.replace(".dep",".rst");
(new File(idrisiHeaderFile)).delete();
(new File(idrisiDataFile)).delete();
WhiteboxRaster.DataType dataType;
if (wbr.getDataType() == WhiteboxRaster.DataType.FLOAT || wbr.getDataType() == WhiteboxRaster.DataType.DOUBLE) {
dataType=WhiteboxRaster.DataType.FLOAT;
}
else {
dataType=WhiteboxRaster.DataType.INTEGER;
}
output=new WhiteboxRaster(whiteboxHeaderFile.replace(".dep","_temp.dep"),"rw",whiteboxHeaderFile,dataType,-9999);
output.setNoDataValue(-9999);
whiteboxDataFile=whiteboxHeaderFile.replace(".dep","_temp.tas");
double[] data=null;
for (row=0; row < rows; row++) {
data=wbr.getRowValues(row);
for (col=0; col < cols; col++) {
if (data[col] != noData) {
output.setValue(row,col,data[col]);
}
else {
output.setValue(row,col,-9999);
}
}
if (cancelOp) {
cancelOperation();
return;
}
progress=(int)(100f * row / (rows - 1));
updateProgress(progress);
}
output.close();
File dataFile=new File(whiteboxDataFile);
File idrisiFile=new File(idrisiDataFile);
dataFile.renameTo(idrisiFile);
boolean success=createHeaderFile(wbr,idrisiHeaderFile);
if (!success) {
showFeedback("IDRISI header file was not written properly. " + "Tool failed to export");
return;
}
wbr.close();
(new File(whiteboxHeaderFile.replace(".dep","_temp.dep"))).delete();
}
showFeedback("Operation complete!");
}
catch ( OutOfMemoryError oe) {
myHost.showFeedback("An out-of-memory error has occurred during operation.");
}
catch ( Exception e) {
myHost.showFeedback("An error has occurred during operation. See log file for details.");
myHost.logException("Error in " + getDescriptiveName(),e);
}
finally {
updateProgress("Progress: ",0);
amIActive=false;
myHost.pluginComplete();
}
}
| Used to execute this plugin tool. |
public static Object loadSingleExtensionClass(final String extensionPointID,final boolean throwForZeroElements){
Check.notNull(extensionPointID,"extensionPointID");
final IExtensionRegistry registry=Platform.getExtensionRegistry();
final IExtensionPoint extensionPoint=registry.getExtensionPoint(extensionPointID);
final IConfigurationElement[] elements=extensionPoint.getConfigurationElements();
if (!throwForZeroElements && elements.length == 0) {
return null;
}
if (elements.length == 0) {
throw new RuntimeException(MessageFormat.format("No provider is configured for extension point id {0}",extensionPointID));
}
else if (elements.length > 1) {
throw new RuntimeException(MessageFormat.format("Multiple providers are configured for extension point id {0}",extensionPointID));
}
try {
final Object provider=elements[0].createExecutableExtension("class");
if (provider == null) {
throw new RuntimeException(MessageFormat.format("Could not instantiate provider for extension point id {0}",extensionPointID));
}
return provider;
}
catch ( final CoreException e) {
final String message=MessageFormat.format("Could not instantiate provider for extension point id {0}",extensionPointID);
throw new RuntimeException(message,e);
}
}
| Finds exactly one contribution for the specified extension point ID and instantiates an object for the <code>class</code> element in that contribution. |
@Override protected boolean useScroll(final Player player){
final StendhalRPZone zone=player.getZone();
if (zone.isInProtectionArea(player)) {
player.sendPrivateText("The aura of protection in this area prevents the scroll from working!");
return false;
}
if (zone.getNPCList().size() >= MAX_ZONE_NPCS) {
player.sendPrivateText("Mysteriously, the scroll does not function! Perhaps this area is too crowded...");
logger.info("Too many npcs to summon another creature");
return false;
}
if (player.hasPet()) {
player.sendPrivateText("The magic is not strong enough to give you more than one pet.");
return false;
}
String type=getInfoString().replaceAll("_"," ");
if (type == null) {
type="cat";
}
Pet pet=null;
switch (type) {
case "cat":
pet=new Cat(player);
break;
case "baby dragon":
pet=new BabyDragon(player);
break;
case "purple dragon":
pet=new PurpleDragon(player);
break;
default :
player.sendPrivateText("This scroll does not seem to work. You should talk to the magician who created it.");
return false;
}
pet.setPosition(player.getX(),player.getY() + 1);
dropBlank(player);
return true;
}
| Is invoked when a summon pet scroll is used. |
@Override public void publish(LogRecord record){
super.publish(record);
super.flush();
}
| Logs a record if necessary. A flush operation will be done afterwards. |
public double impliedVolatility(final double price,final GeneralizedBlackScholesProcess process,final double accuracy,final int maxEvaluations,final double minVol,final double maxVol){
QL.require(!isExpired(),"option expired");
final SimpleQuote volQuote=new SimpleQuote();
final GeneralizedBlackScholesProcess newProcess=ImpliedVolatilityHelper.clone(process,volQuote);
final PricingEngine engine;
switch (exercise.type()) {
case European:
engine=new AnalyticEuropeanEngine(newProcess);
break;
case American:
engine=new FDAmericanEngine(newProcess);
break;
case Bermudan:
engine=new FDBermudanEngine(newProcess);
break;
default :
throw new LibraryException(UNKNOWN_EXERCISE_TYPE);
}
return ImpliedVolatilityHelper.calculate(this,engine,volQuote,price,accuracy,maxEvaluations,minVol,maxVol);
}
| Currently, this method returns the Black-Scholes implied volatility using analytic formulas for European options and a finite-difference method for American and Bermudan options. It will give inconsistent results if the pricing was performed with any other methods (such as jump-diffusion models.) <p> Options with a gamma that changes sign (e.g., binary options) have values that are <b>not</b> monotonic in the volatility. In these cases, the calculation can fail and the result (if any) is almost meaningless. Another possible source of failure is to have a target value that is not attainable with any volatility, e.g., a target value lower than the intrinsic value in the case of American options. |
public boolean isSetVersions(){
return this.versions != null;
}
| Returns true if field versions is set (has been assigned a value) and false otherwise |
public void configure(JobConf conf){
this.conf=conf;
}
| Configure the job. |
@Override protected EClass eStaticClass(){
return UmplePackage.eINSTANCE.getAnonymous_traceType_1_();
}
| <!-- begin-user-doc --> <!-- end-user-doc --> |
public Pair<String,ClassResult> nextUnhandledClass(){
return unhandledClasses.poll();
}
| Returns a class which has not been analyzed yet. |
public RevisionFeed(){
super(RevisionEntry.class);
getCategories().add(RevisionEntry.CATEGORY);
}
| Contructs an empty feed. |
public void stopPlayback(){
currentState=State.IDLE;
if (isReady()) {
try {
mediaPlayer.stop();
}
catch ( Exception e) {
Log.d(TAG,"stopPlayback: error calling mediaPlayer.stop()",e);
}
}
playRequested=false;
}
| Performs the functionality to stop the video in playback |
public static void main(final String[] args){
DOMTestCase.doMain(getElementsByTagNameNS05.class,args);
}
| Runs this test from the command line. |
public ViewPropertyAnimator rotationY(float value){
animateProperty(ROTATION_Y,value);
return this;
}
| This method will cause the View's <code>rotationY</code> property to be animated to the specified value. Animations already running on the property will be canceled. |
public static void main(String[] argv){
runClassifier(new ZeroR(),argv);
}
| Main method for testing this class. |
public synchronized void damageRange(Position pos0,Position pos1){
if (component == null) {
p0.clear();
lastDoc=null;
return;
}
boolean addToQueue=p0.isEmpty();
Document curDoc=component.getDocument();
if (curDoc != lastDoc) {
if (!p0.isEmpty()) {
p0.clear();
p1.clear();
}
lastDoc=curDoc;
}
p0.add(pos0);
p1.add(pos1);
if (addToQueue) {
SwingUtilities.invokeLater(this);
}
}
| Adds the range to be damaged into the range queue. If the range queue is empty (the first call or run() was already invoked) then adds this class instance into EventDispatch queue. The method also tracks if the current document changed or component is null. In this case it removes all ranges added before from range queue. |
public static Date cloneDate(Date date){
Date clonedDate=null;
if (date != null) {
clonedDate=new Date(date.getTime());
}
return clonedDate;
}
| Clona una fecha. |
public boolean isComplete(){
return isComplete_;
}
| Check if this object has all the header fields populated and available for reading. |
public final void testRegexWithCharSequenceParameter(){
assertNotNull(Validators.regex("foo",Pattern.compile(".")));
}
| Tests the functionality of the regex-method, which expects a char sequence as a parameter. |
@SuppressWarnings("unchecked") @Override public void put(Collection<SinkRecord> records){
try {
for ( SinkRecord record : records) {
if (record.key() != null) {
StreamerContext.getStreamer().addData(record.key(),record.value());
}
else {
log.error("Failed to stream a record with null key!");
}
}
}
catch ( ConnectException e) {
log.error("Failed adding record",e);
throw new ConnectException(e);
}
}
| Buffers records. |
public static char[] toCharArray(final InputStream is,final Charset encoding) throws IOException {
CharArrayWriter output=new CharArrayWriter();
IOUtils.copy(is,output,encoding);
return output.toCharArray();
}
| Get the contents of an <code>InputStream</code> as a character array using the specified character encoding. <p> This method buffers the input internally, so there is no need to use a <code>BufferedInputStream</code>. |
public String checkStartBlock(int mode){
if (log.isDebugEnabled()) log.debug("checkStartBlock for warrant \"" + getDisplayName() + "\".");
BlockOrder bo=_orders.get(0);
OBlock block=bo.getBlock();
String msg=block.allocate(this);
if (msg != null) {
return msg;
}
msg=bo.setPath(this);
if (msg != null) {
return msg;
}
int state=block.getState();
if ((state & OBlock.DARK) != 0 || _tempRunBlind) {
msg=Bundle.getMessage("BlockDark",block.getDisplayName());
}
else if ((state & OBlock.OCCUPIED) == 0) {
if (mode == MODE_LEARN) {
msg="learnStart";
}
else {
msg="warnStart";
}
msg=Bundle.getMessage(msg,getTrainName(),block.getDisplayName());
}
else {
TrackerTableAction.stopTrackerIn(block);
}
return msg;
}
| Check start block for occupied for start of run |
public void addListener(ExceptionEventListener listener){
if (!this.listeners.contains(listener)) {
this.listeners.add(listener);
}
}
| Add the exception listener. It will be notified of any exceptions. |
private WebTarget createWebTarget(String restPath,Map<String,String> queryParams){
WebTarget webTarget;
try {
URI u=new URI(this.baseURI + "/plugins/restapi/v1/" + restPath);
Client client=createrRestClient();
webTarget=client.target(u);
if (queryParams != null && !queryParams.isEmpty()) {
for ( Map.Entry<String,String> entry : queryParams.entrySet()) {
if (entry.getKey() != null && entry.getValue() != null) {
LOG.debug("PARAM: {} = {}",entry.getKey(),entry.getValue());
webTarget=webTarget.queryParam(entry.getKey(),entry.getValue());
}
}
}
}
catch ( Exception e) {
LOG.error("Error",e);
return null;
}
return webTarget;
}
| Creates the web target. |
public SVGOMFEFloodElement(String prefix,AbstractDocument owner){
super(prefix,owner);
initializeLiveAttributes();
}
| Creates a new SVGOMFEFloodElement object. |
public void onTxRollback(long duration){
txRollbacks.incrementAndGet();
rollbackTimeNanos.addAndGet(duration);
if (delegate != null) delegate.onTxRollback(duration);
}
| Transaction rollback callback. |
public boolean execute(String action,JSONArray args,CallbackContext callbackContext) throws JSONException {
if (this.cordova.getActivity().isFinishing()) return true;
if (action.equals("beep")) {
this.beep(args.getLong(0));
}
else if (action.equals("alert")) {
this.alert(args.getString(0),args.getString(1),args.getString(2),callbackContext);
return true;
}
else if (action.equals("confirm")) {
this.confirm(args.getString(0),args.getString(1),args.getJSONArray(2),callbackContext);
return true;
}
else if (action.equals("prompt")) {
this.prompt(args.getString(0),args.getString(1),args.getJSONArray(2),args.getString(3),callbackContext);
return true;
}
else if (action.equals("activityStart")) {
this.activityStart(args.getString(0),args.getString(1));
}
else if (action.equals("activityStop")) {
this.activityStop();
}
else if (action.equals("progressStart")) {
this.progressStart(args.getString(0),args.getString(1));
}
else if (action.equals("progressValue")) {
this.progressValue(args.getInt(0));
}
else if (action.equals("progressStop")) {
this.progressStop();
}
else {
return false;
}
callbackContext.success();
return true;
}
| Executes the request and returns PluginResult. |
private PluginEventManager(){
listenerMap=new java.util.HashMap();
eventQueue=new java.util.Vector();
alive=false;
}
| Creates a new instance of PluginEventManager |
@Override public void updateDisplay(final boolean force){
}
| Method updateDisplay() |
private void markSubroutines(){
BitSet anyvisited=new BitSet();
markSubroutineWalk(mainSubroutine,0,anyvisited);
for (Iterator<Map.Entry<LabelNode,BitSet>> it=subroutineHeads.entrySet().iterator(); it.hasNext(); ) {
Map.Entry<LabelNode,BitSet> entry=it.next();
LabelNode lab=entry.getKey();
BitSet sub=entry.getValue();
int index=instructions.indexOf(lab);
markSubroutineWalk(sub,index,anyvisited);
}
}
| Walks the method and determines which internal subroutine(s), if any, each instruction is a method of. |
private AddCloudHostWorkflowService.State buildValidPatchState(TaskState.TaskStage stage){
AddCloudHostWorkflowService.State patchState=new AddCloudHostWorkflowService.State();
patchState.taskState=new TaskState();
patchState.taskState.stage=stage;
return patchState;
}
| This method creates a patch State object which is sufficient to patch a AddCloudHostTaskService instance. |
public void testSortsAttributesBeforeElements() throws Exception {
XppDom dom1=XppFactory.buildDom("<dom x='a'><a/></dom>");
XppDom dom2=XppFactory.buildDom("<dom x='b'><b/></dom>");
assertEquals(-1,comparator.compare(dom1,dom2));
assertEquals("/dom[@x]",xpath.get());
assertEquals(1,comparator.compare(dom2,dom1));
assertEquals("/dom[@x]",xpath.get());
}
| Tests comparison sorts attributes before elements. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.