id_within_dataset
int64
0
69.7k
snippet
stringlengths
10
23k
tokens
sequencelengths
5
4.23k
nl
stringlengths
15
2.45k
split_within_dataset
stringclasses
1 value
is_duplicated
bool
2 classes
0
@Override public int runCommand(boolean mergeErrorIntoOutput,String... commands) throws IOException, InterruptedException { return runCommand(mergeErrorIntoOutput,new ArrayList<String>(Arrays.asList(commands))); }
[ "@", "Override", "public", "int", "runCommand", "(", "boolean", "mergeErrorIntoOutput", ",", "String", "...", "commands", ")", "throws", "IOException", ",", "InterruptedException", "{", "return", "runCommand", "(", "mergeErrorIntoOutput", ",", "new", "ArrayList", "<", "String", ">", "(", "Arrays", ".", "asList", "(", "commands", ")", ")", ")", ";", "}" ]
runs a command on the command line synchronously .
train
false
1
private int findPLV(int M_PriceList_ID){ Timestamp priceDate=null; String dateStr=Env.getContext(Env.getCtx(),p_WindowNo,"DateOrdered"); if (dateStr != null && dateStr.length() > 0) priceDate=Env.getContextAsDate(Env.getCtx(),p_WindowNo,"DateOrdered"); else { dateStr=Env.getContext(Env.getCtx(),p_WindowNo,"DateInvoiced"); if (dateStr != null && dateStr.length() > 0) priceDate=Env.getContextAsDate(Env.getCtx(),p_WindowNo,"DateInvoiced"); } if (priceDate == null) priceDate=new Timestamp(System.currentTimeMillis()); log.config("M_PriceList_ID=" + M_PriceList_ID + " - "+ priceDate); int retValue=0; String sql="SELECT plv.M_PriceList_Version_ID, plv.ValidFrom " + "FROM M_PriceList pl, M_PriceList_Version plv " + "WHERE pl.M_PriceList_ID=plv.M_PriceList_ID"+ " AND plv.IsActive='Y'"+ " AND pl.M_PriceList_ID=? "+ "ORDER BY plv.ValidFrom DESC"; try { PreparedStatement pstmt=DB.prepareStatement(sql,null); pstmt.setInt(1,M_PriceList_ID); ResultSet rs=pstmt.executeQuery(); while (rs.next() && retValue == 0) { Timestamp plDate=rs.getTimestamp(2); if (!priceDate.before(plDate)) retValue=rs.getInt(1); } rs.close(); pstmt.close(); } catch ( SQLException e) { log.log(Level.SEVERE,sql,e); } Env.setContext(Env.getCtx(),p_WindowNo,"M_PriceList_Version_ID",retValue); return retValue; }
[ "private", "int", "findPLV", "(", "int", "M_PriceList_ID", ")", "{", "Timestamp", "priceDate", "=", "null", ";", "String", "dateStr", "=", "Env", ".", "getContext", "(", "Env", ".", "getCtx", "(", ")", ",", "p_WindowNo", ",", "\"DateOrdered\"", ")", ";", "if", "(", "dateStr", "!=", "null", "&&", "dateStr", ".", "length", "(", ")", ">", "0", ")", "priceDate", "=", "Env", ".", "getContextAsDate", "(", "Env", ".", "getCtx", "(", ")", ",", "p_WindowNo", ",", "\"DateOrdered\"", ")", ";", "else", "{", "dateStr", "=", "Env", ".", "getContext", "(", "Env", ".", "getCtx", "(", ")", ",", "p_WindowNo", ",", "\"DateInvoiced\"", ")", ";", "if", "(", "dateStr", "!=", "null", "&&", "dateStr", ".", "length", "(", ")", ">", "0", ")", "priceDate", "=", "Env", ".", "getContextAsDate", "(", "Env", ".", "getCtx", "(", ")", ",", "p_WindowNo", ",", "\"DateInvoiced\"", ")", ";", "}", "if", "(", "priceDate", "==", "null", ")", "priceDate", "=", "new", "Timestamp", "(", "System", ".", "currentTimeMillis", "(", ")", ")", ";", "log", ".", "config", "(", "\"M_PriceList_ID=\"", "+", "M_PriceList_ID", "+", "\" - \"", "+", "priceDate", ")", ";", "int", "retValue", "=", "0", ";", "String", "sql", "=", "\"SELECT plv.M_PriceList_Version_ID, plv.ValidFrom \"", "+", "\"FROM M_PriceList pl, M_PriceList_Version plv \"", "+", "\"WHERE pl.M_PriceList_ID=plv.M_PriceList_ID\"", "+", "\" AND plv.IsActive='Y'\"", "+", "\" AND pl.M_PriceList_ID=? \"", "+", "\"ORDER BY plv.ValidFrom DESC\"", ";", "try", "{", "PreparedStatement", "pstmt", "=", "DB", ".", "prepareStatement", "(", "sql", ",", "null", ")", ";", "pstmt", ".", "setInt", "(", "1", ",", "M_PriceList_ID", ")", ";", "ResultSet", "rs", "=", "pstmt", ".", "executeQuery", "(", ")", ";", "while", "(", "rs", ".", "next", "(", ")", "&&", "retValue", "==", "0", ")", "{", "Timestamp", "plDate", "=", "rs", ".", "getTimestamp", "(", "2", ")", ";", "if", "(", "!", "priceDate", ".", "before", "(", "plDate", ")", ")", "retValue", "=", "rs", ".", "getInt", "(", "1", ")", ";", "}", "rs", ".", "close", "(", ")", ";", "pstmt", ".", "close", "(", ")", ";", "}", "catch", "(", "SQLException", "e", ")", "{", "log", ".", "log", "(", "Level", ".", "SEVERE", ",", "sql", ",", "e", ")", ";", "}", "Env", ".", "setContext", "(", "Env", ".", "getCtx", "(", ")", ",", "p_WindowNo", ",", "\"M_PriceList_Version_ID\"", ",", "retValue", ")", ";", "return", "retValue", ";", "}" ]
find price list version and update context
train
false
2
public static boolean memoryIsLow(){ return availableMemory() * 100 < RUNTIME.totalMemory() * 5; }
[ "public", "static", "boolean", "memoryIsLow", "(", ")", "{", "return", "availableMemory", "(", ")", "*", "100", "<", "RUNTIME", ".", "totalMemory", "(", ")", "*", "5", ";", "}" ]
returns true if less then 5 % of the available memory is free .
train
false
3
public String describeAttributes(){ StringBuilder sb=new StringBuilder(); sb.append("["); boolean first=true; for ( Object key : attributes.keySet()) { if (first) { first=false; } else { sb.append(", "); } sb.append(key); sb.append("=="); sb.append(attributes.get(key)); } sb.append("]"); return sb.toString(); }
[ "public", "String", "describeAttributes", "(", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "sb", ".", "append", "(", "\"[\"", ")", ";", "boolean", "first", "=", "true", ";", "for", "(", "Object", "key", ":", "attributes", ".", "keySet", "(", ")", ")", "{", "if", "(", "first", ")", "{", "first", "=", "false", ";", "}", "else", "{", "sb", ".", "append", "(", "\", \"", ")", ";", "}", "sb", ".", "append", "(", "key", ")", ";", "sb", ".", "append", "(", "\"==\"", ")", ";", "sb", ".", "append", "(", "attributes", ".", "get", "(", "key", ")", ")", ";", "}", "sb", ".", "append", "(", "\"]\"", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}" ]
returns a string representation of the object ' s current attributes
train
false
4
public static byte[] nextBytes(byte[] buffer){ sRandom.nextBytes(buffer); return buffer; }
[ "public", "static", "byte", "[", "]", "nextBytes", "(", "byte", "[", "]", "buffer", ")", "{", "sRandom", ".", "nextBytes", "(", "buffer", ")", ";", "return", "buffer", ";", "}" ]
fill the given buffer with random bytes .
train
false
5
public void removeAllFromDamaged(final Collection<Unit> damagedUnits){ for ( final Unit u : damagedUnits) { while (m_damaged.contains(u)) { m_damaged.remove(u); } } }
[ "public", "void", "removeAllFromDamaged", "(", "final", "Collection", "<", "Unit", ">", "damagedUnits", ")", "{", "for", "(", "final", "Unit", "u", ":", "damagedUnits", ")", "{", "while", "(", "m_damaged", ".", "contains", "(", "u", ")", ")", "{", "m_damaged", ".", "remove", "(", "u", ")", ";", "}", "}", "}" ]
can have multiple of the same unit , to show multiple hits to that unit .
train
false
6
private IJavaElement[] computeChildren(ArrayList namesWithoutExtension){ int size=namesWithoutExtension.size(); if (size == 0) return NO_ELEMENTS; IJavaElement[] children=new IJavaElement[size]; for (int i=0; i < size; i++) { String nameWithoutExtension=(String)namesWithoutExtension.get(i); children[i]=new ClassFile(this,manager,nameWithoutExtension); } return children; }
[ "private", "IJavaElement", "[", "]", "computeChildren", "(", "ArrayList", "namesWithoutExtension", ")", "{", "int", "size", "=", "namesWithoutExtension", ".", "size", "(", ")", ";", "if", "(", "size", "==", "0", ")", "return", "NO_ELEMENTS", ";", "IJavaElement", "[", "]", "children", "=", "new", "IJavaElement", "[", "size", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "size", ";", "i", "++", ")", "{", "String", "nameWithoutExtension", "=", "(", "String", ")", "namesWithoutExtension", ".", "get", "(", "i", ")", ";", "children", "[", "i", "]", "=", "new", "ClassFile", "(", "this", ",", "manager", ",", "nameWithoutExtension", ")", ";", "}", "return", "children", ";", "}" ]
compute the children of this package fragment . children of jar package fragments can only be iclassfile ( representing . class files ) .
train
false
7
public Object[] toArray(){ Object[] result=new Object[size]; System.arraycopy(elementData,0,result,0,size); return result; }
[ "public", "Object", "[", "]", "toArray", "(", ")", "{", "Object", "[", "]", "result", "=", "new", "Object", "[", "size", "]", ";", "System", ".", "arraycopy", "(", "elementData", ",", "0", ",", "result", ",", "0", ",", "size", ")", ";", "return", "result", ";", "}" ]
returns an array containing all of the elements in this list in the correct order .
train
false
10
@Override protected void onDeleteComplete(int token,Object cookie,int result){ if (token == mDeleteToken) { synchronized (sDeletingThreadsLock) { sDeletingThreads=false; if (DELETEDEBUG) { Log.v(TAG,"Conversation onDeleteComplete sDeletingThreads: " + sDeletingThreads); } sDeletingThreadsLock.notifyAll(); } UnreadBadgeService.update(mContext); NotificationManager.create(mContext); } }
[ "@", "Override", "protected", "void", "onDeleteComplete", "(", "int", "token", ",", "Object", "cookie", ",", "int", "result", ")", "{", "if", "(", "token", "==", "mDeleteToken", ")", "{", "synchronized", "(", "sDeletingThreadsLock", ")", "{", "sDeletingThreads", "=", "false", ";", "if", "(", "DELETEDEBUG", ")", "{", "Log", ".", "v", "(", "TAG", ",", "\"Conversation onDeleteComplete sDeletingThreads: \"", "+", "sDeletingThreads", ")", ";", "}", "sDeletingThreadsLock", ".", "notifyAll", "(", ")", ";", "}", "UnreadBadgeService", ".", "update", "(", "mContext", ")", ";", "NotificationManager", ".", "create", "(", "mContext", ")", ";", "}", "}" ]
always call this super method from your overridden ondeletecomplete function .
train
false
11
public static double log10(double val){ if (val > 0.0) return Math.log10(val); return HUGE_NEGATIVE; }
[ "public", "static", "double", "log10", "(", "double", "val", ")", "{", "if", "(", "val", ">", "0.0", ")", "return", "Math", ".", "log10", "(", "val", ")", ";", "return", "HUGE_NEGATIVE", ";", "}" ]
adjusted log10 to handle values less or equal to zero . < p > the logarithm does not result in real numbers for arguments less or equal to zero , but the plot should still somehow handle such values without crashing . so anything & le ; 0 is mapped to a ' really big negative ' number just for the sake of plotting . < p > note that logarithmicaxis . java in the jfreechart has another interesting idea for modifying the log10 of values & le ; 10 , resulting in a smooth plot for the full real argument range . unfortunately that clobbers values like 1e - 7 , which might be a very real vacuum reading .
train
false
12
private static ILaunchConfiguration createNewLaunchConfiguration(IProject project) throws CoreException, OperationCanceledException { String initialName=calculateLaunchConfigName(project); ILaunchConfiguration launchConfig=GwtSuperDevModeCodeServerLaunchUtil.createLaunchConfig(initialName,project); return launchConfig; }
[ "private", "static", "ILaunchConfiguration", "createNewLaunchConfiguration", "(", "IProject", "project", ")", "throws", "CoreException", ",", "OperationCanceledException", "{", "String", "initialName", "=", "calculateLaunchConfigName", "(", "project", ")", ";", "ILaunchConfiguration", "launchConfig", "=", "GwtSuperDevModeCodeServerLaunchUtil", ".", "createLaunchConfig", "(", "initialName", ",", "project", ")", ";", "return", "launchConfig", ";", "}" ]
create a new launch configuration .
train
false
13
protected long parseDate() throws IOException { if (_utcCalendar == null) _utcCalendar=Calendar.getInstance(TimeZone.getTimeZone("UTC")); return parseDate(_utcCalendar); }
[ "protected", "long", "parseDate", "(", ")", "throws", "IOException", "{", "if", "(", "_utcCalendar", "==", "null", ")", "_utcCalendar", "=", "Calendar", ".", "getInstance", "(", "TimeZone", ".", "getTimeZone", "(", "\"UTC\"", ")", ")", ";", "return", "parseDate", "(", "_utcCalendar", ")", ";", "}" ]
parses a date value from the stream .
train
false
14
@Override public Request<List<BuilderStatus>> builds(ProjectReference projectReference){ List<DummyBuilderStatus> current=currentBuilderStatuses.get(projectReference.name()); List<BuilderStatus> update=new ArrayList<>(); if (current != null) { for ( DummyBuilderStatus dummyBuilderStatus : current) { update.add(dummyBuilderStatus); } } return new DummyRequest<>(update); }
[ "@", "Override", "public", "Request", "<", "List", "<", "BuilderStatus", ">", ">", "builds", "(", "ProjectReference", "projectReference", ")", "{", "List", "<", "DummyBuilderStatus", ">", "current", "=", "currentBuilderStatuses", ".", "get", "(", "projectReference", ".", "name", "(", ")", ")", ";", "List", "<", "BuilderStatus", ">", "update", "=", "new", "ArrayList", "<", ">", "(", ")", ";", "if", "(", "current", "!=", "null", ")", "{", "for", "(", "DummyBuilderStatus", "dummyBuilderStatus", ":", "current", ")", "{", "update", ".", "add", "(", "dummyBuilderStatus", ")", ";", "}", "}", "return", "new", "DummyRequest", "<", ">", "(", "update", ")", ";", "}" ]
gets the project builds for the given project
train
false
15
public String lookahead(){ if (buf != null) { return new String(buf,bufPos,buf.length - bufPos); } else { return text.substring(pos.getIndex()); } }
[ "public", "String", "lookahead", "(", ")", "{", "if", "(", "buf", "!=", "null", ")", "{", "return", "new", "String", "(", "buf", ",", "bufPos", ",", "buf", ".", "length", "-", "bufPos", ")", ";", "}", "else", "{", "return", "text", ".", "substring", "(", "pos", ".", "getIndex", "(", ")", ")", ";", "}", "}" ]
returns a string containing the remainder of the characters to be returned by this iterator , without any option processing . if the iterator is currently within a variable expansion , this will only extend to the end of the variable expansion . this method is provided so that iterators may interoperate with string - based apis . the typical sequence of calls is to call skipignored ( ) , then call lookahead ( ) , then parse the string returned by lookahead ( ) , then call jumpahead ( ) to resynchronize the iterator .
train
true
18
public void testObsoleteDstZoneName() throws Exception { SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd'T'HH:mm zzzz",Locale.US); Date normal=format.parse("1970-01-01T00:00 EET"); Date dst=format.parse("1970-01-01T00:00 EEST"); assertEquals(60 * 60 * 1000,normal.getTime() - dst.getTime()); }
[ "public", "void", "testObsoleteDstZoneName", "(", ")", "throws", "Exception", "{", "SimpleDateFormat", "format", "=", "new", "SimpleDateFormat", "(", "\"yyyy-MM-dd'T'HH:mm zzzz\"", ",", "Locale", ".", "US", ")", ";", "Date", "normal", "=", "format", ".", "parse", "(", "\"1970-01-01T00:00 EET\"", ")", ";", "Date", "dst", "=", "format", ".", "parse", "(", "\"1970-01-01T00:00 EEST\"", ")", ";", "assertEquals", "(", "60", "*", "60", "*", "1000", ",", "normal", ".", "getTime", "(", ")", "-", "dst", ".", "getTime", "(", ")", ")", ";", "}" ]
africa / cairo standard time is eet and daylight time is eest . they no longer use their dst zone but we should continue to parse it properly .
train
false
19
public abstract boolean isLoggable(Level level);
[ "public", "abstract", "boolean", "isLoggable", "(", "Level", "level", ")", ";" ]
" logger like " api to be used by rmi implementation
train
false
20
public String replaceTokens(String queryString,String replacement,String... nonReplacementTokenPrefixes){ Matcher matcher=tokenPattern.matcher(queryString); StringBuffer buf=new StringBuffer(); while (matcher.find()) { String origToken=matcher.group(1); if (origToken != null) { matcher.appendReplacement(buf,""); if (tokenStartsWithPrefix(origToken,nonReplacementTokenPrefixes)) { buf.append("${" + origToken + "}"); } else { buf.append(replacement); } } } matcher.appendTail(buf); return buf.toString(); }
[ "public", "String", "replaceTokens", "(", "String", "queryString", ",", "String", "replacement", ",", "String", "...", "nonReplacementTokenPrefixes", ")", "{", "Matcher", "matcher", "=", "tokenPattern", ".", "matcher", "(", "queryString", ")", ";", "StringBuffer", "buf", "=", "new", "StringBuffer", "(", ")", ";", "while", "(", "matcher", ".", "find", "(", ")", ")", "{", "String", "origToken", "=", "matcher", ".", "group", "(", "1", ")", ";", "if", "(", "origToken", "!=", "null", ")", "{", "matcher", ".", "appendReplacement", "(", "buf", ",", "\"\"", ")", ";", "if", "(", "tokenStartsWithPrefix", "(", "origToken", ",", "nonReplacementTokenPrefixes", ")", ")", "{", "buf", ".", "append", "(", "\"${\"", "+", "origToken", "+", "\"}\"", ")", ";", "}", "else", "{", "buf", ".", "append", "(", "replacement", ")", ";", "}", "}", "}", "matcher", ".", "appendTail", "(", "buf", ")", ";", "return", "buf", ".", "toString", "(", ")", ";", "}" ]
replaces a query string with tokens of format $ { token - name } with the specified replacement string for all tokens .
train
false
21
public boolean isPlural(){ return typeString.contains(SUFFIX_PLURAL); }
[ "public", "boolean", "isPlural", "(", ")", "{", "return", "typeString", ".", "contains", "(", "SUFFIX_PLURAL", ")", ";", "}" ]
determine if the expression is in plural form .
train
false
22
public void insert(ForceItem item){ try { insert(item,root,xMin,yMin,xMax,yMax); } catch ( StackOverflowError e) { e.printStackTrace(); } }
[ "public", "void", "insert", "(", "ForceItem", "item", ")", "{", "try", "{", "insert", "(", "item", ",", "root", ",", "xMin", ",", "yMin", ",", "xMax", ",", "yMax", ")", ";", "}", "catch", "(", "StackOverflowError", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}" ]
inserts an item into the quadtree .
train
false
23
private void handleHovering(int x,int y){ handleCellHover(x,y); if (columnHeadersVisible) { handleHoverOnColumnHeader(x,y); } }
[ "private", "void", "handleHovering", "(", "int", "x", ",", "int", "y", ")", "{", "handleCellHover", "(", "x", ",", "y", ")", ";", "if", "(", "columnHeadersVisible", ")", "{", "handleHoverOnColumnHeader", "(", "x", ",", "y", ")", ";", "}", "}" ]
handles the assignment of the correct values to the hover * field variables that let the painting code now what to paint as hovered .
train
false
24
public static void drawCircledText(Graphics2D g,Font font,String text,int x,int y){ Graphics2D g2=(Graphics2D)g.create(); g2.setFont(font); FontMetrics fm=g2.getFontMetrics(); int padding=4; Rectangle2D bounds=fm.getStringBounds(text,g2); double th=bounds.getHeight(); double tw=bounds.getWidth(); float radius=(float)(Math.max(th,tw) / 2f + padding); Ellipse2D.Float circle=new Ellipse2D.Float(x - radius,y - radius,2 * radius + 1,2 * radius + 1); g2.fill(circle); g2.setColor(Color.BLACK); g2.drawString(text,(int)(x - tw / 2),(y + fm.getAscent() / 2)); if (DEBUG) { g2.setColor(Color.RED); g2.drawLine(x - 50,y,x + 50,y); g2.drawLine(x,y - 50,x,y + 50); } g2.dispose(); }
[ "public", "static", "void", "drawCircledText", "(", "Graphics2D", "g", ",", "Font", "font", ",", "String", "text", ",", "int", "x", ",", "int", "y", ")", "{", "Graphics2D", "g2", "=", "(", "Graphics2D", ")", "g", ".", "create", "(", ")", ";", "g2", ".", "setFont", "(", "font", ")", ";", "FontMetrics", "fm", "=", "g2", ".", "getFontMetrics", "(", ")", ";", "int", "padding", "=", "4", ";", "Rectangle2D", "bounds", "=", "fm", ".", "getStringBounds", "(", "text", ",", "g2", ")", ";", "double", "th", "=", "bounds", ".", "getHeight", "(", ")", ";", "double", "tw", "=", "bounds", ".", "getWidth", "(", ")", ";", "float", "radius", "=", "(", "float", ")", "(", "Math", ".", "max", "(", "th", ",", "tw", ")", "/", "2f", "+", "padding", ")", ";", "Ellipse2D", ".", "Float", "circle", "=", "new", "Ellipse2D", ".", "Float", "(", "x", "-", "radius", ",", "y", "-", "radius", ",", "2", "*", "radius", "+", "1", ",", "2", "*", "radius", "+", "1", ")", ";", "g2", ".", "fill", "(", "circle", ")", ";", "g2", ".", "setColor", "(", "Color", ".", "BLACK", ")", ";", "g2", ".", "drawString", "(", "text", ",", "(", "int", ")", "(", "x", "-", "tw", "/", "2", ")", ",", "(", "y", "+", "fm", ".", "getAscent", "(", ")", "/", "2", ")", ")", ";", "if", "(", "DEBUG", ")", "{", "g2", ".", "setColor", "(", "Color", ".", "RED", ")", ";", "g2", ".", "drawLine", "(", "x", "-", "50", ",", "y", ",", "x", "+", "50", ",", "y", ")", ";", "g2", ".", "drawLine", "(", "x", ",", "y", "-", "50", ",", "x", ",", "y", "+", "50", ")", ";", "}", "g2", ".", "dispose", "(", ")", ";", "}" ]
utility function to draw a circle text centered at coordinates ( x , y )
train
false
25
private void registerEnd(final String prefixSingular,final String prefixPlural,final String endString){ prefixEndList.add(new PrefixEntry(endString,prefixSingular,prefixPlural)); registerPrefix(prefixSingular,prefixPlural); }
[ "private", "void", "registerEnd", "(", "final", "String", "prefixSingular", ",", "final", "String", "prefixPlural", ",", "final", "String", "endString", ")", "{", "prefixEndList", ".", "add", "(", "new", "PrefixEntry", "(", "endString", ",", "prefixSingular", ",", "prefixPlural", ")", ")", ";", "registerPrefix", "(", "prefixSingular", ",", "prefixPlural", ")", ";", "}" ]
define the singular and plural prefix strings for an item name to be matched at the end , for example " bottle of . . . potion " .
train
false
27
public String toString(){ return "[PKCS #10 certificate request:\n" + subjectPublicKeyInfo.toString() + " subject: <"+ subject+ ">"+ "\n"+ " attributes: "+ attributeSet.toString()+ "\n]"; }
[ "public", "String", "toString", "(", ")", "{", "return", "\"[PKCS #10 certificate request:\\n\"", "+", "subjectPublicKeyInfo", ".", "toString", "(", ")", "+", "\" subject: <\"", "+", "subject", "+", "\">\"", "+", "\"\\n\"", "+", "\" attributes: \"", "+", "attributeSet", ".", "toString", "(", ")", "+", "\"\\n]\"", ";", "}" ]
provides a short description of this request .
train
false
28
public SystemPropertiesTableModel(){ columnNames=new String[2]; columnNames[0]=res.getString("SystemPropertiesTableModel.NameColumn"); columnNames[1]=res.getString("SystemPropertiesTableModel.ValueColumn"); data=new Object[0][0]; }
[ "public", "SystemPropertiesTableModel", "(", ")", "{", "columnNames", "=", "new", "String", "[", "2", "]", ";", "columnNames", "[", "0", "]", "=", "res", ".", "getString", "(", "\"SystemPropertiesTableModel.NameColumn\"", ")", ";", "columnNames", "[", "1", "]", "=", "res", ".", "getString", "(", "\"SystemPropertiesTableModel.ValueColumn\"", ")", ";", "data", "=", "new", "Object", "[", "0", "]", "[", "0", "]", ";", "}" ]
construct a new systempropertiestablemodel .
train
false
29
public boolean cancelJob(long id,boolean isPersistent){ JobHolder holder; synchronized (getNextJobLock) { if (jobConsumerExecutor.isRunning(id,isPersistent)) return false; if (isPersistent) { synchronized (persistentJobQueue) { holder=persistentJobQueue.findJobById(id); if (holder == null) return false; persistentJobQueue.remove(holder); } } else { synchronized (nonPersistentJobQueue) { holder=nonPersistentJobQueue.findJobById(id); if (holder == null) return false; nonPersistentJobQueue.remove(holder); } } } BaseJob baseJob=holder.getBaseJob(); if (dependencyInjector != null) { dependencyInjector.inject(baseJob); } baseJob.onCancel(); return true; }
[ "public", "boolean", "cancelJob", "(", "long", "id", ",", "boolean", "isPersistent", ")", "{", "JobHolder", "holder", ";", "synchronized", "(", "getNextJobLock", ")", "{", "if", "(", "jobConsumerExecutor", ".", "isRunning", "(", "id", ",", "isPersistent", ")", ")", "return", "false", ";", "if", "(", "isPersistent", ")", "{", "synchronized", "(", "persistentJobQueue", ")", "{", "holder", "=", "persistentJobQueue", ".", "findJobById", "(", "id", ")", ";", "if", "(", "holder", "==", "null", ")", "return", "false", ";", "persistentJobQueue", ".", "remove", "(", "holder", ")", ";", "}", "}", "else", "{", "synchronized", "(", "nonPersistentJobQueue", ")", "{", "holder", "=", "nonPersistentJobQueue", ".", "findJobById", "(", "id", ")", ";", "if", "(", "holder", "==", "null", ")", "return", "false", ";", "nonPersistentJobQueue", ".", "remove", "(", "holder", ")", ";", "}", "}", "}", "BaseJob", "baseJob", "=", "holder", ".", "getBaseJob", "(", ")", ";", "if", "(", "dependencyInjector", "!=", "null", ")", "{", "dependencyInjector", ".", "inject", "(", "baseJob", ")", ";", "}", "baseJob", ".", "onCancel", "(", ")", ";", "return", "true", ";", "}" ]
cancels job which is waiting to be run .
train
false
30
public static boolean isSimpleMatchPattern(String str){ return str.indexOf('*') != -1; }
[ "public", "static", "boolean", "isSimpleMatchPattern", "(", "String", "str", ")", "{", "return", "str", ".", "indexOf", "(", "'*'", ")", "!=", "-", "1", ";", "}" ]
is the str a simple match pattern .
train
false
31
public String readScript(String fname) throws IOException { StringBuilder sb=new StringBuilder(); BufferedReader in=null; try { if (fname.startsWith("hdfs:") || fname.startsWith("gpfs:")) { FileSystem fs=FileSystem.get(ConfigurationManager.getCachedJobConf()); Path scriptPath=new Path(fname); in=new BufferedReader(new InputStreamReader(fs.open(scriptPath))); } else { in=new BufferedReader(new FileReader(fname)); } String tmp=null; while ((tmp=in.readLine()) != null) { sb.append(tmp); sb.append("\n"); } } finally { IOUtilFunctions.closeSilently(in); } return sb.toString(); }
[ "public", "String", "readScript", "(", "String", "fname", ")", "throws", "IOException", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "BufferedReader", "in", "=", "null", ";", "try", "{", "if", "(", "fname", ".", "startsWith", "(", "\"hdfs:\"", ")", "||", "fname", ".", "startsWith", "(", "\"gpfs:\"", ")", ")", "{", "FileSystem", "fs", "=", "FileSystem", ".", "get", "(", "ConfigurationManager", ".", "getCachedJobConf", "(", ")", ")", ";", "Path", "scriptPath", "=", "new", "Path", "(", "fname", ")", ";", "in", "=", "new", "BufferedReader", "(", "new", "InputStreamReader", "(", "fs", ".", "open", "(", "scriptPath", ")", ")", ")", ";", "}", "else", "{", "in", "=", "new", "BufferedReader", "(", "new", "FileReader", "(", "fname", ")", ")", ";", "}", "String", "tmp", "=", "null", ";", "while", "(", "(", "tmp", "=", "in", ".", "readLine", "(", ")", ")", "!=", "null", ")", "{", "sb", ".", "append", "(", "tmp", ")", ";", "sb", ".", "append", "(", "\"\\n\"", ")", ";", "}", "}", "finally", "{", "IOUtilFunctions", ".", "closeSilently", "(", "in", ")", ";", "}", "return", "sb", ".", "toString", "(", ")", ";", "}" ]
read a dml or pydml file as a string .
train
false
32
public static BinaryFieldAccessor create(Field field,int id){ BinaryWriteMode mode=BinaryUtils.mode(field.getType()); switch (mode) { case P_BYTE: return new BytePrimitiveAccessor(field,id); case P_BOOLEAN: return new BooleanPrimitiveAccessor(field,id); case P_SHORT: return new ShortPrimitiveAccessor(field,id); case P_CHAR: return new CharPrimitiveAccessor(field,id); case P_INT: return new IntPrimitiveAccessor(field,id); case P_LONG: return new LongPrimitiveAccessor(field,id); case P_FLOAT: return new FloatPrimitiveAccessor(field,id); case P_DOUBLE: return new DoublePrimitiveAccessor(field,id); case BYTE: case BOOLEAN: case SHORT: case CHAR: case INT: case LONG: case FLOAT: case DOUBLE: case DECIMAL: case STRING: case UUID: case DATE: case TIMESTAMP: case BYTE_ARR: case SHORT_ARR: case INT_ARR: case LONG_ARR: case FLOAT_ARR: case DOUBLE_ARR: case CHAR_ARR: case BOOLEAN_ARR: case DECIMAL_ARR: case STRING_ARR: case UUID_ARR: case DATE_ARR: case TIMESTAMP_ARR: case ENUM_ARR: case OBJECT_ARR: case BINARY_OBJ: case BINARY: return new DefaultFinalClassAccessor(field,id,mode,false); default : return new DefaultFinalClassAccessor(field,id,mode,!U.isFinal(field.getType())); } }
[ "public", "static", "BinaryFieldAccessor", "create", "(", "Field", "field", ",", "int", "id", ")", "{", "BinaryWriteMode", "mode", "=", "BinaryUtils", ".", "mode", "(", "field", ".", "getType", "(", ")", ")", ";", "switch", "(", "mode", ")", "{", "case", "P_BYTE", ":", "return", "new", "BytePrimitiveAccessor", "(", "field", ",", "id", ")", ";", "case", "P_BOOLEAN", ":", "return", "new", "BooleanPrimitiveAccessor", "(", "field", ",", "id", ")", ";", "case", "P_SHORT", ":", "return", "new", "ShortPrimitiveAccessor", "(", "field", ",", "id", ")", ";", "case", "P_CHAR", ":", "return", "new", "CharPrimitiveAccessor", "(", "field", ",", "id", ")", ";", "case", "P_INT", ":", "return", "new", "IntPrimitiveAccessor", "(", "field", ",", "id", ")", ";", "case", "P_LONG", ":", "return", "new", "LongPrimitiveAccessor", "(", "field", ",", "id", ")", ";", "case", "P_FLOAT", ":", "return", "new", "FloatPrimitiveAccessor", "(", "field", ",", "id", ")", ";", "case", "P_DOUBLE", ":", "return", "new", "DoublePrimitiveAccessor", "(", "field", ",", "id", ")", ";", "case", "BYTE", ":", "case", "BOOLEAN", ":", "case", "SHORT", ":", "case", "CHAR", ":", "case", "INT", ":", "case", "LONG", ":", "case", "FLOAT", ":", "case", "DOUBLE", ":", "case", "DECIMAL", ":", "case", "STRING", ":", "case", "UUID", ":", "case", "DATE", ":", "case", "TIMESTAMP", ":", "case", "BYTE_ARR", ":", "case", "SHORT_ARR", ":", "case", "INT_ARR", ":", "case", "LONG_ARR", ":", "case", "FLOAT_ARR", ":", "case", "DOUBLE_ARR", ":", "case", "CHAR_ARR", ":", "case", "BOOLEAN_ARR", ":", "case", "DECIMAL_ARR", ":", "case", "STRING_ARR", ":", "case", "UUID_ARR", ":", "case", "DATE_ARR", ":", "case", "TIMESTAMP_ARR", ":", "case", "ENUM_ARR", ":", "case", "OBJECT_ARR", ":", "case", "BINARY_OBJ", ":", "case", "BINARY", ":", "return", "new", "DefaultFinalClassAccessor", "(", "field", ",", "id", ",", "mode", ",", "false", ")", ";", "default", ":", "return", "new", "DefaultFinalClassAccessor", "(", "field", ",", "id", ",", "mode", ",", "!", "U", ".", "isFinal", "(", "field", ".", "getType", "(", ")", ")", ")", ";", "}", "}" ]
create accessor for the field .
train
false
33
private String result(HttpURLConnection conn,boolean input) throws IOException { StringBuffer sb=new StringBuffer(); if (input) { InputStream is=conn.getInputStream(); BufferedReader reader=new BufferedReader(new InputStreamReader(is,"utf-8")); String line=null; while ((line=reader.readLine()) != null) { sb.append(line); } reader.close(); is.close(); } Map<String,Object> result=new HashMap<String,Object>(); result.put("code",conn.getResponseCode()); result.put("mesg",conn.getResponseMessage()); result.put("type",conn.getContentType()); result.put("data",sb); String output=String.valueOf(conn.getResponseCode()); setOutputResponseCode(output); Gson gson=new Gson(); String json=gson.toJson(result); logger.info("json = " + json); return json; }
[ "private", "String", "result", "(", "HttpURLConnection", "conn", ",", "boolean", "input", ")", "throws", "IOException", "{", "StringBuffer", "sb", "=", "new", "StringBuffer", "(", ")", ";", "if", "(", "input", ")", "{", "InputStream", "is", "=", "conn", ".", "getInputStream", "(", ")", ";", "BufferedReader", "reader", "=", "new", "BufferedReader", "(", "new", "InputStreamReader", "(", "is", ",", "\"utf-8\"", ")", ")", ";", "String", "line", "=", "null", ";", "while", "(", "(", "line", "=", "reader", ".", "readLine", "(", ")", ")", "!=", "null", ")", "{", "sb", ".", "append", "(", "line", ")", ";", "}", "reader", ".", "close", "(", ")", ";", "is", ".", "close", "(", ")", ";", "}", "Map", "<", "String", ",", "Object", ">", "result", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "result", ".", "put", "(", "\"code\"", ",", "conn", ".", "getResponseCode", "(", ")", ")", ";", "result", ".", "put", "(", "\"mesg\"", ",", "conn", ".", "getResponseMessage", "(", ")", ")", ";", "result", ".", "put", "(", "\"type\"", ",", "conn", ".", "getContentType", "(", ")", ")", ";", "result", ".", "put", "(", "\"data\"", ",", "sb", ")", ";", "String", "output", "=", "String", ".", "valueOf", "(", "conn", ".", "getResponseCode", "(", ")", ")", ";", "setOutputResponseCode", "(", "output", ")", ";", "Gson", "gson", "=", "new", "Gson", "(", ")", ";", "String", "json", "=", "gson", ".", "toJson", "(", "result", ")", ";", "logger", ".", "info", "(", "\"json = \"", "+", "json", ")", ";", "return", "json", ";", "}" ]
report the result in json way
train
false
34
public boolean isBannedMethod(String sig){ return banned_methods.contains(sig); }
[ "public", "boolean", "isBannedMethod", "(", "String", "sig", ")", "{", "return", "banned_methods", ".", "contains", "(", "sig", ")", ";", "}" ]
used by the specification create to check if a method is legal to put in the spec . must check the method , and all superclass definitions of the method .
train
false
35
private SendReturn send(int messageType,String message) throws InterruptedException, ExtractorException { String length=String.format("%d",message.length()); String lenlen=String.format("%d",length.length()); String type=String.format("%04d",messageType); String outMessage; int bytesRead; String replyString; int ll; int t; SendReturn retval=new SendReturn(); boolean lengthKnown; int totalBytesRead=0; int totalBytesNeeded; boolean longMessageSupport=true; if (!connected) throw new OracleExtractException("Not connected"); outMessage=lenlen + length + type+ message; if (logger.isDebugEnabled()) { logger.debug("Sending Message type " + messageType); logger.debug(" - Message is -> " + message); logger.debug(" - Therefore sending -> " + outMessage); } out.println(outMessage); if (messageType != Const.MessageControl) { try { if (longMessageSupport) { lengthKnown=false; totalBytesRead=0; totalBytesNeeded=0; for (; ; ) { bytesRead=in.read(replyBuffer,totalBytesRead,replyBufferSize - totalBytesRead - 1); if (bytesRead == -1) { throw new OracleExtractException("End of Stream"); } totalBytesRead+=bytesRead; logger.debug("Read = " + bytesRead + " total = "+ totalBytesRead+ " needed = "+ totalBytesNeeded); if (lengthKnown) { if (totalBytesRead >= totalBytesNeeded) break; else continue; } if (totalBytesRead <= 9) continue; lengthKnown=true; replyBuffer[totalBytesRead]='\0'; lengthBuffer[0]=replyBuffer[0]; lengthBuffer[1]=replyBuffer[1]; lengthBuffer[2]=replyBuffer[2]; lengthBuffer[3]=replyBuffer[3]; lengthBuffer[4]=replyBuffer[4]; lengthBuffer[5]=replyBuffer[5]; lengthBuffer[6]=replyBuffer[6]; lengthBuffer[7]=replyBuffer[7]; lengthBuffer[8]=replyBuffer[8]; lengthBuffer[9]=replyBuffer[9]; lengthBuffer[10]='\0'; String lengthString=new String(lengthBuffer); totalBytesNeeded=Integer.parseInt(lengthString.substring(1,9),16); totalBytesNeeded+=13; if (totalBytesNeeded + 1 > replyBufferSize) increaseReplyBuffer(totalBytesNeeded + 1); if (totalBytesRead >= totalBytesNeeded) break; } } else { totalBytesRead=in.read(replyBuffer); } } catch ( ClosedByInterruptException e) { throw new InterruptedException("Oracle extractor was interrupted"); } catch ( IOException e) { throw new OracleExtractException("End of Stream"); } if (totalBytesRead == -1) { throw new OracleExtractException("End of Stream"); } replyBuffer[totalBytesRead]='\0'; replyString=new String(replyBuffer,0,totalBytesRead); if (logger.isDebugEnabled()) { logger.debug("Reply = \"" + replyString + "\"\n"); } ll=Integer.parseInt(replyString.substring(0,1)); t=Integer.parseInt(replyString.substring(1 + ll,1 + ll + 4)); replyString=replyString.substring(1 + ll + 4); if (logger.isDebugEnabled()) { logger.debug("Reply = \"" + replyString + "\"\n"); } retval.type=t; retval.reply=replyString; } else { retval.type=Const.ReplyReserved; retval.reply=new String("Empty"); } if (retval.type == Const.ReplyError) throw new OracleExtractException("Error from C Oracle Extractor"); msgCount++; return retval; }
[ "private", "SendReturn", "send", "(", "int", "messageType", ",", "String", "message", ")", "throws", "InterruptedException", ",", "ExtractorException", "{", "String", "length", "=", "String", ".", "format", "(", "\"%d\"", ",", "message", ".", "length", "(", ")", ")", ";", "String", "lenlen", "=", "String", ".", "format", "(", "\"%d\"", ",", "length", ".", "length", "(", ")", ")", ";", "String", "type", "=", "String", ".", "format", "(", "\"%04d\"", ",", "messageType", ")", ";", "String", "outMessage", ";", "int", "bytesRead", ";", "String", "replyString", ";", "int", "ll", ";", "int", "t", ";", "SendReturn", "retval", "=", "new", "SendReturn", "(", ")", ";", "boolean", "lengthKnown", ";", "int", "totalBytesRead", "=", "0", ";", "int", "totalBytesNeeded", ";", "boolean", "longMessageSupport", "=", "true", ";", "if", "(", "!", "connected", ")", "throw", "new", "OracleExtractException", "(", "\"Not connected\"", ")", ";", "outMessage", "=", "lenlen", "+", "length", "+", "type", "+", "message", ";", "if", "(", "logger", ".", "isDebugEnabled", "(", ")", ")", "{", "logger", ".", "debug", "(", "\"Sending Message type \"", "+", "messageType", ")", ";", "logger", ".", "debug", "(", "\" - Message is -> \"", "+", "message", ")", ";", "logger", ".", "debug", "(", "\" - Therefore sending -> \"", "+", "outMessage", ")", ";", "}", "out", ".", "println", "(", "outMessage", ")", ";", "if", "(", "messageType", "!=", "Const", ".", "MessageControl", ")", "{", "try", "{", "if", "(", "longMessageSupport", ")", "{", "lengthKnown", "=", "false", ";", "totalBytesRead", "=", "0", ";", "totalBytesNeeded", "=", "0", ";", "for", "(", ";", ";", ")", "{", "bytesRead", "=", "in", ".", "read", "(", "replyBuffer", ",", "totalBytesRead", ",", "replyBufferSize", "-", "totalBytesRead", "-", "1", ")", ";", "if", "(", "bytesRead", "==", "-", "1", ")", "{", "throw", "new", "OracleExtractException", "(", "\"End of Stream\"", ")", ";", "}", "totalBytesRead", "+=", "bytesRead", ";", "logger", ".", "debug", "(", "\"Read = \"", "+", "bytesRead", "+", "\" total = \"", "+", "totalBytesRead", "+", "\" needed = \"", "+", "totalBytesNeeded", ")", ";", "if", "(", "lengthKnown", ")", "{", "if", "(", "totalBytesRead", ">=", "totalBytesNeeded", ")", "break", ";", "else", "continue", ";", "}", "if", "(", "totalBytesRead", "<=", "9", ")", "continue", ";", "lengthKnown", "=", "true", ";", "replyBuffer", "[", "totalBytesRead", "]", "=", "'\\0'", ";", "lengthBuffer", "[", "0", "]", "=", "replyBuffer", "[", "0", "]", ";", "lengthBuffer", "[", "1", "]", "=", "replyBuffer", "[", "1", "]", ";", "lengthBuffer", "[", "2", "]", "=", "replyBuffer", "[", "2", "]", ";", "lengthBuffer", "[", "3", "]", "=", "replyBuffer", "[", "3", "]", ";", "lengthBuffer", "[", "4", "]", "=", "replyBuffer", "[", "4", "]", ";", "lengthBuffer", "[", "5", "]", "=", "replyBuffer", "[", "5", "]", ";", "lengthBuffer", "[", "6", "]", "=", "replyBuffer", "[", "6", "]", ";", "lengthBuffer", "[", "7", "]", "=", "replyBuffer", "[", "7", "]", ";", "lengthBuffer", "[", "8", "]", "=", "replyBuffer", "[", "8", "]", ";", "lengthBuffer", "[", "9", "]", "=", "replyBuffer", "[", "9", "]", ";", "lengthBuffer", "[", "10", "]", "=", "'\\0'", ";", "String", "lengthString", "=", "new", "String", "(", "lengthBuffer", ")", ";", "totalBytesNeeded", "=", "Integer", ".", "parseInt", "(", "lengthString", ".", "substring", "(", "1", ",", "9", ")", ",", "16", ")", ";", "totalBytesNeeded", "+=", "13", ";", "if", "(", "totalBytesNeeded", "+", "1", ">", "replyBufferSize", ")", "increaseReplyBuffer", "(", "totalBytesNeeded", "+", "1", ")", ";", "if", "(", "totalBytesRead", ">=", "totalBytesNeeded", ")", "break", ";", "}", "}", "else", "{", "totalBytesRead", "=", "in", ".", "read", "(", "replyBuffer", ")", ";", "}", "}", "catch", "(", "ClosedByInterruptException", "e", ")", "{", "throw", "new", "InterruptedException", "(", "\"Oracle extractor was interrupted\"", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "OracleExtractException", "(", "\"End of Stream\"", ")", ";", "}", "if", "(", "totalBytesRead", "==", "-", "1", ")", "{", "throw", "new", "OracleExtractException", "(", "\"End of Stream\"", ")", ";", "}", "replyBuffer", "[", "totalBytesRead", "]", "=", "'\\0'", ";", "replyString", "=", "new", "String", "(", "replyBuffer", ",", "0", ",", "totalBytesRead", ")", ";", "if", "(", "logger", ".", "isDebugEnabled", "(", ")", ")", "{", "logger", ".", "debug", "(", "\"Reply = \\\"\"", "+", "replyString", "+", "\"\\\"\\n\"", ")", ";", "}", "ll", "=", "Integer", ".", "parseInt", "(", "replyString", ".", "substring", "(", "0", ",", "1", ")", ")", ";", "t", "=", "Integer", ".", "parseInt", "(", "replyString", ".", "substring", "(", "1", "+", "ll", ",", "1", "+", "ll", "+", "4", ")", ")", ";", "replyString", "=", "replyString", ".", "substring", "(", "1", "+", "ll", "+", "4", ")", ";", "if", "(", "logger", ".", "isDebugEnabled", "(", ")", ")", "{", "logger", ".", "debug", "(", "\"Reply = \\\"\"", "+", "replyString", "+", "\"\\\"\\n\"", ")", ";", "}", "retval", ".", "type", "=", "t", ";", "retval", ".", "reply", "=", "replyString", ";", "}", "else", "{", "retval", ".", "type", "=", "Const", ".", "ReplyReserved", ";", "retval", ".", "reply", "=", "new", "String", "(", "\"Empty\"", ")", ";", "}", "if", "(", "retval", ".", "type", "==", "Const", ".", "ReplyError", ")", "throw", "new", "OracleExtractException", "(", "\"Error from C Oracle Extractor\"", ")", ";", "msgCount", "++", ";", "return", "retval", ";", "}" ]
send message to dslisten - typically an extract next change message
train
false
37
private void attachPlot(SVGPlot newplot){ this.plot=newplot; if (newplot == null) { super.setSVGDocument(null); return; } newplot.synchronizeWith(synchronizer); super.setSVGDocument(newplot.getDocument()); super.setDisableInteractions(newplot.getDisableInteractions()); }
[ "private", "void", "attachPlot", "(", "SVGPlot", "newplot", ")", "{", "this", ".", "plot", "=", "newplot", ";", "if", "(", "newplot", "==", "null", ")", "{", "super", ".", "setSVGDocument", "(", "null", ")", ";", "return", ";", "}", "newplot", ".", "synchronizeWith", "(", "synchronizer", ")", ";", "super", ".", "setSVGDocument", "(", "newplot", ".", "getDocument", "(", ")", ")", ";", "super", ".", "setDisableInteractions", "(", "newplot", ".", "getDisableInteractions", "(", ")", ")", ";", "}" ]
attach to a new plot , and display .
train
true
40
public void shutdown() throws Exception { try { if (solrClient != null) solrClient.close(); List<Callable<JettySolrRunner>> shutdowns=new ArrayList<>(jettys.size()); for ( final JettySolrRunner jetty : jettys) { shutdowns.add(null); } jettys.clear(); Collection<Future<JettySolrRunner>> futures=executor.invokeAll(shutdowns); Exception shutdownError=checkForExceptions("Error shutting down MiniSolrCloudCluster",futures); if (shutdownError != null) { throw shutdownError; } } finally { executor.shutdown(); executor.awaitTermination(2,TimeUnit.SECONDS); try { if (!externalZkServer) { zkServer.shutdown(); } } finally { System.clearProperty("zkHost"); } } }
[ "public", "void", "shutdown", "(", ")", "throws", "Exception", "{", "try", "{", "if", "(", "solrClient", "!=", "null", ")", "solrClient", ".", "close", "(", ")", ";", "List", "<", "Callable", "<", "JettySolrRunner", ">", ">", "shutdowns", "=", "new", "ArrayList", "<", ">", "(", "jettys", ".", "size", "(", ")", ")", ";", "for", "(", "final", "JettySolrRunner", "jetty", ":", "jettys", ")", "{", "shutdowns", ".", "add", "(", "null", ")", ";", "}", "jettys", ".", "clear", "(", ")", ";", "Collection", "<", "Future", "<", "JettySolrRunner", ">", ">", "futures", "=", "executor", ".", "invokeAll", "(", "shutdowns", ")", ";", "Exception", "shutdownError", "=", "checkForExceptions", "(", "\"Error shutting down MiniSolrCloudCluster\"", ",", "futures", ")", ";", "if", "(", "shutdownError", "!=", "null", ")", "{", "throw", "shutdownError", ";", "}", "}", "finally", "{", "executor", ".", "shutdown", "(", ")", ";", "executor", ".", "awaitTermination", "(", "2", ",", "TimeUnit", ".", "SECONDS", ")", ";", "try", "{", "if", "(", "!", "externalZkServer", ")", "{", "zkServer", ".", "shutdown", "(", ")", ";", "}", "}", "finally", "{", "System", ".", "clearProperty", "(", "\"zkHost\"", ")", ";", "}", "}", "}" ]
shut down the cluster , including all solr nodes and zookeeper
train
false
41
private static Control createRequestControl(final Class clazz,final Class[] paramTypes,final Object[] params){ Constructor constructor=ClassUtils.getConstructorIfAvailable(clazz,paramTypes); if (constructor == null) { LdapExceptionUtils.generateErrorException(LdapErrorCodes.ERR_10005_CONTROL_CONTRUCTOR_NOT_FOUND,new String[]{clazz.toString(),StringUtils.arrayToCommaDelimitedString(paramTypes)},LOGGER); } Control result=null; try { result=(Control)constructor.newInstance(params); } catch ( Exception e) { LdapExceptionUtils.generateErrorException(LdapErrorCodes.ERR_10006_CONTROL_INSTANCE_FAILED,new String[]{clazz.toString(),StringUtils.arrayToCommaDelimitedString(paramTypes),StringUtils.arrayToCommaDelimitedString(params)},LOGGER,e); } return result; }
[ "private", "static", "Control", "createRequestControl", "(", "final", "Class", "clazz", ",", "final", "Class", "[", "]", "paramTypes", ",", "final", "Object", "[", "]", "params", ")", "{", "Constructor", "constructor", "=", "ClassUtils", ".", "getConstructorIfAvailable", "(", "clazz", ",", "paramTypes", ")", ";", "if", "(", "constructor", "==", "null", ")", "{", "LdapExceptionUtils", ".", "generateErrorException", "(", "LdapErrorCodes", ".", "ERR_10005_CONTROL_CONTRUCTOR_NOT_FOUND", ",", "new", "String", "[", "]", "{", "clazz", ".", "toString", "(", ")", ",", "StringUtils", ".", "arrayToCommaDelimitedString", "(", "paramTypes", ")", "}", ",", "LOGGER", ")", ";", "}", "Control", "result", "=", "null", ";", "try", "{", "result", "=", "(", "Control", ")", "constructor", ".", "newInstance", "(", "params", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "LdapExceptionUtils", ".", "generateErrorException", "(", "LdapErrorCodes", ".", "ERR_10006_CONTROL_INSTANCE_FAILED", ",", "new", "String", "[", "]", "{", "clazz", ".", "toString", "(", ")", ",", "StringUtils", ".", "arrayToCommaDelimitedString", "(", "paramTypes", ")", ",", "StringUtils", ".", "arrayToCommaDelimitedString", "(", "params", ")", "}", ",", "LOGGER", ",", "e", ")", ";", "}", "return", "result", ";", "}" ]
permite crear una instancia de la clase pasada como parametro .
train
false
43
public boolean isNewState(){ return fileName.equals(""); }
[ "public", "boolean", "isNewState", "(", ")", "{", "return", "fileName", ".", "equals", "(", "\"\"", ")", ";", "}" ]
tells whether this session is in a new state or not . a session is in a new state if it was never saved or it was not loaded from an existing session .
train
false
44
public boolean offer(E e){ final ReentrantLock lock=this.lock; lock.lock(); try { q.offer(e); if (q.peek() == e) { leader=null; available.signal(); } return true; } finally { lock.unlock(); } }
[ "public", "boolean", "offer", "(", "E", "e", ")", "{", "final", "ReentrantLock", "lock", "=", "this", ".", "lock", ";", "lock", ".", "lock", "(", ")", ";", "try", "{", "q", ".", "offer", "(", "e", ")", ";", "if", "(", "q", ".", "peek", "(", ")", "==", "e", ")", "{", "leader", "=", "null", ";", "available", ".", "signal", "(", ")", ";", "}", "return", "true", ";", "}", "finally", "{", "lock", ".", "unlock", "(", ")", ";", "}", "}" ]
inserts the specified element into this delay queue .
train
true
45
public void updateLeagueHistory(){ Collections.sort(teamList,new TeamCompPoll()); String[] yearTop10=new String[10]; Team tt; for (int i=0; i < 10; ++i) { tt=teamList.get(i); yearTop10[i]=tt.abbr + " (" + tt.wins+ "-"+ tt.losses+ ")"; } leagueHistory.add(yearTop10); }
[ "public", "void", "updateLeagueHistory", "(", ")", "{", "Collections", ".", "sort", "(", "teamList", ",", "new", "TeamCompPoll", "(", ")", ")", ";", "String", "[", "]", "yearTop10", "=", "new", "String", "[", "10", "]", ";", "Team", "tt", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "10", ";", "++", "i", ")", "{", "tt", "=", "teamList", ".", "get", "(", "i", ")", ";", "yearTop10", "[", "i", "]", "=", "tt", ".", "abbr", "+", "\" (\"", "+", "tt", ".", "wins", "+", "\"-\"", "+", "tt", ".", "losses", "+", "\")\"", ";", "}", "leagueHistory", ".", "add", "(", "yearTop10", ")", ";", "}" ]
at the end of the year , record the top 10 teams for the league ' s history .
train
false
47
private void updateFont(){ String fontName=fontList.getValue(); Integer fontSize=FALLBACK_FONT_SIZE; try { fontSize=Integer.parseInt(fontSizeList.getValue()); } catch ( NumberFormatException ex) { } font=new Font(fontName,Font.PLAIN,fontSize); preview.setFont(font); }
[ "private", "void", "updateFont", "(", ")", "{", "String", "fontName", "=", "fontList", ".", "getValue", "(", ")", ";", "Integer", "fontSize", "=", "FALLBACK_FONT_SIZE", ";", "try", "{", "fontSize", "=", "Integer", ".", "parseInt", "(", "fontSizeList", ".", "getValue", "(", ")", ")", ";", "}", "catch", "(", "NumberFormatException", "ex", ")", "{", "}", "font", "=", "new", "Font", "(", "fontName", ",", "Font", ".", "PLAIN", ",", "fontSize", ")", ";", "preview", ".", "setFont", "(", "font", ")", ";", "}" ]
creates a new font based on the current settings and also updates the preview . the created font is not only used for the preview , but also to return it when requested from the caller .
train
false
51
@Override public void close() throws IOException { fInputStream.close(); }
[ "@", "Override", "public", "void", "close", "(", ")", "throws", "IOException", "{", "fInputStream", ".", "close", "(", ")", ";", "}" ]
close the stream . once a stream has been closed , further read ( ) , ready ( ) , mark ( ) , or reset ( ) invocations will throw an ioexception . closing a previously - closed stream , however , has no effect .
train
false
52
public static void sleep(){ try { Thread.sleep(TestSettings.RESPONSE_WAIT); } catch ( InterruptedException e) { } }
[ "public", "static", "void", "sleep", "(", ")", "{", "try", "{", "Thread", ".", "sleep", "(", "TestSettings", ".", "RESPONSE_WAIT", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "}", "}" ]
current thread sleeps for a predefined amount of time . if it has been interrupted , the method would be finished and no exception is thrown .
train
false
53
public void add(URI uri,HttpCookie cookie){ if (cookie == null) { throw new NullPointerException("cookie is null"); } lock.lock(); try { cookieJar.remove(cookie); if (cookie.getMaxAge() != 0) { cookieJar.add(cookie); if (cookie.getDomain() != null) { addIndex(domainIndex,cookie.getDomain(),cookie); } if (uri != null) { addIndex(uriIndex,getEffectiveURI(uri),cookie); } } } finally { lock.unlock(); } }
[ "public", "void", "add", "(", "URI", "uri", ",", "HttpCookie", "cookie", ")", "{", "if", "(", "cookie", "==", "null", ")", "{", "throw", "new", "NullPointerException", "(", "\"cookie is null\"", ")", ";", "}", "lock", ".", "lock", "(", ")", ";", "try", "{", "cookieJar", ".", "remove", "(", "cookie", ")", ";", "if", "(", "cookie", ".", "getMaxAge", "(", ")", "!=", "0", ")", "{", "cookieJar", ".", "add", "(", "cookie", ")", ";", "if", "(", "cookie", ".", "getDomain", "(", ")", "!=", "null", ")", "{", "addIndex", "(", "domainIndex", ",", "cookie", ".", "getDomain", "(", ")", ",", "cookie", ")", ";", "}", "if", "(", "uri", "!=", "null", ")", "{", "addIndex", "(", "uriIndex", ",", "getEffectiveURI", "(", "uri", ")", ",", "cookie", ")", ";", "}", "}", "}", "finally", "{", "lock", ".", "unlock", "(", ")", ";", "}", "}" ]
add one cookie into cookie store .
train
false
54
public void delete(RandomAccessFile raf,RandomAccessFile tempRaf) throws IOException, CannotWriteException { FlacTag emptyTag=new FlacTag(null,new ArrayList<MetadataBlockDataPicture>()); raf.seek(0); tempRaf.seek(0); write(emptyTag,raf,tempRaf); }
[ "public", "void", "delete", "(", "RandomAccessFile", "raf", ",", "RandomAccessFile", "tempRaf", ")", "throws", "IOException", ",", "CannotWriteException", "{", "FlacTag", "emptyTag", "=", "new", "FlacTag", "(", "null", ",", "new", "ArrayList", "<", "MetadataBlockDataPicture", ">", "(", ")", ")", ";", "raf", ".", "seek", "(", "0", ")", ";", "tempRaf", ".", "seek", "(", "0", ")", ";", "write", "(", "emptyTag", ",", "raf", ",", "tempRaf", ")", ";", "}" ]
delete tag from file
train
false
55
void show(Rectangle bounds){ if (!isCreated()) { return; } if (log.isLoggable(PlatformLogger.Level.FINER)) { log.finer("showing menu window + " + getWindow() + " at "+ bounds); } XToolkit.awtLock(); try { reshape(bounds.x,bounds.y,bounds.width,bounds.height); xSetVisible(true); toFront(); selectItem(getFirstSelectableItem(),false); } finally { XToolkit.awtUnlock(); } }
[ "void", "show", "(", "Rectangle", "bounds", ")", "{", "if", "(", "!", "isCreated", "(", ")", ")", "{", "return", ";", "}", "if", "(", "log", ".", "isLoggable", "(", "PlatformLogger", ".", "Level", ".", "FINER", ")", ")", "{", "log", ".", "finer", "(", "\"showing menu window + \"", "+", "getWindow", "(", ")", "+", "\" at \"", "+", "bounds", ")", ";", "}", "XToolkit", ".", "awtLock", "(", ")", ";", "try", "{", "reshape", "(", "bounds", ".", "x", ",", "bounds", ".", "y", ",", "bounds", ".", "width", ",", "bounds", ".", "height", ")", ";", "xSetVisible", "(", "true", ")", ";", "toFront", "(", ")", ";", "selectItem", "(", "getFirstSelectableItem", "(", ")", ",", "false", ")", ";", "}", "finally", "{", "XToolkit", ".", "awtUnlock", "(", ")", ";", "}", "}" ]
init window if it ' s not inited yet and show it at specified coordinates
train
false
56
void downcase(final StringBuffer text,final int leng){ for (int i=0; i < leng; i++) { if (Character.isUpperCase(text.charAt(i))) { text.setCharAt(i,Character.toLowerCase(text.charAt(i))); } } }
[ "void", "downcase", "(", "final", "StringBuffer", "text", ",", "final", "int", "leng", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "leng", ";", "i", "++", ")", "{", "if", "(", "Character", ".", "isUpperCase", "(", "text", ".", "charAt", "(", "i", ")", ")", ")", "{", "text", ".", "setCharAt", "(", "i", ",", "Character", ".", "toLowerCase", "(", "text", ".", "charAt", "(", "i", ")", ")", ")", ";", "}", "}", "}" ]
lowercase the characters up to the given length
train
false
58
public void releaseExternalResources(){ if (!isClosed.get()) { logger.info("Releasing all ParallelClient resources... "); ActorConfig.shutDownActorSystemForce(); httpClientStore.shutdown(); tcpSshPingResourceStore.shutdown(); taskManager.cleanWaitTaskQueue(); taskManager.cleanInprogressJobMap(); isClosed.set(true); logger.info("Have released all ParallelClient resources " + "(actor system + async+sync http client + task queue)" + "\nNow safe to stop your application."); } else { logger.debug("NO OP. ParallelClient resources have already been released."); } }
[ "public", "void", "releaseExternalResources", "(", ")", "{", "if", "(", "!", "isClosed", ".", "get", "(", ")", ")", "{", "logger", ".", "info", "(", "\"Releasing all ParallelClient resources... \"", ")", ";", "ActorConfig", ".", "shutDownActorSystemForce", "(", ")", ";", "httpClientStore", ".", "shutdown", "(", ")", ";", "tcpSshPingResourceStore", ".", "shutdown", "(", ")", ";", "taskManager", ".", "cleanWaitTaskQueue", "(", ")", ";", "taskManager", ".", "cleanInprogressJobMap", "(", ")", ";", "isClosed", ".", "set", "(", "true", ")", ";", "logger", ".", "info", "(", "\"Have released all ParallelClient resources \"", "+", "\"(actor system + async+sync http client + task queue)\"", "+", "\"\\nNow safe to stop your application.\"", ")", ";", "}", "else", "{", "logger", ".", "debug", "(", "\"NO OP. ParallelClient resources have already been released.\"", ")", ";", "}", "}" ]
releases the external resources that this object depends on . you should not call this method if you still want to use the external resources ( e . g . akka system , async http client store , thread pool for ssh / tcp ) are in use by other objects .
train
true
61
@Override public IScanListIterator<IEntryCacheInfo> establishScan(K startPos,short relation,K endPos,boolean endPosInclusive,boolean ordered){ ordered|=FORCE_ORDERED_SCAN; long startTime=_recentExtendedIndexUpdates != null ? System.currentTimeMillis() : 0; IScanListIterator<IEntryCacheInfo> res=ordered ? establishScanOrdered(startPos,relation,endPos,endPosInclusive) : establishScanUnOrdered(startPos,relation,endPos,endPosInclusive); if (_recentExtendedIndexUpdates != null && !_recentExtendedIndexUpdates.isEmpty()) { MultiStoredList<IEntryCacheInfo> msl=new MultiStoredList<IEntryCacheInfo>(); msl.add(res); msl.add(_recentExtendedIndexUpdates.iterator(startTime,(ExtendedIndexIterator)res)); return msl; } else return res; }
[ "@", "Override", "public", "IScanListIterator", "<", "IEntryCacheInfo", ">", "establishScan", "(", "K", "startPos", ",", "short", "relation", ",", "K", "endPos", ",", "boolean", "endPosInclusive", ",", "boolean", "ordered", ")", "{", "ordered", "|=", "FORCE_ORDERED_SCAN", ";", "long", "startTime", "=", "_recentExtendedIndexUpdates", "!=", "null", "?", "System", ".", "currentTimeMillis", "(", ")", ":", "0", ";", "IScanListIterator", "<", "IEntryCacheInfo", ">", "res", "=", "ordered", "?", "establishScanOrdered", "(", "startPos", ",", "relation", ",", "endPos", ",", "endPosInclusive", ")", ":", "establishScanUnOrdered", "(", "startPos", ",", "relation", ",", "endPos", ",", "endPosInclusive", ")", ";", "if", "(", "_recentExtendedIndexUpdates", "!=", "null", "&&", "!", "_recentExtendedIndexUpdates", ".", "isEmpty", "(", ")", ")", "{", "MultiStoredList", "<", "IEntryCacheInfo", ">", "msl", "=", "new", "MultiStoredList", "<", "IEntryCacheInfo", ">", "(", ")", ";", "msl", ".", "add", "(", "res", ")", ";", "msl", ".", "add", "(", "_recentExtendedIndexUpdates", ".", "iterator", "(", "startTime", ",", "(", "ExtendedIndexIterator", ")", "res", ")", ")", ";", "return", "msl", ";", "}", "else", "return", "res", ";", "}" ]
establish a scan according to the relation given and startpos : the start - scan object , null means scan all values . the relation is from com . j_spaces . client . templatematchcodes : lt , le , gt , ge ( other codes are not relevant ) endpos - key up to ( or null if no limit in index ) endposinclusive : is the endpos up to ( or down to ) and including ? ordered - according to the condition . gt , ge = = > ascending , lt , le = = = = = > descending . returns an iorderedindexscan object which enables scanning the ordered index , null if no relevant elements to scan
train
false
62
public static BytesToNameCanonicalizer createRoot(){ long now=System.currentTimeMillis(); int seed=(((int)now) + ((int)now >>> 32)) | 1; return createRoot(seed); }
[ "public", "static", "BytesToNameCanonicalizer", "createRoot", "(", ")", "{", "long", "now", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "int", "seed", "=", "(", "(", "(", "int", ")", "now", ")", "+", "(", "(", "int", ")", "now", ">", ">", ">", "32", ")", ")", "|", "1", ";", "return", "createRoot", "(", "seed", ")", ";", "}" ]
factory method to call to create a symbol table instance with a randomized seed value .
train
false
63
public void fillFieldValues(List<SynapseUpdateRule> ruleList){ HebbianRule synapseRef=(HebbianRule)ruleList.get(0); if (!NetworkUtils.isConsistent(ruleList,HebbianRule.class,"getLearningRate")) { tfLearningRate.setText(SimbrainConstants.NULL_STRING); } else { tfLearningRate.setText(Double.toString(synapseRef.getLearningRate())); } }
[ "public", "void", "fillFieldValues", "(", "List", "<", "SynapseUpdateRule", ">", "ruleList", ")", "{", "HebbianRule", "synapseRef", "=", "(", "HebbianRule", ")", "ruleList", ".", "get", "(", "0", ")", ";", "if", "(", "!", "NetworkUtils", ".", "isConsistent", "(", "ruleList", ",", "HebbianRule", ".", "class", ",", "\"getLearningRate\"", ")", ")", "{", "tfLearningRate", ".", "setText", "(", "SimbrainConstants", ".", "NULL_STRING", ")", ";", "}", "else", "{", "tfLearningRate", ".", "setText", "(", "Double", ".", "toString", "(", "synapseRef", ".", "getLearningRate", "(", ")", ")", ")", ";", "}", "}" ]
populate fields with current data .
train
false
64
public static int countArgumentPlaceholders(final String messagePattern){ if (messagePattern == null) { return 0; } final int delim=messagePattern.indexOf(DELIM_START); if (delim == -1) { return 0; } int result=0; boolean isEscaped=false; for (int i=0; i < messagePattern.length(); i++) { final char curChar=messagePattern.charAt(i); if (curChar == ESCAPE_CHAR) { isEscaped=!isEscaped; } else if (curChar == DELIM_START) { if (!isEscaped && i < messagePattern.length() - 1 && messagePattern.charAt(i + 1) == DELIM_STOP) { result++; i++; } isEscaped=false; } else { isEscaped=false; } } return result; }
[ "public", "static", "int", "countArgumentPlaceholders", "(", "final", "String", "messagePattern", ")", "{", "if", "(", "messagePattern", "==", "null", ")", "{", "return", "0", ";", "}", "final", "int", "delim", "=", "messagePattern", ".", "indexOf", "(", "DELIM_START", ")", ";", "if", "(", "delim", "==", "-", "1", ")", "{", "return", "0", ";", "}", "int", "result", "=", "0", ";", "boolean", "isEscaped", "=", "false", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "messagePattern", ".", "length", "(", ")", ";", "i", "++", ")", "{", "final", "char", "curChar", "=", "messagePattern", ".", "charAt", "(", "i", ")", ";", "if", "(", "curChar", "==", "ESCAPE_CHAR", ")", "{", "isEscaped", "=", "!", "isEscaped", ";", "}", "else", "if", "(", "curChar", "==", "DELIM_START", ")", "{", "if", "(", "!", "isEscaped", "&&", "i", "<", "messagePattern", ".", "length", "(", ")", "-", "1", "&&", "messagePattern", ".", "charAt", "(", "i", "+", "1", ")", "==", "DELIM_STOP", ")", "{", "result", "++", ";", "i", "++", ";", "}", "isEscaped", "=", "false", ";", "}", "else", "{", "isEscaped", "=", "false", ";", "}", "}", "return", "result", ";", "}" ]
counts the number of unescaped placeholders in the given messagepattern .
train
false
65
protected abstract boolean isEndOfChunk(char currPrefix,String currLabel,char nextPrefix,String nextLabel);
[ "protected", "abstract", "boolean", "isEndOfChunk", "(", "char", "currPrefix", ",", "String", "currLabel", ",", "char", "nextPrefix", ",", "String", "nextLabel", ")", ";" ]
determines whether the current outcome represents the end of a chunk . both the current outcome and the following outcome are provided for making this decision .
train
false
66
public void clear(){ set.clear(); fireContentsChanged(this,0,0); }
[ "public", "void", "clear", "(", ")", "{", "set", ".", "clear", "(", ")", ";", "fireContentsChanged", "(", "this", ",", "0", ",", "0", ")", ";", "}" ]
clears this list model .
train
false
67
static String toString(@NotNull final Bytes buffer,long position,long len) throws BufferUnderflowException { final long pos=buffer.readPosition(); final long limit=buffer.readLimit(); buffer.readPositionRemaining(position,len); try { final StringBuilder builder=new StringBuilder(); while (buffer.readRemaining() > 0) { builder.append((char)buffer.readByte()); } return builder.toString(); } finally { buffer.readLimit(limit); buffer.readPosition(pos); } }
[ "static", "String", "toString", "(", "@", "NotNull", "final", "Bytes", "buffer", ",", "long", "position", ",", "long", "len", ")", "throws", "BufferUnderflowException", "{", "final", "long", "pos", "=", "buffer", ".", "readPosition", "(", ")", ";", "final", "long", "limit", "=", "buffer", ".", "readLimit", "(", ")", ";", "buffer", ".", "readPositionRemaining", "(", "position", ",", "len", ")", ";", "try", "{", "final", "StringBuilder", "builder", "=", "new", "StringBuilder", "(", ")", ";", "while", "(", "buffer", ".", "readRemaining", "(", ")", ">", "0", ")", "{", "builder", ".", "append", "(", "(", "char", ")", "buffer", ".", "readByte", "(", ")", ")", ";", "}", "return", "builder", ".", "toString", "(", ")", ";", "}", "finally", "{", "buffer", ".", "readLimit", "(", "limit", ")", ";", "buffer", ".", "readPosition", "(", "pos", ")", ";", "}", "}" ]
the buffer is not modified by this call
train
false
68
void collectUnresponsiveMembers(Set s){ if (stillWaiting()) { InternalDistributedMember[] memberList=getMembers(); synchronized (memberList) { for (int i=0; i < memberList.length; i++) { InternalDistributedMember m=memberList[i]; if (m != null) { s.add(m); } } } } }
[ "void", "collectUnresponsiveMembers", "(", "Set", "s", ")", "{", "if", "(", "stillWaiting", "(", ")", ")", "{", "InternalDistributedMember", "[", "]", "memberList", "=", "getMembers", "(", ")", ";", "synchronized", "(", "memberList", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "memberList", ".", "length", ";", "i", "++", ")", "{", "InternalDistributedMember", "m", "=", "memberList", "[", "i", "]", ";", "if", "(", "m", "!=", "null", ")", "{", "s", ".", "add", "(", "m", ")", ";", "}", "}", "}", "}", "}" ]
adds any unresponsive members to s
train
false
69
private void initFromAuthHeader(String authHeader){ this.authHeader=authHeader; if (authHeader == null) throw new NullPointerException("No authentication header information"); Matcher authMatcher=SCHEME_PATTERN.matcher(authHeader); if (!authMatcher.matches()) { throw new IllegalStateException("Unable to parse auth header: " + authHeader); } scheme=authMatcher.group(1); if (authMatcher.groupCount() > 1) { Matcher paramMatcher=PARAM_PATTERN.matcher(authMatcher.group(2)); while (paramMatcher.find()) { String value=paramMatcher.group(2); if (value == null) { value=paramMatcher.group(3); } parameters.put(paramMatcher.group(1),value); } } }
[ "private", "void", "initFromAuthHeader", "(", "String", "authHeader", ")", "{", "this", ".", "authHeader", "=", "authHeader", ";", "if", "(", "authHeader", "==", "null", ")", "throw", "new", "NullPointerException", "(", "\"No authentication header information\"", ")", ";", "Matcher", "authMatcher", "=", "SCHEME_PATTERN", ".", "matcher", "(", "authHeader", ")", ";", "if", "(", "!", "authMatcher", ".", "matches", "(", ")", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Unable to parse auth header: \"", "+", "authHeader", ")", ";", "}", "scheme", "=", "authMatcher", ".", "group", "(", "1", ")", ";", "if", "(", "authMatcher", ".", "groupCount", "(", ")", ">", "1", ")", "{", "Matcher", "paramMatcher", "=", "PARAM_PATTERN", ".", "matcher", "(", "authMatcher", ".", "group", "(", "2", ")", ")", ";", "while", "(", "paramMatcher", ".", "find", "(", ")", ")", "{", "String", "value", "=", "paramMatcher", ".", "group", "(", "2", ")", ";", "if", "(", "value", "==", "null", ")", "{", "value", "=", "paramMatcher", ".", "group", "(", "3", ")", ";", "}", "parameters", ".", "put", "(", "paramMatcher", ".", "group", "(", "1", ")", ",", "value", ")", ";", "}", "}", "}" ]
initializes internal state from the contents of a www - authenticate header .
train
false
70
public String toString(){ String s="KeyIdentifier [\n"; HexDumpEncoder encoder=new HexDumpEncoder(); s+=encoder.encodeBuffer(octetString); s+="]\n"; return (s); }
[ "public", "String", "toString", "(", ")", "{", "String", "s", "=", "\"KeyIdentifier [\\n\"", ";", "HexDumpEncoder", "encoder", "=", "new", "HexDumpEncoder", "(", ")", ";", "s", "+=", "encoder", ".", "encodeBuffer", "(", "octetString", ")", ";", "s", "+=", "\"]\\n\"", ";", "return", "(", "s", ")", ";", "}" ]
returns a printable representation of the keyusage .
train
false
71
public static void addStartupListener(StartUpListener s){ s_startupListeners.add(s); }
[ "public", "static", "void", "addStartupListener", "(", "StartUpListener", "s", ")", "{", "s_startupListeners", ".", "add", "(", "s", ")", ";", "}" ]
add a listener to be notified when startup is complete
train
false
74
@Transactional public void save(final List<WorkFlowMatrix> actualWorkFlowMatrixDetails,final String[] departments){ for ( final String dept : departments) { for ( final WorkFlowMatrix workFlowMatrix : actualWorkFlowMatrixDetails) { final WorkFlowMatrix wfObj=workFlowMatrix.clone(); if (dept.equals(DEFAULT)) { wfObj.setDepartment("ANY"); } else { wfObj.setDepartment(dept); } workflowMatrixRepository.save(wfObj); } } }
[ "@", "Transactional", "public", "void", "save", "(", "final", "List", "<", "WorkFlowMatrix", ">", "actualWorkFlowMatrixDetails", ",", "final", "String", "[", "]", "departments", ")", "{", "for", "(", "final", "String", "dept", ":", "departments", ")", "{", "for", "(", "final", "WorkFlowMatrix", "workFlowMatrix", ":", "actualWorkFlowMatrixDetails", ")", "{", "final", "WorkFlowMatrix", "wfObj", "=", "workFlowMatrix", ".", "clone", "(", ")", ";", "if", "(", "dept", ".", "equals", "(", "DEFAULT", ")", ")", "{", "wfObj", ".", "setDepartment", "(", "\"ANY\"", ")", ";", "}", "else", "{", "wfObj", ".", "setDepartment", "(", "dept", ")", ";", "}", "workflowMatrixRepository", ".", "save", "(", "wfObj", ")", ";", "}", "}", "}" ]
this method saves the workflow matrix details for every department selected
train
false
75
public void write(String file) throws Exception { write(new File(file)); }
[ "public", "void", "write", "(", "String", "file", ")", "throws", "Exception", "{", "write", "(", "new", "File", "(", "file", ")", ")", ";", "}" ]
writes the current dom document into the given file .
train
false
77
private boolean extraEntity(String outputString,int charToMap){ boolean extra=false; if (charToMap < ASCII_MAX) { switch (charToMap) { case '"': if (!outputString.equals("&quot;")) extra=true; break; case '&': if (!outputString.equals("&amp;")) extra=true; break; case '<': if (!outputString.equals("&lt;")) extra=true; break; case '>': if (!outputString.equals("&gt;")) extra=true; break; default : extra=true; } } return extra; }
[ "private", "boolean", "extraEntity", "(", "String", "outputString", ",", "int", "charToMap", ")", "{", "boolean", "extra", "=", "false", ";", "if", "(", "charToMap", "<", "ASCII_MAX", ")", "{", "switch", "(", "charToMap", ")", "{", "case", "'\"'", ":", "if", "(", "!", "outputString", ".", "equals", "(", "\"&quot;\"", ")", ")", "extra", "=", "true", ";", "break", ";", "case", "'&'", ":", "if", "(", "!", "outputString", ".", "equals", "(", "\"&amp;\"", ")", ")", "extra", "=", "true", ";", "break", ";", "case", "'<'", ":", "if", "(", "!", "outputString", ".", "equals", "(", "\"&lt;\"", ")", ")", "extra", "=", "true", ";", "break", ";", "case", "'>'", ":", "if", "(", "!", "outputString", ".", "equals", "(", "\"&gt;\"", ")", ")", "extra", "=", "true", ";", "break", ";", "default", ":", "extra", "=", "true", ";", "}", "}", "return", "extra", ";", "}" ]
this method returns true if there are some non - standard mappings to entities other than quot , amp , lt , gt , and its only purpose is for performance .
train
true
78
public static String quoteIfNeeded(String s,String delim){ if (s == null) return null; if (s.length() == 0) return "\"\""; for (int i=0; i < s.length(); i++) { char c=s.charAt(i); if (c == '\\' || c == '"' || c == '\'' || Character.isWhitespace(c) || delim.indexOf(c) >= 0) { StringBuffer b=new StringBuffer(s.length() + 8); quote(b,s); return b.toString(); } } return s; }
[ "public", "static", "String", "quoteIfNeeded", "(", "String", "s", ",", "String", "delim", ")", "{", "if", "(", "s", "==", "null", ")", "return", "null", ";", "if", "(", "s", ".", "length", "(", ")", "==", "0", ")", "return", "\"\\\"\\\"\"", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "s", ".", "length", "(", ")", ";", "i", "++", ")", "{", "char", "c", "=", "s", ".", "charAt", "(", "i", ")", ";", "if", "(", "c", "==", "'\\\\'", "||", "c", "==", "'\"'", "||", "c", "==", "'\\''", "||", "Character", ".", "isWhitespace", "(", "c", ")", "||", "delim", ".", "indexOf", "(", "c", ")", ">=", "0", ")", "{", "StringBuffer", "b", "=", "new", "StringBuffer", "(", "s", ".", "length", "(", ")", "+", "8", ")", ";", "quote", "(", "b", ",", "s", ")", ";", "return", "b", ".", "toString", "(", ")", ";", "}", "}", "return", "s", ";", "}" ]
quote a string . the string is quoted only if quoting is required due to embedded delimiters , quote characters or the empty string .
train
true
79
public static void report(){ if (License.isDeveloper()) { for ( final Object obj : SPIES) { Diagnostic.developerLog(obj.toString()); } } }
[ "public", "static", "void", "report", "(", ")", "{", "if", "(", "License", ".", "isDeveloper", "(", ")", ")", "{", "for", "(", "final", "Object", "obj", ":", "SPIES", ")", "{", "Diagnostic", ".", "developerLog", "(", "obj", ".", "toString", "(", ")", ")", ";", "}", "}", "}" ]
generate a report to the log from all the current spies .
train
false
80
@Deprecated public void write(byte b[],int off,int len){ if (len < 0) throw new ArrayIndexOutOfBoundsException(len); for (int i=0; i < len; ++i) write(b[off + i]); }
[ "@", "Deprecated", "public", "void", "write", "(", "byte", "b", "[", "]", ",", "int", "off", ",", "int", "len", ")", "{", "if", "(", "len", "<", "0", ")", "throw", "new", "ArrayIndexOutOfBoundsException", "(", "len", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "len", ";", "++", "i", ")", "write", "(", "b", "[", "off", "+", "i", "]", ")", ";", "}" ]
write a subarray of bytes . pass each through write byte method .
train
false
83
public Cursor query(SQLiteDatabase db,String[] projectionIn,String selection,String[] selectionArgs,String groupBy,String having,String sortOrder,String limit){ if (mTables == null) { return null; } if (mStrict && selection != null && selection.length() > 0) { String sqlForValidation=buildQuery(projectionIn,"(" + selection + ")",groupBy,having,sortOrder,limit); validateSql(db,sqlForValidation); } String sql=buildQuery(projectionIn,selection,groupBy,having,sortOrder,limit); return db.rawQueryWithFactory(mFactory,sql,selectionArgs,SQLiteDatabase.findEditTable(mTables)); }
[ "public", "Cursor", "query", "(", "SQLiteDatabase", "db", ",", "String", "[", "]", "projectionIn", ",", "String", "selection", ",", "String", "[", "]", "selectionArgs", ",", "String", "groupBy", ",", "String", "having", ",", "String", "sortOrder", ",", "String", "limit", ")", "{", "if", "(", "mTables", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "mStrict", "&&", "selection", "!=", "null", "&&", "selection", ".", "length", "(", ")", ">", "0", ")", "{", "String", "sqlForValidation", "=", "buildQuery", "(", "projectionIn", ",", "\"(\"", "+", "selection", "+", "\")\"", ",", "groupBy", ",", "having", ",", "sortOrder", ",", "limit", ")", ";", "validateSql", "(", "db", ",", "sqlForValidation", ")", ";", "}", "String", "sql", "=", "buildQuery", "(", "projectionIn", ",", "selection", ",", "groupBy", ",", "having", ",", "sortOrder", ",", "limit", ")", ";", "return", "db", ".", "rawQueryWithFactory", "(", "mFactory", ",", "sql", ",", "selectionArgs", ",", "SQLiteDatabase", ".", "findEditTable", "(", "mTables", ")", ")", ";", "}" ]
perform a query by combining all current settings and the information passed into this method .
train
false
84
private static String replaceChars(String str){ StringBuffer buf=new StringBuffer(str); int length=buf.length(); for (int i=0; i < length; i++) { char currentChar=buf.charAt(i); if (currentChar == ' ') { buf.setCharAt(i,'%'); buf.insert(i + 1,"20"); length=length + 2; i=i + 2; } else if (currentChar == '\\') { buf.setCharAt(i,'/'); } } return buf.toString(); }
[ "private", "static", "String", "replaceChars", "(", "String", "str", ")", "{", "StringBuffer", "buf", "=", "new", "StringBuffer", "(", "str", ")", ";", "int", "length", "=", "buf", ".", "length", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "length", ";", "i", "++", ")", "{", "char", "currentChar", "=", "buf", ".", "charAt", "(", "i", ")", ";", "if", "(", "currentChar", "==", "' '", ")", "{", "buf", ".", "setCharAt", "(", "i", ",", "'%'", ")", ";", "buf", ".", "insert", "(", "i", "+", "1", ",", "\"20\"", ")", ";", "length", "=", "length", "+", "2", ";", "i", "=", "i", "+", "2", ";", "}", "else", "if", "(", "currentChar", "==", "'\\\\'", ")", "{", "buf", ".", "setCharAt", "(", "i", ",", "'/'", ")", ";", "}", "}", "return", "buf", ".", "toString", "(", ")", ";", "}" ]
replace spaces with " % 20 " and backslashes with forward slashes in the input string to generate a well - formed uri string .
train
true
85
public boolean isPaused(){ return false; }
[ "public", "boolean", "isPaused", "(", ")", "{", "return", "false", ";", "}" ]
whether or not the game is paused .
train
false
86
public Builder trustCertificates(KeyStore trustStore) throws GeneralSecurityException { SSLContext sslContext=SslUtils.getTlsSslContext(); SslUtils.initSslContext(sslContext,trustStore,SslUtils.getPkixTrustManagerFactory()); return setSslSocketFactory(sslContext.getSocketFactory()); }
[ "public", "Builder", "trustCertificates", "(", "KeyStore", "trustStore", ")", "throws", "GeneralSecurityException", "{", "SSLContext", "sslContext", "=", "SslUtils", ".", "getTlsSslContext", "(", ")", ";", "SslUtils", ".", "initSslContext", "(", "sslContext", ",", "trustStore", ",", "SslUtils", ".", "getPkixTrustManagerFactory", "(", ")", ")", ";", "return", "setSslSocketFactory", "(", "sslContext", ".", "getSocketFactory", "(", ")", ")", ";", "}" ]
sets the ssl socket factory based on a root certificate trust store .
train
false
87
public void rejectReInvite(int code){ if (sLogger.isActivated()) { sLogger.debug("ReInvite has been rejected"); } synchronized (mWaitUserAnswer) { mReInviteStatus=InvitationStatus.INVITATION_REJECTED; mWaitUserAnswer.notifyAll(); } }
[ "public", "void", "rejectReInvite", "(", "int", "code", ")", "{", "if", "(", "sLogger", ".", "isActivated", "(", ")", ")", "{", "sLogger", ".", "debug", "(", "\"ReInvite has been rejected\"", ")", ";", "}", "synchronized", "(", "mWaitUserAnswer", ")", "{", "mReInviteStatus", "=", "InvitationStatus", ".", "INVITATION_REJECTED", ";", "mWaitUserAnswer", ".", "notifyAll", "(", ")", ";", "}", "}" ]
reject the session invitation
train
false
89
public boolean isPrune(){ return prune; }
[ "public", "boolean", "isPrune", "(", ")", "{", "return", "prune", ";", "}" ]
returns the value of the prune attribute .
train
false
90
public void enqueueNormal(String methodName,int count){ Deque<InvocationHandler> handlers=getHandlers(methodName); for (int i=0; i < count; i++) { handlers.add(delegateHandler); } }
[ "public", "void", "enqueueNormal", "(", "String", "methodName", ",", "int", "count", ")", "{", "Deque", "<", "InvocationHandler", ">", "handlers", "=", "getHandlers", "(", "methodName", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "count", ";", "i", "++", ")", "{", "handlers", ".", "add", "(", "delegateHandler", ")", ";", "}", "}" ]
enqueues the specified number of normal operations . useful to delay faults .
train
false
91
@SuppressWarnings("unchecked") @Override protected Object readPostProcess(Object o) throws Exception { Enumeration<Object> enm; Vector<Vector<?>> deserialized; Object key; deserialized=(Vector<Vector<?>>)super.readPostProcess(o); rebuildBeanConnections(deserialized,REGULAR_CONNECTION); enm=m_BeanConnectionRelation.keys(); while (enm.hasMoreElements()) { key=enm.nextElement(); if (!(key instanceof MetaBean)) { continue; } rebuildBeanConnections(deserialized,key); } if (getDataType() == DATATYPE_USERCOMPONENTS) { removeUserToolBarBeans(deserialized); } return deserialized; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "@", "Override", "protected", "Object", "readPostProcess", "(", "Object", "o", ")", "throws", "Exception", "{", "Enumeration", "<", "Object", ">", "enm", ";", "Vector", "<", "Vector", "<", "?", ">", ">", "deserialized", ";", "Object", "key", ";", "deserialized", "=", "(", "Vector", "<", "Vector", "<", "?", ">", ">", ")", "super", ".", "readPostProcess", "(", "o", ")", ";", "rebuildBeanConnections", "(", "deserialized", ",", "REGULAR_CONNECTION", ")", ";", "enm", "=", "m_BeanConnectionRelation", ".", "keys", "(", ")", ";", "while", "(", "enm", ".", "hasMoreElements", "(", ")", ")", "{", "key", "=", "enm", ".", "nextElement", "(", ")", ";", "if", "(", "!", "(", "key", "instanceof", "MetaBean", ")", ")", "{", "continue", ";", "}", "rebuildBeanConnections", "(", "deserialized", ",", "key", ")", ";", "}", "if", "(", "getDataType", "(", ")", "==", "DATATYPE_USERCOMPONENTS", ")", "{", "removeUserToolBarBeans", "(", "deserialized", ")", ";", "}", "return", "deserialized", ";", "}" ]
additional post - processing can happen in derived classes after reading from xml . re - builds the beanconnections .
train
false
92
public static boolean canSee(IGame game,Entity ae,Targetable target){ return canSee(game,ae,target,true,null,null); }
[ "public", "static", "boolean", "canSee", "(", "IGame", "game", ",", "Entity", "ae", ",", "Targetable", "target", ")", "{", "return", "canSee", "(", "game", ",", "ae", ",", "target", ",", "true", ",", "null", ",", "null", ")", ";", "}" ]
checks to see if the target is visible to the unit , always considering sensors .
train
false
93
@Override void toXML(StringBuilder xml,int level){ indent(xml,level); xml.append("<string>"); for (int i=0; i < bytes.length; i++) { byte b=bytes[i]; if (b < 16) xml.append('0'); xml.append(Integer.toHexString(b)); } xml.append("</string>"); }
[ "@", "Override", "void", "toXML", "(", "StringBuilder", "xml", ",", "int", "level", ")", "{", "indent", "(", "xml", ",", "level", ")", ";", "xml", ".", "append", "(", "\"<string>\"", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "bytes", ".", "length", ";", "i", "++", ")", "{", "byte", "b", "=", "bytes", "[", "i", "]", ";", "if", "(", "b", "<", "16", ")", "xml", ".", "append", "(", "'0'", ")", ";", "xml", ".", "append", "(", "Integer", ".", "toHexString", "(", "b", ")", ")", ";", "}", "xml", ".", "append", "(", "\"</string>\"", ")", ";", "}" ]
there is no xml representation specified for uids . in this implementation uids are represented as strings in the xml output .
train
false
94
public final int readLine(char[] buf,int length,boolean isChop) throws IOException { byte[] readBuffer=_readBuffer; int offset=0; while (true) { int readOffset=_readOffset; int sublen=Math.min(length,_readLength - readOffset); for (; sublen > 0; sublen--) { int ch=readBuffer[readOffset++] & 0xff; if (ch != '\n') { } else if (isChop) { _readOffset=readOffset; if (offset > 0 && buf[offset - 1] == '\r') return offset - 1; else return offset; } else { buf[offset++]=(char)ch; _readOffset=readOffset; return offset + 1; } buf[offset++]=(char)ch; } _readOffset=readOffset; if (readOffset <= _readLength) { if (!readBuffer()) { return offset; } } if (length <= offset) return length + 1; } }
[ "public", "final", "int", "readLine", "(", "char", "[", "]", "buf", ",", "int", "length", ",", "boolean", "isChop", ")", "throws", "IOException", "{", "byte", "[", "]", "readBuffer", "=", "_readBuffer", ";", "int", "offset", "=", "0", ";", "while", "(", "true", ")", "{", "int", "readOffset", "=", "_readOffset", ";", "int", "sublen", "=", "Math", ".", "min", "(", "length", ",", "_readLength", "-", "readOffset", ")", ";", "for", "(", ";", "sublen", ">", "0", ";", "sublen", "--", ")", "{", "int", "ch", "=", "readBuffer", "[", "readOffset", "++", "]", "&", "0xff", ";", "if", "(", "ch", "!=", "'\\n'", ")", "{", "}", "else", "if", "(", "isChop", ")", "{", "_readOffset", "=", "readOffset", ";", "if", "(", "offset", ">", "0", "&&", "buf", "[", "offset", "-", "1", "]", "==", "'\\r'", ")", "return", "offset", "-", "1", ";", "else", "return", "offset", ";", "}", "else", "{", "buf", "[", "offset", "++", "]", "=", "(", "char", ")", "ch", ";", "_readOffset", "=", "readOffset", ";", "return", "offset", "+", "1", ";", "}", "buf", "[", "offset", "++", "]", "=", "(", "char", ")", "ch", ";", "}", "_readOffset", "=", "readOffset", ";", "if", "(", "readOffset", "<=", "_readLength", ")", "{", "if", "(", "!", "readBuffer", "(", ")", ")", "{", "return", "offset", ";", "}", "}", "if", "(", "length", "<=", "offset", ")", "return", "length", "+", "1", ";", "}", "}" ]
reads a line into the character buffer . \ r \ n is converted to \ n .
train
true
95
public static void gotoOffset(final CDebugPerspectiveModel model,final IAddress offset,final boolean focusMemoryWindow){ model.setActiveMemoryAddress(offset,focusMemoryWindow); }
[ "public", "static", "void", "gotoOffset", "(", "final", "CDebugPerspectiveModel", "model", ",", "final", "IAddress", "offset", ",", "final", "boolean", "focusMemoryWindow", ")", "{", "model", ".", "setActiveMemoryAddress", "(", "offset", ",", "focusMemoryWindow", ")", ";", "}" ]
sets the caret of a hex control to a given offset .
train
false
96
public List<AbstractCondition> toConditionsList(){ List<AbstractCondition> list=new ArrayList<>(); for ( Node<AbstractCondition> node : toList()) { list.add(node.getData()); } return list; }
[ "public", "List", "<", "AbstractCondition", ">", "toConditionsList", "(", ")", "{", "List", "<", "AbstractCondition", ">", "list", "=", "new", "ArrayList", "<", ">", "(", ")", ";", "for", "(", "Node", "<", "AbstractCondition", ">", "node", ":", "toList", "(", ")", ")", "{", "list", ".", "add", "(", "node", ".", "getData", "(", ")", ")", ";", "}", "return", "list", ";", "}" ]
get all conditions as a plain list .
train
false
97
protected void initBatchBuffer(){ try { if (!isIncremental()) { m_BatchBuffer=m_Loader.getDataSet(); } else { m_BatchBuffer=null; } } catch ( Exception e) { e.printStackTrace(); } }
[ "protected", "void", "initBatchBuffer", "(", ")", "{", "try", "{", "if", "(", "!", "isIncremental", "(", ")", ")", "{", "m_BatchBuffer", "=", "m_Loader", ".", "getDataSet", "(", ")", ";", "}", "else", "{", "m_BatchBuffer", "=", "null", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}" ]
initializes the batch buffer if necessary , i . e . , for non - incremental loaders .
train
false
98
public BigdataSailRepositoryConnection cxn(){ return tlTx.get(); }
[ "public", "BigdataSailRepositoryConnection", "cxn", "(", ")", "{", "return", "tlTx", ".", "get", "(", ")", ";", "}" ]
direct access to the unisolated connection . may return null if the connection has not been opened yet by this thread .
train
false
99
public void processConnection(DataInputStream dis,DataOutputStream dosParam) throws IOException, Exception { GZIPOutputStream gzip=new GZIPOutputStream(new BufferedOutputStream(dosParam)); DataOutputStream dos=new DataOutputStream(gzip); byte responseStatus=ResponseStatus.STATUS_ERROR; try { ByteArrayOutputStream baos=new ByteArrayOutputStream(); String name=dis.readUTF(); String pw=dis.readUTF(); String serializer=dis.readUTF(); @SuppressWarnings("unused") String locale=dis.readUTF(); byte action=dis.readByte(); Context.openSession(); try { Context.authenticate(name,pw); } catch ( ContextAuthenticationException ex) { responseStatus=ResponseStatus.STATUS_ACCESS_DENIED; } if (responseStatus != ResponseStatus.STATUS_ACCESS_DENIED) { DataOutputStream dosTemp=new DataOutputStream(baos); if (action == ACTION_DOWNLOAD_PATIENTS) downloadPatients(String.valueOf(dis.readInt()),dosTemp,serializer,false); else if (action == ACTION_DOWNLOAD_SS_PATIENTS) downloadPatients(String.valueOf(dis.readInt()),dosTemp,serializer,true); else if (action == ACTION_DOWNLOAD_COHORTS) PatientDownloadManager.downloadCohorts(dosTemp,serializer); else if (action == ACTION_DOWNLOAD_SAVED_SEARCHES) PatientDownloadManager.downloadSavesSearches(dosTemp,serializer); else if (action == ACTION_DOWNLOAD_FORMS) XformDownloadManager.downloadXforms(dosTemp,serializer); else if (action == ACTION_UPLOAD_FORMS) submitXforms(dis,dosTemp,serializer); else if (action == ACTION_DOWNLOAD_USERS) UserDownloadManager.downloadUsers(dosTemp,serializer); else if (action == ACTION_DOWNLOAD_USERS_AND_FORMS) downloadUsersAndForms(dosTemp,serializer); else if (action == ACTION_DOWNLOAD_FILTERED_PATIENTS) downloadPatients(dis.readUTF(),dis.readUTF(),dosTemp,serializer); responseStatus=ResponseStatus.STATUS_SUCCESS; } dos.writeByte(responseStatus); if (responseStatus == ResponseStatus.STATUS_SUCCESS) dos.write(baos.toByteArray()); dos.close(); gzip.finish(); } catch ( Exception ex) { log.error(ex.getMessage(),ex); try { dos.writeByte(responseStatus); dos.flush(); gzip.finish(); } catch ( Exception e) { e.printStackTrace(); } } finally { Context.closeSession(); } }
[ "public", "void", "processConnection", "(", "DataInputStream", "dis", ",", "DataOutputStream", "dosParam", ")", "throws", "IOException", ",", "Exception", "{", "GZIPOutputStream", "gzip", "=", "new", "GZIPOutputStream", "(", "new", "BufferedOutputStream", "(", "dosParam", ")", ")", ";", "DataOutputStream", "dos", "=", "new", "DataOutputStream", "(", "gzip", ")", ";", "byte", "responseStatus", "=", "ResponseStatus", ".", "STATUS_ERROR", ";", "try", "{", "ByteArrayOutputStream", "baos", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "String", "name", "=", "dis", ".", "readUTF", "(", ")", ";", "String", "pw", "=", "dis", ".", "readUTF", "(", ")", ";", "String", "serializer", "=", "dis", ".", "readUTF", "(", ")", ";", "@", "SuppressWarnings", "(", "\"unused\"", ")", "String", "locale", "=", "dis", ".", "readUTF", "(", ")", ";", "byte", "action", "=", "dis", ".", "readByte", "(", ")", ";", "Context", ".", "openSession", "(", ")", ";", "try", "{", "Context", ".", "authenticate", "(", "name", ",", "pw", ")", ";", "}", "catch", "(", "ContextAuthenticationException", "ex", ")", "{", "responseStatus", "=", "ResponseStatus", ".", "STATUS_ACCESS_DENIED", ";", "}", "if", "(", "responseStatus", "!=", "ResponseStatus", ".", "STATUS_ACCESS_DENIED", ")", "{", "DataOutputStream", "dosTemp", "=", "new", "DataOutputStream", "(", "baos", ")", ";", "if", "(", "action", "==", "ACTION_DOWNLOAD_PATIENTS", ")", "downloadPatients", "(", "String", ".", "valueOf", "(", "dis", ".", "readInt", "(", ")", ")", ",", "dosTemp", ",", "serializer", ",", "false", ")", ";", "else", "if", "(", "action", "==", "ACTION_DOWNLOAD_SS_PATIENTS", ")", "downloadPatients", "(", "String", ".", "valueOf", "(", "dis", ".", "readInt", "(", ")", ")", ",", "dosTemp", ",", "serializer", ",", "true", ")", ";", "else", "if", "(", "action", "==", "ACTION_DOWNLOAD_COHORTS", ")", "PatientDownloadManager", ".", "downloadCohorts", "(", "dosTemp", ",", "serializer", ")", ";", "else", "if", "(", "action", "==", "ACTION_DOWNLOAD_SAVED_SEARCHES", ")", "PatientDownloadManager", ".", "downloadSavesSearches", "(", "dosTemp", ",", "serializer", ")", ";", "else", "if", "(", "action", "==", "ACTION_DOWNLOAD_FORMS", ")", "XformDownloadManager", ".", "downloadXforms", "(", "dosTemp", ",", "serializer", ")", ";", "else", "if", "(", "action", "==", "ACTION_UPLOAD_FORMS", ")", "submitXforms", "(", "dis", ",", "dosTemp", ",", "serializer", ")", ";", "else", "if", "(", "action", "==", "ACTION_DOWNLOAD_USERS", ")", "UserDownloadManager", ".", "downloadUsers", "(", "dosTemp", ",", "serializer", ")", ";", "else", "if", "(", "action", "==", "ACTION_DOWNLOAD_USERS_AND_FORMS", ")", "downloadUsersAndForms", "(", "dosTemp", ",", "serializer", ")", ";", "else", "if", "(", "action", "==", "ACTION_DOWNLOAD_FILTERED_PATIENTS", ")", "downloadPatients", "(", "dis", ".", "readUTF", "(", ")", ",", "dis", ".", "readUTF", "(", ")", ",", "dosTemp", ",", "serializer", ")", ";", "responseStatus", "=", "ResponseStatus", ".", "STATUS_SUCCESS", ";", "}", "dos", ".", "writeByte", "(", "responseStatus", ")", ";", "if", "(", "responseStatus", "==", "ResponseStatus", ".", "STATUS_SUCCESS", ")", "dos", ".", "write", "(", "baos", ".", "toByteArray", "(", ")", ")", ";", "dos", ".", "close", "(", ")", ";", "gzip", ".", "finish", "(", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "log", ".", "error", "(", "ex", ".", "getMessage", "(", ")", ",", "ex", ")", ";", "try", "{", "dos", ".", "writeByte", "(", "responseStatus", ")", ";", "dos", ".", "flush", "(", ")", ";", "gzip", ".", "finish", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "finally", "{", "Context", ".", "closeSession", "(", ")", ";", "}", "}" ]
called when a new connection has been received . failures are not handled in this class as different servers ( bt , sms , etc ) may want to handle them differently .
train
false
100
public static int hashObject(Object o){ return o == null ? 0 : o.hashCode(); }
[ "public", "static", "int", "hashObject", "(", "Object", "o", ")", "{", "return", "o", "==", "null", "?", "0", ":", "o", ".", "hashCode", "(", ")", ";", "}" ]
null - safe hash code method for objects . returns the object hash code if it is not null , and 0 otherwise .
train
false
101
boolean needToCheckExclude(){ return false; }
[ "boolean", "needToCheckExclude", "(", ")", "{", "return", "false", ";", "}" ]
return whether we need to check namespace prefixes against and exclude result prefixes list .
train
false
103
public Area(final StendhalRPZone zone,int x,int y,int width,int height){ this.zone=zone; final Rectangle2D myshape=new Rectangle2D.Double(); myshape.setRect(x,y,width,height); this.shape=myshape; }
[ "public", "Area", "(", "final", "StendhalRPZone", "zone", ",", "int", "x", ",", "int", "y", ",", "int", "width", ",", "int", "height", ")", "{", "this", ".", "zone", "=", "zone", ";", "final", "Rectangle2D", "myshape", "=", "new", "Rectangle2D", ".", "Double", "(", ")", ";", "myshape", ".", "setRect", "(", "x", ",", "y", ",", "width", ",", "height", ")", ";", "this", ".", "shape", "=", "myshape", ";", "}" ]
creates a new area .
train
false
104
private byte nextTC() throws IOException { if (hasPushbackTC) { hasPushbackTC=false; } else { pushbackTC=input.readByte(); } return pushbackTC; }
[ "private", "byte", "nextTC", "(", ")", "throws", "IOException", "{", "if", "(", "hasPushbackTC", ")", "{", "hasPushbackTC", "=", "false", ";", "}", "else", "{", "pushbackTC", "=", "input", ".", "readByte", "(", ")", ";", "}", "return", "pushbackTC", ";", "}" ]
return the next token code ( tc ) from the receiver , which indicates what kind of object follows
train
false
105
private void newline(){ print("\n"); }
[ "private", "void", "newline", "(", ")", "{", "print", "(", "\"\\n\"", ")", ";", "}" ]
put the line separator string onto the print stream .
train
false
106
public int size(){ return seq.size(); }
[ "public", "int", "size", "(", ")", "{", "return", "seq", ".", "size", "(", ")", ";", "}" ]
return the number of objects in this sequence .
train
false
107
public static String digestString(String pass,String algorithm) throws NoSuchAlgorithmException { MessageDigest md; ByteArrayOutputStream bos; try { md=MessageDigest.getInstance(algorithm); byte[] digest=md.digest(pass.getBytes("iso-8859-1")); bos=new ByteArrayOutputStream(); OutputStream encodedStream=MimeUtility.encode(bos,"base64"); encodedStream.write(digest); return bos.toString("iso-8859-1"); } catch ( IOException ioe) { throw new RuntimeException("Fatal error: " + ioe); } catch ( MessagingException me) { throw new RuntimeException("Fatal error: " + me); } }
[ "public", "static", "String", "digestString", "(", "String", "pass", ",", "String", "algorithm", ")", "throws", "NoSuchAlgorithmException", "{", "MessageDigest", "md", ";", "ByteArrayOutputStream", "bos", ";", "try", "{", "md", "=", "MessageDigest", ".", "getInstance", "(", "algorithm", ")", ";", "byte", "[", "]", "digest", "=", "md", ".", "digest", "(", "pass", ".", "getBytes", "(", "\"iso-8859-1\"", ")", ")", ";", "bos", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "OutputStream", "encodedStream", "=", "MimeUtility", ".", "encode", "(", "bos", ",", "\"base64\"", ")", ";", "encodedStream", ".", "write", "(", "digest", ")", ";", "return", "bos", ".", "toString", "(", "\"iso-8859-1\"", ")", ";", "}", "catch", "(", "IOException", "ioe", ")", "{", "throw", "new", "RuntimeException", "(", "\"Fatal error: \"", "+", "ioe", ")", ";", "}", "catch", "(", "MessagingException", "me", ")", "{", "throw", "new", "RuntimeException", "(", "\"Fatal error: \"", "+", "me", ")", ";", "}", "}" ]
calculate digest of given string using given algorithm . encode digest in mime - like base64 .
train
false
108
void storeBlock(long lobId,int seq,long pos,byte[] b,String compressAlgorithm) throws SQLException { long block; boolean blockExists=false; if (compressAlgorithm != null) { b=compress.compress(b,compressAlgorithm); } int hash=Arrays.hashCode(b); assertHoldsLock(conn.getSession()); assertHoldsLock(database); block=getHashCacheBlock(hash); if (block != -1) { String sql="SELECT COMPRESSED, DATA FROM " + LOB_DATA + " WHERE BLOCK = ?"; PreparedStatement prep=prepare(sql); prep.setLong(1,block); ResultSet rs=prep.executeQuery(); if (rs.next()) { boolean compressed=rs.getInt(1) != 0; byte[] compare=rs.getBytes(2); if (compressed == (compressAlgorithm != null) && Arrays.equals(b,compare)) { blockExists=true; } } reuse(sql,prep); } if (!blockExists) { block=nextBlock++; setHashCacheBlock(hash,block); String sql="INSERT INTO " + LOB_DATA + "(BLOCK, COMPRESSED, DATA) VALUES(?, ?, ?)"; PreparedStatement prep=prepare(sql); prep.setLong(1,block); prep.setInt(2,compressAlgorithm == null ? 0 : 1); prep.setBytes(3,b); prep.execute(); reuse(sql,prep); } String sql="INSERT INTO " + LOB_MAP + "(LOB, SEQ, POS, HASH, BLOCK) VALUES(?, ?, ?, ?, ?)"; PreparedStatement prep=prepare(sql); prep.setLong(1,lobId); prep.setInt(2,seq); prep.setLong(3,pos); prep.setLong(4,hash); prep.setLong(5,block); prep.execute(); reuse(sql,prep); }
[ "void", "storeBlock", "(", "long", "lobId", ",", "int", "seq", ",", "long", "pos", ",", "byte", "[", "]", "b", ",", "String", "compressAlgorithm", ")", "throws", "SQLException", "{", "long", "block", ";", "boolean", "blockExists", "=", "false", ";", "if", "(", "compressAlgorithm", "!=", "null", ")", "{", "b", "=", "compress", ".", "compress", "(", "b", ",", "compressAlgorithm", ")", ";", "}", "int", "hash", "=", "Arrays", ".", "hashCode", "(", "b", ")", ";", "assertHoldsLock", "(", "conn", ".", "getSession", "(", ")", ")", ";", "assertHoldsLock", "(", "database", ")", ";", "block", "=", "getHashCacheBlock", "(", "hash", ")", ";", "if", "(", "block", "!=", "-", "1", ")", "{", "String", "sql", "=", "\"SELECT COMPRESSED, DATA FROM \"", "+", "LOB_DATA", "+", "\" WHERE BLOCK = ?\"", ";", "PreparedStatement", "prep", "=", "prepare", "(", "sql", ")", ";", "prep", ".", "setLong", "(", "1", ",", "block", ")", ";", "ResultSet", "rs", "=", "prep", ".", "executeQuery", "(", ")", ";", "if", "(", "rs", ".", "next", "(", ")", ")", "{", "boolean", "compressed", "=", "rs", ".", "getInt", "(", "1", ")", "!=", "0", ";", "byte", "[", "]", "compare", "=", "rs", ".", "getBytes", "(", "2", ")", ";", "if", "(", "compressed", "==", "(", "compressAlgorithm", "!=", "null", ")", "&&", "Arrays", ".", "equals", "(", "b", ",", "compare", ")", ")", "{", "blockExists", "=", "true", ";", "}", "}", "reuse", "(", "sql", ",", "prep", ")", ";", "}", "if", "(", "!", "blockExists", ")", "{", "block", "=", "nextBlock", "++", ";", "setHashCacheBlock", "(", "hash", ",", "block", ")", ";", "String", "sql", "=", "\"INSERT INTO \"", "+", "LOB_DATA", "+", "\"(BLOCK, COMPRESSED, DATA) VALUES(?, ?, ?)\"", ";", "PreparedStatement", "prep", "=", "prepare", "(", "sql", ")", ";", "prep", ".", "setLong", "(", "1", ",", "block", ")", ";", "prep", ".", "setInt", "(", "2", ",", "compressAlgorithm", "==", "null", "?", "0", ":", "1", ")", ";", "prep", ".", "setBytes", "(", "3", ",", "b", ")", ";", "prep", ".", "execute", "(", ")", ";", "reuse", "(", "sql", ",", "prep", ")", ";", "}", "String", "sql", "=", "\"INSERT INTO \"", "+", "LOB_MAP", "+", "\"(LOB, SEQ, POS, HASH, BLOCK) VALUES(?, ?, ?, ?, ?)\"", ";", "PreparedStatement", "prep", "=", "prepare", "(", "sql", ")", ";", "prep", ".", "setLong", "(", "1", ",", "lobId", ")", ";", "prep", ".", "setInt", "(", "2", ",", "seq", ")", ";", "prep", ".", "setLong", "(", "3", ",", "pos", ")", ";", "prep", ".", "setLong", "(", "4", ",", "hash", ")", ";", "prep", ".", "setLong", "(", "5", ",", "block", ")", ";", "prep", ".", "execute", "(", ")", ";", "reuse", "(", "sql", ",", "prep", ")", ";", "}" ]
store a block in the lob storage .
train
false
109
public static boolean isDirectory(String path){ File f=new File(path); return f.isDirectory(); }
[ "public", "static", "boolean", "isDirectory", "(", "String", "path", ")", "{", "File", "f", "=", "new", "File", "(", "path", ")", ";", "return", "f", ".", "isDirectory", "(", ")", ";", "}" ]
checks if the given path is a directory
train
false
111
static void transformKillSlot(final RPObject object){ final RPObject kills=KeyedSlotUtil.getKeyedSlotObject(object,"!kills"); if (kills != null) { final RPObject newKills=new RPObject(); for ( final String attr : kills) { if (!attr.equals("id")) { String newAttr=attr; String value=kills.get(attr); if (attr.indexOf('.') < 0) { newAttr=updateItemName(newAttr); newAttr=value + "." + newAttr; value="1"; } newKills.put(newAttr,value); } } final RPSlot slot=object.getSlot("!kills"); slot.remove(kills.getID()); slot.add(newKills); } }
[ "static", "void", "transformKillSlot", "(", "final", "RPObject", "object", ")", "{", "final", "RPObject", "kills", "=", "KeyedSlotUtil", ".", "getKeyedSlotObject", "(", "object", ",", "\"!kills\"", ")", ";", "if", "(", "kills", "!=", "null", ")", "{", "final", "RPObject", "newKills", "=", "new", "RPObject", "(", ")", ";", "for", "(", "final", "String", "attr", ":", "kills", ")", "{", "if", "(", "!", "attr", ".", "equals", "(", "\"id\"", ")", ")", "{", "String", "newAttr", "=", "attr", ";", "String", "value", "=", "kills", ".", "get", "(", "attr", ")", ";", "if", "(", "attr", ".", "indexOf", "(", "'.'", ")", "<", "0", ")", "{", "newAttr", "=", "updateItemName", "(", "newAttr", ")", ";", "newAttr", "=", "value", "+", "\".\"", "+", "newAttr", ";", "value", "=", "\"1\"", ";", "}", "newKills", ".", "put", "(", "newAttr", ",", "value", ")", ";", "}", "}", "final", "RPSlot", "slot", "=", "object", ".", "getSlot", "(", "\"!kills\"", ")", ";", "slot", ".", "remove", "(", "kills", ".", "getID", "(", ")", ")", ";", "slot", ".", "add", "(", "newKills", ")", ";", "}", "}" ]
transform kill slot content to the new kill recording system .
train
false
112
public static CharSequence trimTrailingWhitespace(CharSequence source){ if (source == null) return ""; int i=source.length(); while (--i >= 0 && Character.isWhitespace(source.charAt(i))) { } return source.subSequence(0,i + 1); }
[ "public", "static", "CharSequence", "trimTrailingWhitespace", "(", "CharSequence", "source", ")", "{", "if", "(", "source", "==", "null", ")", "return", "\"\"", ";", "int", "i", "=", "source", ".", "length", "(", ")", ";", "while", "(", "--", "i", ">=", "0", "&&", "Character", ".", "isWhitespace", "(", "source", ".", "charAt", "(", "i", ")", ")", ")", "{", "}", "return", "source", ".", "subSequence", "(", "0", ",", "i", "+", "1", ")", ";", "}" ]
trims trailing whitespace . removes any of these characters : 0009 , horizontal tabulation 000a , line feed 000b , vertical tabulation 000c , form feed 000d , carriage return 001c , file separator 001d , group separator 001e , record separator 001f , unit separator
train
false
113
private static void WriteStringVectorToFile(Vector inputVec,String fileName) throws StringVectorToFileException { try { BufferedWriter fileW=new BufferedWriter(new FileWriter(fileName)); int lineNum=0; while (lineNum < inputVec.size()) { fileW.write((String)inputVec.elementAt(lineNum)); fileW.newLine(); lineNum=lineNum + 1; } ; fileW.close(); } catch ( Exception e) { throw new StringVectorToFileException("Could not write file " + fileName); } ; }
[ "private", "static", "void", "WriteStringVectorToFile", "(", "Vector", "inputVec", ",", "String", "fileName", ")", "throws", "StringVectorToFileException", "{", "try", "{", "BufferedWriter", "fileW", "=", "new", "BufferedWriter", "(", "new", "FileWriter", "(", "fileName", ")", ")", ";", "int", "lineNum", "=", "0", ";", "while", "(", "lineNum", "<", "inputVec", ".", "size", "(", ")", ")", "{", "fileW", ".", "write", "(", "(", "String", ")", "inputVec", ".", "elementAt", "(", "lineNum", ")", ")", ";", "fileW", ".", "newLine", "(", ")", ";", "lineNum", "=", "lineNum", "+", "1", ";", "}", ";", "fileW", ".", "close", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "StringVectorToFileException", "(", "\"Could not write file \"", "+", "fileName", ")", ";", "}", ";", "}" ]
methods for reading and writing files
train
false
114
public boolean before(String userDefinedValue) throws IllegalArgumentException { try { return value.before(getDate(userDefinedValue)); } catch ( DataTypeValidationException e) { throw new IllegalArgumentException(e.getMessage()); } }
[ "public", "boolean", "before", "(", "String", "userDefinedValue", ")", "throws", "IllegalArgumentException", "{", "try", "{", "return", "value", ".", "before", "(", "getDate", "(", "userDefinedValue", ")", ")", ";", "}", "catch", "(", "DataTypeValidationException", "e", ")", "{", "throw", "new", "IllegalArgumentException", "(", "e", ".", "getMessage", "(", ")", ")", ";", "}", "}" ]
indicates whether or not provided value is before .
train
false
115
public void close(){ if (null != inputStreamReader) { CarbonUtil.closeStreams(inputStreamReader); } }
[ "public", "void", "close", "(", ")", "{", "if", "(", "null", "!=", "inputStreamReader", ")", "{", "CarbonUtil", ".", "closeStreams", "(", "inputStreamReader", ")", ";", "}", "}" ]
below method will be used to clear all the stream
train
false
116
public static double exponent(Object left,Object right) throws PageException { return StrictMath.pow(Caster.toDoubleValue(left),Caster.toDoubleValue(right)); }
[ "public", "static", "double", "exponent", "(", "Object", "left", ",", "Object", "right", ")", "throws", "PageException", "{", "return", "StrictMath", ".", "pow", "(", "Caster", ".", "toDoubleValue", "(", "left", ")", ",", "Caster", ".", "toDoubleValue", "(", "right", ")", ")", ";", "}" ]
calculate the exponent of the left value
train
true
117
public synchronized void addActionListener(ActionListener actionListener){ if (actionListeners == null) actionListeners=new ArrayList<ActionListener>(); actionListeners.add(actionListener); if (fired) { actionListener.actionPerformed(new ActionEvent(this,ActionEvent.ACTION_PERFORMED,"")); } }
[ "public", "synchronized", "void", "addActionListener", "(", "ActionListener", "actionListener", ")", "{", "if", "(", "actionListeners", "==", "null", ")", "actionListeners", "=", "new", "ArrayList", "<", "ActionListener", ">", "(", ")", ";", "actionListeners", ".", "add", "(", "actionListener", ")", ";", "if", "(", "fired", ")", "{", "actionListener", ".", "actionPerformed", "(", "new", "ActionEvent", "(", "this", ",", "ActionEvent", ".", "ACTION_PERFORMED", ",", "\"\"", ")", ")", ";", "}", "}" ]
adds a listener that will be notified upon completion of all of the running threads . its actionperformed method will be called immediately if the threads already finished .
train
false
118
public String writeDataFile() throws DataFileException { ByteArrayOutputStream bos=new ByteArrayOutputStream(); writeDataFile(bos); String outString=bos.toString(); try { if (bos != null) bos.close(); } catch ( IOException e) { Debug.logWarning(e,module); } return outString; }
[ "public", "String", "writeDataFile", "(", ")", "throws", "DataFileException", "{", "ByteArrayOutputStream", "bos", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "writeDataFile", "(", "bos", ")", ";", "String", "outString", "=", "bos", ".", "toString", "(", ")", ";", "try", "{", "if", "(", "bos", "!=", "null", ")", "bos", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "Debug", ".", "logWarning", "(", "e", ",", "module", ")", ";", "}", "return", "outString", ";", "}" ]
returns the records in this datafile object as a plain text data file content
train
false
119
public static Color determineBackgroundColor(final INaviInstruction startInstruction,final String trackedRegister,final CInstructionResult result){ Preconditions.checkNotNull(startInstruction,"IE01671: Start instruction argument can not be null"); Preconditions.checkNotNull(trackedRegister,"IE01672: Tracked register argument can not be null"); Preconditions.checkNotNull(result,"IE01673: Result argument can not be null"); if (result.getInstruction() == startInstruction) { return Color.decode("0x00BF00"); } else if (result.undefinesAll()) { return Color.decode("0xB30000"); } else if (result.clearsTrackedRegister(trackedRegister)) { return Color.decode("0xA12967"); } else if (result.undefinesSome()) { return Color.decode("0xED693F"); } else if (result.defines()) { return Color.decode("0xFFCD55"); } else if (result.updates()) { return Color.decode("0x5AAB47"); } else if (result.uses()) { return Color.decode("0x414142"); } else { return Color.WHITE; } }
[ "public", "static", "Color", "determineBackgroundColor", "(", "final", "INaviInstruction", "startInstruction", ",", "final", "String", "trackedRegister", ",", "final", "CInstructionResult", "result", ")", "{", "Preconditions", ".", "checkNotNull", "(", "startInstruction", ",", "\"IE01671: Start instruction argument can not be null\"", ")", ";", "Preconditions", ".", "checkNotNull", "(", "trackedRegister", ",", "\"IE01672: Tracked register argument can not be null\"", ")", ";", "Preconditions", ".", "checkNotNull", "(", "result", ",", "\"IE01673: Result argument can not be null\"", ")", ";", "if", "(", "result", ".", "getInstruction", "(", ")", "==", "startInstruction", ")", "{", "return", "Color", ".", "decode", "(", "\"0x00BF00\"", ")", ";", "}", "else", "if", "(", "result", ".", "undefinesAll", "(", ")", ")", "{", "return", "Color", ".", "decode", "(", "\"0xB30000\"", ")", ";", "}", "else", "if", "(", "result", ".", "clearsTrackedRegister", "(", "trackedRegister", ")", ")", "{", "return", "Color", ".", "decode", "(", "\"0xA12967\"", ")", ";", "}", "else", "if", "(", "result", ".", "undefinesSome", "(", ")", ")", "{", "return", "Color", ".", "decode", "(", "\"0xED693F\"", ")", ";", "}", "else", "if", "(", "result", ".", "defines", "(", ")", ")", "{", "return", "Color", ".", "decode", "(", "\"0xFFCD55\"", ")", ";", "}", "else", "if", "(", "result", ".", "updates", "(", ")", ")", "{", "return", "Color", ".", "decode", "(", "\"0x5AAB47\"", ")", ";", "}", "else", "if", "(", "result", ".", "uses", "(", ")", ")", "{", "return", "Color", ".", "decode", "(", "\"0x414142\"", ")", ";", "}", "else", "{", "return", "Color", ".", "WHITE", ";", "}", "}" ]
determines the background color to be used in the table and in the graph to highlight a given instruction result .
train
false
120
public void removeOnCentralPositionChangedListener(OnCentralPositionChangedListener listener){ mOnCentralPositionChangedListeners.remove(listener); }
[ "public", "void", "removeOnCentralPositionChangedListener", "(", "OnCentralPositionChangedListener", "listener", ")", "{", "mOnCentralPositionChangedListeners", ".", "remove", "(", "listener", ")", ";", "}" ]
removes a listener that would be called when the central item of the list changes .
train
false
121
public void addPickupRS(){ int old=_pickupRS; _pickupRS++; setDirtyAndFirePropertyChange("locationAddPickupRS",Integer.toString(old),Integer.toString(_pickupRS)); }
[ "public", "void", "addPickupRS", "(", ")", "{", "int", "old", "=", "_pickupRS", ";", "_pickupRS", "++", ";", "setDirtyAndFirePropertyChange", "(", "\"locationAddPickupRS\"", ",", "Integer", ".", "toString", "(", "old", ")", ",", "Integer", ".", "toString", "(", "_pickupRS", ")", ")", ";", "}" ]
increments the number of cars and or engines that will be picked up by a train at this location .
train
false
123
public double convert(){ return Double.longBitsToDouble(ints2long(high,low)); }
[ "public", "double", "convert", "(", ")", "{", "return", "Double", ".", "longBitsToDouble", "(", "ints2long", "(", "high", ",", "low", ")", ")", ";", "}" ]
converts the internal representation ( two ints ) to a double .
train
false
125
public void clearArchiveDirectory(){ File directory=new File(getArchiveDirectory()); if (directory.exists() && directory.isDirectory()) { String[] listing=directory.list(); for ( String aListing : listing) { File file=new File(getArchiveDirectory(),aListing); file.delete(); } } if (!directory.exists()) { directory.mkdirs(); } }
[ "public", "void", "clearArchiveDirectory", "(", ")", "{", "File", "directory", "=", "new", "File", "(", "getArchiveDirectory", "(", ")", ")", ";", "if", "(", "directory", ".", "exists", "(", ")", "&&", "directory", ".", "isDirectory", "(", ")", ")", "{", "String", "[", "]", "listing", "=", "directory", ".", "list", "(", ")", ";", "for", "(", "String", "aListing", ":", "listing", ")", "{", "File", "file", "=", "new", "File", "(", "getArchiveDirectory", "(", ")", ",", "aListing", ")", ";", "file", ".", "delete", "(", ")", ";", "}", "}", "if", "(", "!", "directory", ".", "exists", "(", ")", ")", "{", "directory", ".", "mkdirs", "(", ")", ";", "}", "}" ]
clears the archive directory .
train
false