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
102,300
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/lang/ArrayUtils.java
ArrayUtils.prependToArray
public static <T> T[] prependToArray(T item, T[] array, Class<?> type) { if (array == null) { if (type == null && item != null) { type = item.getClass(); } @SuppressWarnings("unchecked") T[] na = (T[]) Array.newInstance(type, 1); na[0] ...
java
public static <T> T[] prependToArray(T item, T[] array, Class<?> type) { if (array == null) { if (type == null && item != null) { type = item.getClass(); } @SuppressWarnings("unchecked") T[] na = (T[]) Array.newInstance(type, 1); na[0] ...
[ "public", "static", "<", "T", ">", "T", "[", "]", "prependToArray", "(", "T", "item", ",", "T", "[", "]", "array", ",", "Class", "<", "?", ">", "type", ")", "{", "if", "(", "array", "==", "null", ")", "{", "if", "(", "type", "==", "null", "&&...
Add element to the start of an array @param array The array to add to (or null) @param item The item to add @param type The type of the array (in case of null array) @param <T> the array entry type @return new array with contents of array plus item
[ "Add", "element", "to", "the", "start", "of", "an", "array" ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/lang/ArrayUtils.java#L145-L162
102,301
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/io/PathResource.java
PathResource.getInputStream
@Override public InputStream getInputStream() throws IOException { if (!exists()) { throw new FileNotFoundException(getPath() + " (no such file or directory)"); } if (Files.isDirectory(this.path)) { throw new FileNotFoundException(getPath() + " (is a directory)"); ...
java
@Override public InputStream getInputStream() throws IOException { if (!exists()) { throw new FileNotFoundException(getPath() + " (no such file or directory)"); } if (Files.isDirectory(this.path)) { throw new FileNotFoundException(getPath() + " (is a directory)"); ...
[ "@", "Override", "public", "InputStream", "getInputStream", "(", ")", "throws", "IOException", "{", "if", "(", "!", "exists", "(", ")", ")", "{", "throw", "new", "FileNotFoundException", "(", "getPath", "(", ")", "+", "\" (no such file or directory)\"", ")", "...
This implementation opens a InputStream for the underlying file. @see java.nio.file.spi.FileSystemProvider#newInputStream(Path, OpenOption...)
[ "This", "implementation", "opens", "a", "InputStream", "for", "the", "underlying", "file", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/io/PathResource.java#L102-L111
102,302
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/io/PathResource.java
PathResource.getOutputStream
@Override public OutputStream getOutputStream() throws IOException { if (Files.isDirectory(this.path)) { throw new FileNotFoundException(getPath() + " (is a directory)"); } return Files.newOutputStream(this.path); }
java
@Override public OutputStream getOutputStream() throws IOException { if (Files.isDirectory(this.path)) { throw new FileNotFoundException(getPath() + " (is a directory)"); } return Files.newOutputStream(this.path); }
[ "@", "Override", "public", "OutputStream", "getOutputStream", "(", ")", "throws", "IOException", "{", "if", "(", "Files", ".", "isDirectory", "(", "this", ".", "path", ")", ")", "{", "throw", "new", "FileNotFoundException", "(", "getPath", "(", ")", "+", "...
This implementation opens a OutputStream for the underlying file. @see java.nio.file.spi.FileSystemProvider#newOutputStream(Path, OpenOption...)
[ "This", "implementation", "opens", "a", "OutputStream", "for", "the", "underlying", "file", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/io/PathResource.java#L130-L136
102,303
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/io/PathResource.java
PathResource.getFile
@Override public File getFile() throws IOException { try { return this.path.toFile(); } catch (UnsupportedOperationException ex) { // only Paths on the default file system can be converted to a File // do exception translation for cases where conversion is not pos...
java
@Override public File getFile() throws IOException { try { return this.path.toFile(); } catch (UnsupportedOperationException ex) { // only Paths on the default file system can be converted to a File // do exception translation for cases where conversion is not pos...
[ "@", "Override", "public", "File", "getFile", "(", ")", "throws", "IOException", "{", "try", "{", "return", "this", ".", "path", ".", "toFile", "(", ")", ";", "}", "catch", "(", "UnsupportedOperationException", "ex", ")", "{", "// only Paths on the default fil...
This implementation returns the underlying File reference.
[ "This", "implementation", "returns", "the", "underlying", "File", "reference", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/io/PathResource.java#L162-L171
102,304
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/io/PathResource.java
PathResource.createRelative
@Override public Resource createRelative(String relativePath) throws IOException { return new PathResource(this.path.resolve(relativePath)); }
java
@Override public Resource createRelative(String relativePath) throws IOException { return new PathResource(this.path.resolve(relativePath)); }
[ "@", "Override", "public", "Resource", "createRelative", "(", "String", "relativePath", ")", "throws", "IOException", "{", "return", "new", "PathResource", "(", "this", ".", "path", ".", "resolve", "(", "relativePath", ")", ")", ";", "}" ]
This implementation creates a FileResource, applying the given path relative to the path of the underlying file of this resource descriptor. @see java.nio.file.Path#resolve(String)
[ "This", "implementation", "creates", "a", "FileResource", "applying", "the", "given", "path", "relative", "to", "the", "path", "of", "the", "underlying", "file", "of", "this", "resource", "descriptor", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/io/PathResource.java#L199-L202
102,305
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/collection/ArrayQueue.java
ArrayQueue.getUnsafe
public E getUnsafe(int index) { int i = (_nextE + index) % _elements.length; return at(i); }
java
public E getUnsafe(int index) { int i = (_nextE + index) % _elements.length; return at(i); }
[ "public", "E", "getUnsafe", "(", "int", "index", ")", "{", "int", "i", "=", "(", "_nextE", "+", "index", ")", "%", "_elements", ".", "length", ";", "return", "at", "(", "i", ")", ";", "}" ]
Get without synchronization or bounds checking. @param index index of the element to return @return the element at the specified index @see #get(int)
[ "Get", "without", "synchronization", "or", "bounds", "checking", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/collection/ArrayQueue.java#L206-L209
102,306
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/lang/QuotedStringTokenizer.java
QuotedStringTokenizer.quoteOnly
public static void quoteOnly(Appendable buffer, String input) { if (input == null) return; try { buffer.append('"'); for (int i = 0; i < input.length(); ++i) { char c = input.charAt(i); if (c == '"' || c == '\\') bu...
java
public static void quoteOnly(Appendable buffer, String input) { if (input == null) return; try { buffer.append('"'); for (int i = 0; i < input.length(); ++i) { char c = input.charAt(i); if (c == '"' || c == '\\') bu...
[ "public", "static", "void", "quoteOnly", "(", "Appendable", "buffer", ",", "String", "input", ")", "{", "if", "(", "input", "==", "null", ")", "return", ";", "try", "{", "buffer", ".", "append", "(", "'", "'", ")", ";", "for", "(", "int", "i", "=",...
Quote a string into an Appendable. Only quotes and backslash are escaped. @param buffer The Appendable @param input The String to quote.
[ "Quote", "a", "string", "into", "an", "Appendable", ".", "Only", "quotes", "and", "backslash", "are", "escaped", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/lang/QuotedStringTokenizer.java#L251-L267
102,307
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/lang/QuotedStringTokenizer.java
QuotedStringTokenizer.quote
public static void quote(Appendable buffer, String input) { if (input == null) return; try { buffer.append('"'); for (int i = 0; i < input.length(); ++i) { char c = input.charAt(i); if (c >= 32) { if (c == '"' || c ...
java
public static void quote(Appendable buffer, String input) { if (input == null) return; try { buffer.append('"'); for (int i = 0; i < input.length(); ++i) { char c = input.charAt(i); if (c >= 32) { if (c == '"' || c ...
[ "public", "static", "void", "quote", "(", "Appendable", "buffer", ",", "String", "input", ")", "{", "if", "(", "input", "==", "null", ")", "return", ";", "try", "{", "buffer", ".", "append", "(", "'", "'", ")", ";", "for", "(", "int", "i", "=", "...
Quote a string into an Appendable. The characters ", \, \n, \r, \t, \f and \b are escaped @param buffer The Appendable @param input The String to quote.
[ "Quote", "a", "string", "into", "an", "Appendable", ".", "The", "characters", "\\", "\\", "n", "\\", "r", "\\", "t", "\\", "f", "and", "\\", "b", "are", "escaped" ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/lang/QuotedStringTokenizer.java#L276-L305
102,308
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/lang/QuotedStringTokenizer.java
QuotedStringTokenizer.unquoteOnly
public static String unquoteOnly(String s, boolean lenient) { if (s == null) return null; if (s.length() < 2) return s; char first = s.charAt(0); char last = s.charAt(s.length() - 1); if (first != last || (first != '"' && first != '\'')) retur...
java
public static String unquoteOnly(String s, boolean lenient) { if (s == null) return null; if (s.length() < 2) return s; char first = s.charAt(0); char last = s.charAt(s.length() - 1); if (first != last || (first != '"' && first != '\'')) retur...
[ "public", "static", "String", "unquoteOnly", "(", "String", "s", ",", "boolean", "lenient", ")", "{", "if", "(", "s", "==", "null", ")", "return", "null", ";", "if", "(", "s", ".", "length", "(", ")", "<", "2", ")", "return", "s", ";", "char", "f...
Unquote a string, NOT converting unicode sequences @param s The string to unquote. @param lenient if true, will leave in backslashes that aren't valid escapes @return quoted string
[ "Unquote", "a", "string", "NOT", "converting", "unicode", "sequences" ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/lang/QuotedStringTokenizer.java#L318-L348
102,309
hypercube1024/firefly
firefly-db/src/main/java/com/firefly/db/init/ScriptUtils.java
ScriptUtils.containsSqlScriptDelimiters
public static boolean containsSqlScriptDelimiters(String script, String delim) { boolean inLiteral = false; char[] content = script.toCharArray(); for (int i = 0; i < script.length(); i++) { if (content[i] == '\'') { inLiteral = !inLiteral; } i...
java
public static boolean containsSqlScriptDelimiters(String script, String delim) { boolean inLiteral = false; char[] content = script.toCharArray(); for (int i = 0; i < script.length(); i++) { if (content[i] == '\'') { inLiteral = !inLiteral; } i...
[ "public", "static", "boolean", "containsSqlScriptDelimiters", "(", "String", "script", ",", "String", "delim", ")", "{", "boolean", "inLiteral", "=", "false", ";", "char", "[", "]", "content", "=", "script", ".", "toCharArray", "(", ")", ";", "for", "(", "...
Does the provided SQL script contain the specified delimiter? @param script the SQL script @param delim String delimiting each statement - typically a ';' character
[ "Does", "the", "provided", "SQL", "script", "contain", "the", "specified", "delimiter?" ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-db/src/main/java/com/firefly/db/init/ScriptUtils.java#L335-L347
102,310
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/ObjectUtils.java
ObjectUtils.addObjectToArray
public static <A, O extends A> A[] addObjectToArray(A[] array, O obj) { Class<?> compType = Object.class; if (array != null) { compType = array.getClass().getComponentType(); } else if (obj != null) { compType = obj.getClass(); } int newArrLength = (array ...
java
public static <A, O extends A> A[] addObjectToArray(A[] array, O obj) { Class<?> compType = Object.class; if (array != null) { compType = array.getClass().getComponentType(); } else if (obj != null) { compType = obj.getClass(); } int newArrLength = (array ...
[ "public", "static", "<", "A", ",", "O", "extends", "A", ">", "A", "[", "]", "addObjectToArray", "(", "A", "[", "]", "array", ",", "O", "obj", ")", "{", "Class", "<", "?", ">", "compType", "=", "Object", ".", "class", ";", "if", "(", "array", "!...
Append the given object to the given array, returning a new array consisting of the input array contents plus the given object. @param array the array to append to (can be {@code null}) @param obj the object to append @return the new array (of the same component type; never {@code null})
[ "Append", "the", "given", "object", "to", "the", "given", "array", "returning", "a", "new", "array", "consisting", "of", "the", "input", "array", "contents", "plus", "the", "given", "object", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/ObjectUtils.java#L205-L220
102,311
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/math/Viterbi.java
Viterbi.compute
public static int[] compute(int[] obs, int[] states, double[] startProb, double[][] transProb, double[][] emitProb) { double[][] v = new double[obs.length][states.length]; int[][] path = new int[states.length][obs.length]; for (int y : states) { v[0][y] = startProb[y] * emitProb[y][...
java
public static int[] compute(int[] obs, int[] states, double[] startProb, double[][] transProb, double[][] emitProb) { double[][] v = new double[obs.length][states.length]; int[][] path = new int[states.length][obs.length]; for (int y : states) { v[0][y] = startProb[y] * emitProb[y][...
[ "public", "static", "int", "[", "]", "compute", "(", "int", "[", "]", "obs", ",", "int", "[", "]", "states", ",", "double", "[", "]", "startProb", ",", "double", "[", "]", "[", "]", "transProb", ",", "double", "[", "]", "[", "]", "emitProb", ")",...
Compute HMM hidden states @param obs observations @param states hidden states @param startProb start probability of the hidden state @param transProb transition probability of the hidden state @param emitProb emission probability @return The most possible hidden states
[ "Compute", "HMM", "hidden", "states" ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/math/Viterbi.java#L17-L59
102,312
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/lang/pool/PooledObject.java
PooledObject.clear
public void clear() { Optional.ofNullable(phantomReference).ifPresent(ref -> pool.getLeakDetector().clear(ref)); }
java
public void clear() { Optional.ofNullable(phantomReference).ifPresent(ref -> pool.getLeakDetector().clear(ref)); }
[ "public", "void", "clear", "(", ")", "{", "Optional", ".", "ofNullable", "(", "phantomReference", ")", ".", "ifPresent", "(", "ref", "->", "pool", ".", "getLeakDetector", "(", ")", ".", "clear", "(", "ref", ")", ")", ";", "}" ]
Clear leak track
[ "Clear", "leak", "track" ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/lang/pool/PooledObject.java#L100-L102
102,313
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/json/io/IOUtils.java
IOUtils.stringSize
public static int stringSize(long x) { long p = 10; for (int i = 1; i < 19; i++) { if (x < p) return i; p = 10 * p; } return 19; }
java
public static int stringSize(long x) { long p = 10; for (int i = 1; i < 19; i++) { if (x < p) return i; p = 10 * p; } return 19; }
[ "public", "static", "int", "stringSize", "(", "long", "x", ")", "{", "long", "p", "=", "10", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "19", ";", "i", "++", ")", "{", "if", "(", "x", "<", "p", ")", "return", "i", ";", "p", "="...
Requires positive x
[ "Requires", "positive", "x" ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/json/io/IOUtils.java#L12-L19
102,314
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/retry/WaitStrategies.java
WaitStrategies.fixedWait
public static <V> Action1<TaskContext<V>> fixedWait(long sleepTime, TimeUnit timeUnit) { return ctx -> ThreadUtils.sleep(sleepTime, timeUnit); }
java
public static <V> Action1<TaskContext<V>> fixedWait(long sleepTime, TimeUnit timeUnit) { return ctx -> ThreadUtils.sleep(sleepTime, timeUnit); }
[ "public", "static", "<", "V", ">", "Action1", "<", "TaskContext", "<", "V", ">", ">", "fixedWait", "(", "long", "sleepTime", ",", "TimeUnit", "timeUnit", ")", "{", "return", "ctx", "->", "ThreadUtils", ".", "sleep", "(", "sleepTime", ",", "timeUnit", ")"...
The fixed sleep time. @param sleepTime The sleep time. @param timeUnit The time unit. @param <V> The return value type. @return The wait strategy action.
[ "The", "fixed", "sleep", "time", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/retry/WaitStrategies.java#L22-L24
102,315
hypercube1024/firefly
firefly-db/src/main/java/com/firefly/db/init/ScriptStatementFailedException.java
ScriptStatementFailedException.buildErrorMessage
public static String buildErrorMessage(String stmt, int stmtNumber, EncodedResource encodedResource) { return String.format("Failed to execute SQL script statement #%s of %s: %s", stmtNumber, encodedResource, stmt); }
java
public static String buildErrorMessage(String stmt, int stmtNumber, EncodedResource encodedResource) { return String.format("Failed to execute SQL script statement #%s of %s: %s", stmtNumber, encodedResource, stmt); }
[ "public", "static", "String", "buildErrorMessage", "(", "String", "stmt", ",", "int", "stmtNumber", ",", "EncodedResource", "encodedResource", ")", "{", "return", "String", ".", "format", "(", "\"Failed to execute SQL script statement #%s of %s: %s\"", ",", "stmtNumber", ...
Build an error message for an SQL script execution failure, based on the supplied arguments. @param stmt the actual SQL statement that failed @param stmtNumber the statement number in the SQL script (i.e., the n<sup>th</sup> statement present in the resource) @param encodedResource the resource from wh...
[ "Build", "an", "error", "message", "for", "an", "SQL", "script", "execution", "failure", "based", "on", "the", "supplied", "arguments", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-db/src/main/java/com/firefly/db/init/ScriptStatementFailedException.java#L38-L40
102,316
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/retry/StopStrategies.java
StopStrategies.afterDelay
public static <V> Predicate<TaskContext<V>> afterDelay(long time, TimeUnit timeUnit) { return ctx -> (System.currentTimeMillis() - ctx.getStartTime()) >= timeUnit.toMillis(time); }
java
public static <V> Predicate<TaskContext<V>> afterDelay(long time, TimeUnit timeUnit) { return ctx -> (System.currentTimeMillis() - ctx.getStartTime()) >= timeUnit.toMillis(time); }
[ "public", "static", "<", "V", ">", "Predicate", "<", "TaskContext", "<", "V", ">", ">", "afterDelay", "(", "long", "time", ",", "TimeUnit", "timeUnit", ")", "{", "return", "ctx", "->", "(", "System", ".", "currentTimeMillis", "(", ")", "-", "ctx", ".",...
If the task executed time exceeds the specified time, the task will stop retry. @param time The max task executed time. @param timeUnit The time unit. @param <V> The return value type. @return The stop strategy predicate.
[ "If", "the", "task", "executed", "time", "exceeds", "the", "specified", "time", "the", "task", "will", "stop", "retry", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/retry/StopStrategies.java#L19-L21
102,317
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/retry/StopStrategies.java
StopStrategies.afterExecute
public static <V> Predicate<TaskContext<V>> afterExecute(int count) { return ctx -> ctx.getExecutedCount() >= count; }
java
public static <V> Predicate<TaskContext<V>> afterExecute(int count) { return ctx -> ctx.getExecutedCount() >= count; }
[ "public", "static", "<", "V", ">", "Predicate", "<", "TaskContext", "<", "V", ">", ">", "afterExecute", "(", "int", "count", ")", "{", "return", "ctx", "->", "ctx", ".", "getExecutedCount", "(", ")", ">=", "count", ";", "}" ]
If the task executed count exceeds the max count, the task will stop retry. @param count The task max executed count. @param <V> The return value type. @return The stop strategy predicate.
[ "If", "the", "task", "executed", "count", "exceeds", "the", "max", "count", "the", "task", "will", "stop", "retry", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/retry/StopStrategies.java#L30-L32
102,318
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/io/BufferUtils.java
BufferUtils.allocate
public static ByteBuffer allocate(int capacity) { ByteBuffer buf = ByteBuffer.allocate(capacity); buf.limit(0); return buf; }
java
public static ByteBuffer allocate(int capacity) { ByteBuffer buf = ByteBuffer.allocate(capacity); buf.limit(0); return buf; }
[ "public", "static", "ByteBuffer", "allocate", "(", "int", "capacity", ")", "{", "ByteBuffer", "buf", "=", "ByteBuffer", ".", "allocate", "(", "capacity", ")", ";", "buf", ".", "limit", "(", "0", ")", ";", "return", "buf", ";", "}" ]
Allocate ByteBuffer in flush mode. The position and limit will both be zero, indicating that the buffer is empty and must be flipped before any data is put to it. @param capacity capacity of the allocated ByteBuffer @return Buffer
[ "Allocate", "ByteBuffer", "in", "flush", "mode", ".", "The", "position", "and", "limit", "will", "both", "be", "zero", "indicating", "that", "the", "buffer", "is", "empty", "and", "must", "be", "flipped", "before", "any", "data", "is", "put", "to", "it", ...
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/io/BufferUtils.java#L103-L107
102,319
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/io/BufferUtils.java
BufferUtils.allocateDirect
public static ByteBuffer allocateDirect(int capacity) { ByteBuffer buf = ByteBuffer.allocateDirect(capacity); buf.limit(0); return buf; }
java
public static ByteBuffer allocateDirect(int capacity) { ByteBuffer buf = ByteBuffer.allocateDirect(capacity); buf.limit(0); return buf; }
[ "public", "static", "ByteBuffer", "allocateDirect", "(", "int", "capacity", ")", "{", "ByteBuffer", "buf", "=", "ByteBuffer", ".", "allocateDirect", "(", "capacity", ")", ";", "buf", ".", "limit", "(", "0", ")", ";", "return", "buf", ";", "}" ]
Allocate ByteBuffer in flush mode. The position and limit will both be zero, indicating that the buffer is empty and in flush mode. @param capacity capacity of the allocated ByteBuffer @return Buffer
[ "Allocate", "ByteBuffer", "in", "flush", "mode", ".", "The", "position", "and", "limit", "will", "both", "be", "zero", "indicating", "that", "the", "buffer", "is", "empty", "and", "in", "flush", "mode", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/io/BufferUtils.java#L119-L123
102,320
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/io/BufferUtils.java
BufferUtils.clearToFill
public static void clearToFill(ByteBuffer buffer) { if (buffer != null) { buffer.position(0); buffer.limit(buffer.capacity()); } }
java
public static void clearToFill(ByteBuffer buffer) { if (buffer != null) { buffer.position(0); buffer.limit(buffer.capacity()); } }
[ "public", "static", "void", "clearToFill", "(", "ByteBuffer", "buffer", ")", "{", "if", "(", "buffer", "!=", "null", ")", "{", "buffer", ".", "position", "(", "0", ")", ";", "buffer", ".", "limit", "(", "buffer", ".", "capacity", "(", ")", ")", ";", ...
Clear the buffer to be empty in fill mode. The position is set to 0 and the limit is set to the capacity. @param buffer The buffer to clear.
[ "Clear", "the", "buffer", "to", "be", "empty", "in", "fill", "mode", ".", "The", "position", "is", "set", "to", "0", "and", "the", "limit", "is", "set", "to", "the", "capacity", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/io/BufferUtils.java#L149-L154
102,321
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/io/BufferUtils.java
BufferUtils.toArray
public static byte[] toArray(ByteBuffer buffer) { if (buffer.hasArray()) { byte[] array = buffer.array(); int from = buffer.arrayOffset() + buffer.position(); return Arrays.copyOfRange(array, from, from + buffer.remaining()); } else { byte[] to = new byte[...
java
public static byte[] toArray(ByteBuffer buffer) { if (buffer.hasArray()) { byte[] array = buffer.array(); int from = buffer.arrayOffset() + buffer.position(); return Arrays.copyOfRange(array, from, from + buffer.remaining()); } else { byte[] to = new byte[...
[ "public", "static", "byte", "[", "]", "toArray", "(", "ByteBuffer", "buffer", ")", "{", "if", "(", "buffer", ".", "hasArray", "(", ")", ")", "{", "byte", "[", "]", "array", "=", "buffer", ".", "array", "(", ")", ";", "int", "from", "=", "buffer", ...
Convert a ByteBuffer to a byte array. @param buffer The buffer to convert in flush mode. The buffer is not altered. @return An array of bytes duplicated from the buffer.
[ "Convert", "a", "ByteBuffer", "to", "a", "byte", "array", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/io/BufferUtils.java#L220-L230
102,322
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/io/BufferUtils.java
BufferUtils.compact
public static boolean compact(ByteBuffer buffer) { if (buffer.position() == 0) return false; boolean full = buffer.limit() == buffer.capacity(); buffer.compact().flip(); return full && buffer.limit() < buffer.capacity(); }
java
public static boolean compact(ByteBuffer buffer) { if (buffer.position() == 0) return false; boolean full = buffer.limit() == buffer.capacity(); buffer.compact().flip(); return full && buffer.limit() < buffer.capacity(); }
[ "public", "static", "boolean", "compact", "(", "ByteBuffer", "buffer", ")", "{", "if", "(", "buffer", ".", "position", "(", ")", "==", "0", ")", "return", "false", ";", "boolean", "full", "=", "buffer", ".", "limit", "(", ")", "==", "buffer", ".", "c...
Compact the buffer @param buffer the buffer to compact @return true if the compact made a full buffer have space
[ "Compact", "the", "buffer" ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/io/BufferUtils.java#L302-L308
102,323
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/io/BufferUtils.java
BufferUtils.append
public static void append(ByteBuffer to, byte[] b, int off, int len) throws BufferOverflowException { int pos = flipToFill(to); try { to.put(b, off, len); } finally { flipToFlush(to, pos); } }
java
public static void append(ByteBuffer to, byte[] b, int off, int len) throws BufferOverflowException { int pos = flipToFill(to); try { to.put(b, off, len); } finally { flipToFlush(to, pos); } }
[ "public", "static", "void", "append", "(", "ByteBuffer", "to", ",", "byte", "[", "]", "b", ",", "int", "off", ",", "int", "len", ")", "throws", "BufferOverflowException", "{", "int", "pos", "=", "flipToFill", "(", "to", ")", ";", "try", "{", "to", "....
Append bytes to a buffer. @param to Buffer is flush mode @param b bytes to append @param off offset into byte @param len length to append @throws BufferOverflowException if unable to append buffer due to space limits
[ "Append", "bytes", "to", "a", "buffer", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/io/BufferUtils.java#L369-L376
102,324
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/io/BufferUtils.java
BufferUtils.append
public static void append(ByteBuffer to, byte b) { int pos = flipToFill(to); try { to.put(b); } finally { flipToFlush(to, pos); } }
java
public static void append(ByteBuffer to, byte b) { int pos = flipToFill(to); try { to.put(b); } finally { flipToFlush(to, pos); } }
[ "public", "static", "void", "append", "(", "ByteBuffer", "to", ",", "byte", "b", ")", "{", "int", "pos", "=", "flipToFill", "(", "to", ")", ";", "try", "{", "to", ".", "put", "(", "b", ")", ";", "}", "finally", "{", "flipToFlush", "(", "to", ",",...
Appends a byte to a buffer @param to Buffer is flush mode @param b byte to append
[ "Appends", "a", "byte", "to", "a", "buffer" ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/io/BufferUtils.java#L386-L393
102,325
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/io/BufferUtils.java
BufferUtils.toBuffer
public static ByteBuffer toBuffer(byte[] array) { if (array == null) return EMPTY_BUFFER; return toBuffer(array, 0, array.length); }
java
public static ByteBuffer toBuffer(byte[] array) { if (array == null) return EMPTY_BUFFER; return toBuffer(array, 0, array.length); }
[ "public", "static", "ByteBuffer", "toBuffer", "(", "byte", "[", "]", "array", ")", "{", "if", "(", "array", "==", "null", ")", "return", "EMPTY_BUFFER", ";", "return", "toBuffer", "(", "array", ",", "0", ",", "array", ".", "length", ")", ";", "}" ]
Create a new ByteBuffer using provided byte array. @param array the byte array to back buffer with. @return ByteBuffer with provided byte array, in flush mode
[ "Create", "a", "new", "ByteBuffer", "using", "provided", "byte", "array", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/io/BufferUtils.java#L795-L799
102,326
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/io/BufferUtils.java
BufferUtils.toBuffer
public static ByteBuffer toBuffer(byte array[], int offset, int length) { if (array == null) return EMPTY_BUFFER; return ByteBuffer.wrap(array, offset, length); }
java
public static ByteBuffer toBuffer(byte array[], int offset, int length) { if (array == null) return EMPTY_BUFFER; return ByteBuffer.wrap(array, offset, length); }
[ "public", "static", "ByteBuffer", "toBuffer", "(", "byte", "array", "[", "]", ",", "int", "offset", ",", "int", "length", ")", "{", "if", "(", "array", "==", "null", ")", "return", "EMPTY_BUFFER", ";", "return", "ByteBuffer", ".", "wrap", "(", "array", ...
Create a new ByteBuffer using the provided byte array. @param array the byte array to use. @param offset the offset within the byte array to use from @param length the length in bytes of the array to use @return ByteBuffer with provided byte array, in flush mode
[ "Create", "a", "new", "ByteBuffer", "using", "the", "provided", "byte", "array", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/io/BufferUtils.java#L809-L813
102,327
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/io/BufferUtils.java
BufferUtils.toDetailString
public static String toDetailString(ByteBuffer buffer) { if (buffer == null) return "null"; StringBuilder buf = new StringBuilder(); idString(buffer, buf); buf.append("[p="); buf.append(buffer.position()); buf.append(",l="); buf.append(buffer.limit())...
java
public static String toDetailString(ByteBuffer buffer) { if (buffer == null) return "null"; StringBuilder buf = new StringBuilder(); idString(buffer, buf); buf.append("[p="); buf.append(buffer.position()); buf.append(",l="); buf.append(buffer.limit())...
[ "public", "static", "String", "toDetailString", "(", "ByteBuffer", "buffer", ")", "{", "if", "(", "buffer", "==", "null", ")", "return", "\"null\"", ";", "StringBuilder", "buf", "=", "new", "StringBuilder", "(", ")", ";", "idString", "(", "buffer", ",", "b...
Convert Buffer to a detail debug string of pointers and content @param buffer the buffer to generate a detail string from @return A string showing the pointers and content of the buffer
[ "Convert", "Buffer", "to", "a", "detail", "debug", "string", "of", "pointers", "and", "content" ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/io/BufferUtils.java#L920-L941
102,328
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/io/BufferUtils.java
BufferUtils.toHexSummary
public static String toHexSummary(ByteBuffer buffer) { if (buffer == null) return "null"; StringBuilder buf = new StringBuilder(); buf.append("b[").append(buffer.remaining()).append("]="); for (int i = buffer.position(); i < buffer.limit(); i++) { TypeUtils.toHex...
java
public static String toHexSummary(ByteBuffer buffer) { if (buffer == null) return "null"; StringBuilder buf = new StringBuilder(); buf.append("b[").append(buffer.remaining()).append("]="); for (int i = buffer.position(); i < buffer.limit(); i++) { TypeUtils.toHex...
[ "public", "static", "String", "toHexSummary", "(", "ByteBuffer", "buffer", ")", "{", "if", "(", "buffer", "==", "null", ")", "return", "\"null\"", ";", "StringBuilder", "buf", "=", "new", "StringBuilder", "(", ")", ";", "buf", ".", "append", "(", "\"b[\"",...
Convert buffer to a Hex Summary String. @param buffer the buffer to generate a hex byte summary from @return A string showing a summary of the content in hex
[ "Convert", "buffer", "to", "a", "Hex", "Summary", "String", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/io/BufferUtils.java#L999-L1013
102,329
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/io/BufferUtils.java
BufferUtils.toHexString
public static String toHexString(ByteBuffer buffer) { if (buffer == null) return "null"; return TypeUtils.toHexString(toArray(buffer)); }
java
public static String toHexString(ByteBuffer buffer) { if (buffer == null) return "null"; return TypeUtils.toHexString(toArray(buffer)); }
[ "public", "static", "String", "toHexString", "(", "ByteBuffer", "buffer", ")", "{", "if", "(", "buffer", "==", "null", ")", "return", "\"null\"", ";", "return", "TypeUtils", ".", "toHexString", "(", "toArray", "(", "buffer", ")", ")", ";", "}" ]
Convert buffer to a Hex String. @param buffer the buffer to generate a hex byte summary from @return A hex string
[ "Convert", "buffer", "to", "a", "Hex", "String", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/io/BufferUtils.java#L1023-L1027
102,330
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/collection/LazyList.java
LazyList.addArray
public static Object addArray(Object list, Object[] array) { for (int i = 0; array != null && i < array.length; i++) list = LazyList.add(list, array[i]); return list; }
java
public static Object addArray(Object list, Object[] array) { for (int i = 0; array != null && i < array.length; i++) list = LazyList.add(list, array[i]); return list; }
[ "public", "static", "Object", "addArray", "(", "Object", "list", ",", "Object", "[", "]", "array", ")", "{", "for", "(", "int", "i", "=", "0", ";", "array", "!=", "null", "&&", "i", "<", "array", ".", "length", ";", "i", "++", ")", "list", "=", ...
Add the contents of an array to a LazyList @param list The list to add to or null if none yet created. @param array The array whose contents should be added. @return The lazylist created or added to.
[ "Add", "the", "contents", "of", "an", "array", "to", "a", "LazyList" ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/collection/LazyList.java#L126-L130
102,331
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/collection/LazyList.java
LazyList.ensureSize
public static Object ensureSize(Object list, int initialSize) { if (list == null) return new ArrayList<Object>(initialSize); if (list instanceof ArrayList) { ArrayList<?> ol = (ArrayList<?>) list; if (ol.size() > initialSize) return ol; Arr...
java
public static Object ensureSize(Object list, int initialSize) { if (list == null) return new ArrayList<Object>(initialSize); if (list instanceof ArrayList) { ArrayList<?> ol = (ArrayList<?>) list; if (ol.size() > initialSize) return ol; Arr...
[ "public", "static", "Object", "ensureSize", "(", "Object", "list", ",", "int", "initialSize", ")", "{", "if", "(", "list", "==", "null", ")", "return", "new", "ArrayList", "<", "Object", ">", "(", "initialSize", ")", ";", "if", "(", "list", "instanceof",...
Ensure the capacity of the underlying list. @param list the list to grow @param initialSize the size to grow to @return the new List with new size
[ "Ensure", "the", "capacity", "of", "the", "underlying", "list", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/collection/LazyList.java#L139-L153
102,332
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/collection/LazyList.java
LazyList.hasEntry
public static boolean hasEntry(Object list) { if (list == null) return false; if (list instanceof List) return !((List<?>) list).isEmpty(); return true; }
java
public static boolean hasEntry(Object list) { if (list == null) return false; if (list instanceof List) return !((List<?>) list).isEmpty(); return true; }
[ "public", "static", "boolean", "hasEntry", "(", "Object", "list", ")", "{", "if", "(", "list", "==", "null", ")", "return", "false", ";", "if", "(", "list", "instanceof", "List", ")", "return", "!", "(", "(", "List", "<", "?", ">", ")", "list", ")"...
Simple utility method to test if List has at least 1 entry. @param list a LazyList, {@link List} or {@link Object} @return true if not-null and is not empty
[ "Simple", "utility", "method", "to", "test", "if", "List", "has", "at", "least", "1", "entry", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/collection/LazyList.java#L229-L235
102,333
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/collection/LazyList.java
LazyList.toArray
public static Object toArray(Object list, Class<?> clazz) { if (list == null) return Array.newInstance(clazz, 0); if (list instanceof List) { List<?> l = (List<?>) list; if (clazz.isPrimitive()) { Object a = Array.newInstance(clazz, l.size()); ...
java
public static Object toArray(Object list, Class<?> clazz) { if (list == null) return Array.newInstance(clazz, 0); if (list instanceof List) { List<?> l = (List<?>) list; if (clazz.isPrimitive()) { Object a = Array.newInstance(clazz, l.size()); ...
[ "public", "static", "Object", "toArray", "(", "Object", "list", ",", "Class", "<", "?", ">", "clazz", ")", "{", "if", "(", "list", "==", "null", ")", "return", "Array", ".", "newInstance", "(", "clazz", ",", "0", ")", ";", "if", "(", "list", "insta...
Convert a lazylist to an array @param list The list to convert @param clazz The class of the array, which may be a primitive type @return array of the lazylist entries passed in
[ "Convert", "a", "lazylist", "to", "an", "array" ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/collection/LazyList.java#L276-L295
102,334
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/collection/LazyList.java
LazyList.size
public static int size(Object list) { if (list == null) return 0; if (list instanceof List) return ((List<?>) list).size(); return 1; }
java
public static int size(Object list) { if (list == null) return 0; if (list instanceof List) return ((List<?>) list).size(); return 1; }
[ "public", "static", "int", "size", "(", "Object", "list", ")", "{", "if", "(", "list", "==", "null", ")", "return", "0", ";", "if", "(", "list", "instanceof", "List", ")", "return", "(", "(", "List", "<", "?", ">", ")", "list", ")", ".", "size", ...
The size of a lazy List @param list A LazyList returned from LazyList.add(Object) or null @return the size of the list.
[ "The", "size", "of", "a", "lazy", "List" ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/collection/LazyList.java#L303-L309
102,335
hypercube1024/firefly
firefly/src/main/java/com/firefly/codec/http2/model/MultiPartWriter.java
MultiPartWriter.close
@Override public void close() throws IOException { try { if (inPart) out.write(__CRLF); out.write(__DASHDASH); out.write(boundary); out.write(__DASHDASH); out.write(__CRLF); inPart = false; } finally { ...
java
@Override public void close() throws IOException { try { if (inPart) out.write(__CRLF); out.write(__DASHDASH); out.write(boundary); out.write(__DASHDASH); out.write(__CRLF); inPart = false; } finally { ...
[ "@", "Override", "public", "void", "close", "(", ")", "throws", "IOException", "{", "try", "{", "if", "(", "inPart", ")", "out", ".", "write", "(", "__CRLF", ")", ";", "out", ".", "write", "(", "__DASHDASH", ")", ";", "out", ".", "write", "(", "bou...
End the current part. @throws IOException IOException
[ "End", "the", "current", "part", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly/src/main/java/com/firefly/codec/http2/model/MultiPartWriter.java#L31-L44
102,336
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/heartbeat/HealthCheck.java
HealthCheck.register
public void register(Task task) { Optional.ofNullable(task) .filter(t -> t.getTask() != null) .filter(t -> StringUtils.hasText(t.getName())) .ifPresent(t -> checkTaskMap.put(t.getName(), t)); }
java
public void register(Task task) { Optional.ofNullable(task) .filter(t -> t.getTask() != null) .filter(t -> StringUtils.hasText(t.getName())) .ifPresent(t -> checkTaskMap.put(t.getName(), t)); }
[ "public", "void", "register", "(", "Task", "task", ")", "{", "Optional", ".", "ofNullable", "(", "task", ")", ".", "filter", "(", "t", "->", "t", ".", "getTask", "(", ")", "!=", "null", ")", ".", "filter", "(", "t", "->", "StringUtils", ".", "hasTe...
Register a health check task. @param task The task function.
[ "Register", "a", "health", "check", "task", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/heartbeat/HealthCheck.java#L66-L71
102,337
hypercube1024/firefly
firefly/src/main/java/com/firefly/codec/http2/hpack/MetaDataBuilder.java
MetaDataBuilder.checkSize
public void checkSize(int length, boolean huffman) throws HpackException.SessionException { // Apply a huffman fudge factor if (huffman) length = (length * 4) / 3; if ((_size + length) > _maxSize) throw new HpackException.SessionException("Header too large %d > %d", _size...
java
public void checkSize(int length, boolean huffman) throws HpackException.SessionException { // Apply a huffman fudge factor if (huffman) length = (length * 4) / 3; if ((_size + length) > _maxSize) throw new HpackException.SessionException("Header too large %d > %d", _size...
[ "public", "void", "checkSize", "(", "int", "length", ",", "boolean", "huffman", ")", "throws", "HpackException", ".", "SessionException", "{", "// Apply a huffman fudge factor", "if", "(", "huffman", ")", "length", "=", "(", "length", "*", "4", ")", "/", "3", ...
Check that the max size will not be exceeded. @param length the length @param huffman the huffman name @throws HpackException.SessionException in case of size errors
[ "Check", "that", "the", "max", "size", "will", "not", "be", "exceeded", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly/src/main/java/com/firefly/codec/http2/hpack/MetaDataBuilder.java#L239-L245
102,338
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/time/HashTimeWheel.java
HashTimeWheel.add
public Future add(long delay, Runnable run) { final int curSlot = currentSlot; final int ticks = delay > interval ? (int) (delay / interval) : 1; // figure out how many ticks need final int index = (curSlot + (ticks % maxTimers)) % maxTimers; // figure out the wheel's index final int ro...
java
public Future add(long delay, Runnable run) { final int curSlot = currentSlot; final int ticks = delay > interval ? (int) (delay / interval) : 1; // figure out how many ticks need final int index = (curSlot + (ticks % maxTimers)) % maxTimers; // figure out the wheel's index final int ro...
[ "public", "Future", "add", "(", "long", "delay", ",", "Runnable", "run", ")", "{", "final", "int", "curSlot", "=", "currentSlot", ";", "final", "int", "ticks", "=", "delay", ">", "interval", "?", "(", "int", ")", "(", "delay", "/", "interval", ")", "...
add a task @param delay after x milliseconds than execute runnable @param run run task in future @return The task future
[ "add", "a", "task" ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/time/HashTimeWheel.java#L40-L51
102,339
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/collection/HashedArrayTree.java
HashedArrayTree.add
@Override public boolean add(T elem) { /* First, check if we're completely out of space. If so, do a resize * to ensure we do indeed have room. */ if (size() == mArrays.length * mArrays.length) grow(); /* Compute the (arr, index) pair for the next posi...
java
@Override public boolean add(T elem) { /* First, check if we're completely out of space. If so, do a resize * to ensure we do indeed have room. */ if (size() == mArrays.length * mArrays.length) grow(); /* Compute the (arr, index) pair for the next posi...
[ "@", "Override", "public", "boolean", "add", "(", "T", "elem", ")", "{", "/* First, check if we're completely out of space. If so, do a resize\r\n * to ensure we do indeed have room.\r\n */", "if", "(", "size", "(", ")", "==", "mArrays", ".", "length", "*", ...
Adds a new element to the HashedArrayTree. @param elem The element to add. @return true
[ "Adds", "a", "new", "element", "to", "the", "HashedArrayTree", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/collection/HashedArrayTree.java#L139-L168
102,340
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/collection/HashedArrayTree.java
HashedArrayTree.set
@Override public T set(int index, T elem) { /* Find out where to look. */ final int offset = computeOffset(index); final int arrIndex = computeIndex(index); /* Cache the value there and write the new one. */ T result = mArrays[offset][arrIndex]; mArrays[offse...
java
@Override public T set(int index, T elem) { /* Find out where to look. */ final int offset = computeOffset(index); final int arrIndex = computeIndex(index); /* Cache the value there and write the new one. */ T result = mArrays[offset][arrIndex]; mArrays[offse...
[ "@", "Override", "public", "T", "set", "(", "int", "index", ",", "T", "elem", ")", "{", "/* Find out where to look. */", "final", "int", "offset", "=", "computeOffset", "(", "index", ")", ";", "final", "int", "arrIndex", "=", "computeIndex", "(", "index", ...
Sets the element at the specified position to the indicated value. If the index is out of bounds, throws an IndexOutOfBounds exception. @param index The index at which to set the value. @param elem The element to store at that position. @return The value initially at that location. @throws IndexOutOfBoundsException I...
[ "Sets", "the", "element", "at", "the", "specified", "position", "to", "the", "indicated", "value", ".", "If", "the", "index", "is", "out", "of", "bounds", "throws", "an", "IndexOutOfBounds", "exception", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/collection/HashedArrayTree.java#L179-L191
102,341
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/collection/HashedArrayTree.java
HashedArrayTree.get
@Override public T get(int index) { /* Check that this is a valid index. */ if (index < 0 || index >= size()) throw new IndexOutOfBoundsException("Index " + index + ", size " + size()); /* Look up the element. */ return mArrays[computeOffset(index)][computeIndex(i...
java
@Override public T get(int index) { /* Check that this is a valid index. */ if (index < 0 || index >= size()) throw new IndexOutOfBoundsException("Index " + index + ", size " + size()); /* Look up the element. */ return mArrays[computeOffset(index)][computeIndex(i...
[ "@", "Override", "public", "T", "get", "(", "int", "index", ")", "{", "/* Check that this is a valid index. */", "if", "(", "index", "<", "0", "||", "index", ">=", "size", "(", ")", ")", "throw", "new", "IndexOutOfBoundsException", "(", "\"Index \"", "+", "i...
Returns the value of the element at the specified position. @param index The index at which to query. @return The value of the element at that position. @throws IndexOutOfBoundsException If the index is invalid.
[ "Returns", "the", "value", "of", "the", "element", "at", "the", "specified", "position", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/collection/HashedArrayTree.java#L200-L208
102,342
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/collection/HashedArrayTree.java
HashedArrayTree.add
@Override public void add(int index, T elem) { /* Confirm the validity of the index. */ if (index < 0 || index >= size()) throw new IndexOutOfBoundsException("Index " + index + ", size " + size()); /* Add a dummy element to ensure that everything resizes correctly. ...
java
@Override public void add(int index, T elem) { /* Confirm the validity of the index. */ if (index < 0 || index >= size()) throw new IndexOutOfBoundsException("Index " + index + ", size " + size()); /* Add a dummy element to ensure that everything resizes correctly. ...
[ "@", "Override", "public", "void", "add", "(", "int", "index", ",", "T", "elem", ")", "{", "/* Confirm the validity of the index. */", "if", "(", "index", "<", "0", "||", "index", ">=", "size", "(", ")", ")", "throw", "new", "IndexOutOfBoundsException", "(",...
Adds the specified element at the position just before the specified index. @param index The index just before which to insert. @param elem The value to insert @throws IndexOutOfBoundsException if the index is invalid.
[ "Adds", "the", "specified", "element", "at", "the", "position", "just", "before", "the", "specified", "index", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/collection/HashedArrayTree.java#L218-L237
102,343
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/collection/HashedArrayTree.java
HashedArrayTree.remove
@Override public T remove(int index) { /* Cache the value at the indicated position; this also does the bounds * check. */ T result = get(index); /* Use a naive shuffle-down algorithm to reposition elements after * the removed one. */ fo...
java
@Override public T remove(int index) { /* Cache the value at the indicated position; this also does the bounds * check. */ T result = get(index); /* Use a naive shuffle-down algorithm to reposition elements after * the removed one. */ fo...
[ "@", "Override", "public", "T", "remove", "(", "int", "index", ")", "{", "/* Cache the value at the indicated position; this also does the bounds\r\n * check.\r\n */", "T", "result", "=", "get", "(", "index", ")", ";", "/* Use a naive shuffle-down algorithm to r...
Removes the element at the specified position from the HashedArrayTree. @param index The index of the element to remove. @return The value of the element at that position. @throws IndexOutOfBoundsException If the index is invalid.
[ "Removes", "the", "element", "at", "the", "specified", "position", "from", "the", "HashedArrayTree", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/collection/HashedArrayTree.java#L246-L276
102,344
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/collection/HashedArrayTree.java
HashedArrayTree.grow
private void grow() { /* Double the size of the topmost array. */ T[][] newArrays = (T[][]) new Object[mArrays.length * 2][]; /* The new arrays each have size 2^(n + 1). We need 2^(n - 1) of them * to hold the old elements. Allocate those here and copy everything * ove...
java
private void grow() { /* Double the size of the topmost array. */ T[][] newArrays = (T[][]) new Object[mArrays.length * 2][]; /* The new arrays each have size 2^(n + 1). We need 2^(n - 1) of them * to hold the old elements. Allocate those here and copy everything * ove...
[ "private", "void", "grow", "(", ")", "{", "/* Double the size of the topmost array. */", "T", "[", "]", "[", "]", "newArrays", "=", "(", "T", "[", "]", "[", "]", ")", "new", "Object", "[", "mArrays", ".", "length", "*", "2", "]", "[", "", "]", ";", ...
Grows the internal representation by doubling the size of the topmost array and copying the appropriate number of elements over.
[ "Grows", "the", "internal", "representation", "by", "doubling", "the", "size", "of", "the", "topmost", "array", "and", "copying", "the", "appropriate", "number", "of", "elements", "over", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/collection/HashedArrayTree.java#L322-L349
102,345
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/collection/HashedArrayTree.java
HashedArrayTree.shrink
private void shrink() { /* If the size of the topmost array is at its minimum, don't do * anything. This doesn't change the asymptotic memory usage because * we only do this for small arrays. */ if (mArrays.length == kMinArraySize) return; /* Otherwise, we cur...
java
private void shrink() { /* If the size of the topmost array is at its minimum, don't do * anything. This doesn't change the asymptotic memory usage because * we only do this for small arrays. */ if (mArrays.length == kMinArraySize) return; /* Otherwise, we cur...
[ "private", "void", "shrink", "(", ")", "{", "/* If the size of the topmost array is at its minimum, don't do\r\n * anything. This doesn't change the asymptotic memory usage because\r\n * we only do this for small arrays.\r\n */", "if", "(", "mArrays", ".", "length", ...
Decreases the size of the HAT by shrinking into a better fit.
[ "Decreases", "the", "size", "of", "the", "HAT", "by", "shrinking", "into", "a", "better", "fit", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/collection/HashedArrayTree.java#L354-L392
102,346
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/concurrent/ReentrantSpinLocker.java
ReentrantSpinLocker.lock
public void lock() { Thread t = Thread.currentThread(); if (t == owner.get()) { // if re-enter, increment the count. count++; return; } while (owner.compareAndSet(null, t)) { } //spin }
java
public void lock() { Thread t = Thread.currentThread(); if (t == owner.get()) { // if re-enter, increment the count. count++; return; } while (owner.compareAndSet(null, t)) { } //spin }
[ "public", "void", "lock", "(", ")", "{", "Thread", "t", "=", "Thread", ".", "currentThread", "(", ")", ";", "if", "(", "t", "==", "owner", ".", "get", "(", ")", ")", "{", "// if re-enter, increment the count.", "count", "++", ";", "return", ";", "}", ...
reentrant count of a thread, no need to be volatile
[ "reentrant", "count", "of", "a", "thread", "no", "need", "to", "be", "volatile" ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/concurrent/ReentrantSpinLocker.java#L17-L25
102,347
hypercube1024/firefly
firefly-slf4j/src/main/java/com/firefly/utils/log/ThreadLocalMappedDiagnosticContext.java
ThreadLocalMappedDiagnosticContext.getCopyOfContextMap
@Override public Map<String, String> getCopyOfContextMap() { Map<String, String> oldMap = inheritableThreadLocal.get(); if (oldMap != null) { return new HashMap<>(oldMap); } else { return null; } }
java
@Override public Map<String, String> getCopyOfContextMap() { Map<String, String> oldMap = inheritableThreadLocal.get(); if (oldMap != null) { return new HashMap<>(oldMap); } else { return null; } }
[ "@", "Override", "public", "Map", "<", "String", ",", "String", ">", "getCopyOfContextMap", "(", ")", "{", "Map", "<", "String", ",", "String", ">", "oldMap", "=", "inheritableThreadLocal", ".", "get", "(", ")", ";", "if", "(", "oldMap", "!=", "null", ...
Return a copy of the current thread's context map. Returned value may be null.
[ "Return", "a", "copy", "of", "the", "current", "thread", "s", "context", "map", ".", "Returned", "value", "may", "be", "null", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-slf4j/src/main/java/com/firefly/utils/log/ThreadLocalMappedDiagnosticContext.java#L102-L110
102,348
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/lang/AtomicBiInteger.java
AtomicBiInteger.getAndSetHi
public int getAndSetHi(int hi) { while (true) { long encoded = get(); long update = encodeHi(encoded, hi); if (compareAndSet(encoded, update)) return getHi(encoded); } }
java
public int getAndSetHi(int hi) { while (true) { long encoded = get(); long update = encodeHi(encoded, hi); if (compareAndSet(encoded, update)) return getHi(encoded); } }
[ "public", "int", "getAndSetHi", "(", "int", "hi", ")", "{", "while", "(", "true", ")", "{", "long", "encoded", "=", "get", "(", ")", ";", "long", "update", "=", "encodeHi", "(", "encoded", ",", "hi", ")", ";", "if", "(", "compareAndSet", "(", "enco...
Atomically sets the hi value without changing the lo value. @param hi the new hi value @return the previous hi value
[ "Atomically", "sets", "the", "hi", "value", "without", "changing", "the", "lo", "value", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/lang/AtomicBiInteger.java#L29-L36
102,349
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/lang/AtomicBiInteger.java
AtomicBiInteger.getAndSetLo
public int getAndSetLo(int lo) { while (true) { long encoded = get(); long update = encodeLo(encoded, lo); if (compareAndSet(encoded, update)) return getLo(encoded); } }
java
public int getAndSetLo(int lo) { while (true) { long encoded = get(); long update = encodeLo(encoded, lo); if (compareAndSet(encoded, update)) return getLo(encoded); } }
[ "public", "int", "getAndSetLo", "(", "int", "lo", ")", "{", "while", "(", "true", ")", "{", "long", "encoded", "=", "get", "(", ")", ";", "long", "update", "=", "encodeLo", "(", "encoded", ",", "lo", ")", ";", "if", "(", "compareAndSet", "(", "enco...
Atomically sets the lo value without changing the hi value. @param lo the new lo value @return the previous lo value
[ "Atomically", "sets", "the", "lo", "value", "without", "changing", "the", "hi", "value", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/lang/AtomicBiInteger.java#L44-L51
102,350
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/lang/AtomicBiInteger.java
AtomicBiInteger.addAndGetHi
public int addAndGetHi(int delta) { while (true) { long encoded = get(); int hi = getHi(encoded) + delta; long update = encodeHi(encoded, hi); if (compareAndSet(encoded, update)) return hi; } }
java
public int addAndGetHi(int delta) { while (true) { long encoded = get(); int hi = getHi(encoded) + delta; long update = encodeHi(encoded, hi); if (compareAndSet(encoded, update)) return hi; } }
[ "public", "int", "addAndGetHi", "(", "int", "delta", ")", "{", "while", "(", "true", ")", "{", "long", "encoded", "=", "get", "(", ")", ";", "int", "hi", "=", "getHi", "(", "encoded", ")", "+", "delta", ";", "long", "update", "=", "encodeHi", "(", ...
Atomically adds the given delta to the current hi value, returning the updated hi value. @param delta the delta to apply @return the updated hi value
[ "Atomically", "adds", "the", "given", "delta", "to", "the", "current", "hi", "value", "returning", "the", "updated", "hi", "value", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/lang/AtomicBiInteger.java#L143-L151
102,351
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/lang/AtomicBiInteger.java
AtomicBiInteger.addAndGetLo
public int addAndGetLo(int delta) { while (true) { long encoded = get(); int lo = getLo(encoded) + delta; long update = encodeLo(encoded, lo); if (compareAndSet(encoded, update)) return lo; } }
java
public int addAndGetLo(int delta) { while (true) { long encoded = get(); int lo = getLo(encoded) + delta; long update = encodeLo(encoded, lo); if (compareAndSet(encoded, update)) return lo; } }
[ "public", "int", "addAndGetLo", "(", "int", "delta", ")", "{", "while", "(", "true", ")", "{", "long", "encoded", "=", "get", "(", ")", ";", "int", "lo", "=", "getLo", "(", "encoded", ")", "+", "delta", ";", "long", "update", "=", "encodeLo", "(", ...
Atomically adds the given delta to the current lo value, returning the updated lo value. @param delta the delta to apply @return the updated lo value
[ "Atomically", "adds", "the", "given", "delta", "to", "the", "current", "lo", "value", "returning", "the", "updated", "lo", "value", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/lang/AtomicBiInteger.java#L159-L167
102,352
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/lang/AtomicBiInteger.java
AtomicBiInteger.add
public void add(int deltaHi, int deltaLo) { while (true) { long encoded = get(); long update = encode(getHi(encoded) + deltaHi, getLo(encoded) + deltaLo); if (compareAndSet(encoded, update)) return; } }
java
public void add(int deltaHi, int deltaLo) { while (true) { long encoded = get(); long update = encode(getHi(encoded) + deltaHi, getLo(encoded) + deltaLo); if (compareAndSet(encoded, update)) return; } }
[ "public", "void", "add", "(", "int", "deltaHi", ",", "int", "deltaLo", ")", "{", "while", "(", "true", ")", "{", "long", "encoded", "=", "get", "(", ")", ";", "long", "update", "=", "encode", "(", "getHi", "(", "encoded", ")", "+", "deltaHi", ",", ...
Atomically adds the given deltas to the current hi and lo values. @param deltaHi the delta to apply to the hi value @param deltaLo the delta to apply to the lo value
[ "Atomically", "adds", "the", "given", "deltas", "to", "the", "current", "hi", "and", "lo", "values", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/lang/AtomicBiInteger.java#L175-L182
102,353
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/lang/AtomicBiInteger.java
AtomicBiInteger.encode
public static long encode(int hi, int lo) { long h = ((long) hi) & 0xFFFF_FFFFL; long l = ((long) lo) & 0xFFFF_FFFFL; return (h << 32) + l; }
java
public static long encode(int hi, int lo) { long h = ((long) hi) & 0xFFFF_FFFFL; long l = ((long) lo) & 0xFFFF_FFFFL; return (h << 32) + l; }
[ "public", "static", "long", "encode", "(", "int", "hi", ",", "int", "lo", ")", "{", "long", "h", "=", "(", "(", "long", ")", "hi", ")", "&", "0xFFFF_FFFF", "", "L", ";", "long", "l", "=", "(", "(", "long", ")", "lo", ")", "&", "0xFFFF_FFFF", ...
Encodes hi and lo values into a long. @param hi the hi value @param lo the lo value @return the encoded value
[ "Encodes", "hi", "and", "lo", "values", "into", "a", "long", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/lang/AtomicBiInteger.java#L211-L215
102,354
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/lang/AtomicBiInteger.java
AtomicBiInteger.encodeHi
public static long encodeHi(long encoded, int hi) { long h = ((long) hi) & 0xFFFF_FFFFL; long l = encoded & 0xFFFF_FFFFL; return (h << 32) + l; }
java
public static long encodeHi(long encoded, int hi) { long h = ((long) hi) & 0xFFFF_FFFFL; long l = encoded & 0xFFFF_FFFFL; return (h << 32) + l; }
[ "public", "static", "long", "encodeHi", "(", "long", "encoded", ",", "int", "hi", ")", "{", "long", "h", "=", "(", "(", "long", ")", "hi", ")", "&", "0xFFFF_FFFF", "", "L", ";", "long", "l", "=", "encoded", "&", "0xFFFF_FFFF", "", "L", ";", "retu...
Sets the hi value into the given encoded value. @param encoded the encoded value @param hi the hi value @return the new encoded value
[ "Sets", "the", "hi", "value", "into", "the", "given", "encoded", "value", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/lang/AtomicBiInteger.java#L224-L228
102,355
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/lang/AtomicBiInteger.java
AtomicBiInteger.encodeLo
public static long encodeLo(long encoded, int lo) { long h = (encoded >> 32) & 0xFFFF_FFFFL; long l = ((long) lo) & 0xFFFF_FFFFL; return (h << 32) + l; }
java
public static long encodeLo(long encoded, int lo) { long h = (encoded >> 32) & 0xFFFF_FFFFL; long l = ((long) lo) & 0xFFFF_FFFFL; return (h << 32) + l; }
[ "public", "static", "long", "encodeLo", "(", "long", "encoded", ",", "int", "lo", ")", "{", "long", "h", "=", "(", "encoded", ">>", "32", ")", "&", "0xFFFF_FFFF", "", "L", ";", "long", "l", "=", "(", "(", "long", ")", "lo", ")", "&", "0xFFFF_FFFF...
Sets the lo value into the given encoded value. @param encoded the encoded value @param lo the lo value @return the new encoded value
[ "Sets", "the", "lo", "value", "into", "the", "given", "encoded", "value", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/lang/AtomicBiInteger.java#L237-L241
102,356
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/collection/MultiMap.java
MultiMap.getValues
public List<V> getValues(String name) { List<V> vals = super.get(name); if ((vals == null) || vals.isEmpty()) { return null; } return vals; }
java
public List<V> getValues(String name) { List<V> vals = super.get(name); if ((vals == null) || vals.isEmpty()) { return null; } return vals; }
[ "public", "List", "<", "V", ">", "getValues", "(", "String", "name", ")", "{", "List", "<", "V", ">", "vals", "=", "super", ".", "get", "(", "name", ")", ";", "if", "(", "(", "vals", "==", "null", ")", "||", "vals", ".", "isEmpty", "(", ")", ...
Get multiple values. Single valued entries are converted to singleton lists. @param name The entry key. @return Unmodifieable List of values.
[ "Get", "multiple", "values", ".", "Single", "valued", "entries", "are", "converted", "to", "singleton", "lists", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/collection/MultiMap.java#L32-L38
102,357
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/collection/MultiMap.java
MultiMap.putAllValues
public void putAllValues(Map<String, V> input) { for (Map.Entry<String, V> entry : input.entrySet()) { put(entry.getKey(), entry.getValue()); } }
java
public void putAllValues(Map<String, V> input) { for (Map.Entry<String, V> entry : input.entrySet()) { put(entry.getKey(), entry.getValue()); } }
[ "public", "void", "putAllValues", "(", "Map", "<", "String", ",", "V", ">", "input", ")", "{", "for", "(", "Map", ".", "Entry", "<", "String", ",", "V", ">", "entry", ":", "input", ".", "entrySet", "(", ")", ")", "{", "put", "(", "entry", ".", ...
Shorthand version of putAll @param input the input map
[ "Shorthand", "version", "of", "putAll" ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/collection/MultiMap.java#L111-L115
102,358
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/collection/MultiMap.java
MultiMap.addAllValues
public boolean addAllValues(MultiMap<V> map) { boolean merged = false; if ((map == null) || (map.isEmpty())) { // done return merged; } for (Map.Entry<String, List<V>> entry : map.entrySet()) { String name = entry.getKey(); List<V> values...
java
public boolean addAllValues(MultiMap<V> map) { boolean merged = false; if ((map == null) || (map.isEmpty())) { // done return merged; } for (Map.Entry<String, List<V>> entry : map.entrySet()) { String name = entry.getKey(); List<V> values...
[ "public", "boolean", "addAllValues", "(", "MultiMap", "<", "V", ">", "map", ")", "{", "boolean", "merged", "=", "false", ";", "if", "(", "(", "map", "==", "null", ")", "||", "(", "map", ".", "isEmpty", "(", ")", ")", ")", "{", "// done", "return", ...
Merge values. @param map the map to overlay on top of this one, merging together values if needed. @return true if an existing key was merged with potentially new values, false if either no change was made, or there were only new keys.
[ "Merge", "values", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/collection/MultiMap.java#L198-L218
102,359
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/lang/LeakDetector.java
LeakDetector.register
public PhantomReference<T> register(T object, Action0 leakCallback) { PhantomReference<T> ref = new PhantomReference<>(object, referenceQueue); registeredMap.put(ref, leakCallback); return ref; }
java
public PhantomReference<T> register(T object, Action0 leakCallback) { PhantomReference<T> ref = new PhantomReference<>(object, referenceQueue); registeredMap.put(ref, leakCallback); return ref; }
[ "public", "PhantomReference", "<", "T", ">", "register", "(", "T", "object", ",", "Action0", "leakCallback", ")", "{", "PhantomReference", "<", "T", ">", "ref", "=", "new", "PhantomReference", "<>", "(", "object", ",", "referenceQueue", ")", ";", "registered...
Register a tracked object. When the tracked object is released, you must call the clear method of the LeakDetector. @param object The tracked object @param leakCallback When the garbage collector cleans up the tracked object, if the tracked object is not released, that means the tracked object has leaked. The de...
[ "Register", "a", "tracked", "object", ".", "When", "the", "tracked", "object", "is", "released", "you", "must", "call", "the", "clear", "method", "of", "the", "LeakDetector", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/lang/LeakDetector.java#L100-L104
102,360
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/lang/LeakDetector.java
LeakDetector.clear
public void clear(PhantomReference<T> reference) { Optional.ofNullable(registeredMap.remove(reference)).ifPresent(a -> reference.clear()); }
java
public void clear(PhantomReference<T> reference) { Optional.ofNullable(registeredMap.remove(reference)).ifPresent(a -> reference.clear()); }
[ "public", "void", "clear", "(", "PhantomReference", "<", "T", ">", "reference", ")", "{", "Optional", ".", "ofNullable", "(", "registeredMap", ".", "remove", "(", "reference", ")", ")", ".", "ifPresent", "(", "a", "->", "reference", ".", "clear", "(", ")...
Clear tracked object @param reference The PhantomReference of tracked object
[ "Clear", "tracked", "object" ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/lang/LeakDetector.java#L111-L113
102,361
hypercube1024/firefly
firefly/src/main/java/com/firefly/codec/websocket/stream/IOState.java
IOState.onCloseLocal
public void onCloseLocal(CloseInfo closeInfo) { boolean open = false; synchronized (this) { ConnectionState initialState = this.state; if (LOG.isDebugEnabled()) LOG.debug("onCloseLocal({}) : {}", closeInfo, initialState); if (initialState == Connection...
java
public void onCloseLocal(CloseInfo closeInfo) { boolean open = false; synchronized (this) { ConnectionState initialState = this.state; if (LOG.isDebugEnabled()) LOG.debug("onCloseLocal({}) : {}", closeInfo, initialState); if (initialState == Connection...
[ "public", "void", "onCloseLocal", "(", "CloseInfo", "closeInfo", ")", "{", "boolean", "open", "=", "false", ";", "synchronized", "(", "this", ")", "{", "ConnectionState", "initialState", "=", "this", ".", "state", ";", "if", "(", "LOG", ".", "isDebugEnabled"...
A close handshake has been issued from the local endpoint @param closeInfo the close information
[ "A", "close", "handshake", "has", "been", "issued", "from", "the", "local", "endpoint" ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly/src/main/java/com/firefly/codec/websocket/stream/IOState.java#L194-L219
102,362
hypercube1024/firefly
firefly/src/main/java/com/firefly/codec/websocket/stream/IOState.java
IOState.onCloseRemote
public void onCloseRemote(CloseInfo closeInfo) { if (LOG.isDebugEnabled()) LOG.debug("onCloseRemote({})", closeInfo); ConnectionState event = null; synchronized (this) { if (this.state == ConnectionState.CLOSED) { // already closed return; ...
java
public void onCloseRemote(CloseInfo closeInfo) { if (LOG.isDebugEnabled()) LOG.debug("onCloseRemote({})", closeInfo); ConnectionState event = null; synchronized (this) { if (this.state == ConnectionState.CLOSED) { // already closed return; ...
[ "public", "void", "onCloseRemote", "(", "CloseInfo", "closeInfo", ")", "{", "if", "(", "LOG", ".", "isDebugEnabled", "(", ")", ")", "LOG", ".", "debug", "(", "\"onCloseRemote({})\"", ",", "closeInfo", ")", ";", "ConnectionState", "event", "=", "null", ";", ...
A close handshake has been received from the remote endpoint @param closeInfo the close information
[ "A", "close", "handshake", "has", "been", "received", "from", "the", "remote", "endpoint" ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly/src/main/java/com/firefly/codec/websocket/stream/IOState.java#L283-L322
102,363
hypercube1024/firefly
firefly/src/main/java/com/firefly/codec/websocket/stream/IOState.java
IOState.onFailedUpgrade
public void onFailedUpgrade() { assert (this.state == ConnectionState.CONNECTING); ConnectionState event = null; synchronized (this) { this.state = ConnectionState.CLOSED; cleanClose = false; inputAvailable = false; outputAvailable = false; ...
java
public void onFailedUpgrade() { assert (this.state == ConnectionState.CONNECTING); ConnectionState event = null; synchronized (this) { this.state = ConnectionState.CLOSED; cleanClose = false; inputAvailable = false; outputAvailable = false; ...
[ "public", "void", "onFailedUpgrade", "(", ")", "{", "assert", "(", "this", ".", "state", "==", "ConnectionState", ".", "CONNECTING", ")", ";", "ConnectionState", "event", "=", "null", ";", "synchronized", "(", "this", ")", "{", "this", ".", "state", "=", ...
A websocket connection has failed its upgrade handshake, and is now closed.
[ "A", "websocket", "connection", "has", "failed", "its", "upgrade", "handshake", "and", "is", "now", "closed", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly/src/main/java/com/firefly/codec/websocket/stream/IOState.java#L348-L359
102,364
hypercube1024/firefly
firefly/src/main/java/com/firefly/codec/websocket/stream/IOState.java
IOState.onOpened
public void onOpened() { if (LOG.isDebugEnabled()) LOG.debug("onOpened()"); ConnectionState event = null; synchronized (this) { if (this.state == ConnectionState.OPEN) { // already opened return; } if (this.state !...
java
public void onOpened() { if (LOG.isDebugEnabled()) LOG.debug("onOpened()"); ConnectionState event = null; synchronized (this) { if (this.state == ConnectionState.OPEN) { // already opened return; } if (this.state !...
[ "public", "void", "onOpened", "(", ")", "{", "if", "(", "LOG", ".", "isDebugEnabled", "(", ")", ")", "LOG", ".", "debug", "(", "\"onOpened()\"", ")", ";", "ConnectionState", "event", "=", "null", ";", "synchronized", "(", "this", ")", "{", "if", "(", ...
A websocket connection has finished its upgrade handshake, and is now open.
[ "A", "websocket", "connection", "has", "finished", "its", "upgrade", "handshake", "and", "is", "now", "open", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly/src/main/java/com/firefly/codec/websocket/stream/IOState.java#L364-L386
102,365
hypercube1024/firefly
firefly/src/main/java/com/firefly/codec/websocket/model/AcceptHash.java
AcceptHash.hashKey
public static String hashKey(String key) { try { MessageDigest md = MessageDigest.getInstance("SHA1"); md.update(key.getBytes(StandardCharsets.UTF_8)); md.update(MAGIC); return new String(B64Code.encode(md.digest())); } catch (Exception e) { th...
java
public static String hashKey(String key) { try { MessageDigest md = MessageDigest.getInstance("SHA1"); md.update(key.getBytes(StandardCharsets.UTF_8)); md.update(MAGIC); return new String(B64Code.encode(md.digest())); } catch (Exception e) { th...
[ "public", "static", "String", "hashKey", "(", "String", "key", ")", "{", "try", "{", "MessageDigest", "md", "=", "MessageDigest", ".", "getInstance", "(", "\"SHA1\"", ")", ";", "md", ".", "update", "(", "key", ".", "getBytes", "(", "StandardCharsets", ".",...
Concatenate the provided key with the Magic GUID and return the Base64 encoded form. @param key the key to hash @return the <code>Sec-WebSocket-Accept</code> header response (per opening handshake spec)
[ "Concatenate", "the", "provided", "key", "with", "the", "Magic", "GUID", "and", "return", "the", "Base64", "encoded", "form", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly/src/main/java/com/firefly/codec/websocket/model/AcceptHash.java#L27-L36
102,366
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/StringUtils.java
StringUtils.unicodeToString
public static String unicodeToString(String s) { StringBuilder sb = new StringBuilder(); StringTokenizer st = new StringTokenizer(s, "\\u"); while (st.hasMoreTokens()) { String token = st.nextToken(); if (token.length() > 4) { sb.append((char) Intege...
java
public static String unicodeToString(String s) { StringBuilder sb = new StringBuilder(); StringTokenizer st = new StringTokenizer(s, "\\u"); while (st.hasMoreTokens()) { String token = st.nextToken(); if (token.length() > 4) { sb.append((char) Intege...
[ "public", "static", "String", "unicodeToString", "(", "String", "s", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "StringTokenizer", "st", "=", "new", "StringTokenizer", "(", "s", ",", "\"\\\\u\"", ")", ";", "while", "(", "s...
Convert a string that is unicode form to a normal string. @param s The unicode form of a string, e.g. "\\u8001\\u9A6C" @return Normal string
[ "Convert", "a", "string", "that", "is", "unicode", "form", "to", "a", "normal", "string", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/StringUtils.java#L656-L669
102,367
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/StringUtils.java
StringUtils.append
public static void append(StringBuilder buf, String s, int offset, int length) { synchronized (buf) { int end = offset + length; for (int i = offset; i < end; i++) { if (i >= s.length()) break; buf.append(s.charAt(i)); ...
java
public static void append(StringBuilder buf, String s, int offset, int length) { synchronized (buf) { int end = offset + length; for (int i = offset; i < end; i++) { if (i >= s.length()) break; buf.append(s.charAt(i)); ...
[ "public", "static", "void", "append", "(", "StringBuilder", "buf", ",", "String", "s", ",", "int", "offset", ",", "int", "length", ")", "{", "synchronized", "(", "buf", ")", "{", "int", "end", "=", "offset", "+", "length", ";", "for", "(", "int", "i"...
Append substring to StringBuilder @param buf StringBuilder to append to @param s String to append from @param offset The offset of the substring @param length The length of the substring
[ "Append", "substring", "to", "StringBuilder" ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/StringUtils.java#L735-L744
102,368
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/StringUtils.java
StringUtils.append
public static void append(StringBuilder buf, byte b, int base) { int bi = 0xff & b; int c = '0' + (bi / base) % base; if (c > '9') c = 'a' + (c - '0' - 10); buf.append((char) c); c = '0' + bi % base; if (c > '9') c = 'a' + (c - '0' - 10); ...
java
public static void append(StringBuilder buf, byte b, int base) { int bi = 0xff & b; int c = '0' + (bi / base) % base; if (c > '9') c = 'a' + (c - '0' - 10); buf.append((char) c); c = '0' + bi % base; if (c > '9') c = 'a' + (c - '0' - 10); ...
[ "public", "static", "void", "append", "(", "StringBuilder", "buf", ",", "byte", "b", ",", "int", "base", ")", "{", "int", "bi", "=", "0xff", "&", "b", ";", "int", "c", "=", "'", "'", "+", "(", "bi", "/", "base", ")", "%", "base", ";", "if", "...
append hex digit @param buf the buffer to append to @param b the byte to append @param base the base of the hex output (almost always 16).
[ "append", "hex", "digit" ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/StringUtils.java#L753-L763
102,369
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/StringUtils.java
StringUtils.toInt
public static int toInt(String string, int from) { int val = 0; boolean started = false; boolean minus = false; for (int i = from; i < string.length(); i++) { char b = string.charAt(i); if (b <= ' ') { if (started) bre...
java
public static int toInt(String string, int from) { int val = 0; boolean started = false; boolean minus = false; for (int i = from; i < string.length(); i++) { char b = string.charAt(i); if (b <= ' ') { if (started) bre...
[ "public", "static", "int", "toInt", "(", "String", "string", ",", "int", "from", ")", "{", "int", "val", "=", "0", ";", "boolean", "started", "=", "false", ";", "boolean", "minus", "=", "false", ";", "for", "(", "int", "i", "=", "from", ";", "i", ...
Convert String to an integer. Parses up to the first non-numeric character. If no number is found an IllegalArgumentException is thrown @param string A String containing an integer. @param from The index to start parsing from @return an int
[ "Convert", "String", "to", "an", "integer", ".", "Parses", "up", "to", "the", "first", "non", "-", "numeric", "character", ".", "If", "no", "number", "is", "found", "an", "IllegalArgumentException", "is", "thrown" ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/StringUtils.java#L773-L795
102,370
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/StringUtils.java
StringUtils.truncate
public static String truncate(String str, int maxSize) { if (str == null) { return null; } if (str.length() <= maxSize) { return str; } return str.substring(0, maxSize); }
java
public static String truncate(String str, int maxSize) { if (str == null) { return null; } if (str.length() <= maxSize) { return str; } return str.substring(0, maxSize); }
[ "public", "static", "String", "truncate", "(", "String", "str", ",", "int", "maxSize", ")", "{", "if", "(", "str", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "str", ".", "length", "(", ")", "<=", "maxSize", ")", "{", "return", ...
Truncate a string to a max size. @param str the string to possibly truncate @param maxSize the maximum size of the string @return the truncated string. if <code>str</code> param is null, then the returned string will also be null.
[ "Truncate", "a", "string", "to", "a", "max", "size", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/StringUtils.java#L1303-L1313
102,371
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/lang/URIUtils.java
URIUtils.parentPath
public static String parentPath(String p) { if (p == null || URIUtils.SLASH.equals(p)) return null; int slash = p.lastIndexOf('/', p.length() - 2); if (slash >= 0) return p.substring(0, slash + 1); return null; }
java
public static String parentPath(String p) { if (p == null || URIUtils.SLASH.equals(p)) return null; int slash = p.lastIndexOf('/', p.length() - 2); if (slash >= 0) return p.substring(0, slash + 1); return null; }
[ "public", "static", "String", "parentPath", "(", "String", "p", ")", "{", "if", "(", "p", "==", "null", "||", "URIUtils", ".", "SLASH", ".", "equals", "(", "p", ")", ")", "return", "null", ";", "int", "slash", "=", "p", ".", "lastIndexOf", "(", "'"...
Return the parent Path. Treat a URI like a directory path and return the parent directory. @param p the path to return a parent reference to @return the parent path of the URI
[ "Return", "the", "parent", "Path", ".", "Treat", "a", "URI", "like", "a", "directory", "path", "and", "return", "the", "parent", "directory", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/lang/URIUtils.java#L511-L518
102,372
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/lang/URIUtils.java
URIUtils.newURI
public static String newURI(String scheme, String server, int port, String path, String query) { StringBuilder builder = newURIBuilder(scheme, server, port); builder.append(path); if (query != null && query.length() > 0) builder.append('?').append(query); return builder.toStr...
java
public static String newURI(String scheme, String server, int port, String path, String query) { StringBuilder builder = newURIBuilder(scheme, server, port); builder.append(path); if (query != null && query.length() > 0) builder.append('?').append(query); return builder.toStr...
[ "public", "static", "String", "newURI", "(", "String", "scheme", ",", "String", "server", ",", "int", "port", ",", "String", "path", ",", "String", "query", ")", "{", "StringBuilder", "builder", "=", "newURIBuilder", "(", "scheme", ",", "server", ",", "por...
Create a new URI from the arguments, handling IPv6 host encoding and default ports @param scheme the URI scheme @param server the URI server @param port the URI port @param path the URI path @param query the URI query @return A String URI
[ "Create", "a", "new", "URI", "from", "the", "arguments", "handling", "IPv6", "host", "encoding", "and", "default", "ports" ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/lang/URIUtils.java#L838-L844
102,373
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/lang/URIUtils.java
URIUtils.newURIBuilder
public static StringBuilder newURIBuilder(String scheme, String server, int port) { StringBuilder builder = new StringBuilder(); appendSchemeHostPort(builder, scheme, server, port); return builder; }
java
public static StringBuilder newURIBuilder(String scheme, String server, int port) { StringBuilder builder = new StringBuilder(); appendSchemeHostPort(builder, scheme, server, port); return builder; }
[ "public", "static", "StringBuilder", "newURIBuilder", "(", "String", "scheme", ",", "String", "server", ",", "int", "port", ")", "{", "StringBuilder", "builder", "=", "new", "StringBuilder", "(", ")", ";", "appendSchemeHostPort", "(", "builder", ",", "scheme", ...
Create a new URI StringBuilder from the arguments, handling IPv6 host encoding and default ports @param scheme the URI scheme @param server the URI server @param port the URI port @return a StringBuilder containing URI prefix
[ "Create", "a", "new", "URI", "StringBuilder", "from", "the", "arguments", "handling", "IPv6", "host", "encoding", "and", "default", "ports" ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/lang/URIUtils.java#L856-L860
102,374
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/lang/URIUtils.java
URIUtils.appendSchemeHostPort
public static void appendSchemeHostPort(StringBuilder url, String scheme, String server, int port) { url.append(scheme).append("://").append(HostPort.normalizeHost(server)); if (port > 0) { switch (scheme) { case "http": if (port != 80) ...
java
public static void appendSchemeHostPort(StringBuilder url, String scheme, String server, int port) { url.append(scheme).append("://").append(HostPort.normalizeHost(server)); if (port > 0) { switch (scheme) { case "http": if (port != 80) ...
[ "public", "static", "void", "appendSchemeHostPort", "(", "StringBuilder", "url", ",", "String", "scheme", ",", "String", "server", ",", "int", "port", ")", "{", "url", ".", "append", "(", "scheme", ")", ".", "append", "(", "\"://\"", ")", ".", "append", ...
Append scheme, host and port URI prefix, handling IPv6 address encoding and default ports @param url StringBuilder to append to @param scheme the URI scheme @param server the URI server @param port the URI port
[ "Append", "scheme", "host", "and", "port", "URI", "prefix", "handling", "IPv6", "address", "encoding", "and", "default", "ports" ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/lang/URIUtils.java#L872-L891
102,375
hypercube1024/firefly
firefly/src/main/java/com/firefly/codec/websocket/decode/Parser.java
Parser.parsePayload
private boolean parsePayload(ByteBuffer buffer) { if (payloadLength == 0) { return true; } if (buffer.hasRemaining()) { // Create a small window of the incoming buffer to work with. // this should only show the payload itself, and not any more // ...
java
private boolean parsePayload(ByteBuffer buffer) { if (payloadLength == 0) { return true; } if (buffer.hasRemaining()) { // Create a small window of the incoming buffer to work with. // this should only show the payload itself, and not any more // ...
[ "private", "boolean", "parsePayload", "(", "ByteBuffer", "buffer", ")", "{", "if", "(", "payloadLength", "==", "0", ")", "{", "return", "true", ";", "}", "if", "(", "buffer", ".", "hasRemaining", "(", ")", ")", "{", "// Create a small window of the incoming bu...
Implementation specific parsing of a payload @param buffer the payload buffer @return true if payload is done reading, false if incomplete
[ "Implementation", "specific", "parsing", "of", "a", "payload" ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly/src/main/java/com/firefly/codec/websocket/decode/Parser.java#L464-L509
102,376
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/retry/RetryStrategies.java
RetryStrategies.ifException
public static <V> Predicate<TaskContext<V>> ifException(Predicate<? super Exception> predicate) { return ctx -> predicate.test(ctx.getException()); }
java
public static <V> Predicate<TaskContext<V>> ifException(Predicate<? super Exception> predicate) { return ctx -> predicate.test(ctx.getException()); }
[ "public", "static", "<", "V", ">", "Predicate", "<", "TaskContext", "<", "V", ">", ">", "ifException", "(", "Predicate", "<", "?", "super", "Exception", ">", "predicate", ")", "{", "return", "ctx", "->", "predicate", ".", "test", "(", "ctx", ".", "getE...
If the task throws some exceptions, the task will be retried. @param predicate The exception predicate. @param <V> The return value type. @return The retry strategy predicate.
[ "If", "the", "task", "throws", "some", "exceptions", "the", "task", "will", "be", "retried", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/retry/RetryStrategies.java#L17-L19
102,377
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/retry/RetryStrategies.java
RetryStrategies.ifResult
public static <V> Predicate<TaskContext<V>> ifResult(Predicate<V> predicate) { return ctx -> predicate.test(ctx.getResult()); }
java
public static <V> Predicate<TaskContext<V>> ifResult(Predicate<V> predicate) { return ctx -> predicate.test(ctx.getResult()); }
[ "public", "static", "<", "V", ">", "Predicate", "<", "TaskContext", "<", "V", ">", ">", "ifResult", "(", "Predicate", "<", "V", ">", "predicate", ")", "{", "return", "ctx", "->", "predicate", ".", "test", "(", "ctx", ".", "getResult", "(", ")", ")", ...
If the task result satisfies condition, the task will be retried. @param predicate The result predicate. @param <V> The return value type. @return The retry strategy predicate.
[ "If", "the", "task", "result", "satisfies", "condition", "the", "task", "will", "be", "retried", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/retry/RetryStrategies.java#L28-L30
102,378
hypercube1024/firefly
firefly/src/main/java/com/firefly/codec/websocket/utils/QuoteUtil.java
QuoteUtil.dequote
public static String dequote(String str) { char start = str.charAt(0); if ((start == '\'') || (start == '\"')) { // possibly quoted char end = str.charAt(str.length() - 1); if (start == end) { // dequote return str.substring(1, str.leng...
java
public static String dequote(String str) { char start = str.charAt(0); if ((start == '\'') || (start == '\"')) { // possibly quoted char end = str.charAt(str.length() - 1); if (start == end) { // dequote return str.substring(1, str.leng...
[ "public", "static", "String", "dequote", "(", "String", "str", ")", "{", "char", "start", "=", "str", ".", "charAt", "(", "0", ")", ";", "if", "(", "(", "start", "==", "'", "'", ")", "||", "(", "start", "==", "'", "'", ")", ")", "{", "// possib...
Remove quotes from a string, only if the input string start with and end with the same quote character. @param str the string to remove surrounding quotes from @return the de-quoted string
[ "Remove", "quotes", "from", "a", "string", "only", "if", "the", "input", "string", "start", "with", "and", "end", "with", "the", "same", "quote", "character", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly/src/main/java/com/firefly/codec/websocket/utils/QuoteUtil.java#L184-L195
102,379
hypercube1024/firefly
firefly/src/main/java/com/firefly/codec/websocket/utils/QuoteUtil.java
QuoteUtil.quote
public static void quote(StringBuilder buf, String str) { buf.append('"'); escape(buf, str); buf.append('"'); }
java
public static void quote(StringBuilder buf, String str) { buf.append('"'); escape(buf, str); buf.append('"'); }
[ "public", "static", "void", "quote", "(", "StringBuilder", "buf", ",", "String", "str", ")", "{", "buf", ".", "append", "(", "'", "'", ")", ";", "escape", "(", "buf", ",", "str", ")", ";", "buf", ".", "append", "(", "'", "'", ")", ";", "}" ]
Simple quote of a string, escaping where needed. @param buf the StringBuilder to append to @param str the string to quote
[ "Simple", "quote", "of", "a", "string", "escaping", "where", "needed", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly/src/main/java/com/firefly/codec/websocket/utils/QuoteUtil.java#L230-L234
102,380
hypercube1024/firefly
firefly/src/main/java/com/firefly/codec/websocket/utils/QuoteUtil.java
QuoteUtil.splitAt
public static Iterator<String> splitAt(String str, String delims) { return new DeQuotingStringIterator(str.trim(), delims); }
java
public static Iterator<String> splitAt(String str, String delims) { return new DeQuotingStringIterator(str.trim(), delims); }
[ "public", "static", "Iterator", "<", "String", ">", "splitAt", "(", "String", "str", ",", "String", "delims", ")", "{", "return", "new", "DeQuotingStringIterator", "(", "str", ".", "trim", "(", ")", ",", "delims", ")", ";", "}" ]
Create an iterator of the input string, breaking apart the string at the provided delimiters, removing quotes and triming the parts of the string as needed. @param str the input string to split apart @param delims the delimiter characters to split the string on @return the iterator of the parts of the string, trimm...
[ "Create", "an", "iterator", "of", "the", "input", "string", "breaking", "apart", "the", "string", "at", "the", "provided", "delimiters", "removing", "quotes", "and", "triming", "the", "parts", "of", "the", "string", "as", "needed", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly/src/main/java/com/firefly/codec/websocket/utils/QuoteUtil.java#L276-L278
102,381
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/codec/HexUtils.java
HexUtils.bytesToHex
public static final String bytesToHex(byte[] bs, int off, int length) { if (bs.length <= off || bs.length < off + length) throw new IllegalArgumentException(); StringBuilder sb = new StringBuilder(length * 2); bytesToHexAppend(bs, off, length, sb); return sb.toString(); }
java
public static final String bytesToHex(byte[] bs, int off, int length) { if (bs.length <= off || bs.length < off + length) throw new IllegalArgumentException(); StringBuilder sb = new StringBuilder(length * 2); bytesToHexAppend(bs, off, length, sb); return sb.toString(); }
[ "public", "static", "final", "String", "bytesToHex", "(", "byte", "[", "]", "bs", ",", "int", "off", ",", "int", "length", ")", "{", "if", "(", "bs", ".", "length", "<=", "off", "||", "bs", ".", "length", "<", "off", "+", "length", ")", "throw", ...
Converts a byte array into a string of lower case hex chars. @param bs A byte array @param off The index of the first byte to read @param length The number of bytes to read. @return the string of hex chars.
[ "Converts", "a", "byte", "array", "into", "a", "string", "of", "lower", "case", "hex", "chars", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/codec/HexUtils.java#L19-L25
102,382
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/codec/HexUtils.java
HexUtils.hexToBytes
public static final void hexToBytes(String s, byte[] out, int off) throws NumberFormatException, IndexOutOfBoundsException { int slen = s.length(); if ((slen % 2) != 0) { s = '0' + s; } if (out.length < off + slen / 2) { throw new IndexOutOfBoundsExc...
java
public static final void hexToBytes(String s, byte[] out, int off) throws NumberFormatException, IndexOutOfBoundsException { int slen = s.length(); if ((slen % 2) != 0) { s = '0' + s; } if (out.length < off + slen / 2) { throw new IndexOutOfBoundsExc...
[ "public", "static", "final", "void", "hexToBytes", "(", "String", "s", ",", "byte", "[", "]", "out", ",", "int", "off", ")", "throws", "NumberFormatException", ",", "IndexOutOfBoundsException", "{", "int", "slen", "=", "s", ".", "length", "(", ")", ";", ...
Converts a String of hex characters into an array of bytes. @param s A string of hex characters (upper case or lower) of even length. @param out A byte array of length at least s.length()/2 + off @param off The first byte to write of the array
[ "Converts", "a", "String", "of", "hex", "characters", "into", "an", "array", "of", "bytes", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/codec/HexUtils.java#L60-L84
102,383
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/codec/HexUtils.java
HexUtils.hexToBits
public static void hexToBits(String s, BitSet ba, int length) { byte[] b = hexToBytes(s); bytesToBits(b, ba, length); }
java
public static void hexToBits(String s, BitSet ba, int length) { byte[] b = hexToBytes(s); bytesToBits(b, ba, length); }
[ "public", "static", "void", "hexToBits", "(", "String", "s", ",", "BitSet", "ba", ",", "int", "length", ")", "{", "byte", "[", "]", "b", "=", "hexToBytes", "(", "s", ")", ";", "bytesToBits", "(", "b", ",", "ba", ",", "length", ")", ";", "}" ]
Read a hex string of bits and write it into a bitset @param s hex string of the stored bits @param ba the bitset to store the bits in @param length the maximum number of bits to store
[ "Read", "a", "hex", "string", "of", "bits", "and", "write", "it", "into", "a", "bitset" ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/codec/HexUtils.java#L134-L137
102,384
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/RandomUtils.java
RandomUtils.random
public static long random(long min, long max) { return Math.round(ThreadLocalRandom.current().nextDouble() * (max - min) + min); }
java
public static long random(long min, long max) { return Math.round(ThreadLocalRandom.current().nextDouble() * (max - min) + min); }
[ "public", "static", "long", "random", "(", "long", "min", ",", "long", "max", ")", "{", "return", "Math", ".", "round", "(", "ThreadLocalRandom", ".", "current", "(", ")", ".", "nextDouble", "(", ")", "*", "(", "max", "-", "min", ")", "+", "min", "...
Generates a random number from a specified range @param min The minimal number of the range @param max The maximal number of the range @return A random number from minimal number to maximal number, which contains minimal and maximal number.
[ "Generates", "a", "random", "number", "from", "a", "specified", "range" ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/RandomUtils.java#L13-L16
102,385
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/RandomUtils.java
RandomUtils.randomSegment
public static int randomSegment(int[] probability) { int total = 0; for (int i = 0; i < probability.length; i++) { total += probability[i]; probability[i] = total; } int rand = (int) random(0, total - 1); for (int i = 0; i < probability.length; i++)...
java
public static int randomSegment(int[] probability) { int total = 0; for (int i = 0; i < probability.length; i++) { total += probability[i]; probability[i] = total; } int rand = (int) random(0, total - 1); for (int i = 0; i < probability.length; i++)...
[ "public", "static", "int", "randomSegment", "(", "int", "[", "]", "probability", ")", "{", "int", "total", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "probability", ".", "length", ";", "i", "++", ")", "{", "total", "+=", "pro...
Returns the index of array that specifies probability. @param probability The element of array represents the probability. @return The index of array.
[ "Returns", "the", "index", "of", "array", "that", "specifies", "probability", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/RandomUtils.java#L40-L53
102,386
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/RandomUtils.java
RandomUtils.randomString
public static String randomString(int length) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < length; i++) { int index = (int) random(0, ALL_CHAR.length() - 1); sb.append(ALL_CHAR.charAt(index)); } return sb.toString(); }
java
public static String randomString(int length) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < length; i++) { int index = (int) random(0, ALL_CHAR.length() - 1); sb.append(ALL_CHAR.charAt(index)); } return sb.toString(); }
[ "public", "static", "String", "randomString", "(", "int", "length", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "length", ";", "i", "++", ")", "{", "int", "index", "=...
Returns a random string. @param length The random string's length @return A random string.
[ "Returns", "a", "random", "string", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/RandomUtils.java#L61-L68
102,387
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/ReflectUtils.java
ReflectUtils.set
public static void set(Object obj, String property, Object value) throws Throwable { getSetterMethod(obj.getClass(), property).invoke(obj, value); }
java
public static void set(Object obj, String property, Object value) throws Throwable { getSetterMethod(obj.getClass(), property).invoke(obj, value); }
[ "public", "static", "void", "set", "(", "Object", "obj", ",", "String", "property", ",", "Object", "value", ")", "throws", "Throwable", "{", "getSetterMethod", "(", "obj", ".", "getClass", "(", ")", ",", "property", ")", ".", "invoke", "(", "obj", ",", ...
Invokes a object's "setter" method by property name @param obj The instance of a object @param property The property name of this object @param value The parameter of "setter" method that you want to set @throws Throwable A runtime exception
[ "Invokes", "a", "object", "s", "setter", "method", "by", "property", "name" ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/ReflectUtils.java#L85-L87
102,388
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/ReflectUtils.java
ReflectUtils.get
public static Object get(Object obj, String property) throws Throwable { return getGetterMethod(obj.getClass(), property).invoke(obj); }
java
public static Object get(Object obj, String property) throws Throwable { return getGetterMethod(obj.getClass(), property).invoke(obj); }
[ "public", "static", "Object", "get", "(", "Object", "obj", ",", "String", "property", ")", "throws", "Throwable", "{", "return", "getGetterMethod", "(", "obj", ".", "getClass", "(", ")", ",", "property", ")", ".", "invoke", "(", "obj", ")", ";", "}" ]
Invokes a object's "getter" method by property name @param obj The instance of a object @param property The property name of this object @return The value of this property @throws Throwable A runtime exception
[ "Invokes", "a", "object", "s", "getter", "method", "by", "property", "name" ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/ReflectUtils.java#L97-L99
102,389
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/ReflectUtils.java
ReflectUtils.getInterfaceNames
public static String[] getInterfaceNames(Class<?> c) { Class<?>[] interfaces = c.getInterfaces(); List<String> names = new ArrayList<>(); for (Class<?> i : interfaces) { names.add(i.getName()); } return names.toArray(new String[0]); }
java
public static String[] getInterfaceNames(Class<?> c) { Class<?>[] interfaces = c.getInterfaces(); List<String> names = new ArrayList<>(); for (Class<?> i : interfaces) { names.add(i.getName()); } return names.toArray(new String[0]); }
[ "public", "static", "String", "[", "]", "getInterfaceNames", "(", "Class", "<", "?", ">", "c", ")", "{", "Class", "<", "?", ">", "[", "]", "interfaces", "=", "c", ".", "getInterfaces", "(", ")", ";", "List", "<", "String", ">", "names", "=", "new",...
Gets the all interface names of this class @param c The class of one object @return Returns the all interface names
[ "Gets", "the", "all", "interface", "names", "of", "this", "class" ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/ReflectUtils.java#L131-L138
102,390
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/ConvertUtils.java
ConvertUtils.convert
@SuppressWarnings("unchecked") public static Object convert(Collection<?> collection, Class<?> arrayType) { int size = collection.size(); // Allocate a new Array Object newArray = Array.newInstance(Optional.ofNullable(arrayType) .filte...
java
@SuppressWarnings("unchecked") public static Object convert(Collection<?> collection, Class<?> arrayType) { int size = collection.size(); // Allocate a new Array Object newArray = Array.newInstance(Optional.ofNullable(arrayType) .filte...
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "Object", "convert", "(", "Collection", "<", "?", ">", "collection", ",", "Class", "<", "?", ">", "arrayType", ")", "{", "int", "size", "=", "collection", ".", "size", "(", ")", ";",...
Returns an array object, this method converts a collection object to an array object through the specified element type of the array. @param collection The collection that needs be converted @param arrayType The element type of an array @return a array object and the element is the parameter specified type.
[ "Returns", "an", "array", "object", "this", "method", "converts", "a", "collection", "object", "to", "an", "array", "object", "through", "the", "specified", "element", "type", "of", "the", "array", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/ConvertUtils.java#L122-L141
102,391
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/ConvertUtils.java
ConvertUtils.getCollectionObj
@SuppressWarnings("unchecked") public static Collection<Object> getCollectionObj(Class<?> clazz) { if (clazz.isInterface()) { if (clazz.isAssignableFrom(List.class)) return new ArrayList<>(); else if (clazz.isAssignableFrom(Set.class)) return new...
java
@SuppressWarnings("unchecked") public static Collection<Object> getCollectionObj(Class<?> clazz) { if (clazz.isInterface()) { if (clazz.isAssignableFrom(List.class)) return new ArrayList<>(); else if (clazz.isAssignableFrom(Set.class)) return new...
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "Collection", "<", "Object", ">", "getCollectionObj", "(", "Class", "<", "?", ">", "clazz", ")", "{", "if", "(", "clazz", ".", "isInterface", "(", ")", ")", "{", "if", "(", "clazz", ...
Returns a collection object instance by class @param clazz The class object of a collection @return A collection object instance
[ "Returns", "a", "collection", "object", "instance", "by", "class" ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/ConvertUtils.java#L149-L173
102,392
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/ResourceUtils.java
ResourceUtils.isJarURL
public static boolean isJarURL(URL url) { String protocol = url.getProtocol(); return (URL_PROTOCOL_JAR.equals(protocol) || URL_PROTOCOL_ZIP.equals(protocol) || URL_PROTOCOL_VFSZIP.equals(protocol) || URL_PROTOCOL_WSJAR.equals(protocol)); }
java
public static boolean isJarURL(URL url) { String protocol = url.getProtocol(); return (URL_PROTOCOL_JAR.equals(protocol) || URL_PROTOCOL_ZIP.equals(protocol) || URL_PROTOCOL_VFSZIP.equals(protocol) || URL_PROTOCOL_WSJAR.equals(protocol)); }
[ "public", "static", "boolean", "isJarURL", "(", "URL", "url", ")", "{", "String", "protocol", "=", "url", ".", "getProtocol", "(", ")", ";", "return", "(", "URL_PROTOCOL_JAR", ".", "equals", "(", "protocol", ")", "||", "URL_PROTOCOL_ZIP", ".", "equals", "(...
Determine whether the given URL points to a resource in a jar file, that is, has protocol "jar", "zip", "vfszip" or "wsjar". @param url the URL to check @return whether the URL has been identified as a JAR URL
[ "Determine", "whether", "the", "given", "URL", "points", "to", "a", "resource", "in", "a", "jar", "file", "that", "is", "has", "protocol", "jar", "zip", "vfszip", "or", "wsjar", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/ResourceUtils.java#L272-L276
102,393
hypercube1024/firefly
firefly-common/src/main/java/com/firefly/utils/ResourceUtils.java
ResourceUtils.isJarFileURL
public static boolean isJarFileURL(URL url) { return (URL_PROTOCOL_FILE.equals(url.getProtocol()) && url.getPath().toLowerCase().endsWith(JAR_FILE_EXTENSION)); }
java
public static boolean isJarFileURL(URL url) { return (URL_PROTOCOL_FILE.equals(url.getProtocol()) && url.getPath().toLowerCase().endsWith(JAR_FILE_EXTENSION)); }
[ "public", "static", "boolean", "isJarFileURL", "(", "URL", "url", ")", "{", "return", "(", "URL_PROTOCOL_FILE", ".", "equals", "(", "url", ".", "getProtocol", "(", ")", ")", "&&", "url", ".", "getPath", "(", ")", ".", "toLowerCase", "(", ")", ".", "end...
Determine whether the given URL points to a jar file itself, that is, has protocol "file" and ends with the ".jar" extension. @param url the URL to check @return whether the URL has been identified as a JAR file URL @since 4.1
[ "Determine", "whether", "the", "given", "URL", "points", "to", "a", "jar", "file", "itself", "that", "is", "has", "protocol", "file", "and", "ends", "with", "the", ".", "jar", "extension", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/ResourceUtils.java#L286-L289
102,394
hypercube1024/firefly
firefly/src/main/java/com/firefly/codec/http2/encode/Generator.java
Generator.data
public Pair<Integer, List<ByteBuffer>> data(DataFrame frame, int maxLength) { return dataGenerator.generate(frame, maxLength); }
java
public Pair<Integer, List<ByteBuffer>> data(DataFrame frame, int maxLength) { return dataGenerator.generate(frame, maxLength); }
[ "public", "Pair", "<", "Integer", ",", "List", "<", "ByteBuffer", ">", ">", "data", "(", "DataFrame", "frame", ",", "int", "maxLength", ")", "{", "return", "dataGenerator", ".", "generate", "(", "frame", ",", "maxLength", ")", ";", "}" ]
Encode data frame to binary codes @param frame DataFrame @param maxLength The max length of DataFrame @return A pair of encoding result. The first field is frame length which contains header frame and data frame. The second field is binary codes.
[ "Encode", "data", "frame", "to", "binary", "codes" ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly/src/main/java/com/firefly/codec/http2/encode/Generator.java#L68-L70
102,395
hypercube1024/firefly
firefly/src/main/java/com/firefly/codec/http2/model/MultiPartFormInputStream.java
MultiPartFormInputStream.getParsedParts
@Deprecated public Collection<Part> getParsedParts() { if (_parts == null) return Collections.emptyList(); Collection<List<Part>> values = _parts.values(); List<Part> parts = new ArrayList<>(); for (List<Part> o : values) { List<Part> asList = LazyList.getLis...
java
@Deprecated public Collection<Part> getParsedParts() { if (_parts == null) return Collections.emptyList(); Collection<List<Part>> values = _parts.values(); List<Part> parts = new ArrayList<>(); for (List<Part> o : values) { List<Part> asList = LazyList.getLis...
[ "@", "Deprecated", "public", "Collection", "<", "Part", ">", "getParsedParts", "(", ")", "{", "if", "(", "_parts", "==", "null", ")", "return", "Collections", ".", "emptyList", "(", ")", ";", "Collection", "<", "List", "<", "Part", ">", ">", "values", ...
Get the already parsed parts. @return the parts that were parsed
[ "Get", "the", "already", "parsed", "parts", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly/src/main/java/com/firefly/codec/http2/model/MultiPartFormInputStream.java#L309-L321
102,396
hypercube1024/firefly
firefly/src/main/java/com/firefly/codec/http2/model/MultiPartFormInputStream.java
MultiPartFormInputStream.deleteParts
public void deleteParts() { if (!_parsed) return; Collection<Part> parts; try { parts = getParts(); } catch (IOException e) { throw new RuntimeException(e); } MultiException err = null; for (Part p : parts) { try {...
java
public void deleteParts() { if (!_parsed) return; Collection<Part> parts; try { parts = getParts(); } catch (IOException e) { throw new RuntimeException(e); } MultiException err = null; for (Part p : parts) { try {...
[ "public", "void", "deleteParts", "(", ")", "{", "if", "(", "!", "_parsed", ")", "return", ";", "Collection", "<", "Part", ">", "parts", ";", "try", "{", "parts", "=", "getParts", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "thro...
Delete any tmp storage for parts, and clear out the parts list.
[ "Delete", "any", "tmp", "storage", "for", "parts", "and", "clear", "out", "the", "parts", "list", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly/src/main/java/com/firefly/codec/http2/model/MultiPartFormInputStream.java#L326-L351
102,397
hypercube1024/firefly
firefly/src/main/java/com/firefly/codec/http2/model/MultiPartFormInputStream.java
MultiPartFormInputStream.getParts
public Collection<Part> getParts() throws IOException { if (!_parsed) parse(); throwIfError(); Collection<List<Part>> values = _parts.values(); List<Part> parts = new ArrayList<>(); for (List<Part> o : values) { List<Part> asList = LazyList.getList(o, fal...
java
public Collection<Part> getParts() throws IOException { if (!_parsed) parse(); throwIfError(); Collection<List<Part>> values = _parts.values(); List<Part> parts = new ArrayList<>(); for (List<Part> o : values) { List<Part> asList = LazyList.getList(o, fal...
[ "public", "Collection", "<", "Part", ">", "getParts", "(", ")", "throws", "IOException", "{", "if", "(", "!", "_parsed", ")", "parse", "(", ")", ";", "throwIfError", "(", ")", ";", "Collection", "<", "List", "<", "Part", ">", ">", "values", "=", "_pa...
Parse, if necessary, the multipart data and return the list of Parts. @return the parts @throws IOException if unable to get the parts
[ "Parse", "if", "necessary", "the", "multipart", "data", "and", "return", "the", "list", "of", "Parts", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly/src/main/java/com/firefly/codec/http2/model/MultiPartFormInputStream.java#L359-L371
102,398
hypercube1024/firefly
firefly/src/main/java/com/firefly/codec/http2/model/MultiPartFormInputStream.java
MultiPartFormInputStream.getPart
public Part getPart(String name) throws IOException { if (!_parsed) parse(); throwIfError(); return _parts.getValue(name, 0); }
java
public Part getPart(String name) throws IOException { if (!_parsed) parse(); throwIfError(); return _parts.getValue(name, 0); }
[ "public", "Part", "getPart", "(", "String", "name", ")", "throws", "IOException", "{", "if", "(", "!", "_parsed", ")", "parse", "(", ")", ";", "throwIfError", "(", ")", ";", "return", "_parts", ".", "getValue", "(", "name", ",", "0", ")", ";", "}" ]
Get the named Part. @param name the part name @return the parts @throws IOException if unable to get the part
[ "Get", "the", "named", "Part", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly/src/main/java/com/firefly/codec/http2/model/MultiPartFormInputStream.java#L380-L385
102,399
hypercube1024/firefly
firefly/src/main/java/com/firefly/codec/http2/model/MultiPartFormInputStream.java
MultiPartFormInputStream.throwIfError
protected void throwIfError() throws IOException { if (_err != null) { _err.addSuppressed(new Throwable()); if (_err instanceof IOException) throw (IOException) _err; if (_err instanceof IllegalStateException) throw (IllegalStateException) _err...
java
protected void throwIfError() throws IOException { if (_err != null) { _err.addSuppressed(new Throwable()); if (_err instanceof IOException) throw (IOException) _err; if (_err instanceof IllegalStateException) throw (IllegalStateException) _err...
[ "protected", "void", "throwIfError", "(", ")", "throws", "IOException", "{", "if", "(", "_err", "!=", "null", ")", "{", "_err", ".", "addSuppressed", "(", "new", "Throwable", "(", ")", ")", ";", "if", "(", "_err", "instanceof", "IOException", ")", "throw...
Throws an exception if one has been latched. @throws IOException the exception (if present)
[ "Throws", "an", "exception", "if", "one", "has", "been", "latched", "." ]
ed3fc75b7c54a65b1e7d8141d01b49144bb423a3
https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly/src/main/java/com/firefly/codec/http2/model/MultiPartFormInputStream.java#L392-L401