id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
154,100
watchrabbit/rabbit-commons
src/main/java/com/watchrabbit/commons/clock/Stopwatch.java
Stopwatch.createStarted
public static Stopwatch createStarted(VoidCallable callable) { Stopwatch stopwatch = new Stopwatch(); stopwatch.callable = callable; stopwatch.start(); return stopwatch; }
java
public static Stopwatch createStarted(VoidCallable callable) { Stopwatch stopwatch = new Stopwatch(); stopwatch.callable = callable; stopwatch.start(); return stopwatch; }
[ "public", "static", "Stopwatch", "createStarted", "(", "VoidCallable", "callable", ")", "{", "Stopwatch", "stopwatch", "=", "new", "Stopwatch", "(", ")", ";", "stopwatch", ".", "callable", "=", "callable", ";", "stopwatch", ".", "start", "(", ")", ";", "return", "stopwatch", ";", "}" ]
Creates Stopwatch around passed callable and invokes callable. @param callable with invocation time would be measured @return
[ "Creates", "Stopwatch", "around", "passed", "callable", "and", "invokes", "callable", "." ]
b11c9f804b5ab70b9264635c34a02f5029bd2a5d
https://github.com/watchrabbit/rabbit-commons/blob/b11c9f804b5ab70b9264635c34a02f5029bd2a5d/src/main/java/com/watchrabbit/commons/clock/Stopwatch.java#L54-L59
154,101
watchrabbit/rabbit-commons
src/main/java/com/watchrabbit/commons/clock/Stopwatch.java
Stopwatch.start
public Stopwatch start() { nanosStart = System.nanoTime(); callable.call(); ended = true; nanosEnd = System.nanoTime(); return this; }
java
public Stopwatch start() { nanosStart = System.nanoTime(); callable.call(); ended = true; nanosEnd = System.nanoTime(); return this; }
[ "public", "Stopwatch", "start", "(", ")", "{", "nanosStart", "=", "System", ".", "nanoTime", "(", ")", ";", "callable", ".", "call", "(", ")", ";", "ended", "=", "true", ";", "nanosEnd", "=", "System", ".", "nanoTime", "(", ")", ";", "return", "this", ";", "}" ]
Invokes passed callable and measures time. @return
[ "Invokes", "passed", "callable", "and", "measures", "time", "." ]
b11c9f804b5ab70b9264635c34a02f5029bd2a5d
https://github.com/watchrabbit/rabbit-commons/blob/b11c9f804b5ab70b9264635c34a02f5029bd2a5d/src/main/java/com/watchrabbit/commons/clock/Stopwatch.java#L66-L72
154,102
StefanLiebenberg/kute
kute-core/src/main/java/slieb/kute/Kute.java
Kute.renameResource
public static RenamedPathResource renameResource(String path, Resource.Readable resource) { return new RenamedPathResource(path, resource); }
java
public static RenamedPathResource renameResource(String path, Resource.Readable resource) { return new RenamedPathResource(path, resource); }
[ "public", "static", "RenamedPathResource", "renameResource", "(", "String", "path", ",", "Resource", ".", "Readable", "resource", ")", "{", "return", "new", "RenamedPathResource", "(", "path", ",", "resource", ")", ";", "}" ]
Create a resource with alternate name @param resource Any resource. @param path The new path location for this resource. @return A resource of type A extends Resource that is a copy of the old resource, but with a new name.
[ "Create", "a", "resource", "with", "alternate", "name" ]
1db0e8d2c76459d22c7d4b0ba99c18f74748f6fd
https://github.com/StefanLiebenberg/kute/blob/1db0e8d2c76459d22c7d4b0ba99c18f74748f6fd/kute-core/src/main/java/slieb/kute/Kute.java#L176-L179
154,103
StefanLiebenberg/kute
kute-core/src/main/java/slieb/kute/Kute.java
Kute.findResource
public static <R extends Resource> Optional<R> findResource(Stream<R> stream, String path) { return findFirstResource(stream.filter(r -> r.getPath().equals(path))); }
java
public static <R extends Resource> Optional<R> findResource(Stream<R> stream, String path) { return findFirstResource(stream.filter(r -> r.getPath().equals(path))); }
[ "public", "static", "<", "R", "extends", "Resource", ">", "Optional", "<", "R", ">", "findResource", "(", "Stream", "<", "R", ">", "stream", ",", "String", "path", ")", "{", "return", "findFirstResource", "(", "stream", ".", "filter", "(", "r", "->", "r", ".", "getPath", "(", ")", ".", "equals", "(", "path", ")", ")", ")", ";", "}" ]
Finds the first resource in stream that matches given path. @param stream A stream of resources. @param path The path to search for. @param <R> The resource implementation. @return A matching resource, if found.
[ "Finds", "the", "first", "resource", "in", "stream", "that", "matches", "given", "path", "." ]
1db0e8d2c76459d22c7d4b0ba99c18f74748f6fd
https://github.com/StefanLiebenberg/kute/blob/1db0e8d2c76459d22c7d4b0ba99c18f74748f6fd/kute-core/src/main/java/slieb/kute/Kute.java#L274-L277
154,104
tvesalainen/util
util/src/main/java/org/vesalainen/util/concurrent/WaiterList.java
WaiterList.wait
public Reason wait(T waiter) { return wait(waiter, Long.MAX_VALUE, TimeUnit.MILLISECONDS); }
java
public Reason wait(T waiter) { return wait(waiter, Long.MAX_VALUE, TimeUnit.MILLISECONDS); }
[ "public", "Reason", "wait", "(", "T", "waiter", ")", "{", "return", "wait", "(", "waiter", ",", "Long", ".", "MAX_VALUE", ",", "TimeUnit", ".", "MILLISECONDS", ")", ";", "}" ]
Adds waiter to queue and waits until releaseAll method call or thread is interrupted. @param waiter @return
[ "Adds", "waiter", "to", "queue", "and", "waits", "until", "releaseAll", "method", "call", "or", "thread", "is", "interrupted", "." ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/util/concurrent/WaiterList.java#L49-L52
154,105
jbundle/jbundle
app/program/script/src/main/java/org/jbundle/app/program/script/scan/BaseScanListener.java
BaseScanListener.moveThisFile
public void moveThisFile(LineNumberReader reader, File fileDestDir, String strDestName) { try { File fileDest = new File(fileDestDir, strDestName); fileDest.createNewFile(); FileOutputStream fileOut = new FileOutputStream(fileDest); m_writer = new PrintWriter(fileOut); this.moveSourceToDest(reader, m_writer); m_writer.close(); fileOut.close(); } catch (FileNotFoundException ex) { ex.printStackTrace(); } catch (IOException ex) { ex.printStackTrace(); } }
java
public void moveThisFile(LineNumberReader reader, File fileDestDir, String strDestName) { try { File fileDest = new File(fileDestDir, strDestName); fileDest.createNewFile(); FileOutputStream fileOut = new FileOutputStream(fileDest); m_writer = new PrintWriter(fileOut); this.moveSourceToDest(reader, m_writer); m_writer.close(); fileOut.close(); } catch (FileNotFoundException ex) { ex.printStackTrace(); } catch (IOException ex) { ex.printStackTrace(); } }
[ "public", "void", "moveThisFile", "(", "LineNumberReader", "reader", ",", "File", "fileDestDir", ",", "String", "strDestName", ")", "{", "try", "{", "File", "fileDest", "=", "new", "File", "(", "fileDestDir", ",", "strDestName", ")", ";", "fileDest", ".", "createNewFile", "(", ")", ";", "FileOutputStream", "fileOut", "=", "new", "FileOutputStream", "(", "fileDest", ")", ";", "m_writer", "=", "new", "PrintWriter", "(", "fileOut", ")", ";", "this", ".", "moveSourceToDest", "(", "reader", ",", "m_writer", ")", ";", "m_writer", ".", "close", "(", ")", ";", "fileOut", ".", "close", "(", ")", ";", "}", "catch", "(", "FileNotFoundException", "ex", ")", "{", "ex", ".", "printStackTrace", "(", ")", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "ex", ".", "printStackTrace", "(", ")", ";", "}", "}" ]
MoveThisFile Method.
[ "MoveThisFile", "Method", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/app/program/script/src/main/java/org/jbundle/app/program/script/scan/BaseScanListener.java#L150-L168
154,106
jbundle/jbundle
base/message/trx/src/main/java/org/jbundle/base/message/trx/transport/soap/SOAPMessageTransport.java
SOAPMessageTransport.free
public void free() { super.free(); try { if (m_con != null) m_con.close(); } catch (SOAPException ex) { ex.printStackTrace(); } }
java
public void free() { super.free(); try { if (m_con != null) m_con.close(); } catch (SOAPException ex) { ex.printStackTrace(); } }
[ "public", "void", "free", "(", ")", "{", "super", ".", "free", "(", ")", ";", "try", "{", "if", "(", "m_con", "!=", "null", ")", "m_con", ".", "close", "(", ")", ";", "}", "catch", "(", "SOAPException", "ex", ")", "{", "ex", ".", "printStackTrace", "(", ")", ";", "}", "}" ]
Free all the resources belonging to this class.
[ "Free", "all", "the", "resources", "belonging", "to", "this", "class", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/message/trx/src/main/java/org/jbundle/base/message/trx/transport/soap/SOAPMessageTransport.java#L107-L116
154,107
jbundle/jbundle
base/message/trx/src/main/java/org/jbundle/base/message/trx/transport/soap/SOAPMessageTransport.java
SOAPMessageTransport.setSOAPBody
public SOAPMessage setSOAPBody(SOAPMessage msg, BaseMessage message) { try { if (msg == null) msg = fac.createMessage(); // Message creation takes care of creating the SOAPPart - a // required part of the message as per the SOAP 1.1 // specification. SOAPPart soappart = msg.getSOAPPart(); // Retrieve the envelope from the soap part to start building // the soap message. SOAPEnvelope envelope = soappart.getEnvelope(); // Create a soap header from the envelope. //?SOAPHeader header = envelope.getHeader(); // Create a soap body from the envelope. SOAPBody body = envelope.getBody(); DOMResult result = new DOMResult(body); if (((BaseXmlTrxMessageOut)message.getExternalMessage()).copyMessageToResult(result)) { // Success // Note: For Jabx, I would have to fix the namespace of the message (so don't use JAXB) msg.saveChanges(); return msg; } } catch(Throwable e) { e.printStackTrace(); Utility.getLogger().warning("Error in constructing or sending message " +e.getMessage()); } return null; }
java
public SOAPMessage setSOAPBody(SOAPMessage msg, BaseMessage message) { try { if (msg == null) msg = fac.createMessage(); // Message creation takes care of creating the SOAPPart - a // required part of the message as per the SOAP 1.1 // specification. SOAPPart soappart = msg.getSOAPPart(); // Retrieve the envelope from the soap part to start building // the soap message. SOAPEnvelope envelope = soappart.getEnvelope(); // Create a soap header from the envelope. //?SOAPHeader header = envelope.getHeader(); // Create a soap body from the envelope. SOAPBody body = envelope.getBody(); DOMResult result = new DOMResult(body); if (((BaseXmlTrxMessageOut)message.getExternalMessage()).copyMessageToResult(result)) { // Success // Note: For Jabx, I would have to fix the namespace of the message (so don't use JAXB) msg.saveChanges(); return msg; } } catch(Throwable e) { e.printStackTrace(); Utility.getLogger().warning("Error in constructing or sending message " +e.getMessage()); } return null; }
[ "public", "SOAPMessage", "setSOAPBody", "(", "SOAPMessage", "msg", ",", "BaseMessage", "message", ")", "{", "try", "{", "if", "(", "msg", "==", "null", ")", "msg", "=", "fac", ".", "createMessage", "(", ")", ";", "// Message creation takes care of creating the SOAPPart - a", "// required part of the message as per the SOAP 1.1", "// specification.", "SOAPPart", "soappart", "=", "msg", ".", "getSOAPPart", "(", ")", ";", "// Retrieve the envelope from the soap part to start building", "// the soap message.", "SOAPEnvelope", "envelope", "=", "soappart", ".", "getEnvelope", "(", ")", ";", "// Create a soap header from the envelope.", "//?SOAPHeader header = envelope.getHeader();", "// Create a soap body from the envelope.", "SOAPBody", "body", "=", "envelope", ".", "getBody", "(", ")", ";", "DOMResult", "result", "=", "new", "DOMResult", "(", "body", ")", ";", "if", "(", "(", "(", "BaseXmlTrxMessageOut", ")", "message", ".", "getExternalMessage", "(", ")", ")", ".", "copyMessageToResult", "(", "result", ")", ")", "{", "// Success", "// Note: For Jabx, I would have to fix the namespace of the message (so don't use JAXB)", "msg", ".", "saveChanges", "(", ")", ";", "return", "msg", ";", "}", "}", "catch", "(", "Throwable", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "Utility", ".", "getLogger", "(", ")", ".", "warning", "(", "\"Error in constructing or sending message \"", "+", "e", ".", "getMessage", "(", ")", ")", ";", "}", "return", "null", ";", "}" ]
This utility method sticks this message into this soap message's body. @param msg The source message.
[ "This", "utility", "method", "sticks", "this", "message", "into", "this", "soap", "message", "s", "body", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/message/trx/src/main/java/org/jbundle/base/message/trx/transport/soap/SOAPMessageTransport.java#L222-L255
154,108
jbundle/jbundle
base/message/trx/src/main/java/org/jbundle/base/message/trx/transport/soap/SOAPMessageTransport.java
SOAPMessageTransport.getElement
public SOAPElement getElement(SOAPElement element, String strElementName) { Iterator<?> iterator = element.getChildElements(); while (iterator.hasNext()) { javax.xml.soap.Node elMessageType = (javax.xml.soap.Node)iterator.next(); if (elMessageType instanceof SOAPElement) { if (strElementName == null) return (SOAPElement)elMessageType; // The message type if (strElementName.equalsIgnoreCase(((SOAPElement)elMessageType).getElementName().getLocalName())) return (SOAPElement)elMessageType; // The message type } } return null; // not found }
java
public SOAPElement getElement(SOAPElement element, String strElementName) { Iterator<?> iterator = element.getChildElements(); while (iterator.hasNext()) { javax.xml.soap.Node elMessageType = (javax.xml.soap.Node)iterator.next(); if (elMessageType instanceof SOAPElement) { if (strElementName == null) return (SOAPElement)elMessageType; // The message type if (strElementName.equalsIgnoreCase(((SOAPElement)elMessageType).getElementName().getLocalName())) return (SOAPElement)elMessageType; // The message type } } return null; // not found }
[ "public", "SOAPElement", "getElement", "(", "SOAPElement", "element", ",", "String", "strElementName", ")", "{", "Iterator", "<", "?", ">", "iterator", "=", "element", ".", "getChildElements", "(", ")", ";", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "javax", ".", "xml", ".", "soap", ".", "Node", "elMessageType", "=", "(", "javax", ".", "xml", ".", "soap", ".", "Node", ")", "iterator", ".", "next", "(", ")", ";", "if", "(", "elMessageType", "instanceof", "SOAPElement", ")", "{", "if", "(", "strElementName", "==", "null", ")", "return", "(", "SOAPElement", ")", "elMessageType", ";", "// The message type", "if", "(", "strElementName", ".", "equalsIgnoreCase", "(", "(", "(", "SOAPElement", ")", "elMessageType", ")", ".", "getElementName", "(", ")", ".", "getLocalName", "(", ")", ")", ")", "return", "(", "SOAPElement", ")", "elMessageType", ";", "// The message type", "}", "}", "return", "null", ";", "// not found", "}" ]
Get the element. @param strElementName The element to return (if null, return the first element).
[ "Get", "the", "element", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/message/trx/src/main/java/org/jbundle/base/message/trx/transport/soap/SOAPMessageTransport.java#L339-L354
154,109
jbundle/jbundle
base/message/trx/src/main/java/org/jbundle/base/message/trx/transport/soap/SOAPMessageTransport.java
SOAPMessageTransport.messageToString
public static String messageToString(SOAPMessage soapMessage) { String strTextMessage = null; if (soapMessage != null) { try { ByteArrayOutputStream ba = new ByteArrayOutputStream(); PrintStream os = new PrintStream(ba); soapMessage.writeTo(os); os.flush(); ByteArrayInputStream is = new ByteArrayInputStream(ba.toByteArray()); Reader reader = new InputStreamReader(is); BufferedReader br = new BufferedReader(reader); StringBuffer sb = new StringBuffer(); String string = null; while ((string = br.readLine()) != null) { sb.append(string); sb.append('\n'); } strTextMessage = sb.toString(); } catch (SOAPException ex) { ex.printStackTrace(); } catch (IOException ex) { ex.printStackTrace(); } } return strTextMessage; }
java
public static String messageToString(SOAPMessage soapMessage) { String strTextMessage = null; if (soapMessage != null) { try { ByteArrayOutputStream ba = new ByteArrayOutputStream(); PrintStream os = new PrintStream(ba); soapMessage.writeTo(os); os.flush(); ByteArrayInputStream is = new ByteArrayInputStream(ba.toByteArray()); Reader reader = new InputStreamReader(is); BufferedReader br = new BufferedReader(reader); StringBuffer sb = new StringBuffer(); String string = null; while ((string = br.readLine()) != null) { sb.append(string); sb.append('\n'); } strTextMessage = sb.toString(); } catch (SOAPException ex) { ex.printStackTrace(); } catch (IOException ex) { ex.printStackTrace(); } } return strTextMessage; }
[ "public", "static", "String", "messageToString", "(", "SOAPMessage", "soapMessage", ")", "{", "String", "strTextMessage", "=", "null", ";", "if", "(", "soapMessage", "!=", "null", ")", "{", "try", "{", "ByteArrayOutputStream", "ba", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "PrintStream", "os", "=", "new", "PrintStream", "(", "ba", ")", ";", "soapMessage", ".", "writeTo", "(", "os", ")", ";", "os", ".", "flush", "(", ")", ";", "ByteArrayInputStream", "is", "=", "new", "ByteArrayInputStream", "(", "ba", ".", "toByteArray", "(", ")", ")", ";", "Reader", "reader", "=", "new", "InputStreamReader", "(", "is", ")", ";", "BufferedReader", "br", "=", "new", "BufferedReader", "(", "reader", ")", ";", "StringBuffer", "sb", "=", "new", "StringBuffer", "(", ")", ";", "String", "string", "=", "null", ";", "while", "(", "(", "string", "=", "br", ".", "readLine", "(", ")", ")", "!=", "null", ")", "{", "sb", ".", "append", "(", "string", ")", ";", "sb", ".", "append", "(", "'", "'", ")", ";", "}", "strTextMessage", "=", "sb", ".", "toString", "(", ")", ";", "}", "catch", "(", "SOAPException", "ex", ")", "{", "ex", ".", "printStackTrace", "(", ")", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "ex", ".", "printStackTrace", "(", ")", ";", "}", "}", "return", "strTextMessage", ";", "}" ]
Convert this SOAP message to a text string.
[ "Convert", "this", "SOAP", "message", "to", "a", "text", "string", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/message/trx/src/main/java/org/jbundle/base/message/trx/transport/soap/SOAPMessageTransport.java#L358-L389
154,110
jbundle/jbundle
base/message/trx/src/main/java/org/jbundle/base/message/trx/transport/soap/SOAPMessageTransport.java
SOAPMessageTransport.printSource
public void printSource(Source src, PrintStream out) { TransformerFactory tFact = TransformerFactory.newInstance(); try { Transformer transformer = tFact.newTransformer(); Result result = new StreamResult( out ); transformer.transform(src, result); } catch (TransformerConfigurationException ex) { ex.printStackTrace(); } catch (TransformerException ex) { ex.printStackTrace(); } }
java
public void printSource(Source src, PrintStream out) { TransformerFactory tFact = TransformerFactory.newInstance(); try { Transformer transformer = tFact.newTransformer(); Result result = new StreamResult( out ); transformer.transform(src, result); } catch (TransformerConfigurationException ex) { ex.printStackTrace(); } catch (TransformerException ex) { ex.printStackTrace(); } }
[ "public", "void", "printSource", "(", "Source", "src", ",", "PrintStream", "out", ")", "{", "TransformerFactory", "tFact", "=", "TransformerFactory", ".", "newInstance", "(", ")", ";", "try", "{", "Transformer", "transformer", "=", "tFact", ".", "newTransformer", "(", ")", ";", "Result", "result", "=", "new", "StreamResult", "(", "out", ")", ";", "transformer", ".", "transform", "(", "src", ",", "result", ")", ";", "}", "catch", "(", "TransformerConfigurationException", "ex", ")", "{", "ex", ".", "printStackTrace", "(", ")", ";", "}", "catch", "(", "TransformerException", "ex", ")", "{", "ex", ".", "printStackTrace", "(", ")", ";", "}", "}" ]
A utility method to print this source tree to the given stream.
[ "A", "utility", "method", "to", "print", "this", "source", "tree", "to", "the", "given", "stream", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/message/trx/src/main/java/org/jbundle/base/message/trx/transport/soap/SOAPMessageTransport.java#L393-L406
154,111
williamwebb/alogger
Utilities/src/main/java/com/jug6ernaut/android/utilites/FileDownloader.java
FileDownloader.downloadFileNew
@Deprecated public File downloadFileNew(File inputUrl, File outputFile){ OutputStream out = null; InputStream fis = null; HttpParams httpParameters = new BasicHttpParams(); int timeoutConnection = 2500; HttpConnectionParams.setConnectionTimeout(httpParameters, timeoutConnection); int timeoutSocket = 2500; HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket); File dir = outputFile.getParentFile(); dir.mkdirs(); try { HttpGet httpRequest = new HttpGet(stringFromFile(inputUrl)); DefaultHttpClient httpClient = new DefaultHttpClient(httpParameters); HttpResponse response = httpClient.execute(httpRequest); int statusCode = response.getStatusLine().getStatusCode(); if (statusCode == HttpStatus.SC_OK) { HttpEntity entity = response.getEntity(); out = new BufferedOutputStream(new FileOutputStream(outputFile)); long total = entity.getContentLength(); fis = entity.getContent(); if(total>1||true) startTalker(total); else{ throw new IOException("Content null"); } long progress = 0; byte[] buffer = new byte[1024]; int length = 0; while ((length = fis.read(buffer)) != -1) { out.write(buffer, 0, length); progressTalker(length); progress+=length; } /* for (int b; (b = fis.read()) != -1;) { out.write(b); progress+=b; progressTalker(b); } */ finishTalker(progress); } }catch(Exception e){ cancelTalker(e); e.printStackTrace(); return null; }finally{ try { if(out!=null){ out.flush(); out.close(); } if(fis!=null) fis.close(); } catch (IOException e) { e.printStackTrace(); } } return outputFile; }
java
@Deprecated public File downloadFileNew(File inputUrl, File outputFile){ OutputStream out = null; InputStream fis = null; HttpParams httpParameters = new BasicHttpParams(); int timeoutConnection = 2500; HttpConnectionParams.setConnectionTimeout(httpParameters, timeoutConnection); int timeoutSocket = 2500; HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket); File dir = outputFile.getParentFile(); dir.mkdirs(); try { HttpGet httpRequest = new HttpGet(stringFromFile(inputUrl)); DefaultHttpClient httpClient = new DefaultHttpClient(httpParameters); HttpResponse response = httpClient.execute(httpRequest); int statusCode = response.getStatusLine().getStatusCode(); if (statusCode == HttpStatus.SC_OK) { HttpEntity entity = response.getEntity(); out = new BufferedOutputStream(new FileOutputStream(outputFile)); long total = entity.getContentLength(); fis = entity.getContent(); if(total>1||true) startTalker(total); else{ throw new IOException("Content null"); } long progress = 0; byte[] buffer = new byte[1024]; int length = 0; while ((length = fis.read(buffer)) != -1) { out.write(buffer, 0, length); progressTalker(length); progress+=length; } /* for (int b; (b = fis.read()) != -1;) { out.write(b); progress+=b; progressTalker(b); } */ finishTalker(progress); } }catch(Exception e){ cancelTalker(e); e.printStackTrace(); return null; }finally{ try { if(out!=null){ out.flush(); out.close(); } if(fis!=null) fis.close(); } catch (IOException e) { e.printStackTrace(); } } return outputFile; }
[ "@", "Deprecated", "public", "File", "downloadFileNew", "(", "File", "inputUrl", ",", "File", "outputFile", ")", "{", "OutputStream", "out", "=", "null", ";", "InputStream", "fis", "=", "null", ";", "HttpParams", "httpParameters", "=", "new", "BasicHttpParams", "(", ")", ";", "int", "timeoutConnection", "=", "2500", ";", "HttpConnectionParams", ".", "setConnectionTimeout", "(", "httpParameters", ",", "timeoutConnection", ")", ";", "int", "timeoutSocket", "=", "2500", ";", "HttpConnectionParams", ".", "setSoTimeout", "(", "httpParameters", ",", "timeoutSocket", ")", ";", "File", "dir", "=", "outputFile", ".", "getParentFile", "(", ")", ";", "dir", ".", "mkdirs", "(", ")", ";", "try", "{", "HttpGet", "httpRequest", "=", "new", "HttpGet", "(", "stringFromFile", "(", "inputUrl", ")", ")", ";", "DefaultHttpClient", "httpClient", "=", "new", "DefaultHttpClient", "(", "httpParameters", ")", ";", "HttpResponse", "response", "=", "httpClient", ".", "execute", "(", "httpRequest", ")", ";", "int", "statusCode", "=", "response", ".", "getStatusLine", "(", ")", ".", "getStatusCode", "(", ")", ";", "if", "(", "statusCode", "==", "HttpStatus", ".", "SC_OK", ")", "{", "HttpEntity", "entity", "=", "response", ".", "getEntity", "(", ")", ";", "out", "=", "new", "BufferedOutputStream", "(", "new", "FileOutputStream", "(", "outputFile", ")", ")", ";", "long", "total", "=", "entity", ".", "getContentLength", "(", ")", ";", "fis", "=", "entity", ".", "getContent", "(", ")", ";", "if", "(", "total", ">", "1", "||", "true", ")", "startTalker", "(", "total", ")", ";", "else", "{", "throw", "new", "IOException", "(", "\"Content null\"", ")", ";", "}", "long", "progress", "=", "0", ";", "byte", "[", "]", "buffer", "=", "new", "byte", "[", "1024", "]", ";", "int", "length", "=", "0", ";", "while", "(", "(", "length", "=", "fis", ".", "read", "(", "buffer", ")", ")", "!=", "-", "1", ")", "{", "out", ".", "write", "(", "buffer", ",", "0", ",", "length", ")", ";", "progressTalker", "(", "length", ")", ";", "progress", "+=", "length", ";", "}", "/*\n\t\t\t\tfor (int b; (b = fis.read()) != -1;) {\n\t\t\t\t\tout.write(b);\n\t\t\t\t\tprogress+=b;\n\t\t\t\t\tprogressTalker(b);\n\t\t\t\t}\n\t\t\t\t*/", "finishTalker", "(", "progress", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "cancelTalker", "(", "e", ")", ";", "e", ".", "printStackTrace", "(", ")", ";", "return", "null", ";", "}", "finally", "{", "try", "{", "if", "(", "out", "!=", "null", ")", "{", "out", ".", "flush", "(", ")", ";", "out", ".", "close", "(", ")", ";", "}", "if", "(", "fis", "!=", "null", ")", "fis", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "return", "outputFile", ";", "}" ]
still has issues... @param inputUrl @param outputFile @return
[ "still", "has", "issues", "..." ]
61fca49e0b8d9c3a76c40da8883ac354b240351e
https://github.com/williamwebb/alogger/blob/61fca49e0b8d9c3a76c40da8883ac354b240351e/Utilities/src/main/java/com/jug6ernaut/android/utilites/FileDownloader.java#L84-L156
154,112
avaje-common/avaje-resteasy-guice
src/main/java/org/avaje/resteasy/Bootstrap.java
Bootstrap.contextInitialized
@Override public void contextInitialized(ServletContextEvent event) { this.event = event; this.serverContainer = getServerContainer(event); super.contextInitialized(event); }
java
@Override public void contextInitialized(ServletContextEvent event) { this.event = event; this.serverContainer = getServerContainer(event); super.contextInitialized(event); }
[ "@", "Override", "public", "void", "contextInitialized", "(", "ServletContextEvent", "event", ")", "{", "this", ".", "event", "=", "event", ";", "this", ".", "serverContainer", "=", "getServerContainer", "(", "event", ")", ";", "super", ".", "contextInitialized", "(", "event", ")", ";", "}" ]
On contextInitialized additional obtain the WebSocket ServerContainer.
[ "On", "contextInitialized", "additional", "obtain", "the", "WebSocket", "ServerContainer", "." ]
a585d8c6b0a6d4fb5ffb679d8950e41a03795929
https://github.com/avaje-common/avaje-resteasy-guice/blob/a585d8c6b0a6d4fb5ffb679d8950e41a03795929/src/main/java/org/avaje/resteasy/Bootstrap.java#L35-L40
154,113
avaje-common/avaje-resteasy-guice
src/main/java/org/avaje/resteasy/Bootstrap.java
Bootstrap.getServerContainer
protected ServerContainer getServerContainer(ServletContextEvent servletContextEvent) { ServletContext context = servletContextEvent.getServletContext(); return (ServerContainer) context.getAttribute("javax.websocket.server.ServerContainer"); }
java
protected ServerContainer getServerContainer(ServletContextEvent servletContextEvent) { ServletContext context = servletContextEvent.getServletContext(); return (ServerContainer) context.getAttribute("javax.websocket.server.ServerContainer"); }
[ "protected", "ServerContainer", "getServerContainer", "(", "ServletContextEvent", "servletContextEvent", ")", "{", "ServletContext", "context", "=", "servletContextEvent", ".", "getServletContext", "(", ")", ";", "return", "(", "ServerContainer", ")", "context", ".", "getAttribute", "(", "\"javax.websocket.server.ServerContainer\"", ")", ";", "}" ]
Return the WebSocket ServerContainer from the servletContext.
[ "Return", "the", "WebSocket", "ServerContainer", "from", "the", "servletContext", "." ]
a585d8c6b0a6d4fb5ffb679d8950e41a03795929
https://github.com/avaje-common/avaje-resteasy-guice/blob/a585d8c6b0a6d4fb5ffb679d8950e41a03795929/src/main/java/org/avaje/resteasy/Bootstrap.java#L45-L49
154,114
avaje-common/avaje-resteasy-guice
src/main/java/org/avaje/resteasy/Bootstrap.java
Bootstrap.registerWebSockets
private void registerWebSockets(Injector injector) { Map<Key<?>, Binding<?>> allBindings = injector.getAllBindings(); // loop all the Guice bindings looking for @ServerEndpoint singletons for (Map.Entry<Key<?>, Binding<?>> entry : allBindings.entrySet()) { final Binding<?> binding = entry.getValue(); binding.acceptScopingVisitor(new DefaultBindingScopingVisitor() { @Override public Object visitEagerSingleton() { // also a eager singleton so register it registerWebSocketEndpoint(binding); return null; } }); } }
java
private void registerWebSockets(Injector injector) { Map<Key<?>, Binding<?>> allBindings = injector.getAllBindings(); // loop all the Guice bindings looking for @ServerEndpoint singletons for (Map.Entry<Key<?>, Binding<?>> entry : allBindings.entrySet()) { final Binding<?> binding = entry.getValue(); binding.acceptScopingVisitor(new DefaultBindingScopingVisitor() { @Override public Object visitEagerSingleton() { // also a eager singleton so register it registerWebSocketEndpoint(binding); return null; } }); } }
[ "private", "void", "registerWebSockets", "(", "Injector", "injector", ")", "{", "Map", "<", "Key", "<", "?", ">", ",", "Binding", "<", "?", ">", ">", "allBindings", "=", "injector", ".", "getAllBindings", "(", ")", ";", "// loop all the Guice bindings looking for @ServerEndpoint singletons", "for", "(", "Map", ".", "Entry", "<", "Key", "<", "?", ">", ",", "Binding", "<", "?", ">", ">", "entry", ":", "allBindings", ".", "entrySet", "(", ")", ")", "{", "final", "Binding", "<", "?", ">", "binding", "=", "entry", ".", "getValue", "(", ")", ";", "binding", ".", "acceptScopingVisitor", "(", "new", "DefaultBindingScopingVisitor", "(", ")", "{", "@", "Override", "public", "Object", "visitEagerSingleton", "(", ")", "{", "// also a eager singleton so register it", "registerWebSocketEndpoint", "(", "binding", ")", ";", "return", "null", ";", "}", "}", ")", ";", "}", "}" ]
Find any Guice eager singletons that are WebSocket endpoints and register them with the servlet container.
[ "Find", "any", "Guice", "eager", "singletons", "that", "are", "WebSocket", "endpoints", "and", "register", "them", "with", "the", "servlet", "container", "." ]
a585d8c6b0a6d4fb5ffb679d8950e41a03795929
https://github.com/avaje-common/avaje-resteasy-guice/blob/a585d8c6b0a6d4fb5ffb679d8950e41a03795929/src/main/java/org/avaje/resteasy/Bootstrap.java#L67-L85
154,115
avaje-common/avaje-resteasy-guice
src/main/java/org/avaje/resteasy/Bootstrap.java
Bootstrap.registerWebSocketEndpoint
protected void registerWebSocketEndpoint(Binding<?> binding) {//}, ServerEndpoint serverEndpoint) { Object instance = binding.getProvider().get(); Class<?> instanceClass = instance.getClass(); ServerEndpoint serverEndpoint = instanceClass.getAnnotation(ServerEndpoint.class); if (serverEndpoint != null) { try { // register with the servlet container such that the Guice created singleton instance // is the instance that is used (and not an instance created per request etc) log.debug("registering ServerEndpoint [{}] with servlet container", instanceClass); BasicWebSocketConfigurator configurator = new BasicWebSocketConfigurator(instance); serverContainer.addEndpoint(new BasicWebSocketEndpointConfig(instanceClass, serverEndpoint, configurator)); } catch (Exception e) { log.error("Error registering WebSocket Singleton " + instance + " with the servlet container", e); } } }
java
protected void registerWebSocketEndpoint(Binding<?> binding) {//}, ServerEndpoint serverEndpoint) { Object instance = binding.getProvider().get(); Class<?> instanceClass = instance.getClass(); ServerEndpoint serverEndpoint = instanceClass.getAnnotation(ServerEndpoint.class); if (serverEndpoint != null) { try { // register with the servlet container such that the Guice created singleton instance // is the instance that is used (and not an instance created per request etc) log.debug("registering ServerEndpoint [{}] with servlet container", instanceClass); BasicWebSocketConfigurator configurator = new BasicWebSocketConfigurator(instance); serverContainer.addEndpoint(new BasicWebSocketEndpointConfig(instanceClass, serverEndpoint, configurator)); } catch (Exception e) { log.error("Error registering WebSocket Singleton " + instance + " with the servlet container", e); } } }
[ "protected", "void", "registerWebSocketEndpoint", "(", "Binding", "<", "?", ">", "binding", ")", "{", "//}, ServerEndpoint serverEndpoint) {", "Object", "instance", "=", "binding", ".", "getProvider", "(", ")", ".", "get", "(", ")", ";", "Class", "<", "?", ">", "instanceClass", "=", "instance", ".", "getClass", "(", ")", ";", "ServerEndpoint", "serverEndpoint", "=", "instanceClass", ".", "getAnnotation", "(", "ServerEndpoint", ".", "class", ")", ";", "if", "(", "serverEndpoint", "!=", "null", ")", "{", "try", "{", "// register with the servlet container such that the Guice created singleton instance", "// is the instance that is used (and not an instance created per request etc)", "log", ".", "debug", "(", "\"registering ServerEndpoint [{}] with servlet container\"", ",", "instanceClass", ")", ";", "BasicWebSocketConfigurator", "configurator", "=", "new", "BasicWebSocketConfigurator", "(", "instance", ")", ";", "serverContainer", ".", "addEndpoint", "(", "new", "BasicWebSocketEndpointConfig", "(", "instanceClass", ",", "serverEndpoint", ",", "configurator", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "log", ".", "error", "(", "\"Error registering WebSocket Singleton \"", "+", "instance", "+", "\" with the servlet container\"", ",", "e", ")", ";", "}", "}", "}" ]
Check if the binding is a WebSocket endpoint. If it is then register the webSocket server endpoint with the servlet container.
[ "Check", "if", "the", "binding", "is", "a", "WebSocket", "endpoint", ".", "If", "it", "is", "then", "register", "the", "webSocket", "server", "endpoint", "with", "the", "servlet", "container", "." ]
a585d8c6b0a6d4fb5ffb679d8950e41a03795929
https://github.com/avaje-common/avaje-resteasy-guice/blob/a585d8c6b0a6d4fb5ffb679d8950e41a03795929/src/main/java/org/avaje/resteasy/Bootstrap.java#L91-L108
154,116
jbundle/jbundle
base/base/src/main/java/org/jbundle/base/util/BaseThickActivator.java
BaseThickActivator.addConfigProperty
public Map<String,Object> addConfigProperty(Map<String,Object> properties, String key, String defaultValue) { if (this.getProperty(key) != null) properties.put(key, this.getProperty(key)); else if (defaultValue != null) properties.put(key, defaultValue); return properties; }
java
public Map<String,Object> addConfigProperty(Map<String,Object> properties, String key, String defaultValue) { if (this.getProperty(key) != null) properties.put(key, this.getProperty(key)); else if (defaultValue != null) properties.put(key, defaultValue); return properties; }
[ "public", "Map", "<", "String", ",", "Object", ">", "addConfigProperty", "(", "Map", "<", "String", ",", "Object", ">", "properties", ",", "String", "key", ",", "String", "defaultValue", ")", "{", "if", "(", "this", ".", "getProperty", "(", "key", ")", "!=", "null", ")", "properties", ".", "put", "(", "key", ",", "this", ".", "getProperty", "(", "key", ")", ")", ";", "else", "if", "(", "defaultValue", "!=", "null", ")", "properties", ".", "put", "(", "key", ",", "defaultValue", ")", ";", "return", "properties", ";", "}" ]
Add this property if it exists in the OSGi config file. @param properties @param key @param defaultValue @return
[ "Add", "this", "property", "if", "it", "exists", "in", "the", "OSGi", "config", "file", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/util/BaseThickActivator.java#L57-L64
154,117
pressgang-ccms/PressGangCCMSContentSpec
src/main/java/org/jboss/pressgang/ccms/contentspec/Process.java
Process.getTopicIds
protected List<String> getTopicIds() { LinkedList<String> topicIds = new LinkedList<String>(); for (final Entry<String, SpecTopic> specTopicEntry : topics.entrySet()) { topicIds.add(specTopicEntry.getKey()); } return topicIds; }
java
protected List<String> getTopicIds() { LinkedList<String> topicIds = new LinkedList<String>(); for (final Entry<String, SpecTopic> specTopicEntry : topics.entrySet()) { topicIds.add(specTopicEntry.getKey()); } return topicIds; }
[ "protected", "List", "<", "String", ">", "getTopicIds", "(", ")", "{", "LinkedList", "<", "String", ">", "topicIds", "=", "new", "LinkedList", "<", "String", ">", "(", ")", ";", "for", "(", "final", "Entry", "<", "String", ",", "SpecTopic", ">", "specTopicEntry", ":", "topics", ".", "entrySet", "(", ")", ")", "{", "topicIds", ".", "add", "(", "specTopicEntry", ".", "getKey", "(", ")", ")", ";", "}", "return", "topicIds", ";", "}" ]
Gets all of the Content Specification Unique Topic ID's that are used in the process. @return A List of Unique Topic ID's.
[ "Gets", "all", "of", "the", "Content", "Specification", "Unique", "Topic", "ID", "s", "that", "are", "used", "in", "the", "process", "." ]
2bc02e2971e4522b47a130fb7ae5a0f5ad377df1
https://github.com/pressgang-ccms/PressGangCCMSContentSpec/blob/2bc02e2971e4522b47a130fb7ae5a0f5ad377df1/src/main/java/org/jboss/pressgang/ccms/contentspec/Process.java#L98-L104
154,118
pressgang-ccms/PressGangCCMSContentSpec
src/main/java/org/jboss/pressgang/ccms/contentspec/Level.java
Level.appendSpecTopic
public void appendSpecTopic(final SpecTopic specTopic) { topics.add(specTopic); nodes.add(specTopic); if (specTopic.getParent() != null && specTopic.getParent() instanceof Level) { ((Level) specTopic.getParent()).removeSpecTopic(specTopic); } specTopic.setParent(this); }
java
public void appendSpecTopic(final SpecTopic specTopic) { topics.add(specTopic); nodes.add(specTopic); if (specTopic.getParent() != null && specTopic.getParent() instanceof Level) { ((Level) specTopic.getParent()).removeSpecTopic(specTopic); } specTopic.setParent(this); }
[ "public", "void", "appendSpecTopic", "(", "final", "SpecTopic", "specTopic", ")", "{", "topics", ".", "add", "(", "specTopic", ")", ";", "nodes", ".", "add", "(", "specTopic", ")", ";", "if", "(", "specTopic", ".", "getParent", "(", ")", "!=", "null", "&&", "specTopic", ".", "getParent", "(", ")", "instanceof", "Level", ")", "{", "(", "(", "Level", ")", "specTopic", ".", "getParent", "(", ")", ")", ".", "removeSpecTopic", "(", "specTopic", ")", ";", "}", "specTopic", ".", "setParent", "(", "this", ")", ";", "}" ]
Adds a Content Specification Topic to the Level. If the Topic already has a parent, then it is removed from that parent and added to this level. @param specTopic The Content Specification Topic to be added to the level.
[ "Adds", "a", "Content", "Specification", "Topic", "to", "the", "Level", ".", "If", "the", "Topic", "already", "has", "a", "parent", "then", "it", "is", "removed", "from", "that", "parent", "and", "added", "to", "this", "level", "." ]
2bc02e2971e4522b47a130fb7ae5a0f5ad377df1
https://github.com/pressgang-ccms/PressGangCCMSContentSpec/blob/2bc02e2971e4522b47a130fb7ae5a0f5ad377df1/src/main/java/org/jboss/pressgang/ccms/contentspec/Level.java#L148-L155
154,119
pressgang-ccms/PressGangCCMSContentSpec
src/main/java/org/jboss/pressgang/ccms/contentspec/Level.java
Level.appendChild
public void appendChild(final Node child) { if (child instanceof Level) { // Append the level levels.add((Level) child); nodes.add(child); if (child.getParent() != null) { child.removeParent(); } child.setParent(this); } else if (child instanceof SpecTopic) { appendSpecTopic((SpecTopic) child); } else if (child instanceof CommonContent) { // Append the common content commonContents.add((CommonContent) child); nodes.add(child); if (child.getParent() != null) { child.removeParent(); } child.setParent(this); } else { nodes.add(child); if (child.getParent() != null) { child.removeParent(); } child.setParent(this); } }
java
public void appendChild(final Node child) { if (child instanceof Level) { // Append the level levels.add((Level) child); nodes.add(child); if (child.getParent() != null) { child.removeParent(); } child.setParent(this); } else if (child instanceof SpecTopic) { appendSpecTopic((SpecTopic) child); } else if (child instanceof CommonContent) { // Append the common content commonContents.add((CommonContent) child); nodes.add(child); if (child.getParent() != null) { child.removeParent(); } child.setParent(this); } else { nodes.add(child); if (child.getParent() != null) { child.removeParent(); } child.setParent(this); } }
[ "public", "void", "appendChild", "(", "final", "Node", "child", ")", "{", "if", "(", "child", "instanceof", "Level", ")", "{", "// Append the level", "levels", ".", "add", "(", "(", "Level", ")", "child", ")", ";", "nodes", ".", "add", "(", "child", ")", ";", "if", "(", "child", ".", "getParent", "(", ")", "!=", "null", ")", "{", "child", ".", "removeParent", "(", ")", ";", "}", "child", ".", "setParent", "(", "this", ")", ";", "}", "else", "if", "(", "child", "instanceof", "SpecTopic", ")", "{", "appendSpecTopic", "(", "(", "SpecTopic", ")", "child", ")", ";", "}", "else", "if", "(", "child", "instanceof", "CommonContent", ")", "{", "// Append the common content", "commonContents", ".", "add", "(", "(", "CommonContent", ")", "child", ")", ";", "nodes", ".", "add", "(", "child", ")", ";", "if", "(", "child", ".", "getParent", "(", ")", "!=", "null", ")", "{", "child", ".", "removeParent", "(", ")", ";", "}", "child", ".", "setParent", "(", "this", ")", ";", "}", "else", "{", "nodes", ".", "add", "(", "child", ")", ";", "if", "(", "child", ".", "getParent", "(", ")", "!=", "null", ")", "{", "child", ".", "removeParent", "(", ")", ";", "}", "child", ".", "setParent", "(", "this", ")", ";", "}", "}" ]
Adds a Child Element to the Level. If the Child Element already has a parent, then it is removed from that parent and added to this level. @param child A Child element to be added to the Level.
[ "Adds", "a", "Child", "Element", "to", "the", "Level", ".", "If", "the", "Child", "Element", "already", "has", "a", "parent", "then", "it", "is", "removed", "from", "that", "parent", "and", "added", "to", "this", "level", "." ]
2bc02e2971e4522b47a130fb7ae5a0f5ad377df1
https://github.com/pressgang-ccms/PressGangCCMSContentSpec/blob/2bc02e2971e4522b47a130fb7ae5a0f5ad377df1/src/main/java/org/jboss/pressgang/ccms/contentspec/Level.java#L185-L211
154,120
pressgang-ccms/PressGangCCMSContentSpec
src/main/java/org/jboss/pressgang/ccms/contentspec/Level.java
Level.removeChild
public void removeChild(final Node child) { if (child instanceof Level) { levels.remove(child); nodes.remove(child); child.setParent(null); } else if (child instanceof SpecTopic) { removeSpecTopic((SpecTopic) child); } else if (child instanceof CommonContent) { commonContents.remove(child); nodes.remove(child); child.setParent(null); } else { nodes.remove(child); child.setParent(null); } }
java
public void removeChild(final Node child) { if (child instanceof Level) { levels.remove(child); nodes.remove(child); child.setParent(null); } else if (child instanceof SpecTopic) { removeSpecTopic((SpecTopic) child); } else if (child instanceof CommonContent) { commonContents.remove(child); nodes.remove(child); child.setParent(null); } else { nodes.remove(child); child.setParent(null); } }
[ "public", "void", "removeChild", "(", "final", "Node", "child", ")", "{", "if", "(", "child", "instanceof", "Level", ")", "{", "levels", ".", "remove", "(", "child", ")", ";", "nodes", ".", "remove", "(", "child", ")", ";", "child", ".", "setParent", "(", "null", ")", ";", "}", "else", "if", "(", "child", "instanceof", "SpecTopic", ")", "{", "removeSpecTopic", "(", "(", "SpecTopic", ")", "child", ")", ";", "}", "else", "if", "(", "child", "instanceof", "CommonContent", ")", "{", "commonContents", ".", "remove", "(", "child", ")", ";", "nodes", ".", "remove", "(", "child", ")", ";", "child", ".", "setParent", "(", "null", ")", ";", "}", "else", "{", "nodes", ".", "remove", "(", "child", ")", ";", "child", ".", "setParent", "(", "null", ")", ";", "}", "}" ]
Removes a Child element from the level and removes the level as the Child's parent. @param child The Child element to be removed from the level.
[ "Removes", "a", "Child", "element", "from", "the", "level", "and", "removes", "the", "level", "as", "the", "Child", "s", "parent", "." ]
2bc02e2971e4522b47a130fb7ae5a0f5ad377df1
https://github.com/pressgang-ccms/PressGangCCMSContentSpec/blob/2bc02e2971e4522b47a130fb7ae5a0f5ad377df1/src/main/java/org/jboss/pressgang/ccms/contentspec/Level.java#L218-L233
154,121
pressgang-ccms/PressGangCCMSContentSpec
src/main/java/org/jboss/pressgang/ccms/contentspec/Level.java
Level.insertBefore
public boolean insertBefore(final Node newNode, final Node oldNode) { if (oldNode == null || newNode == null) { return false; } int index = nodes.indexOf(oldNode); if (index != -1) { // Remove the parent from the new node if one exists if (newNode.getParent() != null) { newNode.removeParent(); } newNode.setParent(this); // Add the node to the relevant list if (newNode instanceof Level) { levels.add((Level) newNode); } else if (newNode instanceof SpecTopic) { topics.add((SpecTopic) newNode); } // Insert the node if (index == 0) { nodes.addFirst(newNode); } else { nodes.add(index - 1, newNode); } return true; } else { return false; } }
java
public boolean insertBefore(final Node newNode, final Node oldNode) { if (oldNode == null || newNode == null) { return false; } int index = nodes.indexOf(oldNode); if (index != -1) { // Remove the parent from the new node if one exists if (newNode.getParent() != null) { newNode.removeParent(); } newNode.setParent(this); // Add the node to the relevant list if (newNode instanceof Level) { levels.add((Level) newNode); } else if (newNode instanceof SpecTopic) { topics.add((SpecTopic) newNode); } // Insert the node if (index == 0) { nodes.addFirst(newNode); } else { nodes.add(index - 1, newNode); } return true; } else { return false; } }
[ "public", "boolean", "insertBefore", "(", "final", "Node", "newNode", ",", "final", "Node", "oldNode", ")", "{", "if", "(", "oldNode", "==", "null", "||", "newNode", "==", "null", ")", "{", "return", "false", ";", "}", "int", "index", "=", "nodes", ".", "indexOf", "(", "oldNode", ")", ";", "if", "(", "index", "!=", "-", "1", ")", "{", "// Remove the parent from the new node if one exists", "if", "(", "newNode", ".", "getParent", "(", ")", "!=", "null", ")", "{", "newNode", ".", "removeParent", "(", ")", ";", "}", "newNode", ".", "setParent", "(", "this", ")", ";", "// Add the node to the relevant list", "if", "(", "newNode", "instanceof", "Level", ")", "{", "levels", ".", "add", "(", "(", "Level", ")", "newNode", ")", ";", "}", "else", "if", "(", "newNode", "instanceof", "SpecTopic", ")", "{", "topics", ".", "add", "(", "(", "SpecTopic", ")", "newNode", ")", ";", "}", "// Insert the node", "if", "(", "index", "==", "0", ")", "{", "nodes", ".", "addFirst", "(", "newNode", ")", ";", "}", "else", "{", "nodes", ".", "add", "(", "index", "-", "1", ",", "newNode", ")", ";", "}", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Inserts a node before the another node in the level. @param newNode The node to be inserted. @param oldNode The node that the new node should be inserted in front of. @return True if the node was inserted correctly otherwise false.
[ "Inserts", "a", "node", "before", "the", "another", "node", "in", "the", "level", "." ]
2bc02e2971e4522b47a130fb7ae5a0f5ad377df1
https://github.com/pressgang-ccms/PressGangCCMSContentSpec/blob/2bc02e2971e4522b47a130fb7ae5a0f5ad377df1/src/main/java/org/jboss/pressgang/ccms/contentspec/Level.java#L269-L297
154,122
pressgang-ccms/PressGangCCMSContentSpec
src/main/java/org/jboss/pressgang/ccms/contentspec/Level.java
Level.getTotalNumberOfChildren
protected Integer getTotalNumberOfChildren() { Integer numChildrenNodes = 0; for (Level childLevel : levels) { numChildrenNodes += childLevel.getTotalNumberOfChildren(); } return nodes.size() + numChildrenNodes; }
java
protected Integer getTotalNumberOfChildren() { Integer numChildrenNodes = 0; for (Level childLevel : levels) { numChildrenNodes += childLevel.getTotalNumberOfChildren(); } return nodes.size() + numChildrenNodes; }
[ "protected", "Integer", "getTotalNumberOfChildren", "(", ")", "{", "Integer", "numChildrenNodes", "=", "0", ";", "for", "(", "Level", "childLevel", ":", "levels", ")", "{", "numChildrenNodes", "+=", "childLevel", ".", "getTotalNumberOfChildren", "(", ")", ";", "}", "return", "nodes", ".", "size", "(", ")", "+", "numChildrenNodes", ";", "}" ]
Gets the total number of Children nodes for the level and its child levels. @return The total number of child nodes for the level and child levels.
[ "Gets", "the", "total", "number", "of", "Children", "nodes", "for", "the", "level", "and", "its", "child", "levels", "." ]
2bc02e2971e4522b47a130fb7ae5a0f5ad377df1
https://github.com/pressgang-ccms/PressGangCCMSContentSpec/blob/2bc02e2971e4522b47a130fb7ae5a0f5ad377df1/src/main/java/org/jboss/pressgang/ccms/contentspec/Level.java#L392-L398
154,123
pressgang-ccms/PressGangCCMSContentSpec
src/main/java/org/jboss/pressgang/ccms/contentspec/Level.java
Level.hasSpecTopics
public boolean hasSpecTopics() { if (getSpecTopics().size() > 0) { return true; } for (final Level childLevel : levels) { if (childLevel.hasSpecTopics()) { return true; } } return false; }
java
public boolean hasSpecTopics() { if (getSpecTopics().size() > 0) { return true; } for (final Level childLevel : levels) { if (childLevel.hasSpecTopics()) { return true; } } return false; }
[ "public", "boolean", "hasSpecTopics", "(", ")", "{", "if", "(", "getSpecTopics", "(", ")", ".", "size", "(", ")", ">", "0", ")", "{", "return", "true", ";", "}", "for", "(", "final", "Level", "childLevel", ":", "levels", ")", "{", "if", "(", "childLevel", ".", "hasSpecTopics", "(", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Checks to see if this level or any of its children contain SpecTopics. @return True if the level or the levels children contain at least one SpecTopic.
[ "Checks", "to", "see", "if", "this", "level", "or", "any", "of", "its", "children", "contain", "SpecTopics", "." ]
2bc02e2971e4522b47a130fb7ae5a0f5ad377df1
https://github.com/pressgang-ccms/PressGangCCMSContentSpec/blob/2bc02e2971e4522b47a130fb7ae5a0f5ad377df1/src/main/java/org/jboss/pressgang/ccms/contentspec/Level.java#L405-L417
154,124
pressgang-ccms/PressGangCCMSContentSpec
src/main/java/org/jboss/pressgang/ccms/contentspec/Level.java
Level.hasCommonContents
public boolean hasCommonContents() { if (getNumberOfCommonContents() > 0) { return true; } for (final Level childLevel : levels) { if (childLevel.hasCommonContents()) { return true; } } return false; }
java
public boolean hasCommonContents() { if (getNumberOfCommonContents() > 0) { return true; } for (final Level childLevel : levels) { if (childLevel.hasCommonContents()) { return true; } } return false; }
[ "public", "boolean", "hasCommonContents", "(", ")", "{", "if", "(", "getNumberOfCommonContents", "(", ")", ">", "0", ")", "{", "return", "true", ";", "}", "for", "(", "final", "Level", "childLevel", ":", "levels", ")", "{", "if", "(", "childLevel", ".", "hasCommonContents", "(", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Checks to see if this level or any of its children contain CommonContent. @return True if the level or the levels children contain at least one CommonContent.
[ "Checks", "to", "see", "if", "this", "level", "or", "any", "of", "its", "children", "contain", "CommonContent", "." ]
2bc02e2971e4522b47a130fb7ae5a0f5ad377df1
https://github.com/pressgang-ccms/PressGangCCMSContentSpec/blob/2bc02e2971e4522b47a130fb7ae5a0f5ad377df1/src/main/java/org/jboss/pressgang/ccms/contentspec/Level.java#L424-L436
154,125
pressgang-ccms/PressGangCCMSContentSpec
src/main/java/org/jboss/pressgang/ccms/contentspec/Level.java
Level.hasRevisionSpecTopics
public boolean hasRevisionSpecTopics() { for (final SpecTopic specTopic : getSpecTopics()) { if (specTopic.getRevision() != null) { return true; } } for (final Level childLevel : getChildLevels()) { if (childLevel.hasRevisionSpecTopics()) { return true; } } return false; }
java
public boolean hasRevisionSpecTopics() { for (final SpecTopic specTopic : getSpecTopics()) { if (specTopic.getRevision() != null) { return true; } } for (final Level childLevel : getChildLevels()) { if (childLevel.hasRevisionSpecTopics()) { return true; } } return false; }
[ "public", "boolean", "hasRevisionSpecTopics", "(", ")", "{", "for", "(", "final", "SpecTopic", "specTopic", ":", "getSpecTopics", "(", ")", ")", "{", "if", "(", "specTopic", ".", "getRevision", "(", ")", "!=", "null", ")", "{", "return", "true", ";", "}", "}", "for", "(", "final", "Level", "childLevel", ":", "getChildLevels", "(", ")", ")", "{", "if", "(", "childLevel", ".", "hasRevisionSpecTopics", "(", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Checks to see if this level or any of its children contain SpecTopics that represent a revision. @return True if the level or the levels children contain at least one SpecTopic that is a revision.
[ "Checks", "to", "see", "if", "this", "level", "or", "any", "of", "its", "children", "contain", "SpecTopics", "that", "represent", "a", "revision", "." ]
2bc02e2971e4522b47a130fb7ae5a0f5ad377df1
https://github.com/pressgang-ccms/PressGangCCMSContentSpec/blob/2bc02e2971e4522b47a130fb7ae5a0f5ad377df1/src/main/java/org/jboss/pressgang/ccms/contentspec/Level.java#L443-L457
154,126
pressgang-ccms/PressGangCCMSContentSpec
src/main/java/org/jboss/pressgang/ccms/contentspec/Level.java
Level.isSpecNodeInLevelByTargetID
public boolean isSpecNodeInLevelByTargetID(final String targetId) { final SpecNode foundTopic = getClosestSpecNodeByTargetId(targetId, false); return foundTopic != null; }
java
public boolean isSpecNodeInLevelByTargetID(final String targetId) { final SpecNode foundTopic = getClosestSpecNodeByTargetId(targetId, false); return foundTopic != null; }
[ "public", "boolean", "isSpecNodeInLevelByTargetID", "(", "final", "String", "targetId", ")", "{", "final", "SpecNode", "foundTopic", "=", "getClosestSpecNodeByTargetId", "(", "targetId", ",", "false", ")", ";", "return", "foundTopic", "!=", "null", ";", "}" ]
Checks to see if a SpecNode exists within this level or its children. @param targetId The Target ID of the level/topic to see if it exists. @return True if the level/topic exists within this level or its children otherwise false.
[ "Checks", "to", "see", "if", "a", "SpecNode", "exists", "within", "this", "level", "or", "its", "children", "." ]
2bc02e2971e4522b47a130fb7ae5a0f5ad377df1
https://github.com/pressgang-ccms/PressGangCCMSContentSpec/blob/2bc02e2971e4522b47a130fb7ae5a0f5ad377df1/src/main/java/org/jboss/pressgang/ccms/contentspec/Level.java#L754-L757
154,127
kirgor/enklib
common/src/main/java/com/kirgor/enklib/common/ConfigUtils.java
ConfigUtils.loadFromXMLFile
public static <T> T loadFromXMLFile(Class<T> configClass, File file) throws Exception { Persister persister = new Persister(); return persister.read(configClass, file); }
java
public static <T> T loadFromXMLFile(Class<T> configClass, File file) throws Exception { Persister persister = new Persister(); return persister.read(configClass, file); }
[ "public", "static", "<", "T", ">", "T", "loadFromXMLFile", "(", "Class", "<", "T", ">", "configClass", ",", "File", "file", ")", "throws", "Exception", "{", "Persister", "persister", "=", "new", "Persister", "(", ")", ";", "return", "persister", ".", "read", "(", "configClass", ",", "file", ")", ";", "}" ]
Loads config values from XML file, maps them to configuration class fields and returns the result instance. @param configClass Class, which fields will be mapped to config values. @param file Where to load the config from. @param <T> Generic type of configClass @return Instance of configClass with field values loaded from config file. @throws Exception
[ "Loads", "config", "values", "from", "XML", "file", "maps", "them", "to", "configuration", "class", "fields", "and", "returns", "the", "result", "instance", "." ]
8a24db296dc43db5d8fe509cf64ace0a0c7be8f2
https://github.com/kirgor/enklib/blob/8a24db296dc43db5d8fe509cf64ace0a0c7be8f2/common/src/main/java/com/kirgor/enklib/common/ConfigUtils.java#L71-L74
154,128
drewwills/cernunnos
cernunnos-core/src/main/java/org/danann/cernunnos/DynamicCacheHelper.java
DynamicCacheHelper.compareKeys
protected final boolean compareKeys(K k1, K k2) { return k1 == k2 || (k1 != null && k1.equals(k2)); }
java
protected final boolean compareKeys(K k1, K k2) { return k1 == k2 || (k1 != null && k1.equals(k2)); }
[ "protected", "final", "boolean", "compareKeys", "(", "K", "k1", ",", "K", "k2", ")", "{", "return", "k1", "==", "k2", "||", "(", "k1", "!=", "null", "&&", "k1", ".", "equals", "(", "k2", ")", ")", ";", "}" ]
Basic logic to compare two keys for equality
[ "Basic", "logic", "to", "compare", "two", "keys", "for", "equality" ]
dc6848e0253775e22b6c869fd06506d4ddb6d728
https://github.com/drewwills/cernunnos/blob/dc6848e0253775e22b6c869fd06506d4ddb6d728/cernunnos-core/src/main/java/org/danann/cernunnos/DynamicCacheHelper.java#L185-L187
154,129
jbundle/jbundle
main/msg.wsdl/src/main/java/org/jbundle/main/msg/wsdl/GetWSDL20.java
GetWSDL20.processInterfaceType
public String processInterfaceType(DescriptionType descriptionType, InterfaceType interfaceType, boolean addAddress) { String interfaceName = interfaceType.getName(); String allAddress = DBConstants.BLANK; for (Object nextElement : interfaceType.getOperationOrFaultOrFeature()) { Object interfaceOperationType = null; if (nextElement instanceof JAXBElement) interfaceOperationType = ((JAXBElement)nextElement).getValue(); if (interfaceOperationType instanceof InterfaceOperationType) { String address = this.processInterfaceOperationType(descriptionType, interfaceName, (InterfaceOperationType)interfaceOperationType, addAddress); if (allAddress != null) { if (allAddress == DBConstants.BLANK) allAddress = address; else if (!allAddress.equalsIgnoreCase(address)) allAddress = null; // null = not all address are the same } } } return allAddress; }
java
public String processInterfaceType(DescriptionType descriptionType, InterfaceType interfaceType, boolean addAddress) { String interfaceName = interfaceType.getName(); String allAddress = DBConstants.BLANK; for (Object nextElement : interfaceType.getOperationOrFaultOrFeature()) { Object interfaceOperationType = null; if (nextElement instanceof JAXBElement) interfaceOperationType = ((JAXBElement)nextElement).getValue(); if (interfaceOperationType instanceof InterfaceOperationType) { String address = this.processInterfaceOperationType(descriptionType, interfaceName, (InterfaceOperationType)interfaceOperationType, addAddress); if (allAddress != null) { if (allAddress == DBConstants.BLANK) allAddress = address; else if (!allAddress.equalsIgnoreCase(address)) allAddress = null; // null = not all address are the same } } } return allAddress; }
[ "public", "String", "processInterfaceType", "(", "DescriptionType", "descriptionType", ",", "InterfaceType", "interfaceType", ",", "boolean", "addAddress", ")", "{", "String", "interfaceName", "=", "interfaceType", ".", "getName", "(", ")", ";", "String", "allAddress", "=", "DBConstants", ".", "BLANK", ";", "for", "(", "Object", "nextElement", ":", "interfaceType", ".", "getOperationOrFaultOrFeature", "(", ")", ")", "{", "Object", "interfaceOperationType", "=", "null", ";", "if", "(", "nextElement", "instanceof", "JAXBElement", ")", "interfaceOperationType", "=", "(", "(", "JAXBElement", ")", "nextElement", ")", ".", "getValue", "(", ")", ";", "if", "(", "interfaceOperationType", "instanceof", "InterfaceOperationType", ")", "{", "String", "address", "=", "this", ".", "processInterfaceOperationType", "(", "descriptionType", ",", "interfaceName", ",", "(", "InterfaceOperationType", ")", "interfaceOperationType", ",", "addAddress", ")", ";", "if", "(", "allAddress", "!=", "null", ")", "{", "if", "(", "allAddress", "==", "DBConstants", ".", "BLANK", ")", "allAddress", "=", "address", ";", "else", "if", "(", "!", "allAddress", ".", "equalsIgnoreCase", "(", "address", ")", ")", "allAddress", "=", "null", ";", "// null = not all address are the same", "}", "}", "}", "return", "allAddress", ";", "}" ]
ProcessInterfaceType Method.
[ "ProcessInterfaceType", "Method", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/main/msg.wsdl/src/main/java/org/jbundle/main/msg/wsdl/GetWSDL20.java#L106-L130
154,130
jbundle/jbundle
thin/base/remote/src/main/java/org/jbundle/thin/base/remote/proxy/TaskProxy.java
TaskProxy.createRemoteReceiveQueue
public RemoteReceiveQueue createRemoteReceiveQueue(String strQueueName, String strQueueType) throws RemoteException { BaseTransport transport = this.createProxyTransport(CREATE_REMOTE_RECEIVE_QUEUE); transport.addParam(MessageConstants.QUEUE_NAME, strQueueName); transport.addParam(MessageConstants.QUEUE_TYPE, strQueueType); String strID = (String)transport.sendMessageAndGetReply(); return new ReceiveQueueProxy(this, strID); }
java
public RemoteReceiveQueue createRemoteReceiveQueue(String strQueueName, String strQueueType) throws RemoteException { BaseTransport transport = this.createProxyTransport(CREATE_REMOTE_RECEIVE_QUEUE); transport.addParam(MessageConstants.QUEUE_NAME, strQueueName); transport.addParam(MessageConstants.QUEUE_TYPE, strQueueType); String strID = (String)transport.sendMessageAndGetReply(); return new ReceiveQueueProxy(this, strID); }
[ "public", "RemoteReceiveQueue", "createRemoteReceiveQueue", "(", "String", "strQueueName", ",", "String", "strQueueType", ")", "throws", "RemoteException", "{", "BaseTransport", "transport", "=", "this", ".", "createProxyTransport", "(", "CREATE_REMOTE_RECEIVE_QUEUE", ")", ";", "transport", ".", "addParam", "(", "MessageConstants", ".", "QUEUE_NAME", ",", "strQueueName", ")", ";", "transport", ".", "addParam", "(", "MessageConstants", ".", "QUEUE_TYPE", ",", "strQueueType", ")", ";", "String", "strID", "=", "(", "String", ")", "transport", ".", "sendMessageAndGetReply", "(", ")", ";", "return", "new", "ReceiveQueueProxy", "(", "this", ",", "strID", ")", ";", "}" ]
Create a new remote receive queue. @param strQueueName The queue name. @param strQueueType The queue type (see MessageConstants).
[ "Create", "a", "new", "remote", "receive", "queue", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/remote/src/main/java/org/jbundle/thin/base/remote/proxy/TaskProxy.java#L129-L136
154,131
jbundle/jbundle
thin/base/remote/src/main/java/org/jbundle/thin/base/remote/proxy/TaskProxy.java
TaskProxy.createRemoteSendQueue
public RemoteSendQueue createRemoteSendQueue(String strQueueName, String strQueueType) throws RemoteException { BaseTransport transport = this.createProxyTransport(CREATE_REMOTE_SEND_QUEUE); transport.addParam(MessageConstants.QUEUE_NAME, strQueueName); transport.addParam(MessageConstants.QUEUE_TYPE, strQueueType); String strID = (String)transport.sendMessageAndGetReply(); return new SendQueueProxy(this, strID); }
java
public RemoteSendQueue createRemoteSendQueue(String strQueueName, String strQueueType) throws RemoteException { BaseTransport transport = this.createProxyTransport(CREATE_REMOTE_SEND_QUEUE); transport.addParam(MessageConstants.QUEUE_NAME, strQueueName); transport.addParam(MessageConstants.QUEUE_TYPE, strQueueType); String strID = (String)transport.sendMessageAndGetReply(); return new SendQueueProxy(this, strID); }
[ "public", "RemoteSendQueue", "createRemoteSendQueue", "(", "String", "strQueueName", ",", "String", "strQueueType", ")", "throws", "RemoteException", "{", "BaseTransport", "transport", "=", "this", ".", "createProxyTransport", "(", "CREATE_REMOTE_SEND_QUEUE", ")", ";", "transport", ".", "addParam", "(", "MessageConstants", ".", "QUEUE_NAME", ",", "strQueueName", ")", ";", "transport", ".", "addParam", "(", "MessageConstants", ".", "QUEUE_TYPE", ",", "strQueueType", ")", ";", "String", "strID", "=", "(", "String", ")", "transport", ".", "sendMessageAndGetReply", "(", ")", ";", "return", "new", "SendQueueProxy", "(", "this", ",", "strID", ")", ";", "}" ]
Create a new remote send queue. @param strQueueName The queue name. @param strQueueType The queue type (see MessageConstants).
[ "Create", "a", "new", "remote", "send", "queue", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/remote/src/main/java/org/jbundle/thin/base/remote/proxy/TaskProxy.java#L142-L149
154,132
jbundle/jbundle
thin/base/message/src/main/java/org/jbundle/thin/base/message/MessageFieldDesc.java
MessageFieldDesc.put
public void put(Object objValue) { Class<?> classData = this.getNativeClassType(); try { objValue = DataConverters.convertObjectToDatatype(objValue, classData, null); // I do this just to be careful. } catch (Exception ex) { objValue = null; } if (this.getMessage() != null) this.getMessage().putNative(this.getFullKey(null), objValue); }
java
public void put(Object objValue) { Class<?> classData = this.getNativeClassType(); try { objValue = DataConverters.convertObjectToDatatype(objValue, classData, null); // I do this just to be careful. } catch (Exception ex) { objValue = null; } if (this.getMessage() != null) this.getMessage().putNative(this.getFullKey(null), objValue); }
[ "public", "void", "put", "(", "Object", "objValue", ")", "{", "Class", "<", "?", ">", "classData", "=", "this", ".", "getNativeClassType", "(", ")", ";", "try", "{", "objValue", "=", "DataConverters", ".", "convertObjectToDatatype", "(", "objValue", ",", "classData", ",", "null", ")", ";", "// I do this just to be careful.", "}", "catch", "(", "Exception", "ex", ")", "{", "objValue", "=", "null", ";", "}", "if", "(", "this", ".", "getMessage", "(", ")", "!=", "null", ")", "this", ".", "getMessage", "(", ")", ".", "putNative", "(", "this", ".", "getFullKey", "(", "null", ")", ",", "objValue", ")", ";", "}" ]
Put the value for this param in the map. If it is not the correct object type, convert it first.
[ "Put", "the", "value", "for", "this", "param", "in", "the", "map", ".", "If", "it", "is", "not", "the", "correct", "object", "type", "convert", "it", "first", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/message/src/main/java/org/jbundle/thin/base/message/MessageFieldDesc.java#L217-L227
154,133
jbundle/jbundle
thin/base/message/src/main/java/org/jbundle/thin/base/message/MessageFieldDesc.java
MessageFieldDesc.putString
public void putString(String strValue) { Class<?> classData = this.getNativeClassType(); Object objValue = null; try { objValue = DataConverters.convertObjectToDatatype(strValue, classData, null); } catch (Exception ex) { objValue = null; } if (this.getMessage() != null) this.getMessage().putNative(this.getFullKey(null), objValue); }
java
public void putString(String strValue) { Class<?> classData = this.getNativeClassType(); Object objValue = null; try { objValue = DataConverters.convertObjectToDatatype(strValue, classData, null); } catch (Exception ex) { objValue = null; } if (this.getMessage() != null) this.getMessage().putNative(this.getFullKey(null), objValue); }
[ "public", "void", "putString", "(", "String", "strValue", ")", "{", "Class", "<", "?", ">", "classData", "=", "this", ".", "getNativeClassType", "(", ")", ";", "Object", "objValue", "=", "null", ";", "try", "{", "objValue", "=", "DataConverters", ".", "convertObjectToDatatype", "(", "strValue", ",", "classData", ",", "null", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "objValue", "=", "null", ";", "}", "if", "(", "this", ".", "getMessage", "(", ")", "!=", "null", ")", "this", ".", "getMessage", "(", ")", ".", "putNative", "(", "this", ".", "getFullKey", "(", "null", ")", ",", "objValue", ")", ";", "}" ]
Convert this external data format to the raw object and put it in the map. Typically this method is overridden to handle specific params.
[ "Convert", "this", "external", "data", "format", "to", "the", "raw", "object", "and", "put", "it", "in", "the", "map", ".", "Typically", "this", "method", "is", "overridden", "to", "handle", "specific", "params", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/message/src/main/java/org/jbundle/thin/base/message/MessageFieldDesc.java#L232-L243
154,134
arxanchain/java-common
src/main/java/com/arxanfintech/common/crypto/CertTool.java
CertTool.getCertfromPEM
public static X509Certificate getCertfromPEM(String certFile) throws IOException, CertificateException, NoSuchProviderException { InputStream inStrm = new FileInputStream(certFile); X509Certificate cert = getCertfromPEM(inStrm); return cert; }
java
public static X509Certificate getCertfromPEM(String certFile) throws IOException, CertificateException, NoSuchProviderException { InputStream inStrm = new FileInputStream(certFile); X509Certificate cert = getCertfromPEM(inStrm); return cert; }
[ "public", "static", "X509Certificate", "getCertfromPEM", "(", "String", "certFile", ")", "throws", "IOException", ",", "CertificateException", ",", "NoSuchProviderException", "{", "InputStream", "inStrm", "=", "new", "FileInputStream", "(", "certFile", ")", ";", "X509Certificate", "cert", "=", "getCertfromPEM", "(", "inStrm", ")", ";", "return", "cert", ";", "}" ]
Reads a certificate in PEM-format from a file. The file may contain other things, the first certificate in the file is read. @param certFile the file containing the certificate in PEM-format @return X509Certificate @exception IOException if the filen cannot be read. @exception CertificateException if the filen does not contain a correct certificate. @throws NoSuchProviderException NoSuchProviderException
[ "Reads", "a", "certificate", "in", "PEM", "-", "format", "from", "a", "file", ".", "The", "file", "may", "contain", "other", "things", "the", "first", "certificate", "in", "the", "file", "is", "read", "." ]
3ddfedfd948f5bab3fee0b74b85cdce4702ed84e
https://github.com/arxanchain/java-common/blob/3ddfedfd948f5bab3fee0b74b85cdce4702ed84e/src/main/java/com/arxanfintech/common/crypto/CertTool.java#L50-L55
154,135
arxanchain/java-common
src/main/java/com/arxanfintech/common/crypto/CertTool.java
CertTool.getCertfromPEM
public static X509Certificate getCertfromPEM(byte[] pemBytes) throws IOException, CertificateException, NoSuchProviderException { InputStream inStrm = new java.io.ByteArrayInputStream(pemBytes); X509Certificate cert = getCertfromPEM(inStrm); return cert; }
java
public static X509Certificate getCertfromPEM(byte[] pemBytes) throws IOException, CertificateException, NoSuchProviderException { InputStream inStrm = new java.io.ByteArrayInputStream(pemBytes); X509Certificate cert = getCertfromPEM(inStrm); return cert; }
[ "public", "static", "X509Certificate", "getCertfromPEM", "(", "byte", "[", "]", "pemBytes", ")", "throws", "IOException", ",", "CertificateException", ",", "NoSuchProviderException", "{", "InputStream", "inStrm", "=", "new", "java", ".", "io", ".", "ByteArrayInputStream", "(", "pemBytes", ")", ";", "X509Certificate", "cert", "=", "getCertfromPEM", "(", "inStrm", ")", ";", "return", "cert", ";", "}" ]
Reads a certificate in PEM-format from a byte array. The array may contain other things, the first certificate in the array is read. @param pemBytes the byte array containing the certificate in PEM-format @return X509Certificate @exception IOException if the array cannot be read. @exception CertificateException if the array does not contain a correct certificate. @throws NoSuchProviderException NoSuchProviderException
[ "Reads", "a", "certificate", "in", "PEM", "-", "format", "from", "a", "byte", "array", ".", "The", "array", "may", "contain", "other", "things", "the", "first", "certificate", "in", "the", "array", "is", "read", "." ]
3ddfedfd948f5bab3fee0b74b85cdce4702ed84e
https://github.com/arxanchain/java-common/blob/3ddfedfd948f5bab3fee0b74b85cdce4702ed84e/src/main/java/com/arxanfintech/common/crypto/CertTool.java#L71-L76
154,136
arxanchain/java-common
src/main/java/com/arxanfintech/common/crypto/CertTool.java
CertTool.getCertfromPEM
public static X509Certificate getCertfromPEM(InputStream certStream) throws IOException, CertificateException, NoSuchProviderException { String beginKey = "-----BEGIN CERTIFICATE-----"; String endKey = "-----END CERTIFICATE-----"; BufferedReader bufRdr = new BufferedReader(new InputStreamReader(certStream)); ByteArrayOutputStream ostr = new ByteArrayOutputStream(); PrintStream opstr = new PrintStream(ostr); String temp; while ((temp = bufRdr.readLine()) != null && !temp.equals(beginKey)) continue; if (temp == null) throw new IOException("Error in " + certStream.toString() + ", missing " + beginKey + " boundary"); while ((temp = bufRdr.readLine()) != null && !temp.equals(endKey)) opstr.print(temp); if (temp == null) throw new IOException("Error in " + certStream.toString() + ", missing " + endKey + " boundary"); opstr.close(); byte[] certbuf = Base64.decode(ostr.toByteArray()); // X509Certificate object CertificateFactory cf = CertificateFactory.getInstance("X.509", "SC"); X509Certificate x509cert = (X509Certificate) cf.generateCertificate(new ByteArrayInputStream(certbuf)); return x509cert; }
java
public static X509Certificate getCertfromPEM(InputStream certStream) throws IOException, CertificateException, NoSuchProviderException { String beginKey = "-----BEGIN CERTIFICATE-----"; String endKey = "-----END CERTIFICATE-----"; BufferedReader bufRdr = new BufferedReader(new InputStreamReader(certStream)); ByteArrayOutputStream ostr = new ByteArrayOutputStream(); PrintStream opstr = new PrintStream(ostr); String temp; while ((temp = bufRdr.readLine()) != null && !temp.equals(beginKey)) continue; if (temp == null) throw new IOException("Error in " + certStream.toString() + ", missing " + beginKey + " boundary"); while ((temp = bufRdr.readLine()) != null && !temp.equals(endKey)) opstr.print(temp); if (temp == null) throw new IOException("Error in " + certStream.toString() + ", missing " + endKey + " boundary"); opstr.close(); byte[] certbuf = Base64.decode(ostr.toByteArray()); // X509Certificate object CertificateFactory cf = CertificateFactory.getInstance("X.509", "SC"); X509Certificate x509cert = (X509Certificate) cf.generateCertificate(new ByteArrayInputStream(certbuf)); return x509cert; }
[ "public", "static", "X509Certificate", "getCertfromPEM", "(", "InputStream", "certStream", ")", "throws", "IOException", ",", "CertificateException", ",", "NoSuchProviderException", "{", "String", "beginKey", "=", "\"-----BEGIN CERTIFICATE-----\"", ";", "String", "endKey", "=", "\"-----END CERTIFICATE-----\"", ";", "BufferedReader", "bufRdr", "=", "new", "BufferedReader", "(", "new", "InputStreamReader", "(", "certStream", ")", ")", ";", "ByteArrayOutputStream", "ostr", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "PrintStream", "opstr", "=", "new", "PrintStream", "(", "ostr", ")", ";", "String", "temp", ";", "while", "(", "(", "temp", "=", "bufRdr", ".", "readLine", "(", ")", ")", "!=", "null", "&&", "!", "temp", ".", "equals", "(", "beginKey", ")", ")", "continue", ";", "if", "(", "temp", "==", "null", ")", "throw", "new", "IOException", "(", "\"Error in \"", "+", "certStream", ".", "toString", "(", ")", "+", "\", missing \"", "+", "beginKey", "+", "\" boundary\"", ")", ";", "while", "(", "(", "temp", "=", "bufRdr", ".", "readLine", "(", ")", ")", "!=", "null", "&&", "!", "temp", ".", "equals", "(", "endKey", ")", ")", "opstr", ".", "print", "(", "temp", ")", ";", "if", "(", "temp", "==", "null", ")", "throw", "new", "IOException", "(", "\"Error in \"", "+", "certStream", ".", "toString", "(", ")", "+", "\", missing \"", "+", "endKey", "+", "\" boundary\"", ")", ";", "opstr", ".", "close", "(", ")", ";", "byte", "[", "]", "certbuf", "=", "Base64", ".", "decode", "(", "ostr", ".", "toByteArray", "(", ")", ")", ";", "// X509Certificate object", "CertificateFactory", "cf", "=", "CertificateFactory", ".", "getInstance", "(", "\"X.509\"", ",", "\"SC\"", ")", ";", "X509Certificate", "x509cert", "=", "(", "X509Certificate", ")", "cf", ".", "generateCertificate", "(", "new", "ByteArrayInputStream", "(", "certbuf", ")", ")", ";", "return", "x509cert", ";", "}" ]
Reads a certificate in PEM-format from an InputStream. The stream may contain other things, the first certificate in the stream is read. @param certStream the input stream containing the certificate in PEM-format @return X509Certificate @exception IOException if the stream cannot be read. @exception CertificateException if the stream does not contain a correct certificate. @throws NoSuchProviderException NoSuchProviderException
[ "Reads", "a", "certificate", "in", "PEM", "-", "format", "from", "an", "InputStream", ".", "The", "stream", "may", "contain", "other", "things", "the", "first", "certificate", "in", "the", "stream", "is", "read", "." ]
3ddfedfd948f5bab3fee0b74b85cdce4702ed84e
https://github.com/arxanchain/java-common/blob/3ddfedfd948f5bab3fee0b74b85cdce4702ed84e/src/main/java/com/arxanfintech/common/crypto/CertTool.java#L92-L117
154,137
Multifarious/MacroManager
src/main/java/com/fasterxml/mama/listeners/HandoffResultsListener.java
HandoffResultsListener.iRequestedHandoff
private boolean iRequestedHandoff(String workUnit) { String destinationNode = cluster.getHandoffResult(workUnit); return (destinationNode != null) && cluster.myWorkUnits.contains(workUnit) && !destinationNode.equals("") && !cluster.isMe(destinationNode); }
java
private boolean iRequestedHandoff(String workUnit) { String destinationNode = cluster.getHandoffResult(workUnit); return (destinationNode != null) && cluster.myWorkUnits.contains(workUnit) && !destinationNode.equals("") && !cluster.isMe(destinationNode); }
[ "private", "boolean", "iRequestedHandoff", "(", "String", "workUnit", ")", "{", "String", "destinationNode", "=", "cluster", ".", "getHandoffResult", "(", "workUnit", ")", ";", "return", "(", "destinationNode", "!=", "null", ")", "&&", "cluster", ".", "myWorkUnits", ".", "contains", "(", "workUnit", ")", "&&", "!", "destinationNode", ".", "equals", "(", "\"\"", ")", "&&", "!", "cluster", ".", "isMe", "(", "destinationNode", ")", ";", "}" ]
Determines if this node requested handoff of a work unit to someone else. I have requested handoff of a work unit if it's currently a member of my active set and its destination node is another node in the cluster.
[ "Determines", "if", "this", "node", "requested", "handoff", "of", "a", "work", "unit", "to", "someone", "else", ".", "I", "have", "requested", "handoff", "of", "a", "work", "unit", "if", "it", "s", "currently", "a", "member", "of", "my", "active", "set", "and", "its", "destination", "node", "is", "another", "node", "in", "the", "cluster", "." ]
559785839981f460aaeba3c3fddff7fb667d9581
https://github.com/Multifarious/MacroManager/blob/559785839981f460aaeba3c3fddff7fb667d9581/src/main/java/com/fasterxml/mama/listeners/HandoffResultsListener.java#L64-L71
154,138
Multifarious/MacroManager
src/main/java/com/fasterxml/mama/listeners/HandoffResultsListener.java
HandoffResultsListener.shutdownAfterHandoff
private Runnable shutdownAfterHandoff(final String workUnit) { final Cluster cluster = this.cluster; final Logger log = LOG; return new Runnable() { @Override public void run() { String str = cluster.getHandoffResult(workUnit); log.info("Shutting down {} following handoff to {}.", workUnit, (str == null) ? "(None)" : str); cluster.shutdownWork(workUnit, /*doLog =*/ false); if (cluster.hasState(NodeState.Draining) && cluster.myWorkUnits.isEmpty()) { cluster.shutdown(); } } }; }
java
private Runnable shutdownAfterHandoff(final String workUnit) { final Cluster cluster = this.cluster; final Logger log = LOG; return new Runnable() { @Override public void run() { String str = cluster.getHandoffResult(workUnit); log.info("Shutting down {} following handoff to {}.", workUnit, (str == null) ? "(None)" : str); cluster.shutdownWork(workUnit, /*doLog =*/ false); if (cluster.hasState(NodeState.Draining) && cluster.myWorkUnits.isEmpty()) { cluster.shutdown(); } } }; }
[ "private", "Runnable", "shutdownAfterHandoff", "(", "final", "String", "workUnit", ")", "{", "final", "Cluster", "cluster", "=", "this", ".", "cluster", ";", "final", "Logger", "log", "=", "LOG", ";", "return", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "String", "str", "=", "cluster", ".", "getHandoffResult", "(", "workUnit", ")", ";", "log", ".", "info", "(", "\"Shutting down {} following handoff to {}.\"", ",", "workUnit", ",", "(", "str", "==", "null", ")", "?", "\"(None)\"", ":", "str", ")", ";", "cluster", ".", "shutdownWork", "(", "workUnit", ",", "/*doLog =*/", "false", ")", ";", "if", "(", "cluster", ".", "hasState", "(", "NodeState", ".", "Draining", ")", "&&", "cluster", ".", "myWorkUnits", ".", "isEmpty", "(", ")", ")", "{", "cluster", ".", "shutdown", "(", ")", ";", "}", "}", "}", ";", "}" ]
Builds a runnable to shut down a work unit after a configurable delay once handoff has completed. If the cluster has been instructed to shut down and the last work unit has been handed off, this task also directs this Ordasity instance to shut down.
[ "Builds", "a", "runnable", "to", "shut", "down", "a", "work", "unit", "after", "a", "configurable", "delay", "once", "handoff", "has", "completed", ".", "If", "the", "cluster", "has", "been", "instructed", "to", "shut", "down", "and", "the", "last", "work", "unit", "has", "been", "handed", "off", "this", "task", "also", "directs", "this", "Ordasity", "instance", "to", "shut", "down", "." ]
559785839981f460aaeba3c3fddff7fb667d9581
https://github.com/Multifarious/MacroManager/blob/559785839981f460aaeba3c3fddff7fb667d9581/src/main/java/com/fasterxml/mama/listeners/HandoffResultsListener.java#L78-L95
154,139
Multifarious/MacroManager
src/main/java/com/fasterxml/mama/listeners/HandoffResultsListener.java
HandoffResultsListener.finishHandoff
public void finishHandoff(final String workUnit) throws InterruptedException { String unitId = cluster.workUnitMap.get(workUnit); LOG.info("Handoff of {} to me acknowledged. Deleting claim ZNode for {} and waiting for {} to shutdown work.", workUnit, workUnit, ((unitId == null) ? "(None)" : unitId)); final String path = cluster.workUnitClaimPath(workUnit); Stat stat = ZKUtils.exists(cluster.zk, path, new Watcher() { @Override public void process(WatchedEvent event) { // Don't really care about the type of event here - call unconditionally to clean up state completeHandoff(workUnit, path); } }); // Unlikely that peer will have already deleted znode, but handle it regardless if (stat == null) { LOG.warn("Peer already deleted znode of {}", workUnit); completeHandoff(workUnit, path); } }
java
public void finishHandoff(final String workUnit) throws InterruptedException { String unitId = cluster.workUnitMap.get(workUnit); LOG.info("Handoff of {} to me acknowledged. Deleting claim ZNode for {} and waiting for {} to shutdown work.", workUnit, workUnit, ((unitId == null) ? "(None)" : unitId)); final String path = cluster.workUnitClaimPath(workUnit); Stat stat = ZKUtils.exists(cluster.zk, path, new Watcher() { @Override public void process(WatchedEvent event) { // Don't really care about the type of event here - call unconditionally to clean up state completeHandoff(workUnit, path); } }); // Unlikely that peer will have already deleted znode, but handle it regardless if (stat == null) { LOG.warn("Peer already deleted znode of {}", workUnit); completeHandoff(workUnit, path); } }
[ "public", "void", "finishHandoff", "(", "final", "String", "workUnit", ")", "throws", "InterruptedException", "{", "String", "unitId", "=", "cluster", ".", "workUnitMap", ".", "get", "(", "workUnit", ")", ";", "LOG", ".", "info", "(", "\"Handoff of {} to me acknowledged. Deleting claim ZNode for {} and waiting for {} to shutdown work.\"", ",", "workUnit", ",", "workUnit", ",", "(", "(", "unitId", "==", "null", ")", "?", "\"(None)\"", ":", "unitId", ")", ")", ";", "final", "String", "path", "=", "cluster", ".", "workUnitClaimPath", "(", "workUnit", ")", ";", "Stat", "stat", "=", "ZKUtils", ".", "exists", "(", "cluster", ".", "zk", ",", "path", ",", "new", "Watcher", "(", ")", "{", "@", "Override", "public", "void", "process", "(", "WatchedEvent", "event", ")", "{", "// Don't really care about the type of event here - call unconditionally to clean up state", "completeHandoff", "(", "workUnit", ",", "path", ")", ";", "}", "}", ")", ";", "// Unlikely that peer will have already deleted znode, but handle it regardless", "if", "(", "stat", "==", "null", ")", "{", "LOG", ".", "warn", "(", "\"Peer already deleted znode of {}\"", ",", "workUnit", ")", ";", "completeHandoff", "(", "workUnit", ",", "path", ")", ";", "}", "}" ]
Completes the process of handing off a work unit from one node to the current one. Attempts to establish a final claim to the node handed off to me in ZooKeeper, and repeats execution of the task every two seconds until it is complete.
[ "Completes", "the", "process", "of", "handing", "off", "a", "work", "unit", "from", "one", "node", "to", "the", "current", "one", ".", "Attempts", "to", "establish", "a", "final", "claim", "to", "the", "node", "handed", "off", "to", "me", "in", "ZooKeeper", "and", "repeats", "execution", "of", "the", "task", "every", "two", "seconds", "until", "it", "is", "complete", "." ]
559785839981f460aaeba3c3fddff7fb667d9581
https://github.com/Multifarious/MacroManager/blob/559785839981f460aaeba3c3fddff7fb667d9581/src/main/java/com/fasterxml/mama/listeners/HandoffResultsListener.java#L102-L123
154,140
tvesalainen/util
security/src/main/java/org/vesalainen/net/ssl/SSLServerSocketChannel.java
SSLServerSocketChannel.open
public static SSLServerSocketChannel open(SocketAddress address) throws IOException { try { return open(address, SSLContext.getDefault()); } catch (NoSuchAlgorithmException ex) { throw new IOException(ex); } }
java
public static SSLServerSocketChannel open(SocketAddress address) throws IOException { try { return open(address, SSLContext.getDefault()); } catch (NoSuchAlgorithmException ex) { throw new IOException(ex); } }
[ "public", "static", "SSLServerSocketChannel", "open", "(", "SocketAddress", "address", ")", "throws", "IOException", "{", "try", "{", "return", "open", "(", "address", ",", "SSLContext", ".", "getDefault", "(", ")", ")", ";", "}", "catch", "(", "NoSuchAlgorithmException", "ex", ")", "{", "throw", "new", "IOException", "(", "ex", ")", ";", "}", "}" ]
Creates and binds SSLServerSocketChannel using default SSLContext. @param address @return @throws IOException
[ "Creates", "and", "binds", "SSLServerSocketChannel", "using", "default", "SSLContext", "." ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/security/src/main/java/org/vesalainen/net/ssl/SSLServerSocketChannel.java#L76-L86
154,141
arxanchain/java-common
src/main/java/com/arxanfintech/common/crypto/Hash.java
Hash.merge
public static Hash merge(Hash a, Hash b) { try { MessageDigest digest = MessageDigest.getInstance("SHA-256"); digest.update(a.bytes); return Hash.createFromSafeArray(digest.digest(digest.digest(b.bytes))); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } }
java
public static Hash merge(Hash a, Hash b) { try { MessageDigest digest = MessageDigest.getInstance("SHA-256"); digest.update(a.bytes); return Hash.createFromSafeArray(digest.digest(digest.digest(b.bytes))); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } }
[ "public", "static", "Hash", "merge", "(", "Hash", "a", ",", "Hash", "b", ")", "{", "try", "{", "MessageDigest", "digest", "=", "MessageDigest", ".", "getInstance", "(", "\"SHA-256\"", ")", ";", "digest", ".", "update", "(", "a", ".", "bytes", ")", ";", "return", "Hash", ".", "createFromSafeArray", "(", "digest", ".", "digest", "(", "digest", ".", "digest", "(", "b", ".", "bytes", ")", ")", ")", ";", "}", "catch", "(", "NoSuchAlgorithmException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}" ]
Merge two Hashes into one for Merkle Tree calculation @param a - a Hash @param b - another Hash @return SHA256(SHA256(a||b))
[ "Merge", "two", "Hashes", "into", "one", "for", "Merkle", "Tree", "calculation" ]
3ddfedfd948f5bab3fee0b74b85cdce4702ed84e
https://github.com/arxanchain/java-common/blob/3ddfedfd948f5bab3fee0b74b85cdce4702ed84e/src/main/java/com/arxanfintech/common/crypto/Hash.java#L114-L122
154,142
arxanchain/java-common
src/main/java/com/arxanfintech/common/crypto/Hash.java
Hash.hash
public static byte[] hash(byte[] data, int offset, int len) { try { MessageDigest a = MessageDigest.getInstance("SHA-256"); a.update(data, offset, len); return a.digest(); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } }
java
public static byte[] hash(byte[] data, int offset, int len) { try { MessageDigest a = MessageDigest.getInstance("SHA-256"); a.update(data, offset, len); return a.digest(); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } }
[ "public", "static", "byte", "[", "]", "hash", "(", "byte", "[", "]", "data", ",", "int", "offset", ",", "int", "len", ")", "{", "try", "{", "MessageDigest", "a", "=", "MessageDigest", ".", "getInstance", "(", "\"SHA-256\"", ")", ";", "a", ".", "update", "(", "data", ",", "offset", ",", "len", ")", ";", "return", "a", ".", "digest", "(", ")", ";", "}", "catch", "(", "NoSuchAlgorithmException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}" ]
SHA256 hash of arbitrary data @param data arbitary data @param offset start hashing at this offset (0 starts) @param len hash len number of bytes @return SHA256(data)
[ "SHA256", "hash", "of", "arbitrary", "data" ]
3ddfedfd948f5bab3fee0b74b85cdce4702ed84e
https://github.com/arxanchain/java-common/blob/3ddfedfd948f5bab3fee0b74b85cdce4702ed84e/src/main/java/com/arxanfintech/common/crypto/Hash.java#L132-L140
154,143
arxanchain/java-common
src/main/java/com/arxanfintech/common/crypto/Hash.java
Hash.toUuidString
public String toUuidString() { String[] items = new String[] {contentAsHex(0, 4), contentAsHex(4, 6), contentAsHex(6, 8), contentAsHex(8, 10), contentAsHex(10, 16)}; String result = StringUtils.join(items, "-"); return result.toLowerCase(); }
java
public String toUuidString() { String[] items = new String[] {contentAsHex(0, 4), contentAsHex(4, 6), contentAsHex(6, 8), contentAsHex(8, 10), contentAsHex(10, 16)}; String result = StringUtils.join(items, "-"); return result.toLowerCase(); }
[ "public", "String", "toUuidString", "(", ")", "{", "String", "[", "]", "items", "=", "new", "String", "[", "]", "{", "contentAsHex", "(", "0", ",", "4", ")", ",", "contentAsHex", "(", "4", ",", "6", ")", ",", "contentAsHex", "(", "6", ",", "8", ")", ",", "contentAsHex", "(", "8", ",", "10", ")", ",", "contentAsHex", "(", "10", ",", "16", ")", "}", ";", "String", "result", "=", "StringUtils", ".", "join", "(", "items", ",", "\"-\"", ")", ";", "return", "result", ".", "toLowerCase", "(", ")", ";", "}" ]
UUID created from the first 128 bits of SHA256 @return String
[ "UUID", "created", "from", "the", "first", "128", "bits", "of", "SHA256" ]
3ddfedfd948f5bab3fee0b74b85cdce4702ed84e
https://github.com/arxanchain/java-common/blob/3ddfedfd948f5bab3fee0b74b85cdce4702ed84e/src/main/java/com/arxanfintech/common/crypto/Hash.java#L167-L173
154,144
glookast/commons-timecode
src/main/java/com/glookast/commons/timecode/MutableTimecode.java
MutableTimecode.valueOf
public static MutableTimecode valueOf(String timecode) throws IllegalArgumentException { MutableTimecode tc = new MutableTimecode(); return (MutableTimecode) tc.parse(timecode); }
java
public static MutableTimecode valueOf(String timecode) throws IllegalArgumentException { MutableTimecode tc = new MutableTimecode(); return (MutableTimecode) tc.parse(timecode); }
[ "public", "static", "MutableTimecode", "valueOf", "(", "String", "timecode", ")", "throws", "IllegalArgumentException", "{", "MutableTimecode", "tc", "=", "new", "MutableTimecode", "(", ")", ";", "return", "(", "MutableTimecode", ")", "tc", ".", "parse", "(", "timecode", ")", ";", "}" ]
Returns a MutableTimecode instance for given Timecode storage string. Will return an invalid timecode in case the storage string represents an invalid Timecode @param timecode @return the timecode @throws IllegalArgumentException
[ "Returns", "a", "MutableTimecode", "instance", "for", "given", "Timecode", "storage", "string", ".", "Will", "return", "an", "invalid", "timecode", "in", "case", "the", "storage", "string", "represents", "an", "invalid", "Timecode" ]
ec2f682a51d1cc435d0b42d80de48ff15adb4ee8
https://github.com/glookast/commons-timecode/blob/ec2f682a51d1cc435d0b42d80de48ff15adb4ee8/src/main/java/com/glookast/commons/timecode/MutableTimecode.java#L58-L62
154,145
tvesalainen/util
util/src/main/java/org/vesalainen/math/AbstractCubicSpline.java
AbstractCubicSpline.getMatrix
protected DoubleMatrix getMatrix(int n) { Map<Integer, DoubleMatrix> degreeMap = matrixCache.get(this.getClass()); if (degreeMap == null) { degreeMap = new HashMap<>(); matrixCache.put(this.getClass(), degreeMap); } DoubleMatrix m = degreeMap.get(n); if (m == null) { m = createMatrix(n); m.decompose(); degreeMap.put(n, m); } return m; }
java
protected DoubleMatrix getMatrix(int n) { Map<Integer, DoubleMatrix> degreeMap = matrixCache.get(this.getClass()); if (degreeMap == null) { degreeMap = new HashMap<>(); matrixCache.put(this.getClass(), degreeMap); } DoubleMatrix m = degreeMap.get(n); if (m == null) { m = createMatrix(n); m.decompose(); degreeMap.put(n, m); } return m; }
[ "protected", "DoubleMatrix", "getMatrix", "(", "int", "n", ")", "{", "Map", "<", "Integer", ",", "DoubleMatrix", ">", "degreeMap", "=", "matrixCache", ".", "get", "(", "this", ".", "getClass", "(", ")", ")", ";", "if", "(", "degreeMap", "==", "null", ")", "{", "degreeMap", "=", "new", "HashMap", "<>", "(", ")", ";", "matrixCache", ".", "put", "(", "this", ".", "getClass", "(", ")", ",", "degreeMap", ")", ";", "}", "DoubleMatrix", "m", "=", "degreeMap", ".", "get", "(", "n", ")", ";", "if", "(", "m", "==", "null", ")", "{", "m", "=", "createMatrix", "(", "n", ")", ";", "m", ".", "decompose", "(", ")", ";", "degreeMap", ".", "put", "(", "n", ",", "m", ")", ";", "}", "return", "m", ";", "}" ]
Returns class cached DoubleMatrix with decompose already called. @param n @return
[ "Returns", "class", "cached", "DoubleMatrix", "with", "decompose", "already", "called", "." ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/math/AbstractCubicSpline.java#L155-L171
154,146
pressgang-ccms/PressGangCCMSRESTv1Common
src/main/java/org/jboss/pressgang/ccms/rest/v1/collections/contentspec/join/RESTCSRelatedNodeCollectionV1.java
RESTCSRelatedNodeCollectionV1.ignoreDuplicatedChangeItemRequests
@Override protected void ignoreDuplicatedChangeItemRequests() { if (getItems() != null) { final List<RESTCSRelatedNodeCollectionItemV1> items = new ArrayList<RESTCSRelatedNodeCollectionItemV1>(getItems()); /* on the second loop, remove any items that are marked for both add and remove is separate items */ for (int i = 0; i < items.size(); ++i) { final RESTCSRelatedNodeCollectionItemV1 child1 = items.get(i); final RESTCSRelatedNodeV1 childItem1 = child1.getItem(); // New Entity so ignore it if (childItem1.getId() == null) continue; /* at this point we know that either add1 or remove1 will be true, but not both */ final boolean add1 = child1.getState().equals(ADD_STATE); final boolean remove1 = child1.getState().equals(REMOVE_STATE); final boolean update1 = child1.getState().equals(UPDATE_STATE); /* Loop a second time, looking for duplicates */ for (int j = i + 1; j < items.size(); ++j) { final RESTCSRelatedNodeCollectionItemV1 child2 = items.get(j); final RESTCSRelatedNodeV1 childItem2 = child2.getItem(); // New Entity so ignore it if (childItem2.getId() == null) continue; final boolean relationshipIdEqual = childItem1.getRelationshipId() == null && childItem2.getRelationshipId() == null || childItem1.getRelationshipId() != null && childItem1.getRelationshipId().equals( childItem2.getRelationshipId()); /* Check the RelatedNode objects for their value as well as their IDs to ensure duplicates are removed*/ if (childItem1.getId().equals(childItem2.getId()) && relationshipIdEqual) { final boolean add2 = child2.getState().equals(ADD_STATE); final boolean remove2 = child2.getState().equals(REMOVE_STATE); final boolean update2 = child2.getState().equals(UPDATE_STATE); /* Do some checks on values that could be null */ final boolean typeEqual = childItem1.getRelationshipType() == null && childItem2.getRelationshipType() == null || childItem1.getRelationshipType() != null && childItem1.getRelationshipType().equals( childItem2.getRelationshipType()); /* check for double add, double remove, double update, and remove one instance */ if ((add1 && add2) || (remove1 && remove2) || (update1 && update2)) { /* * If the relationship types are equal then we only need to remove one item. If * the are different then both should be removed. */ if (typeEqual) { getItems().remove(child1); } else { getItems().remove(child1); getItems().remove(child2); } } /* check for double add, double remove, add and remove, remove and add */ if ((add1 && remove2) || (remove1 && add2) || (update1 && remove2) || (update2 && remove1) || (update1 && add2) || (update2 && add1)) { getItems().remove(child1); getItems().remove(child2); } } } } } }
java
@Override protected void ignoreDuplicatedChangeItemRequests() { if (getItems() != null) { final List<RESTCSRelatedNodeCollectionItemV1> items = new ArrayList<RESTCSRelatedNodeCollectionItemV1>(getItems()); /* on the second loop, remove any items that are marked for both add and remove is separate items */ for (int i = 0; i < items.size(); ++i) { final RESTCSRelatedNodeCollectionItemV1 child1 = items.get(i); final RESTCSRelatedNodeV1 childItem1 = child1.getItem(); // New Entity so ignore it if (childItem1.getId() == null) continue; /* at this point we know that either add1 or remove1 will be true, but not both */ final boolean add1 = child1.getState().equals(ADD_STATE); final boolean remove1 = child1.getState().equals(REMOVE_STATE); final boolean update1 = child1.getState().equals(UPDATE_STATE); /* Loop a second time, looking for duplicates */ for (int j = i + 1; j < items.size(); ++j) { final RESTCSRelatedNodeCollectionItemV1 child2 = items.get(j); final RESTCSRelatedNodeV1 childItem2 = child2.getItem(); // New Entity so ignore it if (childItem2.getId() == null) continue; final boolean relationshipIdEqual = childItem1.getRelationshipId() == null && childItem2.getRelationshipId() == null || childItem1.getRelationshipId() != null && childItem1.getRelationshipId().equals( childItem2.getRelationshipId()); /* Check the RelatedNode objects for their value as well as their IDs to ensure duplicates are removed*/ if (childItem1.getId().equals(childItem2.getId()) && relationshipIdEqual) { final boolean add2 = child2.getState().equals(ADD_STATE); final boolean remove2 = child2.getState().equals(REMOVE_STATE); final boolean update2 = child2.getState().equals(UPDATE_STATE); /* Do some checks on values that could be null */ final boolean typeEqual = childItem1.getRelationshipType() == null && childItem2.getRelationshipType() == null || childItem1.getRelationshipType() != null && childItem1.getRelationshipType().equals( childItem2.getRelationshipType()); /* check for double add, double remove, double update, and remove one instance */ if ((add1 && add2) || (remove1 && remove2) || (update1 && update2)) { /* * If the relationship types are equal then we only need to remove one item. If * the are different then both should be removed. */ if (typeEqual) { getItems().remove(child1); } else { getItems().remove(child1); getItems().remove(child2); } } /* check for double add, double remove, add and remove, remove and add */ if ((add1 && remove2) || (remove1 && add2) || (update1 && remove2) || (update2 && remove1) || (update1 && add2) || (update2 && add1)) { getItems().remove(child1); getItems().remove(child2); } } } } } }
[ "@", "Override", "protected", "void", "ignoreDuplicatedChangeItemRequests", "(", ")", "{", "if", "(", "getItems", "(", ")", "!=", "null", ")", "{", "final", "List", "<", "RESTCSRelatedNodeCollectionItemV1", ">", "items", "=", "new", "ArrayList", "<", "RESTCSRelatedNodeCollectionItemV1", ">", "(", "getItems", "(", ")", ")", ";", "/* on the second loop, remove any items that are marked for both add and remove is separate items */", "for", "(", "int", "i", "=", "0", ";", "i", "<", "items", ".", "size", "(", ")", ";", "++", "i", ")", "{", "final", "RESTCSRelatedNodeCollectionItemV1", "child1", "=", "items", ".", "get", "(", "i", ")", ";", "final", "RESTCSRelatedNodeV1", "childItem1", "=", "child1", ".", "getItem", "(", ")", ";", "// New Entity so ignore it", "if", "(", "childItem1", ".", "getId", "(", ")", "==", "null", ")", "continue", ";", "/* at this point we know that either add1 or remove1 will be true, but not both */", "final", "boolean", "add1", "=", "child1", ".", "getState", "(", ")", ".", "equals", "(", "ADD_STATE", ")", ";", "final", "boolean", "remove1", "=", "child1", ".", "getState", "(", ")", ".", "equals", "(", "REMOVE_STATE", ")", ";", "final", "boolean", "update1", "=", "child1", ".", "getState", "(", ")", ".", "equals", "(", "UPDATE_STATE", ")", ";", "/* Loop a second time, looking for duplicates */", "for", "(", "int", "j", "=", "i", "+", "1", ";", "j", "<", "items", ".", "size", "(", ")", ";", "++", "j", ")", "{", "final", "RESTCSRelatedNodeCollectionItemV1", "child2", "=", "items", ".", "get", "(", "j", ")", ";", "final", "RESTCSRelatedNodeV1", "childItem2", "=", "child2", ".", "getItem", "(", ")", ";", "// New Entity so ignore it", "if", "(", "childItem2", ".", "getId", "(", ")", "==", "null", ")", "continue", ";", "final", "boolean", "relationshipIdEqual", "=", "childItem1", ".", "getRelationshipId", "(", ")", "==", "null", "&&", "childItem2", ".", "getRelationshipId", "(", ")", "==", "null", "||", "childItem1", ".", "getRelationshipId", "(", ")", "!=", "null", "&&", "childItem1", ".", "getRelationshipId", "(", ")", ".", "equals", "(", "childItem2", ".", "getRelationshipId", "(", ")", ")", ";", "/* Check the RelatedNode objects for their value as well as their IDs to ensure duplicates are removed*/", "if", "(", "childItem1", ".", "getId", "(", ")", ".", "equals", "(", "childItem2", ".", "getId", "(", ")", ")", "&&", "relationshipIdEqual", ")", "{", "final", "boolean", "add2", "=", "child2", ".", "getState", "(", ")", ".", "equals", "(", "ADD_STATE", ")", ";", "final", "boolean", "remove2", "=", "child2", ".", "getState", "(", ")", ".", "equals", "(", "REMOVE_STATE", ")", ";", "final", "boolean", "update2", "=", "child2", ".", "getState", "(", ")", ".", "equals", "(", "UPDATE_STATE", ")", ";", "/* Do some checks on values that could be null */", "final", "boolean", "typeEqual", "=", "childItem1", ".", "getRelationshipType", "(", ")", "==", "null", "&&", "childItem2", ".", "getRelationshipType", "(", ")", "==", "null", "||", "childItem1", ".", "getRelationshipType", "(", ")", "!=", "null", "&&", "childItem1", ".", "getRelationshipType", "(", ")", ".", "equals", "(", "childItem2", ".", "getRelationshipType", "(", ")", ")", ";", "/* check for double add, double remove, double update, and remove one instance */", "if", "(", "(", "add1", "&&", "add2", ")", "||", "(", "remove1", "&&", "remove2", ")", "||", "(", "update1", "&&", "update2", ")", ")", "{", "/* \n * If the relationship types are equal then we only need to remove one item. If\n * the are different then both should be removed. \n */", "if", "(", "typeEqual", ")", "{", "getItems", "(", ")", ".", "remove", "(", "child1", ")", ";", "}", "else", "{", "getItems", "(", ")", ".", "remove", "(", "child1", ")", ";", "getItems", "(", ")", ".", "remove", "(", "child2", ")", ";", "}", "}", "/* check for double add, double remove, add and remove, remove and add */", "if", "(", "(", "add1", "&&", "remove2", ")", "||", "(", "remove1", "&&", "add2", ")", "||", "(", "update1", "&&", "remove2", ")", "||", "(", "update2", "&&", "remove1", ")", "||", "(", "update1", "&&", "add2", ")", "||", "(", "update2", "&&", "add1", ")", ")", "{", "getItems", "(", ")", ".", "remove", "(", "child1", ")", ";", "getItems", "(", ")", ".", "remove", "(", "child2", ")", ";", "}", "}", "}", "}", "}", "}" ]
This method will clear out any child items that are marked for both add and remove, or duplicated add and remove requests. Override this method to deal with collections where the children are not uniquely identified by only their id.
[ "This", "method", "will", "clear", "out", "any", "child", "items", "that", "are", "marked", "for", "both", "add", "and", "remove", "or", "duplicated", "add", "and", "remove", "requests", ".", "Override", "this", "method", "to", "deal", "with", "collections", "where", "the", "children", "are", "not", "uniquely", "identified", "by", "only", "their", "id", "." ]
0641d21b127297b47035f3b8e55fba81251b419c
https://github.com/pressgang-ccms/PressGangCCMSRESTv1Common/blob/0641d21b127297b47035f3b8e55fba81251b419c/src/main/java/org/jboss/pressgang/ccms/rest/v1/collections/contentspec/join/RESTCSRelatedNodeCollectionV1.java#L60-L125
154,147
jbundle/jbundle
base/base/src/main/java/org/jbundle/base/field/convert/RecipFieldConverter.java
RecipFieldConverter.setString
public int setString( String strField, boolean bDisplayOption, int iMoveMode) { NumberField numberField = (NumberField)this.getNextConverter(); int iErrorCode = super.setString(strField, DBConstants.DONT_DISPLAY, iMoveMode); if (strField.length() == 0) numberField.displayField(); // Special Case (because we return immediately) if ((iErrorCode != DBConstants.NORMAL_RETURN) || strField.length() == 0) return iErrorCode; double doubleValue = this.getValue(); if (doubleValue != 0) doubleValue = 1 / doubleValue; iErrorCode = this.setValue(doubleValue, bDisplayOption, DBConstants.SCREEN_MOVE); return iErrorCode; }
java
public int setString( String strField, boolean bDisplayOption, int iMoveMode) { NumberField numberField = (NumberField)this.getNextConverter(); int iErrorCode = super.setString(strField, DBConstants.DONT_DISPLAY, iMoveMode); if (strField.length() == 0) numberField.displayField(); // Special Case (because we return immediately) if ((iErrorCode != DBConstants.NORMAL_RETURN) || strField.length() == 0) return iErrorCode; double doubleValue = this.getValue(); if (doubleValue != 0) doubleValue = 1 / doubleValue; iErrorCode = this.setValue(doubleValue, bDisplayOption, DBConstants.SCREEN_MOVE); return iErrorCode; }
[ "public", "int", "setString", "(", "String", "strField", ",", "boolean", "bDisplayOption", ",", "int", "iMoveMode", ")", "{", "NumberField", "numberField", "=", "(", "NumberField", ")", "this", ".", "getNextConverter", "(", ")", ";", "int", "iErrorCode", "=", "super", ".", "setString", "(", "strField", ",", "DBConstants", ".", "DONT_DISPLAY", ",", "iMoveMode", ")", ";", "if", "(", "strField", ".", "length", "(", ")", "==", "0", ")", "numberField", ".", "displayField", "(", ")", ";", "// Special Case (because we return immediately)", "if", "(", "(", "iErrorCode", "!=", "DBConstants", ".", "NORMAL_RETURN", ")", "||", "strField", ".", "length", "(", ")", "==", "0", ")", "return", "iErrorCode", ";", "double", "doubleValue", "=", "this", ".", "getValue", "(", ")", ";", "if", "(", "doubleValue", "!=", "0", ")", "doubleValue", "=", "1", "/", "doubleValue", ";", "iErrorCode", "=", "this", ".", "setValue", "(", "doubleValue", ",", "bDisplayOption", ",", "DBConstants", ".", "SCREEN_MOVE", ")", ";", "return", "iErrorCode", ";", "}" ]
Convert and move string to this field. Get the recriprical of this string and set the string. @param bState the state to set the data to. @param bDisplayOption Display the data on the screen if true. @param iMoveMode INIT, SCREEN, or READ move mode. @return The error code (or NORMAL_RETURN).
[ "Convert", "and", "move", "string", "to", "this", "field", ".", "Get", "the", "recriprical", "of", "this", "string", "and", "set", "the", "string", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/field/convert/RecipFieldConverter.java#L77-L90
154,148
FrodeRanders/java-vopn
src/main/java/org/gautelis/vopn/queue/WorkerQueueFactory.java
WorkerQueueFactory.getWorkQueue
public static WorkQueue getWorkQueue(Type type, int nThreads) { switch(type) { case Simple: return new SimpleWorkQueue(nThreads); case Multi: return new MultiWorkQueue(nThreads); //case WorkStealing: default: return new MultiWorkQueue(nThreads); } }
java
public static WorkQueue getWorkQueue(Type type, int nThreads) { switch(type) { case Simple: return new SimpleWorkQueue(nThreads); case Multi: return new MultiWorkQueue(nThreads); //case WorkStealing: default: return new MultiWorkQueue(nThreads); } }
[ "public", "static", "WorkQueue", "getWorkQueue", "(", "Type", "type", ",", "int", "nThreads", ")", "{", "switch", "(", "type", ")", "{", "case", "Simple", ":", "return", "new", "SimpleWorkQueue", "(", "nThreads", ")", ";", "case", "Multi", ":", "return", "new", "MultiWorkQueue", "(", "nThreads", ")", ";", "//case WorkStealing:\r", "default", ":", "return", "new", "MultiWorkQueue", "(", "nThreads", ")", ";", "}", "}" ]
Returns a thread-backed queue. @param type {@link Type} of queue @param nThreads number of threads tending to the queue @return a worker queue
[ "Returns", "a", "thread", "-", "backed", "queue", "." ]
4c7b2f90201327af4eaa3cd46b3fee68f864e5cc
https://github.com/FrodeRanders/java-vopn/blob/4c7b2f90201327af4eaa3cd46b3fee68f864e5cc/src/main/java/org/gautelis/vopn/queue/WorkerQueueFactory.java#L46-L58
154,149
nwillc/almost-functional
src/main/java/almost/functional/reactive/Promise.java
Promise.run
@Override public void run() { if (!state.compareAndSet(State.CREATED, State.PENDING)) { throw new IllegalStateException("Can only run a promise in the CREATED state"); } T result; try { result = supplier.get(); state.set(State.COMPLETED); observer.next(result); observer.completed(true); } catch (Exception e) { state.set(State.ERROR); observer.error(e); observer.completed(false); } observer = null; //NOPMD }
java
@Override public void run() { if (!state.compareAndSet(State.CREATED, State.PENDING)) { throw new IllegalStateException("Can only run a promise in the CREATED state"); } T result; try { result = supplier.get(); state.set(State.COMPLETED); observer.next(result); observer.completed(true); } catch (Exception e) { state.set(State.ERROR); observer.error(e); observer.completed(false); } observer = null; //NOPMD }
[ "@", "Override", "public", "void", "run", "(", ")", "{", "if", "(", "!", "state", ".", "compareAndSet", "(", "State", ".", "CREATED", ",", "State", ".", "PENDING", ")", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Can only run a promise in the CREATED state\"", ")", ";", "}", "T", "result", ";", "try", "{", "result", "=", "supplier", ".", "get", "(", ")", ";", "state", ".", "set", "(", "State", ".", "COMPLETED", ")", ";", "observer", ".", "next", "(", "result", ")", ";", "observer", ".", "completed", "(", "true", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "state", ".", "set", "(", "State", ".", "ERROR", ")", ";", "observer", ".", "error", "(", "e", ")", ";", "observer", ".", "completed", "(", "false", ")", ";", "}", "observer", "=", "null", ";", "//NOPMD", "}" ]
This method calls the supplier and on successful completion informs the fulfilled consumers of the return value. If the supplier throws an exception the rejected consumers are informed. In either case when the call to the supplier completes the settled consumers are informed with an Optional containing the supplied value on success.
[ "This", "method", "calls", "the", "supplier", "and", "on", "successful", "completion", "informs", "the", "fulfilled", "consumers", "of", "the", "return", "value", ".", "If", "the", "supplier", "throws", "an", "exception", "the", "rejected", "consumers", "are", "informed", ".", "In", "either", "case", "when", "the", "call", "to", "the", "supplier", "completes", "the", "settled", "consumers", "are", "informed", "with", "an", "Optional", "containing", "the", "supplied", "value", "on", "success", "." ]
a6cc7c73b2be475ed1bce5128c24b2eb9c27d666
https://github.com/nwillc/almost-functional/blob/a6cc7c73b2be475ed1bce5128c24b2eb9c27d666/src/main/java/almost/functional/reactive/Promise.java#L78-L95
154,150
jbundle/jbundle
thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/menu/JRemoteMenuScreen.java
JRemoteMenuScreen.init
public void init(Object parent, Object record) { if (parent instanceof BaseApplet) m_strInitParam = ((BaseApplet)parent).getProperty(Params.MENU); super.init(parent, record); }
java
public void init(Object parent, Object record) { if (parent instanceof BaseApplet) m_strInitParam = ((BaseApplet)parent).getProperty(Params.MENU); super.init(parent, record); }
[ "public", "void", "init", "(", "Object", "parent", ",", "Object", "record", ")", "{", "if", "(", "parent", "instanceof", "BaseApplet", ")", "m_strInitParam", "=", "(", "(", "BaseApplet", ")", "parent", ")", ".", "getProperty", "(", "Params", ".", "MENU", ")", ";", "super", ".", "init", "(", "parent", ",", "record", ")", ";", "}" ]
Initialize this class. If there is a top-level "menu=" property, save it for later. @param parent Typically, you pass the BaseApplet as the parent. @param record and the record or GridTableModel as the parent.
[ "Initialize", "this", "class", ".", "If", "there", "is", "a", "top", "-", "level", "menu", "=", "property", "save", "it", "for", "later", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/menu/JRemoteMenuScreen.java#L64-L69
154,151
jbundle/jbundle
thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/menu/JRemoteMenuScreen.java
JRemoteMenuScreen.buildFieldList
public FieldList buildFieldList() { FieldList record = (FieldList)ClassServiceUtility.getClassService().makeObjectFromClassName(Constants.ROOT_PACKAGE + "thin.main.db.Menus"); if (record != null) record.init(this); else return null; record.setOpenMode(Constants.OPEN_READ_ONLY); // This will improve performance by enabling the cache for readnext. BaseApplet applet = BaseApplet.getSharedInstance(); m_remoteSession = applet.makeRemoteSession(null, ".main.remote.MenusSession"); applet.linkRemoteSessionTable(m_remoteSession, record, true); if (m_strInitParam != null) { try { m_remoteSession.doRemoteAction(m_strInitParam, null); } catch (Exception ex) { // Ignore error } } return record; }
java
public FieldList buildFieldList() { FieldList record = (FieldList)ClassServiceUtility.getClassService().makeObjectFromClassName(Constants.ROOT_PACKAGE + "thin.main.db.Menus"); if (record != null) record.init(this); else return null; record.setOpenMode(Constants.OPEN_READ_ONLY); // This will improve performance by enabling the cache for readnext. BaseApplet applet = BaseApplet.getSharedInstance(); m_remoteSession = applet.makeRemoteSession(null, ".main.remote.MenusSession"); applet.linkRemoteSessionTable(m_remoteSession, record, true); if (m_strInitParam != null) { try { m_remoteSession.doRemoteAction(m_strInitParam, null); } catch (Exception ex) { // Ignore error } } return record; }
[ "public", "FieldList", "buildFieldList", "(", ")", "{", "FieldList", "record", "=", "(", "FieldList", ")", "ClassServiceUtility", ".", "getClassService", "(", ")", ".", "makeObjectFromClassName", "(", "Constants", ".", "ROOT_PACKAGE", "+", "\"thin.main.db.Menus\"", ")", ";", "if", "(", "record", "!=", "null", ")", "record", ".", "init", "(", "this", ")", ";", "else", "return", "null", ";", "record", ".", "setOpenMode", "(", "Constants", ".", "OPEN_READ_ONLY", ")", ";", "// This will improve performance by enabling the cache for readnext.", "BaseApplet", "applet", "=", "BaseApplet", ".", "getSharedInstance", "(", ")", ";", "m_remoteSession", "=", "applet", ".", "makeRemoteSession", "(", "null", ",", "\".main.remote.MenusSession\"", ")", ";", "applet", ".", "linkRemoteSessionTable", "(", "m_remoteSession", ",", "record", ",", "true", ")", ";", "if", "(", "m_strInitParam", "!=", "null", ")", "{", "try", "{", "m_remoteSession", ".", "doRemoteAction", "(", "m_strInitParam", ",", "null", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "// Ignore error", "}", "}", "return", "record", ";", "}" ]
Build the list of fields that make up the screen. This method creates a new Menus record and links it to the remote MenusSession. @return the field.
[ "Build", "the", "list", "of", "fields", "that", "make", "up", "the", "screen", ".", "This", "method", "creates", "a", "new", "Menus", "record", "and", "links", "it", "to", "the", "remote", "MenusSession", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/menu/JRemoteMenuScreen.java#L123-L144
154,152
tvesalainen/util
util/src/main/java/org/vesalainen/ui/AbstractView.java
AbstractView.setMargin
public void setMargin(Rectangle2D bounds, Direction... dirs) { for (Direction dir : dirs) { switch (dir) { case BOTTOM: combinedTransform.transform(userBounds.getCenterX(), userBounds.getMinY(), (x,y)-> { inverse.transform(x, y+bounds.getHeight(), this::updatePoint); }); break; case LEFT: combinedTransform.transform(userBounds.getMinX(), userBounds.getCenterY(), (x,y)-> { inverse.transform(x-bounds.getWidth(), y, this::updatePoint); }); break; case RIGHT: combinedTransform.transform(userBounds.getMaxX(), userBounds.getCenterY(), (x,y)-> { inverse.transform(x+bounds.getWidth(), y, this::updatePoint); }); break; case TOP: combinedTransform.transform(userBounds.getCenterX(), userBounds.getMaxY(), (x,y)-> { inverse.transform(x, y-bounds.getHeight(), this::updatePoint); }); break; } } }
java
public void setMargin(Rectangle2D bounds, Direction... dirs) { for (Direction dir : dirs) { switch (dir) { case BOTTOM: combinedTransform.transform(userBounds.getCenterX(), userBounds.getMinY(), (x,y)-> { inverse.transform(x, y+bounds.getHeight(), this::updatePoint); }); break; case LEFT: combinedTransform.transform(userBounds.getMinX(), userBounds.getCenterY(), (x,y)-> { inverse.transform(x-bounds.getWidth(), y, this::updatePoint); }); break; case RIGHT: combinedTransform.transform(userBounds.getMaxX(), userBounds.getCenterY(), (x,y)-> { inverse.transform(x+bounds.getWidth(), y, this::updatePoint); }); break; case TOP: combinedTransform.transform(userBounds.getCenterX(), userBounds.getMaxY(), (x,y)-> { inverse.transform(x, y-bounds.getHeight(), this::updatePoint); }); break; } } }
[ "public", "void", "setMargin", "(", "Rectangle2D", "bounds", ",", "Direction", "...", "dirs", ")", "{", "for", "(", "Direction", "dir", ":", "dirs", ")", "{", "switch", "(", "dir", ")", "{", "case", "BOTTOM", ":", "combinedTransform", ".", "transform", "(", "userBounds", ".", "getCenterX", "(", ")", ",", "userBounds", ".", "getMinY", "(", ")", ",", "(", "x", ",", "y", ")", "->", "{", "inverse", ".", "transform", "(", "x", ",", "y", "+", "bounds", ".", "getHeight", "(", ")", ",", "this", "::", "updatePoint", ")", ";", "}", ")", ";", "break", ";", "case", "LEFT", ":", "combinedTransform", ".", "transform", "(", "userBounds", ".", "getMinX", "(", ")", ",", "userBounds", ".", "getCenterY", "(", ")", ",", "(", "x", ",", "y", ")", "->", "{", "inverse", ".", "transform", "(", "x", "-", "bounds", ".", "getWidth", "(", ")", ",", "y", ",", "this", "::", "updatePoint", ")", ";", "}", ")", ";", "break", ";", "case", "RIGHT", ":", "combinedTransform", ".", "transform", "(", "userBounds", ".", "getMaxX", "(", ")", ",", "userBounds", ".", "getCenterY", "(", ")", ",", "(", "x", ",", "y", ")", "->", "{", "inverse", ".", "transform", "(", "x", "+", "bounds", ".", "getWidth", "(", ")", ",", "y", ",", "this", "::", "updatePoint", ")", ";", "}", ")", ";", "break", ";", "case", "TOP", ":", "combinedTransform", ".", "transform", "(", "userBounds", ".", "getCenterX", "(", ")", ",", "userBounds", ".", "getMaxY", "(", ")", ",", "(", "x", ",", "y", ")", "->", "{", "inverse", ".", "transform", "(", "x", ",", "y", "-", "bounds", ".", "getHeight", "(", ")", ",", "this", "::", "updatePoint", ")", ";", "}", ")", ";", "break", ";", "}", "}", "}" ]
Enlarges margin in screen coordinates to given directions @param bounds @param dirs
[ "Enlarges", "margin", "in", "screen", "coordinates", "to", "given", "directions" ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/ui/AbstractView.java#L109-L141
154,153
tvesalainen/util
util/src/main/java/org/vesalainen/ui/AbstractView.java
AbstractView.toScreenX
public double toScreenX(double x) { Point2D src = srcPnt.get(); Point2D dst = dstPnt.get(); src.setLocation(x, 0); combinedTransform.transform(src, dst); return dst.getX(); //return scaleX * x + xOff; }
java
public double toScreenX(double x) { Point2D src = srcPnt.get(); Point2D dst = dstPnt.get(); src.setLocation(x, 0); combinedTransform.transform(src, dst); return dst.getX(); //return scaleX * x + xOff; }
[ "public", "double", "toScreenX", "(", "double", "x", ")", "{", "Point2D", "src", "=", "srcPnt", ".", "get", "(", ")", ";", "Point2D", "dst", "=", "dstPnt", ".", "get", "(", ")", ";", "src", ".", "setLocation", "(", "x", ",", "0", ")", ";", "combinedTransform", ".", "transform", "(", "src", ",", "dst", ")", ";", "return", "dst", ".", "getX", "(", ")", ";", "//return scaleX * x + xOff;", "}" ]
Translates cartesian x-coordinate to screen coordinate. @param x @return
[ "Translates", "cartesian", "x", "-", "coordinate", "to", "screen", "coordinate", "." ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/ui/AbstractView.java#L182-L190
154,154
tvesalainen/util
util/src/main/java/org/vesalainen/ui/AbstractView.java
AbstractView.toScreenY
public double toScreenY(double y) { Point2D src = srcPnt.get(); Point2D dst = dstPnt.get(); src.setLocation(0, y); combinedTransform.transform(src, dst); return dst.getY(); }
java
public double toScreenY(double y) { Point2D src = srcPnt.get(); Point2D dst = dstPnt.get(); src.setLocation(0, y); combinedTransform.transform(src, dst); return dst.getY(); }
[ "public", "double", "toScreenY", "(", "double", "y", ")", "{", "Point2D", "src", "=", "srcPnt", ".", "get", "(", ")", ";", "Point2D", "dst", "=", "dstPnt", ".", "get", "(", ")", ";", "src", ".", "setLocation", "(", "0", ",", "y", ")", ";", "combinedTransform", ".", "transform", "(", "src", ",", "dst", ")", ";", "return", "dst", ".", "getY", "(", ")", ";", "}" ]
Translates cartesian y-coordinate to screen coordinate. @param y @return
[ "Translates", "cartesian", "y", "-", "coordinate", "to", "screen", "coordinate", "." ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/ui/AbstractView.java#L196-L203
154,155
tvesalainen/util
util/src/main/java/org/vesalainen/ui/AbstractView.java
AbstractView.fromScreenX
public double fromScreenX(double x) { Point2D src = srcPnt.get(); Point2D dst = dstPnt.get(); src.setLocation(x, 0); inverse.transform(src, dst); return dst.getX(); }
java
public double fromScreenX(double x) { Point2D src = srcPnt.get(); Point2D dst = dstPnt.get(); src.setLocation(x, 0); inverse.transform(src, dst); return dst.getX(); }
[ "public", "double", "fromScreenX", "(", "double", "x", ")", "{", "Point2D", "src", "=", "srcPnt", ".", "get", "(", ")", ";", "Point2D", "dst", "=", "dstPnt", ".", "get", "(", ")", ";", "src", ".", "setLocation", "(", "x", ",", "0", ")", ";", "inverse", ".", "transform", "(", "src", ",", "dst", ")", ";", "return", "dst", ".", "getX", "(", ")", ";", "}" ]
Translates screen x-coordinate to cartesian coordinate. @param x @return
[ "Translates", "screen", "x", "-", "coordinate", "to", "cartesian", "coordinate", "." ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/ui/AbstractView.java#L209-L216
154,156
tvesalainen/util
util/src/main/java/org/vesalainen/ui/AbstractView.java
AbstractView.fromScreenY
public double fromScreenY(double y) { Point2D src = srcPnt.get(); Point2D dst = dstPnt.get(); src.setLocation(0, y); inverse.transform(src, dst); return dst.getY(); }
java
public double fromScreenY(double y) { Point2D src = srcPnt.get(); Point2D dst = dstPnt.get(); src.setLocation(0, y); inverse.transform(src, dst); return dst.getY(); }
[ "public", "double", "fromScreenY", "(", "double", "y", ")", "{", "Point2D", "src", "=", "srcPnt", ".", "get", "(", ")", ";", "Point2D", "dst", "=", "dstPnt", ".", "get", "(", ")", ";", "src", ".", "setLocation", "(", "0", ",", "y", ")", ";", "inverse", ".", "transform", "(", "src", ",", "dst", ")", ";", "return", "dst", ".", "getY", "(", ")", ";", "}" ]
Translates screen y-coordinate to cartesian coordinate. @param y @return
[ "Translates", "screen", "y", "-", "coordinate", "to", "cartesian", "coordinate", "." ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/ui/AbstractView.java#L222-L229
154,157
Multifarious/MacroManager
src/main/java/com/fasterxml/mama/Cluster.java
Cluster.znodeIsMe
public boolean znodeIsMe(String path) { String value = ZKUtils.get(zk, path); return (value != null && value == myNodeID); }
java
public boolean znodeIsMe(String path) { String value = ZKUtils.get(zk, path); return (value != null && value == myNodeID); }
[ "public", "boolean", "znodeIsMe", "(", "String", "path", ")", "{", "String", "value", "=", "ZKUtils", ".", "get", "(", "zk", ",", "path", ")", ";", "return", "(", "value", "!=", "null", "&&", "value", "==", "myNodeID", ")", ";", "}" ]
Given a path, determines whether or not the value of a ZNode is my node ID.
[ "Given", "a", "path", "determines", "whether", "or", "not", "the", "value", "of", "a", "ZNode", "is", "my", "node", "ID", "." ]
559785839981f460aaeba3c3fddff7fb667d9581
https://github.com/Multifarious/MacroManager/blob/559785839981f460aaeba3c3fddff7fb667d9581/src/main/java/com/fasterxml/mama/Cluster.java#L236-L239
154,158
Multifarious/MacroManager
src/main/java/com/fasterxml/mama/Cluster.java
Cluster.join
public NodeState join(ZooKeeperClient injectedClient) throws InterruptedException { switch (state.get()) { case Fresh: connect(injectedClient); break; case Shutdown: connect(injectedClient); break; case Draining: LOG.warn("'join' called while draining; ignoring."); break; case Started: LOG.warn("'join' called after started; ignoring."); break; } // why not Enum itself? return state.get(); }
java
public NodeState join(ZooKeeperClient injectedClient) throws InterruptedException { switch (state.get()) { case Fresh: connect(injectedClient); break; case Shutdown: connect(injectedClient); break; case Draining: LOG.warn("'join' called while draining; ignoring."); break; case Started: LOG.warn("'join' called after started; ignoring."); break; } // why not Enum itself? return state.get(); }
[ "public", "NodeState", "join", "(", "ZooKeeperClient", "injectedClient", ")", "throws", "InterruptedException", "{", "switch", "(", "state", ".", "get", "(", ")", ")", "{", "case", "Fresh", ":", "connect", "(", "injectedClient", ")", ";", "break", ";", "case", "Shutdown", ":", "connect", "(", "injectedClient", ")", ";", "break", ";", "case", "Draining", ":", "LOG", ".", "warn", "(", "\"'join' called while draining; ignoring.\"", ")", ";", "break", ";", "case", "Started", ":", "LOG", ".", "warn", "(", "\"'join' called after started; ignoring.\"", ")", ";", "break", ";", "}", "// why not Enum itself?", "return", "state", ".", "get", "(", ")", ";", "}" ]
Joins the cluster using a custom zk client, claims work, and begins operation.
[ "Joins", "the", "cluster", "using", "a", "custom", "zk", "client", "claims", "work", "and", "begins", "operation", "." ]
559785839981f460aaeba3c3fddff7fb667d9581
https://github.com/Multifarious/MacroManager/blob/559785839981f460aaeba3c3fddff7fb667d9581/src/main/java/com/fasterxml/mama/Cluster.java#L329-L347
154,159
Multifarious/MacroManager
src/main/java/com/fasterxml/mama/Cluster.java
Cluster.connect
private void connect(ZooKeeperClient injectedClient) throws InterruptedException { if (!initialized.get()) { if (injectedClient == null) { List<InetSocketAddress> hosts = new ArrayList<InetSocketAddress>(); for (String host : config.hosts.split(",")) { String[] parts = host.split(":"); try { hosts.add(new InetSocketAddress(parts[0], Integer.parseInt(parts[1]))); } catch (Exception e) { LOG.error("Invalid ZK host '"+host+"', need to skip, problem: "+e.getMessage()); } } // TODO: What about empty hosts at this point? LOG.info("Connecting to hosts: {}", hosts.toString()); injectedClient = new ZooKeeperClient(Amount.of((int) config.zkTimeout, Time.MILLISECONDS), hosts); } zk = injectedClient; claimer.start(); LOG.info("Registering connection watcher."); zk.register(connectionWatcher); } // and then see that we can actually get the client without problems try { zk.get(); } catch (ZooKeeperConnectionException e) { throw ZKException.from(e); } }
java
private void connect(ZooKeeperClient injectedClient) throws InterruptedException { if (!initialized.get()) { if (injectedClient == null) { List<InetSocketAddress> hosts = new ArrayList<InetSocketAddress>(); for (String host : config.hosts.split(",")) { String[] parts = host.split(":"); try { hosts.add(new InetSocketAddress(parts[0], Integer.parseInt(parts[1]))); } catch (Exception e) { LOG.error("Invalid ZK host '"+host+"', need to skip, problem: "+e.getMessage()); } } // TODO: What about empty hosts at this point? LOG.info("Connecting to hosts: {}", hosts.toString()); injectedClient = new ZooKeeperClient(Amount.of((int) config.zkTimeout, Time.MILLISECONDS), hosts); } zk = injectedClient; claimer.start(); LOG.info("Registering connection watcher."); zk.register(connectionWatcher); } // and then see that we can actually get the client without problems try { zk.get(); } catch (ZooKeeperConnectionException e) { throw ZKException.from(e); } }
[ "private", "void", "connect", "(", "ZooKeeperClient", "injectedClient", ")", "throws", "InterruptedException", "{", "if", "(", "!", "initialized", ".", "get", "(", ")", ")", "{", "if", "(", "injectedClient", "==", "null", ")", "{", "List", "<", "InetSocketAddress", ">", "hosts", "=", "new", "ArrayList", "<", "InetSocketAddress", ">", "(", ")", ";", "for", "(", "String", "host", ":", "config", ".", "hosts", ".", "split", "(", "\",\"", ")", ")", "{", "String", "[", "]", "parts", "=", "host", ".", "split", "(", "\":\"", ")", ";", "try", "{", "hosts", ".", "add", "(", "new", "InetSocketAddress", "(", "parts", "[", "0", "]", ",", "Integer", ".", "parseInt", "(", "parts", "[", "1", "]", ")", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "LOG", ".", "error", "(", "\"Invalid ZK host '\"", "+", "host", "+", "\"', need to skip, problem: \"", "+", "e", ".", "getMessage", "(", ")", ")", ";", "}", "}", "// TODO: What about empty hosts at this point?", "LOG", ".", "info", "(", "\"Connecting to hosts: {}\"", ",", "hosts", ".", "toString", "(", ")", ")", ";", "injectedClient", "=", "new", "ZooKeeperClient", "(", "Amount", ".", "of", "(", "(", "int", ")", "config", ".", "zkTimeout", ",", "Time", ".", "MILLISECONDS", ")", ",", "hosts", ")", ";", "}", "zk", "=", "injectedClient", ";", "claimer", ".", "start", "(", ")", ";", "LOG", ".", "info", "(", "\"Registering connection watcher.\"", ")", ";", "zk", ".", "register", "(", "connectionWatcher", ")", ";", "}", "// and then see that we can actually get the client without problems", "try", "{", "zk", ".", "get", "(", ")", ";", "}", "catch", "(", "ZooKeeperConnectionException", "e", ")", "{", "throw", "ZKException", ".", "from", "(", "e", ")", ";", "}", "}" ]
Directs the ZooKeeperClient to connect to the ZooKeeper ensemble and wait for the connection to be established before continuing.
[ "Directs", "the", "ZooKeeperClient", "to", "connect", "to", "the", "ZooKeeper", "ensemble", "and", "wait", "for", "the", "connection", "to", "be", "established", "before", "continuing", "." ]
559785839981f460aaeba3c3fddff7fb667d9581
https://github.com/Multifarious/MacroManager/blob/559785839981f460aaeba3c3fddff7fb667d9581/src/main/java/com/fasterxml/mama/Cluster.java#L387-L415
154,160
Multifarious/MacroManager
src/main/java/com/fasterxml/mama/Cluster.java
Cluster.stopAndWait
public void stopAndWait(final long waitTime, final AtomicBoolean stopFlag) { if (!waitInProgress.getAndSet(true)) { stopFlag.set(true); rejoinExecutor.submit(new Runnable() { @Override public void run() { balancingPolicy.drainToCount(0, false); try { Thread.sleep(waitTime); } catch (InterruptedException e) { LOG.warn("Interrupted while waiting."); } LOG.info("Back to work."); stopFlag.set(false); waitInProgress.set(false); } }); } }
java
public void stopAndWait(final long waitTime, final AtomicBoolean stopFlag) { if (!waitInProgress.getAndSet(true)) { stopFlag.set(true); rejoinExecutor.submit(new Runnable() { @Override public void run() { balancingPolicy.drainToCount(0, false); try { Thread.sleep(waitTime); } catch (InterruptedException e) { LOG.warn("Interrupted while waiting."); } LOG.info("Back to work."); stopFlag.set(false); waitInProgress.set(false); } }); } }
[ "public", "void", "stopAndWait", "(", "final", "long", "waitTime", ",", "final", "AtomicBoolean", "stopFlag", ")", "{", "if", "(", "!", "waitInProgress", ".", "getAndSet", "(", "true", ")", ")", "{", "stopFlag", ".", "set", "(", "true", ")", ";", "rejoinExecutor", ".", "submit", "(", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "balancingPolicy", ".", "drainToCount", "(", "0", ",", "false", ")", ";", "try", "{", "Thread", ".", "sleep", "(", "waitTime", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "LOG", ".", "warn", "(", "\"Interrupted while waiting.\"", ")", ";", "}", "LOG", ".", "info", "(", "\"Back to work.\"", ")", ";", "stopFlag", ".", "set", "(", "false", ")", ";", "waitInProgress", ".", "set", "(", "false", ")", ";", "}", "}", ")", ";", "}", "}" ]
For handling problematic nodes - drains workers and does not claim work for waitTime seconds
[ "For", "handling", "problematic", "nodes", "-", "drains", "workers", "and", "does", "not", "claim", "work", "for", "waitTime", "seconds" ]
559785839981f460aaeba3c3fddff7fb667d9581
https://github.com/Multifarious/MacroManager/blob/559785839981f460aaeba3c3fddff7fb667d9581/src/main/java/com/fasterxml/mama/Cluster.java#L421-L439
154,161
Multifarious/MacroManager
src/main/java/com/fasterxml/mama/Cluster.java
Cluster.completeShutdown
public void completeShutdown() { setState(NodeState.Shutdown); shutdownAllWorkUnits(); deleteFromZk(); if (claimer != null) { claimer.interrupt(); try { claimer.join(); } catch (InterruptedException e) { LOG.warn("Shutdown of Claimer interrupted"); } } // The connection watcher will attempt to reconnect - unregister it if (connectionWatcher != null) { zk.unregister(connectionWatcher); } try { zk.close(); } catch (Exception e) { LOG.warn("Zookeeper reported exception on shutdown.", e); } listener.onLeave(); }
java
public void completeShutdown() { setState(NodeState.Shutdown); shutdownAllWorkUnits(); deleteFromZk(); if (claimer != null) { claimer.interrupt(); try { claimer.join(); } catch (InterruptedException e) { LOG.warn("Shutdown of Claimer interrupted"); } } // The connection watcher will attempt to reconnect - unregister it if (connectionWatcher != null) { zk.unregister(connectionWatcher); } try { zk.close(); } catch (Exception e) { LOG.warn("Zookeeper reported exception on shutdown.", e); } listener.onLeave(); }
[ "public", "void", "completeShutdown", "(", ")", "{", "setState", "(", "NodeState", ".", "Shutdown", ")", ";", "shutdownAllWorkUnits", "(", ")", ";", "deleteFromZk", "(", ")", ";", "if", "(", "claimer", "!=", "null", ")", "{", "claimer", ".", "interrupt", "(", ")", ";", "try", "{", "claimer", ".", "join", "(", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "LOG", ".", "warn", "(", "\"Shutdown of Claimer interrupted\"", ")", ";", "}", "}", "// The connection watcher will attempt to reconnect - unregister it", "if", "(", "connectionWatcher", "!=", "null", ")", "{", "zk", ".", "unregister", "(", "connectionWatcher", ")", ";", "}", "try", "{", "zk", ".", "close", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "LOG", ".", "warn", "(", "\"Zookeeper reported exception on shutdown.\"", ",", "e", ")", ";", "}", "listener", ".", "onLeave", "(", ")", ";", "}" ]
Finalizes the shutdown sequence. Called once the drain operation completes.
[ "Finalizes", "the", "shutdown", "sequence", ".", "Called", "once", "the", "drain", "operation", "completes", "." ]
559785839981f460aaeba3c3fddff7fb667d9581
https://github.com/Multifarious/MacroManager/blob/559785839981f460aaeba3c3fddff7fb667d9581/src/main/java/com/fasterxml/mama/Cluster.java#L472-L494
154,162
Multifarious/MacroManager
src/main/java/com/fasterxml/mama/Cluster.java
Cluster.onConnect
void onConnect() throws InterruptedException, IOException { if (state.get() != NodeState.Fresh) { if (previousZKSessionStillActive()) { LOG.info("ZooKeeper session re-established before timeout."); return; } LOG.warn("Rejoined after session timeout. Forcing shutdown and clean startup."); ensureCleanStartup(); } LOG.info("Connected to Zookeeper (ID: {}).", myNodeID); ZKUtils.ensureOrdasityPaths(zk, name, config.workUnitName, config.workUnitShortName); joinCluster(); listener.onJoin(zk); if (watchesRegistered.compareAndSet(false, true)) { registerWatchers(); } initialized.set(true); initializedLatch.countDown(); setState(NodeState.Started); claimer.requestClaim(); verifyIntegrity(); balancingPolicy.onConnect(); if (config.enableAutoRebalance) { scheduleRebalancing(); } }
java
void onConnect() throws InterruptedException, IOException { if (state.get() != NodeState.Fresh) { if (previousZKSessionStillActive()) { LOG.info("ZooKeeper session re-established before timeout."); return; } LOG.warn("Rejoined after session timeout. Forcing shutdown and clean startup."); ensureCleanStartup(); } LOG.info("Connected to Zookeeper (ID: {}).", myNodeID); ZKUtils.ensureOrdasityPaths(zk, name, config.workUnitName, config.workUnitShortName); joinCluster(); listener.onJoin(zk); if (watchesRegistered.compareAndSet(false, true)) { registerWatchers(); } initialized.set(true); initializedLatch.countDown(); setState(NodeState.Started); claimer.requestClaim(); verifyIntegrity(); balancingPolicy.onConnect(); if (config.enableAutoRebalance) { scheduleRebalancing(); } }
[ "void", "onConnect", "(", ")", "throws", "InterruptedException", ",", "IOException", "{", "if", "(", "state", ".", "get", "(", ")", "!=", "NodeState", ".", "Fresh", ")", "{", "if", "(", "previousZKSessionStillActive", "(", ")", ")", "{", "LOG", ".", "info", "(", "\"ZooKeeper session re-established before timeout.\"", ")", ";", "return", ";", "}", "LOG", ".", "warn", "(", "\"Rejoined after session timeout. Forcing shutdown and clean startup.\"", ")", ";", "ensureCleanStartup", "(", ")", ";", "}", "LOG", ".", "info", "(", "\"Connected to Zookeeper (ID: {}).\"", ",", "myNodeID", ")", ";", "ZKUtils", ".", "ensureOrdasityPaths", "(", "zk", ",", "name", ",", "config", ".", "workUnitName", ",", "config", ".", "workUnitShortName", ")", ";", "joinCluster", "(", ")", ";", "listener", ".", "onJoin", "(", "zk", ")", ";", "if", "(", "watchesRegistered", ".", "compareAndSet", "(", "false", ",", "true", ")", ")", "{", "registerWatchers", "(", ")", ";", "}", "initialized", ".", "set", "(", "true", ")", ";", "initializedLatch", ".", "countDown", "(", ")", ";", "setState", "(", "NodeState", ".", "Started", ")", ";", "claimer", ".", "requestClaim", "(", ")", ";", "verifyIntegrity", "(", ")", ";", "balancingPolicy", ".", "onConnect", "(", ")", ";", "if", "(", "config", ".", "enableAutoRebalance", ")", "{", "scheduleRebalancing", "(", ")", ";", "}", "}" ]
Primary callback which is triggered upon successful Zookeeper connection.
[ "Primary", "callback", "which", "is", "triggered", "upon", "successful", "Zookeeper", "connection", "." ]
559785839981f460aaeba3c3fddff7fb667d9581
https://github.com/Multifarious/MacroManager/blob/559785839981f460aaeba3c3fddff7fb667d9581/src/main/java/com/fasterxml/mama/Cluster.java#L506-L534
154,163
Multifarious/MacroManager
src/main/java/com/fasterxml/mama/Cluster.java
Cluster.ensureCleanStartup
private void ensureCleanStartup() { forceShutdown(); ScheduledThreadPoolExecutor oldPool = pool.getAndSet(createScheduledThreadExecutor()); oldPool.shutdownNow(); claimedForHandoff.clear(); workUnitsPeggedToMe.clear(); state.set(NodeState.Fresh); }
java
private void ensureCleanStartup() { forceShutdown(); ScheduledThreadPoolExecutor oldPool = pool.getAndSet(createScheduledThreadExecutor()); oldPool.shutdownNow(); claimedForHandoff.clear(); workUnitsPeggedToMe.clear(); state.set(NodeState.Fresh); }
[ "private", "void", "ensureCleanStartup", "(", ")", "{", "forceShutdown", "(", ")", ";", "ScheduledThreadPoolExecutor", "oldPool", "=", "pool", ".", "getAndSet", "(", "createScheduledThreadExecutor", "(", ")", ")", ";", "oldPool", ".", "shutdownNow", "(", ")", ";", "claimedForHandoff", ".", "clear", "(", ")", ";", "workUnitsPeggedToMe", ".", "clear", "(", ")", ";", "state", ".", "set", "(", "NodeState", ".", "Fresh", ")", ";", "}" ]
In the event that the node has been evicted and is reconnecting, this method clears out all existing state before relaunching to ensure a clean launch.
[ "In", "the", "event", "that", "the", "node", "has", "been", "evicted", "and", "is", "reconnecting", "this", "method", "clears", "out", "all", "existing", "state", "before", "relaunching", "to", "ensure", "a", "clean", "launch", "." ]
559785839981f460aaeba3c3fddff7fb667d9581
https://github.com/Multifarious/MacroManager/blob/559785839981f460aaeba3c3fddff7fb667d9581/src/main/java/com/fasterxml/mama/Cluster.java#L540-L547
154,164
Multifarious/MacroManager
src/main/java/com/fasterxml/mama/Cluster.java
Cluster.scheduleRebalancing
private void scheduleRebalancing() { int interval = config.autoRebalanceInterval; Runnable runRebalance = new Runnable() { @Override public void run() { try { rebalance(); } catch (Exception e) { LOG.error("Error running auto-rebalance.", e); } } }; autoRebalanceFuture = pool.get().scheduleAtFixedRate(runRebalance, interval, interval, TimeUnit.SECONDS); }
java
private void scheduleRebalancing() { int interval = config.autoRebalanceInterval; Runnable runRebalance = new Runnable() { @Override public void run() { try { rebalance(); } catch (Exception e) { LOG.error("Error running auto-rebalance.", e); } } }; autoRebalanceFuture = pool.get().scheduleAtFixedRate(runRebalance, interval, interval, TimeUnit.SECONDS); }
[ "private", "void", "scheduleRebalancing", "(", ")", "{", "int", "interval", "=", "config", ".", "autoRebalanceInterval", ";", "Runnable", "runRebalance", "=", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "try", "{", "rebalance", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "LOG", ".", "error", "(", "\"Error running auto-rebalance.\"", ",", "e", ")", ";", "}", "}", "}", ";", "autoRebalanceFuture", "=", "pool", ".", "get", "(", ")", ".", "scheduleAtFixedRate", "(", "runRebalance", ",", "interval", ",", "interval", ",", "TimeUnit", ".", "SECONDS", ")", ";", "}" ]
Schedules auto-rebalancing if auto-rebalancing is enabled. The task is scheduled to run every 60 seconds by default, or according to the config.
[ "Schedules", "auto", "-", "rebalancing", "if", "auto", "-", "rebalancing", "is", "enabled", ".", "The", "task", "is", "scheduled", "to", "run", "every", "60", "seconds", "by", "default", "or", "according", "to", "the", "config", "." ]
559785839981f460aaeba3c3fddff7fb667d9581
https://github.com/Multifarious/MacroManager/blob/559785839981f460aaeba3c3fddff7fb667d9581/src/main/java/com/fasterxml/mama/Cluster.java#L553-L567
154,165
Multifarious/MacroManager
src/main/java/com/fasterxml/mama/Cluster.java
Cluster.joinCluster
private void joinCluster() throws InterruptedException, IOException { while (true) { NodeInfo myInfo; try { myInfo = new NodeInfo(NodeState.Fresh.toString(), zk.get().getSessionId()); } catch (ZooKeeperConnectionException e) { throw ZKException.from(e); } byte[] encoded = JsonUtil.asJSONBytes(myInfo); if (ZKUtils.createEphemeral(zk, "/" + name + "/nodes/" + myNodeID, encoded)) { return; } else { Stat stat = new Stat(); try { byte[] bytes = zk.get().getData("/" + name + "/nodes/" + myNodeID, false, stat); NodeInfo nodeInfo = JsonUtil.fromJSON(bytes, NodeInfo.class); if(nodeInfo.connectionID == zk.get().getSessionId()) { // As it turns out, our session is already registered! return; } } catch (ZooKeeperConnectionException e) { throw ZKException.from(e); } catch (KeeperException e) { throw ZKException.from(e); } } LOG.warn("Unable to register with Zookeeper on launch. " + "Is {} already running on this host? Retrying in 1 second...", name); Thread.sleep(1000); } }
java
private void joinCluster() throws InterruptedException, IOException { while (true) { NodeInfo myInfo; try { myInfo = new NodeInfo(NodeState.Fresh.toString(), zk.get().getSessionId()); } catch (ZooKeeperConnectionException e) { throw ZKException.from(e); } byte[] encoded = JsonUtil.asJSONBytes(myInfo); if (ZKUtils.createEphemeral(zk, "/" + name + "/nodes/" + myNodeID, encoded)) { return; } else { Stat stat = new Stat(); try { byte[] bytes = zk.get().getData("/" + name + "/nodes/" + myNodeID, false, stat); NodeInfo nodeInfo = JsonUtil.fromJSON(bytes, NodeInfo.class); if(nodeInfo.connectionID == zk.get().getSessionId()) { // As it turns out, our session is already registered! return; } } catch (ZooKeeperConnectionException e) { throw ZKException.from(e); } catch (KeeperException e) { throw ZKException.from(e); } } LOG.warn("Unable to register with Zookeeper on launch. " + "Is {} already running on this host? Retrying in 1 second...", name); Thread.sleep(1000); } }
[ "private", "void", "joinCluster", "(", ")", "throws", "InterruptedException", ",", "IOException", "{", "while", "(", "true", ")", "{", "NodeInfo", "myInfo", ";", "try", "{", "myInfo", "=", "new", "NodeInfo", "(", "NodeState", ".", "Fresh", ".", "toString", "(", ")", ",", "zk", ".", "get", "(", ")", ".", "getSessionId", "(", ")", ")", ";", "}", "catch", "(", "ZooKeeperConnectionException", "e", ")", "{", "throw", "ZKException", ".", "from", "(", "e", ")", ";", "}", "byte", "[", "]", "encoded", "=", "JsonUtil", ".", "asJSONBytes", "(", "myInfo", ")", ";", "if", "(", "ZKUtils", ".", "createEphemeral", "(", "zk", ",", "\"/\"", "+", "name", "+", "\"/nodes/\"", "+", "myNodeID", ",", "encoded", ")", ")", "{", "return", ";", "}", "else", "{", "Stat", "stat", "=", "new", "Stat", "(", ")", ";", "try", "{", "byte", "[", "]", "bytes", "=", "zk", ".", "get", "(", ")", ".", "getData", "(", "\"/\"", "+", "name", "+", "\"/nodes/\"", "+", "myNodeID", ",", "false", ",", "stat", ")", ";", "NodeInfo", "nodeInfo", "=", "JsonUtil", ".", "fromJSON", "(", "bytes", ",", "NodeInfo", ".", "class", ")", ";", "if", "(", "nodeInfo", ".", "connectionID", "==", "zk", ".", "get", "(", ")", ".", "getSessionId", "(", ")", ")", "{", "// As it turns out, our session is already registered!", "return", ";", "}", "}", "catch", "(", "ZooKeeperConnectionException", "e", ")", "{", "throw", "ZKException", ".", "from", "(", "e", ")", ";", "}", "catch", "(", "KeeperException", "e", ")", "{", "throw", "ZKException", ".", "from", "(", "e", ")", ";", "}", "}", "LOG", ".", "warn", "(", "\"Unable to register with Zookeeper on launch. \"", "+", "\"Is {} already running on this host? Retrying in 1 second...\"", ",", "name", ")", ";", "Thread", ".", "sleep", "(", "1000", ")", ";", "}", "}" ]
Registers this node with Zookeeper on startup, retrying until it succeeds. This retry logic is important in that a node which restarts before Zookeeper detects the previous disconnect could prohibit the node from properly launching.
[ "Registers", "this", "node", "with", "Zookeeper", "on", "startup", "retrying", "until", "it", "succeeds", ".", "This", "retry", "logic", "is", "important", "in", "that", "a", "node", "which", "restarts", "before", "Zookeeper", "detects", "the", "previous", "disconnect", "could", "prohibit", "the", "node", "from", "properly", "launching", "." ]
559785839981f460aaeba3c3fddff7fb667d9581
https://github.com/Multifarious/MacroManager/blob/559785839981f460aaeba3c3fddff7fb667d9581/src/main/java/com/fasterxml/mama/Cluster.java#L574-L604
154,166
Multifarious/MacroManager
src/main/java/com/fasterxml/mama/Cluster.java
Cluster.claimWork
public void claimWork() throws InterruptedException { if (state.get() == NodeState.Started && !waitInProgress.get() && connected.get()) { balancingPolicy.claimWork(); } }
java
public void claimWork() throws InterruptedException { if (state.get() == NodeState.Started && !waitInProgress.get() && connected.get()) { balancingPolicy.claimWork(); } }
[ "public", "void", "claimWork", "(", ")", "throws", "InterruptedException", "{", "if", "(", "state", ".", "get", "(", ")", "==", "NodeState", ".", "Started", "&&", "!", "waitInProgress", ".", "get", "(", ")", "&&", "connected", ".", "get", "(", ")", ")", "{", "balancingPolicy", ".", "claimWork", "(", ")", ";", "}", "}" ]
Triggers a work-claiming cycle. If smart balancing is enabled, claim work based on node and cluster load. If simple balancing is in effect, claim by count.
[ "Triggers", "a", "work", "-", "claiming", "cycle", ".", "If", "smart", "balancing", "is", "enabled", "claim", "work", "based", "on", "node", "and", "cluster", "load", ".", "If", "simple", "balancing", "is", "in", "effect", "claim", "by", "count", "." ]
559785839981f460aaeba3c3fddff7fb667d9581
https://github.com/Multifarious/MacroManager/blob/559785839981f460aaeba3c3fddff7fb667d9581/src/main/java/com/fasterxml/mama/Cluster.java#L657-L661
154,167
Multifarious/MacroManager
src/main/java/com/fasterxml/mama/Cluster.java
Cluster.requestHandoff
public void requestHandoff(String workUnit) throws InterruptedException { LOG.info("Requesting handoff for {}.", workUnit); ZKUtils.createEphemeral(zk, "/" + name + "/handoff-requests/" + workUnit); }
java
public void requestHandoff(String workUnit) throws InterruptedException { LOG.info("Requesting handoff for {}.", workUnit); ZKUtils.createEphemeral(zk, "/" + name + "/handoff-requests/" + workUnit); }
[ "public", "void", "requestHandoff", "(", "String", "workUnit", ")", "throws", "InterruptedException", "{", "LOG", ".", "info", "(", "\"Requesting handoff for {}.\"", ",", "workUnit", ")", ";", "ZKUtils", ".", "createEphemeral", "(", "zk", ",", "\"/\"", "+", "name", "+", "\"/handoff-requests/\"", "+", "workUnit", ")", ";", "}" ]
Requests that another node take over for a work unit by creating a ZNode at handoff-requests. This will trigger a claim cycle and adoption.
[ "Requests", "that", "another", "node", "take", "over", "for", "a", "work", "unit", "by", "creating", "a", "ZNode", "at", "handoff", "-", "requests", ".", "This", "will", "trigger", "a", "claim", "cycle", "and", "adoption", "." ]
559785839981f460aaeba3c3fddff7fb667d9581
https://github.com/Multifarious/MacroManager/blob/559785839981f460aaeba3c3fddff7fb667d9581/src/main/java/com/fasterxml/mama/Cluster.java#L674-L677
154,168
Multifarious/MacroManager
src/main/java/com/fasterxml/mama/Cluster.java
Cluster.verifyIntegrity
public void verifyIntegrity() { LinkedHashSet<String> noLongerActive = new LinkedHashSet<String>(myWorkUnits); noLongerActive.removeAll(allWorkUnits.keySet()); for (String workUnit : noLongerActive) { shutdownWork(workUnit, true); } // Check the status of pegged work units to ensure that this node is not serving // a work unit that is pegged to another node in the cluster. for (String workUnit : myWorkUnits) { String claimPath = workUnitClaimPath(workUnit); if (!balancingPolicy.isFairGame(workUnit) && !balancingPolicy.isPeggedToMe(workUnit)) { LOG.info("Discovered I'm serving a work unit that's now " + "pegged to someone else. Shutting down {}", workUnit); shutdownWork(workUnit, true); } else if (workUnitMap.containsKey(workUnit) && !workUnitMap.get(workUnit).equals(myNodeID) && !claimedForHandoff.contains(workUnit) && !znodeIsMe(claimPath)) { LOG.info("Discovered I'm serving a work unit that's now " + "claimed by {} according to ZooKeeper. Shutting down {}", workUnitMap.get(workUnit), workUnit); shutdownWork(workUnit, true); } } }
java
public void verifyIntegrity() { LinkedHashSet<String> noLongerActive = new LinkedHashSet<String>(myWorkUnits); noLongerActive.removeAll(allWorkUnits.keySet()); for (String workUnit : noLongerActive) { shutdownWork(workUnit, true); } // Check the status of pegged work units to ensure that this node is not serving // a work unit that is pegged to another node in the cluster. for (String workUnit : myWorkUnits) { String claimPath = workUnitClaimPath(workUnit); if (!balancingPolicy.isFairGame(workUnit) && !balancingPolicy.isPeggedToMe(workUnit)) { LOG.info("Discovered I'm serving a work unit that's now " + "pegged to someone else. Shutting down {}", workUnit); shutdownWork(workUnit, true); } else if (workUnitMap.containsKey(workUnit) && !workUnitMap.get(workUnit).equals(myNodeID) && !claimedForHandoff.contains(workUnit) && !znodeIsMe(claimPath)) { LOG.info("Discovered I'm serving a work unit that's now " + "claimed by {} according to ZooKeeper. Shutting down {}", workUnitMap.get(workUnit), workUnit); shutdownWork(workUnit, true); } } }
[ "public", "void", "verifyIntegrity", "(", ")", "{", "LinkedHashSet", "<", "String", ">", "noLongerActive", "=", "new", "LinkedHashSet", "<", "String", ">", "(", "myWorkUnits", ")", ";", "noLongerActive", ".", "removeAll", "(", "allWorkUnits", ".", "keySet", "(", ")", ")", ";", "for", "(", "String", "workUnit", ":", "noLongerActive", ")", "{", "shutdownWork", "(", "workUnit", ",", "true", ")", ";", "}", "// Check the status of pegged work units to ensure that this node is not serving", "// a work unit that is pegged to another node in the cluster.", "for", "(", "String", "workUnit", ":", "myWorkUnits", ")", "{", "String", "claimPath", "=", "workUnitClaimPath", "(", "workUnit", ")", ";", "if", "(", "!", "balancingPolicy", ".", "isFairGame", "(", "workUnit", ")", "&&", "!", "balancingPolicy", ".", "isPeggedToMe", "(", "workUnit", ")", ")", "{", "LOG", ".", "info", "(", "\"Discovered I'm serving a work unit that's now \"", "+", "\"pegged to someone else. Shutting down {}\"", ",", "workUnit", ")", ";", "shutdownWork", "(", "workUnit", ",", "true", ")", ";", "}", "else", "if", "(", "workUnitMap", ".", "containsKey", "(", "workUnit", ")", "&&", "!", "workUnitMap", ".", "get", "(", "workUnit", ")", ".", "equals", "(", "myNodeID", ")", "&&", "!", "claimedForHandoff", ".", "contains", "(", "workUnit", ")", "&&", "!", "znodeIsMe", "(", "claimPath", ")", ")", "{", "LOG", ".", "info", "(", "\"Discovered I'm serving a work unit that's now \"", "+", "\"claimed by {} according to ZooKeeper. Shutting down {}\"", ",", "workUnitMap", ".", "get", "(", "workUnit", ")", ",", "workUnit", ")", ";", "shutdownWork", "(", "workUnit", ",", "true", ")", ";", "}", "}", "}" ]
Verifies that all nodes are hooked up properly. Shuts down any work units which have been removed from the cluster or have been assigned to another node.
[ "Verifies", "that", "all", "nodes", "are", "hooked", "up", "properly", ".", "Shuts", "down", "any", "work", "units", "which", "have", "been", "removed", "from", "the", "cluster", "or", "have", "been", "assigned", "to", "another", "node", "." ]
559785839981f460aaeba3c3fddff7fb667d9581
https://github.com/Multifarious/MacroManager/blob/559785839981f460aaeba3c3fddff7fb667d9581/src/main/java/com/fasterxml/mama/Cluster.java#L683-L708
154,169
Multifarious/MacroManager
src/main/java/com/fasterxml/mama/Cluster.java
Cluster.shutdownWork
public void shutdownWork(String workUnit, boolean doLog /*true*/ ) { if (doLog) { LOG.info("Shutting down {}: {}...", config.workUnitName, workUnit); } myWorkUnits.remove(workUnit); claimedForHandoff.remove(workUnit); balancingPolicy.onShutdownWork(workUnit); try { listener.shutdownWork(workUnit); } finally { ZKUtils.deleteAtomic(zk, workUnitClaimPath(workUnit), myNodeID); } }
java
public void shutdownWork(String workUnit, boolean doLog /*true*/ ) { if (doLog) { LOG.info("Shutting down {}: {}...", config.workUnitName, workUnit); } myWorkUnits.remove(workUnit); claimedForHandoff.remove(workUnit); balancingPolicy.onShutdownWork(workUnit); try { listener.shutdownWork(workUnit); } finally { ZKUtils.deleteAtomic(zk, workUnitClaimPath(workUnit), myNodeID); } }
[ "public", "void", "shutdownWork", "(", "String", "workUnit", ",", "boolean", "doLog", "/*true*/", ")", "{", "if", "(", "doLog", ")", "{", "LOG", ".", "info", "(", "\"Shutting down {}: {}...\"", ",", "config", ".", "workUnitName", ",", "workUnit", ")", ";", "}", "myWorkUnits", ".", "remove", "(", "workUnit", ")", ";", "claimedForHandoff", ".", "remove", "(", "workUnit", ")", ";", "balancingPolicy", ".", "onShutdownWork", "(", "workUnit", ")", ";", "try", "{", "listener", ".", "shutdownWork", "(", "workUnit", ")", ";", "}", "finally", "{", "ZKUtils", ".", "deleteAtomic", "(", "zk", ",", "workUnitClaimPath", "(", "workUnit", ")", ",", "myNodeID", ")", ";", "}", "}" ]
Shuts down a work unit by removing the claim in ZK and calling the listener.
[ "Shuts", "down", "a", "work", "unit", "by", "removing", "the", "claim", "in", "ZK", "and", "calling", "the", "listener", "." ]
559785839981f460aaeba3c3fddff7fb667d9581
https://github.com/Multifarious/MacroManager/blob/559785839981f460aaeba3c3fddff7fb667d9581/src/main/java/com/fasterxml/mama/Cluster.java#L742-L754
154,170
Multifarious/MacroManager
src/main/java/com/fasterxml/mama/Cluster.java
Cluster.setState
private boolean setState(NodeState to) { try { NodeInfo myInfo = new NodeInfo(to.toString(), zk.get().getSessionId()); byte[] encoded = JsonUtil.asJSONBytes(myInfo); ZKUtils.set(zk, "/" + name + "/nodes/" + myNodeID, encoded); state.set(to); return true; } catch (Exception e) { // InterruptedException, IOException LOG.warn("Problem trying to setState("+to+"): "+e.getMessage(), e); return false; } }
java
private boolean setState(NodeState to) { try { NodeInfo myInfo = new NodeInfo(to.toString(), zk.get().getSessionId()); byte[] encoded = JsonUtil.asJSONBytes(myInfo); ZKUtils.set(zk, "/" + name + "/nodes/" + myNodeID, encoded); state.set(to); return true; } catch (Exception e) { // InterruptedException, IOException LOG.warn("Problem trying to setState("+to+"): "+e.getMessage(), e); return false; } }
[ "private", "boolean", "setState", "(", "NodeState", "to", ")", "{", "try", "{", "NodeInfo", "myInfo", "=", "new", "NodeInfo", "(", "to", ".", "toString", "(", ")", ",", "zk", ".", "get", "(", ")", ".", "getSessionId", "(", ")", ")", ";", "byte", "[", "]", "encoded", "=", "JsonUtil", ".", "asJSONBytes", "(", "myInfo", ")", ";", "ZKUtils", ".", "set", "(", "zk", ",", "\"/\"", "+", "name", "+", "\"/nodes/\"", "+", "myNodeID", ",", "encoded", ")", ";", "state", ".", "set", "(", "to", ")", ";", "return", "true", ";", "}", "catch", "(", "Exception", "e", ")", "{", "// InterruptedException, IOException", "LOG", ".", "warn", "(", "\"Problem trying to setState(\"", "+", "to", "+", "\"): \"", "+", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "return", "false", ";", "}", "}" ]
Sets the state of the current Ordasity node and notifies others via ZooKeeper.
[ "Sets", "the", "state", "of", "the", "current", "Ordasity", "node", "and", "notifies", "others", "via", "ZooKeeper", "." ]
559785839981f460aaeba3c3fddff7fb667d9581
https://github.com/Multifarious/MacroManager/blob/559785839981f460aaeba3c3fddff7fb667d9581/src/main/java/com/fasterxml/mama/Cluster.java#L772-L784
154,171
Multifarious/MacroManager
src/main/java/com/fasterxml/mama/Cluster.java
Cluster.previousZKSessionStillActive
private boolean previousZKSessionStillActive() { try { byte[] json = zk.get().getData(String.format("/%s/nodes/%s", name, myNodeID), false, null); NodeInfo nodeInfo = JsonUtil.fromJSON(json, NodeInfo.class); return (nodeInfo.connectionID == zk.get().getSessionId()); } catch (NoNodeException e) { ; // apparently harmless? } catch (Exception e) { LOG.error("Encountered unexpected error in checking ZK session status.", e); } return false; }
java
private boolean previousZKSessionStillActive() { try { byte[] json = zk.get().getData(String.format("/%s/nodes/%s", name, myNodeID), false, null); NodeInfo nodeInfo = JsonUtil.fromJSON(json, NodeInfo.class); return (nodeInfo.connectionID == zk.get().getSessionId()); } catch (NoNodeException e) { ; // apparently harmless? } catch (Exception e) { LOG.error("Encountered unexpected error in checking ZK session status.", e); } return false; }
[ "private", "boolean", "previousZKSessionStillActive", "(", ")", "{", "try", "{", "byte", "[", "]", "json", "=", "zk", ".", "get", "(", ")", ".", "getData", "(", "String", ".", "format", "(", "\"/%s/nodes/%s\"", ",", "name", ",", "myNodeID", ")", ",", "false", ",", "null", ")", ";", "NodeInfo", "nodeInfo", "=", "JsonUtil", ".", "fromJSON", "(", "json", ",", "NodeInfo", ".", "class", ")", ";", "return", "(", "nodeInfo", ".", "connectionID", "==", "zk", ".", "get", "(", ")", ".", "getSessionId", "(", ")", ")", ";", "}", "catch", "(", "NoNodeException", "e", ")", "{", ";", "// apparently harmless?", "}", "catch", "(", "Exception", "e", ")", "{", "LOG", ".", "error", "(", "\"Encountered unexpected error in checking ZK session status.\"", ",", "e", ")", ";", "}", "return", "false", ";", "}" ]
Determines if another ZooKeeper session is currently active for the current node by comparing the ZooKeeper session ID of the connection stored in NodeState.
[ "Determines", "if", "another", "ZooKeeper", "session", "is", "currently", "active", "for", "the", "current", "node", "by", "comparing", "the", "ZooKeeper", "session", "ID", "of", "the", "connection", "stored", "in", "NodeState", "." ]
559785839981f460aaeba3c3fddff7fb667d9581
https://github.com/Multifarious/MacroManager/blob/559785839981f460aaeba3c3fddff7fb667d9581/src/main/java/com/fasterxml/mama/Cluster.java#L790-L802
154,172
carewebframework/carewebframework-vista
org.carewebframework.vista.api-parent/org.carewebframework.vista.api.core/src/main/java/org/carewebframework/vista/api/encounter/EncounterUtil.java
EncounterUtil.updateParticipants
public static void updateParticipants(Encounter encounter) { if (encounter == null || encounter.getParticipant().isEmpty()) { return; } RPCParameter params = new RPCParameter(); for (EncounterParticipantComponent participant : encounter.getParticipant()) { String partId = getParticipantId(participant); params.put(partId, "+"); } String dfn = PatientContext.getActivePatient().getIdElement().getIdPart(); VistAUtil.getBrokerSession().callRPC("RGCWENCX UPDPRV", dfn, encode(encounter), params, true); }
java
public static void updateParticipants(Encounter encounter) { if (encounter == null || encounter.getParticipant().isEmpty()) { return; } RPCParameter params = new RPCParameter(); for (EncounterParticipantComponent participant : encounter.getParticipant()) { String partId = getParticipantId(participant); params.put(partId, "+"); } String dfn = PatientContext.getActivePatient().getIdElement().getIdPart(); VistAUtil.getBrokerSession().callRPC("RGCWENCX UPDPRV", dfn, encode(encounter), params, true); }
[ "public", "static", "void", "updateParticipants", "(", "Encounter", "encounter", ")", "{", "if", "(", "encounter", "==", "null", "||", "encounter", ".", "getParticipant", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "return", ";", "}", "RPCParameter", "params", "=", "new", "RPCParameter", "(", ")", ";", "for", "(", "EncounterParticipantComponent", "participant", ":", "encounter", ".", "getParticipant", "(", ")", ")", "{", "String", "partId", "=", "getParticipantId", "(", "participant", ")", ";", "params", ".", "put", "(", "partId", ",", "\"+\"", ")", ";", "}", "String", "dfn", "=", "PatientContext", ".", "getActivePatient", "(", ")", ".", "getIdElement", "(", ")", ".", "getIdPart", "(", ")", ";", "VistAUtil", ".", "getBrokerSession", "(", ")", ".", "callRPC", "(", "\"RGCWENCX UPDPRV\"", ",", "dfn", ",", "encode", "(", "encounter", ")", ",", "params", ",", "true", ")", ";", "}" ]
Updates the participants associated with an encounter. @param encounter The encounter.
[ "Updates", "the", "participants", "associated", "with", "an", "encounter", "." ]
883b2cbe395d9e8a21cd19db820f0876bda6b1c6
https://github.com/carewebframework/carewebframework-vista/blob/883b2cbe395d9e8a21cd19db820f0876bda6b1c6/org.carewebframework.vista.api-parent/org.carewebframework.vista.api.core/src/main/java/org/carewebframework/vista/api/encounter/EncounterUtil.java#L89-L103
154,173
carewebframework/carewebframework-vista
org.carewebframework.vista.api-parent/org.carewebframework.vista.api.core/src/main/java/org/carewebframework/vista/api/encounter/EncounterUtil.java
EncounterUtil.decode
public static Encounter decode(String vstr) { String[] pcs = StrUtil.split(vstr, VSTR_DELIM, 4); long encIEN = NumberUtils.toLong(pcs[3]); if (encIEN > 0) { return DomainFactoryRegistry.fetchObject(Encounter.class, pcs[3]); } long locIEN = NumberUtils.toLong(pcs[0]); Location location = locIEN == 0 ? null : DomainFactoryRegistry.fetchObject(Location.class, pcs[0]); Date date = FMDate.fromString(pcs[1]); return create(PatientContext.getActivePatient(), date, location, pcs[2]); }
java
public static Encounter decode(String vstr) { String[] pcs = StrUtil.split(vstr, VSTR_DELIM, 4); long encIEN = NumberUtils.toLong(pcs[3]); if (encIEN > 0) { return DomainFactoryRegistry.fetchObject(Encounter.class, pcs[3]); } long locIEN = NumberUtils.toLong(pcs[0]); Location location = locIEN == 0 ? null : DomainFactoryRegistry.fetchObject(Location.class, pcs[0]); Date date = FMDate.fromString(pcs[1]); return create(PatientContext.getActivePatient(), date, location, pcs[2]); }
[ "public", "static", "Encounter", "decode", "(", "String", "vstr", ")", "{", "String", "[", "]", "pcs", "=", "StrUtil", ".", "split", "(", "vstr", ",", "VSTR_DELIM", ",", "4", ")", ";", "long", "encIEN", "=", "NumberUtils", ".", "toLong", "(", "pcs", "[", "3", "]", ")", ";", "if", "(", "encIEN", ">", "0", ")", "{", "return", "DomainFactoryRegistry", ".", "fetchObject", "(", "Encounter", ".", "class", ",", "pcs", "[", "3", "]", ")", ";", "}", "long", "locIEN", "=", "NumberUtils", ".", "toLong", "(", "pcs", "[", "0", "]", ")", ";", "Location", "location", "=", "locIEN", "==", "0", "?", "null", ":", "DomainFactoryRegistry", ".", "fetchObject", "(", "Location", ".", "class", ",", "pcs", "[", "0", "]", ")", ";", "Date", "date", "=", "FMDate", ".", "fromString", "(", "pcs", "[", "1", "]", ")", ";", "return", "create", "(", "PatientContext", ".", "getActivePatient", "(", ")", ",", "date", ",", "location", ",", "pcs", "[", "2", "]", ")", ";", "}" ]
Decode encounter from visit string. @param vstr Format is: <p> location ien^visit date^category^visit ien @return The decoded encounter.
[ "Decode", "encounter", "from", "visit", "string", "." ]
883b2cbe395d9e8a21cd19db820f0876bda6b1c6
https://github.com/carewebframework/carewebframework-vista/blob/883b2cbe395d9e8a21cd19db820f0876bda6b1c6/org.carewebframework.vista.api-parent/org.carewebframework.vista.api.core/src/main/java/org/carewebframework/vista/api/encounter/EncounterUtil.java#L113-L125
154,174
carewebframework/carewebframework-vista
org.carewebframework.vista.api-parent/org.carewebframework.vista.api.core/src/main/java/org/carewebframework/vista/api/encounter/EncounterUtil.java
EncounterUtil.encode
public static String encode(Encounter encounter) { Location location = ClientUtil.getResource(encounter.getLocationFirstRep().getLocation(), Location.class); String locIEN = location.isEmpty() ? "" : location.getIdElement().getIdPart(); Date date = encounter.getPeriod().getStart(); String sc = getServiceCategory(encounter); String ien = encounter.getId().isEmpty() ? "" : encounter.getIdElement().getIdPart(); return locIEN + VSTR_DELIM + new FMDate(date).getFMDate() + VSTR_DELIM + sc + VSTR_DELIM + ien; }
java
public static String encode(Encounter encounter) { Location location = ClientUtil.getResource(encounter.getLocationFirstRep().getLocation(), Location.class); String locIEN = location.isEmpty() ? "" : location.getIdElement().getIdPart(); Date date = encounter.getPeriod().getStart(); String sc = getServiceCategory(encounter); String ien = encounter.getId().isEmpty() ? "" : encounter.getIdElement().getIdPart(); return locIEN + VSTR_DELIM + new FMDate(date).getFMDate() + VSTR_DELIM + sc + VSTR_DELIM + ien; }
[ "public", "static", "String", "encode", "(", "Encounter", "encounter", ")", "{", "Location", "location", "=", "ClientUtil", ".", "getResource", "(", "encounter", ".", "getLocationFirstRep", "(", ")", ".", "getLocation", "(", ")", ",", "Location", ".", "class", ")", ";", "String", "locIEN", "=", "location", ".", "isEmpty", "(", ")", "?", "\"\"", ":", "location", ".", "getIdElement", "(", ")", ".", "getIdPart", "(", ")", ";", "Date", "date", "=", "encounter", ".", "getPeriod", "(", ")", ".", "getStart", "(", ")", ";", "String", "sc", "=", "getServiceCategory", "(", "encounter", ")", ";", "String", "ien", "=", "encounter", ".", "getId", "(", ")", ".", "isEmpty", "(", ")", "?", "\"\"", ":", "encounter", ".", "getIdElement", "(", ")", ".", "getIdPart", "(", ")", ";", "return", "locIEN", "+", "VSTR_DELIM", "+", "new", "FMDate", "(", "date", ")", ".", "getFMDate", "(", ")", "+", "VSTR_DELIM", "+", "sc", "+", "VSTR_DELIM", "+", "ien", ";", "}" ]
Encode an encounter to a visit string. @param encounter The encounter. @return The encoded encounter (visit string).
[ "Encode", "an", "encounter", "to", "a", "visit", "string", "." ]
883b2cbe395d9e8a21cd19db820f0876bda6b1c6
https://github.com/carewebframework/carewebframework-vista/blob/883b2cbe395d9e8a21cd19db820f0876bda6b1c6/org.carewebframework.vista.api-parent/org.carewebframework.vista.api.core/src/main/java/org/carewebframework/vista/api/encounter/EncounterUtil.java#L133-L140
154,175
tvesalainen/util
util/src/main/java/org/vesalainen/time/SimpleMutableDateTime.java
SimpleMutableDateTime.plusMonths
public void plusMonths(int delta) { if (delta != 0) { int result = getMonth() -1 + delta; setMonth(Math.floorMod(result, 12) + 1); plusYears(Math.floorDiv(result, 12)); } }
java
public void plusMonths(int delta) { if (delta != 0) { int result = getMonth() -1 + delta; setMonth(Math.floorMod(result, 12) + 1); plusYears(Math.floorDiv(result, 12)); } }
[ "public", "void", "plusMonths", "(", "int", "delta", ")", "{", "if", "(", "delta", "!=", "0", ")", "{", "int", "result", "=", "getMonth", "(", ")", "-", "1", "+", "delta", ";", "setMonth", "(", "Math", ".", "floorMod", "(", "result", ",", "12", ")", "+", "1", ")", ";", "plusYears", "(", "Math", ".", "floorDiv", "(", "result", ",", "12", ")", ")", ";", "}", "}" ]
Adds delta months. Delta can be negative. Month and year fields are affected. @param delta
[ "Adds", "delta", "months", ".", "Delta", "can", "be", "negative", ".", "Month", "and", "year", "fields", "are", "affected", "." ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/time/SimpleMutableDateTime.java#L210-L218
154,176
tvesalainen/util
util/src/main/java/org/vesalainen/time/SimpleMutableDateTime.java
SimpleMutableDateTime.plusDays
public void plusDays(long delta) { if (delta != 0) { long result = getDay() + delta; if (result >= 1 && result <= 28) { setDay((int) result); } else { ZonedDateTime zonedDateTime = ZonedDateTime.from(this); ZonedDateTime plusDays = zonedDateTime.plusDays(delta); set(plusDays); } } }
java
public void plusDays(long delta) { if (delta != 0) { long result = getDay() + delta; if (result >= 1 && result <= 28) { setDay((int) result); } else { ZonedDateTime zonedDateTime = ZonedDateTime.from(this); ZonedDateTime plusDays = zonedDateTime.plusDays(delta); set(plusDays); } } }
[ "public", "void", "plusDays", "(", "long", "delta", ")", "{", "if", "(", "delta", "!=", "0", ")", "{", "long", "result", "=", "getDay", "(", ")", "+", "delta", ";", "if", "(", "result", ">=", "1", "&&", "result", "<=", "28", ")", "{", "setDay", "(", "(", "int", ")", "result", ")", ";", "}", "else", "{", "ZonedDateTime", "zonedDateTime", "=", "ZonedDateTime", ".", "from", "(", "this", ")", ";", "ZonedDateTime", "plusDays", "=", "zonedDateTime", ".", "plusDays", "(", "delta", ")", ";", "set", "(", "plusDays", ")", ";", "}", "}", "}" ]
Adds delta days. Delta can be negative. Month, year and day fields are affected. @param delta
[ "Adds", "delta", "days", ".", "Delta", "can", "be", "negative", ".", "Month", "year", "and", "day", "fields", "are", "affected", "." ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/time/SimpleMutableDateTime.java#L224-L240
154,177
tvesalainen/util
util/src/main/java/org/vesalainen/time/SimpleMutableDateTime.java
SimpleMutableDateTime.plusHours
public void plusHours(long delta) { if (delta != 0) { long result = getHour() + delta; setHour((int) Math.floorMod(result, 24)); plusDays(Math.floorDiv(result, 24)); } }
java
public void plusHours(long delta) { if (delta != 0) { long result = getHour() + delta; setHour((int) Math.floorMod(result, 24)); plusDays(Math.floorDiv(result, 24)); } }
[ "public", "void", "plusHours", "(", "long", "delta", ")", "{", "if", "(", "delta", "!=", "0", ")", "{", "long", "result", "=", "getHour", "(", ")", "+", "delta", ";", "setHour", "(", "(", "int", ")", "Math", ".", "floorMod", "(", "result", ",", "24", ")", ")", ";", "plusDays", "(", "Math", ".", "floorDiv", "(", "result", ",", "24", ")", ")", ";", "}", "}" ]
Adds delta hours. Delta can be negative. Month, year, day and hour fields are affected. @param delta
[ "Adds", "delta", "hours", ".", "Delta", "can", "be", "negative", ".", "Month", "year", "day", "and", "hour", "fields", "are", "affected", "." ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/time/SimpleMutableDateTime.java#L246-L254
154,178
tvesalainen/util
util/src/main/java/org/vesalainen/time/SimpleMutableDateTime.java
SimpleMutableDateTime.plusMinutes
public void plusMinutes(long delta) { if (delta != 0) { long result = getMinute() + delta; setMinute((int) Math.floorMod(result, 60)); plusHours(Math.floorDiv(result, 60)); } }
java
public void plusMinutes(long delta) { if (delta != 0) { long result = getMinute() + delta; setMinute((int) Math.floorMod(result, 60)); plusHours(Math.floorDiv(result, 60)); } }
[ "public", "void", "plusMinutes", "(", "long", "delta", ")", "{", "if", "(", "delta", "!=", "0", ")", "{", "long", "result", "=", "getMinute", "(", ")", "+", "delta", ";", "setMinute", "(", "(", "int", ")", "Math", ".", "floorMod", "(", "result", ",", "60", ")", ")", ";", "plusHours", "(", "Math", ".", "floorDiv", "(", "result", ",", "60", ")", ")", ";", "}", "}" ]
Adds delta minutes. Delta can be negative. Month, year, day, hour and minute fields are affected. @param delta
[ "Adds", "delta", "minutes", ".", "Delta", "can", "be", "negative", ".", "Month", "year", "day", "hour", "and", "minute", "fields", "are", "affected", "." ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/time/SimpleMutableDateTime.java#L260-L268
154,179
tvesalainen/util
util/src/main/java/org/vesalainen/time/SimpleMutableDateTime.java
SimpleMutableDateTime.plusSeconds
public void plusSeconds(long delta) { if (delta != 0) { long result = getSecond() + delta; setSecond((int) Math.floorMod(result, 60)); plusMinutes(Math.floorDiv(result, 60)); } }
java
public void plusSeconds(long delta) { if (delta != 0) { long result = getSecond() + delta; setSecond((int) Math.floorMod(result, 60)); plusMinutes(Math.floorDiv(result, 60)); } }
[ "public", "void", "plusSeconds", "(", "long", "delta", ")", "{", "if", "(", "delta", "!=", "0", ")", "{", "long", "result", "=", "getSecond", "(", ")", "+", "delta", ";", "setSecond", "(", "(", "int", ")", "Math", ".", "floorMod", "(", "result", ",", "60", ")", ")", ";", "plusMinutes", "(", "Math", ".", "floorDiv", "(", "result", ",", "60", ")", ")", ";", "}", "}" ]
Adds delta seconds. Delta can be negative. Month, year, day, hour, minute and seconds fields are affected. @param delta
[ "Adds", "delta", "seconds", ".", "Delta", "can", "be", "negative", ".", "Month", "year", "day", "hour", "minute", "and", "seconds", "fields", "are", "affected", "." ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/time/SimpleMutableDateTime.java#L274-L282
154,180
tvesalainen/util
util/src/main/java/org/vesalainen/time/SimpleMutableDateTime.java
SimpleMutableDateTime.plusMilliSeconds
public void plusMilliSeconds(long delta) { plusNanoSeconds(Math.floorMod(delta, 1000)*1000000); plusSeconds(Math.floorDiv(delta, 1000)); }
java
public void plusMilliSeconds(long delta) { plusNanoSeconds(Math.floorMod(delta, 1000)*1000000); plusSeconds(Math.floorDiv(delta, 1000)); }
[ "public", "void", "plusMilliSeconds", "(", "long", "delta", ")", "{", "plusNanoSeconds", "(", "Math", ".", "floorMod", "(", "delta", ",", "1000", ")", "*", "1000000", ")", ";", "plusSeconds", "(", "Math", ".", "floorDiv", "(", "delta", ",", "1000", ")", ")", ";", "}" ]
Adds delta milliseconds. Delta can be negative. Month, year, day, hour, minute, seconds and nanoSecond fields are affected. @param delta
[ "Adds", "delta", "milliseconds", ".", "Delta", "can", "be", "negative", ".", "Month", "year", "day", "hour", "minute", "seconds", "and", "nanoSecond", "fields", "are", "affected", "." ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/time/SimpleMutableDateTime.java#L288-L292
154,181
tvesalainen/util
util/src/main/java/org/vesalainen/time/SimpleMutableDateTime.java
SimpleMutableDateTime.plusNanoSeconds
public void plusNanoSeconds(long delta) { if (delta != 0) { long result = getNanoSecond() + delta; setNanoSecond((int) Math.floorMod(result, 1000000000)); plusSeconds(Math.floorDiv(result, 1000000000)); } }
java
public void plusNanoSeconds(long delta) { if (delta != 0) { long result = getNanoSecond() + delta; setNanoSecond((int) Math.floorMod(result, 1000000000)); plusSeconds(Math.floorDiv(result, 1000000000)); } }
[ "public", "void", "plusNanoSeconds", "(", "long", "delta", ")", "{", "if", "(", "delta", "!=", "0", ")", "{", "long", "result", "=", "getNanoSecond", "(", ")", "+", "delta", ";", "setNanoSecond", "(", "(", "int", ")", "Math", ".", "floorMod", "(", "result", ",", "1000000000", ")", ")", ";", "plusSeconds", "(", "Math", ".", "floorDiv", "(", "result", ",", "1000000000", ")", ")", ";", "}", "}" ]
Adds delta nanoseconds. Delta can be negative. Month, year, day, hour, minute, seconds and nanoSecond fields are affected. @param delta
[ "Adds", "delta", "nanoseconds", ".", "Delta", "can", "be", "negative", ".", "Month", "year", "day", "hour", "minute", "seconds", "and", "nanoSecond", "fields", "are", "affected", "." ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/time/SimpleMutableDateTime.java#L303-L311
154,182
tvesalainen/util
util/src/main/java/org/vesalainen/time/SimpleMutableDateTime.java
SimpleMutableDateTime.now
public static final SimpleMutableDateTime now(Clock clock) { ZonedDateTime zdt = ZonedDateTime.now(clock); SimpleMutableDateTime smt = SimpleMutableDateTime.from(zdt); return smt; }
java
public static final SimpleMutableDateTime now(Clock clock) { ZonedDateTime zdt = ZonedDateTime.now(clock); SimpleMutableDateTime smt = SimpleMutableDateTime.from(zdt); return smt; }
[ "public", "static", "final", "SimpleMutableDateTime", "now", "(", "Clock", "clock", ")", "{", "ZonedDateTime", "zdt", "=", "ZonedDateTime", ".", "now", "(", "clock", ")", ";", "SimpleMutableDateTime", "smt", "=", "SimpleMutableDateTime", ".", "from", "(", "zdt", ")", ";", "return", "smt", ";", "}" ]
Creates SimpleMutableDateTime and initializes it using given clock. @param clock @return
[ "Creates", "SimpleMutableDateTime", "and", "initializes", "it", "using", "given", "clock", "." ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/time/SimpleMutableDateTime.java#L352-L357
154,183
tvesalainen/util
util/src/main/java/org/vesalainen/time/SimpleMutableDateTime.java
SimpleMutableDateTime.ofEpochMilli
public static final SimpleMutableDateTime ofEpochMilli(long millis) { ZonedDateTime zdt = ZonedDateTime.ofInstant(Instant.ofEpochMilli(millis), ZoneOffset.UTC); SimpleMutableDateTime smt = SimpleMutableDateTime.from(zdt); return smt; }
java
public static final SimpleMutableDateTime ofEpochMilli(long millis) { ZonedDateTime zdt = ZonedDateTime.ofInstant(Instant.ofEpochMilli(millis), ZoneOffset.UTC); SimpleMutableDateTime smt = SimpleMutableDateTime.from(zdt); return smt; }
[ "public", "static", "final", "SimpleMutableDateTime", "ofEpochMilli", "(", "long", "millis", ")", "{", "ZonedDateTime", "zdt", "=", "ZonedDateTime", ".", "ofInstant", "(", "Instant", ".", "ofEpochMilli", "(", "millis", ")", ",", "ZoneOffset", ".", "UTC", ")", ";", "SimpleMutableDateTime", "smt", "=", "SimpleMutableDateTime", ".", "from", "(", "zdt", ")", ";", "return", "smt", ";", "}" ]
Creates SimpleMutableDateTime and initializes it using milliseconds from epoch. @param millis @return
[ "Creates", "SimpleMutableDateTime", "and", "initializes", "it", "using", "milliseconds", "from", "epoch", "." ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/time/SimpleMutableDateTime.java#L364-L369
154,184
tvesalainen/util
util/src/main/java/org/vesalainen/time/SimpleMutableDateTime.java
SimpleMutableDateTime.now
public static final SimpleMutableDateTime now(ZoneId zoneId) { ZonedDateTime zdt = ZonedDateTime.now(zoneId); SimpleMutableDateTime smt = SimpleMutableDateTime.from(zdt); return smt; }
java
public static final SimpleMutableDateTime now(ZoneId zoneId) { ZonedDateTime zdt = ZonedDateTime.now(zoneId); SimpleMutableDateTime smt = SimpleMutableDateTime.from(zdt); return smt; }
[ "public", "static", "final", "SimpleMutableDateTime", "now", "(", "ZoneId", "zoneId", ")", "{", "ZonedDateTime", "zdt", "=", "ZonedDateTime", ".", "now", "(", "zoneId", ")", ";", "SimpleMutableDateTime", "smt", "=", "SimpleMutableDateTime", ".", "from", "(", "zdt", ")", ";", "return", "smt", ";", "}" ]
Creates SimpleMutableDateTime and initializes it to given ZoneId. @param zoneId @return
[ "Creates", "SimpleMutableDateTime", "and", "initializes", "it", "to", "given", "ZoneId", "." ]
bba7a44689f638ffabc8be40a75bdc9a33676433
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/time/SimpleMutableDateTime.java#L379-L384
154,185
avaje-common/avaje-jetty-runner
src/main/java/org/avaje/jettyrunner/RunWar.java
RunWar.setupForWar
protected void setupForWar() { // Identify the war file that contains this class ProtectionDomain protectionDomain = RunWar.class.getProtectionDomain(); URL location = protectionDomain.getCodeSource().getLocation(); String warFilePath = trimToFile(location.toExternalForm()); File warFile = new File(warFilePath); if (!warFile.exists()) { throw new IllegalStateException("war file not found: " + warFilePath); } webapp.setWar(warFilePath); webapp.setClassLoader(Thread.currentThread().getContextClassLoader()); if (!Boolean.getBoolean("webapp.extractWar")) { try { webapp.setExtractWAR(false); webapp.setBaseResource(JarResource.newJarResource(Resource.newResource(warFile))); } catch (IOException e) { throw new RuntimeException("Error setting base resource to:" + warFilePath, e); } } if (log().isDebugEnabled()) { ClassLoader classLoader = webapp.getClassLoader(); log().debug("webapp classLoader: " + classLoader); if (classLoader instanceof URLClassLoader) { URL[] urls = ((URLClassLoader) classLoader).getURLs(); log().debug("webapp classLoader URLs: " + Arrays.toString(urls)); } } }
java
protected void setupForWar() { // Identify the war file that contains this class ProtectionDomain protectionDomain = RunWar.class.getProtectionDomain(); URL location = protectionDomain.getCodeSource().getLocation(); String warFilePath = trimToFile(location.toExternalForm()); File warFile = new File(warFilePath); if (!warFile.exists()) { throw new IllegalStateException("war file not found: " + warFilePath); } webapp.setWar(warFilePath); webapp.setClassLoader(Thread.currentThread().getContextClassLoader()); if (!Boolean.getBoolean("webapp.extractWar")) { try { webapp.setExtractWAR(false); webapp.setBaseResource(JarResource.newJarResource(Resource.newResource(warFile))); } catch (IOException e) { throw new RuntimeException("Error setting base resource to:" + warFilePath, e); } } if (log().isDebugEnabled()) { ClassLoader classLoader = webapp.getClassLoader(); log().debug("webapp classLoader: " + classLoader); if (classLoader instanceof URLClassLoader) { URL[] urls = ((URLClassLoader) classLoader).getURLs(); log().debug("webapp classLoader URLs: " + Arrays.toString(urls)); } } }
[ "protected", "void", "setupForWar", "(", ")", "{", "// Identify the war file that contains this class", "ProtectionDomain", "protectionDomain", "=", "RunWar", ".", "class", ".", "getProtectionDomain", "(", ")", ";", "URL", "location", "=", "protectionDomain", ".", "getCodeSource", "(", ")", ".", "getLocation", "(", ")", ";", "String", "warFilePath", "=", "trimToFile", "(", "location", ".", "toExternalForm", "(", ")", ")", ";", "File", "warFile", "=", "new", "File", "(", "warFilePath", ")", ";", "if", "(", "!", "warFile", ".", "exists", "(", ")", ")", "{", "throw", "new", "IllegalStateException", "(", "\"war file not found: \"", "+", "warFilePath", ")", ";", "}", "webapp", ".", "setWar", "(", "warFilePath", ")", ";", "webapp", ".", "setClassLoader", "(", "Thread", ".", "currentThread", "(", ")", ".", "getContextClassLoader", "(", ")", ")", ";", "if", "(", "!", "Boolean", ".", "getBoolean", "(", "\"webapp.extractWar\"", ")", ")", "{", "try", "{", "webapp", ".", "setExtractWAR", "(", "false", ")", ";", "webapp", ".", "setBaseResource", "(", "JarResource", ".", "newJarResource", "(", "Resource", ".", "newResource", "(", "warFile", ")", ")", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Error setting base resource to:\"", "+", "warFilePath", ",", "e", ")", ";", "}", "}", "if", "(", "log", "(", ")", ".", "isDebugEnabled", "(", ")", ")", "{", "ClassLoader", "classLoader", "=", "webapp", ".", "getClassLoader", "(", ")", ";", "log", "(", ")", ".", "debug", "(", "\"webapp classLoader: \"", "+", "classLoader", ")", ";", "if", "(", "classLoader", "instanceof", "URLClassLoader", ")", "{", "URL", "[", "]", "urls", "=", "(", "(", "URLClassLoader", ")", "classLoader", ")", ".", "getURLs", "(", ")", ";", "log", "(", ")", ".", "debug", "(", "\"webapp classLoader URLs: \"", "+", "Arrays", ".", "toString", "(", "urls", ")", ")", ";", "}", "}", "}" ]
Setup the webapp pointing to the war file that contains this class.
[ "Setup", "the", "webapp", "pointing", "to", "the", "war", "file", "that", "contains", "this", "class", "." ]
acddc23754facc339233fa0b9736e94abc8ae842
https://github.com/avaje-common/avaje-jetty-runner/blob/acddc23754facc339233fa0b9736e94abc8ae842/src/main/java/org/avaje/jettyrunner/RunWar.java#L47-L78
154,186
carewebframework/carewebframework-vista
org.carewebframework.vista.mbroker/src/main/java/org/carewebframework/vista/mbroker/ConnectionParams.java
ConnectionParams.addPiece
private void addPiece(String pc, String prefix, StringBuilder sb) { if (!pc.isEmpty()) { if (sb.length() > 0) { sb.append(prefix); } sb.append(pc); } }
java
private void addPiece(String pc, String prefix, StringBuilder sb) { if (!pc.isEmpty()) { if (sb.length() > 0) { sb.append(prefix); } sb.append(pc); } }
[ "private", "void", "addPiece", "(", "String", "pc", ",", "String", "prefix", ",", "StringBuilder", "sb", ")", "{", "if", "(", "!", "pc", ".", "isEmpty", "(", ")", ")", "{", "if", "(", "sb", ".", "length", "(", ")", ">", "0", ")", "{", "sb", ".", "append", "(", "prefix", ")", ";", "}", "sb", ".", "append", "(", "pc", ")", ";", "}", "}" ]
Used to build a connection string for display. @param pc A connection string field. @param prefix The prefix to include if the field is not empty. @param sb String builder instance.
[ "Used", "to", "build", "a", "connection", "string", "for", "display", "." ]
883b2cbe395d9e8a21cd19db820f0876bda6b1c6
https://github.com/carewebframework/carewebframework-vista/blob/883b2cbe395d9e8a21cd19db820f0876bda6b1c6/org.carewebframework.vista.mbroker/src/main/java/org/carewebframework/vista/mbroker/ConnectionParams.java#L153-L161
154,187
jbundle/jbundle
app/program/manual/util/src/main/java/org/jbundle/app/program/manual/util/FieldIterator.java
FieldIterator.inBaseField
private boolean inBaseField(String strFieldFileName, String[] rgstrClassNames) { for (int i = 0; i < rgstrClassNames.length - 1; i++) { // In my base (but not in this (top) class). if (strFieldFileName.equals(rgstrClassNames[i])) return true; } return false; }
java
private boolean inBaseField(String strFieldFileName, String[] rgstrClassNames) { for (int i = 0; i < rgstrClassNames.length - 1; i++) { // In my base (but not in this (top) class). if (strFieldFileName.equals(rgstrClassNames[i])) return true; } return false; }
[ "private", "boolean", "inBaseField", "(", "String", "strFieldFileName", ",", "String", "[", "]", "rgstrClassNames", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "rgstrClassNames", ".", "length", "-", "1", ";", "i", "++", ")", "{", "// In my base (but not in this (top) class).", "if", "(", "strFieldFileName", ".", "equals", "(", "rgstrClassNames", "[", "i", "]", ")", ")", "return", "true", ";", "}", "return", "false", ";", "}" ]
Is this field in my field list already?
[ "Is", "this", "field", "in", "my", "field", "list", "already?" ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/app/program/manual/util/src/main/java/org/jbundle/app/program/manual/util/FieldIterator.java#L184-L192
154,188
jbundle/jbundle
app/program/manual/util/src/main/java/org/jbundle/app/program/manual/util/FieldIterator.java
FieldIterator.scanSharedFields
private void scanSharedFields() { if (!m_bFirstTime) return; m_bFirstTime = false; m_vFieldList = new Vector<FieldSummary>(); m_iCurrentIndex = 0; String strClassName = m_recClassInfo.getField(ClassInfo.CLASS_NAME).toString(); // Step one - Get a list of all the base classes to the origin [0] = VirtualRecord. m_rgstrClasses = this.getBaseRecordClasses(strClassName); String strBaseSharedRecord = null; //if (includeSharedFields == true) { // Now add all the classes from the first shared record up the chain FileHdr recFileHdr = new FileHdr(Record.findRecordOwner(m_recFileHdr)); recFileHdr.setKeyArea(FileHdr.FILE_NAME_KEY); try { for (int i = 0; i < m_rgstrClasses.length; i++) { recFileHdr.addNew(); recFileHdr.getField(FileHdr.FILE_NAME).setString(m_rgstrClasses[i]); if (recFileHdr.seek(null) == true) // For shared records, include overriding record fields. // if (recFileHdr.getField(FileHdr.TYPE).toString().indexOf("SHARED_TABLE") != -1) // For shared records, include overriding record fields. { strBaseSharedRecord = m_rgstrClasses[i]; break; } } } catch (DBException ex) { ex.printStackTrace(); } finally { if (recFileHdr != null) recFileHdr.free(); } } for (int i = 0; i < m_rgstrClasses.length; i++) { this.scanBaseFields(m_rgstrClasses[i], (i == m_rgstrClasses.length - 1)); if (m_rgstrClasses[i].equals(strBaseSharedRecord)) break; } if (strBaseSharedRecord != null) this.scanExtendedClasses(strBaseSharedRecord); if (strBaseSharedRecord != null) if (!strClassName.equals(strBaseSharedRecord)) { // This class is not the base class, merge the two this.scanRecordsFields(m_rgstrClasses); } }
java
private void scanSharedFields() { if (!m_bFirstTime) return; m_bFirstTime = false; m_vFieldList = new Vector<FieldSummary>(); m_iCurrentIndex = 0; String strClassName = m_recClassInfo.getField(ClassInfo.CLASS_NAME).toString(); // Step one - Get a list of all the base classes to the origin [0] = VirtualRecord. m_rgstrClasses = this.getBaseRecordClasses(strClassName); String strBaseSharedRecord = null; //if (includeSharedFields == true) { // Now add all the classes from the first shared record up the chain FileHdr recFileHdr = new FileHdr(Record.findRecordOwner(m_recFileHdr)); recFileHdr.setKeyArea(FileHdr.FILE_NAME_KEY); try { for (int i = 0; i < m_rgstrClasses.length; i++) { recFileHdr.addNew(); recFileHdr.getField(FileHdr.FILE_NAME).setString(m_rgstrClasses[i]); if (recFileHdr.seek(null) == true) // For shared records, include overriding record fields. // if (recFileHdr.getField(FileHdr.TYPE).toString().indexOf("SHARED_TABLE") != -1) // For shared records, include overriding record fields. { strBaseSharedRecord = m_rgstrClasses[i]; break; } } } catch (DBException ex) { ex.printStackTrace(); } finally { if (recFileHdr != null) recFileHdr.free(); } } for (int i = 0; i < m_rgstrClasses.length; i++) { this.scanBaseFields(m_rgstrClasses[i], (i == m_rgstrClasses.length - 1)); if (m_rgstrClasses[i].equals(strBaseSharedRecord)) break; } if (strBaseSharedRecord != null) this.scanExtendedClasses(strBaseSharedRecord); if (strBaseSharedRecord != null) if (!strClassName.equals(strBaseSharedRecord)) { // This class is not the base class, merge the two this.scanRecordsFields(m_rgstrClasses); } }
[ "private", "void", "scanSharedFields", "(", ")", "{", "if", "(", "!", "m_bFirstTime", ")", "return", ";", "m_bFirstTime", "=", "false", ";", "m_vFieldList", "=", "new", "Vector", "<", "FieldSummary", ">", "(", ")", ";", "m_iCurrentIndex", "=", "0", ";", "String", "strClassName", "=", "m_recClassInfo", ".", "getField", "(", "ClassInfo", ".", "CLASS_NAME", ")", ".", "toString", "(", ")", ";", "// Step one - Get a list of all the base classes to the origin [0] = VirtualRecord.", "m_rgstrClasses", "=", "this", ".", "getBaseRecordClasses", "(", "strClassName", ")", ";", "String", "strBaseSharedRecord", "=", "null", ";", "//if (includeSharedFields == true)", "{", "// Now add all the classes from the first shared record up the chain", "FileHdr", "recFileHdr", "=", "new", "FileHdr", "(", "Record", ".", "findRecordOwner", "(", "m_recFileHdr", ")", ")", ";", "recFileHdr", ".", "setKeyArea", "(", "FileHdr", ".", "FILE_NAME_KEY", ")", ";", "try", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "m_rgstrClasses", ".", "length", ";", "i", "++", ")", "{", "recFileHdr", ".", "addNew", "(", ")", ";", "recFileHdr", ".", "getField", "(", "FileHdr", ".", "FILE_NAME", ")", ".", "setString", "(", "m_rgstrClasses", "[", "i", "]", ")", ";", "if", "(", "recFileHdr", ".", "seek", "(", "null", ")", "==", "true", ")", "// For shared records, include overriding record fields.", "//\t\t\t \tif (recFileHdr.getField(FileHdr.TYPE).toString().indexOf(\"SHARED_TABLE\") != -1) // For shared records, include overriding record fields.", "{", "strBaseSharedRecord", "=", "m_rgstrClasses", "[", "i", "]", ";", "break", ";", "}", "}", "}", "catch", "(", "DBException", "ex", ")", "{", "ex", ".", "printStackTrace", "(", ")", ";", "}", "finally", "{", "if", "(", "recFileHdr", "!=", "null", ")", "recFileHdr", ".", "free", "(", ")", ";", "}", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "m_rgstrClasses", ".", "length", ";", "i", "++", ")", "{", "this", ".", "scanBaseFields", "(", "m_rgstrClasses", "[", "i", "]", ",", "(", "i", "==", "m_rgstrClasses", ".", "length", "-", "1", ")", ")", ";", "if", "(", "m_rgstrClasses", "[", "i", "]", ".", "equals", "(", "strBaseSharedRecord", ")", ")", "break", ";", "}", "if", "(", "strBaseSharedRecord", "!=", "null", ")", "this", ".", "scanExtendedClasses", "(", "strBaseSharedRecord", ")", ";", "if", "(", "strBaseSharedRecord", "!=", "null", ")", "if", "(", "!", "strClassName", ".", "equals", "(", "strBaseSharedRecord", ")", ")", "{", "// This class is not the base class, merge the two", "this", ".", "scanRecordsFields", "(", "m_rgstrClasses", ")", ";", "}", "}" ]
Build the field list from the concrete and base record classes.
[ "Build", "the", "field", "list", "from", "the", "concrete", "and", "base", "record", "classes", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/app/program/manual/util/src/main/java/org/jbundle/app/program/manual/util/FieldIterator.java#L197-L251
154,189
jbundle/jbundle
app/program/manual/util/src/main/java/org/jbundle/app/program/manual/util/FieldIterator.java
FieldIterator.getBaseRecordClasses
private String[] getBaseRecordClasses(String strClassName) { ClassInfo recClassInfo = new ClassInfo(Record.findRecordOwner(m_recClassInfo)); String[] rgstrClasses = new String[0]; // rgstrClasses[0] = strClassName; Record recFileHdr = new FileHdr(Record.findRecordOwner(m_recFileHdr)); try { // First, get the base shared record String strBaseClass = strClassName; while (true) { recClassInfo.setKeyArea(ClassInfo.CLASS_NAME_KEY); recClassInfo.getField(ClassInfo.CLASS_NAME).setString(strBaseClass); if (!recClassInfo.seek(null)) break; // No class, Parent is the base. if ("Record".equalsIgnoreCase(recClassInfo.getField(ClassInfo.CLASS_NAME).toString())) break; // if (!includeBaseFields) // { // recFileHdr.getField(FileHdr.FILE_NAME).moveFieldToThis(recClassInfo.getField(ClassInfo.CLASS_NAME)); // recFileHdr.setKeyArea(FileHdr.FILE_NAME_KEY); // if (!recFileHdr.seek("=")) // break; // No file, Parent is the base. // if (recFileHdr.getField(FileHdr.TYPE).toString().indexOf("SHARED_TABLE") == -1) // break; // Not shared, Parent is the base. //} strClassName = strBaseClass; // This is the new valid base. strBaseClass = recClassInfo.getField(ClassInfo.BASE_CLASS_NAME).toString(); // Continue down. // Now add this base class to the bottom of the list String[] rgstrClassesTemp = new String[rgstrClasses.length + 1]; for (int i = 0; i < rgstrClasses.length; i++) { rgstrClassesTemp[i + 1] = rgstrClasses[i]; } rgstrClassesTemp[0] = strClassName; // New base class rgstrClasses = rgstrClassesTemp; } } catch (DBException ex) { ex.printStackTrace(); } finally { recClassInfo.free(); recFileHdr.free(); } return rgstrClasses; }
java
private String[] getBaseRecordClasses(String strClassName) { ClassInfo recClassInfo = new ClassInfo(Record.findRecordOwner(m_recClassInfo)); String[] rgstrClasses = new String[0]; // rgstrClasses[0] = strClassName; Record recFileHdr = new FileHdr(Record.findRecordOwner(m_recFileHdr)); try { // First, get the base shared record String strBaseClass = strClassName; while (true) { recClassInfo.setKeyArea(ClassInfo.CLASS_NAME_KEY); recClassInfo.getField(ClassInfo.CLASS_NAME).setString(strBaseClass); if (!recClassInfo.seek(null)) break; // No class, Parent is the base. if ("Record".equalsIgnoreCase(recClassInfo.getField(ClassInfo.CLASS_NAME).toString())) break; // if (!includeBaseFields) // { // recFileHdr.getField(FileHdr.FILE_NAME).moveFieldToThis(recClassInfo.getField(ClassInfo.CLASS_NAME)); // recFileHdr.setKeyArea(FileHdr.FILE_NAME_KEY); // if (!recFileHdr.seek("=")) // break; // No file, Parent is the base. // if (recFileHdr.getField(FileHdr.TYPE).toString().indexOf("SHARED_TABLE") == -1) // break; // Not shared, Parent is the base. //} strClassName = strBaseClass; // This is the new valid base. strBaseClass = recClassInfo.getField(ClassInfo.BASE_CLASS_NAME).toString(); // Continue down. // Now add this base class to the bottom of the list String[] rgstrClassesTemp = new String[rgstrClasses.length + 1]; for (int i = 0; i < rgstrClasses.length; i++) { rgstrClassesTemp[i + 1] = rgstrClasses[i]; } rgstrClassesTemp[0] = strClassName; // New base class rgstrClasses = rgstrClassesTemp; } } catch (DBException ex) { ex.printStackTrace(); } finally { recClassInfo.free(); recFileHdr.free(); } return rgstrClasses; }
[ "private", "String", "[", "]", "getBaseRecordClasses", "(", "String", "strClassName", ")", "{", "ClassInfo", "recClassInfo", "=", "new", "ClassInfo", "(", "Record", ".", "findRecordOwner", "(", "m_recClassInfo", ")", ")", ";", "String", "[", "]", "rgstrClasses", "=", "new", "String", "[", "0", "]", ";", "// rgstrClasses[0] = strClassName;", "Record", "recFileHdr", "=", "new", "FileHdr", "(", "Record", ".", "findRecordOwner", "(", "m_recFileHdr", ")", ")", ";", "try", "{", "// First, get the base shared record", "String", "strBaseClass", "=", "strClassName", ";", "while", "(", "true", ")", "{", "recClassInfo", ".", "setKeyArea", "(", "ClassInfo", ".", "CLASS_NAME_KEY", ")", ";", "recClassInfo", ".", "getField", "(", "ClassInfo", ".", "CLASS_NAME", ")", ".", "setString", "(", "strBaseClass", ")", ";", "if", "(", "!", "recClassInfo", ".", "seek", "(", "null", ")", ")", "break", ";", "// No class, Parent is the base.", "if", "(", "\"Record\"", ".", "equalsIgnoreCase", "(", "recClassInfo", ".", "getField", "(", "ClassInfo", ".", "CLASS_NAME", ")", ".", "toString", "(", ")", ")", ")", "break", ";", "// if (!includeBaseFields)", "// {", "// recFileHdr.getField(FileHdr.FILE_NAME).moveFieldToThis(recClassInfo.getField(ClassInfo.CLASS_NAME));", "// recFileHdr.setKeyArea(FileHdr.FILE_NAME_KEY);", "// if (!recFileHdr.seek(\"=\"))", "// break; // No file, Parent is the base.", "// if (recFileHdr.getField(FileHdr.TYPE).toString().indexOf(\"SHARED_TABLE\") == -1)", "// break; // Not shared, Parent is the base.", "//}", "strClassName", "=", "strBaseClass", ";", "// This is the new valid base.", "strBaseClass", "=", "recClassInfo", ".", "getField", "(", "ClassInfo", ".", "BASE_CLASS_NAME", ")", ".", "toString", "(", ")", ";", "// Continue down.", "// Now add this base class to the bottom of the list", "String", "[", "]", "rgstrClassesTemp", "=", "new", "String", "[", "rgstrClasses", ".", "length", "+", "1", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "rgstrClasses", ".", "length", ";", "i", "++", ")", "{", "rgstrClassesTemp", "[", "i", "+", "1", "]", "=", "rgstrClasses", "[", "i", "]", ";", "}", "rgstrClassesTemp", "[", "0", "]", "=", "strClassName", ";", "// New base class", "rgstrClasses", "=", "rgstrClassesTemp", ";", "}", "}", "catch", "(", "DBException", "ex", ")", "{", "ex", ".", "printStackTrace", "(", ")", ";", "}", "finally", "{", "recClassInfo", ".", "free", "(", ")", ";", "recFileHdr", ".", "free", "(", ")", ";", "}", "return", "rgstrClasses", ";", "}" ]
Get the hierarchy of classes starting with this class name. @param strClassName The class to start with. @param recClassInfo The class record I can use to look through the classes. @param excludeSharedFields Only return the shared class hierarchy (otherwise the entire hierarchy is returned). @return The class name hierarchy (with position[0] being the lowest and the last is the passing in name).
[ "Get", "the", "hierarchy", "of", "classes", "starting", "with", "this", "class", "name", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/app/program/manual/util/src/main/java/org/jbundle/app/program/manual/util/FieldIterator.java#L259-L303
154,190
jbundle/jbundle
app/program/manual/util/src/main/java/org/jbundle/app/program/manual/util/FieldIterator.java
FieldIterator.isInRecord
private boolean isInRecord(String[] strClassNames, int iClassIndex, String strRecordClass) { boolean bIsInRecord = false; for (int i = 0; i <= iClassIndex; i++) { if (strClassNames[i].equalsIgnoreCase(strRecordClass)) bIsInRecord = true; // True, it IS in the record } return bIsInRecord; // It is in the record? }
java
private boolean isInRecord(String[] strClassNames, int iClassIndex, String strRecordClass) { boolean bIsInRecord = false; for (int i = 0; i <= iClassIndex; i++) { if (strClassNames[i].equalsIgnoreCase(strRecordClass)) bIsInRecord = true; // True, it IS in the record } return bIsInRecord; // It is in the record? }
[ "private", "boolean", "isInRecord", "(", "String", "[", "]", "strClassNames", ",", "int", "iClassIndex", ",", "String", "strRecordClass", ")", "{", "boolean", "bIsInRecord", "=", "false", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<=", "iClassIndex", ";", "i", "++", ")", "{", "if", "(", "strClassNames", "[", "i", "]", ".", "equalsIgnoreCase", "(", "strRecordClass", ")", ")", "bIsInRecord", "=", "true", ";", "// True, it IS in the record", "}", "return", "bIsInRecord", ";", "// It is in the record?", "}" ]
Is this class one of the base class names for this record?
[ "Is", "this", "class", "one", "of", "the", "base", "class", "names", "for", "this", "record?" ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/app/program/manual/util/src/main/java/org/jbundle/app/program/manual/util/FieldIterator.java#L415-L424
154,191
microfocus-idol/java-parametric-databases
hod/src/main/java/com/hp/autonomy/hod/databases/AbstractResourceMapper.java
AbstractResourceMapper.databaseForResource
protected Database databaseForResource(final TokenProxy<?, TokenType.Simple> tokenProxy, final Resource resource, final String domain) throws HodErrorException { final ResourceIdentifier resourceIdentifier = new ResourceIdentifier(domain, resource.getResource()); final Set<String> parametricFields; if (tokenProxy == null) { parametricFields = indexFieldsService.getParametricFields(resourceIdentifier); } else { parametricFields = indexFieldsService.getParametricFields(tokenProxy, resourceIdentifier); } return new Database.Builder() .setName(resource.getResource()) .setDisplayName(resource.getDisplayName()) .setIsPublic(ResourceIdentifier.PUBLIC_INDEXES_DOMAIN.equals(domain)) .setDomain(domain) .setIndexFields(parametricFields) .build(); }
java
protected Database databaseForResource(final TokenProxy<?, TokenType.Simple> tokenProxy, final Resource resource, final String domain) throws HodErrorException { final ResourceIdentifier resourceIdentifier = new ResourceIdentifier(domain, resource.getResource()); final Set<String> parametricFields; if (tokenProxy == null) { parametricFields = indexFieldsService.getParametricFields(resourceIdentifier); } else { parametricFields = indexFieldsService.getParametricFields(tokenProxy, resourceIdentifier); } return new Database.Builder() .setName(resource.getResource()) .setDisplayName(resource.getDisplayName()) .setIsPublic(ResourceIdentifier.PUBLIC_INDEXES_DOMAIN.equals(domain)) .setDomain(domain) .setIndexFields(parametricFields) .build(); }
[ "protected", "Database", "databaseForResource", "(", "final", "TokenProxy", "<", "?", ",", "TokenType", ".", "Simple", ">", "tokenProxy", ",", "final", "Resource", "resource", ",", "final", "String", "domain", ")", "throws", "HodErrorException", "{", "final", "ResourceIdentifier", "resourceIdentifier", "=", "new", "ResourceIdentifier", "(", "domain", ",", "resource", ".", "getResource", "(", ")", ")", ";", "final", "Set", "<", "String", ">", "parametricFields", ";", "if", "(", "tokenProxy", "==", "null", ")", "{", "parametricFields", "=", "indexFieldsService", ".", "getParametricFields", "(", "resourceIdentifier", ")", ";", "}", "else", "{", "parametricFields", "=", "indexFieldsService", ".", "getParametricFields", "(", "tokenProxy", ",", "resourceIdentifier", ")", ";", "}", "return", "new", "Database", ".", "Builder", "(", ")", ".", "setName", "(", "resource", ".", "getResource", "(", ")", ")", ".", "setDisplayName", "(", "resource", ".", "getDisplayName", "(", ")", ")", ".", "setIsPublic", "(", "ResourceIdentifier", ".", "PUBLIC_INDEXES_DOMAIN", ".", "equals", "(", "domain", ")", ")", ".", "setDomain", "(", "domain", ")", ".", "setIndexFields", "(", "parametricFields", ")", ".", "build", "(", ")", ";", "}" ]
Converts the given resource name to a database @param tokenProxy The token proxy to use to retrieve parametric fields @param resource The resource @param domain The domain of the resource @return A database representation of the resource @throws HodErrorException
[ "Converts", "the", "given", "resource", "name", "to", "a", "database" ]
378a246a1857f911587106241712d16c2e118af2
https://github.com/microfocus-idol/java-parametric-databases/blob/378a246a1857f911587106241712d16c2e118af2/hod/src/main/java/com/hp/autonomy/hod/databases/AbstractResourceMapper.java#L36-L54
154,192
jbundle/jbundle
thin/base/db/base/src/main/java/org/jbundle/thin/base/db/mem/MemoryFieldTable.java
MemoryFieldTable.setPTableRef
public void setPTableRef(PTable pTable, PhysicalDatabaseParent dbOwner) { m_pTable = pTable; if (pTable == null) if (dbOwner != null) { FieldList record = this.getRecord(); if (record != null) { PDatabase pDatabase = dbOwner.getPDatabase(record.getDatabaseName(), ThinPhysicalDatabase.MEMORY_TYPE, true); pDatabase.addPDatabaseOwner(this); if (pDatabase != null) pTable = pDatabase.getPTable(record, true); pTable.addPTableOwner(this); m_pTable = pTable; } } }
java
public void setPTableRef(PTable pTable, PhysicalDatabaseParent dbOwner) { m_pTable = pTable; if (pTable == null) if (dbOwner != null) { FieldList record = this.getRecord(); if (record != null) { PDatabase pDatabase = dbOwner.getPDatabase(record.getDatabaseName(), ThinPhysicalDatabase.MEMORY_TYPE, true); pDatabase.addPDatabaseOwner(this); if (pDatabase != null) pTable = pDatabase.getPTable(record, true); pTable.addPTableOwner(this); m_pTable = pTable; } } }
[ "public", "void", "setPTableRef", "(", "PTable", "pTable", ",", "PhysicalDatabaseParent", "dbOwner", ")", "{", "m_pTable", "=", "pTable", ";", "if", "(", "pTable", "==", "null", ")", "if", "(", "dbOwner", "!=", "null", ")", "{", "FieldList", "record", "=", "this", ".", "getRecord", "(", ")", ";", "if", "(", "record", "!=", "null", ")", "{", "PDatabase", "pDatabase", "=", "dbOwner", ".", "getPDatabase", "(", "record", ".", "getDatabaseName", "(", ")", ",", "ThinPhysicalDatabase", ".", "MEMORY_TYPE", ",", "true", ")", ";", "pDatabase", ".", "addPDatabaseOwner", "(", "this", ")", ";", "if", "(", "pDatabase", "!=", "null", ")", "pTable", "=", "pDatabase", ".", "getPTable", "(", "record", ",", "true", ")", ";", "pTable", ".", "addPTableOwner", "(", "this", ")", ";", "m_pTable", "=", "pTable", ";", "}", "}", "}" ]
Set the raw data table reference. @param pTable The raw data table. @param dbOwner If you want this method to lookup/build the remote table, pass this.
[ "Set", "the", "raw", "data", "table", "reference", "." ]
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/db/base/src/main/java/org/jbundle/thin/base/db/mem/MemoryFieldTable.java#L230-L247
154,193
OwlPlatform/java-owl-worldmodel
src/main/java/com/owlplatform/worldmodel/client/WorldState.java
WorldState.addState
public void addState(final String id, final Collection<Attribute> attributes) { this.stateMap.put(id, attributes); }
java
public void addState(final String id, final Collection<Attribute> attributes) { this.stateMap.put(id, attributes); }
[ "public", "void", "addState", "(", "final", "String", "id", ",", "final", "Collection", "<", "Attribute", ">", "attributes", ")", "{", "this", ".", "stateMap", ".", "put", "(", "id", ",", "attributes", ")", ";", "}" ]
Binds a set of Attribute values to an identifier. @param id the identifier @param attributes the set of attributes.
[ "Binds", "a", "set", "of", "Attribute", "values", "to", "an", "identifier", "." ]
a850e8b930c6e9787c7cad30c0de887858ca563d
https://github.com/OwlPlatform/java-owl-worldmodel/blob/a850e8b930c6e9787c7cad30c0de887858ca563d/src/main/java/com/owlplatform/worldmodel/client/WorldState.java#L50-L52
154,194
OwlPlatform/java-owl-worldmodel
src/main/java/com/owlplatform/worldmodel/client/WorldState.java
WorldState.getIdentifiers
public Collection<String> getIdentifiers() { List<String> keys = new LinkedList<String>(); keys.addAll(this.stateMap.keySet()); return keys; }
java
public Collection<String> getIdentifiers() { List<String> keys = new LinkedList<String>(); keys.addAll(this.stateMap.keySet()); return keys; }
[ "public", "Collection", "<", "String", ">", "getIdentifiers", "(", ")", "{", "List", "<", "String", ">", "keys", "=", "new", "LinkedList", "<", "String", ">", "(", ")", ";", "keys", ".", "addAll", "(", "this", ".", "stateMap", ".", "keySet", "(", ")", ")", ";", "return", "keys", ";", "}" ]
Returns a collection containing the same Identifier Strings as this WorldState object. Modifications to the returned Collection do not impact this WorldState. @return a collection containing the same Identifier Strings as this WorldState.
[ "Returns", "a", "collection", "containing", "the", "same", "Identifier", "Strings", "as", "this", "WorldState", "object", ".", "Modifications", "to", "the", "returned", "Collection", "do", "not", "impact", "this", "WorldState", "." ]
a850e8b930c6e9787c7cad30c0de887858ca563d
https://github.com/OwlPlatform/java-owl-worldmodel/blob/a850e8b930c6e9787c7cad30c0de887858ca563d/src/main/java/com/owlplatform/worldmodel/client/WorldState.java#L73-L77
154,195
lightblueseas/vintage-time
src/main/java/de/alpharogroup/date/IntervalExtensions.java
IntervalExtensions.isBetween
public static boolean isBetween(final Interval timeRange, final Interval timeRangeToCheck) { return ((timeRange.getStart() != null && timeRange.getStart().isBefore(timeRangeToCheck.getStart())) && (timeRange.getEnd() != null && timeRange.getEnd().isAfter(timeRangeToCheck.getEnd()))); }
java
public static boolean isBetween(final Interval timeRange, final Interval timeRangeToCheck) { return ((timeRange.getStart() != null && timeRange.getStart().isBefore(timeRangeToCheck.getStart())) && (timeRange.getEnd() != null && timeRange.getEnd().isAfter(timeRangeToCheck.getEnd()))); }
[ "public", "static", "boolean", "isBetween", "(", "final", "Interval", "timeRange", ",", "final", "Interval", "timeRangeToCheck", ")", "{", "return", "(", "(", "timeRange", ".", "getStart", "(", ")", "!=", "null", "&&", "timeRange", ".", "getStart", "(", ")", ".", "isBefore", "(", "timeRangeToCheck", ".", "getStart", "(", ")", ")", ")", "&&", "(", "timeRange", ".", "getEnd", "(", ")", "!=", "null", "&&", "timeRange", ".", "getEnd", "(", ")", ".", "isAfter", "(", "timeRangeToCheck", ".", "getEnd", "(", ")", ")", ")", ")", ";", "}" ]
Checks if the given time range is between the given time range to check @param timeRange the time range @param timeRangeToCheck the time range to check @return true, if the given time range is between the given time range to check otherwise false
[ "Checks", "if", "the", "given", "time", "range", "is", "between", "the", "given", "time", "range", "to", "check" ]
fbf201e679d9f9b92e7b5771f3eea1413cc2e113
https://github.com/lightblueseas/vintage-time/blob/fbf201e679d9f9b92e7b5771f3eea1413cc2e113/src/main/java/de/alpharogroup/date/IntervalExtensions.java#L54-L60
154,196
lightblueseas/vintage-time
src/main/java/de/alpharogroup/date/IntervalExtensions.java
IntervalExtensions.isOverlappingBefore
public static boolean isOverlappingBefore(final Interval timeRange, final Interval timeRangeToCheck) { return ((timeRange.getStart() != null && timeRange.getStart().isAfter(timeRangeToCheck.getStart())) && (timeRange.getEnd() != null && timeRange.getEnd().isAfter(timeRangeToCheck.getEnd()))); }
java
public static boolean isOverlappingBefore(final Interval timeRange, final Interval timeRangeToCheck) { return ((timeRange.getStart() != null && timeRange.getStart().isAfter(timeRangeToCheck.getStart())) && (timeRange.getEnd() != null && timeRange.getEnd().isAfter(timeRangeToCheck.getEnd()))); }
[ "public", "static", "boolean", "isOverlappingBefore", "(", "final", "Interval", "timeRange", ",", "final", "Interval", "timeRangeToCheck", ")", "{", "return", "(", "(", "timeRange", ".", "getStart", "(", ")", "!=", "null", "&&", "timeRange", ".", "getStart", "(", ")", ".", "isAfter", "(", "timeRangeToCheck", ".", "getStart", "(", ")", ")", ")", "&&", "(", "timeRange", ".", "getEnd", "(", ")", "!=", "null", "&&", "timeRange", ".", "getEnd", "(", ")", ".", "isAfter", "(", "timeRangeToCheck", ".", "getEnd", "(", ")", ")", ")", ")", ";", "}" ]
Checks if the given time range is overlapping before the given time range to check. @param timeRange the time range @param timeRangeToCheck the time range to check @return true, if the given time range is overlapping before the given time range to check otherwise false
[ "Checks", "if", "the", "given", "time", "range", "is", "overlapping", "before", "the", "given", "time", "range", "to", "check", "." ]
fbf201e679d9f9b92e7b5771f3eea1413cc2e113
https://github.com/lightblueseas/vintage-time/blob/fbf201e679d9f9b92e7b5771f3eea1413cc2e113/src/main/java/de/alpharogroup/date/IntervalExtensions.java#L72-L79
154,197
lightblueseas/vintage-time
src/main/java/de/alpharogroup/date/IntervalExtensions.java
IntervalExtensions.isOverlappingAfter
public static boolean isOverlappingAfter(final Interval timeRange, final Interval timeRangeToCheck) { return ((timeRange.getStart() != null && timeRange.getStart().isBefore(timeRangeToCheck.getStart())) && (timeRange.getEnd() != null && timeRange.getEnd().isBefore(timeRangeToCheck.getEnd()))); }
java
public static boolean isOverlappingAfter(final Interval timeRange, final Interval timeRangeToCheck) { return ((timeRange.getStart() != null && timeRange.getStart().isBefore(timeRangeToCheck.getStart())) && (timeRange.getEnd() != null && timeRange.getEnd().isBefore(timeRangeToCheck.getEnd()))); }
[ "public", "static", "boolean", "isOverlappingAfter", "(", "final", "Interval", "timeRange", ",", "final", "Interval", "timeRangeToCheck", ")", "{", "return", "(", "(", "timeRange", ".", "getStart", "(", ")", "!=", "null", "&&", "timeRange", ".", "getStart", "(", ")", ".", "isBefore", "(", "timeRangeToCheck", ".", "getStart", "(", ")", ")", ")", "&&", "(", "timeRange", ".", "getEnd", "(", ")", "!=", "null", "&&", "timeRange", ".", "getEnd", "(", ")", ".", "isBefore", "(", "timeRangeToCheck", ".", "getEnd", "(", ")", ")", ")", ")", ";", "}" ]
Checks if the given time range is overlapping after the given time range to check. @param timeRange the time range @param timeRangeToCheck the time range to check @return true, if the given time range is overlapping after the given time range to check otherwise false
[ "Checks", "if", "the", "given", "time", "range", "is", "overlapping", "after", "the", "given", "time", "range", "to", "check", "." ]
fbf201e679d9f9b92e7b5771f3eea1413cc2e113
https://github.com/lightblueseas/vintage-time/blob/fbf201e679d9f9b92e7b5771f3eea1413cc2e113/src/main/java/de/alpharogroup/date/IntervalExtensions.java#L91-L98
154,198
pressgang-ccms/PressGangCCMSQuery
src/main/java/org/jboss/pressgang/ccms/filter/base/BaseTopicFilterQueryBuilder.java
BaseTopicFilterQueryBuilder.getOpenBugzillaSubquery
private Subquery<TopicToBugzillaBug> getOpenBugzillaSubquery() { final CriteriaBuilder criteriaBuilder = getCriteriaBuilder(); final Subquery<TopicToBugzillaBug> subQuery = getCriteriaQuery().subquery(TopicToBugzillaBug.class); final Root<TopicToBugzillaBug> root = subQuery.from(TopicToBugzillaBug.class); subQuery.select(root); // Create the Condition for the subquery final Predicate topicIdMatch = criteriaBuilder.equal(getRootPath(), root.get("topic")); final Predicate bugOpenMatch = criteriaBuilder.isTrue(root.get("bugzillaBug").get("bugzillaBugOpen").as(Boolean.class)); subQuery.where(criteriaBuilder.and(topicIdMatch, bugOpenMatch)); return subQuery; }
java
private Subquery<TopicToBugzillaBug> getOpenBugzillaSubquery() { final CriteriaBuilder criteriaBuilder = getCriteriaBuilder(); final Subquery<TopicToBugzillaBug> subQuery = getCriteriaQuery().subquery(TopicToBugzillaBug.class); final Root<TopicToBugzillaBug> root = subQuery.from(TopicToBugzillaBug.class); subQuery.select(root); // Create the Condition for the subquery final Predicate topicIdMatch = criteriaBuilder.equal(getRootPath(), root.get("topic")); final Predicate bugOpenMatch = criteriaBuilder.isTrue(root.get("bugzillaBug").get("bugzillaBugOpen").as(Boolean.class)); subQuery.where(criteriaBuilder.and(topicIdMatch, bugOpenMatch)); return subQuery; }
[ "private", "Subquery", "<", "TopicToBugzillaBug", ">", "getOpenBugzillaSubquery", "(", ")", "{", "final", "CriteriaBuilder", "criteriaBuilder", "=", "getCriteriaBuilder", "(", ")", ";", "final", "Subquery", "<", "TopicToBugzillaBug", ">", "subQuery", "=", "getCriteriaQuery", "(", ")", ".", "subquery", "(", "TopicToBugzillaBug", ".", "class", ")", ";", "final", "Root", "<", "TopicToBugzillaBug", ">", "root", "=", "subQuery", ".", "from", "(", "TopicToBugzillaBug", ".", "class", ")", ";", "subQuery", ".", "select", "(", "root", ")", ";", "// Create the Condition for the subquery", "final", "Predicate", "topicIdMatch", "=", "criteriaBuilder", ".", "equal", "(", "getRootPath", "(", ")", ",", "root", ".", "get", "(", "\"topic\"", ")", ")", ";", "final", "Predicate", "bugOpenMatch", "=", "criteriaBuilder", ".", "isTrue", "(", "root", ".", "get", "(", "\"bugzillaBug\"", ")", ".", "get", "(", "\"bugzillaBugOpen\"", ")", ".", "as", "(", "Boolean", ".", "class", ")", ")", ";", "subQuery", ".", "where", "(", "criteriaBuilder", ".", "and", "(", "topicIdMatch", ",", "bugOpenMatch", ")", ")", ";", "return", "subQuery", ";", "}" ]
Create a Subquery to check if a topic has open bugs. @return A subquery that can be used in an exists statement to see if a topic has open bugs.
[ "Create", "a", "Subquery", "to", "check", "if", "a", "topic", "has", "open", "bugs", "." ]
2bb23430adab956737d0301cd2ea933f986dd85b
https://github.com/pressgang-ccms/PressGangCCMSQuery/blob/2bb23430adab956737d0301cd2ea933f986dd85b/src/main/java/org/jboss/pressgang/ccms/filter/base/BaseTopicFilterQueryBuilder.java#L311-L323
154,199
jmeetsma/Iglu-Util
src/main/java/org/ijsberg/iglu/util/collection/CollectionSupport.java
CollectionSupport.print
public static void print(Collection coll, PrintStream out, String separator) { out.print(format(coll, separator)); }
java
public static void print(Collection coll, PrintStream out, String separator) { out.print(format(coll, separator)); }
[ "public", "static", "void", "print", "(", "Collection", "coll", ",", "PrintStream", "out", ",", "String", "separator", ")", "{", "out", ".", "print", "(", "format", "(", "coll", ",", "separator", ")", ")", ";", "}" ]
Prints a collection to the given output stream. @param coll @param out stream to print to @param separator item separator
[ "Prints", "a", "collection", "to", "the", "given", "output", "stream", "." ]
971eb022115247b1e34dc26dd02e7e621e29e910
https://github.com/jmeetsma/Iglu-Util/blob/971eb022115247b1e34dc26dd02e7e621e29e910/src/main/java/org/ijsberg/iglu/util/collection/CollectionSupport.java#L61-L63