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
10,000
aerogear/aerogear-android-push
library/src/main/java/org/jboss/aerogear/android/unifiedpush/fcm/AeroGearFCMPushRegistrar.java
AeroGearFCMPushRegistrar.sendMetrics
@Override public void sendMetrics(final UnifiedPushMetricsMessage metricsMessage, final Callback<UnifiedPushMetricsMessage> callback) { new AsyncTask<Void, Void, Exception>() { @Override protected Exception doInBackground(Void... params) { try { if ((metricsMessage.getMessageId() == null) || (metricsMessage.getMessageId().trim().equals(""))) { throw new IllegalStateException("Message ID cannot be null or blank"); } HttpProvider provider = httpProviderProvider.get(metricsURL, TIMEOUT); setPasswordAuthentication(variantId, secret, provider); try { provider.put(metricsMessage.getMessageId(), ""); return null; } catch (HttpException ex) { return ex; } } catch (Exception ex) { return ex; } } @SuppressWarnings("unchecked") @Override protected void onPostExecute(Exception result) { if (result == null) { callback.onSuccess(metricsMessage); } else { callback.onFailure(result); } } }.execute((Void) null); }
java
@Override public void sendMetrics(final UnifiedPushMetricsMessage metricsMessage, final Callback<UnifiedPushMetricsMessage> callback) { new AsyncTask<Void, Void, Exception>() { @Override protected Exception doInBackground(Void... params) { try { if ((metricsMessage.getMessageId() == null) || (metricsMessage.getMessageId().trim().equals(""))) { throw new IllegalStateException("Message ID cannot be null or blank"); } HttpProvider provider = httpProviderProvider.get(metricsURL, TIMEOUT); setPasswordAuthentication(variantId, secret, provider); try { provider.put(metricsMessage.getMessageId(), ""); return null; } catch (HttpException ex) { return ex; } } catch (Exception ex) { return ex; } } @SuppressWarnings("unchecked") @Override protected void onPostExecute(Exception result) { if (result == null) { callback.onSuccess(metricsMessage); } else { callback.onFailure(result); } } }.execute((Void) null); }
[ "@", "Override", "public", "void", "sendMetrics", "(", "final", "UnifiedPushMetricsMessage", "metricsMessage", ",", "final", "Callback", "<", "UnifiedPushMetricsMessage", ">", "callback", ")", "{", "new", "AsyncTask", "<", "Void", ",", "Void", ",", "Exception", ">", "(", ")", "{", "@", "Override", "protected", "Exception", "doInBackground", "(", "Void", "...", "params", ")", "{", "try", "{", "if", "(", "(", "metricsMessage", ".", "getMessageId", "(", ")", "==", "null", ")", "||", "(", "metricsMessage", ".", "getMessageId", "(", ")", ".", "trim", "(", ")", ".", "equals", "(", "\"\"", ")", ")", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Message ID cannot be null or blank\"", ")", ";", "}", "HttpProvider", "provider", "=", "httpProviderProvider", ".", "get", "(", "metricsURL", ",", "TIMEOUT", ")", ";", "setPasswordAuthentication", "(", "variantId", ",", "secret", ",", "provider", ")", ";", "try", "{", "provider", ".", "put", "(", "metricsMessage", ".", "getMessageId", "(", ")", ",", "\"\"", ")", ";", "return", "null", ";", "}", "catch", "(", "HttpException", "ex", ")", "{", "return", "ex", ";", "}", "}", "catch", "(", "Exception", "ex", ")", "{", "return", "ex", ";", "}", "}", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "@", "Override", "protected", "void", "onPostExecute", "(", "Exception", "result", ")", "{", "if", "(", "result", "==", "null", ")", "{", "callback", ".", "onSuccess", "(", "metricsMessage", ")", ";", "}", "else", "{", "callback", ".", "onFailure", "(", "result", ")", ";", "}", "}", "}", ".", "execute", "(", "(", "Void", ")", "null", ")", ";", "}" ]
Send a confirmation the message was opened @param metricsMessage The id of the message received @param callback a callback.
[ "Send", "a", "confirmation", "the", "message", "was", "opened" ]
f21f93393a9f4590e9a8d6d045ab9aabca3d211f
https://github.com/aerogear/aerogear-android-push/blob/f21f93393a9f4590e9a8d6d045ab9aabca3d211f/library/src/main/java/org/jboss/aerogear/android/unifiedpush/fcm/AeroGearFCMPushRegistrar.java#L311-L351
10,001
aerogear/aerogear-android-push
library/src/main/java/org/jboss/aerogear/android/unifiedpush/fcm/AeroGearFCMPushRegistrar.java
AeroGearFCMPushRegistrar.removeSavedPostData
private void removeSavedPostData(Context appContext) { preferenceProvider.get(appContext).edit() .remove(String.format(REGISTRAR_PREFERENCE_TEMPLATE, senderId)) .commit(); }
java
private void removeSavedPostData(Context appContext) { preferenceProvider.get(appContext).edit() .remove(String.format(REGISTRAR_PREFERENCE_TEMPLATE, senderId)) .commit(); }
[ "private", "void", "removeSavedPostData", "(", "Context", "appContext", ")", "{", "preferenceProvider", ".", "get", "(", "appContext", ")", ".", "edit", "(", ")", ".", "remove", "(", "String", ".", "format", "(", "REGISTRAR_PREFERENCE_TEMPLATE", ",", "senderId", ")", ")", ".", "commit", "(", ")", ";", "}" ]
We are no longer registered. We do not need to respond to changes in registration token. @param appContext the application Context
[ "We", "are", "no", "longer", "registered", ".", "We", "do", "not", "need", "to", "respond", "to", "changes", "in", "registration", "token", "." ]
f21f93393a9f4590e9a8d6d045ab9aabca3d211f
https://github.com/aerogear/aerogear-android-push/blob/f21f93393a9f4590e9a8d6d045ab9aabca3d211f/library/src/main/java/org/jboss/aerogear/android/unifiedpush/fcm/AeroGearFCMPushRegistrar.java#L383-L387
10,002
aerogear/aerogear-android-push
library/src/main/java/org/jboss/aerogear/android/unifiedpush/fcm/AeroGearFCMPushRegistrar.java
AeroGearFCMPushRegistrar.getOldToken
private String getOldToken(Context appContext) { String jsonData = preferenceProvider.get(appContext).getString(String.format(REGISTRAR_PREFERENCE_TEMPLATE, senderId), ""); if (jsonData.isEmpty()) { return ""; } JsonObject jsonedPreferences = new JsonParser().parse(jsonData).getAsJsonObject(); try { return jsonedPreferences.get("deviceToken").getAsString(); } catch (Exception ignore) { //There was something wrong with the deviceToken or the jsonPreferences. //This probably means that there isn't an oldToken. Let's log and return an empty String Log.w(TAG, ignore.getMessage(), ignore); return ""; } }
java
private String getOldToken(Context appContext) { String jsonData = preferenceProvider.get(appContext).getString(String.format(REGISTRAR_PREFERENCE_TEMPLATE, senderId), ""); if (jsonData.isEmpty()) { return ""; } JsonObject jsonedPreferences = new JsonParser().parse(jsonData).getAsJsonObject(); try { return jsonedPreferences.get("deviceToken").getAsString(); } catch (Exception ignore) { //There was something wrong with the deviceToken or the jsonPreferences. //This probably means that there isn't an oldToken. Let's log and return an empty String Log.w(TAG, ignore.getMessage(), ignore); return ""; } }
[ "private", "String", "getOldToken", "(", "Context", "appContext", ")", "{", "String", "jsonData", "=", "preferenceProvider", ".", "get", "(", "appContext", ")", ".", "getString", "(", "String", ".", "format", "(", "REGISTRAR_PREFERENCE_TEMPLATE", ",", "senderId", ")", ",", "\"\"", ")", ";", "if", "(", "jsonData", ".", "isEmpty", "(", ")", ")", "{", "return", "\"\"", ";", "}", "JsonObject", "jsonedPreferences", "=", "new", "JsonParser", "(", ")", ".", "parse", "(", "jsonData", ")", ".", "getAsJsonObject", "(", ")", ";", "try", "{", "return", "jsonedPreferences", ".", "get", "(", "\"deviceToken\"", ")", ".", "getAsString", "(", ")", ";", "}", "catch", "(", "Exception", "ignore", ")", "{", "//There was something wrong with the deviceToken or the jsonPreferences. ", "//This probably means that there isn't an oldToken. Let's log and return an empty String", "Log", ".", "w", "(", "TAG", ",", "ignore", ".", "getMessage", "(", ")", ",", "ignore", ")", ";", "return", "\"\"", ";", "}", "}" ]
Returns the most recently used deviceToken @return a deviceToken or an empty string
[ "Returns", "the", "most", "recently", "used", "deviceToken" ]
f21f93393a9f4590e9a8d6d045ab9aabca3d211f
https://github.com/aerogear/aerogear-android-push/blob/f21f93393a9f4590e9a8d6d045ab9aabca3d211f/library/src/main/java/org/jboss/aerogear/android/unifiedpush/fcm/AeroGearFCMPushRegistrar.java#L393-L409
10,003
amplexus/java-flac-encoder
src/main/java/net/sourceforge/javaflacencoder/RiceEncoder.java
RiceEncoder.beginResidual
public static int beginResidual(boolean useFiveBitParam, byte order, EncodedElement ele) { ele = ele.getEnd(); int paramSize = (useFiveBitParam) ? 1:0; ele.addInt(paramSize, 2); ele.addInt(order, 4); return 6; }
java
public static int beginResidual(boolean useFiveBitParam, byte order, EncodedElement ele) { ele = ele.getEnd(); int paramSize = (useFiveBitParam) ? 1:0; ele.addInt(paramSize, 2); ele.addInt(order, 4); return 6; }
[ "public", "static", "int", "beginResidual", "(", "boolean", "useFiveBitParam", ",", "byte", "order", ",", "EncodedElement", "ele", ")", "{", "ele", "=", "ele", ".", "getEnd", "(", ")", ";", "int", "paramSize", "=", "(", "useFiveBitParam", ")", "?", "1", ":", "0", ";", "ele", ".", "addInt", "(", "paramSize", ",", "2", ")", ";", "ele", ".", "addInt", "(", "order", ",", "4", ")", ";", "return", "6", ";", "}" ]
Create the residual headers for a FLAC stream. @param useFiveBitParam Set TRUE if using a five-bit parameter size, FALSE for a four-bit parameter @param order Specify order of partitions to be used(actual number of partitions will be 2^order. @param ele EncodedElement to write header to. @return total written size of header.
[ "Create", "the", "residual", "headers", "for", "a", "FLAC", "stream", "." ]
3d536b877dee2a3fd4ab2e0d9569e292cae93bc9
https://github.com/amplexus/java-flac-encoder/blob/3d536b877dee2a3fd4ab2e0d9569e292cae93bc9/src/main/java/net/sourceforge/javaflacencoder/RiceEncoder.java#L61-L68
10,004
amplexus/java-flac-encoder
src/main/java/net/sourceforge/javaflacencoder/FrameThread.java
FrameThread.run
public void run() { boolean process = true; synchronized(this) { BlockEncodeRequest ber = manager.getWaitingRequest(); if(ber != null && ber.frameNumber < 0) ber = null; while(ber != null && process) { if(ber.frameNumber < 0) { process = false; } else {//get available BlockEncodeRequest from manager ber.encodedSamples = frame.encodeSamples(ber.samples, ber.count, ber.start, ber.skip, ber.result, ber.frameNumber); ber.valid = true; manager.returnFinishedRequest(ber); ber = manager.getWaitingRequest(); } } manager.notifyFrameThreadExit(this); } }
java
public void run() { boolean process = true; synchronized(this) { BlockEncodeRequest ber = manager.getWaitingRequest(); if(ber != null && ber.frameNumber < 0) ber = null; while(ber != null && process) { if(ber.frameNumber < 0) { process = false; } else {//get available BlockEncodeRequest from manager ber.encodedSamples = frame.encodeSamples(ber.samples, ber.count, ber.start, ber.skip, ber.result, ber.frameNumber); ber.valid = true; manager.returnFinishedRequest(ber); ber = manager.getWaitingRequest(); } } manager.notifyFrameThreadExit(this); } }
[ "public", "void", "run", "(", ")", "{", "boolean", "process", "=", "true", ";", "synchronized", "(", "this", ")", "{", "BlockEncodeRequest", "ber", "=", "manager", ".", "getWaitingRequest", "(", ")", ";", "if", "(", "ber", "!=", "null", "&&", "ber", ".", "frameNumber", "<", "0", ")", "ber", "=", "null", ";", "while", "(", "ber", "!=", "null", "&&", "process", ")", "{", "if", "(", "ber", ".", "frameNumber", "<", "0", ")", "{", "process", "=", "false", ";", "}", "else", "{", "//get available BlockEncodeRequest from manager", "ber", ".", "encodedSamples", "=", "frame", ".", "encodeSamples", "(", "ber", ".", "samples", ",", "ber", ".", "count", ",", "ber", ".", "start", ",", "ber", ".", "skip", ",", "ber", ".", "result", ",", "ber", ".", "frameNumber", ")", ";", "ber", ".", "valid", "=", "true", ";", "manager", ".", "returnFinishedRequest", "(", "ber", ")", ";", "ber", "=", "manager", ".", "getWaitingRequest", "(", ")", ";", "}", "}", "manager", ".", "notifyFrameThreadExit", "(", "this", ")", ";", "}", "}" ]
Run method. This FrameThread will get a BlockEncodeRequest from the BlockThreadManager, encode the block, return it to the manager, then repeat. If no BlockEncodeRequest is available, or if it recieves a request with the "frameNumber" field set to a negative value, it will break the loop and end, notifying the manager it has ended.
[ "Run", "method", ".", "This", "FrameThread", "will", "get", "a", "BlockEncodeRequest", "from", "the", "BlockThreadManager", "encode", "the", "block", "return", "it", "to", "the", "manager", "then", "repeat", ".", "If", "no", "BlockEncodeRequest", "is", "available", "or", "if", "it", "recieves", "a", "request", "with", "the", "frameNumber", "field", "set", "to", "a", "negative", "value", "it", "will", "break", "the", "loop", "and", "end", "notifying", "the", "manager", "it", "has", "ended", "." ]
3d536b877dee2a3fd4ab2e0d9569e292cae93bc9
https://github.com/amplexus/java-flac-encoder/blob/3d536b877dee2a3fd4ab2e0d9569e292cae93bc9/src/main/java/net/sourceforge/javaflacencoder/FrameThread.java#L65-L85
10,005
amplexus/java-flac-encoder
src/main/java/net/sourceforge/javaflacencoder/FLACFileOutputStream.java
FLACFileOutputStream.write
public void write(byte data) throws IOException { fos.write(data); if(position + 1 > size) size = position+1; position+= 1; }
java
public void write(byte data) throws IOException { fos.write(data); if(position + 1 > size) size = position+1; position+= 1; }
[ "public", "void", "write", "(", "byte", "data", ")", "throws", "IOException", "{", "fos", ".", "write", "(", "data", ")", ";", "if", "(", "position", "+", "1", ">", "size", ")", "size", "=", "position", "+", "1", ";", "position", "+=", "1", ";", "}" ]
Write a byte to this stream. @param data byte to write. @throws IOException IOException will be raised if an error occurred while writing.
[ "Write", "a", "byte", "to", "this", "stream", "." ]
3d536b877dee2a3fd4ab2e0d9569e292cae93bc9
https://github.com/amplexus/java-flac-encoder/blob/3d536b877dee2a3fd4ab2e0d9569e292cae93bc9/src/main/java/net/sourceforge/javaflacencoder/FLACFileOutputStream.java#L98-L103
10,006
amplexus/java-flac-encoder
src/main/java/net/sourceforge/javaflacencoder/FLACEncoder.java
FLACEncoder.addSamples
public void addSamples(int[] samples, int count) { assert(count*streamConfig.getChannelCount() <= samples.length); if(samples.length < count*streamConfig.getChannelCount()) throw new IllegalArgumentException("count given exceeds samples array bounds"); sampleLock.lock(); try { //get number of channels int channels = streamConfig.getChannelCount(); int maxBlock = streamConfig.getMaxBlockSize(); if(unfilledRequest == null) unfilledRequest = prepareRequest(maxBlock,channels); int remaining = count; int offset = 0; while(remaining > 0) { int newRemaining = unfilledRequest.addInterleavedSamples(samples, offset, remaining, maxBlock); offset += (remaining-newRemaining)*channels; remaining = newRemaining; if(unfilledRequest.isFull(maxBlock)) { this.preparedRequests.add(unfilledRequest); unfilledRequest = null; } if(remaining > 0) { unfilledRequest = prepareRequest(maxBlock, channels); } } }finally { sampleLock.unlock(); } }
java
public void addSamples(int[] samples, int count) { assert(count*streamConfig.getChannelCount() <= samples.length); if(samples.length < count*streamConfig.getChannelCount()) throw new IllegalArgumentException("count given exceeds samples array bounds"); sampleLock.lock(); try { //get number of channels int channels = streamConfig.getChannelCount(); int maxBlock = streamConfig.getMaxBlockSize(); if(unfilledRequest == null) unfilledRequest = prepareRequest(maxBlock,channels); int remaining = count; int offset = 0; while(remaining > 0) { int newRemaining = unfilledRequest.addInterleavedSamples(samples, offset, remaining, maxBlock); offset += (remaining-newRemaining)*channels; remaining = newRemaining; if(unfilledRequest.isFull(maxBlock)) { this.preparedRequests.add(unfilledRequest); unfilledRequest = null; } if(remaining > 0) { unfilledRequest = prepareRequest(maxBlock, channels); } } }finally { sampleLock.unlock(); } }
[ "public", "void", "addSamples", "(", "int", "[", "]", "samples", ",", "int", "count", ")", "{", "assert", "(", "count", "*", "streamConfig", ".", "getChannelCount", "(", ")", "<=", "samples", ".", "length", ")", ";", "if", "(", "samples", ".", "length", "<", "count", "*", "streamConfig", ".", "getChannelCount", "(", ")", ")", "throw", "new", "IllegalArgumentException", "(", "\"count given exceeds samples array bounds\"", ")", ";", "sampleLock", ".", "lock", "(", ")", ";", "try", "{", "//get number of channels", "int", "channels", "=", "streamConfig", ".", "getChannelCount", "(", ")", ";", "int", "maxBlock", "=", "streamConfig", ".", "getMaxBlockSize", "(", ")", ";", "if", "(", "unfilledRequest", "==", "null", ")", "unfilledRequest", "=", "prepareRequest", "(", "maxBlock", ",", "channels", ")", ";", "int", "remaining", "=", "count", ";", "int", "offset", "=", "0", ";", "while", "(", "remaining", ">", "0", ")", "{", "int", "newRemaining", "=", "unfilledRequest", ".", "addInterleavedSamples", "(", "samples", ",", "offset", ",", "remaining", ",", "maxBlock", ")", ";", "offset", "+=", "(", "remaining", "-", "newRemaining", ")", "*", "channels", ";", "remaining", "=", "newRemaining", ";", "if", "(", "unfilledRequest", ".", "isFull", "(", "maxBlock", ")", ")", "{", "this", ".", "preparedRequests", ".", "add", "(", "unfilledRequest", ")", ";", "unfilledRequest", "=", "null", ";", "}", "if", "(", "remaining", ">", "0", ")", "{", "unfilledRequest", "=", "prepareRequest", "(", "maxBlock", ",", "channels", ")", ";", "}", "}", "}", "finally", "{", "sampleLock", ".", "unlock", "(", ")", ";", "}", "}" ]
Add samples to the encoder, so they may then be encoded. This method uses breaks the samples into blocks, which will then be made available to encode. @param samples Array holding the samples to encode. For all multi-channel audio, the samples must be interleaved in this array. For example, with stereo: sample 0 will belong to the first channel, 1 the second, 2 the first, 3 the second, etc. Samples are interpreted according to the current configuration(for things such as channel and bits-per-sample). @param count Number of interchannel samples to add. For example, with stero: if this is 4000, then "samples" must contain 4000 left samples and 4000 right samples, interleaved in the array.
[ "Add", "samples", "to", "the", "encoder", "so", "they", "may", "then", "be", "encoded", ".", "This", "method", "uses", "breaks", "the", "samples", "into", "blocks", "which", "will", "then", "be", "made", "available", "to", "encode", "." ]
3d536b877dee2a3fd4ab2e0d9569e292cae93bc9
https://github.com/amplexus/java-flac-encoder/blob/3d536b877dee2a3fd4ab2e0d9569e292cae93bc9/src/main/java/net/sourceforge/javaflacencoder/FLACEncoder.java#L386-L414
10,007
amplexus/java-flac-encoder
src/main/java/net/sourceforge/javaflacencoder/FLACEncoder.java
FLACEncoder.checkForThreadErrors
private void checkForThreadErrors() throws IOException { if(error == true && childException != null) { error = false; IOException temp = childException; childException = null; throw temp; } }
java
private void checkForThreadErrors() throws IOException { if(error == true && childException != null) { error = false; IOException temp = childException; childException = null; throw temp; } }
[ "private", "void", "checkForThreadErrors", "(", ")", "throws", "IOException", "{", "if", "(", "error", "==", "true", "&&", "childException", "!=", "null", ")", "{", "error", "=", "false", ";", "IOException", "temp", "=", "childException", ";", "childException", "=", "null", ";", "throw", "temp", ";", "}", "}" ]
Attempts to throw a stored exception that had been caught from a child thread. This method should be called regularly in any public method to let the calling thread know a problem occured. @throws IOException
[ "Attempts", "to", "throw", "a", "stored", "exception", "that", "had", "been", "caught", "from", "a", "child", "thread", ".", "This", "method", "should", "be", "called", "regularly", "in", "any", "public", "method", "to", "let", "the", "calling", "thread", "know", "a", "problem", "occured", "." ]
3d536b877dee2a3fd4ab2e0d9569e292cae93bc9
https://github.com/amplexus/java-flac-encoder/blob/3d536b877dee2a3fd4ab2e0d9569e292cae93bc9/src/main/java/net/sourceforge/javaflacencoder/FLACEncoder.java#L464-L471
10,008
amplexus/java-flac-encoder
src/main/java/net/sourceforge/javaflacencoder/FLACEncoder.java
FLACEncoder.encodeSamples
public int encodeSamples(int count, final boolean end) throws IOException { int encodedCount = 0; streamLock.lock(); try { checkForThreadErrors(); int channels = streamConfig.getChannelCount(); boolean encodeError = false; while(count > 0 && preparedRequests.size() > 0 && !encodeError) { BlockEncodeRequest ber = preparedRequests.peek(); int encodedSamples = encodeRequest(ber,channels); if(encodedSamples < 0) { //ERROR! Return immediately. Do not add results to output. System.err.println("FLACEncoder::encodeSamples : Error in encoding"); encodeError = true; break; } preparedRequests.poll();//pop top off now that we've written. encodedCount += encodedSamples; count -= encodedSamples; } //handle "end" setting if(end) { if(threadManager != null) threadManager.stop(); //if(end && !encodeError && this.samplesAvailableToEncode() >= count) { if(count > 0 && unfilledRequest != null && unfilledRequest.count >= count) { //handle remaining count BlockEncodeRequest ber = unfilledRequest; int encodedSamples = encodeRequest(ber,channels); if(encodedSamples < 0) { //ERROR! Return immediately. Do not add results to output. System.err.println("FLACEncoder::encodeSamples : (end)Error in encoding"); count = -1; } else { count -= encodedSamples; encodedCount += encodedSamples; unfilledRequest = null; } } if(count <= 0) {//close stream if all requested were written. closeFLACStream(); } } else if (end == true) { if(DEBUG_LEV > 30) System.err.println("End set but not done. Error possible. "+ "This can also happen if number of samples requested to " + "encode exeeds available samples"); } }finally { streamLock.unlock(); } return encodedCount; }
java
public int encodeSamples(int count, final boolean end) throws IOException { int encodedCount = 0; streamLock.lock(); try { checkForThreadErrors(); int channels = streamConfig.getChannelCount(); boolean encodeError = false; while(count > 0 && preparedRequests.size() > 0 && !encodeError) { BlockEncodeRequest ber = preparedRequests.peek(); int encodedSamples = encodeRequest(ber,channels); if(encodedSamples < 0) { //ERROR! Return immediately. Do not add results to output. System.err.println("FLACEncoder::encodeSamples : Error in encoding"); encodeError = true; break; } preparedRequests.poll();//pop top off now that we've written. encodedCount += encodedSamples; count -= encodedSamples; } //handle "end" setting if(end) { if(threadManager != null) threadManager.stop(); //if(end && !encodeError && this.samplesAvailableToEncode() >= count) { if(count > 0 && unfilledRequest != null && unfilledRequest.count >= count) { //handle remaining count BlockEncodeRequest ber = unfilledRequest; int encodedSamples = encodeRequest(ber,channels); if(encodedSamples < 0) { //ERROR! Return immediately. Do not add results to output. System.err.println("FLACEncoder::encodeSamples : (end)Error in encoding"); count = -1; } else { count -= encodedSamples; encodedCount += encodedSamples; unfilledRequest = null; } } if(count <= 0) {//close stream if all requested were written. closeFLACStream(); } } else if (end == true) { if(DEBUG_LEV > 30) System.err.println("End set but not done. Error possible. "+ "This can also happen if number of samples requested to " + "encode exeeds available samples"); } }finally { streamLock.unlock(); } return encodedCount; }
[ "public", "int", "encodeSamples", "(", "int", "count", ",", "final", "boolean", "end", ")", "throws", "IOException", "{", "int", "encodedCount", "=", "0", ";", "streamLock", ".", "lock", "(", ")", ";", "try", "{", "checkForThreadErrors", "(", ")", ";", "int", "channels", "=", "streamConfig", ".", "getChannelCount", "(", ")", ";", "boolean", "encodeError", "=", "false", ";", "while", "(", "count", ">", "0", "&&", "preparedRequests", ".", "size", "(", ")", ">", "0", "&&", "!", "encodeError", ")", "{", "BlockEncodeRequest", "ber", "=", "preparedRequests", ".", "peek", "(", ")", ";", "int", "encodedSamples", "=", "encodeRequest", "(", "ber", ",", "channels", ")", ";", "if", "(", "encodedSamples", "<", "0", ")", "{", "//ERROR! Return immediately. Do not add results to output.", "System", ".", "err", ".", "println", "(", "\"FLACEncoder::encodeSamples : Error in encoding\"", ")", ";", "encodeError", "=", "true", ";", "break", ";", "}", "preparedRequests", ".", "poll", "(", ")", ";", "//pop top off now that we've written.", "encodedCount", "+=", "encodedSamples", ";", "count", "-=", "encodedSamples", ";", "}", "//handle \"end\" setting", "if", "(", "end", ")", "{", "if", "(", "threadManager", "!=", "null", ")", "threadManager", ".", "stop", "(", ")", ";", "//if(end && !encodeError && this.samplesAvailableToEncode() >= count) {", "if", "(", "count", ">", "0", "&&", "unfilledRequest", "!=", "null", "&&", "unfilledRequest", ".", "count", ">=", "count", ")", "{", "//handle remaining count", "BlockEncodeRequest", "ber", "=", "unfilledRequest", ";", "int", "encodedSamples", "=", "encodeRequest", "(", "ber", ",", "channels", ")", ";", "if", "(", "encodedSamples", "<", "0", ")", "{", "//ERROR! Return immediately. Do not add results to output.", "System", ".", "err", ".", "println", "(", "\"FLACEncoder::encodeSamples : (end)Error in encoding\"", ")", ";", "count", "=", "-", "1", ";", "}", "else", "{", "count", "-=", "encodedSamples", ";", "encodedCount", "+=", "encodedSamples", ";", "unfilledRequest", "=", "null", ";", "}", "}", "if", "(", "count", "<=", "0", ")", "{", "//close stream if all requested were written.", "closeFLACStream", "(", ")", ";", "}", "}", "else", "if", "(", "end", "==", "true", ")", "{", "if", "(", "DEBUG_LEV", ">", "30", ")", "System", ".", "err", ".", "println", "(", "\"End set but not done. Error possible. \"", "+", "\"This can also happen if number of samples requested to \"", "+", "\"encode exeeds available samples\"", ")", ";", "}", "}", "finally", "{", "streamLock", ".", "unlock", "(", ")", ";", "}", "return", "encodedCount", ";", "}" ]
Attempt to Encode a certain number of samples. Encodes as close to count as possible. @param count number of samples to attempt to encode. Actual number encoded may be greater or less if count does not end on a block boundary. @param end true to finalize stream after encode, false otherwise. If set to true, and return value is greater than or equal to given count, no more encoding must be attempted until a new stream is began. @return number of samples encoded. This may be greater or less than requested count if count does not end on a block boundary. This is NOT an error condition. If end was set "true", and returned count is less than requested count, then end was NOT done, if you still wish to end stream, call this again with end true and a count of of &le; samplesAvailableToEncode() @throws IOException if there was an error writing the results to file.
[ "Attempt", "to", "Encode", "a", "certain", "number", "of", "samples", ".", "Encodes", "as", "close", "to", "count", "as", "possible", "." ]
3d536b877dee2a3fd4ab2e0d9569e292cae93bc9
https://github.com/amplexus/java-flac-encoder/blob/3d536b877dee2a3fd4ab2e0d9569e292cae93bc9/src/main/java/net/sourceforge/javaflacencoder/FLACEncoder.java#L575-L629
10,009
amplexus/java-flac-encoder
src/main/java/net/sourceforge/javaflacencoder/FLACEncoder.java
FLACEncoder.setOutputStream
public void setOutputStream(FLACOutputStream fos) { if(fos == null) throw new IllegalArgumentException("FLACOutputStream fos must not be null."); if(flacWriter == null) flacWriter = new FLACStreamController(fos,streamConfig); else flacWriter.setFLACOutputStream(fos); }
java
public void setOutputStream(FLACOutputStream fos) { if(fos == null) throw new IllegalArgumentException("FLACOutputStream fos must not be null."); if(flacWriter == null) flacWriter = new FLACStreamController(fos,streamConfig); else flacWriter.setFLACOutputStream(fos); }
[ "public", "void", "setOutputStream", "(", "FLACOutputStream", "fos", ")", "{", "if", "(", "fos", "==", "null", ")", "throw", "new", "IllegalArgumentException", "(", "\"FLACOutputStream fos must not be null.\"", ")", ";", "if", "(", "flacWriter", "==", "null", ")", "flacWriter", "=", "new", "FLACStreamController", "(", "fos", ",", "streamConfig", ")", ";", "else", "flacWriter", ".", "setFLACOutputStream", "(", "fos", ")", ";", "}" ]
Set the output stream to use. This must not be called while an encode process is active, or a flac stream is already opened. @param fos output stream to use. This must not be null.
[ "Set", "the", "output", "stream", "to", "use", ".", "This", "must", "not", "be", "called", "while", "an", "encode", "process", "is", "active", "or", "a", "flac", "stream", "is", "already", "opened", "." ]
3d536b877dee2a3fd4ab2e0d9569e292cae93bc9
https://github.com/amplexus/java-flac-encoder/blob/3d536b877dee2a3fd4ab2e0d9569e292cae93bc9/src/main/java/net/sourceforge/javaflacencoder/FLACEncoder.java#L688-L695
10,010
amplexus/java-flac-encoder
src/main/java/net/sourceforge/javaflacencoder/FLAC_FileEncoder.java
FLAC_FileEncoder.encode
public Status encode(File inputFile, File outputFile) { Status status = Status.FULL_ENCODE; this.outFile = outputFile; //take file and initial configuration. //open file AudioInputStream sin = null; AudioFormat format = null; try { sin = AudioSystem.getAudioInputStream(inputFile); }catch(IOException e) { status = Status.FILE_IO_ERROR; }catch (UnsupportedAudioFileException e) { status = Status.UNSUPPORTED_FILE; }finally { if(status != Status.FULL_ENCODE) { try { sin.close(); }catch (IOException e) { //Nothing to do, close failed } return status; } } try { format = sin.getFormat(); //sanitize and optimize configurations adjustConfigurations(format); //open stream openStream(); AudioStreamEncoder.encodeAudioInputStream(sin, MAX_READ, flac, useThreads); } catch(IOException e) { status = Status.FILE_IO_ERROR; } catch(IllegalArgumentException e) { status = Status.GENERAL_ERROR; String message = e.getMessage(); if(message.equals(Status.UNSUPPORTED_SAMPLE_SIZE.name())) status = Status.UNSUPPORTED_SAMPLE_SIZE; else throw e; } finally { try { sin.close(); }catch (IOException e) { //Nothing to do, close failed } } return status; }
java
public Status encode(File inputFile, File outputFile) { Status status = Status.FULL_ENCODE; this.outFile = outputFile; //take file and initial configuration. //open file AudioInputStream sin = null; AudioFormat format = null; try { sin = AudioSystem.getAudioInputStream(inputFile); }catch(IOException e) { status = Status.FILE_IO_ERROR; }catch (UnsupportedAudioFileException e) { status = Status.UNSUPPORTED_FILE; }finally { if(status != Status.FULL_ENCODE) { try { sin.close(); }catch (IOException e) { //Nothing to do, close failed } return status; } } try { format = sin.getFormat(); //sanitize and optimize configurations adjustConfigurations(format); //open stream openStream(); AudioStreamEncoder.encodeAudioInputStream(sin, MAX_READ, flac, useThreads); } catch(IOException e) { status = Status.FILE_IO_ERROR; } catch(IllegalArgumentException e) { status = Status.GENERAL_ERROR; String message = e.getMessage(); if(message.equals(Status.UNSUPPORTED_SAMPLE_SIZE.name())) status = Status.UNSUPPORTED_SAMPLE_SIZE; else throw e; } finally { try { sin.close(); }catch (IOException e) { //Nothing to do, close failed } } return status; }
[ "public", "Status", "encode", "(", "File", "inputFile", ",", "File", "outputFile", ")", "{", "Status", "status", "=", "Status", ".", "FULL_ENCODE", ";", "this", ".", "outFile", "=", "outputFile", ";", "//take file and initial configuration.", "//open file", "AudioInputStream", "sin", "=", "null", ";", "AudioFormat", "format", "=", "null", ";", "try", "{", "sin", "=", "AudioSystem", ".", "getAudioInputStream", "(", "inputFile", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "status", "=", "Status", ".", "FILE_IO_ERROR", ";", "}", "catch", "(", "UnsupportedAudioFileException", "e", ")", "{", "status", "=", "Status", ".", "UNSUPPORTED_FILE", ";", "}", "finally", "{", "if", "(", "status", "!=", "Status", ".", "FULL_ENCODE", ")", "{", "try", "{", "sin", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "//Nothing to do, close failed", "}", "return", "status", ";", "}", "}", "try", "{", "format", "=", "sin", ".", "getFormat", "(", ")", ";", "//sanitize and optimize configurations", "adjustConfigurations", "(", "format", ")", ";", "//open stream", "openStream", "(", ")", ";", "AudioStreamEncoder", ".", "encodeAudioInputStream", "(", "sin", ",", "MAX_READ", ",", "flac", ",", "useThreads", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "status", "=", "Status", ".", "FILE_IO_ERROR", ";", "}", "catch", "(", "IllegalArgumentException", "e", ")", "{", "status", "=", "Status", ".", "GENERAL_ERROR", ";", "String", "message", "=", "e", ".", "getMessage", "(", ")", ";", "if", "(", "message", ".", "equals", "(", "Status", ".", "UNSUPPORTED_SAMPLE_SIZE", ".", "name", "(", ")", ")", ")", "status", "=", "Status", ".", "UNSUPPORTED_SAMPLE_SIZE", ";", "else", "throw", "e", ";", "}", "finally", "{", "try", "{", "sin", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "//Nothing to do, close failed", "}", "}", "return", "status", ";", "}" ]
Encode the given input wav file to an output file. @param inputFile Input wav file to encode. @param outputFile Output file to write FLAC stream to. If file exists, it will be overwritten without prompting. @return Status flag for encode
[ "Encode", "the", "given", "input", "wav", "file", "to", "an", "output", "file", "." ]
3d536b877dee2a3fd4ab2e0d9569e292cae93bc9
https://github.com/amplexus/java-flac-encoder/blob/3d536b877dee2a3fd4ab2e0d9569e292cae93bc9/src/main/java/net/sourceforge/javaflacencoder/FLAC_FileEncoder.java#L155-L207
10,011
mojohaus/clirr-maven-plugin
src/main/java/org/codehaus/mojo/clirr/ClirrReportGenerator.java
ClirrReportGenerator.createNullObject
private Difference createNullObject() { Difference difference = new Difference(); difference.setClassName(""); difference.setMethod(""); difference.setField(""); difference.setFrom(""); difference.setTo(""); difference.setJustification( bundle.getString( "report.clirr.api.changes.unjustified" ) ); return difference; }
java
private Difference createNullObject() { Difference difference = new Difference(); difference.setClassName(""); difference.setMethod(""); difference.setField(""); difference.setFrom(""); difference.setTo(""); difference.setJustification( bundle.getString( "report.clirr.api.changes.unjustified" ) ); return difference; }
[ "private", "Difference", "createNullObject", "(", ")", "{", "Difference", "difference", "=", "new", "Difference", "(", ")", ";", "difference", ".", "setClassName", "(", "\"\"", ")", ";", "difference", ".", "setMethod", "(", "\"\"", ")", ";", "difference", ".", "setField", "(", "\"\"", ")", ";", "difference", ".", "setFrom", "(", "\"\"", ")", ";", "difference", ".", "setTo", "(", "\"\"", ")", ";", "difference", ".", "setJustification", "(", "bundle", ".", "getString", "(", "\"report.clirr.api.changes.unjustified\"", ")", ")", ";", "return", "difference", ";", "}" ]
Use a null object to avoid doing null checks everywhere.
[ "Use", "a", "null", "object", "to", "avoid", "doing", "null", "checks", "everywhere", "." ]
4348dc31ee003097fa352b1cc3a607dda502bb4c
https://github.com/mojohaus/clirr-maven-plugin/blob/4348dc31ee003097fa352b1cc3a607dda502bb4c/src/main/java/org/codehaus/mojo/clirr/ClirrReportGenerator.java#L530-L540
10,012
mojohaus/clirr-maven-plugin
src/main/java/org/codehaus/mojo/clirr/Difference.java
Difference.matches4000
private boolean matches4000( ApiDifference apiDiff ) { throwIfMissing( false, false, false, true ); String newIface = getArgs( apiDiff )[0]; newIface = newIface.replace( '.', '/' ); return SelectorUtils.matchPath( to, newIface, "/", true ); }
java
private boolean matches4000( ApiDifference apiDiff ) { throwIfMissing( false, false, false, true ); String newIface = getArgs( apiDiff )[0]; newIface = newIface.replace( '.', '/' ); return SelectorUtils.matchPath( to, newIface, "/", true ); }
[ "private", "boolean", "matches4000", "(", "ApiDifference", "apiDiff", ")", "{", "throwIfMissing", "(", "false", ",", "false", ",", "false", ",", "true", ")", ";", "String", "newIface", "=", "getArgs", "(", "apiDiff", ")", "[", "0", "]", ";", "newIface", "=", "newIface", ".", "replace", "(", "'", "'", ",", "'", "'", ")", ";", "return", "SelectorUtils", ".", "matchPath", "(", "to", ",", "newIface", ",", "\"/\"", ",", "true", ")", ";", "}" ]
Added interface to the set of implemented interfaces
[ "Added", "interface", "to", "the", "set", "of", "implemented", "interfaces" ]
4348dc31ee003097fa352b1cc3a607dda502bb4c
https://github.com/mojohaus/clirr-maven-plugin/blob/4348dc31ee003097fa352b1cc3a607dda502bb4c/src/main/java/org/codehaus/mojo/clirr/Difference.java#L482-L490
10,013
mojohaus/clirr-maven-plugin
src/main/java/org/codehaus/mojo/clirr/Difference.java
Difference.matches4001
private boolean matches4001( ApiDifference apiDiff ) { throwIfMissing( false, false, false, true ); String removedIface = getArgs( apiDiff )[0]; removedIface = removedIface.replace( '.', '/' ); return SelectorUtils.matchPath( to, removedIface, "/", true ); }
java
private boolean matches4001( ApiDifference apiDiff ) { throwIfMissing( false, false, false, true ); String removedIface = getArgs( apiDiff )[0]; removedIface = removedIface.replace( '.', '/' ); return SelectorUtils.matchPath( to, removedIface, "/", true ); }
[ "private", "boolean", "matches4001", "(", "ApiDifference", "apiDiff", ")", "{", "throwIfMissing", "(", "false", ",", "false", ",", "false", ",", "true", ")", ";", "String", "removedIface", "=", "getArgs", "(", "apiDiff", ")", "[", "0", "]", ";", "removedIface", "=", "removedIface", ".", "replace", "(", "'", "'", ",", "'", "'", ")", ";", "return", "SelectorUtils", ".", "matchPath", "(", "to", ",", "removedIface", ",", "\"/\"", ",", "true", ")", ";", "}" ]
Removed interface from the set of implemented interfaces
[ "Removed", "interface", "from", "the", "set", "of", "implemented", "interfaces" ]
4348dc31ee003097fa352b1cc3a607dda502bb4c
https://github.com/mojohaus/clirr-maven-plugin/blob/4348dc31ee003097fa352b1cc3a607dda502bb4c/src/main/java/org/codehaus/mojo/clirr/Difference.java#L495-L503
10,014
mojohaus/clirr-maven-plugin
src/main/java/org/codehaus/mojo/clirr/Difference.java
Difference.matches5000
private boolean matches5000( ApiDifference apiDiff ) { throwIfMissing( false, false, false, true ); String newSuperclass = getArgs( apiDiff )[0]; newSuperclass = newSuperclass.replace( '.', '/' ); return SelectorUtils.matchPath( to, newSuperclass, "/", true ); }
java
private boolean matches5000( ApiDifference apiDiff ) { throwIfMissing( false, false, false, true ); String newSuperclass = getArgs( apiDiff )[0]; newSuperclass = newSuperclass.replace( '.', '/' ); return SelectorUtils.matchPath( to, newSuperclass, "/", true ); }
[ "private", "boolean", "matches5000", "(", "ApiDifference", "apiDiff", ")", "{", "throwIfMissing", "(", "false", ",", "false", ",", "false", ",", "true", ")", ";", "String", "newSuperclass", "=", "getArgs", "(", "apiDiff", ")", "[", "0", "]", ";", "newSuperclass", "=", "newSuperclass", ".", "replace", "(", "'", "'", ",", "'", "'", ")", ";", "return", "SelectorUtils", ".", "matchPath", "(", "to", ",", "newSuperclass", ",", "\"/\"", ",", "true", ")", ";", "}" ]
Added class to the set of superclasses
[ "Added", "class", "to", "the", "set", "of", "superclasses" ]
4348dc31ee003097fa352b1cc3a607dda502bb4c
https://github.com/mojohaus/clirr-maven-plugin/blob/4348dc31ee003097fa352b1cc3a607dda502bb4c/src/main/java/org/codehaus/mojo/clirr/Difference.java#L508-L516
10,015
mojohaus/clirr-maven-plugin
src/main/java/org/codehaus/mojo/clirr/Difference.java
Difference.matches5001
private boolean matches5001( ApiDifference apiDiff ) { throwIfMissing( false, false, false, true ); String removedSuperclass = getArgs( apiDiff )[0]; removedSuperclass = removedSuperclass.replace( '.', '/' ); return SelectorUtils.matchPath( to, removedSuperclass, "/", true ); }
java
private boolean matches5001( ApiDifference apiDiff ) { throwIfMissing( false, false, false, true ); String removedSuperclass = getArgs( apiDiff )[0]; removedSuperclass = removedSuperclass.replace( '.', '/' ); return SelectorUtils.matchPath( to, removedSuperclass, "/", true ); }
[ "private", "boolean", "matches5001", "(", "ApiDifference", "apiDiff", ")", "{", "throwIfMissing", "(", "false", ",", "false", ",", "false", ",", "true", ")", ";", "String", "removedSuperclass", "=", "getArgs", "(", "apiDiff", ")", "[", "0", "]", ";", "removedSuperclass", "=", "removedSuperclass", ".", "replace", "(", "'", "'", ",", "'", "'", ")", ";", "return", "SelectorUtils", ".", "matchPath", "(", "to", ",", "removedSuperclass", ",", "\"/\"", ",", "true", ")", ";", "}" ]
Removed class from the set of superclasses
[ "Removed", "class", "from", "the", "set", "of", "superclasses" ]
4348dc31ee003097fa352b1cc3a607dda502bb4c
https://github.com/mojohaus/clirr-maven-plugin/blob/4348dc31ee003097fa352b1cc3a607dda502bb4c/src/main/java/org/codehaus/mojo/clirr/Difference.java#L521-L529
10,016
mojohaus/clirr-maven-plugin
src/main/java/org/codehaus/mojo/clirr/Difference.java
Difference.matches6004
private boolean matches6004( ApiDifference apiDiff ) { throwIfMissing( true, false, true, true ); if ( !SelectorUtils.matchPath( field, apiDiff.getAffectedField() ) ) { return false; } String[] args = getArgs( apiDiff ); String diffFrom = args[0]; String diffTo = args[1]; return SelectorUtils.matchPath( from, diffFrom ) && SelectorUtils.matchPath( to, diffTo ); }
java
private boolean matches6004( ApiDifference apiDiff ) { throwIfMissing( true, false, true, true ); if ( !SelectorUtils.matchPath( field, apiDiff.getAffectedField() ) ) { return false; } String[] args = getArgs( apiDiff ); String diffFrom = args[0]; String diffTo = args[1]; return SelectorUtils.matchPath( from, diffFrom ) && SelectorUtils.matchPath( to, diffTo ); }
[ "private", "boolean", "matches6004", "(", "ApiDifference", "apiDiff", ")", "{", "throwIfMissing", "(", "true", ",", "false", ",", "true", ",", "true", ")", ";", "if", "(", "!", "SelectorUtils", ".", "matchPath", "(", "field", ",", "apiDiff", ".", "getAffectedField", "(", ")", ")", ")", "{", "return", "false", ";", "}", "String", "[", "]", "args", "=", "getArgs", "(", "apiDiff", ")", ";", "String", "diffFrom", "=", "args", "[", "0", "]", ";", "String", "diffTo", "=", "args", "[", "1", "]", ";", "return", "SelectorUtils", ".", "matchPath", "(", "from", ",", "diffFrom", ")", "&&", "SelectorUtils", ".", "matchPath", "(", "to", ",", "diffTo", ")", ";", "}" ]
field type changed
[ "field", "type", "changed" ]
4348dc31ee003097fa352b1cc3a607dda502bb4c
https://github.com/mojohaus/clirr-maven-plugin/blob/4348dc31ee003097fa352b1cc3a607dda502bb4c/src/main/java/org/codehaus/mojo/clirr/Difference.java#L570-L584
10,017
mojohaus/clirr-maven-plugin
src/main/java/org/codehaus/mojo/clirr/Difference.java
Difference.matches7000
private boolean matches7000( ApiDifference apiDiff ) { throwIfMissing( false, true, false, false ); return SelectorUtils.matchPath( method, removeVisibilityFromMethodSignature( apiDiff ) ); }
java
private boolean matches7000( ApiDifference apiDiff ) { throwIfMissing( false, true, false, false ); return SelectorUtils.matchPath( method, removeVisibilityFromMethodSignature( apiDiff ) ); }
[ "private", "boolean", "matches7000", "(", "ApiDifference", "apiDiff", ")", "{", "throwIfMissing", "(", "false", ",", "true", ",", "false", ",", "false", ")", ";", "return", "SelectorUtils", ".", "matchPath", "(", "method", ",", "removeVisibilityFromMethodSignature", "(", "apiDiff", ")", ")", ";", "}" ]
method now in superclass
[ "method", "now", "in", "superclass" ]
4348dc31ee003097fa352b1cc3a607dda502bb4c
https://github.com/mojohaus/clirr-maven-plugin/blob/4348dc31ee003097fa352b1cc3a607dda502bb4c/src/main/java/org/codehaus/mojo/clirr/Difference.java#L652-L656
10,018
mojohaus/clirr-maven-plugin
src/main/java/org/codehaus/mojo/clirr/Difference.java
Difference.matches7005
private boolean matches7005( List<ApiDifference> apiDiffs ) { throwIfMissing( false, true, false, true ); ApiDifference firstDiff = apiDiffs.get( 0 ); String methodSig = removeVisibilityFromMethodSignature( firstDiff ); if ( !SelectorUtils.matchPath( method, methodSig ) ) { return false; } String newMethodSig = getNewMethodSignature( methodSig, apiDiffs ); return SelectorUtils.matchPath( to, newMethodSig ); }
java
private boolean matches7005( List<ApiDifference> apiDiffs ) { throwIfMissing( false, true, false, true ); ApiDifference firstDiff = apiDiffs.get( 0 ); String methodSig = removeVisibilityFromMethodSignature( firstDiff ); if ( !SelectorUtils.matchPath( method, methodSig ) ) { return false; } String newMethodSig = getNewMethodSignature( methodSig, apiDiffs ); return SelectorUtils.matchPath( to, newMethodSig ); }
[ "private", "boolean", "matches7005", "(", "List", "<", "ApiDifference", ">", "apiDiffs", ")", "{", "throwIfMissing", "(", "false", ",", "true", ",", "false", ",", "true", ")", ";", "ApiDifference", "firstDiff", "=", "apiDiffs", ".", "get", "(", "0", ")", ";", "String", "methodSig", "=", "removeVisibilityFromMethodSignature", "(", "firstDiff", ")", ";", "if", "(", "!", "SelectorUtils", ".", "matchPath", "(", "method", ",", "methodSig", ")", ")", "{", "return", "false", ";", "}", "String", "newMethodSig", "=", "getNewMethodSignature", "(", "methodSig", ",", "apiDiffs", ")", ";", "return", "SelectorUtils", ".", "matchPath", "(", "to", ",", "newMethodSig", ")", ";", "}" ]
Method Argument Type changed
[ "Method", "Argument", "Type", "changed" ]
4348dc31ee003097fa352b1cc3a607dda502bb4c
https://github.com/mojohaus/clirr-maven-plugin/blob/4348dc31ee003097fa352b1cc3a607dda502bb4c/src/main/java/org/codehaus/mojo/clirr/Difference.java#L702-L715
10,019
mojohaus/clirr-maven-plugin
src/main/java/org/codehaus/mojo/clirr/Difference.java
Difference.matches7006
private boolean matches7006( ApiDifference apiDiff ) { throwIfMissing( false, true, false, true ); String methodSig = removeVisibilityFromMethodSignature( apiDiff ); if ( !SelectorUtils.matchPath( method, methodSig ) ) { return false; } String newRetType = getArgs( apiDiff )[0]; return SelectorUtils.matchPath( to, newRetType ); }
java
private boolean matches7006( ApiDifference apiDiff ) { throwIfMissing( false, true, false, true ); String methodSig = removeVisibilityFromMethodSignature( apiDiff ); if ( !SelectorUtils.matchPath( method, methodSig ) ) { return false; } String newRetType = getArgs( apiDiff )[0]; return SelectorUtils.matchPath( to, newRetType ); }
[ "private", "boolean", "matches7006", "(", "ApiDifference", "apiDiff", ")", "{", "throwIfMissing", "(", "false", ",", "true", ",", "false", ",", "true", ")", ";", "String", "methodSig", "=", "removeVisibilityFromMethodSignature", "(", "apiDiff", ")", ";", "if", "(", "!", "SelectorUtils", ".", "matchPath", "(", "method", ",", "methodSig", ")", ")", "{", "return", "false", ";", "}", "String", "newRetType", "=", "getArgs", "(", "apiDiff", ")", "[", "0", "]", ";", "return", "SelectorUtils", ".", "matchPath", "(", "to", ",", "newRetType", ")", ";", "}" ]
Method Return Type changed
[ "Method", "Return", "Type", "changed" ]
4348dc31ee003097fa352b1cc3a607dda502bb4c
https://github.com/mojohaus/clirr-maven-plugin/blob/4348dc31ee003097fa352b1cc3a607dda502bb4c/src/main/java/org/codehaus/mojo/clirr/Difference.java#L737-L750
10,020
mojohaus/clirr-maven-plugin
src/main/java/org/codehaus/mojo/clirr/Difference.java
Difference.matches10000
private boolean matches10000( ApiDifference apiDiff ) { throwIfMissing( false, false, true, true ); int fromVersion = 0; int toVersion = 0; try { fromVersion = Integer.parseInt( from ); } catch ( NumberFormatException e ) { throw new IllegalArgumentException( "Failed to parse the \"from\" parameter as a number for " + this ); } try { toVersion = Integer.parseInt( to ); } catch ( NumberFormatException e ) { throw new IllegalArgumentException( "Failed to parse the \"to\" parameter as a number for " + this ); } String[] args = getArgs( apiDiff ); int reportedOld = Integer.parseInt( args[0] ); int reportedNew = Integer.parseInt( args[1] ); return fromVersion == reportedOld && toVersion == reportedNew; }
java
private boolean matches10000( ApiDifference apiDiff ) { throwIfMissing( false, false, true, true ); int fromVersion = 0; int toVersion = 0; try { fromVersion = Integer.parseInt( from ); } catch ( NumberFormatException e ) { throw new IllegalArgumentException( "Failed to parse the \"from\" parameter as a number for " + this ); } try { toVersion = Integer.parseInt( to ); } catch ( NumberFormatException e ) { throw new IllegalArgumentException( "Failed to parse the \"to\" parameter as a number for " + this ); } String[] args = getArgs( apiDiff ); int reportedOld = Integer.parseInt( args[0] ); int reportedNew = Integer.parseInt( args[1] ); return fromVersion == reportedOld && toVersion == reportedNew; }
[ "private", "boolean", "matches10000", "(", "ApiDifference", "apiDiff", ")", "{", "throwIfMissing", "(", "false", ",", "false", ",", "true", ",", "true", ")", ";", "int", "fromVersion", "=", "0", ";", "int", "toVersion", "=", "0", ";", "try", "{", "fromVersion", "=", "Integer", ".", "parseInt", "(", "from", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Failed to parse the \\\"from\\\" parameter as a number for \"", "+", "this", ")", ";", "}", "try", "{", "toVersion", "=", "Integer", ".", "parseInt", "(", "to", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Failed to parse the \\\"to\\\" parameter as a number for \"", "+", "this", ")", ";", "}", "String", "[", "]", "args", "=", "getArgs", "(", "apiDiff", ")", ";", "int", "reportedOld", "=", "Integer", ".", "parseInt", "(", "args", "[", "0", "]", ")", ";", "int", "reportedNew", "=", "Integer", ".", "parseInt", "(", "args", "[", "1", "]", ")", ";", "return", "fromVersion", "==", "reportedOld", "&&", "toVersion", "==", "reportedNew", ";", "}" ]
Class format version increased
[ "Class", "format", "version", "increased" ]
4348dc31ee003097fa352b1cc3a607dda502bb4c
https://github.com/mojohaus/clirr-maven-plugin/blob/4348dc31ee003097fa352b1cc3a607dda502bb4c/src/main/java/org/codehaus/mojo/clirr/Difference.java#L836-L866
10,021
Doctoror/Geocoder
library/src/main/java/com/doctoror/geocoder/Geocoder.java
Geocoder.getFromLocation
@NonNull public List<Address> getFromLocation(final double latitude, final double longitude, final int maxResults, final boolean parseAddressComponents) throws GeocoderException { if (latitude < -90.0 || latitude > 90.0) { throw new IllegalArgumentException("latitude == " + latitude); } if (longitude < -180.0 || longitude > 180.0) { throw new IllegalArgumentException("longitude == " + longitude); } if (isLimitExceeded()) { throw GeocoderException.forQueryOverLimit(); } final Uri.Builder uriBuilder = buildBaseRequestUri() .appendQueryParameter("sensor", "true") .appendQueryParameter("latlng", latitude + "," + longitude); final byte[] data; try { data = download(uriBuilder.toString()); } catch (IOException e) { throw new GeocoderException(e); } return Parser.parseJson(data, maxResults, parseAddressComponents); }
java
@NonNull public List<Address> getFromLocation(final double latitude, final double longitude, final int maxResults, final boolean parseAddressComponents) throws GeocoderException { if (latitude < -90.0 || latitude > 90.0) { throw new IllegalArgumentException("latitude == " + latitude); } if (longitude < -180.0 || longitude > 180.0) { throw new IllegalArgumentException("longitude == " + longitude); } if (isLimitExceeded()) { throw GeocoderException.forQueryOverLimit(); } final Uri.Builder uriBuilder = buildBaseRequestUri() .appendQueryParameter("sensor", "true") .appendQueryParameter("latlng", latitude + "," + longitude); final byte[] data; try { data = download(uriBuilder.toString()); } catch (IOException e) { throw new GeocoderException(e); } return Parser.parseJson(data, maxResults, parseAddressComponents); }
[ "@", "NonNull", "public", "List", "<", "Address", ">", "getFromLocation", "(", "final", "double", "latitude", ",", "final", "double", "longitude", ",", "final", "int", "maxResults", ",", "final", "boolean", "parseAddressComponents", ")", "throws", "GeocoderException", "{", "if", "(", "latitude", "<", "-", "90.0", "||", "latitude", ">", "90.0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"latitude == \"", "+", "latitude", ")", ";", "}", "if", "(", "longitude", "<", "-", "180.0", "||", "longitude", ">", "180.0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"longitude == \"", "+", "longitude", ")", ";", "}", "if", "(", "isLimitExceeded", "(", ")", ")", "{", "throw", "GeocoderException", ".", "forQueryOverLimit", "(", ")", ";", "}", "final", "Uri", ".", "Builder", "uriBuilder", "=", "buildBaseRequestUri", "(", ")", ".", "appendQueryParameter", "(", "\"sensor\"", ",", "\"true\"", ")", ".", "appendQueryParameter", "(", "\"latlng\"", ",", "latitude", "+", "\",\"", "+", "longitude", ")", ";", "final", "byte", "[", "]", "data", ";", "try", "{", "data", "=", "download", "(", "uriBuilder", ".", "toString", "(", ")", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "GeocoderException", "(", "e", ")", ";", "}", "return", "Parser", ".", "parseJson", "(", "data", ",", "maxResults", ",", "parseAddressComponents", ")", ";", "}" ]
Returns an array of Addresses that are known to describe the area immediately surrounding the given latitude and longitude. The returned addresses will be localized for the locale provided to this class's constructor. <p> The returned values may be obtained by means of a network lookup. The results are a best guess and are not guaranteed to be meaningful or correct. It may be useful to call this method from a thread separate from your primary UI thread. @param latitude the latitude a point for the search @param longitude the longitude a point for the search @param maxResults max number of addresses to return. Smaller numbers (1 to 5) are recommended @param parseAddressComponents If set to true, will parse "address_components". For more details see documentation provided in the Geocoder class javadoc @return a list of Address objects. Returns empty list if no matches were found. @throws IllegalArgumentException if latitude is less than -90 or greater than 90 @throws IllegalArgumentException if longitude is less than -180 or greater than 180 @throws GeocoderException On Geocoder error, if the network is unavailable or any other I/O problem occurs
[ "Returns", "an", "array", "of", "Addresses", "that", "are", "known", "to", "describe", "the", "area", "immediately", "surrounding", "the", "given", "latitude", "and", "longitude", ".", "The", "returned", "addresses", "will", "be", "localized", "for", "the", "locale", "provided", "to", "this", "class", "s", "constructor", "." ]
c55463266584c7ad79880ffc7869c25e5f9eb006
https://github.com/Doctoror/Geocoder/blob/c55463266584c7ad79880ffc7869c25e5f9eb006/library/src/main/java/com/doctoror/geocoder/Geocoder.java#L141-L168
10,022
Doctoror/Geocoder
library/src/main/java/com/doctoror/geocoder/Geocoder.java
Geocoder.getFromLocationName
@NonNull public List<Address> getFromLocationName(final String locationName, final int maxResults, final boolean parseAddressComponents) throws GeocoderException { if (locationName == null) { throw new IllegalArgumentException("locationName == null"); } if (isLimitExceeded()) { throw GeocoderException.forQueryOverLimit(); } final Uri.Builder uriBuilder = buildBaseRequestUri() .appendQueryParameter("sensor", "false") .appendQueryParameter("address", locationName); final String url = uriBuilder.toString(); byte[] data; try { data = download(url); } catch (IOException e) { throw new GeocoderException(e); } try { return Parser.parseJson(data, maxResults, parseAddressComponents); } catch (GeocoderException e) { if (e.getStatus() == Status.OVER_QUERY_LIMIT) { // OVER_QUERY_LIMIT could be thrown if too many calls per second // If after two seconds, it is thrown again - then it means there are too much calls // per 24 hours try { Thread.sleep(2000); } catch (InterruptedException e1) { // Safely abort when interrupted return new ArrayList<>(); } try { data = download(url); } catch (IOException ioe) { throw new GeocoderException(ioe); } try { return Parser.parseJson(data, maxResults, parseAddressComponents); } catch (GeocoderException e1) { if (e1.getStatus() == Status.OVER_QUERY_LIMIT) { // available in 24 hours setAllowedDate(System.currentTimeMillis() + 86400000L); } throw e1; } } else { throw e; } } }
java
@NonNull public List<Address> getFromLocationName(final String locationName, final int maxResults, final boolean parseAddressComponents) throws GeocoderException { if (locationName == null) { throw new IllegalArgumentException("locationName == null"); } if (isLimitExceeded()) { throw GeocoderException.forQueryOverLimit(); } final Uri.Builder uriBuilder = buildBaseRequestUri() .appendQueryParameter("sensor", "false") .appendQueryParameter("address", locationName); final String url = uriBuilder.toString(); byte[] data; try { data = download(url); } catch (IOException e) { throw new GeocoderException(e); } try { return Parser.parseJson(data, maxResults, parseAddressComponents); } catch (GeocoderException e) { if (e.getStatus() == Status.OVER_QUERY_LIMIT) { // OVER_QUERY_LIMIT could be thrown if too many calls per second // If after two seconds, it is thrown again - then it means there are too much calls // per 24 hours try { Thread.sleep(2000); } catch (InterruptedException e1) { // Safely abort when interrupted return new ArrayList<>(); } try { data = download(url); } catch (IOException ioe) { throw new GeocoderException(ioe); } try { return Parser.parseJson(data, maxResults, parseAddressComponents); } catch (GeocoderException e1) { if (e1.getStatus() == Status.OVER_QUERY_LIMIT) { // available in 24 hours setAllowedDate(System.currentTimeMillis() + 86400000L); } throw e1; } } else { throw e; } } }
[ "@", "NonNull", "public", "List", "<", "Address", ">", "getFromLocationName", "(", "final", "String", "locationName", ",", "final", "int", "maxResults", ",", "final", "boolean", "parseAddressComponents", ")", "throws", "GeocoderException", "{", "if", "(", "locationName", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"locationName == null\"", ")", ";", "}", "if", "(", "isLimitExceeded", "(", ")", ")", "{", "throw", "GeocoderException", ".", "forQueryOverLimit", "(", ")", ";", "}", "final", "Uri", ".", "Builder", "uriBuilder", "=", "buildBaseRequestUri", "(", ")", ".", "appendQueryParameter", "(", "\"sensor\"", ",", "\"false\"", ")", ".", "appendQueryParameter", "(", "\"address\"", ",", "locationName", ")", ";", "final", "String", "url", "=", "uriBuilder", ".", "toString", "(", ")", ";", "byte", "[", "]", "data", ";", "try", "{", "data", "=", "download", "(", "url", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "GeocoderException", "(", "e", ")", ";", "}", "try", "{", "return", "Parser", ".", "parseJson", "(", "data", ",", "maxResults", ",", "parseAddressComponents", ")", ";", "}", "catch", "(", "GeocoderException", "e", ")", "{", "if", "(", "e", ".", "getStatus", "(", ")", "==", "Status", ".", "OVER_QUERY_LIMIT", ")", "{", "// OVER_QUERY_LIMIT could be thrown if too many calls per second", "// If after two seconds, it is thrown again - then it means there are too much calls", "// per 24 hours", "try", "{", "Thread", ".", "sleep", "(", "2000", ")", ";", "}", "catch", "(", "InterruptedException", "e1", ")", "{", "// Safely abort when interrupted", "return", "new", "ArrayList", "<>", "(", ")", ";", "}", "try", "{", "data", "=", "download", "(", "url", ")", ";", "}", "catch", "(", "IOException", "ioe", ")", "{", "throw", "new", "GeocoderException", "(", "ioe", ")", ";", "}", "try", "{", "return", "Parser", ".", "parseJson", "(", "data", ",", "maxResults", ",", "parseAddressComponents", ")", ";", "}", "catch", "(", "GeocoderException", "e1", ")", "{", "if", "(", "e1", ".", "getStatus", "(", ")", "==", "Status", ".", "OVER_QUERY_LIMIT", ")", "{", "// available in 24 hours", "setAllowedDate", "(", "System", ".", "currentTimeMillis", "(", ")", "+", "86400000L", ")", ";", "}", "throw", "e1", ";", "}", "}", "else", "{", "throw", "e", ";", "}", "}", "}" ]
Returns an array of Addresses that are known to describe the named location, which may be a place name such as "Dalvik, Iceland", an address such as "1600 Amphitheatre Parkway, Mountain View, CA", an airport code such as "SFO", etc.. The returned addresses will be localized for the locale provided to this class's constructor. <p> The query will block and returned values will be obtained by means of a network lookup. The results are a best guess and are not guaranteed to be meaningful or correct. It may be useful to call this method from a thread separate from your primary UI thread. @param locationName a user-supplied description of a location @param maxResults max number of results to return. Smaller numbers (1 to 5) are recommended @param parseAddressComponents If set to true, will parse "address_components". For more details see documentation provided in the Geocoder class javadoc @return a list of Address objects. Returns empty list if no matches were found. @throws IllegalArgumentException if locationName is null @throws GeocoderException if parse failed, Geocoder returned error, or if the network is unavailable or any other I/O problem occurs
[ "Returns", "an", "array", "of", "Addresses", "that", "are", "known", "to", "describe", "the", "named", "location", "which", "may", "be", "a", "place", "name", "such", "as", "Dalvik", "Iceland", "an", "address", "such", "as", "1600", "Amphitheatre", "Parkway", "Mountain", "View", "CA", "an", "airport", "code", "such", "as", "SFO", "etc", "..", "The", "returned", "addresses", "will", "be", "localized", "for", "the", "locale", "provided", "to", "this", "class", "s", "constructor", "." ]
c55463266584c7ad79880ffc7869c25e5f9eb006
https://github.com/Doctoror/Geocoder/blob/c55463266584c7ad79880ffc7869c25e5f9eb006/library/src/main/java/com/doctoror/geocoder/Geocoder.java#L194-L251
10,023
Doctoror/Geocoder
library/src/main/java/com/doctoror/geocoder/Geocoder.java
Geocoder.download
@NonNull private static byte[] download(String url) throws IOException { InputStream is = null; ByteArrayOutputStream os = null; try { final URL u = new URL(url); final URLConnection connection = u.openConnection(); connection.connect(); is = connection.getInputStream(); os = new ByteArrayOutputStream(); final byte[] buffer = new byte[4096]; int read; while (true) { read = is.read(buffer, 0, buffer.length); if (read == -1) { break; } os.write(buffer, 0, read); } return os.toByteArray(); } finally { if (is != null) { try { is.close(); } catch (IOException ignored) { } } if (os != null) { try { os.close(); } catch (IOException ignored) { } } } }
java
@NonNull private static byte[] download(String url) throws IOException { InputStream is = null; ByteArrayOutputStream os = null; try { final URL u = new URL(url); final URLConnection connection = u.openConnection(); connection.connect(); is = connection.getInputStream(); os = new ByteArrayOutputStream(); final byte[] buffer = new byte[4096]; int read; while (true) { read = is.read(buffer, 0, buffer.length); if (read == -1) { break; } os.write(buffer, 0, read); } return os.toByteArray(); } finally { if (is != null) { try { is.close(); } catch (IOException ignored) { } } if (os != null) { try { os.close(); } catch (IOException ignored) { } } } }
[ "@", "NonNull", "private", "static", "byte", "[", "]", "download", "(", "String", "url", ")", "throws", "IOException", "{", "InputStream", "is", "=", "null", ";", "ByteArrayOutputStream", "os", "=", "null", ";", "try", "{", "final", "URL", "u", "=", "new", "URL", "(", "url", ")", ";", "final", "URLConnection", "connection", "=", "u", ".", "openConnection", "(", ")", ";", "connection", ".", "connect", "(", ")", ";", "is", "=", "connection", ".", "getInputStream", "(", ")", ";", "os", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "final", "byte", "[", "]", "buffer", "=", "new", "byte", "[", "4096", "]", ";", "int", "read", ";", "while", "(", "true", ")", "{", "read", "=", "is", ".", "read", "(", "buffer", ",", "0", ",", "buffer", ".", "length", ")", ";", "if", "(", "read", "==", "-", "1", ")", "{", "break", ";", "}", "os", ".", "write", "(", "buffer", ",", "0", ",", "read", ")", ";", "}", "return", "os", ".", "toByteArray", "(", ")", ";", "}", "finally", "{", "if", "(", "is", "!=", "null", ")", "{", "try", "{", "is", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "ignored", ")", "{", "}", "}", "if", "(", "os", "!=", "null", ")", "{", "try", "{", "os", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "ignored", ")", "{", "}", "}", "}", "}" ]
Downloads data to buffer @param url Data location @return downloaded data or null if error occurred
[ "Downloads", "data", "to", "buffer" ]
c55463266584c7ad79880ffc7869c25e5f9eb006
https://github.com/Doctoror/Geocoder/blob/c55463266584c7ad79880ffc7869c25e5f9eb006/library/src/main/java/com/doctoror/geocoder/Geocoder.java#L259-L299
10,024
Doctoror/Geocoder
library/src/main/java/com/doctoror/geocoder/Geocoder.java
Geocoder.setAllowedDate
private void setAllowedDate(final long date) { mAllowedDate = date; if (mSharedPreferences == null) { mSharedPreferences = mContext.getSharedPreferences( PREFERENCES_GEOCODER, Context.MODE_PRIVATE); } final Editor e = mSharedPreferences.edit(); e.putLong(KEY_ALLOW, date); e.apply(); }
java
private void setAllowedDate(final long date) { mAllowedDate = date; if (mSharedPreferences == null) { mSharedPreferences = mContext.getSharedPreferences( PREFERENCES_GEOCODER, Context.MODE_PRIVATE); } final Editor e = mSharedPreferences.edit(); e.putLong(KEY_ALLOW, date); e.apply(); }
[ "private", "void", "setAllowedDate", "(", "final", "long", "date", ")", "{", "mAllowedDate", "=", "date", ";", "if", "(", "mSharedPreferences", "==", "null", ")", "{", "mSharedPreferences", "=", "mContext", ".", "getSharedPreferences", "(", "PREFERENCES_GEOCODER", ",", "Context", ".", "MODE_PRIVATE", ")", ";", "}", "final", "Editor", "e", "=", "mSharedPreferences", ".", "edit", "(", ")", ";", "e", ".", "putLong", "(", "KEY_ALLOW", ",", "date", ")", ";", "e", ".", "apply", "(", ")", ";", "}" ]
Sets date after which next geocoding query is allowed @param date the date after which next geocoding query is allowed
[ "Sets", "date", "after", "which", "next", "geocoding", "query", "is", "allowed" ]
c55463266584c7ad79880ffc7869c25e5f9eb006
https://github.com/Doctoror/Geocoder/blob/c55463266584c7ad79880ffc7869c25e5f9eb006/library/src/main/java/com/doctoror/geocoder/Geocoder.java#L316-L325
10,025
Doctoror/Geocoder
library/src/main/java/com/doctoror/geocoder/Geocoder.java
Geocoder.getAllowedDate
private long getAllowedDate() { if (mSharedPreferences == null) { mSharedPreferences = mContext .getSharedPreferences(PREFERENCES_GEOCODER, Context.MODE_PRIVATE); mAllowedDate = mSharedPreferences.getLong(KEY_ALLOW, 0); } return mAllowedDate; }
java
private long getAllowedDate() { if (mSharedPreferences == null) { mSharedPreferences = mContext .getSharedPreferences(PREFERENCES_GEOCODER, Context.MODE_PRIVATE); mAllowedDate = mSharedPreferences.getLong(KEY_ALLOW, 0); } return mAllowedDate; }
[ "private", "long", "getAllowedDate", "(", ")", "{", "if", "(", "mSharedPreferences", "==", "null", ")", "{", "mSharedPreferences", "=", "mContext", ".", "getSharedPreferences", "(", "PREFERENCES_GEOCODER", ",", "Context", ".", "MODE_PRIVATE", ")", ";", "mAllowedDate", "=", "mSharedPreferences", ".", "getLong", "(", "KEY_ALLOW", ",", "0", ")", ";", "}", "return", "mAllowedDate", ";", "}" ]
Returns date after which the next geocoding query is allowed @return date after which the next geocoding query is allowed
[ "Returns", "date", "after", "which", "the", "next", "geocoding", "query", "is", "allowed" ]
c55463266584c7ad79880ffc7869c25e5f9eb006
https://github.com/Doctoror/Geocoder/blob/c55463266584c7ad79880ffc7869c25e5f9eb006/library/src/main/java/com/doctoror/geocoder/Geocoder.java#L332-L339
10,026
Inbot/inbot-utils
src/main/java/io/inbot/utils/IOUtils.java
IOUtils.resource
public static BufferedReader resource(String resourcePath) throws IOException { InputStream is = IOUtils.class.getClassLoader().getResourceAsStream(resourcePath); if(is != null) { return new BufferedReader(new InputStreamReader(is, UTF_8)); } else { File file = new File(resourcePath); if(file.exists()) { return fileReader(file); } else { throw new IllegalArgumentException("resource does not exist " + resourcePath); } } }
java
public static BufferedReader resource(String resourcePath) throws IOException { InputStream is = IOUtils.class.getClassLoader().getResourceAsStream(resourcePath); if(is != null) { return new BufferedReader(new InputStreamReader(is, UTF_8)); } else { File file = new File(resourcePath); if(file.exists()) { return fileReader(file); } else { throw new IllegalArgumentException("resource does not exist " + resourcePath); } } }
[ "public", "static", "BufferedReader", "resource", "(", "String", "resourcePath", ")", "throws", "IOException", "{", "InputStream", "is", "=", "IOUtils", ".", "class", ".", "getClassLoader", "(", ")", ".", "getResourceAsStream", "(", "resourcePath", ")", ";", "if", "(", "is", "!=", "null", ")", "{", "return", "new", "BufferedReader", "(", "new", "InputStreamReader", "(", "is", ",", "UTF_8", ")", ")", ";", "}", "else", "{", "File", "file", "=", "new", "File", "(", "resourcePath", ")", ";", "if", "(", "file", ".", "exists", "(", ")", ")", "{", "return", "fileReader", "(", "file", ")", ";", "}", "else", "{", "throw", "new", "IllegalArgumentException", "(", "\"resource does not exist \"", "+", "resourcePath", ")", ";", "}", "}", "}" ]
Read a resource from the classpath or fallback to treating it as a file. @param resourcePath resource path inside your jar, or a path to an actual file @return BufferedReader @throws IOException if something goes wrong with the stream
[ "Read", "a", "resource", "from", "the", "classpath", "or", "fallback", "to", "treating", "it", "as", "a", "file", "." ]
3112bc08d4237e95fe0f8a219a5bbceb390d0505
https://github.com/Inbot/inbot-utils/blob/3112bc08d4237e95fe0f8a219a5bbceb390d0505/src/main/java/io/inbot/utils/IOUtils.java#L37-L49
10,027
Inbot/inbot-utils
src/main/java/io/inbot/utils/IOUtils.java
IOUtils.byteCount
public long byteCount(Object object) { try { CountingOutputStream cos = new CountingOutputStream(new OutputStream() { @Override public void write(int b) throws IOException { // do nothing } }); ObjectOutputStream os = new ObjectOutputStream(cos); os.writeObject(object); os.flush(); os.close(); return cos.getCount(); } catch (IOException e) { throw new IllegalStateException("error serializing object: " + e.getMessage(),e); } }
java
public long byteCount(Object object) { try { CountingOutputStream cos = new CountingOutputStream(new OutputStream() { @Override public void write(int b) throws IOException { // do nothing } }); ObjectOutputStream os = new ObjectOutputStream(cos); os.writeObject(object); os.flush(); os.close(); return cos.getCount(); } catch (IOException e) { throw new IllegalStateException("error serializing object: " + e.getMessage(),e); } }
[ "public", "long", "byteCount", "(", "Object", "object", ")", "{", "try", "{", "CountingOutputStream", "cos", "=", "new", "CountingOutputStream", "(", "new", "OutputStream", "(", ")", "{", "@", "Override", "public", "void", "write", "(", "int", "b", ")", "throws", "IOException", "{", "// do nothing", "}", "}", ")", ";", "ObjectOutputStream", "os", "=", "new", "ObjectOutputStream", "(", "cos", ")", ";", "os", ".", "writeObject", "(", "object", ")", ";", "os", ".", "flush", "(", ")", ";", "os", ".", "close", "(", ")", ";", "return", "cos", ".", "getCount", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "IllegalStateException", "(", "\"error serializing object: \"", "+", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "}" ]
Calculate the serialized object size in bytes. This is a good indication of how much memory the object roughly takes. Note that this is typically not exactly the same for many objects. @param object any object that implements {@link Serializable} @return number of bytes of the serialized object.
[ "Calculate", "the", "serialized", "object", "size", "in", "bytes", ".", "This", "is", "a", "good", "indication", "of", "how", "much", "memory", "the", "object", "roughly", "takes", ".", "Note", "that", "this", "is", "typically", "not", "exactly", "the", "same", "for", "many", "objects", "." ]
3112bc08d4237e95fe0f8a219a5bbceb390d0505
https://github.com/Inbot/inbot-utils/blob/3112bc08d4237e95fe0f8a219a5bbceb390d0505/src/main/java/io/inbot/utils/IOUtils.java#L57-L74
10,028
craftercms/deployer
src/main/java/org/craftercms/deployer/utils/ConfigUtils.java
ConfigUtils.getStringArrayProperty
public static String[] getStringArrayProperty(Configuration config, String key) throws DeployerConfigurationException { try { return config.getStringArray(key); } catch (Exception e) { throw new DeployerConfigurationException("Failed to retrieve property '" + key + "'", e); } }
java
public static String[] getStringArrayProperty(Configuration config, String key) throws DeployerConfigurationException { try { return config.getStringArray(key); } catch (Exception e) { throw new DeployerConfigurationException("Failed to retrieve property '" + key + "'", e); } }
[ "public", "static", "String", "[", "]", "getStringArrayProperty", "(", "Configuration", "config", ",", "String", "key", ")", "throws", "DeployerConfigurationException", "{", "try", "{", "return", "config", ".", "getStringArray", "(", "key", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "DeployerConfigurationException", "(", "\"Failed to retrieve property '\"", "+", "key", "+", "\"'\"", ",", "e", ")", ";", "}", "}" ]
Returns the specified String array property from the configuration. A String array property is normally specified as a String with values separated by commas in the configuration. @param config the configuration @param key the key of the property @return the String array value of the property, or null if not found @throws DeployerConfigurationException if an error occurred
[ "Returns", "the", "specified", "String", "array", "property", "from", "the", "configuration", ".", "A", "String", "array", "property", "is", "normally", "specified", "as", "a", "String", "with", "values", "separated", "by", "commas", "in", "the", "configuration", "." ]
3ed446e3cc8af1055de2de6f871907f90ef27f63
https://github.com/craftercms/deployer/blob/3ed446e3cc8af1055de2de6f871907f90ef27f63/src/main/java/org/craftercms/deployer/utils/ConfigUtils.java#L232-L239
10,029
craftercms/deployer
src/main/java/org/craftercms/deployer/utils/ConfigUtils.java
ConfigUtils.getConfigurationsAt
@SuppressWarnings("unchecked") public static List<HierarchicalConfiguration> getConfigurationsAt(HierarchicalConfiguration config, String key) throws DeployerConfigurationException { try { return config.configurationsAt(key); } catch (Exception e) { throw new DeployerConfigurationException("Failed to retrieve sub-configurations at '" + key + "'", e); } }
java
@SuppressWarnings("unchecked") public static List<HierarchicalConfiguration> getConfigurationsAt(HierarchicalConfiguration config, String key) throws DeployerConfigurationException { try { return config.configurationsAt(key); } catch (Exception e) { throw new DeployerConfigurationException("Failed to retrieve sub-configurations at '" + key + "'", e); } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "List", "<", "HierarchicalConfiguration", ">", "getConfigurationsAt", "(", "HierarchicalConfiguration", "config", ",", "String", "key", ")", "throws", "DeployerConfigurationException", "{", "try", "{", "return", "config", ".", "configurationsAt", "(", "key", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "DeployerConfigurationException", "(", "\"Failed to retrieve sub-configurations at '\"", "+", "key", "+", "\"'\"", ",", "e", ")", ";", "}", "}" ]
Returns the sub-configuration tree whose root is the specified key. @param config the configuration @param key the key of the configuration tree @return the sub-configuration tree, or null if not found @throws DeployerConfigurationException if an error occurs
[ "Returns", "the", "sub", "-", "configuration", "tree", "whose", "root", "is", "the", "specified", "key", "." ]
3ed446e3cc8af1055de2de6f871907f90ef27f63
https://github.com/craftercms/deployer/blob/3ed446e3cc8af1055de2de6f871907f90ef27f63/src/main/java/org/craftercms/deployer/utils/ConfigUtils.java#L270-L279
10,030
augustd/burp-suite-utils
src/main/java/com/monikamorrow/burp/BurpSuiteTab.java
BurpSuiteTab.highlight
public void highlight() { final JTabbedPane parent = (JTabbedPane) this.getUiComponent().getParent(); //search through tabs until we find this one for (int i = 0; i < parent.getTabCount(); i++) { String title = parent.getTitleAt(i); if (getTabCaption().equals(title)) { //found this tab //create new colored label and set it into the tab final JLabel label = new JLabel(getTabCaption()); label.setForeground(new Color(0xff6633)); parent.setTabComponentAt(i, label); //schedule a task to change back to original color Timer timer = new Timer(); TimerTask task = new TimerTask() { @Override public void run() { label.setForeground(Color.black); } }; timer.schedule(task, 3000); break; } } }
java
public void highlight() { final JTabbedPane parent = (JTabbedPane) this.getUiComponent().getParent(); //search through tabs until we find this one for (int i = 0; i < parent.getTabCount(); i++) { String title = parent.getTitleAt(i); if (getTabCaption().equals(title)) { //found this tab //create new colored label and set it into the tab final JLabel label = new JLabel(getTabCaption()); label.setForeground(new Color(0xff6633)); parent.setTabComponentAt(i, label); //schedule a task to change back to original color Timer timer = new Timer(); TimerTask task = new TimerTask() { @Override public void run() { label.setForeground(Color.black); } }; timer.schedule(task, 3000); break; } } }
[ "public", "void", "highlight", "(", ")", "{", "final", "JTabbedPane", "parent", "=", "(", "JTabbedPane", ")", "this", ".", "getUiComponent", "(", ")", ".", "getParent", "(", ")", ";", "//search through tabs until we find this one", "for", "(", "int", "i", "=", "0", ";", "i", "<", "parent", ".", "getTabCount", "(", ")", ";", "i", "++", ")", "{", "String", "title", "=", "parent", ".", "getTitleAt", "(", "i", ")", ";", "if", "(", "getTabCaption", "(", ")", ".", "equals", "(", "title", ")", ")", "{", "//found this tab", "//create new colored label and set it into the tab", "final", "JLabel", "label", "=", "new", "JLabel", "(", "getTabCaption", "(", ")", ")", ";", "label", ".", "setForeground", "(", "new", "Color", "(", "0xff6633", ")", ")", ";", "parent", ".", "setTabComponentAt", "(", "i", ",", "label", ")", ";", "//schedule a task to change back to original color", "Timer", "timer", "=", "new", "Timer", "(", ")", ";", "TimerTask", "task", "=", "new", "TimerTask", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "label", ".", "setForeground", "(", "Color", ".", "black", ")", ";", "}", "}", ";", "timer", ".", "schedule", "(", "task", ",", "3000", ")", ";", "break", ";", "}", "}", "}" ]
Highlights the tab using Burp's color scheme. The highlight disappears after 3 seconds.
[ "Highlights", "the", "tab", "using", "Burp", "s", "color", "scheme", ".", "The", "highlight", "disappears", "after", "3", "seconds", "." ]
5e34a6b9147f5705382f98049dd9e4f387b78629
https://github.com/augustd/burp-suite-utils/blob/5e34a6b9147f5705382f98049dd9e4f387b78629/src/main/java/com/monikamorrow/burp/BurpSuiteTab.java#L56-L84
10,031
augustd/burp-suite-utils
src/main/java/com/codemagi/burp/parser/HttpResponse.java
HttpResponse.setHeader
public final String setHeader(String name, String value) { sortedHeaders = null; return headers.put(name, value); }
java
public final String setHeader(String name, String value) { sortedHeaders = null; return headers.put(name, value); }
[ "public", "final", "String", "setHeader", "(", "String", "name", ",", "String", "value", ")", "{", "sortedHeaders", "=", "null", ";", "return", "headers", ".", "put", "(", "name", ",", "value", ")", ";", "}" ]
Sets a header field value based on its name. @param name The header name to set @param value The header value to set @return the previous value or null if the field was previously unset.
[ "Sets", "a", "header", "field", "value", "based", "on", "its", "name", "." ]
5e34a6b9147f5705382f98049dd9e4f387b78629
https://github.com/augustd/burp-suite-utils/blob/5e34a6b9147f5705382f98049dd9e4f387b78629/src/main/java/com/codemagi/burp/parser/HttpResponse.java#L150-L153
10,032
Inbot/inbot-utils
src/main/java/io/inbot/utils/SimpleStringTrie.java
SimpleStringTrie.from
public static SimpleStringTrie from(Map<String,?> map) { SimpleStringTrie st = new SimpleStringTrie(); map.keySet().forEach(key -> st.add(key)); return st; }
java
public static SimpleStringTrie from(Map<String,?> map) { SimpleStringTrie st = new SimpleStringTrie(); map.keySet().forEach(key -> st.add(key)); return st; }
[ "public", "static", "SimpleStringTrie", "from", "(", "Map", "<", "String", ",", "?", ">", "map", ")", "{", "SimpleStringTrie", "st", "=", "new", "SimpleStringTrie", "(", ")", ";", "map", ".", "keySet", "(", ")", ".", "forEach", "(", "key", "->", "st", ".", "add", "(", "key", ")", ")", ";", "return", "st", ";", "}" ]
Useful if you want to build a trie for an existing map so you can figure out a matching prefix that has an entry @param map a map @return a SimpleStringTrie for the map.
[ "Useful", "if", "you", "want", "to", "build", "a", "trie", "for", "an", "existing", "map", "so", "you", "can", "figure", "out", "a", "matching", "prefix", "that", "has", "an", "entry" ]
3112bc08d4237e95fe0f8a219a5bbceb390d0505
https://github.com/Inbot/inbot-utils/blob/3112bc08d4237e95fe0f8a219a5bbceb390d0505/src/main/java/io/inbot/utils/SimpleStringTrie.java#L55-L59
10,033
Inbot/inbot-utils
src/main/java/io/inbot/utils/SimpleStringTrie.java
SimpleStringTrie.add
public void add(String input) { TrieNode currentNode = root; for(char c: input.toCharArray()) { Map<Character, TrieNode> children = currentNode.getChildren(); TrieNode matchingNode = children.get(c); if(matchingNode != null) { currentNode = matchingNode; } else { TrieNode newNode = new TrieNode(); children.put(c, newNode); currentNode = newNode; } } currentNode.end=true; // this is the end of an input that was added, there may be more children }
java
public void add(String input) { TrieNode currentNode = root; for(char c: input.toCharArray()) { Map<Character, TrieNode> children = currentNode.getChildren(); TrieNode matchingNode = children.get(c); if(matchingNode != null) { currentNode = matchingNode; } else { TrieNode newNode = new TrieNode(); children.put(c, newNode); currentNode = newNode; } } currentNode.end=true; // this is the end of an input that was added, there may be more children }
[ "public", "void", "add", "(", "String", "input", ")", "{", "TrieNode", "currentNode", "=", "root", ";", "for", "(", "char", "c", ":", "input", ".", "toCharArray", "(", ")", ")", "{", "Map", "<", "Character", ",", "TrieNode", ">", "children", "=", "currentNode", ".", "getChildren", "(", ")", ";", "TrieNode", "matchingNode", "=", "children", ".", "get", "(", "c", ")", ";", "if", "(", "matchingNode", "!=", "null", ")", "{", "currentNode", "=", "matchingNode", ";", "}", "else", "{", "TrieNode", "newNode", "=", "new", "TrieNode", "(", ")", ";", "children", ".", "put", "(", "c", ",", "newNode", ")", ";", "currentNode", "=", "newNode", ";", "}", "}", "currentNode", ".", "end", "=", "true", ";", "// this is the end of an input that was added, there may be more children", "}" ]
Add a string to the trie. @param input any String
[ "Add", "a", "string", "to", "the", "trie", "." ]
3112bc08d4237e95fe0f8a219a5bbceb390d0505
https://github.com/Inbot/inbot-utils/blob/3112bc08d4237e95fe0f8a219a5bbceb390d0505/src/main/java/io/inbot/utils/SimpleStringTrie.java#L65-L80
10,034
Inbot/inbot-utils
src/main/java/io/inbot/utils/SimpleStringTrie.java
SimpleStringTrie.get
public Optional<String> get(String input) { TrieNode currentNode = root; int i=0; for(char c: input.toCharArray()) { TrieNode nextNode = currentNode.getChildren().get(c); if(nextNode != null) { i++; currentNode=nextNode; } else { if(i>0 && currentNode.isLeaf()) { return Optional.of(input.substring(0, i)); } } } if(i>0 && currentNode.isLeaf()) { return Optional.of(input.substring(0, i)); } return Optional.empty(); }
java
public Optional<String> get(String input) { TrieNode currentNode = root; int i=0; for(char c: input.toCharArray()) { TrieNode nextNode = currentNode.getChildren().get(c); if(nextNode != null) { i++; currentNode=nextNode; } else { if(i>0 && currentNode.isLeaf()) { return Optional.of(input.substring(0, i)); } } } if(i>0 && currentNode.isLeaf()) { return Optional.of(input.substring(0, i)); } return Optional.empty(); }
[ "public", "Optional", "<", "String", ">", "get", "(", "String", "input", ")", "{", "TrieNode", "currentNode", "=", "root", ";", "int", "i", "=", "0", ";", "for", "(", "char", "c", ":", "input", ".", "toCharArray", "(", ")", ")", "{", "TrieNode", "nextNode", "=", "currentNode", ".", "getChildren", "(", ")", ".", "get", "(", "c", ")", ";", "if", "(", "nextNode", "!=", "null", ")", "{", "i", "++", ";", "currentNode", "=", "nextNode", ";", "}", "else", "{", "if", "(", "i", ">", "0", "&&", "currentNode", ".", "isLeaf", "(", ")", ")", "{", "return", "Optional", ".", "of", "(", "input", ".", "substring", "(", "0", ",", "i", ")", ")", ";", "}", "}", "}", "if", "(", "i", ">", "0", "&&", "currentNode", ".", "isLeaf", "(", ")", ")", "{", "return", "Optional", ".", "of", "(", "input", ".", "substring", "(", "0", ",", "i", ")", ")", ";", "}", "return", "Optional", ".", "empty", "(", ")", ";", "}" ]
Return the longest matching prefix of the input string that was added to the trie. @param input a string @return Optional of longest matching prefix that was added to the trie
[ "Return", "the", "longest", "matching", "prefix", "of", "the", "input", "string", "that", "was", "added", "to", "the", "trie", "." ]
3112bc08d4237e95fe0f8a219a5bbceb390d0505
https://github.com/Inbot/inbot-utils/blob/3112bc08d4237e95fe0f8a219a5bbceb390d0505/src/main/java/io/inbot/utils/SimpleStringTrie.java#L87-L105
10,035
rometools/rome-modules
src/main/java/com/rometools/modules/itunes/FeedInformationImpl.java
FeedInformationImpl.copyFrom
@Override public void copyFrom(final CopyFrom obj) { final FeedInformationImpl info = (FeedInformationImpl) obj; setAuthor(info.getAuthor()); setBlock(info.getBlock()); getCategories().clear(); if (info.getCategories() != null) { getCategories().addAll(info.getCategories()); } setComplete(info.getComplete()); setNewFeedUrl(info.getNewFeedUrl()); setExplicit(info.getExplicit()); try { if (info.getImage() != null) { setImage(new URL(info.getImage().toExternalForm())); } } catch (final MalformedURLException e) { LOG.debug("Error copying URL:" + info.getImage(), e); } if (info.getKeywords() != null) { setKeywords(info.getKeywords().clone()); } setOwnerEmailAddress(info.getOwnerEmailAddress()); setOwnerName(info.getOwnerName()); setSubtitle(info.getSubtitle()); setSummary(info.getSummary()); }
java
@Override public void copyFrom(final CopyFrom obj) { final FeedInformationImpl info = (FeedInformationImpl) obj; setAuthor(info.getAuthor()); setBlock(info.getBlock()); getCategories().clear(); if (info.getCategories() != null) { getCategories().addAll(info.getCategories()); } setComplete(info.getComplete()); setNewFeedUrl(info.getNewFeedUrl()); setExplicit(info.getExplicit()); try { if (info.getImage() != null) { setImage(new URL(info.getImage().toExternalForm())); } } catch (final MalformedURLException e) { LOG.debug("Error copying URL:" + info.getImage(), e); } if (info.getKeywords() != null) { setKeywords(info.getKeywords().clone()); } setOwnerEmailAddress(info.getOwnerEmailAddress()); setOwnerName(info.getOwnerName()); setSubtitle(info.getSubtitle()); setSummary(info.getSummary()); }
[ "@", "Override", "public", "void", "copyFrom", "(", "final", "CopyFrom", "obj", ")", "{", "final", "FeedInformationImpl", "info", "=", "(", "FeedInformationImpl", ")", "obj", ";", "setAuthor", "(", "info", ".", "getAuthor", "(", ")", ")", ";", "setBlock", "(", "info", ".", "getBlock", "(", ")", ")", ";", "getCategories", "(", ")", ".", "clear", "(", ")", ";", "if", "(", "info", ".", "getCategories", "(", ")", "!=", "null", ")", "{", "getCategories", "(", ")", ".", "addAll", "(", "info", ".", "getCategories", "(", ")", ")", ";", "}", "setComplete", "(", "info", ".", "getComplete", "(", ")", ")", ";", "setNewFeedUrl", "(", "info", ".", "getNewFeedUrl", "(", ")", ")", ";", "setExplicit", "(", "info", ".", "getExplicit", "(", ")", ")", ";", "try", "{", "if", "(", "info", ".", "getImage", "(", ")", "!=", "null", ")", "{", "setImage", "(", "new", "URL", "(", "info", ".", "getImage", "(", ")", ".", "toExternalForm", "(", ")", ")", ")", ";", "}", "}", "catch", "(", "final", "MalformedURLException", "e", ")", "{", "LOG", ".", "debug", "(", "\"Error copying URL:\"", "+", "info", ".", "getImage", "(", ")", ",", "e", ")", ";", "}", "if", "(", "info", ".", "getKeywords", "(", ")", "!=", "null", ")", "{", "setKeywords", "(", "info", ".", "getKeywords", "(", ")", ".", "clone", "(", ")", ")", ";", "}", "setOwnerEmailAddress", "(", "info", ".", "getOwnerEmailAddress", "(", ")", ")", ";", "setOwnerName", "(", "info", ".", "getOwnerName", "(", ")", ")", ";", "setSubtitle", "(", "info", ".", "getSubtitle", "(", ")", ")", ";", "setSummary", "(", "info", ".", "getSummary", "(", ")", ")", ";", "}" ]
Required by the ROME API @param obj object to copy property values from
[ "Required", "by", "the", "ROME", "API" ]
adc6be4ec33b8418c6cf01f15924f8daee37afc9
https://github.com/rometools/rome-modules/blob/adc6be4ec33b8418c6cf01f15924f8daee37afc9/src/main/java/com/rometools/modules/itunes/FeedInformationImpl.java#L164-L195
10,036
Inbot/inbot-utils
src/main/java/io/inbot/utils/PatternEvaluator.java
PatternEvaluator.matches
public static <I,O> BoolExprPattern<I,O> matches(Function<I,Boolean> expr, Function<I,O> f) { return new BoolExprPattern<I, O>(expr, f); }
java
public static <I,O> BoolExprPattern<I,O> matches(Function<I,Boolean> expr, Function<I,O> f) { return new BoolExprPattern<I, O>(expr, f); }
[ "public", "static", "<", "I", ",", "O", ">", "BoolExprPattern", "<", "I", ",", "O", ">", "matches", "(", "Function", "<", "I", ",", "Boolean", ">", "expr", ",", "Function", "<", "I", ",", "O", ">", "f", ")", "{", "return", "new", "BoolExprPattern", "<", "I", ",", "O", ">", "(", "expr", ",", "f", ")", ";", "}" ]
Allows you use a lambda to match on an input. @param expr expression that evaluates to true/false @param f function that produces O from I @param <I> Input @param <O> Output @return pattern that matches on the expression
[ "Allows", "you", "use", "a", "lambda", "to", "match", "on", "an", "input", "." ]
3112bc08d4237e95fe0f8a219a5bbceb390d0505
https://github.com/Inbot/inbot-utils/blob/3112bc08d4237e95fe0f8a219a5bbceb390d0505/src/main/java/io/inbot/utils/PatternEvaluator.java#L105-L107
10,037
Inbot/inbot-utils
src/main/java/io/inbot/utils/PatternEvaluator.java
PatternEvaluator.evaluate
@SafeVarargs public static <I,O> Optional<O> evaluate(I input, Pattern<I,O>...patterns) { return new PatternEvaluator<>(patterns).evaluate(input); }
java
@SafeVarargs public static <I,O> Optional<O> evaluate(I input, Pattern<I,O>...patterns) { return new PatternEvaluator<>(patterns).evaluate(input); }
[ "@", "SafeVarargs", "public", "static", "<", "I", ",", "O", ">", "Optional", "<", "O", ">", "evaluate", "(", "I", "input", ",", "Pattern", "<", "I", ",", "O", ">", "...", "patterns", ")", "{", "return", "new", "PatternEvaluator", "<>", "(", "patterns", ")", ".", "evaluate", "(", "input", ")", ";", "}" ]
Creates an evaluator and then evaluates the value right away. @param input input value @param patterns zero or more patterns @param <I> Input @param <O> Output @return O
[ "Creates", "an", "evaluator", "and", "then", "evaluates", "the", "value", "right", "away", "." ]
3112bc08d4237e95fe0f8a219a5bbceb390d0505
https://github.com/Inbot/inbot-utils/blob/3112bc08d4237e95fe0f8a219a5bbceb390d0505/src/main/java/io/inbot/utils/PatternEvaluator.java#L140-L143
10,038
augustd/burp-suite-utils
src/main/java/com/monikamorrow/burp/ToolsScopeComponent.java
ToolsScopeComponent.setToolDefault
public void setToolDefault(int tool, boolean enabled) { switch (tool) { case IBurpExtenderCallbacks.TOOL_PROXY: if (mCallbacks.loadExtensionSetting(SETTING_PROXY) == null) { jCheckBoxProxy.setSelected(enabled); } break; case IBurpExtenderCallbacks.TOOL_REPEATER: if (mCallbacks.loadExtensionSetting(SETTING_REPEATER) == null) { jCheckBoxRepeater.setSelected(enabled); } break; case IBurpExtenderCallbacks.TOOL_SCANNER: if (mCallbacks.loadExtensionSetting(SETTING_SCANNER) == null) { jCheckBoxScanner.setSelected(enabled); } break; case IBurpExtenderCallbacks.TOOL_INTRUDER: if (mCallbacks.loadExtensionSetting(SETTING_INTRUDER) == null) { jCheckBoxIntruder.setSelected(enabled); } break; case IBurpExtenderCallbacks.TOOL_SEQUENCER: if (mCallbacks.loadExtensionSetting(SETTING_SEQUENCER) == null) { jCheckBoxProxy.setSelected(enabled); } break; case IBurpExtenderCallbacks.TOOL_SPIDER: if (mCallbacks.loadExtensionSetting(SETTING_SPIDER) == null) { jCheckBoxSpider.setSelected(enabled); } break; case IBurpExtenderCallbacks.TOOL_EXTENDER: if (mCallbacks.loadExtensionSetting(SETTING_EXTENDER) == null) { jCheckBoxExtender.setSelected(enabled); } break; default: break; } }
java
public void setToolDefault(int tool, boolean enabled) { switch (tool) { case IBurpExtenderCallbacks.TOOL_PROXY: if (mCallbacks.loadExtensionSetting(SETTING_PROXY) == null) { jCheckBoxProxy.setSelected(enabled); } break; case IBurpExtenderCallbacks.TOOL_REPEATER: if (mCallbacks.loadExtensionSetting(SETTING_REPEATER) == null) { jCheckBoxRepeater.setSelected(enabled); } break; case IBurpExtenderCallbacks.TOOL_SCANNER: if (mCallbacks.loadExtensionSetting(SETTING_SCANNER) == null) { jCheckBoxScanner.setSelected(enabled); } break; case IBurpExtenderCallbacks.TOOL_INTRUDER: if (mCallbacks.loadExtensionSetting(SETTING_INTRUDER) == null) { jCheckBoxIntruder.setSelected(enabled); } break; case IBurpExtenderCallbacks.TOOL_SEQUENCER: if (mCallbacks.loadExtensionSetting(SETTING_SEQUENCER) == null) { jCheckBoxProxy.setSelected(enabled); } break; case IBurpExtenderCallbacks.TOOL_SPIDER: if (mCallbacks.loadExtensionSetting(SETTING_SPIDER) == null) { jCheckBoxSpider.setSelected(enabled); } break; case IBurpExtenderCallbacks.TOOL_EXTENDER: if (mCallbacks.loadExtensionSetting(SETTING_EXTENDER) == null) { jCheckBoxExtender.setSelected(enabled); } break; default: break; } }
[ "public", "void", "setToolDefault", "(", "int", "tool", ",", "boolean", "enabled", ")", "{", "switch", "(", "tool", ")", "{", "case", "IBurpExtenderCallbacks", ".", "TOOL_PROXY", ":", "if", "(", "mCallbacks", ".", "loadExtensionSetting", "(", "SETTING_PROXY", ")", "==", "null", ")", "{", "jCheckBoxProxy", ".", "setSelected", "(", "enabled", ")", ";", "}", "break", ";", "case", "IBurpExtenderCallbacks", ".", "TOOL_REPEATER", ":", "if", "(", "mCallbacks", ".", "loadExtensionSetting", "(", "SETTING_REPEATER", ")", "==", "null", ")", "{", "jCheckBoxRepeater", ".", "setSelected", "(", "enabled", ")", ";", "}", "break", ";", "case", "IBurpExtenderCallbacks", ".", "TOOL_SCANNER", ":", "if", "(", "mCallbacks", ".", "loadExtensionSetting", "(", "SETTING_SCANNER", ")", "==", "null", ")", "{", "jCheckBoxScanner", ".", "setSelected", "(", "enabled", ")", ";", "}", "break", ";", "case", "IBurpExtenderCallbacks", ".", "TOOL_INTRUDER", ":", "if", "(", "mCallbacks", ".", "loadExtensionSetting", "(", "SETTING_INTRUDER", ")", "==", "null", ")", "{", "jCheckBoxIntruder", ".", "setSelected", "(", "enabled", ")", ";", "}", "break", ";", "case", "IBurpExtenderCallbacks", ".", "TOOL_SEQUENCER", ":", "if", "(", "mCallbacks", ".", "loadExtensionSetting", "(", "SETTING_SEQUENCER", ")", "==", "null", ")", "{", "jCheckBoxProxy", ".", "setSelected", "(", "enabled", ")", ";", "}", "break", ";", "case", "IBurpExtenderCallbacks", ".", "TOOL_SPIDER", ":", "if", "(", "mCallbacks", ".", "loadExtensionSetting", "(", "SETTING_SPIDER", ")", "==", "null", ")", "{", "jCheckBoxSpider", ".", "setSelected", "(", "enabled", ")", ";", "}", "break", ";", "case", "IBurpExtenderCallbacks", ".", "TOOL_EXTENDER", ":", "if", "(", "mCallbacks", ".", "loadExtensionSetting", "(", "SETTING_EXTENDER", ")", "==", "null", ")", "{", "jCheckBoxExtender", ".", "setSelected", "(", "enabled", ")", ";", "}", "break", ";", "default", ":", "break", ";", "}", "}" ]
Allows the developer to set the default value for selected tools, not every tool makes sense for every extension @param tool The tool code, as defined in IBurpExtenderCallbacks @param enabled True if the checkbox should be checked by default.
[ "Allows", "the", "developer", "to", "set", "the", "default", "value", "for", "selected", "tools", "not", "every", "tool", "makes", "sense", "for", "every", "extension" ]
5e34a6b9147f5705382f98049dd9e4f387b78629
https://github.com/augustd/burp-suite-utils/blob/5e34a6b9147f5705382f98049dd9e4f387b78629/src/main/java/com/monikamorrow/burp/ToolsScopeComponent.java#L84-L124
10,039
augustd/burp-suite-utils
src/main/java/com/monikamorrow/burp/ToolsScopeComponent.java
ToolsScopeComponent.isToolSelected
public boolean isToolSelected(int tool) { boolean selected = false; switch (tool) { case IBurpExtenderCallbacks.TOOL_PROXY: selected = jCheckBoxProxy.isSelected(); break; case IBurpExtenderCallbacks.TOOL_REPEATER: selected = jCheckBoxRepeater.isSelected(); break; case IBurpExtenderCallbacks.TOOL_SCANNER: selected = jCheckBoxScanner.isSelected(); break; case IBurpExtenderCallbacks.TOOL_INTRUDER: selected = jCheckBoxIntruder.isSelected(); break; case IBurpExtenderCallbacks.TOOL_SEQUENCER: selected = jCheckBoxSequencer.isSelected(); break; case IBurpExtenderCallbacks.TOOL_SPIDER: selected = jCheckBoxSpider.isSelected(); break; case IBurpExtenderCallbacks.TOOL_EXTENDER: selected = jCheckBoxExtender.isSelected(); break; case IBurpExtenderCallbacks.TOOL_TARGET: break; default: break; } return selected; }
java
public boolean isToolSelected(int tool) { boolean selected = false; switch (tool) { case IBurpExtenderCallbacks.TOOL_PROXY: selected = jCheckBoxProxy.isSelected(); break; case IBurpExtenderCallbacks.TOOL_REPEATER: selected = jCheckBoxRepeater.isSelected(); break; case IBurpExtenderCallbacks.TOOL_SCANNER: selected = jCheckBoxScanner.isSelected(); break; case IBurpExtenderCallbacks.TOOL_INTRUDER: selected = jCheckBoxIntruder.isSelected(); break; case IBurpExtenderCallbacks.TOOL_SEQUENCER: selected = jCheckBoxSequencer.isSelected(); break; case IBurpExtenderCallbacks.TOOL_SPIDER: selected = jCheckBoxSpider.isSelected(); break; case IBurpExtenderCallbacks.TOOL_EXTENDER: selected = jCheckBoxExtender.isSelected(); break; case IBurpExtenderCallbacks.TOOL_TARGET: break; default: break; } return selected; }
[ "public", "boolean", "isToolSelected", "(", "int", "tool", ")", "{", "boolean", "selected", "=", "false", ";", "switch", "(", "tool", ")", "{", "case", "IBurpExtenderCallbacks", ".", "TOOL_PROXY", ":", "selected", "=", "jCheckBoxProxy", ".", "isSelected", "(", ")", ";", "break", ";", "case", "IBurpExtenderCallbacks", ".", "TOOL_REPEATER", ":", "selected", "=", "jCheckBoxRepeater", ".", "isSelected", "(", ")", ";", "break", ";", "case", "IBurpExtenderCallbacks", ".", "TOOL_SCANNER", ":", "selected", "=", "jCheckBoxScanner", ".", "isSelected", "(", ")", ";", "break", ";", "case", "IBurpExtenderCallbacks", ".", "TOOL_INTRUDER", ":", "selected", "=", "jCheckBoxIntruder", ".", "isSelected", "(", ")", ";", "break", ";", "case", "IBurpExtenderCallbacks", ".", "TOOL_SEQUENCER", ":", "selected", "=", "jCheckBoxSequencer", ".", "isSelected", "(", ")", ";", "break", ";", "case", "IBurpExtenderCallbacks", ".", "TOOL_SPIDER", ":", "selected", "=", "jCheckBoxSpider", ".", "isSelected", "(", ")", ";", "break", ";", "case", "IBurpExtenderCallbacks", ".", "TOOL_EXTENDER", ":", "selected", "=", "jCheckBoxExtender", ".", "isSelected", "(", ")", ";", "break", ";", "case", "IBurpExtenderCallbacks", ".", "TOOL_TARGET", ":", "break", ";", "default", ":", "break", ";", "}", "return", "selected", ";", "}" ]
Returns true if the requested tool is selected in the GUI @param tool The tool code, as defined in IBurpExtenderCallbacks @return whether the selected tool is selected
[ "Returns", "true", "if", "the", "requested", "tool", "is", "selected", "in", "the", "GUI" ]
5e34a6b9147f5705382f98049dd9e4f387b78629
https://github.com/augustd/burp-suite-utils/blob/5e34a6b9147f5705382f98049dd9e4f387b78629/src/main/java/com/monikamorrow/burp/ToolsScopeComponent.java#L132-L162
10,040
Inbot/inbot-utils
src/main/java/io/inbot/utils/JwtTokenCreationService.java
JwtTokenCreationService.create
public String create(Consumer<JWTCreator.Builder> jwtBuilderConsumer) { Date issueTime = new Date(); Date expirationTime = new Date(issueTime.getTime() + defaultExpirationMs); JWTCreator.Builder builder = JWT.create() // opinionated creation, we enforce using an expiration .withIssuer(issuer) .withIssuedAt(issueTime) .withExpiresAt(expirationTime); // apply any additional token customisation jwtBuilderConsumer.accept(builder); return sign(builder); }
java
public String create(Consumer<JWTCreator.Builder> jwtBuilderConsumer) { Date issueTime = new Date(); Date expirationTime = new Date(issueTime.getTime() + defaultExpirationMs); JWTCreator.Builder builder = JWT.create() // opinionated creation, we enforce using an expiration .withIssuer(issuer) .withIssuedAt(issueTime) .withExpiresAt(expirationTime); // apply any additional token customisation jwtBuilderConsumer.accept(builder); return sign(builder); }
[ "public", "String", "create", "(", "Consumer", "<", "JWTCreator", ".", "Builder", ">", "jwtBuilderConsumer", ")", "{", "Date", "issueTime", "=", "new", "Date", "(", ")", ";", "Date", "expirationTime", "=", "new", "Date", "(", "issueTime", ".", "getTime", "(", ")", "+", "defaultExpirationMs", ")", ";", "JWTCreator", ".", "Builder", "builder", "=", "JWT", ".", "create", "(", ")", "// opinionated creation, we enforce using an expiration", ".", "withIssuer", "(", "issuer", ")", ".", "withIssuedAt", "(", "issueTime", ")", ".", "withExpiresAt", "(", "expirationTime", ")", ";", "// apply any additional token customisation", "jwtBuilderConsumer", ".", "accept", "(", "builder", ")", ";", "return", "sign", "(", "builder", ")", ";", "}" ]
Creates a JWT token. @param jwtBuilderConsumer a way for you to customise the token using a lambda function @return token with the issuer and default expiration set.
[ "Creates", "a", "JWT", "token", "." ]
3112bc08d4237e95fe0f8a219a5bbceb390d0505
https://github.com/Inbot/inbot-utils/blob/3112bc08d4237e95fe0f8a219a5bbceb390d0505/src/main/java/io/inbot/utils/JwtTokenCreationService.java#L41-L52
10,041
Inbot/inbot-utils
src/main/java/io/inbot/utils/JwtTokenCreationService.java
JwtTokenCreationService.sign
public String sign(JWTCreator.Builder builder) { // use the strongest algorithm; return builder.sign(Algorithm.ECDSA512(ecPublicKey, ecPrivateKey)); }
java
public String sign(JWTCreator.Builder builder) { // use the strongest algorithm; return builder.sign(Algorithm.ECDSA512(ecPublicKey, ecPrivateKey)); }
[ "public", "String", "sign", "(", "JWTCreator", ".", "Builder", "builder", ")", "{", "// use the strongest algorithm;", "return", "builder", ".", "sign", "(", "Algorithm", ".", "ECDSA512", "(", "ecPublicKey", ",", "ecPrivateKey", ")", ")", ";", "}" ]
Sign the jwt builder. Use this if you want to control issueing time, expiration time, and issuer. @param builder @return jwt token.
[ "Sign", "the", "jwt", "builder", ".", "Use", "this", "if", "you", "want", "to", "control", "issueing", "time", "expiration", "time", "and", "issuer", "." ]
3112bc08d4237e95fe0f8a219a5bbceb390d0505
https://github.com/Inbot/inbot-utils/blob/3112bc08d4237e95fe0f8a219a5bbceb390d0505/src/main/java/io/inbot/utils/JwtTokenCreationService.java#L63-L66
10,042
rometools/rome-modules
src/main/java/com/rometools/modules/activitystreams/types/Person.java
Person.setAvatar
public void setAvatar(final Link newavatar) { final Link old = getAvatar(); if (old != null) { getOtherLinks().remove(old); } newavatar.setRel("avatar"); getOtherLinks().add(newavatar); }
java
public void setAvatar(final Link newavatar) { final Link old = getAvatar(); if (old != null) { getOtherLinks().remove(old); } newavatar.setRel("avatar"); getOtherLinks().add(newavatar); }
[ "public", "void", "setAvatar", "(", "final", "Link", "newavatar", ")", "{", "final", "Link", "old", "=", "getAvatar", "(", ")", ";", "if", "(", "old", "!=", "null", ")", "{", "getOtherLinks", "(", ")", ".", "remove", "(", "old", ")", ";", "}", "newavatar", ".", "setRel", "(", "\"avatar\"", ")", ";", "getOtherLinks", "(", ")", ".", "add", "(", "newavatar", ")", ";", "}" ]
Set the value of avatar @param newavatar new value of avatar
[ "Set", "the", "value", "of", "avatar" ]
adc6be4ec33b8418c6cf01f15924f8daee37afc9
https://github.com/rometools/rome-modules/blob/adc6be4ec33b8418c6cf01f15924f8daee37afc9/src/main/java/com/rometools/modules/activitystreams/types/Person.java#L80-L87
10,043
Inbot/inbot-utils
src/main/java/io/inbot/utils/Math.java
Math.safeAbs
public static long safeAbs(long number) { // workaround for common issue where Math.abs returns a negative number for Long.MIN_VALUE if(Long.MIN_VALUE == number) { return Long.MAX_VALUE; } else { return java.lang.Math.abs(number); } }
java
public static long safeAbs(long number) { // workaround for common issue where Math.abs returns a negative number for Long.MIN_VALUE if(Long.MIN_VALUE == number) { return Long.MAX_VALUE; } else { return java.lang.Math.abs(number); } }
[ "public", "static", "long", "safeAbs", "(", "long", "number", ")", "{", "// workaround for common issue where Math.abs returns a negative number for Long.MIN_VALUE", "if", "(", "Long", ".", "MIN_VALUE", "==", "number", ")", "{", "return", "Long", ".", "MAX_VALUE", ";", "}", "else", "{", "return", "java", ".", "lang", ".", "Math", ".", "abs", "(", "number", ")", ";", "}", "}" ]
Java Math.abs has an issue with Long and Integer MIN_VALUE where it returns MIN_VALUE. @param number a number @return the absolute value
[ "Java", "Math", ".", "abs", "has", "an", "issue", "with", "Long", "and", "Integer", "MIN_VALUE", "where", "it", "returns", "MIN_VALUE", "." ]
3112bc08d4237e95fe0f8a219a5bbceb390d0505
https://github.com/Inbot/inbot-utils/blob/3112bc08d4237e95fe0f8a219a5bbceb390d0505/src/main/java/io/inbot/utils/Math.java#L14-L21
10,044
Inbot/inbot-utils
src/main/java/io/inbot/utils/Math.java
Math.pow
public static long pow(long l, int exp) { BigInteger bi = BigInteger.valueOf(l).pow(exp); if(bi.compareTo(BigInteger.valueOf(Long.MAX_VALUE)) > 0 || bi.compareTo(BigInteger.valueOf(Long.MIN_VALUE)) < 0) { throw new IllegalArgumentException("pow(" + l + "," + exp + ") exceeds Long.MAX_VALUE"); } return bi.longValue(); }
java
public static long pow(long l, int exp) { BigInteger bi = BigInteger.valueOf(l).pow(exp); if(bi.compareTo(BigInteger.valueOf(Long.MAX_VALUE)) > 0 || bi.compareTo(BigInteger.valueOf(Long.MIN_VALUE)) < 0) { throw new IllegalArgumentException("pow(" + l + "," + exp + ") exceeds Long.MAX_VALUE"); } return bi.longValue(); }
[ "public", "static", "long", "pow", "(", "long", "l", ",", "int", "exp", ")", "{", "BigInteger", "bi", "=", "BigInteger", ".", "valueOf", "(", "l", ")", ".", "pow", "(", "exp", ")", ";", "if", "(", "bi", ".", "compareTo", "(", "BigInteger", ".", "valueOf", "(", "Long", ".", "MAX_VALUE", ")", ")", ">", "0", "||", "bi", ".", "compareTo", "(", "BigInteger", ".", "valueOf", "(", "Long", ".", "MIN_VALUE", ")", ")", "<", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"pow(\"", "+", "l", "+", "\",\"", "+", "exp", "+", "\") exceeds Long.MAX_VALUE\"", ")", ";", "}", "return", "bi", ".", "longValue", "(", ")", ";", "}" ]
Java.lang.pow only works on doubles; this fixes that. Safe version of pow that relies on BigInteger that can raise a long to an int exponential. Uses BigInteger internally to ensure this is done correctly and does a check on the value to ensure it can safely be converted into a long @param l a long @param exp exponent @return l to the power of exp @throws IllegalArgumentException if the resulting value exceeds Long.MAX_VALUE
[ "Java", ".", "lang", ".", "pow", "only", "works", "on", "doubles", ";", "this", "fixes", "that", ".", "Safe", "version", "of", "pow", "that", "relies", "on", "BigInteger", "that", "can", "raise", "a", "long", "to", "an", "int", "exponential", ".", "Uses", "BigInteger", "internally", "to", "ensure", "this", "is", "done", "correctly", "and", "does", "a", "check", "on", "the", "value", "to", "ensure", "it", "can", "safely", "be", "converted", "into", "a", "long" ]
3112bc08d4237e95fe0f8a219a5bbceb390d0505
https://github.com/Inbot/inbot-utils/blob/3112bc08d4237e95fe0f8a219a5bbceb390d0505/src/main/java/io/inbot/utils/Math.java#L52-L58
10,045
craftercms/deployer
src/main/java/org/craftercms/deployer/impl/tasks/TargetCleanupTask.java
TargetCleanupTask.cleanupAllTargets
@Scheduled(cron = "${deployer.main.targets.cleanup.cron}") public void cleanupAllTargets() { try { logger.info("Starting cleanup for all targets"); targetService.getAllTargets().forEach(Target::cleanup); } catch (TargetServiceException e) { logger.error("Error getting loaded targets", e); } }
java
@Scheduled(cron = "${deployer.main.targets.cleanup.cron}") public void cleanupAllTargets() { try { logger.info("Starting cleanup for all targets"); targetService.getAllTargets().forEach(Target::cleanup); } catch (TargetServiceException e) { logger.error("Error getting loaded targets", e); } }
[ "@", "Scheduled", "(", "cron", "=", "\"${deployer.main.targets.cleanup.cron}\"", ")", "public", "void", "cleanupAllTargets", "(", ")", "{", "try", "{", "logger", ".", "info", "(", "\"Starting cleanup for all targets\"", ")", ";", "targetService", ".", "getAllTargets", "(", ")", ".", "forEach", "(", "Target", "::", "cleanup", ")", ";", "}", "catch", "(", "TargetServiceException", "e", ")", "{", "logger", ".", "error", "(", "\"Error getting loaded targets\"", ",", "e", ")", ";", "}", "}" ]
Performs a cleanup on all loaded targets.
[ "Performs", "a", "cleanup", "on", "all", "loaded", "targets", "." ]
3ed446e3cc8af1055de2de6f871907f90ef27f63
https://github.com/craftercms/deployer/blob/3ed446e3cc8af1055de2de6f871907f90ef27f63/src/main/java/org/craftercms/deployer/impl/tasks/TargetCleanupTask.java#L46-L54
10,046
Inbot/inbot-utils
src/main/java/io/inbot/utils/MiscUtils.java
MiscUtils.urlEncode
public static String urlEncode(String s) { try { return URLEncoder.encode(s, StandardCharsets.UTF_8.name()); } catch (UnsupportedEncodingException e) { throw new IllegalStateException("get a jdk that actually supports utf-8", e); } }
java
public static String urlEncode(String s) { try { return URLEncoder.encode(s, StandardCharsets.UTF_8.name()); } catch (UnsupportedEncodingException e) { throw new IllegalStateException("get a jdk that actually supports utf-8", e); } }
[ "public", "static", "String", "urlEncode", "(", "String", "s", ")", "{", "try", "{", "return", "URLEncoder", ".", "encode", "(", "s", ",", "StandardCharsets", ".", "UTF_8", ".", "name", "(", ")", ")", ";", "}", "catch", "(", "UnsupportedEncodingException", "e", ")", "{", "throw", "new", "IllegalStateException", "(", "\"get a jdk that actually supports utf-8\"", ",", "e", ")", ";", "}", "}" ]
Url encode a string and don't throw a checked exception. Uses UTF-8 as per RFC 3986. @param s a string @return url encoded string
[ "Url", "encode", "a", "string", "and", "don", "t", "throw", "a", "checked", "exception", ".", "Uses", "UTF", "-", "8", "as", "per", "RFC", "3986", "." ]
3112bc08d4237e95fe0f8a219a5bbceb390d0505
https://github.com/Inbot/inbot-utils/blob/3112bc08d4237e95fe0f8a219a5bbceb390d0505/src/main/java/io/inbot/utils/MiscUtils.java#L31-L37
10,047
Inbot/inbot-utils
src/main/java/io/inbot/utils/MiscUtils.java
MiscUtils.urlDecode
public static String urlDecode(String s) { try { return URLDecoder.decode(s, StandardCharsets.UTF_8.name()); } catch (UnsupportedEncodingException e) { throw new IllegalStateException("get a jdk that actually supports utf-8", e); } }
java
public static String urlDecode(String s) { try { return URLDecoder.decode(s, StandardCharsets.UTF_8.name()); } catch (UnsupportedEncodingException e) { throw new IllegalStateException("get a jdk that actually supports utf-8", e); } }
[ "public", "static", "String", "urlDecode", "(", "String", "s", ")", "{", "try", "{", "return", "URLDecoder", ".", "decode", "(", "s", ",", "StandardCharsets", ".", "UTF_8", ".", "name", "(", ")", ")", ";", "}", "catch", "(", "UnsupportedEncodingException", "e", ")", "{", "throw", "new", "IllegalStateException", "(", "\"get a jdk that actually supports utf-8\"", ",", "e", ")", ";", "}", "}" ]
Url decode a string and don't throw a checked exception. Uses UTF-8 as per RFC 3986. @param s a string @return decoded string
[ "Url", "decode", "a", "string", "and", "don", "t", "throw", "a", "checked", "exception", ".", "Uses", "UTF", "-", "8", "as", "per", "RFC", "3986", "." ]
3112bc08d4237e95fe0f8a219a5bbceb390d0505
https://github.com/Inbot/inbot-utils/blob/3112bc08d4237e95fe0f8a219a5bbceb390d0505/src/main/java/io/inbot/utils/MiscUtils.java#L44-L50
10,048
craftercms/deployer
src/main/java/org/craftercms/deployer/impl/rest/MonitorController.java
MonitorController.memoryStats
@RequestMapping(value = MEMORY_URL, method = RequestMethod.GET) public ResponseEntity<List<MemoryMonitor>> memoryStats() { return new ResponseEntity<>(MemoryMonitor.getMemoryStats(), HttpStatus.OK); }
java
@RequestMapping(value = MEMORY_URL, method = RequestMethod.GET) public ResponseEntity<List<MemoryMonitor>> memoryStats() { return new ResponseEntity<>(MemoryMonitor.getMemoryStats(), HttpStatus.OK); }
[ "@", "RequestMapping", "(", "value", "=", "MEMORY_URL", ",", "method", "=", "RequestMethod", ".", "GET", ")", "public", "ResponseEntity", "<", "List", "<", "MemoryMonitor", ">", ">", "memoryStats", "(", ")", "{", "return", "new", "ResponseEntity", "<>", "(", "MemoryMonitor", ".", "getMemoryStats", "(", ")", ",", "HttpStatus", ".", "OK", ")", ";", "}" ]
Uses Crafter Commons Memory Monitor POJO to get current JVM Memory stats. @return {link {@link MemoryMonitor}}
[ "Uses", "Crafter", "Commons", "Memory", "Monitor", "POJO", "to", "get", "current", "JVM", "Memory", "stats", "." ]
3ed446e3cc8af1055de2de6f871907f90ef27f63
https://github.com/craftercms/deployer/blob/3ed446e3cc8af1055de2de6f871907f90ef27f63/src/main/java/org/craftercms/deployer/impl/rest/MonitorController.java#L68-L71
10,049
craftercms/deployer
src/main/java/org/craftercms/deployer/impl/rest/MonitorController.java
MonitorController.status
@RequestMapping(value = STATUS_URL, method = RequestMethod.GET) public ResponseEntity<StatusMonitor> status() { return new ResponseEntity<>(StatusMonitor.getCurrentStatus(), HttpStatus.OK); }
java
@RequestMapping(value = STATUS_URL, method = RequestMethod.GET) public ResponseEntity<StatusMonitor> status() { return new ResponseEntity<>(StatusMonitor.getCurrentStatus(), HttpStatus.OK); }
[ "@", "RequestMapping", "(", "value", "=", "STATUS_URL", ",", "method", "=", "RequestMethod", ".", "GET", ")", "public", "ResponseEntity", "<", "StatusMonitor", ">", "status", "(", ")", "{", "return", "new", "ResponseEntity", "<>", "(", "StatusMonitor", ".", "getCurrentStatus", "(", ")", ",", "HttpStatus", ".", "OK", ")", ";", "}" ]
Uses Crafter Commons Status Monitor POJO to get current System status. @return {link {@link StatusMonitor}}
[ "Uses", "Crafter", "Commons", "Status", "Monitor", "POJO", "to", "get", "current", "System", "status", "." ]
3ed446e3cc8af1055de2de6f871907f90ef27f63
https://github.com/craftercms/deployer/blob/3ed446e3cc8af1055de2de6f871907f90ef27f63/src/main/java/org/craftercms/deployer/impl/rest/MonitorController.java#L77-L80
10,050
craftercms/deployer
src/main/java/org/craftercms/deployer/impl/rest/MonitorController.java
MonitorController.version
@RequestMapping(value = VERSION_URL, method = RequestMethod.GET) public ResponseEntity<VersionMonitor> version() throws IOException { try { final VersionMonitor monitor = VersionMonitor.getVersion(MonitorController.class); return new ResponseEntity<>(monitor, HttpStatus.OK); } catch (IOException ex) { LOGGER.error("Unable to read manifest file", ex); throw new IOException("Unable to read manifest file", ex); } }
java
@RequestMapping(value = VERSION_URL, method = RequestMethod.GET) public ResponseEntity<VersionMonitor> version() throws IOException { try { final VersionMonitor monitor = VersionMonitor.getVersion(MonitorController.class); return new ResponseEntity<>(monitor, HttpStatus.OK); } catch (IOException ex) { LOGGER.error("Unable to read manifest file", ex); throw new IOException("Unable to read manifest file", ex); } }
[ "@", "RequestMapping", "(", "value", "=", "VERSION_URL", ",", "method", "=", "RequestMethod", ".", "GET", ")", "public", "ResponseEntity", "<", "VersionMonitor", ">", "version", "(", ")", "throws", "IOException", "{", "try", "{", "final", "VersionMonitor", "monitor", "=", "VersionMonitor", ".", "getVersion", "(", "MonitorController", ".", "class", ")", ";", "return", "new", "ResponseEntity", "<>", "(", "monitor", ",", "HttpStatus", ".", "OK", ")", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "LOGGER", ".", "error", "(", "\"Unable to read manifest file\"", ",", "ex", ")", ";", "throw", "new", "IOException", "(", "\"Unable to read manifest file\"", ",", "ex", ")", ";", "}", "}" ]
Uses Crafter Commons Status Version POJO to get current Deployment and JVM runtime and version information. @return {link {@link VersionMonitor}} @throws IOException If Manifest File can't be read.
[ "Uses", "Crafter", "Commons", "Status", "Version", "POJO", "to", "get", "current", "Deployment", "and", "JVM", "runtime", "and", "version", "information", "." ]
3ed446e3cc8af1055de2de6f871907f90ef27f63
https://github.com/craftercms/deployer/blob/3ed446e3cc8af1055de2de6f871907f90ef27f63/src/main/java/org/craftercms/deployer/impl/rest/MonitorController.java#L89-L98
10,051
augustd/burp-suite-utils
src/main/java/com/codemagi/burp/Utils.java
Utils.getSelection
public static String getSelection(byte[] message, int[] offsets) { if (offsets == null || message == null) return ""; if (offsets.length < 2 || offsets[0] == offsets[1]) return ""; byte[] selection = Arrays.copyOfRange(message, offsets[0], offsets[1]); return new String(selection); }
java
public static String getSelection(byte[] message, int[] offsets) { if (offsets == null || message == null) return ""; if (offsets.length < 2 || offsets[0] == offsets[1]) return ""; byte[] selection = Arrays.copyOfRange(message, offsets[0], offsets[1]); return new String(selection); }
[ "public", "static", "String", "getSelection", "(", "byte", "[", "]", "message", ",", "int", "[", "]", "offsets", ")", "{", "if", "(", "offsets", "==", "null", "||", "message", "==", "null", ")", "return", "\"\"", ";", "if", "(", "offsets", ".", "length", "<", "2", "||", "offsets", "[", "0", "]", "==", "offsets", "[", "1", "]", ")", "return", "\"\"", ";", "byte", "[", "]", "selection", "=", "Arrays", ".", "copyOfRange", "(", "message", ",", "offsets", "[", "0", "]", ",", "offsets", "[", "1", "]", ")", ";", "return", "new", "String", "(", "selection", ")", ";", "}" ]
Returns the user-selected text in the passed array. @param message The array of bytes to get the selection from @param offsets The offsets within the array that indicate the start and end points of the selection @return A String representing the selected bytes. If offsets is null or if both values are the same, "" is returned.
[ "Returns", "the", "user", "-", "selected", "text", "in", "the", "passed", "array", "." ]
5e34a6b9147f5705382f98049dd9e4f387b78629
https://github.com/augustd/burp-suite-utils/blob/5e34a6b9147f5705382f98049dd9e4f387b78629/src/main/java/com/codemagi/burp/Utils.java#L71-L79
10,052
augustd/burp-suite-utils
src/main/java/com/codemagi/burp/Utils.java
Utils.noNulls
public static String noNulls(String test, String output, String defaultOutput) { if (isEmpty(test)) { return defaultOutput; } return output; }
java
public static String noNulls(String test, String output, String defaultOutput) { if (isEmpty(test)) { return defaultOutput; } return output; }
[ "public", "static", "String", "noNulls", "(", "String", "test", ",", "String", "output", ",", "String", "defaultOutput", ")", "{", "if", "(", "isEmpty", "(", "test", ")", ")", "{", "return", "defaultOutput", ";", "}", "return", "output", ";", "}" ]
Outputs the String output if the test String is not empty, otherwise outputs default @param test String to test for emptyness @param output String to output if the test String is not empty @param defaultOutput String to output if the test String is empty @return Object Empty String if the input was null, the input unchanged otherwise
[ "Outputs", "the", "String", "output", "if", "the", "test", "String", "is", "not", "empty", "otherwise", "outputs", "default" ]
5e34a6b9147f5705382f98049dd9e4f387b78629
https://github.com/augustd/burp-suite-utils/blob/5e34a6b9147f5705382f98049dd9e4f387b78629/src/main/java/com/codemagi/burp/Utils.java#L153-L159
10,053
augustd/burp-suite-utils
src/main/java/com/codemagi/burp/Utils.java
Utils.getFileAsLines
public static List<String> getFileAsLines(String sFileName) throws Exception { FileInputStream fIn = null; BufferedReader fileReader = null; try { //open the file fIn = new FileInputStream(sFileName); fileReader = new BufferedReader(new InputStreamReader(fIn)); //create a Vector for output ArrayList<String> output = new ArrayList<String>(); //read the file line by line, append lines to the Vector String line = null; while ((line = fileReader.readLine()) != null) { output.add(line); } return output; } catch (Exception e) { throw e; } finally { fIn.close(); fileReader.close(); } }
java
public static List<String> getFileAsLines(String sFileName) throws Exception { FileInputStream fIn = null; BufferedReader fileReader = null; try { //open the file fIn = new FileInputStream(sFileName); fileReader = new BufferedReader(new InputStreamReader(fIn)); //create a Vector for output ArrayList<String> output = new ArrayList<String>(); //read the file line by line, append lines to the Vector String line = null; while ((line = fileReader.readLine()) != null) { output.add(line); } return output; } catch (Exception e) { throw e; } finally { fIn.close(); fileReader.close(); } }
[ "public", "static", "List", "<", "String", ">", "getFileAsLines", "(", "String", "sFileName", ")", "throws", "Exception", "{", "FileInputStream", "fIn", "=", "null", ";", "BufferedReader", "fileReader", "=", "null", ";", "try", "{", "//open the file ", "fIn", "=", "new", "FileInputStream", "(", "sFileName", ")", ";", "fileReader", "=", "new", "BufferedReader", "(", "new", "InputStreamReader", "(", "fIn", ")", ")", ";", "//create a Vector for output", "ArrayList", "<", "String", ">", "output", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "//read the file line by line, append lines to the Vector", "String", "line", "=", "null", ";", "while", "(", "(", "line", "=", "fileReader", ".", "readLine", "(", ")", ")", "!=", "null", ")", "{", "output", ".", "add", "(", "line", ")", ";", "}", "return", "output", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "e", ";", "}", "finally", "{", "fIn", ".", "close", "(", ")", ";", "fileReader", ".", "close", "(", ")", ";", "}", "}" ]
Returns the contents of an ASCII file as a List of Strings. This method throws any fileIO errors. @param sFileName Full file path. @return String[] String array containing the contents of the file, one element per line @throws Exception Any fileIO errors
[ "Returns", "the", "contents", "of", "an", "ASCII", "file", "as", "a", "List", "of", "Strings", "." ]
5e34a6b9147f5705382f98049dd9e4f387b78629
https://github.com/augustd/burp-suite-utils/blob/5e34a6b9147f5705382f98049dd9e4f387b78629/src/main/java/com/codemagi/burp/Utils.java#L243-L276
10,054
craftercms/deployer
src/main/java/org/craftercms/deployer/api/ChangeSet.java
ChangeSet.isEmpty
@JsonIgnore public boolean isEmpty() { return CollectionUtils.isEmpty(createdFiles) && CollectionUtils.isEmpty(updatedFiles) && CollectionUtils.isEmpty(deletedFiles); }
java
@JsonIgnore public boolean isEmpty() { return CollectionUtils.isEmpty(createdFiles) && CollectionUtils.isEmpty(updatedFiles) && CollectionUtils.isEmpty(deletedFiles); }
[ "@", "JsonIgnore", "public", "boolean", "isEmpty", "(", ")", "{", "return", "CollectionUtils", ".", "isEmpty", "(", "createdFiles", ")", "&&", "CollectionUtils", ".", "isEmpty", "(", "updatedFiles", ")", "&&", "CollectionUtils", ".", "isEmpty", "(", "deletedFiles", ")", ";", "}" ]
Returns true if there are not created, updated or deleted files.
[ "Returns", "true", "if", "there", "are", "not", "created", "updated", "or", "deleted", "files", "." ]
3ed446e3cc8af1055de2de6f871907f90ef27f63
https://github.com/craftercms/deployer/blob/3ed446e3cc8af1055de2de6f871907f90ef27f63/src/main/java/org/craftercms/deployer/api/ChangeSet.java#L78-L83
10,055
craftercms/deployer
src/main/java/org/craftercms/deployer/utils/GitUtils.java
GitUtils.cloneRemoteRepository
public static Git cloneRemoteRepository(String remoteName, String remoteUrl, String branch, GitAuthenticationConfigurator authConfigurator, File localFolder, String bigFileThreshold, Integer compression, Boolean fileMode) throws GitAPIException, IOException { CloneCommand command = Git.cloneRepository(); command.setRemote(remoteName); command.setURI(remoteUrl); command.setDirectory(localFolder); if (StringUtils.isNotEmpty(branch)) { command.setCloneAllBranches(false); command.setBranchesToClone(Collections.singletonList(Constants.R_HEADS + branch)); command.setBranch(branch); } if (authConfigurator != null) { authConfigurator.configureAuthentication(command); } Git git = command.call(); StoredConfig config = git.getRepository().getConfig(); if (StringUtils.isEmpty(bigFileThreshold)) { bigFileThreshold = BIG_FILE_THRESHOLD_DEFAULT; } if (compression == null) { compression = COMPRESSION_DEFAULT; } if (fileMode == null) { fileMode = FILE_MODE_DEFAULT; } config.setString(CORE_CONFIG_SECTION, null, BIG_FILE_THRESHOLD_CONFIG_PARAM, bigFileThreshold); config.setInt(CORE_CONFIG_SECTION, null, COMPRESSION_CONFIG_PARAM, compression); config.setBoolean(CORE_CONFIG_SECTION, null, FILE_MODE_CONFIG_PARAM, fileMode); config.save(); return git; }
java
public static Git cloneRemoteRepository(String remoteName, String remoteUrl, String branch, GitAuthenticationConfigurator authConfigurator, File localFolder, String bigFileThreshold, Integer compression, Boolean fileMode) throws GitAPIException, IOException { CloneCommand command = Git.cloneRepository(); command.setRemote(remoteName); command.setURI(remoteUrl); command.setDirectory(localFolder); if (StringUtils.isNotEmpty(branch)) { command.setCloneAllBranches(false); command.setBranchesToClone(Collections.singletonList(Constants.R_HEADS + branch)); command.setBranch(branch); } if (authConfigurator != null) { authConfigurator.configureAuthentication(command); } Git git = command.call(); StoredConfig config = git.getRepository().getConfig(); if (StringUtils.isEmpty(bigFileThreshold)) { bigFileThreshold = BIG_FILE_THRESHOLD_DEFAULT; } if (compression == null) { compression = COMPRESSION_DEFAULT; } if (fileMode == null) { fileMode = FILE_MODE_DEFAULT; } config.setString(CORE_CONFIG_SECTION, null, BIG_FILE_THRESHOLD_CONFIG_PARAM, bigFileThreshold); config.setInt(CORE_CONFIG_SECTION, null, COMPRESSION_CONFIG_PARAM, compression); config.setBoolean(CORE_CONFIG_SECTION, null, FILE_MODE_CONFIG_PARAM, fileMode); config.save(); return git; }
[ "public", "static", "Git", "cloneRemoteRepository", "(", "String", "remoteName", ",", "String", "remoteUrl", ",", "String", "branch", ",", "GitAuthenticationConfigurator", "authConfigurator", ",", "File", "localFolder", ",", "String", "bigFileThreshold", ",", "Integer", "compression", ",", "Boolean", "fileMode", ")", "throws", "GitAPIException", ",", "IOException", "{", "CloneCommand", "command", "=", "Git", ".", "cloneRepository", "(", ")", ";", "command", ".", "setRemote", "(", "remoteName", ")", ";", "command", ".", "setURI", "(", "remoteUrl", ")", ";", "command", ".", "setDirectory", "(", "localFolder", ")", ";", "if", "(", "StringUtils", ".", "isNotEmpty", "(", "branch", ")", ")", "{", "command", ".", "setCloneAllBranches", "(", "false", ")", ";", "command", ".", "setBranchesToClone", "(", "Collections", ".", "singletonList", "(", "Constants", ".", "R_HEADS", "+", "branch", ")", ")", ";", "command", ".", "setBranch", "(", "branch", ")", ";", "}", "if", "(", "authConfigurator", "!=", "null", ")", "{", "authConfigurator", ".", "configureAuthentication", "(", "command", ")", ";", "}", "Git", "git", "=", "command", ".", "call", "(", ")", ";", "StoredConfig", "config", "=", "git", ".", "getRepository", "(", ")", ".", "getConfig", "(", ")", ";", "if", "(", "StringUtils", ".", "isEmpty", "(", "bigFileThreshold", ")", ")", "{", "bigFileThreshold", "=", "BIG_FILE_THRESHOLD_DEFAULT", ";", "}", "if", "(", "compression", "==", "null", ")", "{", "compression", "=", "COMPRESSION_DEFAULT", ";", "}", "if", "(", "fileMode", "==", "null", ")", "{", "fileMode", "=", "FILE_MODE_DEFAULT", ";", "}", "config", ".", "setString", "(", "CORE_CONFIG_SECTION", ",", "null", ",", "BIG_FILE_THRESHOLD_CONFIG_PARAM", ",", "bigFileThreshold", ")", ";", "config", ".", "setInt", "(", "CORE_CONFIG_SECTION", ",", "null", ",", "COMPRESSION_CONFIG_PARAM", ",", "compression", ")", ";", "config", ".", "setBoolean", "(", "CORE_CONFIG_SECTION", ",", "null", ",", "FILE_MODE_CONFIG_PARAM", ",", "fileMode", ")", ";", "config", ".", "save", "(", ")", ";", "return", "git", ";", "}" ]
Clones a remote repository into a specific local folder. @param remoteName the name of the remote @param remoteUrl the URL of the remote. This should be a legal Git URL. @param branch the branch which should be cloned @param authConfigurator the {@link GitAuthenticationConfigurator} class used to configure the authentication with the remote repository @param localFolder the local folder into which the remote repository should be cloned @param bigFileThreshold the value of the Git {@code core.bigFileThreshold} config property @param compression the value of the Git {@code core.compression} config property @param fileMode the value of the Git {@code core.fileMode} config property @return the Git instance used to handle the cloned repository @throws GitAPIException if a Git related error occurs @throws IOException if an IO error occurs
[ "Clones", "a", "remote", "repository", "into", "a", "specific", "local", "folder", "." ]
3ed446e3cc8af1055de2de6f871907f90ef27f63
https://github.com/craftercms/deployer/blob/3ed446e3cc8af1055de2de6f871907f90ef27f63/src/main/java/org/craftercms/deployer/utils/GitUtils.java#L83-L121
10,056
craftercms/deployer
src/main/java/org/craftercms/deployer/utils/GitUtils.java
GitUtils.pull
public static PullResult pull(Git git, String remoteName, String remoteUrl, String branch, MergeStrategy mergeStrategy, GitAuthenticationConfigurator authConfigurator) throws GitAPIException, URISyntaxException { addRemote(git, remoteName, remoteUrl); PullCommand command = git.pull(); command.setRemote(remoteName); command.setRemoteBranchName(branch); if (mergeStrategy != null) { command.setStrategy(mergeStrategy); } if (authConfigurator != null) { authConfigurator.configureAuthentication(command); } return command.call(); }
java
public static PullResult pull(Git git, String remoteName, String remoteUrl, String branch, MergeStrategy mergeStrategy, GitAuthenticationConfigurator authConfigurator) throws GitAPIException, URISyntaxException { addRemote(git, remoteName, remoteUrl); PullCommand command = git.pull(); command.setRemote(remoteName); command.setRemoteBranchName(branch); if (mergeStrategy != null) { command.setStrategy(mergeStrategy); } if (authConfigurator != null) { authConfigurator.configureAuthentication(command); } return command.call(); }
[ "public", "static", "PullResult", "pull", "(", "Git", "git", ",", "String", "remoteName", ",", "String", "remoteUrl", ",", "String", "branch", ",", "MergeStrategy", "mergeStrategy", ",", "GitAuthenticationConfigurator", "authConfigurator", ")", "throws", "GitAPIException", ",", "URISyntaxException", "{", "addRemote", "(", "git", ",", "remoteName", ",", "remoteUrl", ")", ";", "PullCommand", "command", "=", "git", ".", "pull", "(", ")", ";", "command", ".", "setRemote", "(", "remoteName", ")", ";", "command", ".", "setRemoteBranchName", "(", "branch", ")", ";", "if", "(", "mergeStrategy", "!=", "null", ")", "{", "command", ".", "setStrategy", "(", "mergeStrategy", ")", ";", "}", "if", "(", "authConfigurator", "!=", "null", ")", "{", "authConfigurator", ".", "configureAuthentication", "(", "command", ")", ";", "}", "return", "command", ".", "call", "(", ")", ";", "}" ]
Execute a Git pull. @param git the Git instance used to handle the repository @param remoteName the name of the remote where to pull from @param remoteUrl the URL of the remote (remote will be set to the URL) @param branch the branch to pull @param mergeStrategy the merge strategy to use @param authConfigurator the {@link GitAuthenticationConfigurator} class used to configure the authentication with the remote repository @return the result of the pull @throws GitAPIException if a Git related error occurs @throws URISyntaxException if the remote URL is invalid
[ "Execute", "a", "Git", "pull", "." ]
3ed446e3cc8af1055de2de6f871907f90ef27f63
https://github.com/craftercms/deployer/blob/3ed446e3cc8af1055de2de6f871907f90ef27f63/src/main/java/org/craftercms/deployer/utils/GitUtils.java#L137-L155
10,057
craftercms/deployer
src/main/java/org/craftercms/deployer/utils/GitUtils.java
GitUtils.push
public static Iterable<PushResult> push(Git git, String remote, String branch, GitAuthenticationConfigurator authConfigurator) throws GitAPIException { PushCommand push = git.push(); push.setRemote(remote); if (StringUtils.isNotEmpty(branch)) { push.setRefSpecs(new RefSpec(Constants.HEAD + ":" + Constants.R_HEADS + branch)); } if (authConfigurator != null) { authConfigurator.configureAuthentication(push); } return push.call(); }
java
public static Iterable<PushResult> push(Git git, String remote, String branch, GitAuthenticationConfigurator authConfigurator) throws GitAPIException { PushCommand push = git.push(); push.setRemote(remote); if (StringUtils.isNotEmpty(branch)) { push.setRefSpecs(new RefSpec(Constants.HEAD + ":" + Constants.R_HEADS + branch)); } if (authConfigurator != null) { authConfigurator.configureAuthentication(push); } return push.call(); }
[ "public", "static", "Iterable", "<", "PushResult", ">", "push", "(", "Git", "git", ",", "String", "remote", ",", "String", "branch", ",", "GitAuthenticationConfigurator", "authConfigurator", ")", "throws", "GitAPIException", "{", "PushCommand", "push", "=", "git", ".", "push", "(", ")", ";", "push", ".", "setRemote", "(", "remote", ")", ";", "if", "(", "StringUtils", ".", "isNotEmpty", "(", "branch", ")", ")", "{", "push", ".", "setRefSpecs", "(", "new", "RefSpec", "(", "Constants", ".", "HEAD", "+", "\":\"", "+", "Constants", ".", "R_HEADS", "+", "branch", ")", ")", ";", "}", "if", "(", "authConfigurator", "!=", "null", ")", "{", "authConfigurator", ".", "configureAuthentication", "(", "push", ")", ";", "}", "return", "push", ".", "call", "(", ")", ";", "}" ]
Executes a git push. @param git the Git instance used to handle the repository @param remote remote name or URL @param branch the remote branch being pushed to @param authConfigurator the {@link GitAuthenticationConfigurator} class used to configure the authentication with the remote repository @return the result of the push @throws GitAPIException if a Git related error occurs
[ "Executes", "a", "git", "push", "." ]
3ed446e3cc8af1055de2de6f871907f90ef27f63
https://github.com/craftercms/deployer/blob/3ed446e3cc8af1055de2de6f871907f90ef27f63/src/main/java/org/craftercms/deployer/utils/GitUtils.java#L169-L182
10,058
craftercms/deployer
src/main/java/org/craftercms/deployer/utils/GitUtils.java
GitUtils.cleanup
public static void cleanup(String repoPath) throws GitAPIException, IOException { openRepository(new File(repoPath)).gc().call(); }
java
public static void cleanup(String repoPath) throws GitAPIException, IOException { openRepository(new File(repoPath)).gc().call(); }
[ "public", "static", "void", "cleanup", "(", "String", "repoPath", ")", "throws", "GitAPIException", ",", "IOException", "{", "openRepository", "(", "new", "File", "(", "repoPath", ")", ")", ".", "gc", "(", ")", ".", "call", "(", ")", ";", "}" ]
Executes a git gc. @param repoPath full path of the repository @throws GitAPIException if there is an error running the command @throws IOException if there is an error opening the repository
[ "Executes", "a", "git", "gc", "." ]
3ed446e3cc8af1055de2de6f871907f90ef27f63
https://github.com/craftercms/deployer/blob/3ed446e3cc8af1055de2de6f871907f90ef27f63/src/main/java/org/craftercms/deployer/utils/GitUtils.java#L190-L192
10,059
craftercms/deployer
src/main/java/org/craftercms/deployer/utils/GitUtils.java
GitUtils.addRemote
private static void addRemote(Git git, String remoteName, String remoteUrl) throws GitAPIException, URISyntaxException { String currentUrl = git.getRepository().getConfig().getString("remote", remoteName, "url"); if (StringUtils.isNotEmpty(currentUrl)) { if (!currentUrl.equals(remoteUrl)) { RemoteSetUrlCommand remoteSetUrl = git.remoteSetUrl(); remoteSetUrl.setName(remoteName); remoteSetUrl.setUri(new URIish(remoteUrl)); remoteSetUrl.call(); } } else { RemoteAddCommand remoteAdd = git.remoteAdd(); remoteAdd.setName(remoteName); remoteAdd.setUri(new URIish(remoteUrl)); remoteAdd.call(); } }
java
private static void addRemote(Git git, String remoteName, String remoteUrl) throws GitAPIException, URISyntaxException { String currentUrl = git.getRepository().getConfig().getString("remote", remoteName, "url"); if (StringUtils.isNotEmpty(currentUrl)) { if (!currentUrl.equals(remoteUrl)) { RemoteSetUrlCommand remoteSetUrl = git.remoteSetUrl(); remoteSetUrl.setName(remoteName); remoteSetUrl.setUri(new URIish(remoteUrl)); remoteSetUrl.call(); } } else { RemoteAddCommand remoteAdd = git.remoteAdd(); remoteAdd.setName(remoteName); remoteAdd.setUri(new URIish(remoteUrl)); remoteAdd.call(); } }
[ "private", "static", "void", "addRemote", "(", "Git", "git", ",", "String", "remoteName", ",", "String", "remoteUrl", ")", "throws", "GitAPIException", ",", "URISyntaxException", "{", "String", "currentUrl", "=", "git", ".", "getRepository", "(", ")", ".", "getConfig", "(", ")", ".", "getString", "(", "\"remote\"", ",", "remoteName", ",", "\"url\"", ")", ";", "if", "(", "StringUtils", ".", "isNotEmpty", "(", "currentUrl", ")", ")", "{", "if", "(", "!", "currentUrl", ".", "equals", "(", "remoteUrl", ")", ")", "{", "RemoteSetUrlCommand", "remoteSetUrl", "=", "git", ".", "remoteSetUrl", "(", ")", ";", "remoteSetUrl", ".", "setName", "(", "remoteName", ")", ";", "remoteSetUrl", ".", "setUri", "(", "new", "URIish", "(", "remoteUrl", ")", ")", ";", "remoteSetUrl", ".", "call", "(", ")", ";", "}", "}", "else", "{", "RemoteAddCommand", "remoteAdd", "=", "git", ".", "remoteAdd", "(", ")", ";", "remoteAdd", ".", "setName", "(", "remoteName", ")", ";", "remoteAdd", ".", "setUri", "(", "new", "URIish", "(", "remoteUrl", ")", ")", ";", "remoteAdd", ".", "call", "(", ")", ";", "}", "}" ]
Adds a remote if it doesn't exist. If the remote exists but the URL is different, updates the URL @param git the Git repo @param remoteName the name oif the remote @param remoteUrl the URL of the remote @throws GitAPIException if a Git error occurs @throws URISyntaxException if the remote URL is an invalid Git URL
[ "Adds", "a", "remote", "if", "it", "doesn", "t", "exist", ".", "If", "the", "remote", "exists", "but", "the", "URL", "is", "different", "updates", "the", "URL" ]
3ed446e3cc8af1055de2de6f871907f90ef27f63
https://github.com/craftercms/deployer/blob/3ed446e3cc8af1055de2de6f871907f90ef27f63/src/main/java/org/craftercms/deployer/utils/GitUtils.java#L204-L220
10,060
Inbot/inbot-utils
src/main/java/io/inbot/utils/StrategyEvaluator.java
StrategyEvaluator.evaluate
@SafeVarargs public static <T> Optional<T> evaluate(Supplier<Optional<T>>...suppliers) { for(Supplier<Optional<T>>s: suppliers) { Optional<T> maybe = s.get(); if(maybe.isPresent()) { return maybe; } } return Optional.empty(); }
java
@SafeVarargs public static <T> Optional<T> evaluate(Supplier<Optional<T>>...suppliers) { for(Supplier<Optional<T>>s: suppliers) { Optional<T> maybe = s.get(); if(maybe.isPresent()) { return maybe; } } return Optional.empty(); }
[ "@", "SafeVarargs", "public", "static", "<", "T", ">", "Optional", "<", "T", ">", "evaluate", "(", "Supplier", "<", "Optional", "<", "T", ">", ">", "...", "suppliers", ")", "{", "for", "(", "Supplier", "<", "Optional", "<", "T", ">", ">", "s", ":", "suppliers", ")", "{", "Optional", "<", "T", ">", "maybe", "=", "s", ".", "get", "(", ")", ";", "if", "(", "maybe", ".", "isPresent", "(", ")", ")", "{", "return", "maybe", ";", "}", "}", "return", "Optional", ".", "empty", "(", ")", ";", "}" ]
Evaluate supplier stategies that produce Optionals until one returns something. This implements the strategy pattern with a simple varargs of suppliers that produce an Optional T. You can use this to use several strategies to calculate a T. @param suppliers the strategies that produce Optionals of the desired output type. @return the optional provided by the first successful supplier or Optional.empty() @param <T> type
[ "Evaluate", "supplier", "stategies", "that", "produce", "Optionals", "until", "one", "returns", "something", ".", "This", "implements", "the", "strategy", "pattern", "with", "a", "simple", "varargs", "of", "suppliers", "that", "produce", "an", "Optional", "T", ".", "You", "can", "use", "this", "to", "use", "several", "strategies", "to", "calculate", "a", "T", "." ]
3112bc08d4237e95fe0f8a219a5bbceb390d0505
https://github.com/Inbot/inbot-utils/blob/3112bc08d4237e95fe0f8a219a5bbceb390d0505/src/main/java/io/inbot/utils/StrategyEvaluator.java#L18-L27
10,061
Inbot/inbot-utils
src/main/java/io/inbot/utils/KeyPairUtils.java
KeyPairUtils.privateKey2String
public static String privateKey2String(PrivateKey key) { PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(key.getEncoded()); return new String(Base64.getEncoder().encode(spec.getEncoded()), StandardCharsets.UTF_8); }
java
public static String privateKey2String(PrivateKey key) { PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(key.getEncoded()); return new String(Base64.getEncoder().encode(spec.getEncoded()), StandardCharsets.UTF_8); }
[ "public", "static", "String", "privateKey2String", "(", "PrivateKey", "key", ")", "{", "PKCS8EncodedKeySpec", "spec", "=", "new", "PKCS8EncodedKeySpec", "(", "key", ".", "getEncoded", "(", ")", ")", ";", "return", "new", "String", "(", "Base64", ".", "getEncoder", "(", ")", ".", "encode", "(", "spec", ".", "getEncoded", "(", ")", ")", ",", "StandardCharsets", ".", "UTF_8", ")", ";", "}" ]
Put this in a safe place obviously. @param key the key @return base 64 encoded string of the PKCS8 spec
[ "Put", "this", "in", "a", "safe", "place", "obviously", "." ]
3112bc08d4237e95fe0f8a219a5bbceb390d0505
https://github.com/Inbot/inbot-utils/blob/3112bc08d4237e95fe0f8a219a5bbceb390d0505/src/main/java/io/inbot/utils/KeyPairUtils.java#L45-L48
10,062
Inbot/inbot-utils
src/main/java/io/inbot/utils/KeyPairUtils.java
KeyPairUtils.publicKey2String
public static String publicKey2String(PublicKey key) { X509EncodedKeySpec spec = new X509EncodedKeySpec(key.getEncoded()); return new String(Base64.getEncoder().encode(spec.getEncoded()), StandardCharsets.UTF_8); }
java
public static String publicKey2String(PublicKey key) { X509EncodedKeySpec spec = new X509EncodedKeySpec(key.getEncoded()); return new String(Base64.getEncoder().encode(spec.getEncoded()), StandardCharsets.UTF_8); }
[ "public", "static", "String", "publicKey2String", "(", "PublicKey", "key", ")", "{", "X509EncodedKeySpec", "spec", "=", "new", "X509EncodedKeySpec", "(", "key", ".", "getEncoded", "(", ")", ")", ";", "return", "new", "String", "(", "Base64", ".", "getEncoder", "(", ")", ".", "encode", "(", "spec", ".", "getEncoded", "(", ")", ")", ",", "StandardCharsets", ".", "UTF_8", ")", ";", "}" ]
This is what you can share. @param key the key @return base 64 encoded string of the X509 spec
[ "This", "is", "what", "you", "can", "share", "." ]
3112bc08d4237e95fe0f8a219a5bbceb390d0505
https://github.com/Inbot/inbot-utils/blob/3112bc08d4237e95fe0f8a219a5bbceb390d0505/src/main/java/io/inbot/utils/KeyPairUtils.java#L55-L58
10,063
craftercms/deployer
src/main/java/org/craftercms/deployer/api/Deployment.java
Deployment.getDuration
@JsonProperty("duration") public Long getDuration() { if (start != null && end != null) { return start.until(end, ChronoUnit.MILLIS); } else { return null; } }
java
@JsonProperty("duration") public Long getDuration() { if (start != null && end != null) { return start.until(end, ChronoUnit.MILLIS); } else { return null; } }
[ "@", "JsonProperty", "(", "\"duration\"", ")", "public", "Long", "getDuration", "(", ")", "{", "if", "(", "start", "!=", "null", "&&", "end", "!=", "null", ")", "{", "return", "start", ".", "until", "(", "end", ",", "ChronoUnit", ".", "MILLIS", ")", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
Returns the duration of the deployment.
[ "Returns", "the", "duration", "of", "the", "deployment", "." ]
3ed446e3cc8af1055de2de6f871907f90ef27f63
https://github.com/craftercms/deployer/blob/3ed446e3cc8af1055de2de6f871907f90ef27f63/src/main/java/org/craftercms/deployer/api/Deployment.java#L97-L104
10,064
augustd/burp-suite-utils
src/main/java/com/codemagi/burp/PassiveScan.java
PassiveScan.getMatchRule
public MatchRule getMatchRule(int index) { if (index < rules.size()) { return rules.get(index); } return null; }
java
public MatchRule getMatchRule(int index) { if (index < rules.size()) { return rules.get(index); } return null; }
[ "public", "MatchRule", "getMatchRule", "(", "int", "index", ")", "{", "if", "(", "index", "<", "rules", ".", "size", "(", ")", ")", "{", "return", "rules", ".", "get", "(", "index", ")", ";", "}", "return", "null", ";", "}" ]
Get an existing match rule of the scan. If no match rule exists at the specified index, this method returns null. @param index Index of the match rule to return @return The match rule at the specified index, or null if none exists
[ "Get", "an", "existing", "match", "rule", "of", "the", "scan", "." ]
5e34a6b9147f5705382f98049dd9e4f387b78629
https://github.com/augustd/burp-suite-utils/blob/5e34a6b9147f5705382f98049dd9e4f387b78629/src/main/java/com/codemagi/burp/PassiveScan.java#L93-L98
10,065
augustd/burp-suite-utils
src/main/java/com/codemagi/burp/PassiveScan.java
PassiveScan.processIssues
protected List<IScanIssue> processIssues(List<ScannerMatch> matches, IHttpRequestResponse baseRequestResponse) { List<IScanIssue> issues = new ArrayList<>(); if (!matches.isEmpty()) { Collections.sort(matches); //matches must be in order //get the offsets of scanner matches List<int[]> startStop = new ArrayList<>(1); for (ScannerMatch match : matches) { callbacks.printOutput("Processing match: " + match); callbacks.printOutput(" start: " + match.getStart() + " end: " + match.getEnd() + " full match: " + match.getFullMatch() + " group: " + match.getMatchGroup()); //add a marker for code highlighting startStop.add(new int[]{match.getStart(), match.getEnd()}); } issues.add(getScanIssue(baseRequestResponse, matches, startStop)); callbacks.printOutput("issues: " + issues.size()); } return issues; }
java
protected List<IScanIssue> processIssues(List<ScannerMatch> matches, IHttpRequestResponse baseRequestResponse) { List<IScanIssue> issues = new ArrayList<>(); if (!matches.isEmpty()) { Collections.sort(matches); //matches must be in order //get the offsets of scanner matches List<int[]> startStop = new ArrayList<>(1); for (ScannerMatch match : matches) { callbacks.printOutput("Processing match: " + match); callbacks.printOutput(" start: " + match.getStart() + " end: " + match.getEnd() + " full match: " + match.getFullMatch() + " group: " + match.getMatchGroup()); //add a marker for code highlighting startStop.add(new int[]{match.getStart(), match.getEnd()}); } issues.add(getScanIssue(baseRequestResponse, matches, startStop)); callbacks.printOutput("issues: " + issues.size()); } return issues; }
[ "protected", "List", "<", "IScanIssue", ">", "processIssues", "(", "List", "<", "ScannerMatch", ">", "matches", ",", "IHttpRequestResponse", "baseRequestResponse", ")", "{", "List", "<", "IScanIssue", ">", "issues", "=", "new", "ArrayList", "<>", "(", ")", ";", "if", "(", "!", "matches", ".", "isEmpty", "(", ")", ")", "{", "Collections", ".", "sort", "(", "matches", ")", ";", "//matches must be in order", "//get the offsets of scanner matches", "List", "<", "int", "[", "]", ">", "startStop", "=", "new", "ArrayList", "<>", "(", "1", ")", ";", "for", "(", "ScannerMatch", "match", ":", "matches", ")", "{", "callbacks", ".", "printOutput", "(", "\"Processing match: \"", "+", "match", ")", ";", "callbacks", ".", "printOutput", "(", "\" start: \"", "+", "match", ".", "getStart", "(", ")", "+", "\" end: \"", "+", "match", ".", "getEnd", "(", ")", "+", "\" full match: \"", "+", "match", ".", "getFullMatch", "(", ")", "+", "\" group: \"", "+", "match", ".", "getMatchGroup", "(", ")", ")", ";", "//add a marker for code highlighting", "startStop", ".", "add", "(", "new", "int", "[", "]", "{", "match", ".", "getStart", "(", ")", ",", "match", ".", "getEnd", "(", ")", "}", ")", ";", "}", "issues", ".", "add", "(", "getScanIssue", "(", "baseRequestResponse", ",", "matches", ",", "startStop", ")", ")", ";", "callbacks", ".", "printOutput", "(", "\"issues: \"", "+", "issues", ".", "size", "(", ")", ")", ";", "}", "return", "issues", ";", "}" ]
Process scanner matches into a list of reportable issues. @param matches A list of matches found by the scanner @param baseRequestResponse The request/response object that was scanned @return the final list of scanner issues to be reported, or null if no issues are found.
[ "Process", "scanner", "matches", "into", "a", "list", "of", "reportable", "issues", "." ]
5e34a6b9147f5705382f98049dd9e4f387b78629
https://github.com/augustd/burp-suite-utils/blob/5e34a6b9147f5705382f98049dd9e4f387b78629/src/main/java/com/codemagi/burp/PassiveScan.java#L150-L167
10,066
omadahealth/TypefaceView
lib/src/main/java/com/github/omadahealth/typefaceview/TypefaceEditText.java
TypefaceEditText.setCustomTypeface
private void setCustomTypeface(Context context, AttributeSet attrs) { DEFAULT_TYPEFACE = TypefaceType.getDefaultTypeface(context); //Typeface.createFromAsset doesn't work in the layout editor. Skipping... if (isInEditMode() || attrs == null || Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { return; } TypedArray styledAttrs = context.obtainStyledAttributes(attrs, R.styleable.TypefaceView); Integer fontInt = styledAttrs.getInt(R.styleable.TypefaceView_tv_typeface, DEFAULT_TYPEFACE); styledAttrs.recycle(); mCurrentTypeface = TypefaceType.getTypeface(fontInt); Typeface typeface = getFont(context, mCurrentTypeface.getAssetFileName()); setTypeface(typeface); }
java
private void setCustomTypeface(Context context, AttributeSet attrs) { DEFAULT_TYPEFACE = TypefaceType.getDefaultTypeface(context); //Typeface.createFromAsset doesn't work in the layout editor. Skipping... if (isInEditMode() || attrs == null || Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { return; } TypedArray styledAttrs = context.obtainStyledAttributes(attrs, R.styleable.TypefaceView); Integer fontInt = styledAttrs.getInt(R.styleable.TypefaceView_tv_typeface, DEFAULT_TYPEFACE); styledAttrs.recycle(); mCurrentTypeface = TypefaceType.getTypeface(fontInt); Typeface typeface = getFont(context, mCurrentTypeface.getAssetFileName()); setTypeface(typeface); }
[ "private", "void", "setCustomTypeface", "(", "Context", "context", ",", "AttributeSet", "attrs", ")", "{", "DEFAULT_TYPEFACE", "=", "TypefaceType", ".", "getDefaultTypeface", "(", "context", ")", ";", "//Typeface.createFromAsset doesn't work in the layout editor. Skipping...", "if", "(", "isInEditMode", "(", ")", "||", "attrs", "==", "null", "||", "Build", ".", "VERSION", ".", "SDK_INT", "<", "Build", ".", "VERSION_CODES", ".", "HONEYCOMB", ")", "{", "return", ";", "}", "TypedArray", "styledAttrs", "=", "context", ".", "obtainStyledAttributes", "(", "attrs", ",", "R", ".", "styleable", ".", "TypefaceView", ")", ";", "Integer", "fontInt", "=", "styledAttrs", ".", "getInt", "(", "R", ".", "styleable", ".", "TypefaceView_tv_typeface", ",", "DEFAULT_TYPEFACE", ")", ";", "styledAttrs", ".", "recycle", "(", ")", ";", "mCurrentTypeface", "=", "TypefaceType", ".", "getTypeface", "(", "fontInt", ")", ";", "Typeface", "typeface", "=", "getFont", "(", "context", ",", "mCurrentTypeface", ".", "getAssetFileName", "(", ")", ")", ";", "setTypeface", "(", "typeface", ")", ";", "}" ]
Sets the typeface for the view @param context @param attrs
[ "Sets", "the", "typeface", "for", "the", "view" ]
9a36a67b0fb26584c3e20a24f8f0bafad6a0badd
https://github.com/omadahealth/TypefaceView/blob/9a36a67b0fb26584c3e20a24f8f0bafad6a0badd/lib/src/main/java/com/github/omadahealth/typefaceview/TypefaceEditText.java#L81-L96
10,067
omadahealth/TypefaceView
lib/src/main/java/com/github/omadahealth/typefaceview/TypefaceEditText.java
TypefaceEditText.getFont
public static Typeface getFont(Context context, String fontName) { synchronized (cache) { if (!cache.containsKey(fontName)) { try { Typeface t = Typeface.createFromAsset(context.getAssets(), fontName); cache.put(fontName, t); } catch (Exception e) { return null; } } return cache.get(fontName); } }
java
public static Typeface getFont(Context context, String fontName) { synchronized (cache) { if (!cache.containsKey(fontName)) { try { Typeface t = Typeface.createFromAsset(context.getAssets(), fontName); cache.put(fontName, t); } catch (Exception e) { return null; } } return cache.get(fontName); } }
[ "public", "static", "Typeface", "getFont", "(", "Context", "context", ",", "String", "fontName", ")", "{", "synchronized", "(", "cache", ")", "{", "if", "(", "!", "cache", ".", "containsKey", "(", "fontName", ")", ")", "{", "try", "{", "Typeface", "t", "=", "Typeface", ".", "createFromAsset", "(", "context", ".", "getAssets", "(", ")", ",", "fontName", ")", ";", "cache", ".", "put", "(", "fontName", ",", "t", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "return", "null", ";", "}", "}", "return", "cache", ".", "get", "(", "fontName", ")", ";", "}", "}" ]
Avoid reloading assets every time
[ "Avoid", "reloading", "assets", "every", "time" ]
9a36a67b0fb26584c3e20a24f8f0bafad6a0badd
https://github.com/omadahealth/TypefaceView/blob/9a36a67b0fb26584c3e20a24f8f0bafad6a0badd/lib/src/main/java/com/github/omadahealth/typefaceview/TypefaceEditText.java#L101-L113
10,068
Inbot/inbot-utils
src/main/java/io/inbot/utils/PasswordHash.java
PasswordHash.createHash
public static String createHash(char[] password) throws NoSuchAlgorithmException, InvalidKeySpecException { // Generate a random salt SecureRandom random = new SecureRandom(); byte[] salt = new byte[SALT_BYTE_SIZE]; random.nextBytes(salt); // Hash the password byte[] hash = pbkdf2(password, salt, PBKDF2_ITERATIONS, HASH_BYTE_SIZE); // format iterations:salt:hash return PBKDF2_ITERATIONS + ":" + toHex(salt) + ":" + toHex(hash); }
java
public static String createHash(char[] password) throws NoSuchAlgorithmException, InvalidKeySpecException { // Generate a random salt SecureRandom random = new SecureRandom(); byte[] salt = new byte[SALT_BYTE_SIZE]; random.nextBytes(salt); // Hash the password byte[] hash = pbkdf2(password, salt, PBKDF2_ITERATIONS, HASH_BYTE_SIZE); // format iterations:salt:hash return PBKDF2_ITERATIONS + ":" + toHex(salt) + ":" + toHex(hash); }
[ "public", "static", "String", "createHash", "(", "char", "[", "]", "password", ")", "throws", "NoSuchAlgorithmException", ",", "InvalidKeySpecException", "{", "// Generate a random salt", "SecureRandom", "random", "=", "new", "SecureRandom", "(", ")", ";", "byte", "[", "]", "salt", "=", "new", "byte", "[", "SALT_BYTE_SIZE", "]", ";", "random", ".", "nextBytes", "(", "salt", ")", ";", "// Hash the password", "byte", "[", "]", "hash", "=", "pbkdf2", "(", "password", ",", "salt", ",", "PBKDF2_ITERATIONS", ",", "HASH_BYTE_SIZE", ")", ";", "// format iterations:salt:hash", "return", "PBKDF2_ITERATIONS", "+", "\":\"", "+", "toHex", "(", "salt", ")", "+", "\":\"", "+", "toHex", "(", "hash", ")", ";", "}" ]
Returns a salted PBKDF2 hash of the password. @param password the password to hash @return a salted PBKDF2 hash of the password @throws NoSuchAlgorithmException if jdk does not support the algorithm @throws InvalidKeySpecException if the password or salt are invalid
[ "Returns", "a", "salted", "PBKDF2", "hash", "of", "the", "password", "." ]
3112bc08d4237e95fe0f8a219a5bbceb390d0505
https://github.com/Inbot/inbot-utils/blob/3112bc08d4237e95fe0f8a219a5bbceb390d0505/src/main/java/io/inbot/utils/PasswordHash.java#L78-L88
10,069
Inbot/inbot-utils
src/main/java/io/inbot/utils/PasswordHash.java
PasswordHash.slowEquals
private static boolean slowEquals(byte[] a, byte[] b) { int diff = a.length ^ b.length; for(int i = 0; i < a.length && i < b.length; i++) { diff |= a[i] ^ b[i]; } return diff == 0; }
java
private static boolean slowEquals(byte[] a, byte[] b) { int diff = a.length ^ b.length; for(int i = 0; i < a.length && i < b.length; i++) { diff |= a[i] ^ b[i]; } return diff == 0; }
[ "private", "static", "boolean", "slowEquals", "(", "byte", "[", "]", "a", ",", "byte", "[", "]", "b", ")", "{", "int", "diff", "=", "a", ".", "length", "^", "b", ".", "length", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "a", ".", "length", "&&", "i", "<", "b", ".", "length", ";", "i", "++", ")", "{", "diff", "|=", "a", "[", "i", "]", "^", "b", "[", "i", "]", ";", "}", "return", "diff", "==", "0", ";", "}" ]
Compares two byte arrays in length-constant time. This comparison method is used so that password hashes cannot be extracted from an on-line system using a timing attack and then attacked off-line. @param a the first byte array @param b the second byte array @return true if both byte arrays are the same, false if not
[ "Compares", "two", "byte", "arrays", "in", "length", "-", "constant", "time", ".", "This", "comparison", "method", "is", "used", "so", "that", "password", "hashes", "cannot", "be", "extracted", "from", "an", "on", "-", "line", "system", "using", "a", "timing", "attack", "and", "then", "attacked", "off", "-", "line", "." ]
3112bc08d4237e95fe0f8a219a5bbceb390d0505
https://github.com/Inbot/inbot-utils/blob/3112bc08d4237e95fe0f8a219a5bbceb390d0505/src/main/java/io/inbot/utils/PasswordHash.java#L140-L146
10,070
rometools/rome-modules
src/main/java/com/rometools/modules/activitystreams/types/Bookmark.java
Bookmark.setThumbnail
public void setThumbnail(final Link newthumbnail) { Link old = null; for (final Link l : getOtherLinks()) { if ("thumbnail".equals(l.getRel())) { old = l; break; } } if (old != null) { getOtherLinks().remove(old); newthumbnail.setRel("thumbnail"); } getOtherLinks().add(newthumbnail); }
java
public void setThumbnail(final Link newthumbnail) { Link old = null; for (final Link l : getOtherLinks()) { if ("thumbnail".equals(l.getRel())) { old = l; break; } } if (old != null) { getOtherLinks().remove(old); newthumbnail.setRel("thumbnail"); } getOtherLinks().add(newthumbnail); }
[ "public", "void", "setThumbnail", "(", "final", "Link", "newthumbnail", ")", "{", "Link", "old", "=", "null", ";", "for", "(", "final", "Link", "l", ":", "getOtherLinks", "(", ")", ")", "{", "if", "(", "\"thumbnail\"", ".", "equals", "(", "l", ".", "getRel", "(", ")", ")", ")", "{", "old", "=", "l", ";", "break", ";", "}", "}", "if", "(", "old", "!=", "null", ")", "{", "getOtherLinks", "(", ")", ".", "remove", "(", "old", ")", ";", "newthumbnail", ".", "setRel", "(", "\"thumbnail\"", ")", ";", "}", "getOtherLinks", "(", ")", ".", "add", "(", "newthumbnail", ")", ";", "}" ]
Set the value of thumbnail @param newthumbnail new value of thumbnail
[ "Set", "the", "value", "of", "thumbnail" ]
adc6be4ec33b8418c6cf01f15924f8daee37afc9
https://github.com/rometools/rome-modules/blob/adc6be4ec33b8418c6cf01f15924f8daee37afc9/src/main/java/com/rometools/modules/activitystreams/types/Bookmark.java#L102-L115
10,071
augustd/burp-suite-utils
src/main/java/com/codemagi/burp/parser/HttpRequest.java
HttpRequest.getCookies
public List<ICookie> getCookies() { String cookies = getHeader("Cookie"); List<ICookie> output = new ArrayList<>(); if (Utils.isEmpty(cookies)) { return output; } for (String cookieStr : cookies.split("[; ]+")) { String[] pair = cookieStr.split("=", 2); output.add(new Cookie(pair[0], pair[1])); } return output; }
java
public List<ICookie> getCookies() { String cookies = getHeader("Cookie"); List<ICookie> output = new ArrayList<>(); if (Utils.isEmpty(cookies)) { return output; } for (String cookieStr : cookies.split("[; ]+")) { String[] pair = cookieStr.split("=", 2); output.add(new Cookie(pair[0], pair[1])); } return output; }
[ "public", "List", "<", "ICookie", ">", "getCookies", "(", ")", "{", "String", "cookies", "=", "getHeader", "(", "\"Cookie\"", ")", ";", "List", "<", "ICookie", ">", "output", "=", "new", "ArrayList", "<>", "(", ")", ";", "if", "(", "Utils", ".", "isEmpty", "(", "cookies", ")", ")", "{", "return", "output", ";", "}", "for", "(", "String", "cookieStr", ":", "cookies", ".", "split", "(", "\"[; ]+\"", ")", ")", "{", "String", "[", "]", "pair", "=", "cookieStr", ".", "split", "(", "\"=\"", ",", "2", ")", ";", "output", ".", "add", "(", "new", "Cookie", "(", "pair", "[", "0", "]", ",", "pair", "[", "1", "]", ")", ")", ";", "}", "return", "output", ";", "}" ]
Gets the value of the Cookie header @return A list containing Cookie objects parsed from the internal string representation
[ "Gets", "the", "value", "of", "the", "Cookie", "header" ]
5e34a6b9147f5705382f98049dd9e4f387b78629
https://github.com/augustd/burp-suite-utils/blob/5e34a6b9147f5705382f98049dd9e4f387b78629/src/main/java/com/codemagi/burp/parser/HttpRequest.java#L250-L263
10,072
augustd/burp-suite-utils
src/main/java/com/codemagi/burp/parser/HttpRequest.java
HttpRequest.setParameter
public void setParameter(String name, String value) { sortedParams = null; parameters.add(new Parameter(name, value)); }
java
public void setParameter(String name, String value) { sortedParams = null; parameters.add(new Parameter(name, value)); }
[ "public", "void", "setParameter", "(", "String", "name", ",", "String", "value", ")", "{", "sortedParams", "=", "null", ";", "parameters", ".", "add", "(", "new", "Parameter", "(", "name", ",", "value", ")", ")", ";", "}" ]
Sets a parameter value based on its name. @param name The parameter name to set @param value The parameter value to set
[ "Sets", "a", "parameter", "value", "based", "on", "its", "name", "." ]
5e34a6b9147f5705382f98049dd9e4f387b78629
https://github.com/augustd/burp-suite-utils/blob/5e34a6b9147f5705382f98049dd9e4f387b78629/src/main/java/com/codemagi/burp/parser/HttpRequest.java#L309-L312
10,073
augustd/burp-suite-utils
src/main/java/com/codemagi/burp/parser/HttpRequest.java
HttpRequest.parseParameters
private void parseParameters(String input) { for (String param : input.split("&")) { String[] pair = param.split("="); String name = (pair.length > 0) ? pair[0] : null; String value = (pair.length > 1) ? pair[1] : null; if (name != null) { setParameter(name, value); } } }
java
private void parseParameters(String input) { for (String param : input.split("&")) { String[] pair = param.split("="); String name = (pair.length > 0) ? pair[0] : null; String value = (pair.length > 1) ? pair[1] : null; if (name != null) { setParameter(name, value); } } }
[ "private", "void", "parseParameters", "(", "String", "input", ")", "{", "for", "(", "String", "param", ":", "input", ".", "split", "(", "\"&\"", ")", ")", "{", "String", "[", "]", "pair", "=", "param", ".", "split", "(", "\"=\"", ")", ";", "String", "name", "=", "(", "pair", ".", "length", ">", "0", ")", "?", "pair", "[", "0", "]", ":", "null", ";", "String", "value", "=", "(", "pair", ".", "length", ">", "1", ")", "?", "pair", "[", "1", "]", ":", "null", ";", "if", "(", "name", "!=", "null", ")", "{", "setParameter", "(", "name", ",", "value", ")", ";", "}", "}", "}" ]
Parses a String of HTTP parameters into the internal parameters data structure. No input checking or decoding is performed! @param input A String of HTTP parameters in the form of: name1=value1&name2=value2&...
[ "Parses", "a", "String", "of", "HTTP", "parameters", "into", "the", "internal", "parameters", "data", "structure", ".", "No", "input", "checking", "or", "decoding", "is", "performed!" ]
5e34a6b9147f5705382f98049dd9e4f387b78629
https://github.com/augustd/burp-suite-utils/blob/5e34a6b9147f5705382f98049dd9e4f387b78629/src/main/java/com/codemagi/burp/parser/HttpRequest.java#L488-L499
10,074
Inbot/inbot-utils
src/main/java/io/inbot/utils/JwtVerificationService.java
JwtVerificationService.verify
public void verify(String token, Consumer<Verification> verificationConsumer) throws JWTVerificationException, IllegalArgumentException { Verification verifierBuilder = JWT.require(Algorithm.ECDSA512(ecPublicKey, null)) .withIssuer(issuer); // apply any custom verififaction verificationConsumer.accept(verifierBuilder); JWTVerifier verifier = verifierBuilder.build(); verifier.verify(token); }
java
public void verify(String token, Consumer<Verification> verificationConsumer) throws JWTVerificationException, IllegalArgumentException { Verification verifierBuilder = JWT.require(Algorithm.ECDSA512(ecPublicKey, null)) .withIssuer(issuer); // apply any custom verififaction verificationConsumer.accept(verifierBuilder); JWTVerifier verifier = verifierBuilder.build(); verifier.verify(token); }
[ "public", "void", "verify", "(", "String", "token", ",", "Consumer", "<", "Verification", ">", "verificationConsumer", ")", "throws", "JWTVerificationException", ",", "IllegalArgumentException", "{", "Verification", "verifierBuilder", "=", "JWT", ".", "require", "(", "Algorithm", ".", "ECDSA512", "(", "ecPublicKey", ",", "null", ")", ")", ".", "withIssuer", "(", "issuer", ")", ";", "// apply any custom verififaction", "verificationConsumer", ".", "accept", "(", "verifierBuilder", ")", ";", "JWTVerifier", "verifier", "=", "verifierBuilder", ".", "build", "(", ")", ";", "verifier", ".", "verify", "(", "token", ")", ";", "}" ]
Verifies the token. @param token a jwt token. @param verificationConsumer a way for you to verify claims by passing in a lambda function that accepts a Verification on which you can call e.g. withSubject, withClaim, etc. @throws JWTVerificationException if not valid @throws IllegalArgumentException if token is malformed
[ "Verifies", "the", "token", "." ]
3112bc08d4237e95fe0f8a219a5bbceb390d0505
https://github.com/Inbot/inbot-utils/blob/3112bc08d4237e95fe0f8a219a5bbceb390d0505/src/main/java/io/inbot/utils/JwtVerificationService.java#L46-L53
10,075
craftercms/deployer
src/main/java/org/craftercms/deployer/impl/rest/TargetController.java
TargetController.getPendingDeployments
@RequestMapping(value = GET_PENDING_DEPLOYMENTS_URL, method = RequestMethod.GET) public ResponseEntity<Collection<Deployment>> getPendingDeployments(@PathVariable(ENV_PATH_VAR_NAME) String env, @PathVariable(SITE_NAME_PATH_VAR_NAME) String siteName) throws DeployerException { Target target = targetService.getTarget(env, siteName); Collection<Deployment> deployments = target.getPendingDeployments(); return new ResponseEntity<>(deployments, RestServiceUtils.setLocationHeader(new HttpHeaders(), BASE_URL +GET_PENDING_DEPLOYMENTS_URL, env, siteName), HttpStatus.OK); }
java
@RequestMapping(value = GET_PENDING_DEPLOYMENTS_URL, method = RequestMethod.GET) public ResponseEntity<Collection<Deployment>> getPendingDeployments(@PathVariable(ENV_PATH_VAR_NAME) String env, @PathVariable(SITE_NAME_PATH_VAR_NAME) String siteName) throws DeployerException { Target target = targetService.getTarget(env, siteName); Collection<Deployment> deployments = target.getPendingDeployments(); return new ResponseEntity<>(deployments, RestServiceUtils.setLocationHeader(new HttpHeaders(), BASE_URL +GET_PENDING_DEPLOYMENTS_URL, env, siteName), HttpStatus.OK); }
[ "@", "RequestMapping", "(", "value", "=", "GET_PENDING_DEPLOYMENTS_URL", ",", "method", "=", "RequestMethod", ".", "GET", ")", "public", "ResponseEntity", "<", "Collection", "<", "Deployment", ">", ">", "getPendingDeployments", "(", "@", "PathVariable", "(", "ENV_PATH_VAR_NAME", ")", "String", "env", ",", "@", "PathVariable", "(", "SITE_NAME_PATH_VAR_NAME", ")", "String", "siteName", ")", "throws", "DeployerException", "{", "Target", "target", "=", "targetService", ".", "getTarget", "(", "env", ",", "siteName", ")", ";", "Collection", "<", "Deployment", ">", "deployments", "=", "target", ".", "getPendingDeployments", "(", ")", ";", "return", "new", "ResponseEntity", "<>", "(", "deployments", ",", "RestServiceUtils", ".", "setLocationHeader", "(", "new", "HttpHeaders", "(", ")", ",", "BASE_URL", "+", "GET_PENDING_DEPLOYMENTS_URL", ",", "env", ",", "siteName", ")", ",", "HttpStatus", ".", "OK", ")", ";", "}" ]
Gets the pending deployments for a target. @param env the target's environment @param siteName the target's site name @return the pending deployments for the target @throws DeployerException if an error occurred
[ "Gets", "the", "pending", "deployments", "for", "a", "target", "." ]
3ed446e3cc8af1055de2de6f871907f90ef27f63
https://github.com/craftercms/deployer/blob/3ed446e3cc8af1055de2de6f871907f90ef27f63/src/main/java/org/craftercms/deployer/impl/rest/TargetController.java#L268-L279
10,076
craftercms/deployer
src/main/java/org/craftercms/deployer/impl/rest/TargetController.java
TargetController.getCurrentDeployment
@RequestMapping(value = GET_CURRENT_DEPLOYMENT_URL, method = RequestMethod.GET) public ResponseEntity<Deployment> getCurrentDeployment(@PathVariable(ENV_PATH_VAR_NAME) String env, @PathVariable(SITE_NAME_PATH_VAR_NAME) String siteName) throws DeployerException { Target target = targetService.getTarget(env, siteName); Deployment deployment = target.getCurrentDeployment(); return new ResponseEntity<>(deployment, RestServiceUtils.setLocationHeader(new HttpHeaders(), BASE_URL + GET_CURRENT_DEPLOYMENT_URL, env, siteName), HttpStatus.OK); }
java
@RequestMapping(value = GET_CURRENT_DEPLOYMENT_URL, method = RequestMethod.GET) public ResponseEntity<Deployment> getCurrentDeployment(@PathVariable(ENV_PATH_VAR_NAME) String env, @PathVariable(SITE_NAME_PATH_VAR_NAME) String siteName) throws DeployerException { Target target = targetService.getTarget(env, siteName); Deployment deployment = target.getCurrentDeployment(); return new ResponseEntity<>(deployment, RestServiceUtils.setLocationHeader(new HttpHeaders(), BASE_URL + GET_CURRENT_DEPLOYMENT_URL, env, siteName), HttpStatus.OK); }
[ "@", "RequestMapping", "(", "value", "=", "GET_CURRENT_DEPLOYMENT_URL", ",", "method", "=", "RequestMethod", ".", "GET", ")", "public", "ResponseEntity", "<", "Deployment", ">", "getCurrentDeployment", "(", "@", "PathVariable", "(", "ENV_PATH_VAR_NAME", ")", "String", "env", ",", "@", "PathVariable", "(", "SITE_NAME_PATH_VAR_NAME", ")", "String", "siteName", ")", "throws", "DeployerException", "{", "Target", "target", "=", "targetService", ".", "getTarget", "(", "env", ",", "siteName", ")", ";", "Deployment", "deployment", "=", "target", ".", "getCurrentDeployment", "(", ")", ";", "return", "new", "ResponseEntity", "<>", "(", "deployment", ",", "RestServiceUtils", ".", "setLocationHeader", "(", "new", "HttpHeaders", "(", ")", ",", "BASE_URL", "+", "GET_CURRENT_DEPLOYMENT_URL", ",", "env", ",", "siteName", ")", ",", "HttpStatus", ".", "OK", ")", ";", "}" ]
Gets the current deployment for a target. @param env the target's environment @param siteName the target's site name @return the pending and current deployments for the target @throws DeployerException if an error occurred
[ "Gets", "the", "current", "deployment", "for", "a", "target", "." ]
3ed446e3cc8af1055de2de6f871907f90ef27f63
https://github.com/craftercms/deployer/blob/3ed446e3cc8af1055de2de6f871907f90ef27f63/src/main/java/org/craftercms/deployer/impl/rest/TargetController.java#L291-L302
10,077
augustd/burp-suite-utils
src/main/java/com/codemagi/burp/RuleTableComponent.java
RuleTableComponent.loadMatchRules
private boolean loadMatchRules(String rulesUrl) { //load match rules from file try { //check for file URL if (rulesUrl != null && rulesUrl.toLowerCase().startsWith("file:")) { return loadMatchRulesFromFile(rulesUrl); } //request match rules from remote URL mCallbacks.printOutput("Loading match rules from: " + rulesUrl); URL url = new URL(rulesUrl); IHttpService service = new HttpService(url); HttpRequest request = new HttpRequest(url); byte[] responseBytes = mCallbacks.makeHttpRequest( service.getHost(), service.getPort(), HttpService.PROTOCOL_HTTPS.equalsIgnoreCase(service.getProtocol()), request.getBytes()); //parse the response if (responseBytes == null) return false; //no response received from server HttpResponse response = HttpResponse.parseMessage(responseBytes); //read match rules from the response Reader is = new StringReader(response.getBody()); BufferedReader reader = new BufferedReader(is); processMatchRules(reader); return true; } catch (IOException e) { scan.printStackTrace(e); } catch (Exception e) { scan.printStackTrace(e); } return false; }
java
private boolean loadMatchRules(String rulesUrl) { //load match rules from file try { //check for file URL if (rulesUrl != null && rulesUrl.toLowerCase().startsWith("file:")) { return loadMatchRulesFromFile(rulesUrl); } //request match rules from remote URL mCallbacks.printOutput("Loading match rules from: " + rulesUrl); URL url = new URL(rulesUrl); IHttpService service = new HttpService(url); HttpRequest request = new HttpRequest(url); byte[] responseBytes = mCallbacks.makeHttpRequest( service.getHost(), service.getPort(), HttpService.PROTOCOL_HTTPS.equalsIgnoreCase(service.getProtocol()), request.getBytes()); //parse the response if (responseBytes == null) return false; //no response received from server HttpResponse response = HttpResponse.parseMessage(responseBytes); //read match rules from the response Reader is = new StringReader(response.getBody()); BufferedReader reader = new BufferedReader(is); processMatchRules(reader); return true; } catch (IOException e) { scan.printStackTrace(e); } catch (Exception e) { scan.printStackTrace(e); } return false; }
[ "private", "boolean", "loadMatchRules", "(", "String", "rulesUrl", ")", "{", "//load match rules from file", "try", "{", "//check for file URL ", "if", "(", "rulesUrl", "!=", "null", "&&", "rulesUrl", ".", "toLowerCase", "(", ")", ".", "startsWith", "(", "\"file:\"", ")", ")", "{", "return", "loadMatchRulesFromFile", "(", "rulesUrl", ")", ";", "}", "//request match rules from remote URL ", "mCallbacks", ".", "printOutput", "(", "\"Loading match rules from: \"", "+", "rulesUrl", ")", ";", "URL", "url", "=", "new", "URL", "(", "rulesUrl", ")", ";", "IHttpService", "service", "=", "new", "HttpService", "(", "url", ")", ";", "HttpRequest", "request", "=", "new", "HttpRequest", "(", "url", ")", ";", "byte", "[", "]", "responseBytes", "=", "mCallbacks", ".", "makeHttpRequest", "(", "service", ".", "getHost", "(", ")", ",", "service", ".", "getPort", "(", ")", ",", "HttpService", ".", "PROTOCOL_HTTPS", ".", "equalsIgnoreCase", "(", "service", ".", "getProtocol", "(", ")", ")", ",", "request", ".", "getBytes", "(", ")", ")", ";", "//parse the response", "if", "(", "responseBytes", "==", "null", ")", "return", "false", ";", "//no response received from server ", "HttpResponse", "response", "=", "HttpResponse", ".", "parseMessage", "(", "responseBytes", ")", ";", "//read match rules from the response", "Reader", "is", "=", "new", "StringReader", "(", "response", ".", "getBody", "(", ")", ")", ";", "BufferedReader", "reader", "=", "new", "BufferedReader", "(", "is", ")", ";", "processMatchRules", "(", "reader", ")", ";", "return", "true", ";", "}", "catch", "(", "IOException", "e", ")", "{", "scan", ".", "printStackTrace", "(", "e", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "scan", ".", "printStackTrace", "(", "e", ")", ";", "}", "return", "false", ";", "}" ]
Load match rules from a URL
[ "Load", "match", "rules", "from", "a", "URL" ]
5e34a6b9147f5705382f98049dd9e4f387b78629
https://github.com/augustd/burp-suite-utils/blob/5e34a6b9147f5705382f98049dd9e4f387b78629/src/main/java/com/codemagi/burp/RuleTableComponent.java#L105-L143
10,078
augustd/burp-suite-utils
src/main/java/com/codemagi/burp/RuleTableComponent.java
RuleTableComponent.loadMatchRulesFromJar
private boolean loadMatchRulesFromJar(String rulesUrl) { //load match rules from a local file try { mCallbacks.printOutput("Loading match rules from local jar: " + rulesUrl); InputStream in = getClass().getClassLoader().getResourceAsStream(rulesUrl); BufferedReader reader = new BufferedReader(new InputStreamReader(in)); processMatchRules(reader); return true; } catch (IOException e) { scan.printStackTrace(e); } catch (NumberFormatException e) { scan.printStackTrace(e); } return false; }
java
private boolean loadMatchRulesFromJar(String rulesUrl) { //load match rules from a local file try { mCallbacks.printOutput("Loading match rules from local jar: " + rulesUrl); InputStream in = getClass().getClassLoader().getResourceAsStream(rulesUrl); BufferedReader reader = new BufferedReader(new InputStreamReader(in)); processMatchRules(reader); return true; } catch (IOException e) { scan.printStackTrace(e); } catch (NumberFormatException e) { scan.printStackTrace(e); } return false; }
[ "private", "boolean", "loadMatchRulesFromJar", "(", "String", "rulesUrl", ")", "{", "//load match rules from a local file", "try", "{", "mCallbacks", ".", "printOutput", "(", "\"Loading match rules from local jar: \"", "+", "rulesUrl", ")", ";", "InputStream", "in", "=", "getClass", "(", ")", ".", "getClassLoader", "(", ")", ".", "getResourceAsStream", "(", "rulesUrl", ")", ";", "BufferedReader", "reader", "=", "new", "BufferedReader", "(", "new", "InputStreamReader", "(", "in", ")", ")", ";", "processMatchRules", "(", "reader", ")", ";", "return", "true", ";", "}", "catch", "(", "IOException", "e", ")", "{", "scan", ".", "printStackTrace", "(", "e", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "scan", ".", "printStackTrace", "(", "e", ")", ";", "}", "return", "false", ";", "}" ]
Load match rules from within the jar
[ "Load", "match", "rules", "from", "within", "the", "jar" ]
5e34a6b9147f5705382f98049dd9e4f387b78629
https://github.com/augustd/burp-suite-utils/blob/5e34a6b9147f5705382f98049dd9e4f387b78629/src/main/java/com/codemagi/burp/RuleTableComponent.java#L170-L188
10,079
augustd/burp-suite-utils
src/main/java/com/codemagi/burp/RuleTableComponent.java
RuleTableComponent.loadMatchRulesFromFile
private boolean loadMatchRulesFromFile(String rulesUrl) { //load match rules from a local file try { mCallbacks.printOutput("Loading match rules from file: " + rulesUrl); InputStream in = new URL(rulesUrl).openStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(in, "UTF-8")); processMatchRules(reader); return true; } catch (IOException e) { scan.printStackTrace(e); } catch (NumberFormatException e) { scan.printStackTrace(e); } return false; }
java
private boolean loadMatchRulesFromFile(String rulesUrl) { //load match rules from a local file try { mCallbacks.printOutput("Loading match rules from file: " + rulesUrl); InputStream in = new URL(rulesUrl).openStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(in, "UTF-8")); processMatchRules(reader); return true; } catch (IOException e) { scan.printStackTrace(e); } catch (NumberFormatException e) { scan.printStackTrace(e); } return false; }
[ "private", "boolean", "loadMatchRulesFromFile", "(", "String", "rulesUrl", ")", "{", "//load match rules from a local file", "try", "{", "mCallbacks", ".", "printOutput", "(", "\"Loading match rules from file: \"", "+", "rulesUrl", ")", ";", "InputStream", "in", "=", "new", "URL", "(", "rulesUrl", ")", ".", "openStream", "(", ")", ";", "BufferedReader", "reader", "=", "new", "BufferedReader", "(", "new", "InputStreamReader", "(", "in", ",", "\"UTF-8\"", ")", ")", ";", "processMatchRules", "(", "reader", ")", ";", "return", "true", ";", "}", "catch", "(", "IOException", "e", ")", "{", "scan", ".", "printStackTrace", "(", "e", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "scan", ".", "printStackTrace", "(", "e", ")", ";", "}", "return", "false", ";", "}" ]
Load match rules from a file URL
[ "Load", "match", "rules", "from", "a", "file", "URL" ]
5e34a6b9147f5705382f98049dd9e4f387b78629
https://github.com/augustd/burp-suite-utils/blob/5e34a6b9147f5705382f98049dd9e4f387b78629/src/main/java/com/codemagi/burp/RuleTableComponent.java#L193-L211
10,080
rometools/rome-modules
src/main/java/com/rometools/modules/base/types/GenderEnumeration.java
GenderEnumeration.findByValue
public static GenderEnumeration findByValue(final String value) { if (value == null) { return null; } final String gender = value.toUpperCase(); if (gender.charAt(0) == 'M') { return GenderEnumeration.MALE; } else if (gender.charAt(0) == 'F') { return GenderEnumeration.FEMALE; } else { return null; } }
java
public static GenderEnumeration findByValue(final String value) { if (value == null) { return null; } final String gender = value.toUpperCase(); if (gender.charAt(0) == 'M') { return GenderEnumeration.MALE; } else if (gender.charAt(0) == 'F') { return GenderEnumeration.FEMALE; } else { return null; } }
[ "public", "static", "GenderEnumeration", "findByValue", "(", "final", "String", "value", ")", "{", "if", "(", "value", "==", "null", ")", "{", "return", "null", ";", "}", "final", "String", "gender", "=", "value", ".", "toUpperCase", "(", ")", ";", "if", "(", "gender", ".", "charAt", "(", "0", ")", "==", "'", "'", ")", "{", "return", "GenderEnumeration", ".", "MALE", ";", "}", "else", "if", "(", "gender", ".", "charAt", "(", "0", ")", "==", "'", "'", ")", "{", "return", "GenderEnumeration", ".", "FEMALE", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
Returns the proper instance based on the string value
[ "Returns", "the", "proper", "instance", "based", "on", "the", "string", "value" ]
adc6be4ec33b8418c6cf01f15924f8daee37afc9
https://github.com/rometools/rome-modules/blob/adc6be4ec33b8418c6cf01f15924f8daee37afc9/src/main/java/com/rometools/modules/base/types/GenderEnumeration.java#L60-L74
10,081
Inbot/inbot-utils
src/main/java/io/inbot/utils/HashUtils.java
HashUtils.bitString
public static String bitString(long number) { return String.format(Locale.ROOT,"%064d", new BigInteger(Long.toBinaryString(number))); }
java
public static String bitString(long number) { return String.format(Locale.ROOT,"%064d", new BigInteger(Long.toBinaryString(number))); }
[ "public", "static", "String", "bitString", "(", "long", "number", ")", "{", "return", "String", ".", "format", "(", "Locale", ".", "ROOT", ",", "\"%064d\"", ",", "new", "BigInteger", "(", "Long", ".", "toBinaryString", "(", "number", ")", ")", ")", ";", "}" ]
Get a String representations of the bit in a 64 bit long. @param number the long you want rendered as bits @return formatted string with raw bits for the long number
[ "Get", "a", "String", "representations", "of", "the", "bit", "in", "a", "64", "bit", "long", "." ]
3112bc08d4237e95fe0f8a219a5bbceb390d0505
https://github.com/Inbot/inbot-utils/blob/3112bc08d4237e95fe0f8a219a5bbceb390d0505/src/main/java/io/inbot/utils/HashUtils.java#L131-L133
10,082
kenyee/android-ddp-client
src/com/keysolutions/ddpclient/android/MeteorAuthCommands.java
MeteorAuthCommands.login
public void login(String token) { TokenAuth tokenAuth = new TokenAuth(token); Object[] methodArgs = new Object[1]; methodArgs[0] = tokenAuth; getDDP().call("login", methodArgs, new DDPListener() { @Override public void onResult(Map<String, Object> jsonFields) { handleLoginResult(jsonFields); } }); }
java
public void login(String token) { TokenAuth tokenAuth = new TokenAuth(token); Object[] methodArgs = new Object[1]; methodArgs[0] = tokenAuth; getDDP().call("login", methodArgs, new DDPListener() { @Override public void onResult(Map<String, Object> jsonFields) { handleLoginResult(jsonFields); } }); }
[ "public", "void", "login", "(", "String", "token", ")", "{", "TokenAuth", "tokenAuth", "=", "new", "TokenAuth", "(", "token", ")", ";", "Object", "[", "]", "methodArgs", "=", "new", "Object", "[", "1", "]", ";", "methodArgs", "[", "0", "]", "=", "tokenAuth", ";", "getDDP", "(", ")", ".", "call", "(", "\"login\"", ",", "methodArgs", ",", "new", "DDPListener", "(", ")", "{", "@", "Override", "public", "void", "onResult", "(", "Map", "<", "String", ",", "Object", ">", "jsonFields", ")", "{", "handleLoginResult", "(", "jsonFields", ")", ";", "}", "}", ")", ";", "}" ]
Logs in using resume token @param token resume token
[ "Logs", "in", "using", "resume", "token" ]
6ab416e415570a03f96c383497144dd742de3f08
https://github.com/kenyee/android-ddp-client/blob/6ab416e415570a03f96c383497144dd742de3f08/src/com/keysolutions/ddpclient/android/MeteorAuthCommands.java#L38-L48
10,083
kenyee/android-ddp-client
src/com/keysolutions/ddpclient/android/MeteorAuthCommands.java
MeteorAuthCommands.registerUser
public boolean registerUser(String username, String email, String password) { if (((username == null) && (email == null)) || (password == null)) { return false; } Object[] methodArgs = new Object[1]; Map<String,Object> options = new HashMap<>(); methodArgs[0] = options; if (username != null) { options.put("username", username); } if (email != null) { options.put("email", email); } options.put("password", password); getDDP().call("createUser", methodArgs, new DDPListener() { @Override public void onResult(Map<String, Object> jsonFields) { handleLoginResult(jsonFields); } }); return true; }
java
public boolean registerUser(String username, String email, String password) { if (((username == null) && (email == null)) || (password == null)) { return false; } Object[] methodArgs = new Object[1]; Map<String,Object> options = new HashMap<>(); methodArgs[0] = options; if (username != null) { options.put("username", username); } if (email != null) { options.put("email", email); } options.put("password", password); getDDP().call("createUser", methodArgs, new DDPListener() { @Override public void onResult(Map<String, Object> jsonFields) { handleLoginResult(jsonFields); } }); return true; }
[ "public", "boolean", "registerUser", "(", "String", "username", ",", "String", "email", ",", "String", "password", ")", "{", "if", "(", "(", "(", "username", "==", "null", ")", "&&", "(", "email", "==", "null", ")", ")", "||", "(", "password", "==", "null", ")", ")", "{", "return", "false", ";", "}", "Object", "[", "]", "methodArgs", "=", "new", "Object", "[", "1", "]", ";", "Map", "<", "String", ",", "Object", ">", "options", "=", "new", "HashMap", "<>", "(", ")", ";", "methodArgs", "[", "0", "]", "=", "options", ";", "if", "(", "username", "!=", "null", ")", "{", "options", ".", "put", "(", "\"username\"", ",", "username", ")", ";", "}", "if", "(", "email", "!=", "null", ")", "{", "options", ".", "put", "(", "\"email\"", ",", "email", ")", ";", "}", "options", ".", "put", "(", "\"password\"", ",", "password", ")", ";", "getDDP", "(", ")", ".", "call", "(", "\"createUser\"", ",", "methodArgs", ",", "new", "DDPListener", "(", ")", "{", "@", "Override", "public", "void", "onResult", "(", "Map", "<", "String", ",", "Object", ">", "jsonFields", ")", "{", "handleLoginResult", "(", "jsonFields", ")", ";", "}", "}", ")", ";", "return", "true", ";", "}" ]
Register's user into Meteor's accounts-password system @param username user's username (this or email has to be specified) @param email user's email (this or username has to be specified) @param password password @return true if create user called
[ "Register", "s", "user", "into", "Meteor", "s", "accounts", "-", "password", "system" ]
6ab416e415570a03f96c383497144dd742de3f08
https://github.com/kenyee/android-ddp-client/blob/6ab416e415570a03f96c383497144dd742de3f08/src/com/keysolutions/ddpclient/android/MeteorAuthCommands.java#L80-L102
10,084
kenyee/android-ddp-client
src/com/keysolutions/ddpclient/android/MeteorAuthCommands.java
MeteorAuthCommands.forgotPassword
public void forgotPassword(String email) { if (email == null) { return; } Object[] methodArgs = new Object[1]; Map<String,Object> options = new HashMap<>(); methodArgs[0] = options; options.put("email", email); getDDP().call("forgotPassword", methodArgs, new DDPListener() { @Override public void onResult(Map<String, Object> jsonFields) { handleLoginResult(jsonFields); } }); }
java
public void forgotPassword(String email) { if (email == null) { return; } Object[] methodArgs = new Object[1]; Map<String,Object> options = new HashMap<>(); methodArgs[0] = options; options.put("email", email); getDDP().call("forgotPassword", methodArgs, new DDPListener() { @Override public void onResult(Map<String, Object> jsonFields) { handleLoginResult(jsonFields); } }); }
[ "public", "void", "forgotPassword", "(", "String", "email", ")", "{", "if", "(", "email", "==", "null", ")", "{", "return", ";", "}", "Object", "[", "]", "methodArgs", "=", "new", "Object", "[", "1", "]", ";", "Map", "<", "String", ",", "Object", ">", "options", "=", "new", "HashMap", "<>", "(", ")", ";", "methodArgs", "[", "0", "]", "=", "options", ";", "options", ".", "put", "(", "\"email\"", ",", "email", ")", ";", "getDDP", "(", ")", ".", "call", "(", "\"forgotPassword\"", ",", "methodArgs", ",", "new", "DDPListener", "(", ")", "{", "@", "Override", "public", "void", "onResult", "(", "Map", "<", "String", ",", "Object", ">", "jsonFields", ")", "{", "handleLoginResult", "(", "jsonFields", ")", ";", "}", "}", ")", ";", "}" ]
Sends password reset mail to specified email address @param email email address of user
[ "Sends", "password", "reset", "mail", "to", "specified", "email", "address" ]
6ab416e415570a03f96c383497144dd742de3f08
https://github.com/kenyee/android-ddp-client/blob/6ab416e415570a03f96c383497144dd742de3f08/src/com/keysolutions/ddpclient/android/MeteorAuthCommands.java#L108-L123
10,085
cogroo/cogroo4
cogroo-ruta/src/main/java/org/cogroo/ruta/uima/AnnotatorUtil.java
AnnotatorUtil.getType
public static Type getType(TypeSystem typeSystem, String name) throws AnalysisEngineProcessException { Type type = typeSystem.getType(name); if (type == null) { throw new OpenNlpAnnotatorProcessException( ExceptionMessages.TYPE_NOT_FOUND, new Object[] {name}); } return type; }
java
public static Type getType(TypeSystem typeSystem, String name) throws AnalysisEngineProcessException { Type type = typeSystem.getType(name); if (type == null) { throw new OpenNlpAnnotatorProcessException( ExceptionMessages.TYPE_NOT_FOUND, new Object[] {name}); } return type; }
[ "public", "static", "Type", "getType", "(", "TypeSystem", "typeSystem", ",", "String", "name", ")", "throws", "AnalysisEngineProcessException", "{", "Type", "type", "=", "typeSystem", ".", "getType", "(", "name", ")", ";", "if", "(", "type", "==", "null", ")", "{", "throw", "new", "OpenNlpAnnotatorProcessException", "(", "ExceptionMessages", ".", "TYPE_NOT_FOUND", ",", "new", "Object", "[", "]", "{", "name", "}", ")", ";", "}", "return", "type", ";", "}" ]
Retrieves a type of the given name from the given type system. @param typeSystem @param name @return the type @throws AnalysisEngineProcessException
[ "Retrieves", "a", "type", "of", "the", "given", "name", "from", "the", "given", "type", "system", "." ]
b6228900c20c6b37eac10a03708a9669dd562f52
https://github.com/cogroo/cogroo4/blob/b6228900c20c6b37eac10a03708a9669dd562f52/cogroo-ruta/src/main/java/org/cogroo/ruta/uima/AnnotatorUtil.java#L50-L61
10,086
cogroo/cogroo4
cogroo-ruta/src/main/java/org/cogroo/ruta/uima/AnnotatorUtil.java
AnnotatorUtil.checkFeatureType
private static void checkFeatureType(Feature feature, String expectedType) throws AnalysisEngineProcessException { if (!feature.getRange().getName().equals(expectedType)) { throw new OpenNlpAnnotatorProcessException( ExceptionMessages.WRONG_FEATURE_TYPE, new Object[] {feature.getName(), expectedType }); } }
java
private static void checkFeatureType(Feature feature, String expectedType) throws AnalysisEngineProcessException { if (!feature.getRange().getName().equals(expectedType)) { throw new OpenNlpAnnotatorProcessException( ExceptionMessages.WRONG_FEATURE_TYPE, new Object[] {feature.getName(), expectedType }); } }
[ "private", "static", "void", "checkFeatureType", "(", "Feature", "feature", ",", "String", "expectedType", ")", "throws", "AnalysisEngineProcessException", "{", "if", "(", "!", "feature", ".", "getRange", "(", ")", ".", "getName", "(", ")", ".", "equals", "(", "expectedType", ")", ")", "{", "throw", "new", "OpenNlpAnnotatorProcessException", "(", "ExceptionMessages", ".", "WRONG_FEATURE_TYPE", ",", "new", "Object", "[", "]", "{", "feature", ".", "getName", "(", ")", ",", "expectedType", "}", ")", ";", "}", "}" ]
Checks if the given feature has the expected type otherwise an exception is thrown. @param feature @param expectedType @throws AnalysisEngineProcessException - if type does not match
[ "Checks", "if", "the", "given", "feature", "has", "the", "expected", "type", "otherwise", "an", "exception", "is", "thrown", "." ]
b6228900c20c6b37eac10a03708a9669dd562f52
https://github.com/cogroo/cogroo4/blob/b6228900c20c6b37eac10a03708a9669dd562f52/cogroo-ruta/src/main/java/org/cogroo/ruta/uima/AnnotatorUtil.java#L72-L81
10,087
cogroo/cogroo4
cogroo-ruta/src/main/java/org/cogroo/ruta/uima/AnnotatorUtil.java
AnnotatorUtil.getRequiredFeature
public static Feature getRequiredFeature(Type type, String featureName, String rangeType) throws AnalysisEngineProcessException { Feature feature = getRequiredFeature(type, featureName); checkFeatureType(feature, rangeType); return feature; }
java
public static Feature getRequiredFeature(Type type, String featureName, String rangeType) throws AnalysisEngineProcessException { Feature feature = getRequiredFeature(type, featureName); checkFeatureType(feature, rangeType); return feature; }
[ "public", "static", "Feature", "getRequiredFeature", "(", "Type", "type", ",", "String", "featureName", ",", "String", "rangeType", ")", "throws", "AnalysisEngineProcessException", "{", "Feature", "feature", "=", "getRequiredFeature", "(", "type", ",", "featureName", ")", ";", "checkFeatureType", "(", "feature", ",", "rangeType", ")", ";", "return", "feature", ";", "}" ]
Retrieves a required feature from the given type. @param type the type @param featureName the name of the feature @param rangeType the expected range type @return the requested parameter @throws AnalysisEngineProcessException
[ "Retrieves", "a", "required", "feature", "from", "the", "given", "type", "." ]
b6228900c20c6b37eac10a03708a9669dd562f52
https://github.com/cogroo/cogroo4/blob/b6228900c20c6b37eac10a03708a9669dd562f52/cogroo-ruta/src/main/java/org/cogroo/ruta/uima/AnnotatorUtil.java#L107-L115
10,088
cogroo/cogroo4
cogroo-ruta/src/main/java/org/cogroo/ruta/uima/AnnotatorUtil.java
AnnotatorUtil.getOptionalBooleanParameter
public static Boolean getOptionalBooleanParameter(UimaContext context, String parameter) throws ResourceInitializationException { Object value = getOptionalParameter(context, parameter); if (value instanceof Boolean) { return (Boolean) value; } else if (value == null) { return null; } else { throw new ResourceInitializationException( ExceptionMessages.MESSAGE_CATALOG, ExceptionMessages.WRONG_PARAMETER_TYPE, new Object[] {parameter, "Boolean"}); } }
java
public static Boolean getOptionalBooleanParameter(UimaContext context, String parameter) throws ResourceInitializationException { Object value = getOptionalParameter(context, parameter); if (value instanceof Boolean) { return (Boolean) value; } else if (value == null) { return null; } else { throw new ResourceInitializationException( ExceptionMessages.MESSAGE_CATALOG, ExceptionMessages.WRONG_PARAMETER_TYPE, new Object[] {parameter, "Boolean"}); } }
[ "public", "static", "Boolean", "getOptionalBooleanParameter", "(", "UimaContext", "context", ",", "String", "parameter", ")", "throws", "ResourceInitializationException", "{", "Object", "value", "=", "getOptionalParameter", "(", "context", ",", "parameter", ")", ";", "if", "(", "value", "instanceof", "Boolean", ")", "{", "return", "(", "Boolean", ")", "value", ";", "}", "else", "if", "(", "value", "==", "null", ")", "{", "return", "null", ";", "}", "else", "{", "throw", "new", "ResourceInitializationException", "(", "ExceptionMessages", ".", "MESSAGE_CATALOG", ",", "ExceptionMessages", ".", "WRONG_PARAMETER_TYPE", ",", "new", "Object", "[", "]", "{", "parameter", ",", "\"Boolean\"", "}", ")", ";", "}", "}" ]
Retrieves an optional parameter from the given context. @param context @param parameter @return the parameter or null if not set @throws ResourceInitializationException
[ "Retrieves", "an", "optional", "parameter", "from", "the", "given", "context", "." ]
b6228900c20c6b37eac10a03708a9669dd562f52
https://github.com/cogroo/cogroo4/blob/b6228900c20c6b37eac10a03708a9669dd562f52/cogroo-ruta/src/main/java/org/cogroo/ruta/uima/AnnotatorUtil.java#L407-L424
10,089
cogroo/cogroo4
cogroo-ruta/src/main/java/org/cogroo/ruta/uima/AnnotatorUtil.java
AnnotatorUtil.getResourceAsStream
public static InputStream getResourceAsStream(UimaContext context, String name) throws ResourceInitializationException { InputStream inResource = getOptionalResourceAsStream(context, name); if (inResource == null) { throw new ResourceInitializationException( ExceptionMessages.MESSAGE_CATALOG, ExceptionMessages.IO_ERROR_MODEL_READING, new Object[] { name + " could not be found!" }); } return inResource; }
java
public static InputStream getResourceAsStream(UimaContext context, String name) throws ResourceInitializationException { InputStream inResource = getOptionalResourceAsStream(context, name); if (inResource == null) { throw new ResourceInitializationException( ExceptionMessages.MESSAGE_CATALOG, ExceptionMessages.IO_ERROR_MODEL_READING, new Object[] { name + " could not be found!" }); } return inResource; }
[ "public", "static", "InputStream", "getResourceAsStream", "(", "UimaContext", "context", ",", "String", "name", ")", "throws", "ResourceInitializationException", "{", "InputStream", "inResource", "=", "getOptionalResourceAsStream", "(", "context", ",", "name", ")", ";", "if", "(", "inResource", "==", "null", ")", "{", "throw", "new", "ResourceInitializationException", "(", "ExceptionMessages", ".", "MESSAGE_CATALOG", ",", "ExceptionMessages", ".", "IO_ERROR_MODEL_READING", ",", "new", "Object", "[", "]", "{", "name", "+", "\" could not be found!\"", "}", ")", ";", "}", "return", "inResource", ";", "}" ]
Retrieves a resource as stream from the given context. @param context @param name @return the stream @throws ResourceInitializationException
[ "Retrieves", "a", "resource", "as", "stream", "from", "the", "given", "context", "." ]
b6228900c20c6b37eac10a03708a9669dd562f52
https://github.com/cogroo/cogroo4/blob/b6228900c20c6b37eac10a03708a9669dd562f52/cogroo-ruta/src/main/java/org/cogroo/ruta/uima/AnnotatorUtil.java#L451-L464
10,090
cogroo/cogroo4
cogroo-nlp/src/main/java/org/cogroo/formats/ad/ADContractionNameSampleStream.java
ADContractionNameSampleStream.process
private void process(Node node, List<String> sentence, List<Span> names) { if (node != null) { for (TreeElement element : node.getElements()) { if (element.isLeaf()) { processLeaf((Leaf) element, sentence, names); } else { process((Node) element, sentence, names); } } } }
java
private void process(Node node, List<String> sentence, List<Span> names) { if (node != null) { for (TreeElement element : node.getElements()) { if (element.isLeaf()) { processLeaf((Leaf) element, sentence, names); } else { process((Node) element, sentence, names); } } } }
[ "private", "void", "process", "(", "Node", "node", ",", "List", "<", "String", ">", "sentence", ",", "List", "<", "Span", ">", "names", ")", "{", "if", "(", "node", "!=", "null", ")", "{", "for", "(", "TreeElement", "element", ":", "node", ".", "getElements", "(", ")", ")", "{", "if", "(", "element", ".", "isLeaf", "(", ")", ")", "{", "processLeaf", "(", "(", "Leaf", ")", "element", ",", "sentence", ",", "names", ")", ";", "}", "else", "{", "process", "(", "(", "Node", ")", "element", ",", "sentence", ",", "names", ")", ";", "}", "}", "}", "}" ]
Recursive method to process a node in Arvores Deitadas format. @param node the node to be processed @param sentence the sentence tokens we got so far @param names the names we got so far
[ "Recursive", "method", "to", "process", "a", "node", "in", "Arvores", "Deitadas", "format", "." ]
b6228900c20c6b37eac10a03708a9669dd562f52
https://github.com/cogroo/cogroo4/blob/b6228900c20c6b37eac10a03708a9669dd562f52/cogroo-nlp/src/main/java/org/cogroo/formats/ad/ADContractionNameSampleStream.java#L142-L152
10,091
cogroo/cogroo4
cogroo-ruta/src/main/java/org/cogroo/ruta/uima/CoGrOOUIMA.java
CoGrOOUIMA.process
public void process(CAS tcas) { String text = tcas.getDocumentText(); Document document = new DocumentImpl(text); cogroo.analyze(document); for (Sentence sentence : document.getSentences()) { // create sentence annotations AnnotationFS sentenceAnn = tcas.createAnnotation(mSentenceType, sentence.getStart(), sentence.getEnd()); tcas.getIndexRepository().addFS(sentenceAnn); int sentenceOffset = sentence.getStart(); AnnotationFS[] tokenAnnotationArr = new AnnotationFS[sentence .getTokens().size()]; int i = 0; for (Token token : sentence.getTokens()) { // create token annotations tokenAnnotationArr[i] = tcas.createAnnotation(mTokenType, sentenceOffset + token.getStart(), sentenceOffset + token.getEnd()); // add POSTag annotations tokenAnnotationArr[i].setStringValue(this.mPosFeature, token.getPOSTag()); // add lexeme annotations tokenAnnotationArr[i].setStringValue(this.mLexemeFeature, token.getLexeme()); // add lemma annotations StringArrayFS lemmas = tcas.createStringArrayFS(token .getLemmas().length); lemmas.copyFromArray(token.getLemmas(), 0, 0, token.getLemmas().length); tokenAnnotationArr[i].setFeatureValue(this.mLemmaFeature, lemmas); tokenAnnotationArr[i].setStringValue(this.mFeaturesFeature, token.getFeatures()); tcas.getIndexRepository().addFS(tokenAnnotationArr[i]); i++; } // chunks for (Chunk chunk : sentence.getChunks()) { int start = sentence.getTokens().get(chunk.getStart()) .getStart() + sentenceOffset; int end = sentence.getTokens().get(chunk.getEnd() - 1).getEnd() + sentenceOffset; AnnotationFS chunkAnn = tcas.createAnnotation(mChunkType, start, end); chunkAnn.setStringValue(mChunkFeature, chunk.getTag()); if(chunk.getHeadIndex() >= 0) { chunkAnn.setFeatureValue(mChunkHead, tokenAnnotationArr[chunk.getHeadIndex()]); } tcas.getIndexRepository().addFS(chunkAnn); } // syntactic chunk for (SyntacticChunk sc : sentence.getSyntacticChunks()) { int start = sentence.getTokens().get(sc.getStart()).getStart() + sentenceOffset; int end = sentence.getTokens().get(sc.getEnd() - 1).getEnd() + sentenceOffset; AnnotationFS syntChunkAnn = tcas.createAnnotation( mSyntacticChunkType, start, end); syntChunkAnn.setStringValue(mSyntacticChunkFeature, sc.getTag()); tcas.getIndexRepository().addFS(syntChunkAnn); } } }
java
public void process(CAS tcas) { String text = tcas.getDocumentText(); Document document = new DocumentImpl(text); cogroo.analyze(document); for (Sentence sentence : document.getSentences()) { // create sentence annotations AnnotationFS sentenceAnn = tcas.createAnnotation(mSentenceType, sentence.getStart(), sentence.getEnd()); tcas.getIndexRepository().addFS(sentenceAnn); int sentenceOffset = sentence.getStart(); AnnotationFS[] tokenAnnotationArr = new AnnotationFS[sentence .getTokens().size()]; int i = 0; for (Token token : sentence.getTokens()) { // create token annotations tokenAnnotationArr[i] = tcas.createAnnotation(mTokenType, sentenceOffset + token.getStart(), sentenceOffset + token.getEnd()); // add POSTag annotations tokenAnnotationArr[i].setStringValue(this.mPosFeature, token.getPOSTag()); // add lexeme annotations tokenAnnotationArr[i].setStringValue(this.mLexemeFeature, token.getLexeme()); // add lemma annotations StringArrayFS lemmas = tcas.createStringArrayFS(token .getLemmas().length); lemmas.copyFromArray(token.getLemmas(), 0, 0, token.getLemmas().length); tokenAnnotationArr[i].setFeatureValue(this.mLemmaFeature, lemmas); tokenAnnotationArr[i].setStringValue(this.mFeaturesFeature, token.getFeatures()); tcas.getIndexRepository().addFS(tokenAnnotationArr[i]); i++; } // chunks for (Chunk chunk : sentence.getChunks()) { int start = sentence.getTokens().get(chunk.getStart()) .getStart() + sentenceOffset; int end = sentence.getTokens().get(chunk.getEnd() - 1).getEnd() + sentenceOffset; AnnotationFS chunkAnn = tcas.createAnnotation(mChunkType, start, end); chunkAnn.setStringValue(mChunkFeature, chunk.getTag()); if(chunk.getHeadIndex() >= 0) { chunkAnn.setFeatureValue(mChunkHead, tokenAnnotationArr[chunk.getHeadIndex()]); } tcas.getIndexRepository().addFS(chunkAnn); } // syntactic chunk for (SyntacticChunk sc : sentence.getSyntacticChunks()) { int start = sentence.getTokens().get(sc.getStart()).getStart() + sentenceOffset; int end = sentence.getTokens().get(sc.getEnd() - 1).getEnd() + sentenceOffset; AnnotationFS syntChunkAnn = tcas.createAnnotation( mSyntacticChunkType, start, end); syntChunkAnn.setStringValue(mSyntacticChunkFeature, sc.getTag()); tcas.getIndexRepository().addFS(syntChunkAnn); } } }
[ "public", "void", "process", "(", "CAS", "tcas", ")", "{", "String", "text", "=", "tcas", ".", "getDocumentText", "(", ")", ";", "Document", "document", "=", "new", "DocumentImpl", "(", "text", ")", ";", "cogroo", ".", "analyze", "(", "document", ")", ";", "for", "(", "Sentence", "sentence", ":", "document", ".", "getSentences", "(", ")", ")", "{", "// create sentence annotations", "AnnotationFS", "sentenceAnn", "=", "tcas", ".", "createAnnotation", "(", "mSentenceType", ",", "sentence", ".", "getStart", "(", ")", ",", "sentence", ".", "getEnd", "(", ")", ")", ";", "tcas", ".", "getIndexRepository", "(", ")", ".", "addFS", "(", "sentenceAnn", ")", ";", "int", "sentenceOffset", "=", "sentence", ".", "getStart", "(", ")", ";", "AnnotationFS", "[", "]", "tokenAnnotationArr", "=", "new", "AnnotationFS", "[", "sentence", ".", "getTokens", "(", ")", ".", "size", "(", ")", "]", ";", "int", "i", "=", "0", ";", "for", "(", "Token", "token", ":", "sentence", ".", "getTokens", "(", ")", ")", "{", "// create token annotations", "tokenAnnotationArr", "[", "i", "]", "=", "tcas", ".", "createAnnotation", "(", "mTokenType", ",", "sentenceOffset", "+", "token", ".", "getStart", "(", ")", ",", "sentenceOffset", "+", "token", ".", "getEnd", "(", ")", ")", ";", "// add POSTag annotations", "tokenAnnotationArr", "[", "i", "]", ".", "setStringValue", "(", "this", ".", "mPosFeature", ",", "token", ".", "getPOSTag", "(", ")", ")", ";", "// add lexeme annotations", "tokenAnnotationArr", "[", "i", "]", ".", "setStringValue", "(", "this", ".", "mLexemeFeature", ",", "token", ".", "getLexeme", "(", ")", ")", ";", "// add lemma annotations", "StringArrayFS", "lemmas", "=", "tcas", ".", "createStringArrayFS", "(", "token", ".", "getLemmas", "(", ")", ".", "length", ")", ";", "lemmas", ".", "copyFromArray", "(", "token", ".", "getLemmas", "(", ")", ",", "0", ",", "0", ",", "token", ".", "getLemmas", "(", ")", ".", "length", ")", ";", "tokenAnnotationArr", "[", "i", "]", ".", "setFeatureValue", "(", "this", ".", "mLemmaFeature", ",", "lemmas", ")", ";", "tokenAnnotationArr", "[", "i", "]", ".", "setStringValue", "(", "this", ".", "mFeaturesFeature", ",", "token", ".", "getFeatures", "(", ")", ")", ";", "tcas", ".", "getIndexRepository", "(", ")", ".", "addFS", "(", "tokenAnnotationArr", "[", "i", "]", ")", ";", "i", "++", ";", "}", "// chunks", "for", "(", "Chunk", "chunk", ":", "sentence", ".", "getChunks", "(", ")", ")", "{", "int", "start", "=", "sentence", ".", "getTokens", "(", ")", ".", "get", "(", "chunk", ".", "getStart", "(", ")", ")", ".", "getStart", "(", ")", "+", "sentenceOffset", ";", "int", "end", "=", "sentence", ".", "getTokens", "(", ")", ".", "get", "(", "chunk", ".", "getEnd", "(", ")", "-", "1", ")", ".", "getEnd", "(", ")", "+", "sentenceOffset", ";", "AnnotationFS", "chunkAnn", "=", "tcas", ".", "createAnnotation", "(", "mChunkType", ",", "start", ",", "end", ")", ";", "chunkAnn", ".", "setStringValue", "(", "mChunkFeature", ",", "chunk", ".", "getTag", "(", ")", ")", ";", "if", "(", "chunk", ".", "getHeadIndex", "(", ")", ">=", "0", ")", "{", "chunkAnn", ".", "setFeatureValue", "(", "mChunkHead", ",", "tokenAnnotationArr", "[", "chunk", ".", "getHeadIndex", "(", ")", "]", ")", ";", "}", "tcas", ".", "getIndexRepository", "(", ")", ".", "addFS", "(", "chunkAnn", ")", ";", "}", "// syntactic chunk", "for", "(", "SyntacticChunk", "sc", ":", "sentence", ".", "getSyntacticChunks", "(", ")", ")", "{", "int", "start", "=", "sentence", ".", "getTokens", "(", ")", ".", "get", "(", "sc", ".", "getStart", "(", ")", ")", ".", "getStart", "(", ")", "+", "sentenceOffset", ";", "int", "end", "=", "sentence", ".", "getTokens", "(", ")", ".", "get", "(", "sc", ".", "getEnd", "(", ")", "-", "1", ")", ".", "getEnd", "(", ")", "+", "sentenceOffset", ";", "AnnotationFS", "syntChunkAnn", "=", "tcas", ".", "createAnnotation", "(", "mSyntacticChunkType", ",", "start", ",", "end", ")", ";", "syntChunkAnn", ".", "setStringValue", "(", "mSyntacticChunkFeature", ",", "sc", ".", "getTag", "(", ")", ")", ";", "tcas", ".", "getIndexRepository", "(", ")", ".", "addFS", "(", "syntChunkAnn", ")", ";", "}", "}", "}" ]
Performs chunking on the given tcas object.
[ "Performs", "chunking", "on", "the", "given", "tcas", "object", "." ]
b6228900c20c6b37eac10a03708a9669dd562f52
https://github.com/cogroo/cogroo4/blob/b6228900c20c6b37eac10a03708a9669dd562f52/cogroo-ruta/src/main/java/org/cogroo/ruta/uima/CoGrOOUIMA.java#L152-L237
10,092
cogroo/cogroo4
cogroo-gc/src/main/java/org/cogroo/entities/impl/MorphologicalTag.java
MorphologicalTag.match
public boolean match(TagMask tagMask, boolean restricted) { if (tagMask.getClazz() != null) { if ((this.getClazzE() != null || restricted) && !match( this.getClazzE(), tagMask.getClazz())) return false; } if (tagMask.getGender() != null) { if ((this.getGenderE() != null || restricted) && dontMatch(tagMask.getGender())) return false; } if (tagMask.getNumber() != null) { if ((this.getNumberE() != null || restricted) && dontMatch(tagMask.getNumber())) return false; } if (tagMask.getCase() != null) { if ((this.getCase() != null || restricted) && this.getCase() != tagMask.getCase()) return false; } if (tagMask.getPerson() != null) { if ((this.getPersonE() != null || restricted) && dontMatch(tagMask.getPerson())) return false; } if (tagMask.getTense() != null) { if ((this.getTense() != null || restricted) && !match(this.getTense(), tagMask.getTense())) return false; } if (tagMask.getMood() != null) { if ((this.getMood() != null || restricted) && this.getMood() != tagMask.getMood()) return false; } if (tagMask.getPunctuation() != null) { if ((this.getPunctuation() != null || restricted) && this.getPunctuation() != tagMask.getPunctuation()) return false; } return true; }
java
public boolean match(TagMask tagMask, boolean restricted) { if (tagMask.getClazz() != null) { if ((this.getClazzE() != null || restricted) && !match( this.getClazzE(), tagMask.getClazz())) return false; } if (tagMask.getGender() != null) { if ((this.getGenderE() != null || restricted) && dontMatch(tagMask.getGender())) return false; } if (tagMask.getNumber() != null) { if ((this.getNumberE() != null || restricted) && dontMatch(tagMask.getNumber())) return false; } if (tagMask.getCase() != null) { if ((this.getCase() != null || restricted) && this.getCase() != tagMask.getCase()) return false; } if (tagMask.getPerson() != null) { if ((this.getPersonE() != null || restricted) && dontMatch(tagMask.getPerson())) return false; } if (tagMask.getTense() != null) { if ((this.getTense() != null || restricted) && !match(this.getTense(), tagMask.getTense())) return false; } if (tagMask.getMood() != null) { if ((this.getMood() != null || restricted) && this.getMood() != tagMask.getMood()) return false; } if (tagMask.getPunctuation() != null) { if ((this.getPunctuation() != null || restricted) && this.getPunctuation() != tagMask.getPunctuation()) return false; } return true; }
[ "public", "boolean", "match", "(", "TagMask", "tagMask", ",", "boolean", "restricted", ")", "{", "if", "(", "tagMask", ".", "getClazz", "(", ")", "!=", "null", ")", "{", "if", "(", "(", "this", ".", "getClazzE", "(", ")", "!=", "null", "||", "restricted", ")", "&&", "!", "match", "(", "this", ".", "getClazzE", "(", ")", ",", "tagMask", ".", "getClazz", "(", ")", ")", ")", "return", "false", ";", "}", "if", "(", "tagMask", ".", "getGender", "(", ")", "!=", "null", ")", "{", "if", "(", "(", "this", ".", "getGenderE", "(", ")", "!=", "null", "||", "restricted", ")", "&&", "dontMatch", "(", "tagMask", ".", "getGender", "(", ")", ")", ")", "return", "false", ";", "}", "if", "(", "tagMask", ".", "getNumber", "(", ")", "!=", "null", ")", "{", "if", "(", "(", "this", ".", "getNumberE", "(", ")", "!=", "null", "||", "restricted", ")", "&&", "dontMatch", "(", "tagMask", ".", "getNumber", "(", ")", ")", ")", "return", "false", ";", "}", "if", "(", "tagMask", ".", "getCase", "(", ")", "!=", "null", ")", "{", "if", "(", "(", "this", ".", "getCase", "(", ")", "!=", "null", "||", "restricted", ")", "&&", "this", ".", "getCase", "(", ")", "!=", "tagMask", ".", "getCase", "(", ")", ")", "return", "false", ";", "}", "if", "(", "tagMask", ".", "getPerson", "(", ")", "!=", "null", ")", "{", "if", "(", "(", "this", ".", "getPersonE", "(", ")", "!=", "null", "||", "restricted", ")", "&&", "dontMatch", "(", "tagMask", ".", "getPerson", "(", ")", ")", ")", "return", "false", ";", "}", "if", "(", "tagMask", ".", "getTense", "(", ")", "!=", "null", ")", "{", "if", "(", "(", "this", ".", "getTense", "(", ")", "!=", "null", "||", "restricted", ")", "&&", "!", "match", "(", "this", ".", "getTense", "(", ")", ",", "tagMask", ".", "getTense", "(", ")", ")", ")", "return", "false", ";", "}", "if", "(", "tagMask", ".", "getMood", "(", ")", "!=", "null", ")", "{", "if", "(", "(", "this", ".", "getMood", "(", ")", "!=", "null", "||", "restricted", ")", "&&", "this", ".", "getMood", "(", ")", "!=", "tagMask", ".", "getMood", "(", ")", ")", "return", "false", ";", "}", "if", "(", "tagMask", ".", "getPunctuation", "(", ")", "!=", "null", ")", "{", "if", "(", "(", "this", ".", "getPunctuation", "(", ")", "!=", "null", "||", "restricted", ")", "&&", "this", ".", "getPunctuation", "(", ")", "!=", "tagMask", ".", "getPunctuation", "(", ")", ")", "return", "false", ";", "}", "return", "true", ";", "}" ]
tag doesn't
[ "tag", "doesn", "t" ]
b6228900c20c6b37eac10a03708a9669dd562f52
https://github.com/cogroo/cogroo4/blob/b6228900c20c6b37eac10a03708a9669dd562f52/cogroo-gc/src/main/java/org/cogroo/entities/impl/MorphologicalTag.java#L219-L269
10,093
cogroo/cogroo4
lang/pt_br/cogroo-addon/src/org/cogroo/addon/dialogs/MessageBox.java
MessageBox.showMessageBox
public short showMessageBox(XWindowPeer _xParentWindowPeer, String _sTitle, String _sMessage, String _aType, int _aButtons) { short nResult = -1; XComponent xComponent = null; try { Object oToolkit = m_xMCF.createInstanceWithContext("com.sun.star.awt.Toolkit", m_xContext); XMessageBoxFactory xMessageBoxFactory = (XMessageBoxFactory) UnoRuntime.queryInterface(XMessageBoxFactory.class, oToolkit); // rectangle may be empty if position is in the center of the parent peer Rectangle aRectangle = new Rectangle(); XMessageBox xMessageBox = xMessageBoxFactory.createMessageBox(_xParentWindowPeer, aRectangle, _aType, _aButtons, _sTitle, _sMessage); xComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, xMessageBox); if (xMessageBox != null) { nResult = xMessageBox.execute(); } } catch (com.sun.star.uno.Exception ex) { ex.printStackTrace(System.out); } finally { //make sure always to dispose the component and free the memory! if (xComponent != null) { xComponent.dispose(); } } return nResult; }
java
public short showMessageBox(XWindowPeer _xParentWindowPeer, String _sTitle, String _sMessage, String _aType, int _aButtons) { short nResult = -1; XComponent xComponent = null; try { Object oToolkit = m_xMCF.createInstanceWithContext("com.sun.star.awt.Toolkit", m_xContext); XMessageBoxFactory xMessageBoxFactory = (XMessageBoxFactory) UnoRuntime.queryInterface(XMessageBoxFactory.class, oToolkit); // rectangle may be empty if position is in the center of the parent peer Rectangle aRectangle = new Rectangle(); XMessageBox xMessageBox = xMessageBoxFactory.createMessageBox(_xParentWindowPeer, aRectangle, _aType, _aButtons, _sTitle, _sMessage); xComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, xMessageBox); if (xMessageBox != null) { nResult = xMessageBox.execute(); } } catch (com.sun.star.uno.Exception ex) { ex.printStackTrace(System.out); } finally { //make sure always to dispose the component and free the memory! if (xComponent != null) { xComponent.dispose(); } } return nResult; }
[ "public", "short", "showMessageBox", "(", "XWindowPeer", "_xParentWindowPeer", ",", "String", "_sTitle", ",", "String", "_sMessage", ",", "String", "_aType", ",", "int", "_aButtons", ")", "{", "short", "nResult", "=", "-", "1", ";", "XComponent", "xComponent", "=", "null", ";", "try", "{", "Object", "oToolkit", "=", "m_xMCF", ".", "createInstanceWithContext", "(", "\"com.sun.star.awt.Toolkit\"", ",", "m_xContext", ")", ";", "XMessageBoxFactory", "xMessageBoxFactory", "=", "(", "XMessageBoxFactory", ")", "UnoRuntime", ".", "queryInterface", "(", "XMessageBoxFactory", ".", "class", ",", "oToolkit", ")", ";", "// rectangle may be empty if position is in the center of the parent peer", "Rectangle", "aRectangle", "=", "new", "Rectangle", "(", ")", ";", "XMessageBox", "xMessageBox", "=", "xMessageBoxFactory", ".", "createMessageBox", "(", "_xParentWindowPeer", ",", "aRectangle", ",", "_aType", ",", "_aButtons", ",", "_sTitle", ",", "_sMessage", ")", ";", "xComponent", "=", "(", "XComponent", ")", "UnoRuntime", ".", "queryInterface", "(", "XComponent", ".", "class", ",", "xMessageBox", ")", ";", "if", "(", "xMessageBox", "!=", "null", ")", "{", "nResult", "=", "xMessageBox", ".", "execute", "(", ")", ";", "}", "}", "catch", "(", "com", ".", "sun", ".", "star", ".", "uno", ".", "Exception", "ex", ")", "{", "ex", ".", "printStackTrace", "(", "System", ".", "out", ")", ";", "}", "finally", "{", "//make sure always to dispose the component and free the memory!", "if", "(", "xComponent", "!=", "null", ")", "{", "xComponent", ".", "dispose", "(", ")", ";", "}", "}", "return", "nResult", ";", "}" ]
Shows an messagebox @param _xParentWindowPeer the windowpeer of the parent window @param _sTitle the title of the messagebox @param _sMessage the message of the messagebox @param _aType string which determines the message box type: (infobox|warningbox|errorbox|querybox|messbox) @param _aButtons MessageBoxButtons which buttons should be available on the message box
[ "Shows", "an", "messagebox" ]
b6228900c20c6b37eac10a03708a9669dd562f52
https://github.com/cogroo/cogroo4/blob/b6228900c20c6b37eac10a03708a9669dd562f52/lang/pt_br/cogroo-addon/src/org/cogroo/addon/dialogs/MessageBox.java#L58-L80
10,094
kenyee/android-ddp-client
src/com/keysolutions/ddpclient/android/DDPBroadcastReceiver.java
DDPBroadcastReceiver.onReceive
@Override public void onReceive(Context context, Intent intent) { // display errors to the user Bundle bundle = intent.getExtras(); if (intent.getAction().equals(DDPStateSingleton.MESSAGE_ERROR)) { String message = bundle .getString(DDPStateSingleton.MESSAGE_EXTRA_MSG); onError("Login Error", message); } else if (intent.getAction().equals( DDPStateSingleton.MESSAGE_CONNECTION)) { int state = bundle.getInt(DDPStateSingleton.MESSAGE_EXTRA_STATE); if (state == DDPStateSingleton.DDPSTATE.Closed.ordinal()) { // connection was closed, show error message onError("Disconnected", "Websocket to server was closed"); } else if (state == DDPStateSingleton.DDPSTATE.Connected.ordinal()) { onDDPConnect(mDDP); } else if (state == DDPStateSingleton.DDPSTATE.LoggedIn.ordinal()) { onLogin(); } else if (state == DDPStateSingleton.DDPSTATE.NotLoggedIn.ordinal()) { onLogout(); } } else if (intent.getAction().equals( DDPStateSingleton.MESSAGE_SUBUPDATED)) { String subscriptionName = bundle .getString(DDPStateSingleton.MESSAGE_EXTRA_SUBNAME); String changeType = bundle.getString(DDPStateSingleton.MESSAGE_EXTRA_CHANGETYPE); String docId = bundle.getString(DDPStateSingleton.MESSAGE_EXTRA_CHANGEID); onSubscriptionUpdate(changeType, subscriptionName, docId); } }
java
@Override public void onReceive(Context context, Intent intent) { // display errors to the user Bundle bundle = intent.getExtras(); if (intent.getAction().equals(DDPStateSingleton.MESSAGE_ERROR)) { String message = bundle .getString(DDPStateSingleton.MESSAGE_EXTRA_MSG); onError("Login Error", message); } else if (intent.getAction().equals( DDPStateSingleton.MESSAGE_CONNECTION)) { int state = bundle.getInt(DDPStateSingleton.MESSAGE_EXTRA_STATE); if (state == DDPStateSingleton.DDPSTATE.Closed.ordinal()) { // connection was closed, show error message onError("Disconnected", "Websocket to server was closed"); } else if (state == DDPStateSingleton.DDPSTATE.Connected.ordinal()) { onDDPConnect(mDDP); } else if (state == DDPStateSingleton.DDPSTATE.LoggedIn.ordinal()) { onLogin(); } else if (state == DDPStateSingleton.DDPSTATE.NotLoggedIn.ordinal()) { onLogout(); } } else if (intent.getAction().equals( DDPStateSingleton.MESSAGE_SUBUPDATED)) { String subscriptionName = bundle .getString(DDPStateSingleton.MESSAGE_EXTRA_SUBNAME); String changeType = bundle.getString(DDPStateSingleton.MESSAGE_EXTRA_CHANGETYPE); String docId = bundle.getString(DDPStateSingleton.MESSAGE_EXTRA_CHANGEID); onSubscriptionUpdate(changeType, subscriptionName, docId); } }
[ "@", "Override", "public", "void", "onReceive", "(", "Context", "context", ",", "Intent", "intent", ")", "{", "// display errors to the user", "Bundle", "bundle", "=", "intent", ".", "getExtras", "(", ")", ";", "if", "(", "intent", ".", "getAction", "(", ")", ".", "equals", "(", "DDPStateSingleton", ".", "MESSAGE_ERROR", ")", ")", "{", "String", "message", "=", "bundle", ".", "getString", "(", "DDPStateSingleton", ".", "MESSAGE_EXTRA_MSG", ")", ";", "onError", "(", "\"Login Error\"", ",", "message", ")", ";", "}", "else", "if", "(", "intent", ".", "getAction", "(", ")", ".", "equals", "(", "DDPStateSingleton", ".", "MESSAGE_CONNECTION", ")", ")", "{", "int", "state", "=", "bundle", ".", "getInt", "(", "DDPStateSingleton", ".", "MESSAGE_EXTRA_STATE", ")", ";", "if", "(", "state", "==", "DDPStateSingleton", ".", "DDPSTATE", ".", "Closed", ".", "ordinal", "(", ")", ")", "{", "// connection was closed, show error message", "onError", "(", "\"Disconnected\"", ",", "\"Websocket to server was closed\"", ")", ";", "}", "else", "if", "(", "state", "==", "DDPStateSingleton", ".", "DDPSTATE", ".", "Connected", ".", "ordinal", "(", ")", ")", "{", "onDDPConnect", "(", "mDDP", ")", ";", "}", "else", "if", "(", "state", "==", "DDPStateSingleton", ".", "DDPSTATE", ".", "LoggedIn", ".", "ordinal", "(", ")", ")", "{", "onLogin", "(", ")", ";", "}", "else", "if", "(", "state", "==", "DDPStateSingleton", ".", "DDPSTATE", ".", "NotLoggedIn", ".", "ordinal", "(", ")", ")", "{", "onLogout", "(", ")", ";", "}", "}", "else", "if", "(", "intent", ".", "getAction", "(", ")", ".", "equals", "(", "DDPStateSingleton", ".", "MESSAGE_SUBUPDATED", ")", ")", "{", "String", "subscriptionName", "=", "bundle", ".", "getString", "(", "DDPStateSingleton", ".", "MESSAGE_EXTRA_SUBNAME", ")", ";", "String", "changeType", "=", "bundle", ".", "getString", "(", "DDPStateSingleton", ".", "MESSAGE_EXTRA_CHANGETYPE", ")", ";", "String", "docId", "=", "bundle", ".", "getString", "(", "DDPStateSingleton", ".", "MESSAGE_EXTRA_CHANGEID", ")", ";", "onSubscriptionUpdate", "(", "changeType", ",", "subscriptionName", ",", "docId", ")", ";", "}", "}" ]
Handles receiving Android broadcast messages @param context Android context @param intent Android intent
[ "Handles", "receiving", "Android", "broadcast", "messages" ]
6ab416e415570a03f96c383497144dd742de3f08
https://github.com/kenyee/android-ddp-client/blob/6ab416e415570a03f96c383497144dd742de3f08/src/com/keysolutions/ddpclient/android/DDPBroadcastReceiver.java#L74-L105
10,095
kenyee/android-ddp-client
src/com/keysolutions/ddpclient/android/DDPBroadcastReceiver.java
DDPBroadcastReceiver.onDDPConnect
protected void onDDPConnect(DDPStateSingleton ddp) { if (!ddp.isLoggedIn()) { // override this to handle first time connection (usually to subscribe) // if we have a login resume token, use it String resumeToken = ddp.getResumeToken(); if (resumeToken != null) { ddp.login(resumeToken); } } }
java
protected void onDDPConnect(DDPStateSingleton ddp) { if (!ddp.isLoggedIn()) { // override this to handle first time connection (usually to subscribe) // if we have a login resume token, use it String resumeToken = ddp.getResumeToken(); if (resumeToken != null) { ddp.login(resumeToken); } } }
[ "protected", "void", "onDDPConnect", "(", "DDPStateSingleton", "ddp", ")", "{", "if", "(", "!", "ddp", ".", "isLoggedIn", "(", ")", ")", "{", "// override this to handle first time connection (usually to subscribe)", "// if we have a login resume token, use it", "String", "resumeToken", "=", "ddp", ".", "getResumeToken", "(", ")", ";", "if", "(", "resumeToken", "!=", "null", ")", "{", "ddp", ".", "login", "(", "resumeToken", ")", ";", "}", "}", "}" ]
Override this to hook into what happens when DDP connect happens Default behavior is to feed in the resume token if available @param ddp DDP singleton
[ "Override", "this", "to", "hook", "into", "what", "happens", "when", "DDP", "connect", "happens", "Default", "behavior", "is", "to", "feed", "in", "the", "resume", "token", "if", "available" ]
6ab416e415570a03f96c383497144dd742de3f08
https://github.com/kenyee/android-ddp-client/blob/6ab416e415570a03f96c383497144dd742de3f08/src/com/keysolutions/ddpclient/android/DDPBroadcastReceiver.java#L134-L143
10,096
kenyee/android-ddp-client
src/com/keysolutions/ddpclient/android/DDPBroadcastReceiver.java
DDPBroadcastReceiver.onError
protected void onError(String title, String msg) { // override this to override default error handling behavior AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); builder.setMessage(msg).setTitle(title); builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }); AlertDialog dialog = builder.create(); dialog.show(); }
java
protected void onError(String title, String msg) { // override this to override default error handling behavior AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); builder.setMessage(msg).setTitle(title); builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }); AlertDialog dialog = builder.create(); dialog.show(); }
[ "protected", "void", "onError", "(", "String", "title", ",", "String", "msg", ")", "{", "// override this to override default error handling behavior", "AlertDialog", ".", "Builder", "builder", "=", "new", "AlertDialog", ".", "Builder", "(", "mActivity", ")", ";", "builder", ".", "setMessage", "(", "msg", ")", ".", "setTitle", "(", "title", ")", ";", "builder", ".", "setPositiveButton", "(", "\"OK\"", ",", "new", "DialogInterface", ".", "OnClickListener", "(", ")", "{", "public", "void", "onClick", "(", "DialogInterface", "dialog", ",", "int", "id", ")", "{", "dialog", ".", "dismiss", "(", ")", ";", "}", "}", ")", ";", "AlertDialog", "dialog", "=", "builder", ".", "create", "(", ")", ";", "dialog", ".", "show", "(", ")", ";", "}" ]
Override this to hook into error display Default behavior is to display the error as a dialog in your application @param title title of error @param msg detail of error
[ "Override", "this", "to", "hook", "into", "error", "display", "Default", "behavior", "is", "to", "display", "the", "error", "as", "a", "dialog", "in", "your", "application" ]
6ab416e415570a03f96c383497144dd742de3f08
https://github.com/kenyee/android-ddp-client/blob/6ab416e415570a03f96c383497144dd742de3f08/src/com/keysolutions/ddpclient/android/DDPBroadcastReceiver.java#L151-L162
10,097
cogroo/cogroo4
cogroo-nlp/src/main/java/org/cogroo/tools/featurizer/FeaturizerFactory.java
FeaturizerFactory.validateFeatureDictionary
protected void validateFeatureDictionary() { FeatureDictionary dict = getFeatureDictionary(); if (dict != null) { if (dict instanceof Iterable<?>) { FeatureDictionary posDict = (FeatureDictionary) dict; Set<String> dictTags = new HashSet<String>(); Set<String> poisoned = new HashSet<String>(); for (WordTag wt : (Iterable<WordTag>) posDict) { dictTags.add(wt.getPostag()); } Set<String> modelTags = new HashSet<String>(); AbstractModel posModel = this.artifactProvider .getArtifact(FeaturizerModel.FEATURIZER_MODEL_ENTRY_NAME); for (int i = 0; i < posModel.getNumOutcomes(); i++) { modelTags.add(posModel.getOutcome(i)); } for (String d : dictTags) { if (!modelTags.contains(d)) { poisoned.add(d); } } this.poisonedDictionaryTags = Collections.unmodifiableSet(poisoned); // if (poisonedDictionaryTags.size() > 0) { // System.err // .println("WARNING: Feature dictioinary contains tags which are unkown by the model! " // + this.poisonedDictionaryTags.toString()); // } } } }
java
protected void validateFeatureDictionary() { FeatureDictionary dict = getFeatureDictionary(); if (dict != null) { if (dict instanceof Iterable<?>) { FeatureDictionary posDict = (FeatureDictionary) dict; Set<String> dictTags = new HashSet<String>(); Set<String> poisoned = new HashSet<String>(); for (WordTag wt : (Iterable<WordTag>) posDict) { dictTags.add(wt.getPostag()); } Set<String> modelTags = new HashSet<String>(); AbstractModel posModel = this.artifactProvider .getArtifact(FeaturizerModel.FEATURIZER_MODEL_ENTRY_NAME); for (int i = 0; i < posModel.getNumOutcomes(); i++) { modelTags.add(posModel.getOutcome(i)); } for (String d : dictTags) { if (!modelTags.contains(d)) { poisoned.add(d); } } this.poisonedDictionaryTags = Collections.unmodifiableSet(poisoned); // if (poisonedDictionaryTags.size() > 0) { // System.err // .println("WARNING: Feature dictioinary contains tags which are unkown by the model! " // + this.poisonedDictionaryTags.toString()); // } } } }
[ "protected", "void", "validateFeatureDictionary", "(", ")", "{", "FeatureDictionary", "dict", "=", "getFeatureDictionary", "(", ")", ";", "if", "(", "dict", "!=", "null", ")", "{", "if", "(", "dict", "instanceof", "Iterable", "<", "?", ">", ")", "{", "FeatureDictionary", "posDict", "=", "(", "FeatureDictionary", ")", "dict", ";", "Set", "<", "String", ">", "dictTags", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "Set", "<", "String", ">", "poisoned", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "for", "(", "WordTag", "wt", ":", "(", "Iterable", "<", "WordTag", ">", ")", "posDict", ")", "{", "dictTags", ".", "add", "(", "wt", ".", "getPostag", "(", ")", ")", ";", "}", "Set", "<", "String", ">", "modelTags", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "AbstractModel", "posModel", "=", "this", ".", "artifactProvider", ".", "getArtifact", "(", "FeaturizerModel", ".", "FEATURIZER_MODEL_ENTRY_NAME", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "posModel", ".", "getNumOutcomes", "(", ")", ";", "i", "++", ")", "{", "modelTags", ".", "add", "(", "posModel", ".", "getOutcome", "(", "i", ")", ")", ";", "}", "for", "(", "String", "d", ":", "dictTags", ")", "{", "if", "(", "!", "modelTags", ".", "contains", "(", "d", ")", ")", "{", "poisoned", ".", "add", "(", "d", ")", ";", "}", "}", "this", ".", "poisonedDictionaryTags", "=", "Collections", ".", "unmodifiableSet", "(", "poisoned", ")", ";", "// if (poisonedDictionaryTags.size() > 0) {", "// System.err", "// .println(\"WARNING: Feature dictioinary contains tags which are unkown by the model! \"", "// + this.poisonedDictionaryTags.toString());", "// }", "}", "}", "}" ]
because the poisoned tags are persisted...
[ "because", "the", "poisoned", "tags", "are", "persisted", "..." ]
b6228900c20c6b37eac10a03708a9669dd562f52
https://github.com/cogroo/cogroo4/blob/b6228900c20c6b37eac10a03708a9669dd562f52/cogroo-nlp/src/main/java/org/cogroo/tools/featurizer/FeaturizerFactory.java#L142-L180
10,098
DataArt/CalculationEngine
calculation-engine/engine-evaluation/src/main/java/com/dataart/spreadsheetanalytics/engine/graph/GraphBuilderUtils.java
GraphBuilderUtils.copyProperties
static void copyProperties(ExecutionGraphVertex standard, Set<ExecutionGraphVertex> vertices) { for (ExecutionGraphVertex vertex : vertices) { if (standard.equals(vertex)) { continue; } IExecutionGraphVertexProperties from = standard.properties(); IExecutionGraphVertexProperties to = vertex.properties(); //copy all, but: IndexInFormula and VertexId to.setName(from.getName()); to.setAlias(from.getAlias()); to.setValue(from.getValue()); to.setType(from.getType()); to.setFormulaPtg(from.getFormulaPtg()); to.setPtgs(from.getPtgs()); if (from.getFormulaString() == null && to.getFormulaString() != null) { from.setFormulaString(to.getFormulaString()); } else { to.setFormulaString(from.getFormulaString()); } if (from.getFormulaValues() == null && to.getFormulaValues() != null) { from.setFormulaValues(to.getFormulaValues()); } else { to.setFormulaValues(from.getFormulaValues()); } if (from.getFormulaPtgString() == null && to.getFormulaPtgString() != null) { from.setFormulaPtgString(to.getFormulaPtgString()); } else { to.setFormulaPtgString(from.getFormulaPtgString()); } if (from.getPtgString() == null && to.getPtgString() != null) { from.setPtgString(to.getPtgString()); } else { to.setPtgString(from.getPtgString()); } to.setSourceObjectId(from.getSourceObjectId()); to.setRootFormulaId(from.getRootFormulaId()); } }
java
static void copyProperties(ExecutionGraphVertex standard, Set<ExecutionGraphVertex> vertices) { for (ExecutionGraphVertex vertex : vertices) { if (standard.equals(vertex)) { continue; } IExecutionGraphVertexProperties from = standard.properties(); IExecutionGraphVertexProperties to = vertex.properties(); //copy all, but: IndexInFormula and VertexId to.setName(from.getName()); to.setAlias(from.getAlias()); to.setValue(from.getValue()); to.setType(from.getType()); to.setFormulaPtg(from.getFormulaPtg()); to.setPtgs(from.getPtgs()); if (from.getFormulaString() == null && to.getFormulaString() != null) { from.setFormulaString(to.getFormulaString()); } else { to.setFormulaString(from.getFormulaString()); } if (from.getFormulaValues() == null && to.getFormulaValues() != null) { from.setFormulaValues(to.getFormulaValues()); } else { to.setFormulaValues(from.getFormulaValues()); } if (from.getFormulaPtgString() == null && to.getFormulaPtgString() != null) { from.setFormulaPtgString(to.getFormulaPtgString()); } else { to.setFormulaPtgString(from.getFormulaPtgString()); } if (from.getPtgString() == null && to.getPtgString() != null) { from.setPtgString(to.getPtgString()); } else { to.setPtgString(from.getPtgString()); } to.setSourceObjectId(from.getSourceObjectId()); to.setRootFormulaId(from.getRootFormulaId()); } }
[ "static", "void", "copyProperties", "(", "ExecutionGraphVertex", "standard", ",", "Set", "<", "ExecutionGraphVertex", ">", "vertices", ")", "{", "for", "(", "ExecutionGraphVertex", "vertex", ":", "vertices", ")", "{", "if", "(", "standard", ".", "equals", "(", "vertex", ")", ")", "{", "continue", ";", "}", "IExecutionGraphVertexProperties", "from", "=", "standard", ".", "properties", "(", ")", ";", "IExecutionGraphVertexProperties", "to", "=", "vertex", ".", "properties", "(", ")", ";", "//copy all, but: IndexInFormula and VertexId\r", "to", ".", "setName", "(", "from", ".", "getName", "(", ")", ")", ";", "to", ".", "setAlias", "(", "from", ".", "getAlias", "(", ")", ")", ";", "to", ".", "setValue", "(", "from", ".", "getValue", "(", ")", ")", ";", "to", ".", "setType", "(", "from", ".", "getType", "(", ")", ")", ";", "to", ".", "setFormulaPtg", "(", "from", ".", "getFormulaPtg", "(", ")", ")", ";", "to", ".", "setPtgs", "(", "from", ".", "getPtgs", "(", ")", ")", ";", "if", "(", "from", ".", "getFormulaString", "(", ")", "==", "null", "&&", "to", ".", "getFormulaString", "(", ")", "!=", "null", ")", "{", "from", ".", "setFormulaString", "(", "to", ".", "getFormulaString", "(", ")", ")", ";", "}", "else", "{", "to", ".", "setFormulaString", "(", "from", ".", "getFormulaString", "(", ")", ")", ";", "}", "if", "(", "from", ".", "getFormulaValues", "(", ")", "==", "null", "&&", "to", ".", "getFormulaValues", "(", ")", "!=", "null", ")", "{", "from", ".", "setFormulaValues", "(", "to", ".", "getFormulaValues", "(", ")", ")", ";", "}", "else", "{", "to", ".", "setFormulaValues", "(", "from", ".", "getFormulaValues", "(", ")", ")", ";", "}", "if", "(", "from", ".", "getFormulaPtgString", "(", ")", "==", "null", "&&", "to", ".", "getFormulaPtgString", "(", ")", "!=", "null", ")", "{", "from", ".", "setFormulaPtgString", "(", "to", ".", "getFormulaPtgString", "(", ")", ")", ";", "}", "else", "{", "to", ".", "setFormulaPtgString", "(", "from", ".", "getFormulaPtgString", "(", ")", ")", ";", "}", "if", "(", "from", ".", "getPtgString", "(", ")", "==", "null", "&&", "to", ".", "getPtgString", "(", ")", "!=", "null", ")", "{", "from", ".", "setPtgString", "(", "to", ".", "getPtgString", "(", ")", ")", ";", "}", "else", "{", "to", ".", "setPtgString", "(", "from", ".", "getPtgString", "(", ")", ")", ";", "}", "to", ".", "setSourceObjectId", "(", "from", ".", "getSourceObjectId", "(", ")", ")", ";", "to", ".", "setRootFormulaId", "(", "from", ".", "getRootFormulaId", "(", ")", ")", ";", "}", "}" ]
Does copy of all properties for every Vertex from @param vertices. the first @param standard is used as object to copy from.
[ "Does", "copy", "of", "all", "properties", "for", "every", "Vertex", "from" ]
34ce1d9c1f9b57a502906b274311d28580b134e5
https://github.com/DataArt/CalculationEngine/blob/34ce1d9c1f9b57a502906b274311d28580b134e5/calculation-engine/engine-evaluation/src/main/java/com/dataart/spreadsheetanalytics/engine/graph/GraphBuilderUtils.java#L100-L125
10,099
cogroo/cogroo4
cogroo-eval/BaselineCogrooAE/src/main/java/cogroo/uima/ae/UimaPOSTagger.java
UimaPOSTagger.createSpanList
public static List<TypedSpan> createSpanList(String[] toks, String[] tags) { // initialize with the list maximum size List<TypedSpan> phrases = new ArrayList<TypedSpan>(toks.length); String startTag = ""; int startIndex = 0; boolean foundPhrase = false; for (int ci = 0, cn = tags.length; ci < cn; ci++) { String pred = tags[ci]; if(!tags[ci].startsWith("B-") && !tags[ci].startsWith("I-")) { pred = "O"; } if (pred.startsWith("B-") || (!pred.equals("I-" + startTag) && !pred.equals("O"))) { // start if (foundPhrase) { // handle the last phrases.add(new TypedSpan(startIndex, ci, startTag)); } startIndex = ci; startTag = pred.substring(2); foundPhrase = true; } else if (pred.equals("I-" + startTag)) { // middle // do nothing } else if (foundPhrase) {// end phrases.add(new TypedSpan(startIndex, ci, startTag)); foundPhrase = false; startTag = ""; } } if (foundPhrase) { // leftover phrases.add(new TypedSpan(startIndex, tags.length, startTag)); } return phrases; }
java
public static List<TypedSpan> createSpanList(String[] toks, String[] tags) { // initialize with the list maximum size List<TypedSpan> phrases = new ArrayList<TypedSpan>(toks.length); String startTag = ""; int startIndex = 0; boolean foundPhrase = false; for (int ci = 0, cn = tags.length; ci < cn; ci++) { String pred = tags[ci]; if(!tags[ci].startsWith("B-") && !tags[ci].startsWith("I-")) { pred = "O"; } if (pred.startsWith("B-") || (!pred.equals("I-" + startTag) && !pred.equals("O"))) { // start if (foundPhrase) { // handle the last phrases.add(new TypedSpan(startIndex, ci, startTag)); } startIndex = ci; startTag = pred.substring(2); foundPhrase = true; } else if (pred.equals("I-" + startTag)) { // middle // do nothing } else if (foundPhrase) {// end phrases.add(new TypedSpan(startIndex, ci, startTag)); foundPhrase = false; startTag = ""; } } if (foundPhrase) { // leftover phrases.add(new TypedSpan(startIndex, tags.length, startTag)); } return phrases; }
[ "public", "static", "List", "<", "TypedSpan", ">", "createSpanList", "(", "String", "[", "]", "toks", ",", "String", "[", "]", "tags", ")", "{", "// initialize with the list maximum size", "List", "<", "TypedSpan", ">", "phrases", "=", "new", "ArrayList", "<", "TypedSpan", ">", "(", "toks", ".", "length", ")", ";", "String", "startTag", "=", "\"\"", ";", "int", "startIndex", "=", "0", ";", "boolean", "foundPhrase", "=", "false", ";", "for", "(", "int", "ci", "=", "0", ",", "cn", "=", "tags", ".", "length", ";", "ci", "<", "cn", ";", "ci", "++", ")", "{", "String", "pred", "=", "tags", "[", "ci", "]", ";", "if", "(", "!", "tags", "[", "ci", "]", ".", "startsWith", "(", "\"B-\"", ")", "&&", "!", "tags", "[", "ci", "]", ".", "startsWith", "(", "\"I-\"", ")", ")", "{", "pred", "=", "\"O\"", ";", "}", "if", "(", "pred", ".", "startsWith", "(", "\"B-\"", ")", "||", "(", "!", "pred", ".", "equals", "(", "\"I-\"", "+", "startTag", ")", "&&", "!", "pred", ".", "equals", "(", "\"O\"", ")", ")", ")", "{", "// start", "if", "(", "foundPhrase", ")", "{", "// handle the last", "phrases", ".", "add", "(", "new", "TypedSpan", "(", "startIndex", ",", "ci", ",", "startTag", ")", ")", ";", "}", "startIndex", "=", "ci", ";", "startTag", "=", "pred", ".", "substring", "(", "2", ")", ";", "foundPhrase", "=", "true", ";", "}", "else", "if", "(", "pred", ".", "equals", "(", "\"I-\"", "+", "startTag", ")", ")", "{", "// middle", "// do nothing", "}", "else", "if", "(", "foundPhrase", ")", "{", "// end", "phrases", ".", "add", "(", "new", "TypedSpan", "(", "startIndex", ",", "ci", ",", "startTag", ")", ")", ";", "foundPhrase", "=", "false", ";", "startTag", "=", "\"\"", ";", "}", "}", "if", "(", "foundPhrase", ")", "{", "// leftover", "phrases", ".", "add", "(", "new", "TypedSpan", "(", "startIndex", ",", "tags", ".", "length", ",", "startTag", ")", ")", ";", "}", "return", "phrases", ";", "}" ]
this is from opennlp
[ "this", "is", "from", "opennlp" ]
b6228900c20c6b37eac10a03708a9669dd562f52
https://github.com/cogroo/cogroo4/blob/b6228900c20c6b37eac10a03708a9669dd562f52/cogroo-eval/BaselineCogrooAE/src/main/java/cogroo/uima/ae/UimaPOSTagger.java#L88-L122