id_within_dataset
int64
0
69.7k
snippet
stringlengths
10
23k
tokens
sequence
nl
stringlengths
15
2.45k
split_within_dataset
stringclasses
1 value
is_duplicated
bool
2 classes
69,266
public static <E,M>ProducerT<E,M,T0> yield(E e){ return ProducerT.producerT(FreeT.liftF(YieldF.yield(e,T0.of()))); }
[ "public", "static", "<", "E", ",", "M", ">", "ProducerT", "<", "E", ",", "M", ",", "T0", ">", "yield", "(", "E", "e", ")", "{", "return", "ProducerT", ".", "producerT", "(", "FreeT", ".", "liftF", "(", "YieldF", ".", "yield", "(", "e", ",", "T0", ".", "of", "(", ")", ")", ")", ")", ";", "}" ]
produces a generator that will suspend its computation returning a yielded value , plus the rest of the computation to be completed later .
train
false
69,267
public void zoomIn(int x,int y){ double rangeX=Math.abs(pageBox.getMaxX() - pageBox.getMinX()); double rangeY=Math.abs(pageBox.getMaxY() - pageBox.getMinY()); pageBox.setMinX(x - (rangeX * 0.85) / 2.0); pageBox.setMinY(y - (rangeY * 0.85) / 2.0); pageBox.setMaxX(x + (rangeX * 0.85) / 2.0); pageBox.setMaxY(y + (rangeY * 0.85) / 2.0); }
[ "public", "void", "zoomIn", "(", "int", "x", ",", "int", "y", ")", "{", "double", "rangeX", "=", "Math", ".", "abs", "(", "pageBox", ".", "getMaxX", "(", ")", "-", "pageBox", ".", "getMinX", "(", ")", ")", ";", "double", "rangeY", "=", "Math", ".", "abs", "(", "pageBox", ".", "getMaxY", "(", ")", "-", "pageBox", ".", "getMinY", "(", ")", ")", ";", "pageBox", ".", "setMinX", "(", "x", "-", "(", "rangeX", "*", "0.85", ")", "/", "2.0", ")", ";", "pageBox", ".", "setMinY", "(", "y", "-", "(", "rangeY", "*", "0.85", ")", "/", "2.0", ")", ";", "pageBox", ".", "setMaxX", "(", "x", "+", "(", "rangeX", "*", "0.85", ")", "/", "2.0", ")", ";", "pageBox", ".", "setMaxY", "(", "y", "+", "(", "rangeY", "*", "0.85", ")", "/", "2.0", ")", ";", "}" ]
used to zoom into the map page
train
false
69,268
public Object clone() throws CloneNotSupportedException { NodeSet clone=(NodeSet)super.clone(); if ((null != this.m_map) && (this.m_map == clone.m_map)) { clone.m_map=new Node[this.m_map.length]; System.arraycopy(this.m_map,0,clone.m_map,0,this.m_map.length); } return clone; }
[ "public", "Object", "clone", "(", ")", "throws", "CloneNotSupportedException", "{", "NodeSet", "clone", "=", "(", "NodeSet", ")", "super", ".", "clone", "(", ")", ";", "if", "(", "(", "null", "!=", "this", ".", "m_map", ")", "&&", "(", "this", ".", "m_map", "==", "clone", ".", "m_map", ")", ")", "{", "clone", ".", "m_map", "=", "new", "Node", "[", "this", ".", "m_map", ".", "length", "]", ";", "System", ".", "arraycopy", "(", "this", ".", "m_map", ",", "0", ",", "clone", ".", "m_map", ",", "0", ",", "this", ".", "m_map", ".", "length", ")", ";", "}", "return", "clone", ";", "}" ]
get a cloned locpathiterator .
train
false
69,269
public synchronized boolean verifyFileAuthTag() throws FileEncryptionException { byte[] storedTag=backEncRandomAccessFile.readFileAuthenticationTag(); if (storedTag == null || storedTag.length != AUTH_TAG_SIZE) { throw new FileEncryptionException("Encrypted file has invalid file authentication tag!"); } else { byte[] tmp=buildFileAuthTag(); return Arrays.equals(tmp,storedTag); } }
[ "public", "synchronized", "boolean", "verifyFileAuthTag", "(", ")", "throws", "FileEncryptionException", "{", "byte", "[", "]", "storedTag", "=", "backEncRandomAccessFile", ".", "readFileAuthenticationTag", "(", ")", ";", "if", "(", "storedTag", "==", "null", "||", "storedTag", ".", "length", "!=", "AUTH_TAG_SIZE", ")", "{", "throw", "new", "FileEncryptionException", "(", "\"Encrypted file has invalid file authentication tag!\"", ")", ";", "}", "else", "{", "byte", "[", "]", "tmp", "=", "buildFileAuthTag", "(", ")", ";", "return", "Arrays", ".", "equals", "(", "tmp", ",", "storedTag", ")", ";", "}", "}" ]
verifies the complete list of all authentication tags w . r . t . the central file authentication tag
train
false
69,270
public void transpile(N4JSResource resource,Writer outCode,Optional<SourceMapInfo> optSourceMapInfo){ final TranspilerState state=prepare(resource); transform(state); prettyPrint(state,outCode,optSourceMapInfo); }
[ "public", "void", "transpile", "(", "N4JSResource", "resource", ",", "Writer", "outCode", ",", "Optional", "<", "SourceMapInfo", ">", "optSourceMapInfo", ")", "{", "final", "TranspilerState", "state", "=", "prepare", "(", "resource", ")", ";", "transform", "(", "state", ")", ";", "prettyPrint", "(", "state", ",", "outCode", ",", "optSourceMapInfo", ")", ";", "}" ]
transpile the given resource to the given writers .
train
false
69,272
public boolean hleKernelUnRegisterCallback(int callbackType,int cbid){ boolean found=false; for ( SceKernelThreadInfo thread : threadMap.values()) { RegisteredCallbacks registeredCallbacks=thread.getRegisteredCallbacks(callbackType); pspBaseCallback callback=registeredCallbacks.getCallbackInfoByUid(cbid); if (callback != null) { found=true; if (registeredCallbacks.isCallbackReady(callback)) { log.warn("hleKernelUnRegisterCallback(type=" + callbackType + ") removing pending callback"); } registeredCallbacks.removeCallback(callback); break; } } if (!found) { log.warn("hleKernelUnRegisterCallback(type=" + callbackType + ") cbid="+ Integer.toHexString(cbid)+ " no matching callbacks found"); } return found; }
[ "public", "boolean", "hleKernelUnRegisterCallback", "(", "int", "callbackType", ",", "int", "cbid", ")", "{", "boolean", "found", "=", "false", ";", "for", "(", "SceKernelThreadInfo", "thread", ":", "threadMap", ".", "values", "(", ")", ")", "{", "RegisteredCallbacks", "registeredCallbacks", "=", "thread", ".", "getRegisteredCallbacks", "(", "callbackType", ")", ";", "pspBaseCallback", "callback", "=", "registeredCallbacks", ".", "getCallbackInfoByUid", "(", "cbid", ")", ";", "if", "(", "callback", "!=", "null", ")", "{", "found", "=", "true", ";", "if", "(", "registeredCallbacks", ".", "isCallbackReady", "(", "callback", ")", ")", "{", "log", ".", "warn", "(", "\"hleKernelUnRegisterCallback(type=\"", "+", "callbackType", "+", "\") removing pending callback\"", ")", ";", "}", "registeredCallbacks", ".", "removeCallback", "(", "callback", ")", ";", "break", ";", "}", "}", "if", "(", "!", "found", ")", "{", "log", ".", "warn", "(", "\"hleKernelUnRegisterCallback(type=\"", "+", "callbackType", "+", "\") cbid=\"", "+", "Integer", ".", "toHexString", "(", "cbid", ")", "+", "\" no matching callbacks found\"", ")", ";", "}", "return", "found", ";", "}" ]
unregisters a callback by type and cbid . may not be on the current thread .
train
false
69,273
public void write(DataOutput out) throws IOException { if (array == null) { out.writeLong(0); return; } DataBuffer data=array.data(); DataBuffer.Type type=data.dataType(); out.writeLong(array.length()); out.writeInt(type.ordinal()); switch (type) { case DOUBLE: { DoubleBuffer buffer=data.asNioDouble(); while (buffer.remaining() > 0) { out.writeDouble(buffer.get()); } return; } case FLOAT: { FloatBuffer buffer=data.asNioFloat(); while (buffer.remaining() > 0) { out.writeFloat(buffer.get()); } return; } case INT: { IntBuffer buffer=data.asNioInt(); while (buffer.remaining() > 0) { out.writeInt(buffer.get()); } return; } } throw new UnsupportedOperationException("Unsupported data type: " + type); }
[ "public", "void", "write", "(", "DataOutput", "out", ")", "throws", "IOException", "{", "if", "(", "array", "==", "null", ")", "{", "out", ".", "writeLong", "(", "0", ")", ";", "return", ";", "}", "DataBuffer", "data", "=", "array", ".", "data", "(", ")", ";", "DataBuffer", ".", "Type", "type", "=", "data", ".", "dataType", "(", ")", ";", "out", ".", "writeLong", "(", "array", ".", "length", "(", ")", ")", ";", "out", ".", "writeInt", "(", "type", ".", "ordinal", "(", ")", ")", ";", "switch", "(", "type", ")", "{", "case", "DOUBLE", ":", "{", "DoubleBuffer", "buffer", "=", "data", ".", "asNioDouble", "(", ")", ";", "while", "(", "buffer", ".", "remaining", "(", ")", ">", "0", ")", "{", "out", ".", "writeDouble", "(", "buffer", ".", "get", "(", ")", ")", ";", "}", "return", ";", "}", "case", "FLOAT", ":", "{", "FloatBuffer", "buffer", "=", "data", ".", "asNioFloat", "(", ")", ";", "while", "(", "buffer", ".", "remaining", "(", ")", ">", "0", ")", "{", "out", ".", "writeFloat", "(", "buffer", ".", "get", "(", ")", ")", ";", "}", "return", ";", "}", "case", "INT", ":", "{", "IntBuffer", "buffer", "=", "data", ".", "asNioInt", "(", ")", ";", "while", "(", "buffer", ".", "remaining", "(", ")", ">", "0", ")", "{", "out", ".", "writeInt", "(", "buffer", ".", "get", "(", ")", ")", ";", "}", "return", ";", "}", "}", "throw", "new", "UnsupportedOperationException", "(", "\"Unsupported data type: \"", "+", "type", ")", ";", "}" ]
serialize array data linearly .
train
false
69,274
public void fires(double[] input,ArrayList<SimpleRule> ruleCollection){ if (m_predicate.evaluate(input) == TreeModel.Predicate.Eval.TRUE) { ruleCollection.add(this); } }
[ "public", "void", "fires", "(", "double", "[", "]", "input", ",", "ArrayList", "<", "SimpleRule", ">", "ruleCollection", ")", "{", "if", "(", "m_predicate", ".", "evaluate", "(", "input", ")", "==", "TreeModel", ".", "Predicate", ".", "Eval", ".", "TRUE", ")", "{", "ruleCollection", ".", "add", "(", "this", ")", ";", "}", "}" ]
collect the rule ( s ) that fire for the supplied incoming instance
train
false
69,275
public void log(java.util.logging.Level level,CharSequence message,Throwable e){ LogRecord rec=new ELKILogRecord(level,message); rec.setThrown(e); logger.log(rec); }
[ "public", "void", "log", "(", "java", ".", "util", ".", "logging", ".", "Level", "level", ",", "CharSequence", "message", ",", "Throwable", "e", ")", "{", "LogRecord", "rec", "=", "new", "ELKILogRecord", "(", "level", ",", "message", ")", ";", "rec", ".", "setThrown", "(", "e", ")", ";", "logger", ".", "log", "(", "rec", ")", ";", "}" ]
log a log message and exception at the given level .
train
true
69,276
private void checkParameters(File lexFile) throws MojoExecutionException { if (lexFile == null) { throw new MojoExecutionException("<lexDefinition> is empty. Please define input file with <lexDefinition>input.jflex</lexDefinition>"); } assert lexFile.isAbsolute() : lexFile; if (!lexFile.isFile()) { throw new MojoExecutionException("Input file does not exist: " + lexFile); } }
[ "private", "void", "checkParameters", "(", "File", "lexFile", ")", "throws", "MojoExecutionException", "{", "if", "(", "lexFile", "==", "null", ")", "{", "throw", "new", "MojoExecutionException", "(", "\"<lexDefinition> is empty. Please define input file with <lexDefinition>input.jflex</lexDefinition>\"", ")", ";", "}", "assert", "lexFile", ".", "isAbsolute", "(", ")", ":", "lexFile", ";", "if", "(", "!", "lexFile", ".", "isFile", "(", ")", ")", "{", "throw", "new", "MojoExecutionException", "(", "\"Input file does not exist: \"", "+", "lexFile", ")", ";", "}", "}" ]
check parameter lexfile . must not be null and file must exist .
train
false
69,277
@Override public void modifyVariableId(String oldId,String newId){ if (variable.equals(oldId)) { variable=newId; } if (discreteCache != null) { discreteCache.modifyVariableId(oldId,newId); } }
[ "@", "Override", "public", "void", "modifyVariableId", "(", "String", "oldId", ",", "String", "newId", ")", "{", "if", "(", "variable", ".", "equals", "(", "oldId", ")", ")", "{", "variable", "=", "newId", ";", "}", "if", "(", "discreteCache", "!=", "null", ")", "{", "discreteCache", ".", "modifyVariableId", "(", "oldId", ",", "newId", ")", ";", "}", "}" ]
modifies the variable label
train
false
69,278
public ZkConfigManager(SolrZkClient zkClient){ this.zkClient=zkClient; }
[ "public", "ZkConfigManager", "(", "SolrZkClient", "zkClient", ")", "{", "this", ".", "zkClient", "=", "zkClient", ";", "}" ]
creates a new zkconfigmanager
train
false
69,280
public void removeConversation(String name){ conversations.remove(name.toLowerCase()); }
[ "public", "void", "removeConversation", "(", "String", "name", ")", "{", "conversations", ".", "remove", "(", "name", ".", "toLowerCase", "(", ")", ")", ";", "}" ]
removes a conversation by name
train
false
69,281
public MBeanDumper(MBeanServerConnection server) throws IOException { setMBeanServerConnection(server); try { objname=new ObjectName(ManagementFactory.THREAD_MXBEAN_NAME); } catch ( MalformedObjectNameException e) { InternalError ie=new InternalError(e.getMessage()); ie.initCause(e); throw ie; } parseMBeanInfo(); }
[ "public", "MBeanDumper", "(", "MBeanServerConnection", "server", ")", "throws", "IOException", "{", "setMBeanServerConnection", "(", "server", ")", ";", "try", "{", "objname", "=", "new", "ObjectName", "(", "ManagementFactory", ".", "THREAD_MXBEAN_NAME", ")", ";", "}", "catch", "(", "MalformedObjectNameException", "e", ")", "{", "InternalError", "ie", "=", "new", "InternalError", "(", "e", ".", "getMessage", "(", ")", ")", ";", "ie", ".", "initCause", "(", "e", ")", ";", "throw", "ie", ";", "}", "parseMBeanInfo", "(", ")", ";", "}" ]
constructs a threadmonitor object to get thread information in a remote jvm .
train
false
69,283
public void reset(){ count=0; System.arraycopy(IV,0,FR,0,FR.length); cipher.reset(); }
[ "public", "void", "reset", "(", ")", "{", "count", "=", "0", ";", "System", ".", "arraycopy", "(", "IV", ",", "0", ",", "FR", ",", "0", ",", "FR", ".", "length", ")", ";", "cipher", ".", "reset", "(", ")", ";", "}" ]
reset the chaining vector back to the iv and reset the underlying cipher .
train
false
69,284
public AccessibleRelation[] toArray(){ if (relations == null) { return new AccessibleRelation[0]; } else { AccessibleRelation[] relationArray=new AccessibleRelation[relations.size()]; for (int i=0; i < relationArray.length; i++) { relationArray[i]=(AccessibleRelation)relations.elementAt(i); } return relationArray; } }
[ "public", "AccessibleRelation", "[", "]", "toArray", "(", ")", "{", "if", "(", "relations", "==", "null", ")", "{", "return", "new", "AccessibleRelation", "[", "0", "]", ";", "}", "else", "{", "AccessibleRelation", "[", "]", "relationArray", "=", "new", "AccessibleRelation", "[", "relations", ".", "size", "(", ")", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "relationArray", ".", "length", ";", "i", "++", ")", "{", "relationArray", "[", "i", "]", "=", "(", "AccessibleRelation", ")", "relations", ".", "elementAt", "(", "i", ")", ";", "}", "return", "relationArray", ";", "}", "}" ]
returns the current relation set as an array of accessiblerelation
train
false
69,286
private Collection<Var> migrateColumns(SQLTable table,ResultSet row,Var instance) throws SQLException { String tableType=table.getEntityType(); Map<String,ResourceType.DataType> columns=table.getColumns(); Map<String,String> foreign=table.getForeignKeyColumns(); ResultSetMetaData metadata=row.getMetaData(); List<Var> vars=new ArrayList<>(); for (int i=1; i <= metadata.getColumnCount(); i++) { String columnName=metadata.getColumnName(i); Object columnValue=row.getObject(columnName); ResourceType.DataType dataType=columns.get(columnName); String foreignKey=foreign.get(columnName); if (foreignKey != null) { vars.addAll(migrateColumnValueAsRelation(instance,columnName,foreignKey,columnValue)); } else { vars.addAll(migrateColumnValueAsResource(instance,columnName,cast(dataType,columnName,row),tableType)); } } return vars; }
[ "private", "Collection", "<", "Var", ">", "migrateColumns", "(", "SQLTable", "table", ",", "ResultSet", "row", ",", "Var", "instance", ")", "throws", "SQLException", "{", "String", "tableType", "=", "table", ".", "getEntityType", "(", ")", ";", "Map", "<", "String", ",", "ResourceType", ".", "DataType", ">", "columns", "=", "table", ".", "getColumns", "(", ")", ";", "Map", "<", "String", ",", "String", ">", "foreign", "=", "table", ".", "getForeignKeyColumns", "(", ")", ";", "ResultSetMetaData", "metadata", "=", "row", ".", "getMetaData", "(", ")", ";", "List", "<", "Var", ">", "vars", "=", "new", "ArrayList", "<", ">", "(", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<=", "metadata", ".", "getColumnCount", "(", ")", ";", "i", "++", ")", "{", "String", "columnName", "=", "metadata", ".", "getColumnName", "(", "i", ")", ";", "Object", "columnValue", "=", "row", ".", "getObject", "(", "columnName", ")", ";", "ResourceType", ".", "DataType", "dataType", "=", "columns", ".", "get", "(", "columnName", ")", ";", "String", "foreignKey", "=", "foreign", ".", "get", "(", "columnName", ")", ";", "if", "(", "foreignKey", "!=", "null", ")", "{", "vars", ".", "addAll", "(", "migrateColumnValueAsRelation", "(", "instance", ",", "columnName", ",", "foreignKey", ",", "columnValue", ")", ")", ";", "}", "else", "{", "vars", ".", "addAll", "(", "migrateColumnValueAsResource", "(", "instance", ",", "columnName", ",", "cast", "(", "dataType", ",", "columnName", ",", "row", ")", ",", "tableType", ")", ")", ";", "}", "}", "return", "vars", ";", "}" ]
loop through each of the columns in the row , migrating each as a resource or relation .
train
false
69,287
public final void println(final LocalizableMessage msg){ if (!isQuiet()) { out.println(wrap(msg)); } }
[ "public", "final", "void", "println", "(", "final", "LocalizableMessage", "msg", ")", "{", "if", "(", "!", "isQuiet", "(", ")", ")", "{", "out", ".", "println", "(", "wrap", "(", "msg", ")", ")", ";", "}", "}" ]
displays a message to the output stream .
train
false
69,288
public boolean checkStationaryPoint(final double xOld,final double xNew,final int statStateIterations,final Type ecType){ if (Math.abs(xNew - xOld) >= rootEpsilon_) { this.statStateIterations=0; return false; } this.statStateIterations++; if (statStateIterations <= maxStationaryStateIterations_) return false; this.ecType=Type.StationaryPoint; return true; }
[ "public", "boolean", "checkStationaryPoint", "(", "final", "double", "xOld", ",", "final", "double", "xNew", ",", "final", "int", "statStateIterations", ",", "final", "Type", "ecType", ")", "{", "if", "(", "Math", ".", "abs", "(", "xNew", "-", "xOld", ")", ">=", "rootEpsilon_", ")", "{", "this", ".", "statStateIterations", "=", "0", ";", "return", "false", ";", "}", "this", ".", "statStateIterations", "++", ";", "if", "(", "statStateIterations", "<=", "maxStationaryStateIterations_", ")", "return", "false", ";", "this", ".", "ecType", "=", "Type", ".", "StationaryPoint", ";", "return", "true", ";", "}" ]
test if the root variation is below rootepsilon
train
false
69,289
private void recomputeSeperation(double[][] means,double[] sep,double[][] cdist){ final int k=means.length; assert (sep.length == k); boolean issquared=(distanceFunction instanceof SquaredEuclideanDistanceFunction); Arrays.fill(sep,Double.POSITIVE_INFINITY); for (int i=1; i < k; i++) { DoubleVector mi=DoubleVector.wrap(means[i]); for (int j=0; j < i; j++) { double d=distanceFunction.distance(mi,DoubleVector.wrap(means[j])); d=issquared ? Math.sqrt(d) : d; d*=.5; cdist[i][j]=d; cdist[j][i]=d; sep[i]=(d < sep[i]) ? d : sep[i]; sep[j]=(d < sep[j]) ? d : sep[j]; } } }
[ "private", "void", "recomputeSeperation", "(", "double", "[", "]", "[", "]", "means", ",", "double", "[", "]", "sep", ",", "double", "[", "]", "[", "]", "cdist", ")", "{", "final", "int", "k", "=", "means", ".", "length", ";", "assert", "(", "sep", ".", "length", "==", "k", ")", ";", "boolean", "issquared", "=", "(", "distanceFunction", "instanceof", "SquaredEuclideanDistanceFunction", ")", ";", "Arrays", ".", "fill", "(", "sep", ",", "Double", ".", "POSITIVE_INFINITY", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "k", ";", "i", "++", ")", "{", "DoubleVector", "mi", "=", "DoubleVector", ".", "wrap", "(", "means", "[", "i", "]", ")", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "i", ";", "j", "++", ")", "{", "double", "d", "=", "distanceFunction", ".", "distance", "(", "mi", ",", "DoubleVector", ".", "wrap", "(", "means", "[", "j", "]", ")", ")", ";", "d", "=", "issquared", "?", "Math", ".", "sqrt", "(", "d", ")", ":", "d", ";", "d", "*=", ".5", ";", "cdist", "[", "i", "]", "[", "j", "]", "=", "d", ";", "cdist", "[", "j", "]", "[", "i", "]", "=", "d", ";", "sep", "[", "i", "]", "=", "(", "d", "<", "sep", "[", "i", "]", ")", "?", "d", ":", "sep", "[", "i", "]", ";", "sep", "[", "j", "]", "=", "(", "d", "<", "sep", "[", "j", "]", ")", "?", "d", ":", "sep", "[", "j", "]", ";", "}", "}", "}" ]
recompute the separation of cluster means .
train
false
69,290
default Document read(URL jsonUrl) throws IOException { return read(jsonUrl.openStream()); }
[ "default", "Document", "read", "(", "URL", "jsonUrl", ")", "throws", "IOException", "{", "return", "read", "(", "jsonUrl", ".", "openStream", "(", ")", ")", ";", "}" ]
read a document from the content at the given url .
train
false
69,291
static int popLength(InputStream stream){ byte[] lengthBytes=new byte[Integer.SIZE / Byte.SIZE]; try { stream.read(lengthBytes); } catch ( IOException e) { log.error("IOException popping length from input stream: ",e); return -1; } ByteBuffer buffer=ByteBuffer.wrap(lengthBytes); buffer.order(ByteOrder.BIG_ENDIAN); return buffer.getInt(); }
[ "static", "int", "popLength", "(", "InputStream", "stream", ")", "{", "byte", "[", "]", "lengthBytes", "=", "new", "byte", "[", "Integer", ".", "SIZE", "/", "Byte", ".", "SIZE", "]", ";", "try", "{", "stream", ".", "read", "(", "lengthBytes", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "log", ".", "error", "(", "\"IOException popping length from input stream: \"", ",", "e", ")", ";", "return", "-", "1", ";", "}", "ByteBuffer", "buffer", "=", "ByteBuffer", ".", "wrap", "(", "lengthBytes", ")", ";", "buffer", ".", "order", "(", "ByteOrder", ".", "BIG_ENDIAN", ")", ";", "return", "buffer", ".", "getInt", "(", ")", ";", "}" ]
take the output of lengthvalueencode ( ) and decode it to a message of the given type .
train
false
69,293
public java.lang.StringBuffer append(char c){ internal.append(c); return this; }
[ "public", "java", ".", "lang", ".", "StringBuffer", "append", "(", "char", "c", ")", "{", "internal", ".", "append", "(", "c", ")", ";", "return", "this", ";", "}" ]
appends the string representation of the char argument to this string buffer . the argument is appended to the contents of this string buffer . the length of this string buffer increases by 1 . the overall effect is exactly as if the argument were converted to a string by the method string . valueof ( char ) and the character in that string were then appended to this stringbuffer object .
train
false
69,294
public void edit(File file) throws IOException { checkAWTPermission(); checkExec(); checkActionSupport(Action.EDIT); file.canWrite(); checkFileValidation(file); peer.edit(file); }
[ "public", "void", "edit", "(", "File", "file", ")", "throws", "IOException", "{", "checkAWTPermission", "(", ")", ";", "checkExec", "(", ")", ";", "checkActionSupport", "(", "Action", ".", "EDIT", ")", ";", "file", ".", "canWrite", "(", ")", ";", "checkFileValidation", "(", "file", ")", ";", "peer", ".", "edit", "(", "file", ")", ";", "}" ]
launches the associated editor application and opens a file for editing .
train
false
69,295
public static void leftShift(ObjectOutputStream self,Object value) throws IOException { self.writeObject(value); }
[ "public", "static", "void", "leftShift", "(", "ObjectOutputStream", "self", ",", "Object", "value", ")", "throws", "IOException", "{", "self", ".", "writeObject", "(", "value", ")", ";", "}" ]
overloads the leftshift operator to add objects to an objectoutputstream .
train
false
69,296
public void deferFree(final int rwaddr,final int sze){ m_allocationWriteLock.lock(); try { if (sze > (this.m_maxFixedAlloc - 4)) { m_deferredFreeOut.writeInt(-rwaddr); m_deferredFreeOut.writeInt(sze); log.debug("Unexpected code path deferring free of direct blob address"); } else { m_deferredFreeOut.writeInt(rwaddr); } } catch ( IOException e) { throw new RuntimeException("Could not free: rwaddr=" + rwaddr + ", size="+ sze,e); } finally { m_allocationWriteLock.unlock(); } }
[ "public", "void", "deferFree", "(", "final", "int", "rwaddr", ",", "final", "int", "sze", ")", "{", "m_allocationWriteLock", ".", "lock", "(", ")", ";", "try", "{", "if", "(", "sze", ">", "(", "this", ".", "m_maxFixedAlloc", "-", "4", ")", ")", "{", "m_deferredFreeOut", ".", "writeInt", "(", "-", "rwaddr", ")", ";", "m_deferredFreeOut", ".", "writeInt", "(", "sze", ")", ";", "log", ".", "debug", "(", "\"Unexpected code path deferring free of direct blob address\"", ")", ";", "}", "else", "{", "m_deferredFreeOut", ".", "writeInt", "(", "rwaddr", ")", ";", "}", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Could not free: rwaddr=\"", "+", "rwaddr", "+", "\", size=\"", "+", "sze", ",", "e", ")", ";", "}", "finally", "{", "m_allocationWriteLock", ".", "unlock", "(", ")", ";", "}", "}" ]
adds the address for later freeing to the deferred free list . < p > if the allocation is for a blob then the sze is also stored < p > the deferred list is checked on allocblock and prior to commit . < p > deferredfrees are written to the deferred psoutputstream
train
false
69,297
int addVert(float x,float y,float z){ int i=nvert; if (i >= maxvert) { if (vert == null) { maxvert=100; vert=new float[maxvert * 3]; } else { maxvert*=2; float nv[]=new float[maxvert * 3]; System.arraycopy(vert,0,nv,0,vert.length); vert=nv; } } i*=3; vert[i]=x; vert[i + 1]=y; vert[i + 2]=z; return nvert++; }
[ "int", "addVert", "(", "float", "x", ",", "float", "y", ",", "float", "z", ")", "{", "int", "i", "=", "nvert", ";", "if", "(", "i", ">=", "maxvert", ")", "{", "if", "(", "vert", "==", "null", ")", "{", "maxvert", "=", "100", ";", "vert", "=", "new", "float", "[", "maxvert", "*", "3", "]", ";", "}", "else", "{", "maxvert", "*=", "2", ";", "float", "nv", "[", "]", "=", "new", "float", "[", "maxvert", "*", "3", "]", ";", "System", ".", "arraycopy", "(", "vert", ",", "0", ",", "nv", ",", "0", ",", "vert", ".", "length", ")", ";", "vert", "=", "nv", ";", "}", "}", "i", "*=", "3", ";", "vert", "[", "i", "]", "=", "x", ";", "vert", "[", "i", "+", "1", "]", "=", "y", ";", "vert", "[", "i", "+", "2", "]", "=", "z", ";", "return", "nvert", "++", ";", "}" ]
add a vertex to this model
train
false
69,298
private com.google.security.zynamics.binnavi.debug.models.trace.TraceLogger createLogger(){ return new com.google.security.zynamics.binnavi.debug.models.trace.TraceLogger(project == null ? new ModuleTraceProvider(module.getNative()) : new ProjectTraceProvider(project.getNative()),debugger.getNative()); }
[ "private", "com", ".", "google", ".", "security", ".", "zynamics", ".", "binnavi", ".", "debug", ".", "models", ".", "trace", ".", "TraceLogger", "createLogger", "(", ")", "{", "return", "new", "com", ".", "google", ".", "security", ".", "zynamics", ".", "binnavi", ".", "debug", ".", "models", ".", "trace", ".", "TraceLogger", "(", "project", "==", "null", "?", "new", "ModuleTraceProvider", "(", "module", ".", "getNative", "(", ")", ")", ":", "new", "ProjectTraceProvider", "(", "project", ".", "getNative", "(", ")", ")", ",", "debugger", ".", "getNative", "(", ")", ")", ";", "}" ]
creates a new internal trace logger object .
train
false
69,299
@Override public int hashCode(){ return variable.hashCode() - value.hashCode(); }
[ "@", "Override", "public", "int", "hashCode", "(", ")", "{", "return", "variable", ".", "hashCode", "(", ")", "-", "value", ".", "hashCode", "(", ")", ";", "}" ]
returns the distribution ' s hashcode
train
false
69,300
public void alignRight(ArrayList<Integer> nodes){ if (m_bNeedsUndoAction) { addUndoAction(new alignRightAction(nodes)); } int nMaxX=-1; for (int iNode=0; iNode < nodes.size(); iNode++) { int nX=getPositionX(nodes.get(iNode)); if (nX > nMaxX || iNode == 0) { nMaxX=nX; } } for (int iNode=0; iNode < nodes.size(); iNode++) { int nNode=nodes.get(iNode); m_nPositionX.set(nNode,nMaxX); } }
[ "public", "void", "alignRight", "(", "ArrayList", "<", "Integer", ">", "nodes", ")", "{", "if", "(", "m_bNeedsUndoAction", ")", "{", "addUndoAction", "(", "new", "alignRightAction", "(", "nodes", ")", ")", ";", "}", "int", "nMaxX", "=", "-", "1", ";", "for", "(", "int", "iNode", "=", "0", ";", "iNode", "<", "nodes", ".", "size", "(", ")", ";", "iNode", "++", ")", "{", "int", "nX", "=", "getPositionX", "(", "nodes", ".", "get", "(", "iNode", ")", ")", ";", "if", "(", "nX", ">", "nMaxX", "||", "iNode", "==", "0", ")", "{", "nMaxX", "=", "nX", ";", "}", "}", "for", "(", "int", "iNode", "=", "0", ";", "iNode", "<", "nodes", ".", "size", "(", ")", ";", "iNode", "++", ")", "{", "int", "nNode", "=", "nodes", ".", "get", "(", "iNode", ")", ";", "m_nPositionX", ".", "set", "(", "nNode", ",", "nMaxX", ")", ";", "}", "}" ]
align set of nodes with the right most node in the list
train
false
69,301
public MediaSize(float x,float y,int units,MediaSizeName media){ super(x,y,units); if (x > y) { throw new IllegalArgumentException("X dimension > Y dimension"); } if (media != null && mediaMap.get(media) == null) { mediaName=media; mediaMap.put(mediaName,this); } sizeVector.add(this); }
[ "public", "MediaSize", "(", "float", "x", ",", "float", "y", ",", "int", "units", ",", "MediaSizeName", "media", ")", "{", "super", "(", "x", ",", "y", ",", "units", ")", ";", "if", "(", "x", ">", "y", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"X dimension > Y dimension\"", ")", ";", "}", "if", "(", "media", "!=", "null", "&&", "mediaMap", ".", "get", "(", "media", ")", "==", "null", ")", "{", "mediaName", "=", "media", ";", "mediaMap", ".", "put", "(", "mediaName", ",", "this", ")", ";", "}", "sizeVector", ".", "add", "(", "this", ")", ";", "}" ]
construct a new media size attribute from the given floating - point values .
train
false
69,302
public void delete(String name) throws IOException { if (name.equalsIgnoreCase(DATE)) { date=null; } else { throw new IOException("Name not supported by InvalidityDateExtension"); } encodeThis(); }
[ "public", "void", "delete", "(", "String", "name", ")", "throws", "IOException", "{", "if", "(", "name", ".", "equalsIgnoreCase", "(", "DATE", ")", ")", "{", "date", "=", "null", ";", "}", "else", "{", "throw", "new", "IOException", "(", "\"Name not supported by InvalidityDateExtension\"", ")", ";", "}", "encodeThis", "(", ")", ";", "}" ]
delete the attribute value .
train
true
69,304
private AttributeType(final String name,final Syntax syntax,final MatchingRule equalityMatchingRule){ final StringBuilder builder=new StringBuilder(name.length() + 4); StaticUtils.toLowerCase(name,builder); builder.append("-oid"); this.oid=builder.toString(); this.names=Collections.singletonList(name); this.isObsolete=false; this.superiorTypeOID=null; this.superiorType=null; this.equalityMatchingRule=equalityMatchingRule; this.equalityMatchingRuleOID=equalityMatchingRule.getOID(); this.orderingMatchingRuleOID=null; this.substringMatchingRuleOID=null; this.approximateMatchingRuleOID=null; this.syntax=syntax; this.syntaxOID=syntax.getOID(); this.isSingleValue=false; this.isCollective=false; this.isNoUserModification=false; this.attributeUsage=null; this.isObjectClassType=false; this.isPlaceHolder=true; this.normalizedName=StaticUtils.toLowerCase(getNameOrOID()); }
[ "private", "AttributeType", "(", "final", "String", "name", ",", "final", "Syntax", "syntax", ",", "final", "MatchingRule", "equalityMatchingRule", ")", "{", "final", "StringBuilder", "builder", "=", "new", "StringBuilder", "(", "name", ".", "length", "(", ")", "+", "4", ")", ";", "StaticUtils", ".", "toLowerCase", "(", "name", ",", "builder", ")", ";", "builder", ".", "append", "(", "\"-oid\"", ")", ";", "this", ".", "oid", "=", "builder", ".", "toString", "(", ")", ";", "this", ".", "names", "=", "Collections", ".", "singletonList", "(", "name", ")", ";", "this", ".", "isObsolete", "=", "false", ";", "this", ".", "superiorTypeOID", "=", "null", ";", "this", ".", "superiorType", "=", "null", ";", "this", ".", "equalityMatchingRule", "=", "equalityMatchingRule", ";", "this", ".", "equalityMatchingRuleOID", "=", "equalityMatchingRule", ".", "getOID", "(", ")", ";", "this", ".", "orderingMatchingRuleOID", "=", "null", ";", "this", ".", "substringMatchingRuleOID", "=", "null", ";", "this", ".", "approximateMatchingRuleOID", "=", "null", ";", "this", ".", "syntax", "=", "syntax", ";", "this", ".", "syntaxOID", "=", "syntax", ".", "getOID", "(", ")", ";", "this", ".", "isSingleValue", "=", "false", ";", "this", ".", "isCollective", "=", "false", ";", "this", ".", "isNoUserModification", "=", "false", ";", "this", ".", "attributeUsage", "=", "null", ";", "this", ".", "isObjectClassType", "=", "false", ";", "this", ".", "isPlaceHolder", "=", "true", ";", "this", ".", "normalizedName", "=", "StaticUtils", ".", "toLowerCase", "(", "getNameOrOID", "(", ")", ")", ";", "}" ]
creates a new place - holder attribute type having the specified name , default syntax , and default matching rule .
train
false
69,305
public boolean isDefending(){ return (isBeingAttacked() && (System.currentTimeMillis() - combatIconTime < 4 * TURN_LENGTH)); }
[ "public", "boolean", "isDefending", "(", ")", "{", "return", "(", "isBeingAttacked", "(", ")", "&&", "(", "System", ".", "currentTimeMillis", "(", ")", "-", "combatIconTime", "<", "4", "*", "TURN_LENGTH", ")", ")", ";", "}" ]
check if the entity is defending against an attack right now . the entity is defending if the last attack happened within 1 . 2s .
train
false
69,306
public static Byte toByte(Object o,Byte defaultValue){ if (o instanceof Byte) return (Byte)o; if (defaultValue != null) return new Byte(toByteValue(o,defaultValue.byteValue())); byte res=toByteValue(o,Byte.MIN_VALUE); if (res == Byte.MIN_VALUE) return defaultValue; return new Byte(res); }
[ "public", "static", "Byte", "toByte", "(", "Object", "o", ",", "Byte", "defaultValue", ")", "{", "if", "(", "o", "instanceof", "Byte", ")", "return", "(", "Byte", ")", "o", ";", "if", "(", "defaultValue", "!=", "null", ")", "return", "new", "Byte", "(", "toByteValue", "(", "o", ",", "defaultValue", ".", "byteValue", "(", ")", ")", ")", ";", "byte", "res", "=", "toByteValue", "(", "o", ",", "Byte", ".", "MIN_VALUE", ")", ";", "if", "(", "res", "==", "Byte", ".", "MIN_VALUE", ")", "return", "defaultValue", ";", "return", "new", "Byte", "(", "res", ")", ";", "}" ]
cast a object to a byte object ( reference type )
train
true
69,307
public Instance startMachine(String workspaceId,MachineConfig machineConfig) throws ServerException, ConflictException, NotFoundException { try (StripedLocks.ReadLock lock=stripedLocks.acquireReadLock(workspaceId)){ getRunningState(workspaceId); } List<String> agents=Collections.singletonList("org.eclipse.che.terminal"); Instance instance=environmentEngine.startMachine(workspaceId,machineConfig,agents); launchAgents(instance,agents); try (StripedLocks.WriteLock lock=stripedLocks.acquireWriteLock(workspaceId)){ WorkspaceState workspaceState=workspaces.get(workspaceId); if (workspaceState == null || workspaceState.status != RUNNING) { try { environmentEngine.stopMachine(workspaceId,instance.getId()); } catch ( NotFoundException|ServerException|ConflictException e) { LOG.error(e.getLocalizedMessage(),e); } throw new ConflictException(format("Environment of workspace '%s' was stopped during start of machine",workspaceId)); } } return instance; }
[ "public", "Instance", "startMachine", "(", "String", "workspaceId", ",", "MachineConfig", "machineConfig", ")", "throws", "ServerException", ",", "ConflictException", ",", "NotFoundException", "{", "try", "(", "StripedLocks", ".", "ReadLock", "lock", "=", "stripedLocks", ".", "acquireReadLock", "(", "workspaceId", ")", ")", "{", "getRunningState", "(", "workspaceId", ")", ";", "}", "List", "<", "String", ">", "agents", "=", "Collections", ".", "singletonList", "(", "\"org.eclipse.che.terminal\"", ")", ";", "Instance", "instance", "=", "environmentEngine", ".", "startMachine", "(", "workspaceId", ",", "machineConfig", ",", "agents", ")", ";", "launchAgents", "(", "instance", ",", "agents", ")", ";", "try", "(", "StripedLocks", ".", "WriteLock", "lock", "=", "stripedLocks", ".", "acquireWriteLock", "(", "workspaceId", ")", ")", "{", "WorkspaceState", "workspaceState", "=", "workspaces", ".", "get", "(", "workspaceId", ")", ";", "if", "(", "workspaceState", "==", "null", "||", "workspaceState", ".", "status", "!=", "RUNNING", ")", "{", "try", "{", "environmentEngine", ".", "stopMachine", "(", "workspaceId", ",", "instance", ".", "getId", "(", ")", ")", ";", "}", "catch", "(", "NotFoundException", "|", "ServerException", "|", "ConflictException", "e", ")", "{", "LOG", ".", "error", "(", "e", ".", "getLocalizedMessage", "(", ")", ",", "e", ")", ";", "}", "throw", "new", "ConflictException", "(", "format", "(", "\"Environment of workspace '%s' was stopped during start of machine\"", ",", "workspaceId", ")", ")", ";", "}", "}", "return", "instance", ";", "}" ]
starts machine in running workspace .
train
false
69,308
protected String rtrim(String s){ if ((s == null) || (s.length() == 0)) { return s; } int pos=s.length(); while ((pos > 0) && Character.isWhitespace(s.charAt(pos - 1))) { --pos; } return s.substring(0,pos); }
[ "protected", "String", "rtrim", "(", "String", "s", ")", "{", "if", "(", "(", "s", "==", "null", ")", "||", "(", "s", ".", "length", "(", ")", "==", "0", ")", ")", "{", "return", "s", ";", "}", "int", "pos", "=", "s", ".", "length", "(", ")", ";", "while", "(", "(", "pos", ">", "0", ")", "&&", "Character", ".", "isWhitespace", "(", "s", ".", "charAt", "(", "pos", "-", "1", ")", ")", ")", "{", "--", "pos", ";", "}", "return", "s", ".", "substring", "(", "0", ",", "pos", ")", ";", "}" ]
remove the trailing whitespace from the specified string .
train
true
69,309
private void drawHole(){ if (mDrawHole) { mDrawCanvas.drawCircle(mContentRect.width() / 2,mContentRect.height() / 2,getDiameter() / 4,mHolePaint); } }
[ "private", "void", "drawHole", "(", ")", "{", "if", "(", "mDrawHole", ")", "{", "mDrawCanvas", ".", "drawCircle", "(", "mContentRect", ".", "width", "(", ")", "/", "2", ",", "mContentRect", ".", "height", "(", ")", "/", "2", ",", "getDiameter", "(", ")", "/", "4", ",", "mHolePaint", ")", ";", "}", "}" ]
draws the hole in the center of the chart
train
false
69,311
public static int maxElement(int[] vals){ if (vals.length == 0) { throw new NoSuchElementException("No Max Element in Empty Array."); } return maxElement(vals,0,vals.length); }
[ "public", "static", "int", "maxElement", "(", "int", "[", "]", "vals", ")", "{", "if", "(", "vals", ".", "length", "==", "0", ")", "{", "throw", "new", "NoSuchElementException", "(", "\"No Max Element in Empty Array.\"", ")", ";", "}", "return", "maxElement", "(", "vals", ",", "0", ",", "vals", ".", "length", ")", ";", "}" ]
return largest element in the array using helper method for divide and conquer .
train
false
69,312
public static void randomBytes(byte[] bytes){ RANDOM.nextBytes(bytes); }
[ "public", "static", "void", "randomBytes", "(", "byte", "[", "]", "bytes", ")", "{", "RANDOM", ".", "nextBytes", "(", "bytes", ")", ";", "}" ]
get a number of pseudo random bytes .
train
false
69,313
private void updateTCPEndPointDetails(StoragePort port,CIMInstance tcpPointInstance) throws IOException { if (null != port) { port.setTcpPortNumber(Long.parseLong(getCIMPropertyValue(tcpPointInstance,PORTNUMBER))); _dbClient.persistObject(port); } }
[ "private", "void", "updateTCPEndPointDetails", "(", "StoragePort", "port", ",", "CIMInstance", "tcpPointInstance", ")", "throws", "IOException", "{", "if", "(", "null", "!=", "port", ")", "{", "port", ".", "setTcpPortNumber", "(", "Long", ".", "parseLong", "(", "getCIMPropertyValue", "(", "tcpPointInstance", ",", "PORTNUMBER", ")", ")", ")", ";", "_dbClient", ".", "persistObject", "(", "port", ")", ";", "}", "}" ]
update tcp port number details
train
false
69,314
public static Path createTempFile(Path tempDirPath,String prefix,String suffix) throws IOException { if (!Files.exists(tempDirPath)) { Files.createDirectory(tempDirPath); } return Files.createTempFile(tempDirPath,prefix,suffix,permissions); }
[ "public", "static", "Path", "createTempFile", "(", "Path", "tempDirPath", ",", "String", "prefix", ",", "String", "suffix", ")", "throws", "IOException", "{", "if", "(", "!", "Files", ".", "exists", "(", "tempDirPath", ")", ")", "{", "Files", ".", "createDirectory", "(", "tempDirPath", ")", ";", "}", "return", "Files", ".", "createTempFile", "(", "tempDirPath", ",", "prefix", ",", "suffix", ",", "permissions", ")", ";", "}" ]
creates a temporary file in the specified location . also creates the location if it does not exist .
train
false
69,315
private void checkBoundedTypeParameter(Method method){ TypeVariable<Method> typeParameter=getTypeParameter(method); assertEquals("T",typeParameter.getName()); assertEquals(method,typeParameter.getGenericDeclaration()); Type[] bounds=typeParameter.getBounds(); assertLenghtOne(bounds); Type bound=bounds[0]; assertEquals(BoundedGenericMethods.class,bound); }
[ "private", "void", "checkBoundedTypeParameter", "(", "Method", "method", ")", "{", "TypeVariable", "<", "Method", ">", "typeParameter", "=", "getTypeParameter", "(", "method", ")", ";", "assertEquals", "(", "\"T\"", ",", "typeParameter", ".", "getName", "(", ")", ")", ";", "assertEquals", "(", "method", ",", "typeParameter", ".", "getGenericDeclaration", "(", ")", ")", ";", "Type", "[", "]", "bounds", "=", "typeParameter", ".", "getBounds", "(", ")", ";", "assertLenghtOne", "(", "bounds", ")", ";", "Type", "bound", "=", "bounds", "[", "0", "]", ";", "assertEquals", "(", "BoundedGenericMethods", ".", "class", ",", "bound", ")", ";", "}" ]
tests whether the type parameter is upper bounded by boundedgenericmethods . < t extends boundedgenericmethods > .
train
false
69,316
public static String toHexString(byte[] value){ if (value == null) { return null; } StringBuffer buffer=new StringBuffer(2 * value.length); int single; for (int i=0; i < value.length; i++) { single=value[i] & 0xFF; if (single < 0x10) { buffer.append('0'); } buffer.append(Integer.toString(single,16)); } return buffer.toString(); }
[ "public", "static", "String", "toHexString", "(", "byte", "[", "]", "value", ")", "{", "if", "(", "value", "==", "null", ")", "{", "return", "null", ";", "}", "StringBuffer", "buffer", "=", "new", "StringBuffer", "(", "2", "*", "value", ".", "length", ")", ";", "int", "single", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "value", ".", "length", ";", "i", "++", ")", "{", "single", "=", "value", "[", "i", "]", "&", "0xFF", ";", "if", "(", "single", "<", "0x10", ")", "{", "buffer", ".", "append", "(", "'0'", ")", ";", "}", "buffer", ".", "append", "(", "Integer", ".", "toString", "(", "single", ",", "16", ")", ")", ";", "}", "return", "buffer", ".", "toString", "(", ")", ";", "}" ]
converts a byte array to a hexadecimal string . each byte is presented by its two digit hex - code ; 0x0a - > " 0a " , 0x00 - > " 00 " . no leading " 0x " is included in the result .
train
false
69,317
public String[] list(String path) throws IOException { if (path.startsWith("/")) { path=path.substring(1); } if (!path.endsWith("/")) { path=path + "/"; } ArrayList<String> names=new ArrayList<>(); ZipFile zipFile=getZipFile(); try { Enumeration<? extends ZipEntry> e=zipFile.entries(); while (e.hasMoreElements()) { ZipEntry entry=e.nextElement(); String name=entry.getName(); if (name.startsWith(path)) { String tail=name.substring(path.length()); int p=tail.indexOf('/'); if (p >= 0) { tail=tail.substring(0,p); } if (!tail.equals("") && !names.contains(tail)) { names.add(tail); } } } } finally { closeZipFile(zipFile); } String[] list=new String[names.size()]; names.toArray(list); return list; }
[ "public", "String", "[", "]", "list", "(", "String", "path", ")", "throws", "IOException", "{", "if", "(", "path", ".", "startsWith", "(", "\"/\"", ")", ")", "{", "path", "=", "path", ".", "substring", "(", "1", ")", ";", "}", "if", "(", "!", "path", ".", "endsWith", "(", "\"/\"", ")", ")", "{", "path", "=", "path", "+", "\"/\"", ";", "}", "ArrayList", "<", "String", ">", "names", "=", "new", "ArrayList", "<", ">", "(", ")", ";", "ZipFile", "zipFile", "=", "getZipFile", "(", ")", ";", "try", "{", "Enumeration", "<", "?", "extends", "ZipEntry", ">", "e", "=", "zipFile", ".", "entries", "(", ")", ";", "while", "(", "e", ".", "hasMoreElements", "(", ")", ")", "{", "ZipEntry", "entry", "=", "e", ".", "nextElement", "(", ")", ";", "String", "name", "=", "entry", ".", "getName", "(", ")", ";", "if", "(", "name", ".", "startsWith", "(", "path", ")", ")", "{", "String", "tail", "=", "name", ".", "substring", "(", "path", ".", "length", "(", ")", ")", ";", "int", "p", "=", "tail", ".", "indexOf", "(", "'/'", ")", ";", "if", "(", "p", ">=", "0", ")", "{", "tail", "=", "tail", ".", "substring", "(", "0", ",", "p", ")", ";", "}", "if", "(", "!", "tail", ".", "equals", "(", "\"\"", ")", "&&", "!", "names", ".", "contains", "(", "tail", ")", ")", "{", "names", ".", "add", "(", "tail", ")", ";", "}", "}", "}", "}", "finally", "{", "closeZipFile", "(", "zipFile", ")", ";", "}", "String", "[", "]", "list", "=", "new", "String", "[", "names", ".", "size", "(", ")", "]", ";", "names", ".", "toArray", "(", "list", ")", ";", "return", "list", ";", "}" ]
lists all the files in this directory .
train
true
69,318
public final void addToTiersByVarNames(List<String> varNames){ if (!variables.containsAll(varNames)) { for ( String varName : varNames) { addVariable(varName); } } for ( Object varName : varNames) { String node=(String)varName; int index=node.lastIndexOf(":t"); if (index != -1) { String substring=node.substring(index + 2); addToTier(new Integer(substring),node); } } }
[ "public", "final", "void", "addToTiersByVarNames", "(", "List", "<", "String", ">", "varNames", ")", "{", "if", "(", "!", "variables", ".", "containsAll", "(", "varNames", ")", ")", "{", "for", "(", "String", "varName", ":", "varNames", ")", "{", "addVariable", "(", "varName", ")", ";", "}", "}", "for", "(", "Object", "varName", ":", "varNames", ")", "{", "String", "node", "=", "(", "String", ")", "varName", ";", "int", "index", "=", "node", ".", "lastIndexOf", "(", "\":t\"", ")", ";", "if", "(", "index", "!=", "-", "1", ")", "{", "String", "substring", "=", "node", ".", "substring", "(", "index", "+", "2", ")", ";", "addToTier", "(", "new", "Integer", "(", "substring", ")", ",", "node", ")", ";", "}", "}", "}" ]
puts a variable into tier i if its name is xxx : i for some xxx and some i .
train
false
69,319
public static String addQuotationMarksIfNeeded(String str){ if (!str.startsWith("\"") && !str.isEmpty()) return "\"" + str + "\""; return str; }
[ "public", "static", "String", "addQuotationMarksIfNeeded", "(", "String", "str", ")", "{", "if", "(", "!", "str", ".", "startsWith", "(", "\"\\\"\"", ")", "&&", "!", "str", ".", "isEmpty", "(", ")", ")", "return", "\"\\\"\"", "+", "str", "+", "\"\\\"\"", ";", "return", "str", ";", "}" ]
add quotation marks at the beginning and end of the string .
train
false
69,320
public void updateTrainComboBox(JComboBox<Train> box,Car car){ box.removeAllItems(); box.addItem(null); for ( Train train : getTrainsByNameList()) { if (train.services(car)) { box.addItem(train); } } }
[ "public", "void", "updateTrainComboBox", "(", "JComboBox", "<", "Train", ">", "box", ",", "Car", "car", ")", "{", "box", ".", "removeAllItems", "(", ")", ";", "box", ".", "addItem", "(", "null", ")", ";", "for", "(", "Train", "train", ":", "getTrainsByNameList", "(", ")", ")", "{", "if", "(", "train", ".", "services", "(", "car", ")", ")", "{", "box", ".", "addItem", "(", "train", ")", ";", "}", "}", "}" ]
update combo box with trains that will service this car
train
false
69,321
protected void scaleTo(Projection thisProj){ if (DEBUG) { logger.fine("starting scaling evaluation."); } if (bitmap == null) { if (DEBUG) { logger.fine("source image is null"); } return; } Rectangle winRect=new Rectangle(thisProj.getWidth(),thisProj.getHeight()); Rectangle projRect=new Rectangle(); projRect.setLocation(point1); projRect.setSize(point2.x - point1.x,point2.y - point1.y); Rectangle sourceRect=new Rectangle(); sourceRect.width=bitmap.getWidth(this); sourceRect.height=bitmap.getHeight(this); clipRect=null; Rectangle iRect=projRect; if (corners == null || corners.size() <= 2) { iRect=winRect.intersection(projRect); } if (!iRect.isEmpty()) { Rectangle nClipRect=new Rectangle(); nClipRect.setBounds(sourceRect); if ((iRect.width >= 1) && (iRect.height >= 1)) { if (!winRect.contains(projRect)) { double xScaleFactor=(double)sourceRect.width / (double)projRect.width; double yScaleFactor=(double)sourceRect.height / (double)projRect.height; int xOffset=iRect.x - projRect.x; int yOffset=iRect.y - projRect.y; nClipRect.x=(int)Math.floor(xOffset * xScaleFactor); nClipRect.y=(int)Math.floor(yOffset * yScaleFactor); nClipRect.width=(int)Math.ceil(iRect.width * xScaleFactor); nClipRect.height=(int)Math.ceil(iRect.height * yScaleFactor); if (nClipRect.width + nClipRect.x > sourceRect.width) { nClipRect.width=sourceRect.width - nClipRect.x; } if (nClipRect.height + nClipRect.y > sourceRect.height) { nClipRect.height=sourceRect.height - nClipRect.y; } } if (nClipRect.width <= 0) { nClipRect.width=1; } if (nClipRect.height <= 0) { nClipRect.height=1; } double widthAdj=(double)iRect.width / (double)nClipRect.width; double heightAdj=(double)iRect.height / (double)nClipRect.height; AffineTransform xform=new AffineTransform(); xform.setToScale(widthAdj,heightAdj); clipRect=nClipRect; this.scalingXFormOp=new AffineTransformOp(xform,getScaleTransformType()); point1.setLocation(iRect.x,iRect.y); point2.setLocation(iRect.x + iRect.width,iRect.y + iRect.height); } } }
[ "protected", "void", "scaleTo", "(", "Projection", "thisProj", ")", "{", "if", "(", "DEBUG", ")", "{", "logger", ".", "fine", "(", "\"starting scaling evaluation.\"", ")", ";", "}", "if", "(", "bitmap", "==", "null", ")", "{", "if", "(", "DEBUG", ")", "{", "logger", ".", "fine", "(", "\"source image is null\"", ")", ";", "}", "return", ";", "}", "Rectangle", "winRect", "=", "new", "Rectangle", "(", "thisProj", ".", "getWidth", "(", ")", ",", "thisProj", ".", "getHeight", "(", ")", ")", ";", "Rectangle", "projRect", "=", "new", "Rectangle", "(", ")", ";", "projRect", ".", "setLocation", "(", "point1", ")", ";", "projRect", ".", "setSize", "(", "point2", ".", "x", "-", "point1", ".", "x", ",", "point2", ".", "y", "-", "point1", ".", "y", ")", ";", "Rectangle", "sourceRect", "=", "new", "Rectangle", "(", ")", ";", "sourceRect", ".", "width", "=", "bitmap", ".", "getWidth", "(", "this", ")", ";", "sourceRect", ".", "height", "=", "bitmap", ".", "getHeight", "(", "this", ")", ";", "clipRect", "=", "null", ";", "Rectangle", "iRect", "=", "projRect", ";", "if", "(", "corners", "==", "null", "||", "corners", ".", "size", "(", ")", "<=", "2", ")", "{", "iRect", "=", "winRect", ".", "intersection", "(", "projRect", ")", ";", "}", "if", "(", "!", "iRect", ".", "isEmpty", "(", ")", ")", "{", "Rectangle", "nClipRect", "=", "new", "Rectangle", "(", ")", ";", "nClipRect", ".", "setBounds", "(", "sourceRect", ")", ";", "if", "(", "(", "iRect", ".", "width", ">=", "1", ")", "&&", "(", "iRect", ".", "height", ">=", "1", ")", ")", "{", "if", "(", "!", "winRect", ".", "contains", "(", "projRect", ")", ")", "{", "double", "xScaleFactor", "=", "(", "double", ")", "sourceRect", ".", "width", "/", "(", "double", ")", "projRect", ".", "width", ";", "double", "yScaleFactor", "=", "(", "double", ")", "sourceRect", ".", "height", "/", "(", "double", ")", "projRect", ".", "height", ";", "int", "xOffset", "=", "iRect", ".", "x", "-", "projRect", ".", "x", ";", "int", "yOffset", "=", "iRect", ".", "y", "-", "projRect", ".", "y", ";", "nClipRect", ".", "x", "=", "(", "int", ")", "Math", ".", "floor", "(", "xOffset", "*", "xScaleFactor", ")", ";", "nClipRect", ".", "y", "=", "(", "int", ")", "Math", ".", "floor", "(", "yOffset", "*", "yScaleFactor", ")", ";", "nClipRect", ".", "width", "=", "(", "int", ")", "Math", ".", "ceil", "(", "iRect", ".", "width", "*", "xScaleFactor", ")", ";", "nClipRect", ".", "height", "=", "(", "int", ")", "Math", ".", "ceil", "(", "iRect", ".", "height", "*", "yScaleFactor", ")", ";", "if", "(", "nClipRect", ".", "width", "+", "nClipRect", ".", "x", ">", "sourceRect", ".", "width", ")", "{", "nClipRect", ".", "width", "=", "sourceRect", ".", "width", "-", "nClipRect", ".", "x", ";", "}", "if", "(", "nClipRect", ".", "height", "+", "nClipRect", ".", "y", ">", "sourceRect", ".", "height", ")", "{", "nClipRect", ".", "height", "=", "sourceRect", ".", "height", "-", "nClipRect", ".", "y", ";", "}", "}", "if", "(", "nClipRect", ".", "width", "<=", "0", ")", "{", "nClipRect", ".", "width", "=", "1", ";", "}", "if", "(", "nClipRect", ".", "height", "<=", "0", ")", "{", "nClipRect", ".", "height", "=", "1", ";", "}", "double", "widthAdj", "=", "(", "double", ")", "iRect", ".", "width", "/", "(", "double", ")", "nClipRect", ".", "width", ";", "double", "heightAdj", "=", "(", "double", ")", "iRect", ".", "height", "/", "(", "double", ")", "nClipRect", ".", "height", ";", "AffineTransform", "xform", "=", "new", "AffineTransform", "(", ")", ";", "xform", ".", "setToScale", "(", "widthAdj", ",", "heightAdj", ")", ";", "clipRect", "=", "nClipRect", ";", "this", ".", "scalingXFormOp", "=", "new", "AffineTransformOp", "(", "xform", ",", "getScaleTransformType", "(", ")", ")", ";", "point1", ".", "setLocation", "(", "iRect", ".", "x", ",", "iRect", ".", "y", ")", ";", "point2", ".", "setLocation", "(", "iRect", ".", "x", "+", "iRect", ".", "width", ",", "iRect", ".", "y", "+", "iRect", ".", "height", ")", ";", "}", "}", "}" ]
take the current projection and the sourceimage , and make the image that gets displayed fit the projection . if the source image isn ' t over the map , then this omgraphic is set to be invisible . if part of the image is on the map , only that part is used . the omraster bitmap variable is set with an image that is created from the source image , and the point1 variable is set to the point where the image should be placed . for instance , if the source image upper left corner is off the map to the northwest , then the omraster bitmap is set to a image , clipped from the source , that is entirely on the map . the omraster point1 is set to 0 , 0 , since that is where the clipped image should be placed .
train
false
69,322
public Random(){ this(System.currentTimeMillis()); }
[ "public", "Random", "(", ")", "{", "this", "(", "System", ".", "currentTimeMillis", "(", ")", ")", ";", "}" ]
creates a new random number generator . its seed is initialized to a value based on the current time : public random ( ) { this ( system . currenttimemillis ( ) ) ; } see also : system . currenttimemillis ( )
train
false
69,323
public int size(){ return symbols.size(); }
[ "public", "int", "size", "(", ")", "{", "return", "symbols", ".", "size", "(", ")", ";", "}" ]
returns the number of symbols contained in this production .
train
false
69,324
public void testCase22(){ byte rBytes[]={2}; BigInteger aNumber=BigInteger.ONE; BigInteger bNumber=BigInteger.ONE; BigInteger result=aNumber.add(bNumber); byte resBytes[]=new byte[rBytes.length]; resBytes=result.toByteArray(); for (int i=0; i < resBytes.length; i++) { assertTrue(resBytes[i] == rBytes[i]); } assertEquals("incorrect sign",1,result.signum()); }
[ "public", "void", "testCase22", "(", ")", "{", "byte", "rBytes", "[", "]", "=", "{", "2", "}", ";", "BigInteger", "aNumber", "=", "BigInteger", ".", "ONE", ";", "BigInteger", "bNumber", "=", "BigInteger", ".", "ONE", ";", "BigInteger", "result", "=", "aNumber", ".", "add", "(", "bNumber", ")", ";", "byte", "resBytes", "[", "]", "=", "new", "byte", "[", "rBytes", ".", "length", "]", ";", "resBytes", "=", "result", ".", "toByteArray", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "resBytes", ".", "length", ";", "i", "++", ")", "{", "assertTrue", "(", "resBytes", "[", "i", "]", "==", "rBytes", "[", "i", "]", ")", ";", "}", "assertEquals", "(", "\"incorrect sign\"", ",", "1", ",", "result", ".", "signum", "(", ")", ")", ";", "}" ]
add one to one
train
false
69,325
public void paintComponent(Graphics g){ if (image == null || image.getWidth(null) != getWidth() || image.getHeight(null) != getHeight()) { isImageUpToDate=false; } if (!isImageUpToDate) updateOffScreenImage(); g.drawImage(image,0,0,this); }
[ "public", "void", "paintComponent", "(", "Graphics", "g", ")", "{", "if", "(", "image", "==", "null", "||", "image", ".", "getWidth", "(", "null", ")", "!=", "getWidth", "(", ")", "||", "image", ".", "getHeight", "(", "null", ")", "!=", "getHeight", "(", ")", ")", "{", "isImageUpToDate", "=", "false", ";", "}", "if", "(", "!", "isImageUpToDate", ")", "updateOffScreenImage", "(", ")", ";", "g", ".", "drawImage", "(", "image", ",", "0", ",", "0", ",", "this", ")", ";", "}" ]
shows a graphical representation of the provided map data .
train
false
69,327
private void paintZoomIndicator(Graphics2D graphics){ if (mZoom != 0) { int width=getWidth() / 4; int x=(getWidth() / 2) - (width / 2); graphics.drawRect(x,getHeight() - 12,width,10); int zoomWidth=width / getZoomMultiplier(); int windowOffset=0; if (mDFTZoomWindowOffset != 0) { windowOffset=(int)(((double)mDFTZoomWindowOffset / (double)mDFTSize) * width); } graphics.fillRect(x + windowOffset,getHeight() - 12,zoomWidth,10); graphics.drawString("Zoom: " + getZoomMultiplier() + "x",x + width + 3,getHeight() - 2); } }
[ "private", "void", "paintZoomIndicator", "(", "Graphics2D", "graphics", ")", "{", "if", "(", "mZoom", "!=", "0", ")", "{", "int", "width", "=", "getWidth", "(", ")", "/", "4", ";", "int", "x", "=", "(", "getWidth", "(", ")", "/", "2", ")", "-", "(", "width", "/", "2", ")", ";", "graphics", ".", "drawRect", "(", "x", ",", "getHeight", "(", ")", "-", "12", ",", "width", ",", "10", ")", ";", "int", "zoomWidth", "=", "width", "/", "getZoomMultiplier", "(", ")", ";", "int", "windowOffset", "=", "0", ";", "if", "(", "mDFTZoomWindowOffset", "!=", "0", ")", "{", "windowOffset", "=", "(", "int", ")", "(", "(", "(", "double", ")", "mDFTZoomWindowOffset", "/", "(", "double", ")", "mDFTSize", ")", "*", "width", ")", ";", "}", "graphics", ".", "fillRect", "(", "x", "+", "windowOffset", ",", "getHeight", "(", ")", "-", "12", ",", "zoomWidth", ",", "10", ")", ";", "graphics", ".", "drawString", "(", "\"Zoom: \"", "+", "getZoomMultiplier", "(", ")", "+", "\"x\"", ",", "x", "+", "width", "+", "3", ",", "getHeight", "(", ")", "-", "2", ")", ";", "}", "}" ]
when zoom level is greater than zero , paints a small indicator at the bottom center of the screen showing the location of the zoom window within the overall dft results window
train
false
69,329
public void addCapabilitiesListener(Set<ContactId> contacts,CapabilitiesListener listener) throws RcsServiceNotAvailableException, RcsGenericException { if (mApi == null) { throw new RcsServiceNotAvailableException(); } if (contacts == null || contacts.isEmpty()) { throw new RcsIllegalArgumentException("contacts must not be null or empty!"); } try { ICapabilitiesListener rcsListener=new CapabilitiesListenerImpl(listener); mCapabilitiesListeners.put(listener,new WeakReference<>(rcsListener)); for ( ContactId contact : contacts) { mApi.addCapabilitiesListener2(contact,rcsListener); } } catch ( Exception e) { RcsIllegalArgumentException.assertException(e); throw new RcsGenericException(e); } }
[ "public", "void", "addCapabilitiesListener", "(", "Set", "<", "ContactId", ">", "contacts", ",", "CapabilitiesListener", "listener", ")", "throws", "RcsServiceNotAvailableException", ",", "RcsGenericException", "{", "if", "(", "mApi", "==", "null", ")", "{", "throw", "new", "RcsServiceNotAvailableException", "(", ")", ";", "}", "if", "(", "contacts", "==", "null", "||", "contacts", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "RcsIllegalArgumentException", "(", "\"contacts must not be null or empty!\"", ")", ";", "}", "try", "{", "ICapabilitiesListener", "rcsListener", "=", "new", "CapabilitiesListenerImpl", "(", "listener", ")", ";", "mCapabilitiesListeners", ".", "put", "(", "listener", ",", "new", "WeakReference", "<", ">", "(", "rcsListener", ")", ")", ";", "for", "(", "ContactId", "contact", ":", "contacts", ")", "{", "mApi", ".", "addCapabilitiesListener2", "(", "contact", ",", "rcsListener", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "RcsIllegalArgumentException", ".", "assertException", "(", "e", ")", ";", "throw", "new", "RcsGenericException", "(", "e", ")", ";", "}", "}" ]
registers a capabilities listener on a list of contacts
train
false
69,331
public ParsingException(String msg){ super(msg); i18nMessage=msg; }
[ "public", "ParsingException", "(", "String", "msg", ")", "{", "super", "(", "msg", ")", ";", "i18nMessage", "=", "msg", ";", "}" ]
constructs a parsingexception with the specified detail message . a detail message is a string that describes this particular exception , which may , for example , specify which algorithm is not available .
train
false
69,332
int indexOf(GridColumn column){ column=column.getFirstLeaf(); int index=columns.indexOf(column); if (index < 0) { log.warn("Bad column [" + column.getElement() + "]"); } return index; }
[ "int", "indexOf", "(", "GridColumn", "column", ")", "{", "column", "=", "column", ".", "getFirstLeaf", "(", ")", ";", "int", "index", "=", "columns", ".", "indexOf", "(", "column", ")", ";", "if", "(", "index", "<", "0", ")", "{", "log", ".", "warn", "(", "\"Bad column [\"", "+", "column", ".", "getElement", "(", ")", "+", "\"]\"", ")", ";", "}", "return", "index", ";", "}" ]
searches the receiver ' s list starting at the first column ( index 0 ) until a column is found that is equal to the argument , and returns the index of that column . if no column is found , returns - 1 .
train
false
69,333
public Iterator<RecordID> scanFrom(DataType startValue){ List<BEntry> validEntries=getAllValidEntries(); List<RecordID> rids=new ArrayList<RecordID>(); for ( BEntry le : validEntries) { if (startValue.compareTo(le.getKey()) < 1) { rids.add(le.getRecordID()); } } return rids.iterator(); }
[ "public", "Iterator", "<", "RecordID", ">", "scanFrom", "(", "DataType", "startValue", ")", "{", "List", "<", "BEntry", ">", "validEntries", "=", "getAllValidEntries", "(", ")", ";", "List", "<", "RecordID", ">", "rids", "=", "new", "ArrayList", "<", "RecordID", ">", "(", ")", ";", "for", "(", "BEntry", "le", ":", "validEntries", ")", "{", "if", "(", "startValue", ".", "compareTo", "(", "le", ".", "getKey", "(", ")", ")", "<", "1", ")", "{", "rids", ".", "add", "(", "le", ".", "getRecordID", "(", ")", ")", ";", "}", "}", "return", "rids", ".", "iterator", "(", ")", ";", "}" ]
creates an iterator of recordid ' s whose keys are greater than or equal to the given start value key .
train
false
69,334
@Override public String toString(){ final StringBuilder sbuf=new StringBuilder(); sbuf.append('['); sbuf.append(path[0]); for (int i=1; i < path.length; i++) { sbuf.append(':'); sbuf.append(path[i]); } sbuf.append(']'); return sbuf.toString(); }
[ "@", "Override", "public", "String", "toString", "(", ")", "{", "final", "StringBuilder", "sbuf", "=", "new", "StringBuilder", "(", ")", ";", "sbuf", ".", "append", "(", "'['", ")", ";", "sbuf", ".", "append", "(", "path", "[", "0", "]", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "path", ".", "length", ";", "i", "++", ")", "{", "sbuf", ".", "append", "(", "':'", ")", ";", "sbuf", ".", "append", "(", "path", "[", "i", "]", ")", ";", "}", "sbuf", ".", "append", "(", "']'", ")", ";", "return", "sbuf", ".", "toString", "(", ")", ";", "}" ]
get the string representation .
train
false
69,335
public Distribution(Distribution toMerge){ totaL=toMerge.totaL; m_perClass=new double[toMerge.numClasses()]; System.arraycopy(toMerge.m_perClass,0,m_perClass,0,toMerge.numClasses()); m_perClassPerBag=new double[1][0]; m_perClassPerBag[0]=new double[toMerge.numClasses()]; System.arraycopy(toMerge.m_perClass,0,m_perClassPerBag[0],0,toMerge.numClasses()); m_perBag=new double[1]; m_perBag[0]=totaL; }
[ "public", "Distribution", "(", "Distribution", "toMerge", ")", "{", "totaL", "=", "toMerge", ".", "totaL", ";", "m_perClass", "=", "new", "double", "[", "toMerge", ".", "numClasses", "(", ")", "]", ";", "System", ".", "arraycopy", "(", "toMerge", ".", "m_perClass", ",", "0", ",", "m_perClass", ",", "0", ",", "toMerge", ".", "numClasses", "(", ")", ")", ";", "m_perClassPerBag", "=", "new", "double", "[", "1", "]", "[", "0", "]", ";", "m_perClassPerBag", "[", "0", "]", "=", "new", "double", "[", "toMerge", ".", "numClasses", "(", ")", "]", ";", "System", ".", "arraycopy", "(", "toMerge", ".", "m_perClass", ",", "0", ",", "m_perClassPerBag", "[", "0", "]", ",", "0", ",", "toMerge", ".", "numClasses", "(", ")", ")", ";", "m_perBag", "=", "new", "double", "[", "1", "]", ";", "m_perBag", "[", "0", "]", "=", "totaL", ";", "}" ]
creates distribution with only one bag by merging all bags of given distribution .
train
false
69,336
private void reverseChildren(){ List<View> children=new ArrayList<View>(); for (int i=getChildCount() - 1; i >= 0; i--) { children.add(getChildAt(i)); } for ( View v : children) { bringChildToFront(v); } }
[ "private", "void", "reverseChildren", "(", ")", "{", "List", "<", "View", ">", "children", "=", "new", "ArrayList", "<", "View", ">", "(", ")", ";", "for", "(", "int", "i", "=", "getChildCount", "(", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "children", ".", "add", "(", "getChildAt", "(", "i", ")", ")", ";", "}", "for", "(", "View", "v", ":", "children", ")", "{", "bringChildToFront", "(", "v", ")", ";", "}", "}" ]
reverse the ordering of the children in this layout . note : bringchildtofront produced a non - deterministic ordering .
train
false
69,338
public GridConcurrentSkipListSet(SortedSet<E> s){ m=new ConcurrentSkipListMap<>(s.comparator()); addAll(s); }
[ "public", "GridConcurrentSkipListSet", "(", "SortedSet", "<", "E", ">", "s", ")", "{", "m", "=", "new", "ConcurrentSkipListMap", "<", ">", "(", "s", ".", "comparator", "(", ")", ")", ";", "addAll", "(", "s", ")", ";", "}" ]
constructs a new set containing the same elements and using the same ordering as the specified sorted set .
train
false
69,340
public void registerExtension(ExtensionNamespaceSupport extNsSpt){ String namespace=extNsSpt.getNamespace(); if (namespaceIndex(namespace,m_extensions) == -1) { m_extensions.add(extNsSpt); if (m_unregisteredExtensions.contains(namespace)) m_unregisteredExtensions.remove(namespace); } }
[ "public", "void", "registerExtension", "(", "ExtensionNamespaceSupport", "extNsSpt", ")", "{", "String", "namespace", "=", "extNsSpt", ".", "getNamespace", "(", ")", ";", "if", "(", "namespaceIndex", "(", "namespace", ",", "m_extensions", ")", "==", "-", "1", ")", "{", "m_extensions", ".", "add", "(", "extNsSpt", ")", ";", "if", "(", "m_unregisteredExtensions", ".", "contains", "(", "namespace", ")", ")", "m_unregisteredExtensions", ".", "remove", "(", "namespace", ")", ";", "}", "}" ]
register the extension namespace for an elemextensiondecl or elemfunction , and prepare a support object to launch the appropriate extensionhandler at transformation runtime .
train
true
69,341
public void createPolicyManagerConfiguration(String clusterName) throws ConfigurationException { String policyMgrConfigFileName=getModulePropertiesFileName(ConfigurationConstants.PM_PROPERTIES,getClusterHome()); File policyMgrConfigFile=new File(policyMgrConfigFileName); if (policyMgrConfigFile.exists()) { logger.debug(String.format("Policy manager configuration already exists at '%s'",policyMgrConfigFileName)); return; } ClusterPolicyManagerConfiguration config=new ClusterPolicyManagerConfiguration(clusterName); config.setClusterHome(getClusterHome()); config.setHost(ConfigurationConstants.PM_RMI_DEFAULT_HOST); TungstenProperties configProps=new TungstenProperties(); configProps.extractProperties(config,true); logger.debug("Writing out a policy manager configuration to '" + policyMgrConfigFileName + "'"); logger.debug("policymgr.properties contains:" + configProps); config.store(configProps,policyMgrConfigFileName); }
[ "public", "void", "createPolicyManagerConfiguration", "(", "String", "clusterName", ")", "throws", "ConfigurationException", "{", "String", "policyMgrConfigFileName", "=", "getModulePropertiesFileName", "(", "ConfigurationConstants", ".", "PM_PROPERTIES", ",", "getClusterHome", "(", ")", ")", ";", "File", "policyMgrConfigFile", "=", "new", "File", "(", "policyMgrConfigFileName", ")", ";", "if", "(", "policyMgrConfigFile", ".", "exists", "(", ")", ")", "{", "logger", ".", "debug", "(", "String", ".", "format", "(", "\"Policy manager configuration already exists at '%s'\"", ",", "policyMgrConfigFileName", ")", ")", ";", "return", ";", "}", "ClusterPolicyManagerConfiguration", "config", "=", "new", "ClusterPolicyManagerConfiguration", "(", "clusterName", ")", ";", "config", ".", "setClusterHome", "(", "getClusterHome", "(", ")", ")", ";", "config", ".", "setHost", "(", "ConfigurationConstants", ".", "PM_RMI_DEFAULT_HOST", ")", ";", "TungstenProperties", "configProps", "=", "new", "TungstenProperties", "(", ")", ";", "configProps", ".", "extractProperties", "(", "config", ",", "true", ")", ";", "logger", ".", "debug", "(", "\"Writing out a policy manager configuration to '\"", "+", "policyMgrConfigFileName", "+", "\"'\"", ")", ";", "logger", ".", "debug", "(", "\"policymgr.properties contains:\"", "+", "configProps", ")", ";", "config", ".", "store", "(", "configProps", ",", "policyMgrConfigFileName", ")", ";", "}" ]
creates a default policy manager configuration in the correct location
train
false
69,342
private void testBug71396PrepStatementClose(PreparedStatement[] testPStmt) throws SQLException { for ( Statement testStmt : testPStmt) { testStmt.close(); } }
[ "private", "void", "testBug71396PrepStatementClose", "(", "PreparedStatement", "[", "]", "testPStmt", ")", "throws", "SQLException", "{", "for", "(", "Statement", "testStmt", ":", "testPStmt", ")", "{", "testStmt", ".", "close", "(", ")", ";", "}", "}" ]
closes all preparedstatements in the array .
train
false
69,343
public void addComponent(MultiblockComponent component){ if (getComponentForLocation(component.getRelativePosition()) != null) throw new IllegalArgumentException("Location in multiblock already occupied"); components.add(component); changeAxisForNewComponent(component.getRelativePosition()); calculateCostForNewComponent(component); addComponentToLocationCache(component); }
[ "public", "void", "addComponent", "(", "MultiblockComponent", "component", ")", "{", "if", "(", "getComponentForLocation", "(", "component", ".", "getRelativePosition", "(", ")", ")", "!=", "null", ")", "throw", "new", "IllegalArgumentException", "(", "\"Location in multiblock already occupied\"", ")", ";", "components", ".", "add", "(", "component", ")", ";", "changeAxisForNewComponent", "(", "component", ".", "getRelativePosition", "(", ")", ")", ";", "calculateCostForNewComponent", "(", "component", ")", ";", "addComponentToLocationCache", "(", "component", ")", ";", "}" ]
adds a multiblock component to this multiblock . the component ' s x y z coords should be pivoted to the center of the structure .
train
false
69,344
static String createUTCTimeValue(final Date d){ synchronized (DATE_FORMAT_LOCK) { return DATE_FORMAT.format(d); } }
[ "static", "String", "createUTCTimeValue", "(", "final", "Date", "d", ")", "{", "synchronized", "(", "DATE_FORMAT_LOCK", ")", "{", "return", "DATE_FORMAT", ".", "format", "(", "d", ")", ";", "}", "}" ]
retrieves an string containing a utc time representation of the provided date .
train
false
69,345
protected void awaitCompletionComputeValuesAndShutdown(){ { final long before=System.currentTimeMillis(); runExecutorAndAwaitCompletion(); durationFlowFunctionConstruction=System.currentTimeMillis() - before; } if (computeValues) { final long before=System.currentTimeMillis(); computeValues(); durationFlowFunctionApplication=System.currentTimeMillis() - before; } if (logger.isDebugEnabled()) printStats(); executor.shutdown(); runExecutorAndAwaitCompletion(); }
[ "protected", "void", "awaitCompletionComputeValuesAndShutdown", "(", ")", "{", "{", "final", "long", "before", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "runExecutorAndAwaitCompletion", "(", ")", ";", "durationFlowFunctionConstruction", "=", "System", ".", "currentTimeMillis", "(", ")", "-", "before", ";", "}", "if", "(", "computeValues", ")", "{", "final", "long", "before", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "computeValues", "(", ")", ";", "durationFlowFunctionApplication", "=", "System", ".", "currentTimeMillis", "(", ")", "-", "before", ";", "}", "if", "(", "logger", ".", "isDebugEnabled", "(", ")", ")", "printStats", "(", ")", ";", "executor", ".", "shutdown", "(", ")", ";", "runExecutorAndAwaitCompletion", "(", ")", ";", "}" ]
awaits the completion of the exploded super graph . when complete , computes result values , shuts down the executor and returns .
train
false
69,346
private MenuItem addInternal(int group,int id,int categoryOrder,CharSequence title){ final MenuItemImpl item=createNewMenuItem(group,id,categoryOrder,title); mItems.add(findInsertIndex(mItems,categoryOrder),item); onItemsChanged(true); return item; }
[ "private", "MenuItem", "addInternal", "(", "int", "group", ",", "int", "id", ",", "int", "categoryOrder", ",", "CharSequence", "title", ")", "{", "final", "MenuItemImpl", "item", "=", "createNewMenuItem", "(", "group", ",", "id", ",", "categoryOrder", ",", "title", ")", ";", "mItems", ".", "add", "(", "findInsertIndex", "(", "mItems", ",", "categoryOrder", ")", ",", "item", ")", ";", "onItemsChanged", "(", "true", ")", ";", "return", "item", ";", "}" ]
adds an item to the menu . the other add methods funnel to this .
train
false
69,347
public boolean hasAny(){ return partitions != null && !partitions.isEmpty(); }
[ "public", "boolean", "hasAny", "(", ")", "{", "return", "partitions", "!=", "null", "&&", "!", "partitions", ".", "isEmpty", "(", ")", ";", "}" ]
indicates whether this instance has any partitions .
train
false
69,348
public int hashCode(Object obj){ return obj.hashCode(); }
[ "public", "int", "hashCode", "(", "Object", "obj", ")", "{", "return", "obj", ".", "hashCode", "(", ")", ";", "}" ]
this method returns the hash code for the supplied object .
train
false
69,351
protected View createChild(String name){ View view=null; if (name.equals(PG_SESSION)) { view=new StaticTextField(this,name,""); } else if (name.equals(BTN_GHOST)) { view=new Button(this,name,""); } else if (name.startsWith(AMViewInterface.PREFIX_STATIC_TXT)) { view=new CCStaticTextField(this,name,null); } else if (name.startsWith(AMViewInterface.PREFIX_SERIALIZABLE)) { view=new SerializedField(this,name,null); } else if (name.startsWith(AMViewInterface.PREFIX_CHECKBOX)) { view=new CCCheckBox(this,name,"true","false",false); } else if (name.startsWith(AMViewInterface.PREFIX_TEXTFIELD)) { view=new CCTextField(this,name,null); } else if (name.startsWith(AMViewInterface.PREFIX_LABEL)) { view=new CCLabel(this,name,null); } else if (name.startsWith(AMViewInterface.PREFIX_BUTTON)) { view=new CCButton(this,name,null); } else if (name.startsWith(AMViewInterface.PREFIX_SINGLE_CHOICE)) { view=new CCDropDownMenu(this,name,null); } else if (name.startsWith(AMViewInterface.PREFIX_HREF)) { view=new CCHref(this,name,null); } else if (name.startsWith(AMViewInterface.PREFIX_RADIO_BUTTON)) { view=new CCRadioButton(this,name,null); } else if (name.startsWith(AMViewInterface.PREFIX_INLINE_ALERT)) { view=new CCAlertInline(this,name,null); } else { throw new IllegalArgumentException("Invalid child name [" + name + "]"); } return view; }
[ "protected", "View", "createChild", "(", "String", "name", ")", "{", "View", "view", "=", "null", ";", "if", "(", "name", ".", "equals", "(", "PG_SESSION", ")", ")", "{", "view", "=", "new", "StaticTextField", "(", "this", ",", "name", ",", "\"\"", ")", ";", "}", "else", "if", "(", "name", ".", "equals", "(", "BTN_GHOST", ")", ")", "{", "view", "=", "new", "Button", "(", "this", ",", "name", ",", "\"\"", ")", ";", "}", "else", "if", "(", "name", ".", "startsWith", "(", "AMViewInterface", ".", "PREFIX_STATIC_TXT", ")", ")", "{", "view", "=", "new", "CCStaticTextField", "(", "this", ",", "name", ",", "null", ")", ";", "}", "else", "if", "(", "name", ".", "startsWith", "(", "AMViewInterface", ".", "PREFIX_SERIALIZABLE", ")", ")", "{", "view", "=", "new", "SerializedField", "(", "this", ",", "name", ",", "null", ")", ";", "}", "else", "if", "(", "name", ".", "startsWith", "(", "AMViewInterface", ".", "PREFIX_CHECKBOX", ")", ")", "{", "view", "=", "new", "CCCheckBox", "(", "this", ",", "name", ",", "\"true\"", ",", "\"false\"", ",", "false", ")", ";", "}", "else", "if", "(", "name", ".", "startsWith", "(", "AMViewInterface", ".", "PREFIX_TEXTFIELD", ")", ")", "{", "view", "=", "new", "CCTextField", "(", "this", ",", "name", ",", "null", ")", ";", "}", "else", "if", "(", "name", ".", "startsWith", "(", "AMViewInterface", ".", "PREFIX_LABEL", ")", ")", "{", "view", "=", "new", "CCLabel", "(", "this", ",", "name", ",", "null", ")", ";", "}", "else", "if", "(", "name", ".", "startsWith", "(", "AMViewInterface", ".", "PREFIX_BUTTON", ")", ")", "{", "view", "=", "new", "CCButton", "(", "this", ",", "name", ",", "null", ")", ";", "}", "else", "if", "(", "name", ".", "startsWith", "(", "AMViewInterface", ".", "PREFIX_SINGLE_CHOICE", ")", ")", "{", "view", "=", "new", "CCDropDownMenu", "(", "this", ",", "name", ",", "null", ")", ";", "}", "else", "if", "(", "name", ".", "startsWith", "(", "AMViewInterface", ".", "PREFIX_HREF", ")", ")", "{", "view", "=", "new", "CCHref", "(", "this", ",", "name", ",", "null", ")", ";", "}", "else", "if", "(", "name", ".", "startsWith", "(", "AMViewInterface", ".", "PREFIX_RADIO_BUTTON", ")", ")", "{", "view", "=", "new", "CCRadioButton", "(", "this", ",", "name", ",", "null", ")", ";", "}", "else", "if", "(", "name", ".", "startsWith", "(", "AMViewInterface", ".", "PREFIX_INLINE_ALERT", ")", ")", "{", "view", "=", "new", "CCAlertInline", "(", "this", ",", "name", ",", "null", ")", ";", "}", "else", "{", "throw", "new", "IllegalArgumentException", "(", "\"Invalid child name [\"", "+", "name", "+", "\"]\"", ")", ";", "}", "return", "view", ";", "}" ]
creates user interface components used by this view bean .
train
false
69,352
@Override public void dropView(){ view=null; subs.unsubscribeAll(); }
[ "@", "Override", "public", "void", "dropView", "(", ")", "{", "view", "=", "null", ";", "subs", ".", "unsubscribeAll", "(", ")", ";", "}" ]
unsubscribe when view is destroyed
train
false
69,353
void updatePressed(ActionEvent e,boolean newSignalGroup,boolean close){ if (curSignalGroup == null) { if (!checkNewNamesOK()) { return; } } if (!checkValidSignalMast()) { return; } String uName=_userName.getText(); SignalGroup g=checkNamesOK(); if (g == null) { return; } curSignalGroup=g; g.setUserName(uName); initializeIncludedList(); setSignalInformation(g); setMastAppearanceInformation(g); g.setSignalMast((SignalMast)mainSignal.getSelectedBean(),mainSignal.getSelectedDisplayName()); SignalGroupDirty=true; if (close) { finishUpdate(); } }
[ "void", "updatePressed", "(", "ActionEvent", "e", ",", "boolean", "newSignalGroup", ",", "boolean", "close", ")", "{", "if", "(", "curSignalGroup", "==", "null", ")", "{", "if", "(", "!", "checkNewNamesOK", "(", ")", ")", "{", "return", ";", "}", "}", "if", "(", "!", "checkValidSignalMast", "(", ")", ")", "{", "return", ";", "}", "String", "uName", "=", "_userName", ".", "getText", "(", ")", ";", "SignalGroup", "g", "=", "checkNamesOK", "(", ")", ";", "if", "(", "g", "==", "null", ")", "{", "return", ";", "}", "curSignalGroup", "=", "g", ";", "g", ".", "setUserName", "(", "uName", ")", ";", "initializeIncludedList", "(", ")", ";", "setSignalInformation", "(", "g", ")", ";", "setMastAppearanceInformation", "(", "g", ")", ";", "g", ".", "setSignalMast", "(", "(", "SignalMast", ")", "mainSignal", ".", "getSelectedBean", "(", ")", ",", "mainSignal", ".", "getSelectedDisplayName", "(", ")", ")", ";", "SignalGroupDirty", "=", "true", ";", "if", "(", "close", ")", "{", "finishUpdate", "(", ")", ";", "}", "}" ]
responds to the update button - update to signalgroup table
train
false
69,354
public void scanClass(InputStream bits) throws IOException { DataInputStream dstream=new DataInputStream(new BufferedInputStream(bits)); ClassFile cf=null; try { cf=new ClassFile(dstream); classIndex.put(cf.getName(),new HashSet<String>()); scanClass(cf); if (scanMethodAnnotations || scanParameterAnnotations) { scanMethods(cf); } if (scanFieldAnnotations) { scanFields(cf); } if (cf.getInterfaces() != null) { Set<String> intfs=new HashSet<String>(); for ( String intf : cf.getInterfaces()) { intfs.add(intf); } implementsIndex.put(cf.getName(),intfs); } } finally { dstream.close(); bits.close(); } }
[ "public", "void", "scanClass", "(", "InputStream", "bits", ")", "throws", "IOException", "{", "DataInputStream", "dstream", "=", "new", "DataInputStream", "(", "new", "BufferedInputStream", "(", "bits", ")", ")", ";", "ClassFile", "cf", "=", "null", ";", "try", "{", "cf", "=", "new", "ClassFile", "(", "dstream", ")", ";", "classIndex", ".", "put", "(", "cf", ".", "getName", "(", ")", ",", "new", "HashSet", "<", "String", ">", "(", ")", ")", ";", "scanClass", "(", "cf", ")", ";", "if", "(", "scanMethodAnnotations", "||", "scanParameterAnnotations", ")", "{", "scanMethods", "(", "cf", ")", ";", "}", "if", "(", "scanFieldAnnotations", ")", "{", "scanFields", "(", "cf", ")", ";", "}", "if", "(", "cf", ".", "getInterfaces", "(", ")", "!=", "null", ")", "{", "Set", "<", "String", ">", "intfs", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "for", "(", "String", "intf", ":", "cf", ".", "getInterfaces", "(", ")", ")", "{", "intfs", ".", "add", "(", "intf", ")", ";", "}", "implementsIndex", ".", "put", "(", "cf", ".", "getName", "(", ")", ",", "intfs", ")", ";", "}", "}", "finally", "{", "dstream", ".", "close", "(", ")", ";", "bits", ".", "close", "(", ")", ";", "}", "}" ]
parse a . class file for annotations
train
true
69,355
public void copyState(Lifecycle source){ _state=source._state; }
[ "public", "void", "copyState", "(", "Lifecycle", "source", ")", "{", "_state", "=", "source", ".", "_state", ";", "}" ]
copies from a target state .
train
false
69,356
private void fillResource(){ KeyNamePair pp=(KeyNamePair)fieldResourceType.getSelectedItem(); if (pp == null) return; int S_ResourceType_ID=pp.getKey(); KeyNamePair defaultValue=null; m_loading=true; fieldResource.removeAllItems(); String sql="SELECT S_Resource_ID, Name FROM S_Resource WHERE IsActive='Y' AND S_ResourceType_ID=? ORDER BY 2"; PreparedStatement pstmt=null; ResultSet rs=null; try { pstmt=DB.prepareStatement(sql,null); pstmt.setInt(1,S_ResourceType_ID); rs=pstmt.executeQuery(); while (rs.next()) { pp=new KeyNamePair(rs.getInt(1),rs.getString(2)); if (m_mAssignment.getS_Resource_ID() == pp.getKey()) defaultValue=pp; fieldResource.addItem(pp); } } catch ( SQLException e) { log.log(Level.SEVERE,sql,e); } finally { DB.close(rs,pstmt); rs=null; pstmt=null; } if (defaultValue != null) fieldResource.setSelectedItem(defaultValue); m_loading=false; }
[ "private", "void", "fillResource", "(", ")", "{", "KeyNamePair", "pp", "=", "(", "KeyNamePair", ")", "fieldResourceType", ".", "getSelectedItem", "(", ")", ";", "if", "(", "pp", "==", "null", ")", "return", ";", "int", "S_ResourceType_ID", "=", "pp", ".", "getKey", "(", ")", ";", "KeyNamePair", "defaultValue", "=", "null", ";", "m_loading", "=", "true", ";", "fieldResource", ".", "removeAllItems", "(", ")", ";", "String", "sql", "=", "\"SELECT S_Resource_ID, Name FROM S_Resource WHERE IsActive='Y' AND S_ResourceType_ID=? ORDER BY 2\"", ";", "PreparedStatement", "pstmt", "=", "null", ";", "ResultSet", "rs", "=", "null", ";", "try", "{", "pstmt", "=", "DB", ".", "prepareStatement", "(", "sql", ",", "null", ")", ";", "pstmt", ".", "setInt", "(", "1", ",", "S_ResourceType_ID", ")", ";", "rs", "=", "pstmt", ".", "executeQuery", "(", ")", ";", "while", "(", "rs", ".", "next", "(", ")", ")", "{", "pp", "=", "new", "KeyNamePair", "(", "rs", ".", "getInt", "(", "1", ")", ",", "rs", ".", "getString", "(", "2", ")", ")", ";", "if", "(", "m_mAssignment", ".", "getS_Resource_ID", "(", ")", "==", "pp", ".", "getKey", "(", ")", ")", "defaultValue", "=", "pp", ";", "fieldResource", ".", "addItem", "(", "pp", ")", ";", "}", "}", "catch", "(", "SQLException", "e", ")", "{", "log", ".", "log", "(", "Level", ".", "SEVERE", ",", "sql", ",", "e", ")", ";", "}", "finally", "{", "DB", ".", "close", "(", "rs", ",", "pstmt", ")", ";", "rs", "=", "null", ";", "pstmt", "=", "null", ";", "}", "if", "(", "defaultValue", "!=", "null", ")", "fieldResource", ".", "setSelectedItem", "(", "defaultValue", ")", ";", "m_loading", "=", "false", ";", "}" ]
fill resource pick from resource type
train
false
69,357
public SpyVersions loadVersions() throws XMLException { setLoading(true); try { final URL url=new URL(propertyLoader.getProperty(BasePropertyNames.VERSION_INFO_URL)); versions=(SpyVersions)loadFromInputStream(url.openStream()); } catch ( IOException|NullPointerException e) { throw new XMLException("Cannot read version info from " + propertyLoader.getProperty(BasePropertyNames.VERSION_INFO_URL),e); } setLoading(false); return versions; }
[ "public", "SpyVersions", "loadVersions", "(", ")", "throws", "XMLException", "{", "setLoading", "(", "true", ")", ";", "try", "{", "final", "URL", "url", "=", "new", "URL", "(", "propertyLoader", ".", "getProperty", "(", "BasePropertyNames", ".", "VERSION_INFO_URL", ")", ")", ";", "versions", "=", "(", "SpyVersions", ")", "loadFromInputStream", "(", "url", ".", "openStream", "(", ")", ")", ";", "}", "catch", "(", "IOException", "|", "NullPointerException", "e", ")", "{", "throw", "new", "XMLException", "(", "\"Cannot read version info from \"", "+", "propertyLoader", ".", "getProperty", "(", "BasePropertyNames", ".", "VERSION_INFO_URL", ")", ",", "e", ")", ";", "}", "setLoading", "(", "false", ")", ";", "return", "versions", ";", "}" ]
loads version information from the url .
train
false
69,360
@Override public final String toString(){ return HexTool.toString(baos.toByteArray()); }
[ "@", "Override", "public", "final", "String", "toString", "(", ")", "{", "return", "HexTool", ".", "toString", "(", "baos", ".", "toByteArray", "(", ")", ")", ";", "}" ]
changes this packet into a human - readable hexadecimal stream of bytes .
train
false
69,361
public boolean isValid(){ String value; if (thisone == null) { return false; } value=getText(); if (fieldType == FieldType.TEXT) { if ((value.length() < 1) && (allow0Length == false)) { return false; } else if (((allow0Length == true) && (value.length() == 0)) || (value.matches(validateRegExpr))) { return true; } else { return false; } } else if (fieldType == FieldType.INTEGRALNUMERIC) { try { if ((allow0Length == true) && (value.length() == 0)) { return true; } else if (value.length() == 0) { return false; } else if ((Integer.parseInt(value) >= minAllowedValue) && (Integer.parseInt(value) <= maxAllowedValue)) { return true; } else { return false; } } catch ( Exception e) { return false; } } else if (fieldType == FieldType.INTEGRALNUMERICPLUSSTRING) { Integer findLocation=999; Integer location=999; if ((allow0Length == true) && (value.length() == 0)) { return true; } else if (value.length() == 0) { return false; } location=value.indexOf('c'); if ((location != -1) && (location < findLocation)) { findLocation=location; } location=value.indexOf('C'); if ((location != -1) && (location < findLocation)) { findLocation=location; } location=value.indexOf('t'); if ((location != -1) && (location < findLocation)) { findLocation=location; } location=value.indexOf('T'); if ((location != -1) && (location < findLocation)) { findLocation=location; } if (findLocation == 999) { return false; } try { Integer address=Integer.parseInt(value.substring(0,findLocation)); if ((address < minAllowedValue) || (address > maxAllowedValue)) { return false; } else if ((value.length() < 2) || (!value.matches(validateRegExpr))) { return false; } else { return true; } } catch ( Exception e) { return false; } } else if (fieldType == FieldType.LIMITEDHEX) { try { if (value.length() == 0) { return false; } else if ((Integer.parseInt(value,16) >= minAllowedValue) && (Integer.parseInt(value,16) <= maxAllowedValue)) { return true; } else { return false; } } catch ( Exception e) { return false; } } else { return false; } }
[ "public", "boolean", "isValid", "(", ")", "{", "String", "value", ";", "if", "(", "thisone", "==", "null", ")", "{", "return", "false", ";", "}", "value", "=", "getText", "(", ")", ";", "if", "(", "fieldType", "==", "FieldType", ".", "TEXT", ")", "{", "if", "(", "(", "value", ".", "length", "(", ")", "<", "1", ")", "&&", "(", "allow0Length", "==", "false", ")", ")", "{", "return", "false", ";", "}", "else", "if", "(", "(", "(", "allow0Length", "==", "true", ")", "&&", "(", "value", ".", "length", "(", ")", "==", "0", ")", ")", "||", "(", "value", ".", "matches", "(", "validateRegExpr", ")", ")", ")", "{", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}", "else", "if", "(", "fieldType", "==", "FieldType", ".", "INTEGRALNUMERIC", ")", "{", "try", "{", "if", "(", "(", "allow0Length", "==", "true", ")", "&&", "(", "value", ".", "length", "(", ")", "==", "0", ")", ")", "{", "return", "true", ";", "}", "else", "if", "(", "value", ".", "length", "(", ")", "==", "0", ")", "{", "return", "false", ";", "}", "else", "if", "(", "(", "Integer", ".", "parseInt", "(", "value", ")", ">=", "minAllowedValue", ")", "&&", "(", "Integer", ".", "parseInt", "(", "value", ")", "<=", "maxAllowedValue", ")", ")", "{", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "return", "false", ";", "}", "}", "else", "if", "(", "fieldType", "==", "FieldType", ".", "INTEGRALNUMERICPLUSSTRING", ")", "{", "Integer", "findLocation", "=", "999", ";", "Integer", "location", "=", "999", ";", "if", "(", "(", "allow0Length", "==", "true", ")", "&&", "(", "value", ".", "length", "(", ")", "==", "0", ")", ")", "{", "return", "true", ";", "}", "else", "if", "(", "value", ".", "length", "(", ")", "==", "0", ")", "{", "return", "false", ";", "}", "location", "=", "value", ".", "indexOf", "(", "'c'", ")", ";", "if", "(", "(", "location", "!=", "-", "1", ")", "&&", "(", "location", "<", "findLocation", ")", ")", "{", "findLocation", "=", "location", ";", "}", "location", "=", "value", ".", "indexOf", "(", "'C'", ")", ";", "if", "(", "(", "location", "!=", "-", "1", ")", "&&", "(", "location", "<", "findLocation", ")", ")", "{", "findLocation", "=", "location", ";", "}", "location", "=", "value", ".", "indexOf", "(", "'t'", ")", ";", "if", "(", "(", "location", "!=", "-", "1", ")", "&&", "(", "location", "<", "findLocation", ")", ")", "{", "findLocation", "=", "location", ";", "}", "location", "=", "value", ".", "indexOf", "(", "'T'", ")", ";", "if", "(", "(", "location", "!=", "-", "1", ")", "&&", "(", "location", "<", "findLocation", ")", ")", "{", "findLocation", "=", "location", ";", "}", "if", "(", "findLocation", "==", "999", ")", "{", "return", "false", ";", "}", "try", "{", "Integer", "address", "=", "Integer", ".", "parseInt", "(", "value", ".", "substring", "(", "0", ",", "findLocation", ")", ")", ";", "if", "(", "(", "address", "<", "minAllowedValue", ")", "||", "(", "address", ">", "maxAllowedValue", ")", ")", "{", "return", "false", ";", "}", "else", "if", "(", "(", "value", ".", "length", "(", ")", "<", "2", ")", "||", "(", "!", "value", ".", "matches", "(", "validateRegExpr", ")", ")", ")", "{", "return", "false", ";", "}", "else", "{", "return", "true", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "return", "false", ";", "}", "}", "else", "if", "(", "fieldType", "==", "FieldType", ".", "LIMITEDHEX", ")", "{", "try", "{", "if", "(", "value", ".", "length", "(", ")", "==", "0", ")", "{", "return", "false", ";", "}", "else", "if", "(", "(", "Integer", ".", "parseInt", "(", "value", ",", "16", ")", ">=", "minAllowedValue", ")", "&&", "(", "Integer", ".", "parseInt", "(", "value", ",", "16", ")", "<=", "maxAllowedValue", ")", ")", "{", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "return", "false", ";", "}", "}", "else", "{", "return", "false", ";", "}", "}" ]
validates the field information . does not make any gui changes . a field value that is zero - length is considered invalid .
train
false
69,362
public PerTestClassLoaderRunner(Class<?> klass) throws InitializationError { super(klass); }
[ "public", "PerTestClassLoaderRunner", "(", "Class", "<", "?", ">", "klass", ")", "throws", "InitializationError", "{", "super", "(", "klass", ")", ";", "}" ]
instantiates a new test per class loader runner .
train
false
69,363
private void injectDynamically(){ injectionRequestProcessor.injectMembers(); stopwatch.resetAndLog("Static member injection"); initializer.injectAll(errors); stopwatch.resetAndLog("Instance injection"); errors.throwCreationExceptionIfErrorsExist(); for ( InjectorShell shell : shells) { loadEagerSingletons(shell.getInjector(),stage,errors); } stopwatch.resetAndLog("Preloading singletons"); errors.throwCreationExceptionIfErrorsExist(); }
[ "private", "void", "injectDynamically", "(", ")", "{", "injectionRequestProcessor", ".", "injectMembers", "(", ")", ";", "stopwatch", ".", "resetAndLog", "(", "\"Static member injection\"", ")", ";", "initializer", ".", "injectAll", "(", "errors", ")", ";", "stopwatch", ".", "resetAndLog", "(", "\"Instance injection\"", ")", ";", "errors", ".", "throwCreationExceptionIfErrorsExist", "(", ")", ";", "for", "(", "InjectorShell", "shell", ":", "shells", ")", "{", "loadEagerSingletons", "(", "shell", ".", "getInjector", "(", ")", ",", "stage", ",", "errors", ")", ";", "}", "stopwatch", ".", "resetAndLog", "(", "\"Preloading singletons\"", ")", ";", "errors", ".", "throwCreationExceptionIfErrorsExist", "(", ")", ";", "}" ]
inject everything that can be injected . this method is intentionally not synchronized . if we locked while injecting members ( ie . running user code ) , things would deadlock should the user code build a just - in - time binding from another thread .
train
false
69,364
public List<E> next(){ if (numLeft.equals(total)) { numLeft=numLeft.subtract(BigInteger.ONE); return items; } int temp; int j=a.length - 2; while (a[j] > a[j + 1]) { j--; } int k=a.length - 1; while (a[j] > a[k]) { k--; } temp=a[k]; a[k]=a[j]; a[j]=temp; int r=a.length - 1; int s=j + 1; while (r > s) { temp=a[s]; a[s]=a[r]; a[r]=temp; r--; s++; } numLeft=numLeft.subtract(BigInteger.ONE); List<E> ans=new ArrayList<E>(a.length); for ( int index : a) { ans.add(items.get(index)); } return ans; }
[ "public", "List", "<", "E", ">", "next", "(", ")", "{", "if", "(", "numLeft", ".", "equals", "(", "total", ")", ")", "{", "numLeft", "=", "numLeft", ".", "subtract", "(", "BigInteger", ".", "ONE", ")", ";", "return", "items", ";", "}", "int", "temp", ";", "int", "j", "=", "a", ".", "length", "-", "2", ";", "while", "(", "a", "[", "j", "]", ">", "a", "[", "j", "+", "1", "]", ")", "{", "j", "--", ";", "}", "int", "k", "=", "a", ".", "length", "-", "1", ";", "while", "(", "a", "[", "j", "]", ">", "a", "[", "k", "]", ")", "{", "k", "--", ";", "}", "temp", "=", "a", "[", "k", "]", ";", "a", "[", "k", "]", "=", "a", "[", "j", "]", ";", "a", "[", "j", "]", "=", "temp", ";", "int", "r", "=", "a", ".", "length", "-", "1", ";", "int", "s", "=", "j", "+", "1", ";", "while", "(", "r", ">", "s", ")", "{", "temp", "=", "a", "[", "s", "]", ";", "a", "[", "s", "]", "=", "a", "[", "r", "]", ";", "a", "[", "r", "]", "=", "temp", ";", "r", "--", ";", "s", "++", ";", "}", "numLeft", "=", "numLeft", ".", "subtract", "(", "BigInteger", ".", "ONE", ")", ";", "List", "<", "E", ">", "ans", "=", "new", "ArrayList", "<", "E", ">", "(", "a", ".", "length", ")", ";", "for", "(", "int", "index", ":", "a", ")", "{", "ans", ".", "add", "(", "items", ".", "get", "(", "index", ")", ")", ";", "}", "return", "ans", ";", "}" ]
generate next permutation ( algorithm from rosen p . 284 )
train
true
69,365
public boolean write(Type type,Object value,NodeMap node,Map map){ Class actual=value.getClass(); Class expect=type.getType(); Class real=actual; if (actual.isArray()) { real=writeArray(expect,value,node); } if (actual != expect) { node.put(label,real.getName()); } return false; }
[ "public", "boolean", "write", "(", "Type", "type", ",", "Object", "value", ",", "NodeMap", "node", ",", "Map", "map", ")", "{", "Class", "actual", "=", "value", ".", "getClass", "(", ")", ";", "Class", "expect", "=", "type", ".", "getType", "(", ")", ";", "Class", "real", "=", "actual", ";", "if", "(", "actual", ".", "isArray", "(", ")", ")", "{", "real", "=", "writeArray", "(", "expect", ",", "value", ",", "node", ")", ";", "}", "if", "(", "actual", "!=", "expect", ")", "{", "node", ".", "put", "(", "label", ",", "real", ".", "getName", "(", ")", ")", ";", "}", "return", "false", ";", "}" ]
this is used to attach a attribute to the provided element that is used to identify the class . the attribute name is " class " and has the value of the fully qualified class name for the object provided . this will only be invoked if the object class is different from the field class .
train
false
69,366
public void offerBusyBox(Activity activity){ RootTools.log("Launching Market for BusyBox"); Intent i=new Intent(Intent.ACTION_VIEW,Uri.parse("market://details?id=stericson.busybox")); activity.startActivity(i); }
[ "public", "void", "offerBusyBox", "(", "Activity", "activity", ")", "{", "RootTools", ".", "log", "(", "\"Launching Market for BusyBox\"", ")", ";", "Intent", "i", "=", "new", "Intent", "(", "Intent", ".", "ACTION_VIEW", ",", "Uri", ".", "parse", "(", "\"market://details?id=stericson.busybox\"", ")", ")", ";", "activity", ".", "startActivity", "(", "i", ")", ";", "}" ]
this will launch the android market looking for busybox
train
false
69,367
public void addColumn(String name,int sqlType,String sqlTypeName,int precision,int scale){ if (rows != null && rows.size() > 0) { throw new IllegalStateException("Cannot add a column after adding rows"); } if (name == null) { name="C" + (columns.size() + 1); } Column column=new Column(); column.name=name; column.sqlType=sqlType; column.precision=precision; column.scale=scale; column.sqlTypeName=sqlTypeName; columns.add(column); }
[ "public", "void", "addColumn", "(", "String", "name", ",", "int", "sqlType", ",", "String", "sqlTypeName", ",", "int", "precision", ",", "int", "scale", ")", "{", "if", "(", "rows", "!=", "null", "&&", "rows", ".", "size", "(", ")", ">", "0", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Cannot add a column after adding rows\"", ")", ";", "}", "if", "(", "name", "==", "null", ")", "{", "name", "=", "\"C\"", "+", "(", "columns", ".", "size", "(", ")", "+", "1", ")", ";", "}", "Column", "column", "=", "new", "Column", "(", ")", ";", "column", ".", "name", "=", "name", ";", "column", ".", "sqlType", "=", "sqlType", ";", "column", ".", "precision", "=", "precision", ";", "column", ".", "scale", "=", "scale", ";", "column", ".", "sqlTypeName", "=", "sqlTypeName", ";", "columns", ".", "add", "(", "column", ")", ";", "}" ]
adds a column to the result set . all columns must be added before adding rows .
train
false
69,368
@Override public byte[] serialize(){ byte[] payloadData=null; if (payload != null) { payload.setParent(this); payloadData=payload.serialize(); } int optionsLength=0; if (this.options != null) optionsLength=this.options.length / 4; this.headerLength=(byte)(5 + optionsLength); this.totalLength=(short)(this.headerLength * 4 + ((payloadData == null) ? 0 : payloadData.length)); byte[] data=new byte[this.totalLength]; ByteBuffer bb=ByteBuffer.wrap(data); bb.put((byte)(((this.version & 0xf) << 4) | (this.headerLength & 0xf))); bb.put(this.diffServ); bb.putShort(this.totalLength); bb.putShort(this.identification); bb.putShort((short)(((this.flags & IPV4_FLAGS_MASK) << IPV4_FLAGS_SHIFT) | (this.fragmentOffset & IPV4_OFFSET_MASK))); bb.put(this.ttl); bb.put(this.protocol); bb.putShort(this.checksum); bb.putInt(this.sourceAddress); bb.putInt(this.destinationAddress); if (this.options != null) bb.put(this.options); if (payloadData != null) bb.put(payloadData); if (this.checksum == 0) { bb.rewind(); int accumulation=0; for (int i=0; i < this.headerLength * 2; ++i) { accumulation+=0xffff & bb.getShort(); } accumulation=((accumulation >> 16) & 0xffff) + (accumulation & 0xffff); this.checksum=(short)(~accumulation & 0xffff); bb.putShort(10,this.checksum); } return data; }
[ "@", "Override", "public", "byte", "[", "]", "serialize", "(", ")", "{", "byte", "[", "]", "payloadData", "=", "null", ";", "if", "(", "payload", "!=", "null", ")", "{", "payload", ".", "setParent", "(", "this", ")", ";", "payloadData", "=", "payload", ".", "serialize", "(", ")", ";", "}", "int", "optionsLength", "=", "0", ";", "if", "(", "this", ".", "options", "!=", "null", ")", "optionsLength", "=", "this", ".", "options", ".", "length", "/", "4", ";", "this", ".", "headerLength", "=", "(", "byte", ")", "(", "5", "+", "optionsLength", ")", ";", "this", ".", "totalLength", "=", "(", "short", ")", "(", "this", ".", "headerLength", "*", "4", "+", "(", "(", "payloadData", "==", "null", ")", "?", "0", ":", "payloadData", ".", "length", ")", ")", ";", "byte", "[", "]", "data", "=", "new", "byte", "[", "this", ".", "totalLength", "]", ";", "ByteBuffer", "bb", "=", "ByteBuffer", ".", "wrap", "(", "data", ")", ";", "bb", ".", "put", "(", "(", "byte", ")", "(", "(", "(", "this", ".", "version", "&", "0xf", ")", "<<", "4", ")", "|", "(", "this", ".", "headerLength", "&", "0xf", ")", ")", ")", ";", "bb", ".", "put", "(", "this", ".", "diffServ", ")", ";", "bb", ".", "putShort", "(", "this", ".", "totalLength", ")", ";", "bb", ".", "putShort", "(", "this", ".", "identification", ")", ";", "bb", ".", "putShort", "(", "(", "short", ")", "(", "(", "(", "this", ".", "flags", "&", "IPV4_FLAGS_MASK", ")", "<<", "IPV4_FLAGS_SHIFT", ")", "|", "(", "this", ".", "fragmentOffset", "&", "IPV4_OFFSET_MASK", ")", ")", ")", ";", "bb", ".", "put", "(", "this", ".", "ttl", ")", ";", "bb", ".", "put", "(", "this", ".", "protocol", ")", ";", "bb", ".", "putShort", "(", "this", ".", "checksum", ")", ";", "bb", ".", "putInt", "(", "this", ".", "sourceAddress", ")", ";", "bb", ".", "putInt", "(", "this", ".", "destinationAddress", ")", ";", "if", "(", "this", ".", "options", "!=", "null", ")", "bb", ".", "put", "(", "this", ".", "options", ")", ";", "if", "(", "payloadData", "!=", "null", ")", "bb", ".", "put", "(", "payloadData", ")", ";", "if", "(", "this", ".", "checksum", "==", "0", ")", "{", "bb", ".", "rewind", "(", ")", ";", "int", "accumulation", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "this", ".", "headerLength", "*", "2", ";", "++", "i", ")", "{", "accumulation", "+=", "0xffff", "&", "bb", ".", "getShort", "(", ")", ";", "}", "accumulation", "=", "(", "(", "accumulation", ">", ">", "16", ")", "&", "0xffff", ")", "+", "(", "accumulation", "&", "0xffff", ")", ";", "this", ".", "checksum", "=", "(", "short", ")", "(", "~", "accumulation", "&", "0xffff", ")", ";", "bb", ".", "putShort", "(", "10", ",", "this", ".", "checksum", ")", ";", "}", "return", "data", ";", "}" ]
serializes the packet . will compute and set the following fields if they are set to specific values at the time serialize is called : - checksum : 0 - headerlength : 0 - totallength : 0
train
false
69,370
public void test_getPreparedPropertiesCompatibility() throws Exception { String namespace="newNamespace"; Properties properties=new Properties(); properties.put(RemoteRepository.OPTION_CREATE_KB_NAMESPACE,namespace); final Properties p=m_mgr.getPreparedProperties(namespace,properties); properties.put("com.bigdata.rdf.sail.truthMaintenance","true"); properties.put("com.bigdata.rdf.store.AbstractTripleStore.quads","true"); try { m_mgr.getPreparedProperties(namespace,properties); fail("Expecting: " + HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } catch ( HttpException ex) { assertEquals(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,ex.getStatusCode()); } }
[ "public", "void", "test_getPreparedPropertiesCompatibility", "(", ")", "throws", "Exception", "{", "String", "namespace", "=", "\"newNamespace\"", ";", "Properties", "properties", "=", "new", "Properties", "(", ")", ";", "properties", ".", "put", "(", "RemoteRepository", ".", "OPTION_CREATE_KB_NAMESPACE", ",", "namespace", ")", ";", "final", "Properties", "p", "=", "m_mgr", ".", "getPreparedProperties", "(", "namespace", ",", "properties", ")", ";", "properties", ".", "put", "(", "\"com.bigdata.rdf.sail.truthMaintenance\"", ",", "\"true\"", ")", ";", "properties", ".", "put", "(", "\"com.bigdata.rdf.store.AbstractTripleStore.quads\"", ",", "\"true\"", ")", ";", "try", "{", "m_mgr", ".", "getPreparedProperties", "(", "namespace", ",", "properties", ")", ";", "fail", "(", "\"Expecting: \"", "+", "HttpServletResponse", ".", "SC_INTERNAL_SERVER_ERROR", ")", ";", "}", "catch", "(", "HttpException", "ex", ")", "{", "assertEquals", "(", "HttpServletResponse", ".", "SC_INTERNAL_SERVER_ERROR", ",", "ex", ".", "getStatusCode", "(", ")", ")", ";", "}", "}" ]
verify fail create properties if properties are not compatible .
train
false
69,371
protected int[] colsBitsetToIDs(BitSet cols){ int[] colIDs=new int[cols.cardinality()]; int colsIndex=0; for (int i=cols.nextSetBit(0); i >= 0; i=cols.nextSetBit(i + 1)) { colIDs[colsIndex]=i; colsIndex++; } return colIDs; }
[ "protected", "int", "[", "]", "colsBitsetToIDs", "(", "BitSet", "cols", ")", "{", "int", "[", "]", "colIDs", "=", "new", "int", "[", "cols", ".", "cardinality", "(", ")", "]", ";", "int", "colsIndex", "=", "0", ";", "for", "(", "int", "i", "=", "cols", ".", "nextSetBit", "(", "0", ")", ";", "i", ">=", "0", ";", "i", "=", "cols", ".", "nextSetBit", "(", "i", "+", "1", ")", ")", "{", "colIDs", "[", "colsIndex", "]", "=", "i", ";", "colsIndex", "++", ";", "}", "return", "colIDs", ";", "}" ]
convert a bitset into integer column ids .
train
true
69,372
private void storeRequestId(String requestId,String key){ requestIds.put(requestId,key); }
[ "private", "void", "storeRequestId", "(", "String", "requestId", ",", "String", "key", ")", "{", "requestIds", ".", "put", "(", "requestId", ",", "key", ")", ";", "}" ]
helper method to associate request ids to shared preference keys
train
false
69,373
private static EscapeStringResult escapeString(String s,char quote){ final String[] octal_strings={"\\0","\\001","\\002","\\003","\\004","\\005","\\006","\\a","\\b","\\t","\\n","\\v","\\f","\\r","\\016","\\017","\\020","\\021","\\022","\\023","\\024","\\025","\\026","\\027","\\030","\\031","\\032","\\033","\\034","\\035","\\036","\\037"}; StringBuilder result=new StringBuilder(s); boolean needQuotes=s.isEmpty(); for (int i=0, next_i; i < result.length(); i=next_i) { final int code_point=result.codePointAt(i); next_i=result.offsetByCodePoints(i,1); if (code_point == 0) { result.replace(i,next_i,"\\0"); next_i=i + 2; needQuotes=true; } else if (code_point == (int)'\\') { result.replace(i,next_i,"\\\\"); next_i=i + 2; needQuotes=true; } else if (code_point == (int)quote) { result.replace(i,next_i,"\\" + quote); next_i=i + 2; needQuotes=true; } else if (code_point < 32) { String octal=octal_strings[code_point]; result.replace(i,next_i,octal); next_i=i + octal.length(); needQuotes=true; } else if (code_point >= 65536) { String repl=String.format("\\U%08x",code_point); result.replace(i,next_i,repl); next_i=i + repl.length(); needQuotes=true; } else if (code_point >= 128) { String repl=String.format("\\u%04x",code_point); result.replace(i,next_i,repl); next_i=i + repl.length(); needQuotes=true; } } return new EscapeStringResult(needQuotes,result); }
[ "private", "static", "EscapeStringResult", "escapeString", "(", "String", "s", ",", "char", "quote", ")", "{", "final", "String", "[", "]", "octal_strings", "=", "{", "\"\\\\0\"", ",", "\"\\\\001\"", ",", "\"\\\\002\"", ",", "\"\\\\003\"", ",", "\"\\\\004\"", ",", "\"\\\\005\"", ",", "\"\\\\006\"", ",", "\"\\\\a\"", ",", "\"\\\\b\"", ",", "\"\\\\t\"", ",", "\"\\\\n\"", ",", "\"\\\\v\"", ",", "\"\\\\f\"", ",", "\"\\\\r\"", ",", "\"\\\\016\"", ",", "\"\\\\017\"", ",", "\"\\\\020\"", ",", "\"\\\\021\"", ",", "\"\\\\022\"", ",", "\"\\\\023\"", ",", "\"\\\\024\"", ",", "\"\\\\025\"", ",", "\"\\\\026\"", ",", "\"\\\\027\"", ",", "\"\\\\030\"", ",", "\"\\\\031\"", ",", "\"\\\\032\"", ",", "\"\\\\033\"", ",", "\"\\\\034\"", ",", "\"\\\\035\"", ",", "\"\\\\036\"", ",", "\"\\\\037\"", "}", ";", "StringBuilder", "result", "=", "new", "StringBuilder", "(", "s", ")", ";", "boolean", "needQuotes", "=", "s", ".", "isEmpty", "(", ")", ";", "for", "(", "int", "i", "=", "0", ",", "next_i", ";", "i", "<", "result", ".", "length", "(", ")", ";", "i", "=", "next_i", ")", "{", "final", "int", "code_point", "=", "result", ".", "codePointAt", "(", "i", ")", ";", "next_i", "=", "result", ".", "offsetByCodePoints", "(", "i", ",", "1", ")", ";", "if", "(", "code_point", "==", "0", ")", "{", "result", ".", "replace", "(", "i", ",", "next_i", ",", "\"\\\\0\"", ")", ";", "next_i", "=", "i", "+", "2", ";", "needQuotes", "=", "true", ";", "}", "else", "if", "(", "code_point", "==", "(", "int", ")", "'\\\\'", ")", "{", "result", ".", "replace", "(", "i", ",", "next_i", ",", "\"\\\\\\\\\"", ")", ";", "next_i", "=", "i", "+", "2", ";", "needQuotes", "=", "true", ";", "}", "else", "if", "(", "code_point", "==", "(", "int", ")", "quote", ")", "{", "result", ".", "replace", "(", "i", ",", "next_i", ",", "\"\\\\\"", "+", "quote", ")", ";", "next_i", "=", "i", "+", "2", ";", "needQuotes", "=", "true", ";", "}", "else", "if", "(", "code_point", "<", "32", ")", "{", "String", "octal", "=", "octal_strings", "[", "code_point", "]", ";", "result", ".", "replace", "(", "i", ",", "next_i", ",", "octal", ")", ";", "next_i", "=", "i", "+", "octal", ".", "length", "(", ")", ";", "needQuotes", "=", "true", ";", "}", "else", "if", "(", "code_point", ">=", "65536", ")", "{", "String", "repl", "=", "String", ".", "format", "(", "\"\\\\U%08x\"", ",", "code_point", ")", ";", "result", ".", "replace", "(", "i", ",", "next_i", ",", "repl", ")", ";", "next_i", "=", "i", "+", "repl", ".", "length", "(", ")", ";", "needQuotes", "=", "true", ";", "}", "else", "if", "(", "code_point", ">=", "128", ")", "{", "String", "repl", "=", "String", ".", "format", "(", "\"\\\\u%04x\"", ",", "code_point", ")", ";", "result", ".", "replace", "(", "i", ",", "next_i", ",", "repl", ")", ";", "next_i", "=", "i", "+", "repl", ".", "length", "(", ")", ";", "needQuotes", "=", "true", ";", "}", "}", "return", "new", "EscapeStringResult", "(", "needQuotes", ",", "result", ")", ";", "}" ]
escape a string configuration element .
train
true
69,375
public static void checkExplanations(Query query,String defaultFieldName,IndexSearcher searcher) throws IOException { checkExplanations(query,defaultFieldName,searcher,false); }
[ "public", "static", "void", "checkExplanations", "(", "Query", "query", ",", "String", "defaultFieldName", ",", "IndexSearcher", "searcher", ")", "throws", "IOException", "{", "checkExplanations", "(", "query", ",", "defaultFieldName", ",", "searcher", ",", "false", ")", ";", "}" ]
asserts that the explanation value for every document matching a query corresponds with the true score .
train
false
69,376
public Element deepCopy(){ return deepFreezeOrCopy(false); }
[ "public", "Element", "deepCopy", "(", ")", "{", "return", "deepFreezeOrCopy", "(", "false", ")", ";", "}" ]
returns new element ( this ) , and also recursively copies sub - elements .
train
false
69,377
public boolean isAuthnContextMatching(List requestedACClassRefs,String acClassRef,String comparison,String realm,String hostEntityID){ Map authRefMap=getAuthRefMap(realm,hostEntityID); return SAML2Utils.isAuthnContextMatching(requestedACClassRefs,acClassRef,comparison,authRefMap); }
[ "public", "boolean", "isAuthnContextMatching", "(", "List", "requestedACClassRefs", ",", "String", "acClassRef", ",", "String", "comparison", ",", "String", "realm", ",", "String", "hostEntityID", ")", "{", "Map", "authRefMap", "=", "getAuthRefMap", "(", "realm", ",", "hostEntityID", ")", ";", "return", "SAML2Utils", ".", "isAuthnContextMatching", "(", "requestedACClassRefs", ",", "acClassRef", ",", "comparison", ",", "authRefMap", ")", ";", "}" ]
returns true if the specified authncontextclassref matches a list of requested authncontextclassref .
train
false
69,379
private int rdHexDigit(){ int b=0; try { b=buffIn.read(); if ((b >= '0') && (b <= '9')) { b=b - '0'; } else if ((b >= 'A') && (b <= 'F')) { b=b - 'A' + 10; } else if ((b >= 'a') && (b <= 'f')) { b=b - 'a' + 10; } else { JOptionPane.showMessageDialog(this,"Invalid hex digit at line " + lineNo,"Hex File",JOptionPane.ERROR_MESSAGE); log.error("Format Error! Invalid hex digit at line " + lineNo); b=16; } } catch ( IOException e) { JOptionPane.showMessageDialog(this,"I/O Error reading hex file!","Hex File",JOptionPane.ERROR_MESSAGE); log.error("I/O Error reading hex file!" + e.toString()); } return (byte)b; }
[ "private", "int", "rdHexDigit", "(", ")", "{", "int", "b", "=", "0", ";", "try", "{", "b", "=", "buffIn", ".", "read", "(", ")", ";", "if", "(", "(", "b", ">=", "'0'", ")", "&&", "(", "b", "<=", "'9'", ")", ")", "{", "b", "=", "b", "-", "'0'", ";", "}", "else", "if", "(", "(", "b", ">=", "'A'", ")", "&&", "(", "b", "<=", "'F'", ")", ")", "{", "b", "=", "b", "-", "'A'", "+", "10", ";", "}", "else", "if", "(", "(", "b", ">=", "'a'", ")", "&&", "(", "b", "<=", "'f'", ")", ")", "{", "b", "=", "b", "-", "'a'", "+", "10", ";", "}", "else", "{", "JOptionPane", ".", "showMessageDialog", "(", "this", ",", "\"Invalid hex digit at line \"", "+", "lineNo", ",", "\"Hex File\"", ",", "JOptionPane", ".", "ERROR_MESSAGE", ")", ";", "log", ".", "error", "(", "\"Format Error! Invalid hex digit at line \"", "+", "lineNo", ")", ";", "b", "=", "16", ";", "}", "}", "catch", "(", "IOException", "e", ")", "{", "JOptionPane", ".", "showMessageDialog", "(", "this", ",", "\"I/O Error reading hex file!\"", ",", "\"Hex File\"", ",", "JOptionPane", ".", "ERROR_MESSAGE", ")", ";", "log", ".", "error", "(", "\"I/O Error reading hex file!\"", "+", "e", ".", "toString", "(", ")", ")", ";", "}", "return", "(", "byte", ")", "b", ";", "}" ]
read a single hex digit . returns 16 if digit is invalid
train
false
69,380
private boolean validateSignature(KeySelector keySelector) throws MalformedTokenException { NodeList securityNodeList=_parsedToken.getElementsByTagNameNS(Constants.DIGITAL_SIGNATURE_NAMESPACE,SIGNATURE_ELEMENT_NAME); XMLSignatureFactory fac=XMLSignatureFactory.getInstance(); DOMValidateContext valContext=new DOMValidateContext(keySelector,securityNodeList.item(0)); boolean isValid=false; try { XMLSignature signature=fac.unmarshalXMLSignature(valContext); isValid=signature.validate(valContext); } catch ( MarshalException e) { _log.error(SIGNATURE_VALIDATION_ERROR_MSG,e); throw new MalformedTokenException(SIGNATURE_VALIDATION_ERROR_MSG,e); } catch ( XMLSignatureException e) { _log.error(SIGNATURE_VALIDATION_ERROR_MSG,e); throw new MalformedTokenException(SIGNATURE_VALIDATION_ERROR_MSG,e); } _log.debug("SAML token signature is valid status: " + isValid); return isValid; }
[ "private", "boolean", "validateSignature", "(", "KeySelector", "keySelector", ")", "throws", "MalformedTokenException", "{", "NodeList", "securityNodeList", "=", "_parsedToken", ".", "getElementsByTagNameNS", "(", "Constants", ".", "DIGITAL_SIGNATURE_NAMESPACE", ",", "SIGNATURE_ELEMENT_NAME", ")", ";", "XMLSignatureFactory", "fac", "=", "XMLSignatureFactory", ".", "getInstance", "(", ")", ";", "DOMValidateContext", "valContext", "=", "new", "DOMValidateContext", "(", "keySelector", ",", "securityNodeList", ".", "item", "(", "0", ")", ")", ";", "boolean", "isValid", "=", "false", ";", "try", "{", "XMLSignature", "signature", "=", "fac", ".", "unmarshalXMLSignature", "(", "valContext", ")", ";", "isValid", "=", "signature", ".", "validate", "(", "valContext", ")", ";", "}", "catch", "(", "MarshalException", "e", ")", "{", "_log", ".", "error", "(", "SIGNATURE_VALIDATION_ERROR_MSG", ",", "e", ")", ";", "throw", "new", "MalformedTokenException", "(", "SIGNATURE_VALIDATION_ERROR_MSG", ",", "e", ")", ";", "}", "catch", "(", "XMLSignatureException", "e", ")", "{", "_log", ".", "error", "(", "SIGNATURE_VALIDATION_ERROR_MSG", ",", "e", ")", ";", "throw", "new", "MalformedTokenException", "(", "SIGNATURE_VALIDATION_ERROR_MSG", ",", "e", ")", ";", "}", "_log", ".", "debug", "(", "\"SAML token signature is valid status: \"", "+", "isValid", ")", ";", "return", "isValid", ";", "}" ]
validates the signature element of the saml token .
train
false
69,381
public static boolean isDoubleClick(MouseEvent e){ return ((e.getButton() == MouseEvent.BUTTON1) && (e.getClickCount() == 2)); }
[ "public", "static", "boolean", "isDoubleClick", "(", "MouseEvent", "e", ")", "{", "return", "(", "(", "e", ".", "getButton", "(", ")", "==", "MouseEvent", ".", "BUTTON1", ")", "&&", "(", "e", ".", "getClickCount", "(", ")", "==", "2", ")", ")", ";", "}" ]
checks whether the mouse event is a double - click event ( with the left mouse button ) . ctrl / alt / shift are allowed .
train
false
69,387
public String quotedNameOf(String s){ if (reservedNames.contains(s)) return "\'" + s + "\'"; else return s; }
[ "public", "String", "quotedNameOf", "(", "String", "s", ")", "{", "if", "(", "reservedNames", ".", "contains", "(", "s", ")", ")", "return", "\"\\'\"", "+", "s", "+", "\"\\'\"", ";", "else", "return", "s", ";", "}" ]
if this name is in the set of reserved names , then return a quoted version of it . else pass it through .
train
false
69,388
private long stringToIp(String ip) throws PolicyException { StringTokenizer st=new StringTokenizer(ip,"."); int tokenCount=st.countTokens(); if (tokenCount != 4) { String args[]={"ip",ip}; throw new PolicyException(ResBundleUtils.rbName,"invalid_property_value",args,null); } long ipValue=0L; while (st.hasMoreElements()) { String s=st.nextToken(); short ipElement=0; try { ipElement=Short.parseShort(s); } catch ( Exception e) { String args[]={"ip",ip}; throw new PolicyException(ResBundleUtils.rbName,"invalid_property_value",args,null); } if (ipElement < 0 || ipElement > 255) { String args[]={"ipElement",s}; throw new PolicyException(ResBundleUtils.rbName,"invalid_property_value",args,null); } ipValue=ipValue * 256L + ipElement; } return ipValue; }
[ "private", "long", "stringToIp", "(", "String", "ip", ")", "throws", "PolicyException", "{", "StringTokenizer", "st", "=", "new", "StringTokenizer", "(", "ip", ",", "\".\"", ")", ";", "int", "tokenCount", "=", "st", ".", "countTokens", "(", ")", ";", "if", "(", "tokenCount", "!=", "4", ")", "{", "String", "args", "[", "]", "=", "{", "\"ip\"", ",", "ip", "}", ";", "throw", "new", "PolicyException", "(", "ResBundleUtils", ".", "rbName", ",", "\"invalid_property_value\"", ",", "args", ",", "null", ")", ";", "}", "long", "ipValue", "=", "0L", ";", "while", "(", "st", ".", "hasMoreElements", "(", ")", ")", "{", "String", "s", "=", "st", ".", "nextToken", "(", ")", ";", "short", "ipElement", "=", "0", ";", "try", "{", "ipElement", "=", "Short", ".", "parseShort", "(", "s", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "String", "args", "[", "]", "=", "{", "\"ip\"", ",", "ip", "}", ";", "throw", "new", "PolicyException", "(", "ResBundleUtils", ".", "rbName", ",", "\"invalid_property_value\"", ",", "args", ",", "null", ")", ";", "}", "if", "(", "ipElement", "<", "0", "||", "ipElement", ">", "255", ")", "{", "String", "args", "[", "]", "=", "{", "\"ipElement\"", ",", "s", "}", ";", "throw", "new", "PolicyException", "(", "ResBundleUtils", ".", "rbName", ",", "\"invalid_property_value\"", ",", "args", ",", "null", ")", ";", "}", "ipValue", "=", "ipValue", "*", "256L", "+", "ipElement", ";", "}", "return", "ipValue", ";", "}" ]
converts string represenration of ip address to a long .
train
false
69,389
@Ignore @Test public void testDodCRLCache(){ Calendar currentDate=new GregorianCalendar(); if (currentDate.after(testUtil.dodCertExpireDate)) { return; } try { KeyStore trustStore=testUtil.getTrustStore(); ClientCertPolicy certPolicy=ClientCertTestUtils.intializeCertPolicy(); X509Certificate[] certs=testUtil.getDodValidCert1(); certPolicy.setRevocationCheckEnabled(true); certPolicy.setUseCertCRL(false); certPolicy.setCRLUrl(testUtil.getCRLLocalCacheURL(testUtil.dodCRLCacheEMAILCA_29)); IdmCertificatePathValidator validator=new IdmCertificatePathValidator(trustStore,certPolicy,ClientCertTestUtils.tenant1,null); validator.validate(certs[0],new Hashtable<String,String>()); return; } catch ( CertRevocationStatusUnknownException e) { fail("revocation check status unkown"); } catch ( Exception e) { fail("unexpected error in validating cert"); } }
[ "@", "Ignore", "@", "Test", "public", "void", "testDodCRLCache", "(", ")", "{", "Calendar", "currentDate", "=", "new", "GregorianCalendar", "(", ")", ";", "if", "(", "currentDate", ".", "after", "(", "testUtil", ".", "dodCertExpireDate", ")", ")", "{", "return", ";", "}", "try", "{", "KeyStore", "trustStore", "=", "testUtil", ".", "getTrustStore", "(", ")", ";", "ClientCertPolicy", "certPolicy", "=", "ClientCertTestUtils", ".", "intializeCertPolicy", "(", ")", ";", "X509Certificate", "[", "]", "certs", "=", "testUtil", ".", "getDodValidCert1", "(", ")", ";", "certPolicy", ".", "setRevocationCheckEnabled", "(", "true", ")", ";", "certPolicy", ".", "setUseCertCRL", "(", "false", ")", ";", "certPolicy", ".", "setCRLUrl", "(", "testUtil", ".", "getCRLLocalCacheURL", "(", "testUtil", ".", "dodCRLCacheEMAILCA_29", ")", ")", ";", "IdmCertificatePathValidator", "validator", "=", "new", "IdmCertificatePathValidator", "(", "trustStore", ",", "certPolicy", ",", "ClientCertTestUtils", ".", "tenant1", ",", "null", ")", ";", "validator", ".", "validate", "(", "certs", "[", "0", "]", ",", "new", "Hashtable", "<", "String", ",", "String", ">", "(", ")", ")", ";", "return", ";", "}", "catch", "(", "CertRevocationStatusUnknownException", "e", ")", "{", "fail", "(", "\"revocation check status unkown\"", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "fail", "(", "\"unexpected error in validating cert\"", ")", ";", "}", "}" ]
crldp test with local dod crl cache . using dod soft cert :
train
false