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
127
public static boolean nonemptyQueryResult(ResultSet R){ logger.trace("nonemptyQueryResult(R)"); boolean nonEmpty=false; if (R == null) { return false; } try { if (R.getRow() != 0) { nonEmpty=true; } else { logger.trace("nonemptyQueryResult(R) - check R.first()..."); nonEmpty=R.first(); R.beforeFirst(); } } catch ( Throwable t) { surfaceThrowable("nonemptyQueryResult()",t); } return nonEmpty; }
[ "public", "static", "boolean", "nonemptyQueryResult", "(", "ResultSet", "R", ")", "{", "logger", ".", "trace", "(", "\"nonemptyQueryResult(R)\"", ")", ";", "boolean", "nonEmpty", "=", "false", ";", "if", "(", "R", "==", "null", ")", "{", "return", "false", ";", "}", "try", "{", "if", "(", "R", ".", "getRow", "(", ")", "!=", "0", ")", "{", "nonEmpty", "=", "true", ";", "}", "else", "{", "logger", ".", "trace", "(", "\"nonemptyQueryResult(R) - check R.first()...\"", ")", ";", "nonEmpty", "=", "R", ".", "first", "(", ")", ";", "R", ".", "beforeFirst", "(", ")", ";", "}", "}", "catch", "(", "Throwable", "t", ")", "{", "surfaceThrowable", "(", "\"nonemptyQueryResult()\"", ",", "t", ")", ";", "}", "return", "nonEmpty", ";", "}" ]
since the resultset class mysteriously lacks a " size ( ) " method , and since simply iterating thru what might be a large resultset could be a costly exercise , we play the following games . we take care to try and leave r as we found it , cursor - wise .
train
false
128
private String createFullMessageText(String senderName,String receiverName,String text){ if (senderName.equals(receiverName)) { return "You mutter to yourself: " + text; } else { return senderName + " tells you: " + text; } }
[ "private", "String", "createFullMessageText", "(", "String", "senderName", ",", "String", "receiverName", ",", "String", "text", ")", "{", "if", "(", "senderName", ".", "equals", "(", "receiverName", ")", ")", "{", "return", "\"You mutter to yourself: \"", "+", "text", ";", "}", "else", "{", "return", "senderName", "+", "\" tells you: \"", "+", "text", ";", "}", "}" ]
creates the full message based on the text provided by the player
train
false
129
public void validate() throws IgniteCheckedException { for ( CachePluginProvider provider : providersList) provider.validate(); }
[ "public", "void", "validate", "(", ")", "throws", "IgniteCheckedException", "{", "for", "(", "CachePluginProvider", "provider", ":", "providersList", ")", "provider", ".", "validate", "(", ")", ";", "}" ]
validates cache plugin configurations . throw exception if validation failed .
train
false
131
protected boolean oneSameNetwork(MacAddress m1,MacAddress m2){ String net1=macToGuid.get(m1); String net2=macToGuid.get(m2); if (net1 == null) return false; if (net2 == null) return false; return net1.equals(net2); }
[ "protected", "boolean", "oneSameNetwork", "(", "MacAddress", "m1", ",", "MacAddress", "m2", ")", "{", "String", "net1", "=", "macToGuid", ".", "get", "(", "m1", ")", ";", "String", "net2", "=", "macToGuid", ".", "get", "(", "m2", ")", ";", "if", "(", "net1", "==", "null", ")", "return", "false", ";", "if", "(", "net2", "==", "null", ")", "return", "false", ";", "return", "net1", ".", "equals", "(", "net2", ")", ";", "}" ]
checks to see if two mac addresses are on the same network .
train
false
132
public static Object[] polar2CartesianArray(Double r,Double alpha){ double x=r.doubleValue() * Math.cos(alpha.doubleValue()); double y=r.doubleValue() * Math.sin(alpha.doubleValue()); return new Object[]{new Double(x),new Double(y)}; }
[ "public", "static", "Object", "[", "]", "polar2CartesianArray", "(", "Double", "r", ",", "Double", "alpha", ")", "{", "double", "x", "=", "r", ".", "doubleValue", "(", ")", "*", "Math", ".", "cos", "(", "alpha", ".", "doubleValue", "(", ")", ")", ";", "double", "y", "=", "r", ".", "doubleValue", "(", ")", "*", "Math", ".", "sin", "(", "alpha", ".", "doubleValue", "(", ")", ")", ";", "return", "new", "Object", "[", "]", "{", "new", "Double", "(", "x", ")", ",", "new", "Double", "(", "y", ")", "}", ";", "}" ]
convert polar coordinates to cartesian coordinates . the function may be called twice , once to retrieve the result columns ( with null parameters ) , and the second time to return the data .
train
false
133
protected void singleEnsemble(final double[] ensemble,final NumberVector vec){ double[] buf=new double[1]; for (int i=0; i < ensemble.length; i++) { buf[0]=vec.doubleValue(i); ensemble[i]=voting.combine(buf,1); if (Double.isNaN(ensemble[i])) { LOG.warning("NaN after combining: " + FormatUtil.format(buf) + " "+ voting.toString()); } } applyScaling(ensemble,scaling); }
[ "protected", "void", "singleEnsemble", "(", "final", "double", "[", "]", "ensemble", ",", "final", "NumberVector", "vec", ")", "{", "double", "[", "]", "buf", "=", "new", "double", "[", "1", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "ensemble", ".", "length", ";", "i", "++", ")", "{", "buf", "[", "0", "]", "=", "vec", ".", "doubleValue", "(", "i", ")", ";", "ensemble", "[", "i", "]", "=", "voting", ".", "combine", "(", "buf", ",", "1", ")", ";", "if", "(", "Double", ".", "isNaN", "(", "ensemble", "[", "i", "]", ")", ")", "{", "LOG", ".", "warning", "(", "\"NaN after combining: \"", "+", "FormatUtil", ".", "format", "(", "buf", ")", "+", "\" \"", "+", "voting", ".", "toString", "(", ")", ")", ";", "}", "}", "applyScaling", "(", "ensemble", ",", "scaling", ")", ";", "}" ]
build a single - element " ensemble " .
train
true
134
@Override public boolean is_IntBox(){ for (int index=0; index < lines_size(); ++index) { PlaLineInt curr_line=tline_get(index); if (!curr_line.is_orthogonal()) return false; if (!corner_is_bounded(index)) return false; } return true; }
[ "@", "Override", "public", "boolean", "is_IntBox", "(", ")", "{", "for", "(", "int", "index", "=", "0", ";", "index", "<", "lines_size", "(", ")", ";", "++", "index", ")", "{", "PlaLineInt", "curr_line", "=", "tline_get", "(", "index", ")", ";", "if", "(", "!", "curr_line", ".", "is_orthogonal", "(", ")", ")", "return", "false", ";", "if", "(", "!", "corner_is_bounded", "(", "index", ")", ")", "return", "false", ";", "}", "return", "true", ";", "}" ]
checks if this simplex can be converted into an intbox
train
false
135
public void addItemAtIndex(T item,int index){ if (index <= items.size()) { items.add(index,item); fireDataChangedEvent(DataChangedListener.ADDED,index); } }
[ "public", "void", "addItemAtIndex", "(", "T", "item", ",", "int", "index", ")", "{", "if", "(", "index", "<=", "items", ".", "size", "(", ")", ")", "{", "items", ".", "add", "(", "index", ",", "item", ")", ";", "fireDataChangedEvent", "(", "DataChangedListener", ".", "ADDED", ",", "index", ")", ";", "}", "}" ]
adding an item to list at given index
train
false
137
public static MatchedValuesRequestControl newControl(final boolean isCritical,final String... filters){ Reject.ifFalse(filters.length > 0,"filters is empty"); final List<Filter> parsedFilters=new ArrayList<>(filters.length); for ( final String filter : filters) { parsedFilters.add(validateFilter(Filter.valueOf(filter))); } return new MatchedValuesRequestControl(isCritical,Collections.unmodifiableList(parsedFilters)); }
[ "public", "static", "MatchedValuesRequestControl", "newControl", "(", "final", "boolean", "isCritical", ",", "final", "String", "...", "filters", ")", "{", "Reject", ".", "ifFalse", "(", "filters", ".", "length", ">", "0", ",", "\"filters is empty\"", ")", ";", "final", "List", "<", "Filter", ">", "parsedFilters", "=", "new", "ArrayList", "<", ">", "(", "filters", ".", "length", ")", ";", "for", "(", "final", "String", "filter", ":", "filters", ")", "{", "parsedFilters", ".", "add", "(", "validateFilter", "(", "Filter", ".", "valueOf", "(", "filter", ")", ")", ")", ";", "}", "return", "new", "MatchedValuesRequestControl", "(", "isCritical", ",", "Collections", ".", "unmodifiableList", "(", "parsedFilters", ")", ")", ";", "}" ]
creates a new matched values request control with the provided criticality and list of filters .
train
false
138
private void updateIPEndPointDetails(Map<String,Object> keyMap,StoragePort port,CIMInstance ipPointInstance,String portInstanceID) throws IOException { if (null != port) { updateIPAddress(getCIMPropertyValue(ipPointInstance,IPv4Address),port); _dbClient.persistObject(port); } }
[ "private", "void", "updateIPEndPointDetails", "(", "Map", "<", "String", ",", "Object", ">", "keyMap", ",", "StoragePort", "port", ",", "CIMInstance", "ipPointInstance", ",", "String", "portInstanceID", ")", "throws", "IOException", "{", "if", "(", "null", "!=", "port", ")", "{", "updateIPAddress", "(", "getCIMPropertyValue", "(", "ipPointInstance", ",", "IPv4Address", ")", ",", "port", ")", ";", "_dbClient", ".", "persistObject", "(", "port", ")", ";", "}", "}" ]
update end point details
train
false
139
public void replace(String param,String value){ int[] range; while ((range=findTemplate(param)) != null) buff.replace(range[0],range[1],value); }
[ "public", "void", "replace", "(", "String", "param", ",", "String", "value", ")", "{", "int", "[", "]", "range", ";", "while", "(", "(", "range", "=", "findTemplate", "(", "param", ")", ")", "!=", "null", ")", "buff", ".", "replace", "(", "range", "[", "0", "]", ",", "range", "[", "1", "]", ",", "value", ")", ";", "}" ]
substitute the specified text for the parameter
train
true
140
public void calcMajorTick(){ fraction=UNIT; double u=majorTick; double r=maxTick - minTick; majorTickCount=(int)(r / u); while (majorTickCount < prefMajorTickCount) { u=majorTick / 2; if (!isDiscrete || u == Math.floor(u)) { majorTickCount=(int)(r / u); fraction=HALFS; if (majorTickCount >= prefMajorTickCount) break; } u=majorTick / 4; if (!isDiscrete || u == Math.floor(u)) { majorTickCount=(int)(r / u); fraction=QUARTERS; if (majorTickCount >= prefMajorTickCount) break; } u=majorTick / 5; if (!isDiscrete || u == Math.floor(u)) { majorTickCount=(int)(r / u); fraction=FIFTHS; if (majorTickCount >= prefMajorTickCount) break; } if (isDiscrete && (majorTick / 10) != Math.floor(majorTick / 10)) { u=majorTick; majorTickCount=(int)(r / u); break; } majorTick/=10; u=majorTick; majorTickCount=(int)(r / u); fraction=UNIT; } majorTick=u; if (isDiscrete && majorTick < 1.0) { majorTick=1.0; majorTickCount=(int)(r / majorTick); fraction=UNIT; } majorTickCount++; while ((minTick + majorTick - epsilon) < minData) { minTick+=majorTick; majorTickCount--; } while ((maxTick - majorTick + epsilon) > maxData) { maxTick-=majorTick; majorTickCount--; } }
[ "public", "void", "calcMajorTick", "(", ")", "{", "fraction", "=", "UNIT", ";", "double", "u", "=", "majorTick", ";", "double", "r", "=", "maxTick", "-", "minTick", ";", "majorTickCount", "=", "(", "int", ")", "(", "r", "/", "u", ")", ";", "while", "(", "majorTickCount", "<", "prefMajorTickCount", ")", "{", "u", "=", "majorTick", "/", "2", ";", "if", "(", "!", "isDiscrete", "||", "u", "==", "Math", ".", "floor", "(", "u", ")", ")", "{", "majorTickCount", "=", "(", "int", ")", "(", "r", "/", "u", ")", ";", "fraction", "=", "HALFS", ";", "if", "(", "majorTickCount", ">=", "prefMajorTickCount", ")", "break", ";", "}", "u", "=", "majorTick", "/", "4", ";", "if", "(", "!", "isDiscrete", "||", "u", "==", "Math", ".", "floor", "(", "u", ")", ")", "{", "majorTickCount", "=", "(", "int", ")", "(", "r", "/", "u", ")", ";", "fraction", "=", "QUARTERS", ";", "if", "(", "majorTickCount", ">=", "prefMajorTickCount", ")", "break", ";", "}", "u", "=", "majorTick", "/", "5", ";", "if", "(", "!", "isDiscrete", "||", "u", "==", "Math", ".", "floor", "(", "u", ")", ")", "{", "majorTickCount", "=", "(", "int", ")", "(", "r", "/", "u", ")", ";", "fraction", "=", "FIFTHS", ";", "if", "(", "majorTickCount", ">=", "prefMajorTickCount", ")", "break", ";", "}", "if", "(", "isDiscrete", "&&", "(", "majorTick", "/", "10", ")", "!=", "Math", ".", "floor", "(", "majorTick", "/", "10", ")", ")", "{", "u", "=", "majorTick", ";", "majorTickCount", "=", "(", "int", ")", "(", "r", "/", "u", ")", ";", "break", ";", "}", "majorTick", "/=", "10", ";", "u", "=", "majorTick", ";", "majorTickCount", "=", "(", "int", ")", "(", "r", "/", "u", ")", ";", "fraction", "=", "UNIT", ";", "}", "majorTick", "=", "u", ";", "if", "(", "isDiscrete", "&&", "majorTick", "<", "1.0", ")", "{", "majorTick", "=", "1.0", ";", "majorTickCount", "=", "(", "int", ")", "(", "r", "/", "majorTick", ")", ";", "fraction", "=", "UNIT", ";", "}", "majorTickCount", "++", ";", "while", "(", "(", "minTick", "+", "majorTick", "-", "epsilon", ")", "<", "minData", ")", "{", "minTick", "+=", "majorTick", ";", "majorTickCount", "--", ";", "}", "while", "(", "(", "maxTick", "-", "majorTick", "+", "epsilon", ")", ">", "maxData", ")", "{", "maxTick", "-=", "majorTick", ";", "majorTickCount", "--", ";", "}", "}" ]
calculate the optimum major tick distance . override to change default behaviour
train
false
144
private JsonWriter open(JsonScope empty,String openBracket) throws IOException { beforeValue(true); stack.add(empty); out.write(openBracket); return this; }
[ "private", "JsonWriter", "open", "(", "JsonScope", "empty", ",", "String", "openBracket", ")", "throws", "IOException", "{", "beforeValue", "(", "true", ")", ";", "stack", ".", "add", "(", "empty", ")", ";", "out", ".", "write", "(", "openBracket", ")", ";", "return", "this", ";", "}" ]
enters a new scope by appending any necessary whitespace and the given bracket .
train
true
147
public void warn(String msg,Object args[]) throws org.xml.sax.SAXException { String formattedMsg=XSLMessages.createWarning(msg,args); SAXSourceLocator locator=getLocator(); ErrorListener handler=m_stylesheetProcessor.getErrorListener(); try { if (null != handler) handler.warning(new TransformerException(formattedMsg,locator)); } catch ( TransformerException te) { throw new org.xml.sax.SAXException(te); } }
[ "public", "void", "warn", "(", "String", "msg", ",", "Object", "args", "[", "]", ")", "throws", "org", ".", "xml", ".", "sax", ".", "SAXException", "{", "String", "formattedMsg", "=", "XSLMessages", ".", "createWarning", "(", "msg", ",", "args", ")", ";", "SAXSourceLocator", "locator", "=", "getLocator", "(", ")", ";", "ErrorListener", "handler", "=", "m_stylesheetProcessor", ".", "getErrorListener", "(", ")", ";", "try", "{", "if", "(", "null", "!=", "handler", ")", "handler", ".", "warning", "(", "new", "TransformerException", "(", "formattedMsg", ",", "locator", ")", ")", ";", "}", "catch", "(", "TransformerException", "te", ")", "{", "throw", "new", "org", ".", "xml", ".", "sax", ".", "SAXException", "(", "te", ")", ";", "}", "}" ]
warn the user of an problem .
train
true
148
public Shape triangle_up(float x,float y,float height){ m_path.reset(); m_path.moveTo(x,y + height); m_path.lineTo(x + height / 2,y); m_path.lineTo(x + height,(y + height)); m_path.closePath(); return m_path; }
[ "public", "Shape", "triangle_up", "(", "float", "x", ",", "float", "y", ",", "float", "height", ")", "{", "m_path", ".", "reset", "(", ")", ";", "m_path", ".", "moveTo", "(", "x", ",", "y", "+", "height", ")", ";", "m_path", ".", "lineTo", "(", "x", "+", "height", "/", "2", ",", "y", ")", ";", "m_path", ".", "lineTo", "(", "x", "+", "height", ",", "(", "y", "+", "height", ")", ")", ";", "m_path", ".", "closePath", "(", ")", ";", "return", "m_path", ";", "}" ]
returns a up - pointing triangle of the given dimenisions .
train
false
149
public double minDataDLIfExists(int index,double expFPRate,boolean checkErr){ double[] rulesetStat=new double[6]; for (int j=0; j < m_SimpleStats.size(); j++) { rulesetStat[0]+=m_SimpleStats.get(j)[0]; rulesetStat[2]+=m_SimpleStats.get(j)[2]; rulesetStat[4]+=m_SimpleStats.get(j)[4]; if (j == m_SimpleStats.size() - 1) { rulesetStat[1]=m_SimpleStats.get(j)[1]; rulesetStat[3]=m_SimpleStats.get(j)[3]; rulesetStat[5]=m_SimpleStats.get(j)[5]; } } double potential=0; for (int k=index + 1; k < m_SimpleStats.size(); k++) { double[] ruleStat=getSimpleStats(k); double ifDeleted=potential(k,expFPRate,rulesetStat,ruleStat,checkErr); if (!Double.isNaN(ifDeleted)) { potential+=ifDeleted; } } double dataDLWith=dataDL(expFPRate,rulesetStat[0],rulesetStat[1],rulesetStat[4],rulesetStat[5]); return (dataDLWith - potential); }
[ "public", "double", "minDataDLIfExists", "(", "int", "index", ",", "double", "expFPRate", ",", "boolean", "checkErr", ")", "{", "double", "[", "]", "rulesetStat", "=", "new", "double", "[", "6", "]", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "m_SimpleStats", ".", "size", "(", ")", ";", "j", "++", ")", "{", "rulesetStat", "[", "0", "]", "+=", "m_SimpleStats", ".", "get", "(", "j", ")", "[", "0", "]", ";", "rulesetStat", "[", "2", "]", "+=", "m_SimpleStats", ".", "get", "(", "j", ")", "[", "2", "]", ";", "rulesetStat", "[", "4", "]", "+=", "m_SimpleStats", ".", "get", "(", "j", ")", "[", "4", "]", ";", "if", "(", "j", "==", "m_SimpleStats", ".", "size", "(", ")", "-", "1", ")", "{", "rulesetStat", "[", "1", "]", "=", "m_SimpleStats", ".", "get", "(", "j", ")", "[", "1", "]", ";", "rulesetStat", "[", "3", "]", "=", "m_SimpleStats", ".", "get", "(", "j", ")", "[", "3", "]", ";", "rulesetStat", "[", "5", "]", "=", "m_SimpleStats", ".", "get", "(", "j", ")", "[", "5", "]", ";", "}", "}", "double", "potential", "=", "0", ";", "for", "(", "int", "k", "=", "index", "+", "1", ";", "k", "<", "m_SimpleStats", ".", "size", "(", ")", ";", "k", "++", ")", "{", "double", "[", "]", "ruleStat", "=", "getSimpleStats", "(", "k", ")", ";", "double", "ifDeleted", "=", "potential", "(", "k", ",", "expFPRate", ",", "rulesetStat", ",", "ruleStat", ",", "checkErr", ")", ";", "if", "(", "!", "Double", ".", "isNaN", "(", "ifDeleted", ")", ")", "{", "potential", "+=", "ifDeleted", ";", "}", "}", "double", "dataDLWith", "=", "dataDL", "(", "expFPRate", ",", "rulesetStat", "[", "0", "]", ",", "rulesetStat", "[", "1", "]", ",", "rulesetStat", "[", "4", "]", ",", "rulesetStat", "[", "5", "]", ")", ";", "return", "(", "dataDLWith", "-", "potential", ")", ";", "}" ]
compute the minimal data description length of the ruleset if the rule in the given position is not deleted . < br > the min_data_dl_if_n_deleted = data_dl_if_n_deleted - potential
train
false
150
public static void writeIntegerCollection(@Nonnull NBTTagCompound data,@Nonnull Collection<Integer> coll){ data.setInteger("size",coll.size()); final int[] ary=new int[coll.size()]; int i=0; for ( Integer num : coll) { ary[i]=num; i++; } data.setTag("data",new NBTTagIntArray(ary)); }
[ "public", "static", "void", "writeIntegerCollection", "(", "@", "Nonnull", "NBTTagCompound", "data", ",", "@", "Nonnull", "Collection", "<", "Integer", ">", "coll", ")", "{", "data", ".", "setInteger", "(", "\"size\"", ",", "coll", ".", "size", "(", ")", ")", ";", "final", "int", "[", "]", "ary", "=", "new", "int", "[", "coll", ".", "size", "(", ")", "]", ";", "int", "i", "=", "0", ";", "for", "(", "Integer", "num", ":", "coll", ")", "{", "ary", "[", "i", "]", "=", "num", ";", "i", "++", ";", "}", "data", ".", "setTag", "(", "\"data\"", ",", "new", "NBTTagIntArray", "(", "ary", ")", ")", ";", "}" ]
writes the given collection to the nbttagcompound as an intarray
train
false
151
@SuppressWarnings("unchecked") public void queryForDump(String cfName,String fileName,String[] ids) throws Exception { final Class clazz=getClassFromCFName(cfName); if (clazz == null) { return; } initDumpXmlFile(cfName); for ( String id : ids) { queryAndPrintRecord(URI.create(id),clazz,DbCliOperation.DUMP); } writeToXmlFile(fileName); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "queryForDump", "(", "String", "cfName", ",", "String", "fileName", ",", "String", "[", "]", "ids", ")", "throws", "Exception", "{", "final", "Class", "clazz", "=", "getClassFromCFName", "(", "cfName", ")", ";", "if", "(", "clazz", "==", "null", ")", "{", "return", ";", "}", "initDumpXmlFile", "(", "cfName", ")", ";", "for", "(", "String", "id", ":", "ids", ")", "{", "queryAndPrintRecord", "(", "URI", ".", "create", "(", "id", ")", ",", "clazz", ",", "DbCliOperation", ".", "DUMP", ")", ";", "}", "writeToXmlFile", "(", "fileName", ")", ";", "}" ]
query and dump into xml for a particular id in a columnfamily
train
false
152
private AsciiFuncs(){ }
[ "private", "AsciiFuncs", "(", ")", "{", "}" ]
utility class not to be instantiated .
train
false
153
public DialogueImporter importDialogue(String dialogueFile){ List<DialogueState> turns=XMLDialogueReader.extractDialogue(dialogueFile); DialogueImporter importer=new DialogueImporter(this,turns); importer.start(); return importer; }
[ "public", "DialogueImporter", "importDialogue", "(", "String", "dialogueFile", ")", "{", "List", "<", "DialogueState", ">", "turns", "=", "XMLDialogueReader", ".", "extractDialogue", "(", "dialogueFile", ")", ";", "DialogueImporter", "importer", "=", "new", "DialogueImporter", "(", "this", ",", "turns", ")", ";", "importer", ".", "start", "(", ")", ";", "return", "importer", ";", "}" ]
imports the dialogue specified in the provided file .
train
false
155
public static String transformFilename(String fileName){ if (!fileName.endsWith(".fb")) { fileName=fileName + ".fb"; } return fileName; }
[ "public", "static", "String", "transformFilename", "(", "String", "fileName", ")", "{", "if", "(", "!", "fileName", ".", "endsWith", "(", "\".fb\"", ")", ")", "{", "fileName", "=", "fileName", "+", "\".fb\"", ";", "}", "return", "fileName", ";", "}" ]
transform a user - entered filename into a proper filename , by adding the " . fb " file extension if it isn ' t already present .
train
false
156
public String readLine() throws IOException { return keepCarriageReturns ? readUntilNewline() : reader.readLine(); }
[ "public", "String", "readLine", "(", ")", "throws", "IOException", "{", "return", "keepCarriageReturns", "?", "readUntilNewline", "(", ")", ":", "reader", ".", "readLine", "(", ")", ";", "}" ]
reads the next line from the reader .
train
false
157
public void hideValidationMessages(){ for ( ValidationErrorMessage invalidField : validationMessages) { View view=parentView.findViewWithTag(invalidField.getPaymentProductFieldId()); validationMessageRenderer.removeValidationMessage((ViewGroup)view.getParent(),invalidField.getPaymentProductFieldId()); } validationMessages.clear(); fieldIdsOfErrorMessagesShowing.clear(); }
[ "public", "void", "hideValidationMessages", "(", ")", "{", "for", "(", "ValidationErrorMessage", "invalidField", ":", "validationMessages", ")", "{", "View", "view", "=", "parentView", ".", "findViewWithTag", "(", "invalidField", ".", "getPaymentProductFieldId", "(", ")", ")", ";", "validationMessageRenderer", ".", "removeValidationMessage", "(", "(", "ViewGroup", ")", "view", ".", "getParent", "(", ")", ",", "invalidField", ".", "getPaymentProductFieldId", "(", ")", ")", ";", "}", "validationMessages", ".", "clear", "(", ")", ";", "fieldIdsOfErrorMessagesShowing", ".", "clear", "(", ")", ";", "}" ]
hides all visible validationmessages
train
false
158
private synchronized void removeLoader(ClassLoader loader){ int i; for (i=_loaders.size() - 1; i >= 0; i--) { WeakReference<ClassLoader> ref=_loaders.get(i); ClassLoader refLoader=ref.get(); if (refLoader == null) _loaders.remove(i); else if (refLoader == loader) _loaders.remove(i); } }
[ "private", "synchronized", "void", "removeLoader", "(", "ClassLoader", "loader", ")", "{", "int", "i", ";", "for", "(", "i", "=", "_loaders", ".", "size", "(", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "WeakReference", "<", "ClassLoader", ">", "ref", "=", "_loaders", ".", "get", "(", "i", ")", ";", "ClassLoader", "refLoader", "=", "ref", ".", "get", "(", ")", ";", "if", "(", "refLoader", "==", "null", ")", "_loaders", ".", "remove", "(", "i", ")", ";", "else", "if", "(", "refLoader", "==", "loader", ")", "_loaders", ".", "remove", "(", "i", ")", ";", "}", "}" ]
removes the specified loader .
train
true
159
public static double parseString(String value){ return Double.parseDouble(value); }
[ "public", "static", "double", "parseString", "(", "String", "value", ")", "{", "return", "Double", ".", "parseDouble", "(", "value", ")", ";", "}" ]
parse string value returning a double .
train
false
160
private void writePostContent(HttpURLConnection connection,String postContent) throws Exception { connection.setRequestMethod("POST"); connection.addRequestProperty("Content-Type","application/xml; charset=utf-8"); connection.setDoOutput(true); connection.setDoInput(true); connection.setAllowUserInteraction(false); DataOutputStream dstream=null; try { connection.connect(); dstream=new DataOutputStream(connection.getOutputStream()); dstream.writeBytes(postContent); dstream.flush(); } finally { if (dstream != null) { try { dstream.close(); } catch ( Exception ex) { _log.error("Exception while closing the stream." + " Exception: " + ex,"WebClient._writePostContent()"); } } } }
[ "private", "void", "writePostContent", "(", "HttpURLConnection", "connection", ",", "String", "postContent", ")", "throws", "Exception", "{", "connection", ".", "setRequestMethod", "(", "\"POST\"", ")", ";", "connection", ".", "addRequestProperty", "(", "\"Content-Type\"", ",", "\"application/xml; charset=utf-8\"", ")", ";", "connection", ".", "setDoOutput", "(", "true", ")", ";", "connection", ".", "setDoInput", "(", "true", ")", ";", "connection", ".", "setAllowUserInteraction", "(", "false", ")", ";", "DataOutputStream", "dstream", "=", "null", ";", "try", "{", "connection", ".", "connect", "(", ")", ";", "dstream", "=", "new", "DataOutputStream", "(", "connection", ".", "getOutputStream", "(", ")", ")", ";", "dstream", ".", "writeBytes", "(", "postContent", ")", ";", "dstream", ".", "flush", "(", ")", ";", "}", "finally", "{", "if", "(", "dstream", "!=", "null", ")", "{", "try", "{", "dstream", ".", "close", "(", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "_log", ".", "error", "(", "\"Exception while closing the stream.\"", "+", "\" Exception: \"", "+", "ex", ",", "\"WebClient._writePostContent()\"", ")", ";", "}", "}", "}", "}" ]
send a post request with content to the specified connection
train
false
161
public void add(WFNode node){ m_nodes.add(node); }
[ "public", "void", "add", "(", "WFNode", "node", ")", "{", "m_nodes", ".", "add", "(", "node", ")", ";", "}" ]
add component and add mouse listener
train
false
162
@Override public int clampViewPositionVertical(View child,int top,int dy){ int topBound=0; int bottomBound=0; switch (draggerView.getDragPosition()) { case TOP: if (top > 0) { topBound=draggerView.getPaddingTop(); bottomBound=(int)draggerListener.dragVerticalDragRange(); } break; case BOTTOM: if (top < 0) { topBound=(int)-draggerListener.dragVerticalDragRange(); bottomBound=draggerView.getPaddingTop(); } break; default : break; } return Math.min(Math.max(top,topBound),bottomBound); }
[ "@", "Override", "public", "int", "clampViewPositionVertical", "(", "View", "child", ",", "int", "top", ",", "int", "dy", ")", "{", "int", "topBound", "=", "0", ";", "int", "bottomBound", "=", "0", ";", "switch", "(", "draggerView", ".", "getDragPosition", "(", ")", ")", "{", "case", "TOP", ":", "if", "(", "top", ">", "0", ")", "{", "topBound", "=", "draggerView", ".", "getPaddingTop", "(", ")", ";", "bottomBound", "=", "(", "int", ")", "draggerListener", ".", "dragVerticalDragRange", "(", ")", ";", "}", "break", ";", "case", "BOTTOM", ":", "if", "(", "top", "<", "0", ")", "{", "topBound", "=", "(", "int", ")", "-", "draggerListener", ".", "dragVerticalDragRange", "(", ")", ";", "bottomBound", "=", "draggerView", ".", "getPaddingTop", "(", ")", ";", "}", "break", ";", "default", ":", "break", ";", "}", "return", "Math", ".", "min", "(", "Math", ".", "max", "(", "top", ",", "topBound", ")", ",", "bottomBound", ")", ";", "}" ]
return the value of slide based on top and height of the element
train
false
164
@GET @Produces({MediaType.APPLICATION_XML,MediaType.APPLICATION_JSON}) @Path("/{id}/hosts") @Deprecated public HostList listHosts(@PathParam("id") URI id) throws DatabaseException { getTenantById(id,false); verifyAuthorizedInTenantOrg(id,getUserFromContext()); HostList list=new HostList(); list.setHosts(map(ResourceTypeEnum.HOST,listChildren(id,Host.class,"label","tenant"))); return list; }
[ "@", "GET", "@", "Produces", "(", "{", "MediaType", ".", "APPLICATION_XML", ",", "MediaType", ".", "APPLICATION_JSON", "}", ")", "@", "Path", "(", "\"/{id}/hosts\"", ")", "@", "Deprecated", "public", "HostList", "listHosts", "(", "@", "PathParam", "(", "\"id\"", ")", "URI", "id", ")", "throws", "DatabaseException", "{", "getTenantById", "(", "id", ",", "false", ")", ";", "verifyAuthorizedInTenantOrg", "(", "id", ",", "getUserFromContext", "(", ")", ")", ";", "HostList", "list", "=", "new", "HostList", "(", ")", ";", "list", ".", "setHosts", "(", "map", "(", "ResourceTypeEnum", ".", "HOST", ",", "listChildren", "(", "id", ",", "Host", ".", "class", ",", "\"label\"", ",", "\"tenant\"", ")", ")", ")", ";", "return", "list", ";", "}" ]
lists the id and name for all the hosts that belong to the given tenant organization . < p > this method is deprecated . use / compute / hosts instead
train
false
165
private void processDirectorStats(Map<String,MetricHeaderInfo> metricHeaderInfoMap,Map<String,Double> maxValues,Map<String,String> lastSample){ MetricHeaderInfo headerInfo=metricHeaderInfoMap.get(HEADER_KEY_DIRECTOR_BUSY); if (headerInfo != null) { String directorBusyString=lastSample.get(HEADER_KEY_DIRECTOR_BUSY); if (directorBusyString != null) { Double percentBusy=Double.valueOf(directorBusyString); Double iops=(maxValues.containsKey(HEADER_KEY_DIRECTOR_FE_OPS)) ? maxValues.get(HEADER_KEY_DIRECTOR_FE_OPS) : Double.valueOf(lastSample.get(HEADER_KEY_DIRECTOR_FE_OPS)); String lastSampleTime=lastSample.get(HEADER_KEY_TIME_UTC); portMetricsProcessor.processFEAdaptMetrics(percentBusy,iops.longValue(),headerInfo.director,lastSampleTime,false); } } }
[ "private", "void", "processDirectorStats", "(", "Map", "<", "String", ",", "MetricHeaderInfo", ">", "metricHeaderInfoMap", ",", "Map", "<", "String", ",", "Double", ">", "maxValues", ",", "Map", "<", "String", ",", "String", ">", "lastSample", ")", "{", "MetricHeaderInfo", "headerInfo", "=", "metricHeaderInfoMap", ".", "get", "(", "HEADER_KEY_DIRECTOR_BUSY", ")", ";", "if", "(", "headerInfo", "!=", "null", ")", "{", "String", "directorBusyString", "=", "lastSample", ".", "get", "(", "HEADER_KEY_DIRECTOR_BUSY", ")", ";", "if", "(", "directorBusyString", "!=", "null", ")", "{", "Double", "percentBusy", "=", "Double", ".", "valueOf", "(", "directorBusyString", ")", ";", "Double", "iops", "=", "(", "maxValues", ".", "containsKey", "(", "HEADER_KEY_DIRECTOR_FE_OPS", ")", ")", "?", "maxValues", ".", "get", "(", "HEADER_KEY_DIRECTOR_FE_OPS", ")", ":", "Double", ".", "valueOf", "(", "lastSample", ".", "get", "(", "HEADER_KEY_DIRECTOR_FE_OPS", ")", ")", ";", "String", "lastSampleTime", "=", "lastSample", ".", "get", "(", "HEADER_KEY_TIME_UTC", ")", ";", "portMetricsProcessor", ".", "processFEAdaptMetrics", "(", "percentBusy", ",", "iops", ".", "longValue", "(", ")", ",", "headerInfo", ".", "director", ",", "lastSampleTime", ",", "false", ")", ";", "}", "}", "}" ]
process the director metrics found in metricheaderinfomap
train
false
166
public Point2D transform(Point2D p){ if (p == null) return null; return transform.transform(p,null); }
[ "public", "Point2D", "transform", "(", "Point2D", "p", ")", "{", "if", "(", "p", "==", "null", ")", "return", "null", ";", "return", "transform", ".", "transform", "(", "p", ",", "null", ")", ";", "}" ]
applies the transform to the supplied point .
train
false
168
private void correctChanged(){ clock.setCorrectHardware(correctCheckBox.isSelected(),true); changed=true; }
[ "private", "void", "correctChanged", "(", ")", "{", "clock", ".", "setCorrectHardware", "(", "correctCheckBox", ".", "isSelected", "(", ")", ",", "true", ")", ";", "changed", "=", "true", ";", "}" ]
method to handle correct check box change
train
false
169
private void writeOFMessagesToSwitch(DatapathId dpid,List<OFMessage> messages){ IOFSwitch ofswitch=switchService.getSwitch(dpid); if (ofswitch != null) { if (log.isDebugEnabled()) { log.debug("Sending {} new entries to {}",messages.size(),dpid); } ofswitch.write(messages); } }
[ "private", "void", "writeOFMessagesToSwitch", "(", "DatapathId", "dpid", ",", "List", "<", "OFMessage", ">", "messages", ")", "{", "IOFSwitch", "ofswitch", "=", "switchService", ".", "getSwitch", "(", "dpid", ")", ";", "if", "(", "ofswitch", "!=", "null", ")", "{", "if", "(", "log", ".", "isDebugEnabled", "(", ")", ")", "{", "log", ".", "debug", "(", "\"Sending {} new entries to {}\"", ",", "messages", ".", "size", "(", ")", ",", "dpid", ")", ";", "}", "ofswitch", ".", "write", "(", "messages", ")", ";", "}", "}" ]
writes a list of ofmessages to a switch
train
false
170
private Set<HiCSSubspace> calculateSubspaces(Relation<? extends NumberVector> relation,ArrayList<ArrayDBIDs> subspaceIndex,Random random){ final int dbdim=RelationUtil.dimensionality(relation); FiniteProgress dprog=LOG.isVerbose() ? new FiniteProgress("Subspace dimensionality",dbdim,LOG) : null; if (dprog != null) { dprog.setProcessed(2,LOG); } TreeSet<HiCSSubspace> subspaceList=new TreeSet<>(HiCSSubspace.SORT_BY_SUBSPACE); TopBoundedHeap<HiCSSubspace> dDimensionalList=new TopBoundedHeap<>(cutoff,HiCSSubspace.SORT_BY_CONTRAST_ASC); FiniteProgress prog=LOG.isVerbose() ? new FiniteProgress("Generating two-element subsets",(dbdim * (dbdim - 1)) >> 1,LOG) : null; for (int i=0; i < dbdim; i++) { for (int j=i + 1; j < dbdim; j++) { HiCSSubspace ts=new HiCSSubspace(); ts.set(i); ts.set(j); calculateContrast(relation,ts,subspaceIndex,random); dDimensionalList.add(ts); LOG.incrementProcessed(prog); } } LOG.ensureCompleted(prog); IndefiniteProgress qprog=LOG.isVerbose() ? new IndefiniteProgress("Testing subspace candidates",LOG) : null; for (int d=3; !dDimensionalList.isEmpty(); d++) { if (dprog != null) { dprog.setProcessed(d,LOG); } ArrayList<HiCSSubspace> candidateList=new ArrayList<>(dDimensionalList.size()); for (Heap<HiCSSubspace>.UnorderedIter it=dDimensionalList.unorderedIter(); it.valid(); it.advance()) { subspaceList.add(it.get()); candidateList.add(it.get()); } dDimensionalList.clear(); Collections.sort(candidateList,HiCSSubspace.SORT_BY_SUBSPACE); for (int i=0; i < candidateList.size() - 1; i++) { for (int j=i + 1; j < candidateList.size(); j++) { HiCSSubspace set1=candidateList.get(i); HiCSSubspace set2=candidateList.get(j); HiCSSubspace joinedSet=new HiCSSubspace(); joinedSet.or(set1); joinedSet.or(set2); if (joinedSet.cardinality() != d) { continue; } calculateContrast(relation,joinedSet,subspaceIndex,random); dDimensionalList.add(joinedSet); LOG.incrementProcessed(qprog); } } for ( HiCSSubspace cand : candidateList) { for (Heap<HiCSSubspace>.UnorderedIter it=dDimensionalList.unorderedIter(); it.valid(); it.advance()) { if (it.get().contrast > cand.contrast) { subspaceList.remove(cand); break; } } } } LOG.setCompleted(qprog); if (dprog != null) { dprog.setProcessed(dbdim,LOG); dprog.ensureCompleted(LOG); } return subspaceList; }
[ "private", "Set", "<", "HiCSSubspace", ">", "calculateSubspaces", "(", "Relation", "<", "?", "extends", "NumberVector", ">", "relation", ",", "ArrayList", "<", "ArrayDBIDs", ">", "subspaceIndex", ",", "Random", "random", ")", "{", "final", "int", "dbdim", "=", "RelationUtil", ".", "dimensionality", "(", "relation", ")", ";", "FiniteProgress", "dprog", "=", "LOG", ".", "isVerbose", "(", ")", "?", "new", "FiniteProgress", "(", "\"Subspace dimensionality\"", ",", "dbdim", ",", "LOG", ")", ":", "null", ";", "if", "(", "dprog", "!=", "null", ")", "{", "dprog", ".", "setProcessed", "(", "2", ",", "LOG", ")", ";", "}", "TreeSet", "<", "HiCSSubspace", ">", "subspaceList", "=", "new", "TreeSet", "<", ">", "(", "HiCSSubspace", ".", "SORT_BY_SUBSPACE", ")", ";", "TopBoundedHeap", "<", "HiCSSubspace", ">", "dDimensionalList", "=", "new", "TopBoundedHeap", "<", ">", "(", "cutoff", ",", "HiCSSubspace", ".", "SORT_BY_CONTRAST_ASC", ")", ";", "FiniteProgress", "prog", "=", "LOG", ".", "isVerbose", "(", ")", "?", "new", "FiniteProgress", "(", "\"Generating two-element subsets\"", ",", "(", "dbdim", "*", "(", "dbdim", "-", "1", ")", ")", ">", ">", "1", ",", "LOG", ")", ":", "null", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "dbdim", ";", "i", "++", ")", "{", "for", "(", "int", "j", "=", "i", "+", "1", ";", "j", "<", "dbdim", ";", "j", "++", ")", "{", "HiCSSubspace", "ts", "=", "new", "HiCSSubspace", "(", ")", ";", "ts", ".", "set", "(", "i", ")", ";", "ts", ".", "set", "(", "j", ")", ";", "calculateContrast", "(", "relation", ",", "ts", ",", "subspaceIndex", ",", "random", ")", ";", "dDimensionalList", ".", "add", "(", "ts", ")", ";", "LOG", ".", "incrementProcessed", "(", "prog", ")", ";", "}", "}", "LOG", ".", "ensureCompleted", "(", "prog", ")", ";", "IndefiniteProgress", "qprog", "=", "LOG", ".", "isVerbose", "(", ")", "?", "new", "IndefiniteProgress", "(", "\"Testing subspace candidates\"", ",", "LOG", ")", ":", "null", ";", "for", "(", "int", "d", "=", "3", ";", "!", "dDimensionalList", ".", "isEmpty", "(", ")", ";", "d", "++", ")", "{", "if", "(", "dprog", "!=", "null", ")", "{", "dprog", ".", "setProcessed", "(", "d", ",", "LOG", ")", ";", "}", "ArrayList", "<", "HiCSSubspace", ">", "candidateList", "=", "new", "ArrayList", "<", ">", "(", "dDimensionalList", ".", "size", "(", ")", ")", ";", "for", "(", "Heap", "<", "HiCSSubspace", ">", ".", "UnorderedIter", "it", "=", "dDimensionalList", ".", "unorderedIter", "(", ")", ";", "it", ".", "valid", "(", ")", ";", "it", ".", "advance", "(", ")", ")", "{", "subspaceList", ".", "add", "(", "it", ".", "get", "(", ")", ")", ";", "candidateList", ".", "add", "(", "it", ".", "get", "(", ")", ")", ";", "}", "dDimensionalList", ".", "clear", "(", ")", ";", "Collections", ".", "sort", "(", "candidateList", ",", "HiCSSubspace", ".", "SORT_BY_SUBSPACE", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "candidateList", ".", "size", "(", ")", "-", "1", ";", "i", "++", ")", "{", "for", "(", "int", "j", "=", "i", "+", "1", ";", "j", "<", "candidateList", ".", "size", "(", ")", ";", "j", "++", ")", "{", "HiCSSubspace", "set1", "=", "candidateList", ".", "get", "(", "i", ")", ";", "HiCSSubspace", "set2", "=", "candidateList", ".", "get", "(", "j", ")", ";", "HiCSSubspace", "joinedSet", "=", "new", "HiCSSubspace", "(", ")", ";", "joinedSet", ".", "or", "(", "set1", ")", ";", "joinedSet", ".", "or", "(", "set2", ")", ";", "if", "(", "joinedSet", ".", "cardinality", "(", ")", "!=", "d", ")", "{", "continue", ";", "}", "calculateContrast", "(", "relation", ",", "joinedSet", ",", "subspaceIndex", ",", "random", ")", ";", "dDimensionalList", ".", "add", "(", "joinedSet", ")", ";", "LOG", ".", "incrementProcessed", "(", "qprog", ")", ";", "}", "}", "for", "(", "HiCSSubspace", "cand", ":", "candidateList", ")", "{", "for", "(", "Heap", "<", "HiCSSubspace", ">", ".", "UnorderedIter", "it", "=", "dDimensionalList", ".", "unorderedIter", "(", ")", ";", "it", ".", "valid", "(", ")", ";", "it", ".", "advance", "(", ")", ")", "{", "if", "(", "it", ".", "get", "(", ")", ".", "contrast", ">", "cand", ".", "contrast", ")", "{", "subspaceList", ".", "remove", "(", "cand", ")", ";", "break", ";", "}", "}", "}", "}", "LOG", ".", "setCompleted", "(", "qprog", ")", ";", "if", "(", "dprog", "!=", "null", ")", "{", "dprog", ".", "setProcessed", "(", "dbdim", ",", "LOG", ")", ";", "dprog", ".", "ensureCompleted", "(", "LOG", ")", ";", "}", "return", "subspaceList", ";", "}" ]
identifies high contrast subspaces in a given full - dimensional database .
train
true
171
public void testFailoverAutoReconnect() throws Exception { Set<String> downedHosts=new HashSet<String>(); downedHosts.add(HOST_1); downedHosts.add(HOST_2); Properties props=new Properties(); props.setProperty("retriesAllDown","2"); props.setProperty("maxReconnects","2"); props.setProperty("initialTimeout","1"); for ( boolean foAutoReconnect : new boolean[]{true,false}) { props.setProperty("autoReconnect",Boolean.toString(foAutoReconnect)); Connection testConn=getUnreliableFailoverConnection(new String[]{HOST_1,HOST_2,HOST_3},props,downedHosts); Statement testStmt1=null, testStmt2=null; try { assertEquals(HOST_3_OK,UnreliableSocketFactory.getHostFromLastConnection()); testStmt1=testConn.createStatement(); testStmt2=testConn.createStatement(); assertSingleValueQuery(testStmt1,"SELECT 1",1L); assertSingleValueQuery(testStmt2,"SELECT 2",2L); UnreliableSocketFactory.dontDownHost(HOST_2); UnreliableSocketFactory.downHost(HOST_3); assertEquals(HOST_3_OK,UnreliableSocketFactory.getHostFromLastConnection()); assertSQLException(testStmt1,"SELECT 1",COMM_LINK_ERR_PATTERN); assertEquals(HOST_2_OK,UnreliableSocketFactory.getHostFromLastConnection()); UnreliableSocketFactory.dontDownHost(HOST_1); if (!foAutoReconnect) { assertSQLException(testStmt1,"SELECT 1",STMT_CLOSED_ERR_PATTERN); assertSQLException(testStmt2,"SELECT 2",STMT_CLOSED_ERR_PATTERN); testStmt1=testConn.createStatement(); testStmt2=testConn.createStatement(); } assertSingleValueQuery(testStmt1,"SELECT 1",1L); assertSingleValueQuery(testStmt2,"SELECT 2",2L); UnreliableSocketFactory.downHost(HOST_2); assertEquals(HOST_2_OK,UnreliableSocketFactory.getHostFromLastConnection()); assertSQLException(testStmt2,"SELECT 2",COMM_LINK_ERR_PATTERN); assertEquals(HOST_1_OK,UnreliableSocketFactory.getHostFromLastConnection()); UnreliableSocketFactory.dontDownHost(HOST_3); if (!foAutoReconnect) { assertSQLException(testStmt1,"SELECT 1",STMT_CLOSED_ERR_PATTERN); assertSQLException(testStmt2,"SELECT 2",STMT_CLOSED_ERR_PATTERN); testStmt1=testConn.createStatement(); testStmt2=testConn.createStatement(); } assertSingleValueQuery(testStmt1,"SELECT 1",1L); assertSingleValueQuery(testStmt2,"SELECT 2",2L); UnreliableSocketFactory.downHost(HOST_1); assertEquals(HOST_1_OK,UnreliableSocketFactory.getHostFromLastConnection()); assertSQLException(testStmt1,"SELECT 1",COMM_LINK_ERR_PATTERN); assertEquals(HOST_3_OK,UnreliableSocketFactory.getHostFromLastConnection()); if (!foAutoReconnect) { assertSQLException(testStmt1,"SELECT 1",STMT_CLOSED_ERR_PATTERN); assertSQLException(testStmt2,"SELECT 2",STMT_CLOSED_ERR_PATTERN); testStmt1=testConn.createStatement(); testStmt2=testConn.createStatement(); } assertSingleValueQuery(testStmt1,"SELECT 1",1L); assertSingleValueQuery(testStmt2,"SELECT 2",2L); if (foAutoReconnect) { assertConnectionsHistory(HOST_1_FAIL,HOST_1_FAIL,HOST_2_FAIL,HOST_2_FAIL,HOST_3_OK,HOST_2_OK,HOST_3_FAIL,HOST_3_FAIL,HOST_2_FAIL,HOST_2_FAIL,HOST_3_FAIL,HOST_3_FAIL,HOST_1_OK,HOST_2_FAIL,HOST_2_FAIL,HOST_3_OK); } else { assertConnectionsHistory(HOST_1_FAIL,HOST_2_FAIL,HOST_3_OK,HOST_2_OK,HOST_3_FAIL,HOST_2_FAIL,HOST_3_FAIL,HOST_1_OK,HOST_2_FAIL,HOST_3_OK); } } finally { if (testStmt1 != null) { testStmt1.close(); } if (testStmt2 != null) { testStmt2.close(); } if (testConn != null) { testConn.close(); } } } }
[ "public", "void", "testFailoverAutoReconnect", "(", ")", "throws", "Exception", "{", "Set", "<", "String", ">", "downedHosts", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "downedHosts", ".", "add", "(", "HOST_1", ")", ";", "downedHosts", ".", "add", "(", "HOST_2", ")", ";", "Properties", "props", "=", "new", "Properties", "(", ")", ";", "props", ".", "setProperty", "(", "\"retriesAllDown\"", ",", "\"2\"", ")", ";", "props", ".", "setProperty", "(", "\"maxReconnects\"", ",", "\"2\"", ")", ";", "props", ".", "setProperty", "(", "\"initialTimeout\"", ",", "\"1\"", ")", ";", "for", "(", "boolean", "foAutoReconnect", ":", "new", "boolean", "[", "]", "{", "true", ",", "false", "}", ")", "{", "props", ".", "setProperty", "(", "\"autoReconnect\"", ",", "Boolean", ".", "toString", "(", "foAutoReconnect", ")", ")", ";", "Connection", "testConn", "=", "getUnreliableFailoverConnection", "(", "new", "String", "[", "]", "{", "HOST_1", ",", "HOST_2", ",", "HOST_3", "}", ",", "props", ",", "downedHosts", ")", ";", "Statement", "testStmt1", "=", "null", ",", "testStmt2", "=", "null", ";", "try", "{", "assertEquals", "(", "HOST_3_OK", ",", "UnreliableSocketFactory", ".", "getHostFromLastConnection", "(", ")", ")", ";", "testStmt1", "=", "testConn", ".", "createStatement", "(", ")", ";", "testStmt2", "=", "testConn", ".", "createStatement", "(", ")", ";", "assertSingleValueQuery", "(", "testStmt1", ",", "\"SELECT 1\"", ",", "1L", ")", ";", "assertSingleValueQuery", "(", "testStmt2", ",", "\"SELECT 2\"", ",", "2L", ")", ";", "UnreliableSocketFactory", ".", "dontDownHost", "(", "HOST_2", ")", ";", "UnreliableSocketFactory", ".", "downHost", "(", "HOST_3", ")", ";", "assertEquals", "(", "HOST_3_OK", ",", "UnreliableSocketFactory", ".", "getHostFromLastConnection", "(", ")", ")", ";", "assertSQLException", "(", "testStmt1", ",", "\"SELECT 1\"", ",", "COMM_LINK_ERR_PATTERN", ")", ";", "assertEquals", "(", "HOST_2_OK", ",", "UnreliableSocketFactory", ".", "getHostFromLastConnection", "(", ")", ")", ";", "UnreliableSocketFactory", ".", "dontDownHost", "(", "HOST_1", ")", ";", "if", "(", "!", "foAutoReconnect", ")", "{", "assertSQLException", "(", "testStmt1", ",", "\"SELECT 1\"", ",", "STMT_CLOSED_ERR_PATTERN", ")", ";", "assertSQLException", "(", "testStmt2", ",", "\"SELECT 2\"", ",", "STMT_CLOSED_ERR_PATTERN", ")", ";", "testStmt1", "=", "testConn", ".", "createStatement", "(", ")", ";", "testStmt2", "=", "testConn", ".", "createStatement", "(", ")", ";", "}", "assertSingleValueQuery", "(", "testStmt1", ",", "\"SELECT 1\"", ",", "1L", ")", ";", "assertSingleValueQuery", "(", "testStmt2", ",", "\"SELECT 2\"", ",", "2L", ")", ";", "UnreliableSocketFactory", ".", "downHost", "(", "HOST_2", ")", ";", "assertEquals", "(", "HOST_2_OK", ",", "UnreliableSocketFactory", ".", "getHostFromLastConnection", "(", ")", ")", ";", "assertSQLException", "(", "testStmt2", ",", "\"SELECT 2\"", ",", "COMM_LINK_ERR_PATTERN", ")", ";", "assertEquals", "(", "HOST_1_OK", ",", "UnreliableSocketFactory", ".", "getHostFromLastConnection", "(", ")", ")", ";", "UnreliableSocketFactory", ".", "dontDownHost", "(", "HOST_3", ")", ";", "if", "(", "!", "foAutoReconnect", ")", "{", "assertSQLException", "(", "testStmt1", ",", "\"SELECT 1\"", ",", "STMT_CLOSED_ERR_PATTERN", ")", ";", "assertSQLException", "(", "testStmt2", ",", "\"SELECT 2\"", ",", "STMT_CLOSED_ERR_PATTERN", ")", ";", "testStmt1", "=", "testConn", ".", "createStatement", "(", ")", ";", "testStmt2", "=", "testConn", ".", "createStatement", "(", ")", ";", "}", "assertSingleValueQuery", "(", "testStmt1", ",", "\"SELECT 1\"", ",", "1L", ")", ";", "assertSingleValueQuery", "(", "testStmt2", ",", "\"SELECT 2\"", ",", "2L", ")", ";", "UnreliableSocketFactory", ".", "downHost", "(", "HOST_1", ")", ";", "assertEquals", "(", "HOST_1_OK", ",", "UnreliableSocketFactory", ".", "getHostFromLastConnection", "(", ")", ")", ";", "assertSQLException", "(", "testStmt1", ",", "\"SELECT 1\"", ",", "COMM_LINK_ERR_PATTERN", ")", ";", "assertEquals", "(", "HOST_3_OK", ",", "UnreliableSocketFactory", ".", "getHostFromLastConnection", "(", ")", ")", ";", "if", "(", "!", "foAutoReconnect", ")", "{", "assertSQLException", "(", "testStmt1", ",", "\"SELECT 1\"", ",", "STMT_CLOSED_ERR_PATTERN", ")", ";", "assertSQLException", "(", "testStmt2", ",", "\"SELECT 2\"", ",", "STMT_CLOSED_ERR_PATTERN", ")", ";", "testStmt1", "=", "testConn", ".", "createStatement", "(", ")", ";", "testStmt2", "=", "testConn", ".", "createStatement", "(", ")", ";", "}", "assertSingleValueQuery", "(", "testStmt1", ",", "\"SELECT 1\"", ",", "1L", ")", ";", "assertSingleValueQuery", "(", "testStmt2", ",", "\"SELECT 2\"", ",", "2L", ")", ";", "if", "(", "foAutoReconnect", ")", "{", "assertConnectionsHistory", "(", "HOST_1_FAIL", ",", "HOST_1_FAIL", ",", "HOST_2_FAIL", ",", "HOST_2_FAIL", ",", "HOST_3_OK", ",", "HOST_2_OK", ",", "HOST_3_FAIL", ",", "HOST_3_FAIL", ",", "HOST_2_FAIL", ",", "HOST_2_FAIL", ",", "HOST_3_FAIL", ",", "HOST_3_FAIL", ",", "HOST_1_OK", ",", "HOST_2_FAIL", ",", "HOST_2_FAIL", ",", "HOST_3_OK", ")", ";", "}", "else", "{", "assertConnectionsHistory", "(", "HOST_1_FAIL", ",", "HOST_2_FAIL", ",", "HOST_3_OK", ",", "HOST_2_OK", ",", "HOST_3_FAIL", ",", "HOST_2_FAIL", ",", "HOST_3_FAIL", ",", "HOST_1_OK", ",", "HOST_2_FAIL", ",", "HOST_3_OK", ")", ";", "}", "}", "finally", "{", "if", "(", "testStmt1", "!=", "null", ")", "{", "testStmt1", ".", "close", "(", ")", ";", "}", "if", "(", "testStmt2", "!=", "null", ")", "{", "testStmt2", ".", "close", "(", ")", ";", "}", "if", "(", "testConn", "!=", "null", ")", "{", "testConn", ".", "close", "(", ")", ";", "}", "}", "}", "}" ]
tests the property ' autoreconnect ' in a failover connection using three hosts and the following sequence of events : - [ \ host_1 : \ host_2 : / host_3 ] - - > host_3 - [ \ host_1 : / host_2 : \ host_3 ] - - > host_2 - [ / host_1 : / host_2 : \ host_3 ] - [ / host_1 : \ host_2 : \ host_3 ] - - > host_1 - [ / host_1 : \ host_2 : / host_3 ] - [ \ host_1 : \ host_2 : / host_3 ] - - > host_3 [ legend : " / host_n " - - > host_n up ; " \ host_n " - - > host_n down ]
train
false
172
public void addContainerRequest(Map<StreamingContainerAgent.ContainerStartRequest,MutablePair<Integer,ContainerRequest>> requestedResources,int loopCounter,List<ContainerRequest> containerRequests,StreamingContainerAgent.ContainerStartRequest csr,ContainerRequest cr){ MutablePair<Integer,ContainerRequest> pair=new MutablePair<Integer,ContainerRequest>(loopCounter,cr); requestedResources.put(csr,pair); containerRequests.add(cr); }
[ "public", "void", "addContainerRequest", "(", "Map", "<", "StreamingContainerAgent", ".", "ContainerStartRequest", ",", "MutablePair", "<", "Integer", ",", "ContainerRequest", ">", ">", "requestedResources", ",", "int", "loopCounter", ",", "List", "<", "ContainerRequest", ">", "containerRequests", ",", "StreamingContainerAgent", ".", "ContainerStartRequest", "csr", ",", "ContainerRequest", "cr", ")", "{", "MutablePair", "<", "Integer", ",", "ContainerRequest", ">", "pair", "=", "new", "MutablePair", "<", "Integer", ",", "ContainerRequest", ">", "(", "loopCounter", ",", "cr", ")", ";", "requestedResources", ".", "put", "(", "csr", ",", "pair", ")", ";", "containerRequests", ".", "add", "(", "cr", ")", ";", "}" ]
add container request to list of issued requests to yarn along with current loop counter
train
false
173
public void waitForChannelState(DistributedMember member,Map channelState) throws InterruptedException { if (Thread.interrupted()) throw new InterruptedException(); TCPConduit tc=this.conduit; if (tc != null) { tc.waitForThreadOwnedOrderedConnectionState(member,channelState); } }
[ "public", "void", "waitForChannelState", "(", "DistributedMember", "member", ",", "Map", "channelState", ")", "throws", "InterruptedException", "{", "if", "(", "Thread", ".", "interrupted", "(", ")", ")", "throw", "new", "InterruptedException", "(", ")", ";", "TCPConduit", "tc", "=", "this", ".", "conduit", ";", "if", "(", "tc", "!=", "null", ")", "{", "tc", ".", "waitForThreadOwnedOrderedConnectionState", "(", "member", ",", "channelState", ")", ";", "}", "}" ]
wait for the given connections to process the number of messages associated with the connection in the given map
train
false
174
private boolean isSameCircleOfTrust(BaseConfigType config,String realm,String entityID){ boolean isTrusted=false; if (config != null) { Map attr=IDFFMetaUtils.getAttributes(config); List cotList=(List)attr.get(IDFFCOTUtils.COT_LIST); if ((cotList != null) && !cotList.isEmpty()) { for (Iterator iter=cotList.iterator(); iter.hasNext(); ) { String cotName=(String)iter.next(); if (cotManager.isInCircleOfTrust(realm,cotName,COTConstants.IDFF,entityID)) { isTrusted=true; } } } } return isTrusted; }
[ "private", "boolean", "isSameCircleOfTrust", "(", "BaseConfigType", "config", ",", "String", "realm", ",", "String", "entityID", ")", "{", "boolean", "isTrusted", "=", "false", ";", "if", "(", "config", "!=", "null", ")", "{", "Map", "attr", "=", "IDFFMetaUtils", ".", "getAttributes", "(", "config", ")", ";", "List", "cotList", "=", "(", "List", ")", "attr", ".", "get", "(", "IDFFCOTUtils", ".", "COT_LIST", ")", ";", "if", "(", "(", "cotList", "!=", "null", ")", "&&", "!", "cotList", ".", "isEmpty", "(", ")", ")", "{", "for", "(", "Iterator", "iter", "=", "cotList", ".", "iterator", "(", ")", ";", "iter", ".", "hasNext", "(", ")", ";", ")", "{", "String", "cotName", "=", "(", "String", ")", "iter", ".", "next", "(", ")", ";", "if", "(", "cotManager", ".", "isInCircleOfTrust", "(", "realm", ",", "cotName", ",", "COTConstants", ".", "IDFF", ",", "entityID", ")", ")", "{", "isTrusted", "=", "true", ";", "}", "}", "}", "}", "return", "isTrusted", ";", "}" ]
checks if the remote entity identifier is in the entity config ' s circle of trust .
train
false
175
public RuleGrounding(){ groundings=new HashSet<Assignment>(); groundings.add(new Assignment()); }
[ "public", "RuleGrounding", "(", ")", "{", "groundings", "=", "new", "HashSet", "<", "Assignment", ">", "(", ")", ";", "groundings", ".", "add", "(", "new", "Assignment", "(", ")", ")", ";", "}" ]
constructs an empty set of groundings
train
false
176
public void removeIndexKeyspace(final String index) throws IOException { try { QueryProcessor.process(String.format("DROP KEYSPACE \"%s\";",index),ConsistencyLevel.LOCAL_ONE); } catch ( Throwable e) { throw new IOException(e.getMessage(),e); } }
[ "public", "void", "removeIndexKeyspace", "(", "final", "String", "index", ")", "throws", "IOException", "{", "try", "{", "QueryProcessor", ".", "process", "(", "String", ".", "format", "(", "\"DROP KEYSPACE \\\"%s\\\";\"", ",", "index", ")", ",", "ConsistencyLevel", ".", "LOCAL_ONE", ")", ";", "}", "catch", "(", "Throwable", "e", ")", "{", "throw", "new", "IOException", "(", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "}" ]
don ' t use queryprocessor . executeinternal , we need to propagate this on all nodes .
train
false
177
public void writeVecor(File ftrain,File ftest,File all,File trainLabel) throws Exception { int labels[]=readLabels(); FileWriter fw=new FileWriter(ftrain); FileWriter fwt=new FileWriter(ftest); FileWriter flabel=new FileWriter(trainLabel); for (int i=0; i < dataNum; i++) { if (TestTrain[i] == 1) { flabel.write(String.valueOf(labels[i]) + '\n'); for (int j=0; j < dimension; j++) { if (j != dimension - 1) { fw.write(String.valueOf(W[i][j]) + " "); } else { fw.write(String.valueOf(W[i][j]) + '\n'); } } } else { for (int j=0; j < dimension; j++) { if (j != dimension - 1) { fwt.write(String.valueOf(W[i][j]) + " "); } else { fwt.write(String.valueOf(W[i][j]) + '\n'); } } } } fw.close(); fwt.close(); flabel.close(); FileWriter fwall=new FileWriter(all); for (int i=0; i < dataNum; i++) { for (int j=0; j < dimension; j++) { if (j != dimension - 1) { fwall.write(String.valueOf(W[i][j]) + " "); } else { fwall.write(String.valueOf(W[i][j]) + '\n'); } } } fwall.close(); }
[ "public", "void", "writeVecor", "(", "File", "ftrain", ",", "File", "ftest", ",", "File", "all", ",", "File", "trainLabel", ")", "throws", "Exception", "{", "int", "labels", "[", "]", "=", "readLabels", "(", ")", ";", "FileWriter", "fw", "=", "new", "FileWriter", "(", "ftrain", ")", ";", "FileWriter", "fwt", "=", "new", "FileWriter", "(", "ftest", ")", ";", "FileWriter", "flabel", "=", "new", "FileWriter", "(", "trainLabel", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "dataNum", ";", "i", "++", ")", "{", "if", "(", "TestTrain", "[", "i", "]", "==", "1", ")", "{", "flabel", ".", "write", "(", "String", ".", "valueOf", "(", "labels", "[", "i", "]", ")", "+", "'\\n'", ")", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "dimension", ";", "j", "++", ")", "{", "if", "(", "j", "!=", "dimension", "-", "1", ")", "{", "fw", ".", "write", "(", "String", ".", "valueOf", "(", "W", "[", "i", "]", "[", "j", "]", ")", "+", "\" \"", ")", ";", "}", "else", "{", "fw", ".", "write", "(", "String", ".", "valueOf", "(", "W", "[", "i", "]", "[", "j", "]", ")", "+", "'\\n'", ")", ";", "}", "}", "}", "else", "{", "for", "(", "int", "j", "=", "0", ";", "j", "<", "dimension", ";", "j", "++", ")", "{", "if", "(", "j", "!=", "dimension", "-", "1", ")", "{", "fwt", ".", "write", "(", "String", ".", "valueOf", "(", "W", "[", "i", "]", "[", "j", "]", ")", "+", "\" \"", ")", ";", "}", "else", "{", "fwt", ".", "write", "(", "String", ".", "valueOf", "(", "W", "[", "i", "]", "[", "j", "]", ")", "+", "'\\n'", ")", ";", "}", "}", "}", "}", "fw", ".", "close", "(", ")", ";", "fwt", ".", "close", "(", ")", ";", "flabel", ".", "close", "(", ")", ";", "FileWriter", "fwall", "=", "new", "FileWriter", "(", "all", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "dataNum", ";", "i", "++", ")", "{", "for", "(", "int", "j", "=", "0", ";", "j", "<", "dimension", ";", "j", "++", ")", "{", "if", "(", "j", "!=", "dimension", "-", "1", ")", "{", "fwall", ".", "write", "(", "String", ".", "valueOf", "(", "W", "[", "i", "]", "[", "j", "]", ")", "+", "\" \"", ")", ";", "}", "else", "{", "fwall", ".", "write", "(", "String", ".", "valueOf", "(", "W", "[", "i", "]", "[", "j", "]", ")", "+", "'\\n'", ")", ";", "}", "}", "}", "fwall", ".", "close", "(", ")", ";", "}" ]
write the trained embedding to certain files .
train
false
179
public static String unhtmlAngleBrackets(String str){ str=str.replaceAll("&lt;","<"); str=str.replaceAll("&gt;",">"); return str; }
[ "public", "static", "String", "unhtmlAngleBrackets", "(", "String", "str", ")", "{", "str", "=", "str", ".", "replaceAll", "(", "\"&lt;\"", ",", "\"<\"", ")", ";", "str", "=", "str", ".", "replaceAll", "(", "\"&gt;\"", ",", "\">\"", ")", ";", "return", "str", ";", "}" ]
replace & amp ; lt ; & amp ; gt ; entities with & lt ; & gt ; characters .
train
false
180
public long next(long fromTime){ if (getCurrentCount() == 0 || fromTime == 0 || fromTime == startDate.getTime()) { return first(); } if (Debug.verboseOn()) { Debug.logVerbose("Date List Size: " + (rDateList == null ? 0 : rDateList.size()),module); Debug.logVerbose("Rule List Size: " + (rRulesList == null ? 0 : rRulesList.size()),module); } if (rDateList == null && rRulesList == null) { return 0; } long nextRuleTime=fromTime; boolean hasNext=true; Iterator<RecurrenceRule> rulesIterator=getRecurrenceRuleIterator(); while (rulesIterator.hasNext()) { RecurrenceRule rule=rulesIterator.next(); while (hasNext) { nextRuleTime=getNextTime(rule,nextRuleTime); if (nextRuleTime == 0 || isValid(nextRuleTime)) { hasNext=false; } } } return nextRuleTime; }
[ "public", "long", "next", "(", "long", "fromTime", ")", "{", "if", "(", "getCurrentCount", "(", ")", "==", "0", "||", "fromTime", "==", "0", "||", "fromTime", "==", "startDate", ".", "getTime", "(", ")", ")", "{", "return", "first", "(", ")", ";", "}", "if", "(", "Debug", ".", "verboseOn", "(", ")", ")", "{", "Debug", ".", "logVerbose", "(", "\"Date List Size: \"", "+", "(", "rDateList", "==", "null", "?", "0", ":", "rDateList", ".", "size", "(", ")", ")", ",", "module", ")", ";", "Debug", ".", "logVerbose", "(", "\"Rule List Size: \"", "+", "(", "rRulesList", "==", "null", "?", "0", ":", "rRulesList", ".", "size", "(", ")", ")", ",", "module", ")", ";", "}", "if", "(", "rDateList", "==", "null", "&&", "rRulesList", "==", "null", ")", "{", "return", "0", ";", "}", "long", "nextRuleTime", "=", "fromTime", ";", "boolean", "hasNext", "=", "true", ";", "Iterator", "<", "RecurrenceRule", ">", "rulesIterator", "=", "getRecurrenceRuleIterator", "(", ")", ";", "while", "(", "rulesIterator", ".", "hasNext", "(", ")", ")", "{", "RecurrenceRule", "rule", "=", "rulesIterator", ".", "next", "(", ")", ";", "while", "(", "hasNext", ")", "{", "nextRuleTime", "=", "getNextTime", "(", "rule", ",", "nextRuleTime", ")", ";", "if", "(", "nextRuleTime", "==", "0", "||", "isValid", "(", "nextRuleTime", ")", ")", "{", "hasNext", "=", "false", ";", "}", "}", "}", "return", "nextRuleTime", ";", "}" ]
returns the next recurrence from the specified time .
train
false
182
public ResultT extractLatestAttempted(){ ArrayList<UpdateT> updates=new ArrayList<>(inflightAttempted.size() + 1); synchronized (attemptedLock) { updates.add(finishedAttempted); updates.addAll(inflightAttempted.values()); } return aggregation.extract(aggregation.combine(updates)); }
[ "public", "ResultT", "extractLatestAttempted", "(", ")", "{", "ArrayList", "<", "UpdateT", ">", "updates", "=", "new", "ArrayList", "<", ">", "(", "inflightAttempted", ".", "size", "(", ")", "+", "1", ")", ";", "synchronized", "(", "attemptedLock", ")", "{", "updates", ".", "add", "(", "finishedAttempted", ")", ";", "updates", ".", "addAll", "(", "inflightAttempted", ".", "values", "(", ")", ")", ";", "}", "return", "aggregation", ".", "extract", "(", "aggregation", ".", "combine", "(", "updates", ")", ")", ";", "}" ]
extract the latest values from all attempted and in - progress bundles .
train
false
183
public Set<JsonUser> loadKnownUsers() throws InterruptedException, ExecutionException, RemoteException, OperationApplicationException { Set<JsonUser> users=getUsersFromDb(); if (users.isEmpty()) { LOG.i("Database contains no user; fetching from server"); users=syncKnownUsers(); } LOG.i(String.format("Found %d users in db",users.size())); return users; }
[ "public", "Set", "<", "JsonUser", ">", "loadKnownUsers", "(", ")", "throws", "InterruptedException", ",", "ExecutionException", ",", "RemoteException", ",", "OperationApplicationException", "{", "Set", "<", "JsonUser", ">", "users", "=", "getUsersFromDb", "(", ")", ";", "if", "(", "users", ".", "isEmpty", "(", ")", ")", "{", "LOG", ".", "i", "(", "\"Database contains no user; fetching from server\"", ")", ";", "users", "=", "syncKnownUsers", "(", ")", ";", "}", "LOG", ".", "i", "(", "String", ".", "format", "(", "\"Found %d users in db\"", ",", "users", ".", "size", "(", ")", ")", ")", ";", "return", "users", ";", "}" ]
loads the known users from local store . if there is no user in db or the application can ' t retrieve from there , then it fetches the users from server
train
false
184
public void start(){ eventLogThread.start(); LOGGER.info("Started " + eventLogThread.getName() + " with ID "+ eventLogThread.getId()+ "."); }
[ "public", "void", "start", "(", ")", "{", "eventLogThread", ".", "start", "(", ")", ";", "LOGGER", ".", "info", "(", "\"Started \"", "+", "eventLogThread", ".", "getName", "(", ")", "+", "\" with ID \"", "+", "eventLogThread", ".", "getId", "(", ")", "+", "\".\"", ")", ";", "}" ]
starts the event log thread .
train
false
185
private static String htmlencode(String str){ if (str == null) { return ""; } else { StringBuilder buf=new StringBuilder(); for ( char ch : str.toCharArray()) { switch (ch) { case '<': buf.append("&lt;"); break; case '>': buf.append("&gt;"); break; case '&': buf.append("&amp;"); break; default : buf.append(ch); break; } } return buf.toString(); } }
[ "private", "static", "String", "htmlencode", "(", "String", "str", ")", "{", "if", "(", "str", "==", "null", ")", "{", "return", "\"\"", ";", "}", "else", "{", "StringBuilder", "buf", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "char", "ch", ":", "str", ".", "toCharArray", "(", ")", ")", "{", "switch", "(", "ch", ")", "{", "case", "'<'", ":", "buf", ".", "append", "(", "\"&lt;\"", ")", ";", "break", ";", "case", "'>'", ":", "buf", ".", "append", "(", "\"&gt;\"", ")", ";", "break", ";", "case", "'&'", ":", "buf", ".", "append", "(", "\"&amp;\"", ")", ";", "break", ";", "default", ":", "buf", ".", "append", "(", "ch", ")", ";", "break", ";", "}", "}", "return", "buf", ".", "toString", "(", ")", ";", "}", "}" ]
escapes all ' < ' , ' > ' and ' & ' characters in a string .
train
false
187
public static void begin(ServletRequest request,ServletResponse response,String serviceName,String objectId) throws ServletException { ServiceContext context=(ServiceContext)_localContext.get(); if (context == null) { context=new ServiceContext(); _localContext.set(context); } context._request=request; context._response=response; context._serviceName=serviceName; context._objectId=objectId; context._count++; }
[ "public", "static", "void", "begin", "(", "ServletRequest", "request", ",", "ServletResponse", "response", ",", "String", "serviceName", ",", "String", "objectId", ")", "throws", "ServletException", "{", "ServiceContext", "context", "=", "(", "ServiceContext", ")", "_localContext", ".", "get", "(", ")", ";", "if", "(", "context", "==", "null", ")", "{", "context", "=", "new", "ServiceContext", "(", ")", ";", "_localContext", ".", "set", "(", "context", ")", ";", "}", "context", ".", "_request", "=", "request", ";", "context", ".", "_response", "=", "response", ";", "context", ".", "_serviceName", "=", "serviceName", ";", "context", ".", "_objectId", "=", "objectId", ";", "context", ".", "_count", "++", ";", "}" ]
sets the request object prior to calling the service ' s method .
train
true
188
public final BufferedImage loadStoredImage(String current_image){ if (current_image == null) { return null; } current_image=removeIllegalFileNameCharacters(current_image); final String flag=image_type.get(current_image); BufferedImage image=null; if (flag == null) { return null; } else if (flag.equals("tif")) { image=loadStoredImage(current_image,".tif"); } else if (flag.equals("jpg")) { image=loadStoredJPEGImage(current_image); } else if (flag.equals("png")) { image=loadStoredImage(current_image,".png"); } else if (flag.equals("jpl")) { image=loadStoredImage(current_image,".jpl"); } return image; }
[ "public", "final", "BufferedImage", "loadStoredImage", "(", "String", "current_image", ")", "{", "if", "(", "current_image", "==", "null", ")", "{", "return", "null", ";", "}", "current_image", "=", "removeIllegalFileNameCharacters", "(", "current_image", ")", ";", "final", "String", "flag", "=", "image_type", ".", "get", "(", "current_image", ")", ";", "BufferedImage", "image", "=", "null", ";", "if", "(", "flag", "==", "null", ")", "{", "return", "null", ";", "}", "else", "if", "(", "flag", ".", "equals", "(", "\"tif\"", ")", ")", "{", "image", "=", "loadStoredImage", "(", "current_image", ",", "\".tif\"", ")", ";", "}", "else", "if", "(", "flag", ".", "equals", "(", "\"jpg\"", ")", ")", "{", "image", "=", "loadStoredJPEGImage", "(", "current_image", ")", ";", "}", "else", "if", "(", "flag", ".", "equals", "(", "\"png\"", ")", ")", "{", "image", "=", "loadStoredImage", "(", "current_image", ",", "\".png\"", ")", ";", "}", "else", "if", "(", "flag", ".", "equals", "(", "\"jpl\"", ")", ")", "{", "image", "=", "loadStoredImage", "(", "current_image", ",", "\".jpl\"", ")", ";", "}", "return", "image", ";", "}" ]
load a image when required and remove from store
train
false
189
public boolean canUseCachedProjectData(){ if (!myGradlePluginVersion.equals(GRADLE_PLUGIN_RECOMMENDED_VERSION)) { return false; } for ( Map.Entry<String,byte[]> entry : myFileChecksums.entrySet()) { File file=new File(entry.getKey()); if (!file.isAbsolute()) { file=new File(myRootDirPath,file.getPath()); } try { if (!Arrays.equals(entry.getValue(),createChecksum(file))) { return false; } } catch ( IOException e) { return false; } } return true; }
[ "public", "boolean", "canUseCachedProjectData", "(", ")", "{", "if", "(", "!", "myGradlePluginVersion", ".", "equals", "(", "GRADLE_PLUGIN_RECOMMENDED_VERSION", ")", ")", "{", "return", "false", ";", "}", "for", "(", "Map", ".", "Entry", "<", "String", ",", "byte", "[", "]", ">", "entry", ":", "myFileChecksums", ".", "entrySet", "(", ")", ")", "{", "File", "file", "=", "new", "File", "(", "entry", ".", "getKey", "(", ")", ")", ";", "if", "(", "!", "file", ".", "isAbsolute", "(", ")", ")", "{", "file", "=", "new", "File", "(", "myRootDirPath", ",", "file", ".", "getPath", "(", ")", ")", ";", "}", "try", "{", "if", "(", "!", "Arrays", ".", "equals", "(", "entry", ".", "getValue", "(", ")", ",", "createChecksum", "(", "file", ")", ")", ")", "{", "return", "false", ";", "}", "}", "catch", "(", "IOException", "e", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
verifies that whether the persisted external project data can be used to create the project or not . < p / > this validates that all the files that the external project data depends on , still have the same content checksum and that the gradle model version is still the same .
train
false
190
protected void waitForImage(Image image){ int id=++nextTrackerID; tracker.addImage(image,id); try { tracker.waitForID(id,0); } catch ( InterruptedException e) { e.printStackTrace(); } tracker.removeImage(image,id); }
[ "protected", "void", "waitForImage", "(", "Image", "image", ")", "{", "int", "id", "=", "++", "nextTrackerID", ";", "tracker", ".", "addImage", "(", "image", ",", "id", ")", ";", "try", "{", "tracker", ".", "waitForID", "(", "id", ",", "0", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "tracker", ".", "removeImage", "(", "image", ",", "id", ")", ";", "}" ]
wait for an image to load .
train
false
193
private static boolean isNonLeft(int i0,int i1,int i2,int i3,double[] pts){ double l1, l2, l4, l5, l6, angle1, angle2, angle; l1=Math.sqrt(Math.pow(pts[i2 + 1] - pts[i1 + 1],2) + Math.pow(pts[i2] - pts[i1],2)); l2=Math.sqrt(Math.pow(pts[i3 + 1] - pts[i2 + 1],2) + Math.pow(pts[i3] - pts[i2],2)); l4=Math.sqrt(Math.pow(pts[i3 + 1] - pts[i0 + 1],2) + Math.pow(pts[i3] - pts[i0],2)); l5=Math.sqrt(Math.pow(pts[i1 + 1] - pts[i0 + 1],2) + Math.pow(pts[i1] - pts[i0],2)); l6=Math.sqrt(Math.pow(pts[i2 + 1] - pts[i0 + 1],2) + Math.pow(pts[i2] - pts[i0],2)); angle1=Math.acos(((l2 * l2) + (l6 * l6) - (l4 * l4)) / (2 * l2 * l6)); angle2=Math.acos(((l6 * l6) + (l1 * l1) - (l5 * l5)) / (2 * l6 * l1)); angle=(Math.PI - angle1) - angle2; if (angle <= 0.0) { return (true); } else { return (false); } }
[ "private", "static", "boolean", "isNonLeft", "(", "int", "i0", ",", "int", "i1", ",", "int", "i2", ",", "int", "i3", ",", "double", "[", "]", "pts", ")", "{", "double", "l1", ",", "l2", ",", "l4", ",", "l5", ",", "l6", ",", "angle1", ",", "angle2", ",", "angle", ";", "l1", "=", "Math", ".", "sqrt", "(", "Math", ".", "pow", "(", "pts", "[", "i2", "+", "1", "]", "-", "pts", "[", "i1", "+", "1", "]", ",", "2", ")", "+", "Math", ".", "pow", "(", "pts", "[", "i2", "]", "-", "pts", "[", "i1", "]", ",", "2", ")", ")", ";", "l2", "=", "Math", ".", "sqrt", "(", "Math", ".", "pow", "(", "pts", "[", "i3", "+", "1", "]", "-", "pts", "[", "i2", "+", "1", "]", ",", "2", ")", "+", "Math", ".", "pow", "(", "pts", "[", "i3", "]", "-", "pts", "[", "i2", "]", ",", "2", ")", ")", ";", "l4", "=", "Math", ".", "sqrt", "(", "Math", ".", "pow", "(", "pts", "[", "i3", "+", "1", "]", "-", "pts", "[", "i0", "+", "1", "]", ",", "2", ")", "+", "Math", ".", "pow", "(", "pts", "[", "i3", "]", "-", "pts", "[", "i0", "]", ",", "2", ")", ")", ";", "l5", "=", "Math", ".", "sqrt", "(", "Math", ".", "pow", "(", "pts", "[", "i1", "+", "1", "]", "-", "pts", "[", "i0", "+", "1", "]", ",", "2", ")", "+", "Math", ".", "pow", "(", "pts", "[", "i1", "]", "-", "pts", "[", "i0", "]", ",", "2", ")", ")", ";", "l6", "=", "Math", ".", "sqrt", "(", "Math", ".", "pow", "(", "pts", "[", "i2", "+", "1", "]", "-", "pts", "[", "i0", "+", "1", "]", ",", "2", ")", "+", "Math", ".", "pow", "(", "pts", "[", "i2", "]", "-", "pts", "[", "i0", "]", ",", "2", ")", ")", ";", "angle1", "=", "Math", ".", "acos", "(", "(", "(", "l2", "*", "l2", ")", "+", "(", "l6", "*", "l6", ")", "-", "(", "l4", "*", "l4", ")", ")", "/", "(", "2", "*", "l2", "*", "l6", ")", ")", ";", "angle2", "=", "Math", ".", "acos", "(", "(", "(", "l6", "*", "l6", ")", "+", "(", "l1", "*", "l1", ")", "-", "(", "l5", "*", "l5", ")", ")", "/", "(", "2", "*", "l6", "*", "l1", ")", ")", ";", "angle", "=", "(", "Math", ".", "PI", "-", "angle1", ")", "-", "angle2", ";", "if", "(", "angle", "<=", "0.0", ")", "{", "return", "(", "true", ")", ";", "}", "else", "{", "return", "(", "false", ")", ";", "}", "}" ]
convex hull helper method for detecting a non left turn about 3 points
train
false
194
@RequestMapping(value="/SAML2/SLO/{tenant:.*}") public void sloError(Locale locale,@PathVariable(value="tenant") String tenant,HttpServletResponse response) throws IOException { logger.info("SLO binding error! The client locale is " + locale.toString() + ", tenant is "+ tenant); sloDefaultTenantBindingError(locale,response); }
[ "@", "RequestMapping", "(", "value", "=", "\"/SAML2/SLO/{tenant:.*}\"", ")", "public", "void", "sloError", "(", "Locale", "locale", ",", "@", "PathVariable", "(", "value", "=", "\"tenant\"", ")", "String", "tenant", ",", "HttpServletResponse", "response", ")", "throws", "IOException", "{", "logger", ".", "info", "(", "\"SLO binding error! The client locale is \"", "+", "locale", ".", "toString", "(", ")", "+", "\", tenant is \"", "+", "tenant", ")", ";", "sloDefaultTenantBindingError", "(", "locale", ",", "response", ")", ";", "}" ]
handle request sent with a wrong binding
train
false
195
public static double cdf(double x,double lambda){ return 1.0 - Math.exp(-lambda * x); }
[ "public", "static", "double", "cdf", "(", "double", "x", ",", "double", "lambda", ")", "{", "return", "1.0", "-", "Math", ".", "exp", "(", "-", "lambda", "*", "x", ")", ";", "}" ]
cumulative density function of the exponential distribution
train
false
197
private boolean isDerivedByRestriction(String ancestorNS,String ancestorName,XSTypeDefinition type){ XSTypeDefinition oldType=null; while (type != null && type != oldType) { if ((ancestorName.equals(type.getName())) && ((ancestorNS != null && ancestorNS.equals(type.getNamespace())) || (type.getNamespace() == null && ancestorNS == null))) { return true; } oldType=type; type=type.getBaseType(); } return false; }
[ "private", "boolean", "isDerivedByRestriction", "(", "String", "ancestorNS", ",", "String", "ancestorName", ",", "XSTypeDefinition", "type", ")", "{", "XSTypeDefinition", "oldType", "=", "null", ";", "while", "(", "type", "!=", "null", "&&", "type", "!=", "oldType", ")", "{", "if", "(", "(", "ancestorName", ".", "equals", "(", "type", ".", "getName", "(", ")", ")", ")", "&&", "(", "(", "ancestorNS", "!=", "null", "&&", "ancestorNS", ".", "equals", "(", "type", ".", "getNamespace", "(", ")", ")", ")", "||", "(", "type", ".", "getNamespace", "(", ")", "==", "null", "&&", "ancestorNS", "==", "null", ")", ")", ")", "{", "return", "true", ";", "}", "oldType", "=", "type", ";", "type", "=", "type", ".", "getBaseType", "(", ")", ";", "}", "return", "false", ";", "}" ]
dom level 3 checks if a type is derived from another by restriction . see : http : / / www . w3 . org / tr / 2004 / rec - dom - level - 3 - core - 20040407 / core . html # typeinfo - isderivedfrom
train
false
199
public static void onOperatorError(BiFunction<? super Throwable,Object,? extends Throwable> f){ log.info("Hooking new default : onOperatorError"); onOperatorErrorHook=Objects.requireNonNull(f,"onOperatorErrorHook"); }
[ "public", "static", "void", "onOperatorError", "(", "BiFunction", "<", "?", "super", "Throwable", ",", "Object", ",", "?", "extends", "Throwable", ">", "f", ")", "{", "log", ".", "info", "(", "\"Hooking new default : onOperatorError\"", ")", ";", "onOperatorErrorHook", "=", "Objects", ".", "requireNonNull", "(", "f", ",", "\"onOperatorErrorHook\"", ")", ";", "}" ]
override global operator error mapping which by default add as suppressed exception either data driven exception or error driven exception .
train
false
200
public boolean showJoinPartAndQuit(){ return preferences.getBoolean(resources.getString(R.string.key_show_joinpartquit),Boolean.parseBoolean(resources.getString(R.string.default_show_joinpartquit))); }
[ "public", "boolean", "showJoinPartAndQuit", "(", ")", "{", "return", "preferences", ".", "getBoolean", "(", "resources", ".", "getString", "(", "R", ".", "string", ".", "key_show_joinpartquit", ")", ",", "Boolean", ".", "parseBoolean", "(", "resources", ".", "getString", "(", "R", ".", "string", ".", "default_show_joinpartquit", ")", ")", ")", ";", "}" ]
should join , part and quit messages be displayed ?
train
false
201
public void reset(){ lastMtd=null; map.clear(); loadCnt.set(0); putCnt.set(0); putAllCnt.set(0); ts=System.currentTimeMillis(); txs.clear(); }
[ "public", "void", "reset", "(", ")", "{", "lastMtd", "=", "null", ";", "map", ".", "clear", "(", ")", ";", "loadCnt", ".", "set", "(", "0", ")", ";", "putCnt", ".", "set", "(", "0", ")", ";", "putAllCnt", ".", "set", "(", "0", ")", ";", "ts", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "txs", ".", "clear", "(", ")", ";", "}" ]
resets the store to initial state .
train
false
202
public static Configuration load(InputStream stream) throws IOException { try { Properties properties=new Properties(); properties.load(stream); return from(properties); } finally { stream.close(); } }
[ "public", "static", "Configuration", "load", "(", "InputStream", "stream", ")", "throws", "IOException", "{", "try", "{", "Properties", "properties", "=", "new", "Properties", "(", ")", ";", "properties", ".", "load", "(", "stream", ")", ";", "return", "from", "(", "properties", ")", ";", "}", "finally", "{", "stream", ".", "close", "(", ")", ";", "}", "}" ]
obtain a configuration instance by loading the properties from the supplied stream .
train
false
203
private static String encode_base64(final byte d[],final int len) throws IllegalArgumentException { int off=0; final StringBuffer rs=new StringBuffer(); int c1, c2; if (len <= 0 || len > d.length) { throw new IllegalArgumentException("Invalid len"); } while (off < len) { c1=d[off++] & 0xff; rs.append(base64_code[c1 >> 2 & 0x3f]); c1=(c1 & 0x03) << 4; if (off >= len) { rs.append(base64_code[c1 & 0x3f]); break; } c2=d[off++] & 0xff; c1|=c2 >> 4 & 0x0f; rs.append(base64_code[c1 & 0x3f]); c1=(c2 & 0x0f) << 2; if (off >= len) { rs.append(base64_code[c1 & 0x3f]); break; } c2=d[off++] & 0xff; c1|=c2 >> 6 & 0x03; rs.append(base64_code[c1 & 0x3f]); rs.append(base64_code[c2 & 0x3f]); } return rs.toString(); }
[ "private", "static", "String", "encode_base64", "(", "final", "byte", "d", "[", "]", ",", "final", "int", "len", ")", "throws", "IllegalArgumentException", "{", "int", "off", "=", "0", ";", "final", "StringBuffer", "rs", "=", "new", "StringBuffer", "(", ")", ";", "int", "c1", ",", "c2", ";", "if", "(", "len", "<=", "0", "||", "len", ">", "d", ".", "length", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Invalid len\"", ")", ";", "}", "while", "(", "off", "<", "len", ")", "{", "c1", "=", "d", "[", "off", "++", "]", "&", "0xff", ";", "rs", ".", "append", "(", "base64_code", "[", "c1", ">", ">", "2", "&", "0x3f", "]", ")", ";", "c1", "=", "(", "c1", "&", "0x03", ")", "<<", "4", ";", "if", "(", "off", ">=", "len", ")", "{", "rs", ".", "append", "(", "base64_code", "[", "c1", "&", "0x3f", "]", ")", ";", "break", ";", "}", "c2", "=", "d", "[", "off", "++", "]", "&", "0xff", ";", "c1", "|=", "c2", ">", ">", "4", "&", "0x0f", ";", "rs", ".", "append", "(", "base64_code", "[", "c1", "&", "0x3f", "]", ")", ";", "c1", "=", "(", "c2", "&", "0x0f", ")", "<<", "2", ";", "if", "(", "off", ">=", "len", ")", "{", "rs", ".", "append", "(", "base64_code", "[", "c1", "&", "0x3f", "]", ")", ";", "break", ";", "}", "c2", "=", "d", "[", "off", "++", "]", "&", "0xff", ";", "c1", "|=", "c2", ">", ">", "6", "&", "0x03", ";", "rs", ".", "append", "(", "base64_code", "[", "c1", "&", "0x3f", "]", ")", ";", "rs", ".", "append", "(", "base64_code", "[", "c2", "&", "0x3f", "]", ")", ";", "}", "return", "rs", ".", "toString", "(", ")", ";", "}" ]
encode a byte array using bcrypt ' s slightly - modified base64 encoding scheme . note that this is * not * compatible with the standard mime - base64 encoding .
train
true
205
public JSONException(Throwable cause){ super(cause.getMessage()); this.cause=cause; }
[ "public", "JSONException", "(", "Throwable", "cause", ")", "{", "super", "(", "cause", ".", "getMessage", "(", ")", ")", ";", "this", ".", "cause", "=", "cause", ";", "}" ]
constructs a new jsonexception with the specified cause .
train
false
206
public static PcRunner serializableInstance(){ return PcRunner.serializableInstance(); }
[ "public", "static", "PcRunner", "serializableInstance", "(", ")", "{", "return", "PcRunner", ".", "serializableInstance", "(", ")", ";", "}" ]
generates a simple exemplar of this class to test serialization .
train
false
207
public void drawFigure(Graphics2D g){ AffineTransform savedTransform=null; if (get(TRANSFORM) != null) { savedTransform=g.getTransform(); g.transform(get(TRANSFORM)); } Paint paint=SVGAttributeKeys.getFillPaint(this); if (paint != null) { g.setPaint(paint); drawFill(g); } paint=SVGAttributeKeys.getStrokePaint(this); if (paint != null && get(STROKE_WIDTH) > 0) { g.setPaint(paint); g.setStroke(SVGAttributeKeys.getStroke(this)); drawStroke(g); } if (get(TRANSFORM) != null) { g.setTransform(savedTransform); } }
[ "public", "void", "drawFigure", "(", "Graphics2D", "g", ")", "{", "AffineTransform", "savedTransform", "=", "null", ";", "if", "(", "get", "(", "TRANSFORM", ")", "!=", "null", ")", "{", "savedTransform", "=", "g", ".", "getTransform", "(", ")", ";", "g", ".", "transform", "(", "get", "(", "TRANSFORM", ")", ")", ";", "}", "Paint", "paint", "=", "SVGAttributeKeys", ".", "getFillPaint", "(", "this", ")", ";", "if", "(", "paint", "!=", "null", ")", "{", "g", ".", "setPaint", "(", "paint", ")", ";", "drawFill", "(", "g", ")", ";", "}", "paint", "=", "SVGAttributeKeys", ".", "getStrokePaint", "(", "this", ")", ";", "if", "(", "paint", "!=", "null", "&&", "get", "(", "STROKE_WIDTH", ")", ">", "0", ")", "{", "g", ".", "setPaint", "(", "paint", ")", ";", "g", ".", "setStroke", "(", "SVGAttributeKeys", ".", "getStroke", "(", "this", ")", ")", ";", "drawStroke", "(", "g", ")", ";", "}", "if", "(", "get", "(", "TRANSFORM", ")", "!=", "null", ")", "{", "g", ".", "setTransform", "(", "savedTransform", ")", ";", "}", "}" ]
this method is invoked before the rendered image of the figure is composited .
train
false
208
protected Object[] parseArguments(final byte[] theBytes){ Object[] myArguments=new Object[0]; int myTagIndex=0; int myIndex=0; myArguments=new Object[_myTypetag.length]; isArray=(_myTypetag.length > 0) ? true : false; while (myTagIndex < _myTypetag.length) { if (myTagIndex == 0) { _myArrayType=_myTypetag[myTagIndex]; } else { if (_myTypetag[myTagIndex] != _myArrayType) { isArray=false; } } switch (_myTypetag[myTagIndex]) { case (0x63): myArguments[myTagIndex]=(new Character((char)(Bytes.toInt(Bytes.copy(theBytes,myIndex,4))))); myIndex+=4; break; case (0x69): myArguments[myTagIndex]=(new Integer(Bytes.toInt(Bytes.copy(theBytes,myIndex,4)))); myIndex+=4; break; case (0x66): myArguments[myTagIndex]=(new Float(Bytes.toFloat(Bytes.copy(theBytes,myIndex,4)))); myIndex+=4; break; case (0x6c): case (0x68): myArguments[myTagIndex]=(new Long(Bytes.toLong(Bytes.copy(theBytes,myIndex,8)))); myIndex+=8; break; case (0x64): myArguments[myTagIndex]=(new Double(Bytes.toDouble(Bytes.copy(theBytes,myIndex,8)))); myIndex+=8; break; case (0x53): case (0x73): int newIndex=myIndex; StringBuffer stringBuffer=new StringBuffer(); stringLoop: do { if (theBytes[newIndex] == 0x00) { break stringLoop; } else { stringBuffer.append((char)theBytes[newIndex]); } newIndex++; } while (newIndex < theBytes.length); myArguments[myTagIndex]=(stringBuffer.toString()); myIndex=newIndex + align(newIndex); break; case 0x62: int myLen=Bytes.toInt(Bytes.copy(theBytes,myIndex,4)); myIndex+=4; myArguments[myTagIndex]=Bytes.copy(theBytes,myIndex,myLen); myIndex+=myLen + (align(myLen) % 4); break; case 0x6d: myArguments[myTagIndex]=Bytes.copy(theBytes,myIndex,4); myIndex+=4; break; } myTagIndex++; } _myData=Bytes.copy(_myData,0,myIndex); return myArguments; }
[ "protected", "Object", "[", "]", "parseArguments", "(", "final", "byte", "[", "]", "theBytes", ")", "{", "Object", "[", "]", "myArguments", "=", "new", "Object", "[", "0", "]", ";", "int", "myTagIndex", "=", "0", ";", "int", "myIndex", "=", "0", ";", "myArguments", "=", "new", "Object", "[", "_myTypetag", ".", "length", "]", ";", "isArray", "=", "(", "_myTypetag", ".", "length", ">", "0", ")", "?", "true", ":", "false", ";", "while", "(", "myTagIndex", "<", "_myTypetag", ".", "length", ")", "{", "if", "(", "myTagIndex", "==", "0", ")", "{", "_myArrayType", "=", "_myTypetag", "[", "myTagIndex", "]", ";", "}", "else", "{", "if", "(", "_myTypetag", "[", "myTagIndex", "]", "!=", "_myArrayType", ")", "{", "isArray", "=", "false", ";", "}", "}", "switch", "(", "_myTypetag", "[", "myTagIndex", "]", ")", "{", "case", "(", "0x63", ")", ":", "myArguments", "[", "myTagIndex", "]", "=", "(", "new", "Character", "(", "(", "char", ")", "(", "Bytes", ".", "toInt", "(", "Bytes", ".", "copy", "(", "theBytes", ",", "myIndex", ",", "4", ")", ")", ")", ")", ")", ";", "myIndex", "+=", "4", ";", "break", ";", "case", "(", "0x69", ")", ":", "myArguments", "[", "myTagIndex", "]", "=", "(", "new", "Integer", "(", "Bytes", ".", "toInt", "(", "Bytes", ".", "copy", "(", "theBytes", ",", "myIndex", ",", "4", ")", ")", ")", ")", ";", "myIndex", "+=", "4", ";", "break", ";", "case", "(", "0x66", ")", ":", "myArguments", "[", "myTagIndex", "]", "=", "(", "new", "Float", "(", "Bytes", ".", "toFloat", "(", "Bytes", ".", "copy", "(", "theBytes", ",", "myIndex", ",", "4", ")", ")", ")", ")", ";", "myIndex", "+=", "4", ";", "break", ";", "case", "(", "0x6c", ")", ":", "case", "(", "0x68", ")", ":", "myArguments", "[", "myTagIndex", "]", "=", "(", "new", "Long", "(", "Bytes", ".", "toLong", "(", "Bytes", ".", "copy", "(", "theBytes", ",", "myIndex", ",", "8", ")", ")", ")", ")", ";", "myIndex", "+=", "8", ";", "break", ";", "case", "(", "0x64", ")", ":", "myArguments", "[", "myTagIndex", "]", "=", "(", "new", "Double", "(", "Bytes", ".", "toDouble", "(", "Bytes", ".", "copy", "(", "theBytes", ",", "myIndex", ",", "8", ")", ")", ")", ")", ";", "myIndex", "+=", "8", ";", "break", ";", "case", "(", "0x53", ")", ":", "case", "(", "0x73", ")", ":", "int", "newIndex", "=", "myIndex", ";", "StringBuffer", "stringBuffer", "=", "new", "StringBuffer", "(", ")", ";", "stringLoop", ":", "do", "{", "if", "(", "theBytes", "[", "newIndex", "]", "==", "0x00", ")", "{", "break", "stringLoop", ";", "}", "else", "{", "stringBuffer", ".", "append", "(", "(", "char", ")", "theBytes", "[", "newIndex", "]", ")", ";", "}", "newIndex", "++", ";", "}", "while", "(", "newIndex", "<", "theBytes", ".", "length", ")", ";", "myArguments", "[", "myTagIndex", "]", "=", "(", "stringBuffer", ".", "toString", "(", ")", ")", ";", "myIndex", "=", "newIndex", "+", "align", "(", "newIndex", ")", ";", "break", ";", "case", "0x62", ":", "int", "myLen", "=", "Bytes", ".", "toInt", "(", "Bytes", ".", "copy", "(", "theBytes", ",", "myIndex", ",", "4", ")", ")", ";", "myIndex", "+=", "4", ";", "myArguments", "[", "myTagIndex", "]", "=", "Bytes", ".", "copy", "(", "theBytes", ",", "myIndex", ",", "myLen", ")", ";", "myIndex", "+=", "myLen", "+", "(", "align", "(", "myLen", ")", "%", "4", ")", ";", "break", ";", "case", "0x6d", ":", "myArguments", "[", "myTagIndex", "]", "=", "Bytes", ".", "copy", "(", "theBytes", ",", "myIndex", ",", "4", ")", ";", "myIndex", "+=", "4", ";", "break", ";", "}", "myTagIndex", "++", ";", "}", "_myData", "=", "Bytes", ".", "copy", "(", "_myData", ",", "0", ",", "myIndex", ")", ";", "return", "myArguments", ";", "}" ]
cast the arguments passed with the incoming osc message and store them in an object array .
train
false
209
private boolean hasNextPostponed(){ return !postponedRoutes.isEmpty(); }
[ "private", "boolean", "hasNextPostponed", "(", ")", "{", "return", "!", "postponedRoutes", ".", "isEmpty", "(", ")", ";", "}" ]
returns true if there is another postponed route to try .
train
false
210
public static String decodeAttributeCode(String attributeCode){ return attributeCode.startsWith("+") ? attributeCode.substring(1) : attributeCode; }
[ "public", "static", "String", "decodeAttributeCode", "(", "String", "attributeCode", ")", "{", "return", "attributeCode", ".", "startsWith", "(", "\"+\"", ")", "?", "attributeCode", ".", "substring", "(", "1", ")", ":", "attributeCode", ";", "}" ]
remove dynamic attribute marker ( + ) from attribute code ( if exists )
train
false
211
public boolean toBoolean(Element el,String attributeName){ return Caster.toBooleanValue(el.getAttribute(attributeName),false); }
[ "public", "boolean", "toBoolean", "(", "Element", "el", ",", "String", "attributeName", ")", "{", "return", "Caster", ".", "toBooleanValue", "(", "el", ".", "getAttribute", "(", "attributeName", ")", ",", "false", ")", ";", "}" ]
reads a xml element attribute ans cast it to a boolean value
train
true
213
void saveToStream(DataOutputStream out) throws IOException { out.writeUTF(mUrl); out.writeUTF(mName); out.writeUTF(mValue); out.writeUTF(mDomain); out.writeUTF(mPath); out.writeLong(mCreation); out.writeLong(mExpiration); out.writeLong(mLastAccess); out.writeBoolean(mSecure); out.writeBoolean(mHttpOnly); out.writeBoolean(mFirstPartyOnly); out.writeInt(mPriority); }
[ "void", "saveToStream", "(", "DataOutputStream", "out", ")", "throws", "IOException", "{", "out", ".", "writeUTF", "(", "mUrl", ")", ";", "out", ".", "writeUTF", "(", "mName", ")", ";", "out", ".", "writeUTF", "(", "mValue", ")", ";", "out", ".", "writeUTF", "(", "mDomain", ")", ";", "out", ".", "writeUTF", "(", "mPath", ")", ";", "out", ".", "writeLong", "(", "mCreation", ")", ";", "out", ".", "writeLong", "(", "mExpiration", ")", ";", "out", ".", "writeLong", "(", "mLastAccess", ")", ";", "out", ".", "writeBoolean", "(", "mSecure", ")", ";", "out", ".", "writeBoolean", "(", "mHttpOnly", ")", ";", "out", ".", "writeBoolean", "(", "mFirstPartyOnly", ")", ";", "out", ".", "writeInt", "(", "mPriority", ")", ";", "}" ]
serializes for saving to disk . does not close the stream . it is up to the caller to do so .
train
false
214
public boolean delete(File f){ if (f.isDirectory()) { for ( File child : f.listFiles()) { if (!delete(child)) { return (false); } } } boolean result=f.delete(); MediaScannerConnection.scanFile(this,new String[]{f.getAbsolutePath()},null,null); return (result); }
[ "public", "boolean", "delete", "(", "File", "f", ")", "{", "if", "(", "f", ".", "isDirectory", "(", ")", ")", "{", "for", "(", "File", "child", ":", "f", ".", "listFiles", "(", ")", ")", "{", "if", "(", "!", "delete", "(", "child", ")", ")", "{", "return", "(", "false", ")", ";", "}", "}", "}", "boolean", "result", "=", "f", ".", "delete", "(", ")", ";", "MediaScannerConnection", ".", "scanFile", "(", "this", ",", "new", "String", "[", "]", "{", "f", ".", "getAbsolutePath", "(", ")", "}", ",", "null", ",", "null", ")", ";", "return", "(", "result", ")", ";", "}" ]
recursively deletes a directory and its contents .
train
false
215
public static void replaceHttpHeaderMapNodeSpecific(Map<String,String> httpHeaderMap,Map<String,String> requestParameters){ boolean needToReplaceVarInHttpHeader=false; for ( String parameter : requestParameters.keySet()) { if (parameter.contains(PcConstants.NODE_REQUEST_PREFIX_REPLACE_VAR)) { needToReplaceVarInHttpHeader=true; break; } } if (!needToReplaceVarInHttpHeader) { logger.debug("No need to replace. Since there are no HTTP header variables. "); return; } for ( Entry<String,String> entry : httpHeaderMap.entrySet()) { String key=entry.getKey(); String valueOriginal=entry.getValue(); String valueUpdated=NodeReqResponse.replaceStrByMap(requestParameters,valueOriginal); httpHeaderMap.put(key,valueUpdated); } }
[ "public", "static", "void", "replaceHttpHeaderMapNodeSpecific", "(", "Map", "<", "String", ",", "String", ">", "httpHeaderMap", ",", "Map", "<", "String", ",", "String", ">", "requestParameters", ")", "{", "boolean", "needToReplaceVarInHttpHeader", "=", "false", ";", "for", "(", "String", "parameter", ":", "requestParameters", ".", "keySet", "(", ")", ")", "{", "if", "(", "parameter", ".", "contains", "(", "PcConstants", ".", "NODE_REQUEST_PREFIX_REPLACE_VAR", ")", ")", "{", "needToReplaceVarInHttpHeader", "=", "true", ";", "break", ";", "}", "}", "if", "(", "!", "needToReplaceVarInHttpHeader", ")", "{", "logger", ".", "debug", "(", "\"No need to replace. Since there are no HTTP header variables. \"", ")", ";", "return", ";", "}", "for", "(", "Entry", "<", "String", ",", "String", ">", "entry", ":", "httpHeaderMap", ".", "entrySet", "(", ")", ")", "{", "String", "key", "=", "entry", ".", "getKey", "(", ")", ";", "String", "valueOriginal", "=", "entry", ".", "getValue", "(", ")", ";", "String", "valueUpdated", "=", "NodeReqResponse", ".", "replaceStrByMap", "(", "requestParameters", ",", "valueOriginal", ")", ";", "httpHeaderMap", ".", "put", "(", "key", ",", "valueUpdated", ")", ";", "}", "}" ]
! ! ! ! assumption : all var exists in http header must of type : apivarreplace_name_prefix_http_header 20140310 this may be costly ( o ( n ^ 2 ) ) of the updated related # of headers ; # of parameters in the requests . better to only do it when there are some replacement in the request parameters . a prefix : tobe tested
train
true
216
private void mapPut(Map map,String name,Object preference) throws IOException { isEmpty=false; if ((name.length() == 0) || (name == null)) { throw new IOException("no name specified in preference" + " expression"); } if (map.put(name,preference) != null) { throw new IOException("duplicate map entry: " + name); } }
[ "private", "void", "mapPut", "(", "Map", "map", ",", "String", "name", ",", "Object", "preference", ")", "throws", "IOException", "{", "isEmpty", "=", "false", ";", "if", "(", "(", "name", ".", "length", "(", ")", "==", "0", ")", "||", "(", "name", "==", "null", ")", ")", "{", "throw", "new", "IOException", "(", "\"no name specified in preference\"", "+", "\" expression\"", ")", ";", "}", "if", "(", "map", ".", "put", "(", "name", ",", "preference", ")", "!=", "null", ")", "{", "throw", "new", "IOException", "(", "\"duplicate map entry: \"", "+", "name", ")", ";", "}", "}" ]
insert a preference expression and value into a given map .
train
false
217
public Builder withTags(Map<String,String> tags){ this.tags=Collections.unmodifiableMap(tags); return this; }
[ "public", "Builder", "withTags", "(", "Map", "<", "String", ",", "String", ">", "tags", ")", "{", "this", ".", "tags", "=", "Collections", ".", "unmodifiableMap", "(", "tags", ")", ";", "return", "this", ";", "}" ]
add these tags to all metrics .
train
false
219
@Override public Object[] toArray(){ final ArrayList<Object> out=new ArrayList<Object>(); final Iterator<IGPO> gpos=iterator(); while (gpos.hasNext()) { out.add(gpos.next()); } return out.toArray(); }
[ "@", "Override", "public", "Object", "[", "]", "toArray", "(", ")", "{", "final", "ArrayList", "<", "Object", ">", "out", "=", "new", "ArrayList", "<", "Object", ">", "(", ")", ";", "final", "Iterator", "<", "IGPO", ">", "gpos", "=", "iterator", "(", ")", ";", "while", "(", "gpos", ".", "hasNext", "(", ")", ")", "{", "out", ".", "add", "(", "gpos", ".", "next", "(", ")", ")", ";", "}", "return", "out", ".", "toArray", "(", ")", ";", "}" ]
eagerly streams materialized objects into an array
train
false
220
public static Angle rhumbAzimuth(LatLon p1,LatLon p2){ if (p1 == null || p2 == null) { throw new IllegalArgumentException("LatLon Is Null"); } double lat1=p1.getLatitude().radians; double lon1=p1.getLongitude().radians; double lat2=p2.getLatitude().radians; double lon2=p2.getLongitude().radians; if (lat1 == lat2 && lon1 == lon2) return Angle.ZERO; double dLon=lon2 - lon1; double dPhi=Math.log(Math.tan(lat2 / 2.0 + Math.PI / 4.0) / Math.tan(lat1 / 2.0 + Math.PI / 4.0)); if (Math.abs(dLon) > Math.PI) { dLon=dLon > 0 ? -(2 * Math.PI - dLon) : (2 * Math.PI + dLon); } double azimuthRadians=Math.atan2(dLon,dPhi); return Double.isNaN(azimuthRadians) ? Angle.ZERO : Angle.fromRadians(azimuthRadians); }
[ "public", "static", "Angle", "rhumbAzimuth", "(", "LatLon", "p1", ",", "LatLon", "p2", ")", "{", "if", "(", "p1", "==", "null", "||", "p2", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"LatLon Is Null\"", ")", ";", "}", "double", "lat1", "=", "p1", ".", "getLatitude", "(", ")", ".", "radians", ";", "double", "lon1", "=", "p1", ".", "getLongitude", "(", ")", ".", "radians", ";", "double", "lat2", "=", "p2", ".", "getLatitude", "(", ")", ".", "radians", ";", "double", "lon2", "=", "p2", ".", "getLongitude", "(", ")", ".", "radians", ";", "if", "(", "lat1", "==", "lat2", "&&", "lon1", "==", "lon2", ")", "return", "Angle", ".", "ZERO", ";", "double", "dLon", "=", "lon2", "-", "lon1", ";", "double", "dPhi", "=", "Math", ".", "log", "(", "Math", ".", "tan", "(", "lat2", "/", "2.0", "+", "Math", ".", "PI", "/", "4.0", ")", "/", "Math", ".", "tan", "(", "lat1", "/", "2.0", "+", "Math", ".", "PI", "/", "4.0", ")", ")", ";", "if", "(", "Math", ".", "abs", "(", "dLon", ")", ">", "Math", ".", "PI", ")", "{", "dLon", "=", "dLon", ">", "0", "?", "-", "(", "2", "*", "Math", ".", "PI", "-", "dLon", ")", ":", "(", "2", "*", "Math", ".", "PI", "+", "dLon", ")", ";", "}", "double", "azimuthRadians", "=", "Math", ".", "atan2", "(", "dLon", ",", "dPhi", ")", ";", "return", "Double", ".", "isNaN", "(", "azimuthRadians", ")", "?", "Angle", ".", "ZERO", ":", "Angle", ".", "fromRadians", "(", "azimuthRadians", ")", ";", "}" ]
computes the azimuth angle ( clockwise from north ) of a rhumb line ( a line of constant heading ) between two locations .
train
false
221
public void takeColumnFamilySnapshot(String keyspaceName,String columnFamilyName,String tag) throws IOException { if (keyspaceName == null) throw new IOException("You must supply a keyspace name"); if (operationMode == Mode.JOINING) throw new IOException("Cannot snapshot until bootstrap completes"); if (columnFamilyName == null) throw new IOException("You must supply a table name"); if (columnFamilyName.contains(".")) throw new IllegalArgumentException("Cannot take a snapshot of a secondary index by itself. Run snapshot on the table that owns the index."); if (tag == null || tag.equals("")) throw new IOException("You must supply a snapshot name."); Keyspace keyspace=getValidKeyspace(keyspaceName); ColumnFamilyStore columnFamilyStore=keyspace.getColumnFamilyStore(columnFamilyName); if (columnFamilyStore.snapshotExists(tag)) throw new IOException("Snapshot " + tag + " already exists."); columnFamilyStore.snapshot(tag); }
[ "public", "void", "takeColumnFamilySnapshot", "(", "String", "keyspaceName", ",", "String", "columnFamilyName", ",", "String", "tag", ")", "throws", "IOException", "{", "if", "(", "keyspaceName", "==", "null", ")", "throw", "new", "IOException", "(", "\"You must supply a keyspace name\"", ")", ";", "if", "(", "operationMode", "==", "Mode", ".", "JOINING", ")", "throw", "new", "IOException", "(", "\"Cannot snapshot until bootstrap completes\"", ")", ";", "if", "(", "columnFamilyName", "==", "null", ")", "throw", "new", "IOException", "(", "\"You must supply a table name\"", ")", ";", "if", "(", "columnFamilyName", ".", "contains", "(", "\".\"", ")", ")", "throw", "new", "IllegalArgumentException", "(", "\"Cannot take a snapshot of a secondary index by itself. Run snapshot on the table that owns the index.\"", ")", ";", "if", "(", "tag", "==", "null", "||", "tag", ".", "equals", "(", "\"\"", ")", ")", "throw", "new", "IOException", "(", "\"You must supply a snapshot name.\"", ")", ";", "Keyspace", "keyspace", "=", "getValidKeyspace", "(", "keyspaceName", ")", ";", "ColumnFamilyStore", "columnFamilyStore", "=", "keyspace", ".", "getColumnFamilyStore", "(", "columnFamilyName", ")", ";", "if", "(", "columnFamilyStore", ".", "snapshotExists", "(", "tag", ")", ")", "throw", "new", "IOException", "(", "\"Snapshot \"", "+", "tag", "+", "\" already exists.\"", ")", ";", "columnFamilyStore", ".", "snapshot", "(", "tag", ")", ";", "}" ]
takes the snapshot of a specific column family . a snapshot name must be specified .
train
false
225
@SuppressWarnings("unchecked") private void applyToGroupAndSubGroups(final AST2BOpContext context,final QueryRoot queryRoot,final QueryHintScope scope,final GraphPatternGroup<IGroupMemberNode> group,final String name,final String value){ for ( IGroupMemberNode child : group) { _applyQueryHint(context,queryRoot,scope,(ASTBase)child,name,value); if (child instanceof GraphPatternGroup<?>) { applyToGroupAndSubGroups(context,queryRoot,scope,(GraphPatternGroup<IGroupMemberNode>)child,name,value); } } _applyQueryHint(context,queryRoot,scope,(ASTBase)group,name,value); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "void", "applyToGroupAndSubGroups", "(", "final", "AST2BOpContext", "context", ",", "final", "QueryRoot", "queryRoot", ",", "final", "QueryHintScope", "scope", ",", "final", "GraphPatternGroup", "<", "IGroupMemberNode", ">", "group", ",", "final", "String", "name", ",", "final", "String", "value", ")", "{", "for", "(", "IGroupMemberNode", "child", ":", "group", ")", "{", "_applyQueryHint", "(", "context", ",", "queryRoot", ",", "scope", ",", "(", "ASTBase", ")", "child", ",", "name", ",", "value", ")", ";", "if", "(", "child", "instanceof", "GraphPatternGroup", "<", "?", ">", ")", "{", "applyToGroupAndSubGroups", "(", "context", ",", "queryRoot", ",", "scope", ",", "(", "GraphPatternGroup", "<", "IGroupMemberNode", ">", ")", "child", ",", "name", ",", "value", ")", ";", "}", "}", "_applyQueryHint", "(", "context", ",", "queryRoot", ",", "scope", ",", "(", "ASTBase", ")", "group", ",", "name", ",", "value", ")", ";", "}" ]
apply the query hint to the group and , recursively , to any sub - groups .
train
false
227
public static int readInt(final JSONObject jsonObject,final String key,final boolean required,final boolean notNull) throws JSONException { if (required) { return jsonObject.getInt(key); } if (notNull && jsonObject.isNull(key)) { throw new JSONException(String.format(Locale.US,NULL_VALUE_FORMAT_OBJECT,key)); } int value=0; if (!jsonObject.isNull(key)) { value=jsonObject.getInt(key); } return value; }
[ "public", "static", "int", "readInt", "(", "final", "JSONObject", "jsonObject", ",", "final", "String", "key", ",", "final", "boolean", "required", ",", "final", "boolean", "notNull", ")", "throws", "JSONException", "{", "if", "(", "required", ")", "{", "return", "jsonObject", ".", "getInt", "(", "key", ")", ";", "}", "if", "(", "notNull", "&&", "jsonObject", ".", "isNull", "(", "key", ")", ")", "{", "throw", "new", "JSONException", "(", "String", ".", "format", "(", "Locale", ".", "US", ",", "NULL_VALUE_FORMAT_OBJECT", ",", "key", ")", ")", ";", "}", "int", "value", "=", "0", ";", "if", "(", "!", "jsonObject", ".", "isNull", "(", "key", ")", ")", "{", "value", "=", "jsonObject", ".", "getInt", "(", "key", ")", ";", "}", "return", "value", ";", "}" ]
reads the int value from the json object for specified tag .
train
false
228
public TimeTableXYDataset(){ this(TimeZone.getDefault(),Locale.getDefault()); }
[ "public", "TimeTableXYDataset", "(", ")", "{", "this", "(", "TimeZone", ".", "getDefault", "(", ")", ",", "Locale", ".", "getDefault", "(", ")", ")", ";", "}" ]
creates a new dataset .
train
false
230
public void removeTmpStore(IMXStore store){ if (null != store) { mTmpStores.remove(store); } }
[ "public", "void", "removeTmpStore", "(", "IMXStore", "store", ")", "{", "if", "(", "null", "!=", "store", ")", "{", "mTmpStores", ".", "remove", "(", "store", ")", ";", "}", "}" ]
remove the dedicated store from the tmp stores list .
train
false
231
public static List<AnnotationDto> transformToDto(List<Annotation> annotations){ if (annotations == null) { throw new WebApplicationException("Null entity object cannot be converted to Dto object.",Status.INTERNAL_SERVER_ERROR); } List<AnnotationDto> result=new ArrayList<>(); for ( Annotation annotation : annotations) { result.add(transformToDto(annotation)); } return result; }
[ "public", "static", "List", "<", "AnnotationDto", ">", "transformToDto", "(", "List", "<", "Annotation", ">", "annotations", ")", "{", "if", "(", "annotations", "==", "null", ")", "{", "throw", "new", "WebApplicationException", "(", "\"Null entity object cannot be converted to Dto object.\"", ",", "Status", ".", "INTERNAL_SERVER_ERROR", ")", ";", "}", "List", "<", "AnnotationDto", ">", "result", "=", "new", "ArrayList", "<", ">", "(", ")", ";", "for", "(", "Annotation", "annotation", ":", "annotations", ")", "{", "result", ".", "add", "(", "transformToDto", "(", "annotation", ")", ")", ";", "}", "return", "result", ";", "}" ]
converts list of alert entity objects to list of alertdto objects .
train
true
232
protected void enableButtons(){ m_M_Product_ID=-1; m_ProductName=null; m_Price=null; int row=m_table.getSelectedRow(); boolean enabled=row != -1; if (enabled) { Integer ID=m_table.getSelectedRowKey(); if (ID != null) { m_M_Product_ID=ID.intValue(); m_ProductName=(String)m_table.getValueAt(row,2); m_Price=(BigDecimal)m_table.getValueAt(row,7); } } f_ok.setEnabled(enabled); log.fine("M_Product_ID=" + m_M_Product_ID + " - "+ m_ProductName+ " - "+ m_Price); }
[ "protected", "void", "enableButtons", "(", ")", "{", "m_M_Product_ID", "=", "-", "1", ";", "m_ProductName", "=", "null", ";", "m_Price", "=", "null", ";", "int", "row", "=", "m_table", ".", "getSelectedRow", "(", ")", ";", "boolean", "enabled", "=", "row", "!=", "-", "1", ";", "if", "(", "enabled", ")", "{", "Integer", "ID", "=", "m_table", ".", "getSelectedRowKey", "(", ")", ";", "if", "(", "ID", "!=", "null", ")", "{", "m_M_Product_ID", "=", "ID", ".", "intValue", "(", ")", ";", "m_ProductName", "=", "(", "String", ")", "m_table", ".", "getValueAt", "(", "row", ",", "2", ")", ";", "m_Price", "=", "(", "BigDecimal", ")", "m_table", ".", "getValueAt", "(", "row", ",", "7", ")", ";", "}", "}", "f_ok", ".", "setEnabled", "(", "enabled", ")", ";", "log", ".", "fine", "(", "\"M_Product_ID=\"", "+", "m_M_Product_ID", "+", "\" - \"", "+", "m_ProductName", "+", "\" - \"", "+", "m_Price", ")", ";", "}" ]
enable / set buttons and set id
train
false
234
public static List<IAType> validatePartitioningExpressions(ARecordType recType,ARecordType metaRecType,List<List<String>> partitioningExprs,List<Integer> keySourceIndicators,boolean autogenerated) throws AsterixException { List<IAType> partitioningExprTypes=new ArrayList<IAType>(partitioningExprs.size()); if (autogenerated) { if (partitioningExprs.size() > 1) { throw new AsterixException("Cannot autogenerate a composite primary key"); } List<String> fieldName=partitioningExprs.get(0); IAType fieldType=recType.getSubFieldType(fieldName); partitioningExprTypes.add(fieldType); ATypeTag pkTypeTag=fieldType.getTypeTag(); if (pkTypeTag != ATypeTag.UUID) { throw new AsterixException("Cannot autogenerate a primary key for type " + pkTypeTag + ". Autogenerated primary keys must be of type "+ ATypeTag.UUID+ "."); } } else { partitioningExprTypes=KeyFieldTypeUtils.getKeyTypes(recType,metaRecType,partitioningExprs,keySourceIndicators); for (int fidx=0; fidx < partitioningExprTypes.size(); ++fidx) { IAType fieldType=partitioningExprTypes.get(fidx); if (fieldType == null) { throw new AsterixException("Type not found for partitioning key " + partitioningExprs.get(fidx)); } switch (fieldType.getTypeTag()) { case INT8: case INT16: case INT32: case INT64: case FLOAT: case DOUBLE: case STRING: case BINARY: case DATE: case TIME: case UUID: case DATETIME: case YEARMONTHDURATION: case DAYTIMEDURATION: break; case UNION: throw new AsterixException("The partitioning key " + partitioningExprs.get(fidx) + " cannot be nullable"); default : throw new AsterixException("The partitioning key " + partitioningExprs.get(fidx) + " cannot be of type "+ fieldType.getTypeTag()+ "."); } } } return partitioningExprTypes; }
[ "public", "static", "List", "<", "IAType", ">", "validatePartitioningExpressions", "(", "ARecordType", "recType", ",", "ARecordType", "metaRecType", ",", "List", "<", "List", "<", "String", ">", ">", "partitioningExprs", ",", "List", "<", "Integer", ">", "keySourceIndicators", ",", "boolean", "autogenerated", ")", "throws", "AsterixException", "{", "List", "<", "IAType", ">", "partitioningExprTypes", "=", "new", "ArrayList", "<", "IAType", ">", "(", "partitioningExprs", ".", "size", "(", ")", ")", ";", "if", "(", "autogenerated", ")", "{", "if", "(", "partitioningExprs", ".", "size", "(", ")", ">", "1", ")", "{", "throw", "new", "AsterixException", "(", "\"Cannot autogenerate a composite primary key\"", ")", ";", "}", "List", "<", "String", ">", "fieldName", "=", "partitioningExprs", ".", "get", "(", "0", ")", ";", "IAType", "fieldType", "=", "recType", ".", "getSubFieldType", "(", "fieldName", ")", ";", "partitioningExprTypes", ".", "add", "(", "fieldType", ")", ";", "ATypeTag", "pkTypeTag", "=", "fieldType", ".", "getTypeTag", "(", ")", ";", "if", "(", "pkTypeTag", "!=", "ATypeTag", ".", "UUID", ")", "{", "throw", "new", "AsterixException", "(", "\"Cannot autogenerate a primary key for type \"", "+", "pkTypeTag", "+", "\". Autogenerated primary keys must be of type \"", "+", "ATypeTag", ".", "UUID", "+", "\".\"", ")", ";", "}", "}", "else", "{", "partitioningExprTypes", "=", "KeyFieldTypeUtils", ".", "getKeyTypes", "(", "recType", ",", "metaRecType", ",", "partitioningExprs", ",", "keySourceIndicators", ")", ";", "for", "(", "int", "fidx", "=", "0", ";", "fidx", "<", "partitioningExprTypes", ".", "size", "(", ")", ";", "++", "fidx", ")", "{", "IAType", "fieldType", "=", "partitioningExprTypes", ".", "get", "(", "fidx", ")", ";", "if", "(", "fieldType", "==", "null", ")", "{", "throw", "new", "AsterixException", "(", "\"Type not found for partitioning key \"", "+", "partitioningExprs", ".", "get", "(", "fidx", ")", ")", ";", "}", "switch", "(", "fieldType", ".", "getTypeTag", "(", ")", ")", "{", "case", "INT8", ":", "case", "INT16", ":", "case", "INT32", ":", "case", "INT64", ":", "case", "FLOAT", ":", "case", "DOUBLE", ":", "case", "STRING", ":", "case", "BINARY", ":", "case", "DATE", ":", "case", "TIME", ":", "case", "UUID", ":", "case", "DATETIME", ":", "case", "YEARMONTHDURATION", ":", "case", "DAYTIMEDURATION", ":", "break", ";", "case", "UNION", ":", "throw", "new", "AsterixException", "(", "\"The partitioning key \"", "+", "partitioningExprs", ".", "get", "(", "fidx", ")", "+", "\" cannot be nullable\"", ")", ";", "default", ":", "throw", "new", "AsterixException", "(", "\"The partitioning key \"", "+", "partitioningExprs", ".", "get", "(", "fidx", ")", "+", "\" cannot be of type \"", "+", "fieldType", ".", "getTypeTag", "(", ")", "+", "\".\"", ")", ";", "}", "}", "}", "return", "partitioningExprTypes", ";", "}" ]
validates the partitioning expression that will be used to partition a dataset and returns expression type .
train
false
236
public void start(){ managedPorts.add(createPort()); fixNames(); ports.addObserver(observer,false); }
[ "public", "void", "start", "(", ")", "{", "managedPorts", ".", "add", "(", "createPort", "(", ")", ")", ";", "fixNames", "(", ")", ";", "ports", ".", "addObserver", "(", "observer", ",", "false", ")", ";", "}" ]
creates an initial port and starts to listen .
train
false
237
public HessianDebugOutputStream(OutputStream os,PrintWriter dbg){ _os=os; _state=new HessianDebugState(dbg); }
[ "public", "HessianDebugOutputStream", "(", "OutputStream", "os", ",", "PrintWriter", "dbg", ")", "{", "_os", "=", "os", ";", "_state", "=", "new", "HessianDebugState", "(", "dbg", ")", ";", "}" ]
creates an uninitialized hessian input stream .
train
false
238
public Configurator fromFile(File file){ if (!file.exists()) { throw new FileNotFoundException(file.getAbsolutePath() + " does not exist."); } return new Configurator(file.getAbsolutePath(),false); }
[ "public", "Configurator", "fromFile", "(", "File", "file", ")", "{", "if", "(", "!", "file", ".", "exists", "(", ")", ")", "{", "throw", "new", "FileNotFoundException", "(", "file", ".", "getAbsolutePath", "(", ")", "+", "\" does not exist.\"", ")", ";", "}", "return", "new", "Configurator", "(", "file", ".", "getAbsolutePath", "(", ")", ",", "false", ")", ";", "}" ]
use a file as the pdf source
train
false
239
public synchronized void insertText(String inputtype,String outputtype,String locale,String voice,String outputparams,String style,String effects,String inputtext,String outputtext) throws SQLException { if (inputtype == null || outputtype == null || locale == null || voice == null || inputtext == null || outputtext == null) { throw new NullPointerException("Null argument"); } if (lookupText(inputtype,outputtype,locale,voice,outputparams,style,effects,inputtext) != null) { return; } String query="INSERT INTO MARYCACHE (inputtype, outputtype, locale, voice, outputparams, style, effects, inputtext, outputtext) VALUES ('" + inputtype + "','"+ outputtype+ "','"+ locale+ "','"+ voice+ "','"+ outputparams+ "','"+ style+ "','"+ effects+ "',?,?)"; PreparedStatement st=connection.prepareStatement(query); st.setString(1,inputtext); st.setString(2,outputtext); st.executeUpdate(); st.close(); }
[ "public", "synchronized", "void", "insertText", "(", "String", "inputtype", ",", "String", "outputtype", ",", "String", "locale", ",", "String", "voice", ",", "String", "outputparams", ",", "String", "style", ",", "String", "effects", ",", "String", "inputtext", ",", "String", "outputtext", ")", "throws", "SQLException", "{", "if", "(", "inputtype", "==", "null", "||", "outputtype", "==", "null", "||", "locale", "==", "null", "||", "voice", "==", "null", "||", "inputtext", "==", "null", "||", "outputtext", "==", "null", ")", "{", "throw", "new", "NullPointerException", "(", "\"Null argument\"", ")", ";", "}", "if", "(", "lookupText", "(", "inputtype", ",", "outputtype", ",", "locale", ",", "voice", ",", "outputparams", ",", "style", ",", "effects", ",", "inputtext", ")", "!=", "null", ")", "{", "return", ";", "}", "String", "query", "=", "\"INSERT INTO MARYCACHE (inputtype, outputtype, locale, voice, outputparams, style, effects, inputtext, outputtext) VALUES ('\"", "+", "inputtype", "+", "\"','\"", "+", "outputtype", "+", "\"','\"", "+", "locale", "+", "\"','\"", "+", "voice", "+", "\"','\"", "+", "outputparams", "+", "\"','\"", "+", "style", "+", "\"','\"", "+", "effects", "+", "\"',?,?)\"", ";", "PreparedStatement", "st", "=", "connection", ".", "prepareStatement", "(", "query", ")", ";", "st", ".", "setString", "(", "1", ",", "inputtext", ")", ";", "st", ".", "setString", "(", "2", ",", "outputtext", ")", ";", "st", ".", "executeUpdate", "(", ")", ";", "st", ".", "close", "(", ")", ";", "}" ]
insert a record of a mary request producing data of type text into the cache . if a record with the same lookup keys ( i . e . , all parameters everything except outputtext ) exists already , this call does nothing .
train
false
240
public boolean isEmpty(){ return true; }
[ "public", "boolean", "isEmpty", "(", ")", "{", "return", "true", ";", "}" ]
methods that need to be implemented from generaltaskrunnable .
train
false
241
public static boolean isNumericOrPunctuationOrSymbols(String token){ int len=token.length(); for (int i=0; i < len; ++i) { char c=token.charAt(i); if (!(Character.isDigit(c) || Characters.isPunctuation(c) || Characters.isSymbol(c))) { return false; } } return true; }
[ "public", "static", "boolean", "isNumericOrPunctuationOrSymbols", "(", "String", "token", ")", "{", "int", "len", "=", "token", ".", "length", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "len", ";", "++", "i", ")", "{", "char", "c", "=", "token", ".", "charAt", "(", "i", ")", ";", "if", "(", "!", "(", "Character", ".", "isDigit", "(", "c", ")", "||", "Characters", ".", "isPunctuation", "(", "c", ")", "||", "Characters", ".", "isSymbol", "(", "c", ")", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
returns true if a string consists entirely of numbers , punctuation , and / or symbols .
train
false
242
@Deprecated public DCCppMessage(String s){ setBinary(false); setRetries(_nRetries); setTimeout(DCCppMessageTimeout); myMessage=new StringBuilder(s); _nDataChars=myMessage.length(); _dataChars=new int[_nDataChars]; }
[ "@", "Deprecated", "public", "DCCppMessage", "(", "String", "s", ")", "{", "setBinary", "(", "false", ")", ";", "setRetries", "(", "_nRetries", ")", ";", "setTimeout", "(", "DCCppMessageTimeout", ")", ";", "myMessage", "=", "new", "StringBuilder", "(", "s", ")", ";", "_nDataChars", "=", "myMessage", ".", "length", "(", ")", ";", "_dataChars", "=", "new", "int", "[", "_nDataChars", "]", ";", "}" ]
create a dccppmessage from a string containing bytes . since dccppmessages are text , there is no hex - to - byte conversion
train
false
243
@Override public void start() throws BaleenException { }
[ "@", "Override", "public", "void", "start", "(", ")", "throws", "BaleenException", "{", "}" ]
will not start controllers .
train
false
244
public ObjectInstance(ObjectName objectName,String className){ if (objectName.isPattern()) { final IllegalArgumentException iae=new IllegalArgumentException("Invalid name->" + objectName.toString()); throw new RuntimeOperationsException(iae); } this.name=objectName; this.className=className; }
[ "public", "ObjectInstance", "(", "ObjectName", "objectName", ",", "String", "className", ")", "{", "if", "(", "objectName", ".", "isPattern", "(", ")", ")", "{", "final", "IllegalArgumentException", "iae", "=", "new", "IllegalArgumentException", "(", "\"Invalid name->\"", "+", "objectName", ".", "toString", "(", ")", ")", ";", "throw", "new", "RuntimeOperationsException", "(", "iae", ")", ";", "}", "this", ".", "name", "=", "objectName", ";", "this", ".", "className", "=", "className", ";", "}" ]
allows an object instance to be created given an object name and the full class name , including the package name .
train
false
245
public static void flushEL(Writer w){ try { if (w != null) w.flush(); } catch ( Exception e) { } }
[ "public", "static", "void", "flushEL", "(", "Writer", "w", ")", "{", "try", "{", "if", "(", "w", "!=", "null", ")", "w", ".", "flush", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "}", "}" ]
flush outputstream without a exception
train
false
247
private void addGroupText(FormEntryCaption[] groups){ StringBuilder s=new StringBuilder(""); String t=""; int i; for ( FormEntryCaption g : groups) { i=g.getMultiplicity() + 1; t=g.getLongText(); if (t != null) { s.append(t); if (g.repeats() && i > 0) { s.append(" (" + i + ")"); } s.append(" > "); } } if (s.length() > 0) { TextView tv=new TextView(getContext()); tv.setText(s.substring(0,s.length() - 3)); int questionFontsize=Collect.getQuestionFontsize(); tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP,questionFontsize - 4); tv.setPadding(0,0,0,5); mView.addView(tv,mLayout); } }
[ "private", "void", "addGroupText", "(", "FormEntryCaption", "[", "]", "groups", ")", "{", "StringBuilder", "s", "=", "new", "StringBuilder", "(", "\"\"", ")", ";", "String", "t", "=", "\"\"", ";", "int", "i", ";", "for", "(", "FormEntryCaption", "g", ":", "groups", ")", "{", "i", "=", "g", ".", "getMultiplicity", "(", ")", "+", "1", ";", "t", "=", "g", ".", "getLongText", "(", ")", ";", "if", "(", "t", "!=", "null", ")", "{", "s", ".", "append", "(", "t", ")", ";", "if", "(", "g", ".", "repeats", "(", ")", "&&", "i", ">", "0", ")", "{", "s", ".", "append", "(", "\" (\"", "+", "i", "+", "\")\"", ")", ";", "}", "s", ".", "append", "(", "\" > \"", ")", ";", "}", "}", "if", "(", "s", ".", "length", "(", ")", ">", "0", ")", "{", "TextView", "tv", "=", "new", "TextView", "(", "getContext", "(", ")", ")", ";", "tv", ".", "setText", "(", "s", ".", "substring", "(", "0", ",", "s", ".", "length", "(", ")", "-", "3", ")", ")", ";", "int", "questionFontsize", "=", "Collect", ".", "getQuestionFontsize", "(", ")", ";", "tv", ".", "setTextSize", "(", "TypedValue", ".", "COMPLEX_UNIT_DIP", ",", "questionFontsize", "-", "4", ")", ";", "tv", ".", "setPadding", "(", "0", ",", "0", ",", "0", ",", "5", ")", ";", "mView", ".", "addView", "(", "tv", ",", "mLayout", ")", ";", "}", "}" ]
/ / * add a textview containing the hierarchy of groups to which the question belongs . / /
train
false
248
public static Number plus(Number left,Character right){ return NumberNumberPlus.plus(left,Integer.valueOf(right)); }
[ "public", "static", "Number", "plus", "(", "Number", "left", ",", "Character", "right", ")", "{", "return", "NumberNumberPlus", ".", "plus", "(", "left", ",", "Integer", ".", "valueOf", "(", "right", ")", ")", ";", "}" ]
add a number and a character . the ordinal value of the character is used in the addition ( the ordinal value is the unicode value which for simple character sets is the ascii value ) .
train
true
249
public void addFlag(OptionID optionid){ parameters.add(new ParameterPair(optionid,Flag.SET)); }
[ "public", "void", "addFlag", "(", "OptionID", "optionid", ")", "{", "parameters", ".", "add", "(", "new", "ParameterPair", "(", "optionid", ",", "Flag", ".", "SET", ")", ")", ";", "}" ]
add a flag to the parameter list
train
true
250
public static ByteBuffer toBuffer(String spacedHex){ return ByteBuffer.wrap(toByteArray(spacedHex)); }
[ "public", "static", "ByteBuffer", "toBuffer", "(", "String", "spacedHex", ")", "{", "return", "ByteBuffer", ".", "wrap", "(", "toByteArray", "(", "spacedHex", ")", ")", ";", "}" ]
convert the spaced hex form of a string into a bytebuffer .
train
false
251
protected void print(char v) throws IOException { os.write(v); }
[ "protected", "void", "print", "(", "char", "v", ")", "throws", "IOException", "{", "os", ".", "write", "(", "v", ")", ";", "}" ]
prints a char to the stream .
train
false
253
public static boolean isRightTurn(Point p1,Point p2,Point p3){ if (p1.equals(p2) || p2.equals(p3)) { return false; } double val=(p2.x * p3.y + p1.x * p2.y + p3.x * p1.y) - (p2.x * p1.y + p3.x * p2.y + p1.x * p3.y); return val > 0; }
[ "public", "static", "boolean", "isRightTurn", "(", "Point", "p1", ",", "Point", "p2", ",", "Point", "p3", ")", "{", "if", "(", "p1", ".", "equals", "(", "p2", ")", "||", "p2", ".", "equals", "(", "p3", ")", ")", "{", "return", "false", ";", "}", "double", "val", "=", "(", "p2", ".", "x", "*", "p3", ".", "y", "+", "p1", ".", "x", "*", "p2", ".", "y", "+", "p3", ".", "x", "*", "p1", ".", "y", ")", "-", "(", "p2", ".", "x", "*", "p1", ".", "y", "+", "p3", ".", "x", "*", "p2", ".", "y", "+", "p1", ".", "x", "*", "p3", ".", "y", ")", ";", "return", "val", ">", "0", ";", "}" ]
returns true , if the three given points make a right turn .
train
false
255
public boolean isRefreshTokenExpired(){ return refreshTokenExpiresAt.before(new Date()); }
[ "public", "boolean", "isRefreshTokenExpired", "(", ")", "{", "return", "refreshTokenExpiresAt", ".", "before", "(", "new", "Date", "(", ")", ")", ";", "}" ]
checks if the time the refresh access token will be valid are over
train
false
257
public String toString(){ if (m_FilteredInstances == null) { return "RandomizableFilteredClassifier: No model built yet."; } String result="RandomizableFilteredClassifier using " + getClassifierSpec() + " on data filtered through "+ getFilterSpec()+ "\n\nFiltered Header\n"+ m_FilteredInstances.toString()+ "\n\nClassifier Model\n"+ m_Classifier.toString(); return result; }
[ "public", "String", "toString", "(", ")", "{", "if", "(", "m_FilteredInstances", "==", "null", ")", "{", "return", "\"RandomizableFilteredClassifier: No model built yet.\"", ";", "}", "String", "result", "=", "\"RandomizableFilteredClassifier using \"", "+", "getClassifierSpec", "(", ")", "+", "\" on data filtered through \"", "+", "getFilterSpec", "(", ")", "+", "\"\\n\\nFiltered Header\\n\"", "+", "m_FilteredInstances", ".", "toString", "(", ")", "+", "\"\\n\\nClassifier Model\\n\"", "+", "m_Classifier", ".", "toString", "(", ")", ";", "return", "result", ";", "}" ]
output a representation of this classifier
train
false