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 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
simplifycom/ink-android | ink/src/main/java/com/simplify/ink/InkView.java | InkView.setMinStrokeWidth | public void setMinStrokeWidth(float width) {
minStrokeWidth = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, width, getResources().getDisplayMetrics());
} | java | public void setMinStrokeWidth(float width) {
minStrokeWidth = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, width, getResources().getDisplayMetrics());
} | [
"public",
"void",
"setMinStrokeWidth",
"(",
"float",
"width",
")",
"{",
"minStrokeWidth",
"=",
"TypedValue",
".",
"applyDimension",
"(",
"TypedValue",
".",
"COMPLEX_UNIT_DIP",
",",
"width",
",",
"getResources",
"(",
")",
".",
"getDisplayMetrics",
"(",
")",
")",
... | Sets the minimum stroke width
@param width The width (in dp) | [
"Sets",
"the",
"minimum",
"stroke",
"width"
] | 1a365e656b496554e7ee2e735bb775367f5eac0b | https://github.com/simplifycom/ink-android/blob/1a365e656b496554e7ee2e735bb775367f5eac0b/ink/src/main/java/com/simplify/ink/InkView.java#L352-L354 | train |
simplifycom/ink-android | ink/src/main/java/com/simplify/ink/InkView.java | InkView.clear | public void clear() {
// clean up existing bitmap
if (bitmap != null) {
bitmap.recycle();
}
// init bitmap cache
bitmap = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_8888);
canvas = new Canvas(bitmap);
// notify listeners
... | java | public void clear() {
// clean up existing bitmap
if (bitmap != null) {
bitmap.recycle();
}
// init bitmap cache
bitmap = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_8888);
canvas = new Canvas(bitmap);
// notify listeners
... | [
"public",
"void",
"clear",
"(",
")",
"{",
"// clean up existing bitmap",
"if",
"(",
"bitmap",
"!=",
"null",
")",
"{",
"bitmap",
".",
"recycle",
"(",
")",
";",
"}",
"// init bitmap cache",
"bitmap",
"=",
"Bitmap",
".",
"createBitmap",
"(",
"getWidth",
"(",
... | Clears the view | [
"Clears",
"the",
"view"
] | 1a365e656b496554e7ee2e735bb775367f5eac0b | https://github.com/simplifycom/ink-android/blob/1a365e656b496554e7ee2e735bb775367f5eac0b/ink/src/main/java/com/simplify/ink/InkView.java#L387-L404 | train |
simplifycom/ink-android | ink/src/main/java/com/simplify/ink/InkView.java | InkView.getBitmap | public Bitmap getBitmap(int backgroundColor) {
// create new bitmap
Bitmap bitmap = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_8888);
Canvas bitmapCanvas = new Canvas(bitmap);
// draw background if not transparent
if (backgroundColor != 0) {
bitm... | java | public Bitmap getBitmap(int backgroundColor) {
// create new bitmap
Bitmap bitmap = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_8888);
Canvas bitmapCanvas = new Canvas(bitmap);
// draw background if not transparent
if (backgroundColor != 0) {
bitm... | [
"public",
"Bitmap",
"getBitmap",
"(",
"int",
"backgroundColor",
")",
"{",
"// create new bitmap",
"Bitmap",
"bitmap",
"=",
"Bitmap",
".",
"createBitmap",
"(",
"getWidth",
"(",
")",
",",
"getHeight",
"(",
")",
",",
"Bitmap",
".",
"Config",
".",
"ARGB_8888",
"... | Returns the bitmap of the drawing with the specified background color
@param backgroundColor The background color for the bitmap
@return The bitmap | [
"Returns",
"the",
"bitmap",
"of",
"the",
"drawing",
"with",
"the",
"specified",
"background",
"color"
] | 1a365e656b496554e7ee2e735bb775367f5eac0b | https://github.com/simplifycom/ink-android/blob/1a365e656b496554e7ee2e735bb775367f5eac0b/ink/src/main/java/com/simplify/ink/InkView.java#L421-L435 | train |
jsurfer/JsonSurfer | jsurfer-core/src/main/java/org/jsfr/json/JsonSurfer.java | JsonSurfer.createNonBlockingParser | public NonBlockingParser createNonBlockingParser(SurfingConfiguration configuration) {
ensureSetting(configuration);
return jsonParserAdapter.createNonBlockingParser(new SurfingContext(configuration));
} | java | public NonBlockingParser createNonBlockingParser(SurfingConfiguration configuration) {
ensureSetting(configuration);
return jsonParserAdapter.createNonBlockingParser(new SurfingContext(configuration));
} | [
"public",
"NonBlockingParser",
"createNonBlockingParser",
"(",
"SurfingConfiguration",
"configuration",
")",
"{",
"ensureSetting",
"(",
"configuration",
")",
";",
"return",
"jsonParserAdapter",
".",
"createNonBlockingParser",
"(",
"new",
"SurfingContext",
"(",
"configuratio... | Create non-blocking parser
@param configuration
@return | [
"Create",
"non",
"-",
"blocking",
"parser"
] | 52bd75a453338b86e115092803da140bf99cee62 | https://github.com/jsurfer/JsonSurfer/blob/52bd75a453338b86e115092803da140bf99cee62/jsurfer-core/src/main/java/org/jsfr/json/JsonSurfer.java#L249-L252 | train |
orientechnologies/orientdb-gremlin | driver/src/main/java/org/apache/tinkerpop/gremlin/orientdb/OrientGraphFactory.java | OrientGraphFactory.setupPool | public OrientGraphBaseFactory setupPool(final int max) {
pool = new OPartitionedReCreatableDatabasePool(this.factory, dbName, user, password, max);
return this;
} | java | public OrientGraphBaseFactory setupPool(final int max) {
pool = new OPartitionedReCreatableDatabasePool(this.factory, dbName, user, password, max);
return this;
} | [
"public",
"OrientGraphBaseFactory",
"setupPool",
"(",
"final",
"int",
"max",
")",
"{",
"pool",
"=",
"new",
"OPartitionedReCreatableDatabasePool",
"(",
"this",
".",
"factory",
",",
"dbName",
",",
"user",
",",
"password",
",",
"max",
")",
";",
"return",
"this",
... | Setting up the factory to use database pool instead of creation a new
instance of database connection each time. | [
"Setting",
"up",
"the",
"factory",
"to",
"use",
"database",
"pool",
"instead",
"of",
"creation",
"a",
"new",
"instance",
"of",
"database",
"connection",
"each",
"time",
"."
] | 94549ee82431dd3b4c53a1aedb4b5107e4763b71 | https://github.com/orientechnologies/orientdb-gremlin/blob/94549ee82431dd3b4c53a1aedb4b5107e4763b71/driver/src/main/java/org/apache/tinkerpop/gremlin/orientdb/OrientGraphFactory.java#L196-L199 | train |
orientechnologies/orientdb-gremlin | driver/src/main/java/org/apache/tinkerpop/gremlin/orientdb/OrientGraphFactory.java | OrientGraphFactory.close | public void close() {
if (pool != null)
pool.close();
pool = null;
if (shouldCloseOrientDB) {
factory.close();
}
} | java | public void close() {
if (pool != null)
pool.close();
pool = null;
if (shouldCloseOrientDB) {
factory.close();
}
} | [
"public",
"void",
"close",
"(",
")",
"{",
"if",
"(",
"pool",
"!=",
"null",
")",
"pool",
".",
"close",
"(",
")",
";",
"pool",
"=",
"null",
";",
"if",
"(",
"shouldCloseOrientDB",
")",
"{",
"factory",
".",
"close",
"(",
")",
";",
"}",
"}"
] | Closes all pooled databases and clear the pool. | [
"Closes",
"all",
"pooled",
"databases",
"and",
"clear",
"the",
"pool",
"."
] | 94549ee82431dd3b4c53a1aedb4b5107e4763b71 | https://github.com/orientechnologies/orientdb-gremlin/blob/94549ee82431dd3b4c53a1aedb4b5107e4763b71/driver/src/main/java/org/apache/tinkerpop/gremlin/orientdb/OrientGraphFactory.java#L213-L221 | train |
orientechnologies/orientdb-gremlin | driver/src/main/java/org/apache/tinkerpop/gremlin/orientdb/traversal/step/sideEffect/OrientGraphStep.java | OrientGraphStep.findClassLabelsInHasContainers | private Set<String> findClassLabelsInHasContainers() {
Set<String> classLabels = new HashSet<>();
HasContainer container = this.hasContainers.stream().filter(hasContainer -> isLabelKey(hasContainer.getKey())).findFirst()
.orElseGet(() -> {
String defaultClass = Vertex.class.isAssignableFrom(g... | java | private Set<String> findClassLabelsInHasContainers() {
Set<String> classLabels = new HashSet<>();
HasContainer container = this.hasContainers.stream().filter(hasContainer -> isLabelKey(hasContainer.getKey())).findFirst()
.orElseGet(() -> {
String defaultClass = Vertex.class.isAssignableFrom(g... | [
"private",
"Set",
"<",
"String",
">",
"findClassLabelsInHasContainers",
"(",
")",
"{",
"Set",
"<",
"String",
">",
"classLabels",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"HasContainer",
"container",
"=",
"this",
".",
"hasContainers",
".",
"stream",
"(",
... | if one of the HasContainers is a label matching predicate, then return those labels | [
"if",
"one",
"of",
"the",
"HasContainers",
"is",
"a",
"label",
"matching",
"predicate",
"then",
"return",
"those",
"labels"
] | 94549ee82431dd3b4c53a1aedb4b5107e4763b71 | https://github.com/orientechnologies/orientdb-gremlin/blob/94549ee82431dd3b4c53a1aedb4b5107e4763b71/driver/src/main/java/org/apache/tinkerpop/gremlin/orientdb/traversal/step/sideEffect/OrientGraphStep.java#L104-L124 | train |
orientechnologies/orientdb-gremlin | driver/src/main/java/org/apache/tinkerpop/gremlin/orientdb/traversal/step/sideEffect/OrientGraphStep.java | OrientGraphStep.getValueIterator | private Iterator<Object> getValueIterator(HasContainer c) {
return c.getPredicate().getBiPredicate() == Contains.within ?
((Iterable<Object>) c.getValue()).iterator() :
IteratorUtils.of(c.getValue());
} | java | private Iterator<Object> getValueIterator(HasContainer c) {
return c.getPredicate().getBiPredicate() == Contains.within ?
((Iterable<Object>) c.getValue()).iterator() :
IteratorUtils.of(c.getValue());
} | [
"private",
"Iterator",
"<",
"Object",
">",
"getValueIterator",
"(",
"HasContainer",
"c",
")",
"{",
"return",
"c",
".",
"getPredicate",
"(",
")",
".",
"getBiPredicate",
"(",
")",
"==",
"Contains",
".",
"within",
"?",
"(",
"(",
"Iterable",
"<",
"Object",
"... | gets the requested values from the Has step. If it's a single value, wrap it in an array, otherwise return the array | [
"gets",
"the",
"requested",
"values",
"from",
"the",
"Has",
"step",
".",
"If",
"it",
"s",
"a",
"single",
"value",
"wrap",
"it",
"in",
"an",
"array",
"otherwise",
"return",
"the",
"array"
] | 94549ee82431dd3b4c53a1aedb4b5107e4763b71 | https://github.com/orientechnologies/orientdb-gremlin/blob/94549ee82431dd3b4c53a1aedb4b5107e4763b71/driver/src/main/java/org/apache/tinkerpop/gremlin/orientdb/traversal/step/sideEffect/OrientGraphStep.java#L177-L181 | train |
nvanbenschoten/motion | motion/src/main/java/com/nvanbenschoten/motion/ParallaxImageView.java | ParallaxImageView.registerSensorManager | public void registerSensorManager(int samplingPeriodUs) {
if (getContext() == null || mSensorManager != null) return;
// Acquires a sensor manager
mSensorManager = (SensorManager) getContext().getSystemService(Context.SENSOR_SERVICE);
if (mSensorManager != null) {
mSensorMa... | java | public void registerSensorManager(int samplingPeriodUs) {
if (getContext() == null || mSensorManager != null) return;
// Acquires a sensor manager
mSensorManager = (SensorManager) getContext().getSystemService(Context.SENSOR_SERVICE);
if (mSensorManager != null) {
mSensorMa... | [
"public",
"void",
"registerSensorManager",
"(",
"int",
"samplingPeriodUs",
")",
"{",
"if",
"(",
"getContext",
"(",
")",
"==",
"null",
"||",
"mSensorManager",
"!=",
"null",
")",
"return",
";",
"// Acquires a sensor manager",
"mSensorManager",
"=",
"(",
"SensorManag... | Registers a sensor manager with the parallax ImageView. Should be called in onResume
or onStart lifecycle callbacks from an Activity or Fragment.
@param samplingPeriodUs the sensor sampling period rate | [
"Registers",
"a",
"sensor",
"manager",
"with",
"the",
"parallax",
"ImageView",
".",
"Should",
"be",
"called",
"in",
"onResume",
"or",
"onStart",
"lifecycle",
"callbacks",
"from",
"an",
"Activity",
"or",
"Fragment",
"."
] | 152208310d5e61009416b7c2f48ff8ca2464942f | https://github.com/nvanbenschoten/motion/blob/152208310d5e61009416b7c2f48ff8ca2464942f/motion/src/main/java/com/nvanbenschoten/motion/ParallaxImageView.java#L145-L156 | train |
nvanbenschoten/motion | motion/src/main/java/com/nvanbenschoten/motion/ParallaxImageView.java | ParallaxImageView.unregisterSensorManager | public void unregisterSensorManager(boolean resetTranslation) {
if (mSensorManager == null || mSensorInterpreter == null) return;
mSensorManager.unregisterListener(this);
mSensorManager = null;
mSensorInterpreter.reset();
if (resetTranslation) {
setTranslate(0, 0);
... | java | public void unregisterSensorManager(boolean resetTranslation) {
if (mSensorManager == null || mSensorInterpreter == null) return;
mSensorManager.unregisterListener(this);
mSensorManager = null;
mSensorInterpreter.reset();
if (resetTranslation) {
setTranslate(0, 0);
... | [
"public",
"void",
"unregisterSensorManager",
"(",
"boolean",
"resetTranslation",
")",
"{",
"if",
"(",
"mSensorManager",
"==",
"null",
"||",
"mSensorInterpreter",
"==",
"null",
")",
"return",
";",
"mSensorManager",
".",
"unregisterListener",
"(",
"this",
")",
";",
... | Unregisters the ParallaxImageView's SensorManager. Should be called in onPause from
an Activity or Fragment to avoid continuing sensor usage.
@param resetTranslation if the image translation should be reset to the origin | [
"Unregisters",
"the",
"ParallaxImageView",
"s",
"SensorManager",
".",
"Should",
"be",
"called",
"in",
"onPause",
"from",
"an",
"Activity",
"or",
"Fragment",
"to",
"avoid",
"continuing",
"sensor",
"usage",
"."
] | 152208310d5e61009416b7c2f48ff8ca2464942f | https://github.com/nvanbenschoten/motion/blob/152208310d5e61009416b7c2f48ff8ca2464942f/motion/src/main/java/com/nvanbenschoten/motion/ParallaxImageView.java#L172-L182 | train |
nvanbenschoten/motion | motion/src/main/java/com/nvanbenschoten/motion/ParallaxImageView.java | ParallaxImageView.setTranslate | private void setTranslate(float x, float y) {
if (Math.abs(x) > 1 || Math.abs(y) > 1) {
throw new IllegalArgumentException("Parallax effect cannot translate more than 100% of its off-screen size");
}
float xScale, yScale;
if (mScaledIntensities) {
// Set both sc... | java | private void setTranslate(float x, float y) {
if (Math.abs(x) > 1 || Math.abs(y) > 1) {
throw new IllegalArgumentException("Parallax effect cannot translate more than 100% of its off-screen size");
}
float xScale, yScale;
if (mScaledIntensities) {
// Set both sc... | [
"private",
"void",
"setTranslate",
"(",
"float",
"x",
",",
"float",
"y",
")",
"{",
"if",
"(",
"Math",
".",
"abs",
"(",
"x",
")",
">",
"1",
"||",
"Math",
".",
"abs",
"(",
"y",
")",
">",
"1",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(... | Sets the image view's translation coordinates. These values must be between -1 and 1,
representing the transaction percentage from the center.
@param x the horizontal translation
@param y the vertical translation | [
"Sets",
"the",
"image",
"view",
"s",
"translation",
"coordinates",
".",
"These",
"values",
"must",
"be",
"between",
"-",
"1",
"and",
"1",
"representing",
"the",
"transaction",
"percentage",
"from",
"the",
"center",
"."
] | 152208310d5e61009416b7c2f48ff8ca2464942f | https://github.com/nvanbenschoten/motion/blob/152208310d5e61009416b7c2f48ff8ca2464942f/motion/src/main/java/com/nvanbenschoten/motion/ParallaxImageView.java#L237-L275 | train |
nvanbenschoten/motion | motion/src/main/java/com/nvanbenschoten/motion/ParallaxImageView.java | ParallaxImageView.configureMatrix | private void configureMatrix() {
if (getDrawable() == null || getWidth() == 0 || getHeight() == 0) return;
int dWidth = getDrawable().getIntrinsicWidth();
int dHeight = getDrawable().getIntrinsicHeight();
int vWidth = getWidth();
int vHeight = getHeight();
float scale;
... | java | private void configureMatrix() {
if (getDrawable() == null || getWidth() == 0 || getHeight() == 0) return;
int dWidth = getDrawable().getIntrinsicWidth();
int dHeight = getDrawable().getIntrinsicHeight();
int vWidth = getWidth();
int vHeight = getHeight();
float scale;
... | [
"private",
"void",
"configureMatrix",
"(",
")",
"{",
"if",
"(",
"getDrawable",
"(",
")",
"==",
"null",
"||",
"getWidth",
"(",
")",
"==",
"0",
"||",
"getHeight",
"(",
")",
"==",
"0",
")",
"return",
";",
"int",
"dWidth",
"=",
"getDrawable",
"(",
")",
... | Configures the ImageView's imageMatrix to allow for movement of the
source image. | [
"Configures",
"the",
"ImageView",
"s",
"imageMatrix",
"to",
"allow",
"for",
"movement",
"of",
"the",
"source",
"image",
"."
] | 152208310d5e61009416b7c2f48ff8ca2464942f | https://github.com/nvanbenschoten/motion/blob/152208310d5e61009416b7c2f48ff8ca2464942f/motion/src/main/java/com/nvanbenschoten/motion/ParallaxImageView.java#L281-L309 | train |
TomasMikula/EasyBind | src/main/java/org/fxmisc/easybind/EasyBind.java | EasyBind.monadic | public static <T> MonadicObservableValue<T> monadic(ObservableValue<T> o) {
if(o instanceof MonadicObservableValue) {
return (MonadicObservableValue<T>) o;
} else {
return new MonadicWrapper<>(o);
}
} | java | public static <T> MonadicObservableValue<T> monadic(ObservableValue<T> o) {
if(o instanceof MonadicObservableValue) {
return (MonadicObservableValue<T>) o;
} else {
return new MonadicWrapper<>(o);
}
} | [
"public",
"static",
"<",
"T",
">",
"MonadicObservableValue",
"<",
"T",
">",
"monadic",
"(",
"ObservableValue",
"<",
"T",
">",
"o",
")",
"{",
"if",
"(",
"o",
"instanceof",
"MonadicObservableValue",
")",
"{",
"return",
"(",
"MonadicObservableValue",
"<",
"T",
... | Creates a thin wrapper around an observable value to make it monadic.
@param o ObservableValue to wrap
@return {@code o} if {@code o} is already monadic, or a thin monadic
wrapper around {@code o} otherwise. | [
"Creates",
"a",
"thin",
"wrapper",
"around",
"an",
"observable",
"value",
"to",
"make",
"it",
"monadic",
"."
] | 516947dec9de4977d8a817b7d1dfd320cc644298 | https://github.com/TomasMikula/EasyBind/blob/516947dec9de4977d8a817b7d1dfd320cc644298/src/main/java/org/fxmisc/easybind/EasyBind.java#L53-L59 | train |
hypercube1024/firefly | firefly/src/main/java/com/firefly/codec/http2/model/MimeTypes.java | MimeTypes.getDefaultMimeByExtension | public static String getDefaultMimeByExtension(String filename) {
String type = null;
if (filename != null) {
int i = -1;
while (type == null) {
i = filename.indexOf(".", i + 1);
if (i < 0 || i >= filename.length())
break;
... | java | public static String getDefaultMimeByExtension(String filename) {
String type = null;
if (filename != null) {
int i = -1;
while (type == null) {
i = filename.indexOf(".", i + 1);
if (i < 0 || i >= filename.length())
break;
... | [
"public",
"static",
"String",
"getDefaultMimeByExtension",
"(",
"String",
"filename",
")",
"{",
"String",
"type",
"=",
"null",
";",
"if",
"(",
"filename",
"!=",
"null",
")",
"{",
"int",
"i",
"=",
"-",
"1",
";",
"while",
"(",
"type",
"==",
"null",
")",
... | Get the MIME type by filename extension.
Lookup only the static default mime map.
@param filename A file name
@return MIME type matching the longest dot extension of the
file name. | [
"Get",
"the",
"MIME",
"type",
"by",
"filename",
"extension",
".",
"Lookup",
"only",
"the",
"static",
"default",
"mime",
"map",
"."
] | ed3fc75b7c54a65b1e7d8141d01b49144bb423a3 | https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly/src/main/java/com/firefly/codec/http2/model/MimeTypes.java#L244-L265 | train |
hypercube1024/firefly | firefly/src/main/java/com/firefly/codec/http2/model/HttpURI.java | HttpURI.createHttpURI | public static HttpURI createHttpURI(String scheme, String host, int port, String path, String param, String query, String fragment) {
if (port == 80 && HttpScheme.HTTP.is(scheme))
port = 0;
if (port == 443 && HttpScheme.HTTPS.is(scheme))
port = 0;
return new HttpURI(schem... | java | public static HttpURI createHttpURI(String scheme, String host, int port, String path, String param, String query, String fragment) {
if (port == 80 && HttpScheme.HTTP.is(scheme))
port = 0;
if (port == 443 && HttpScheme.HTTPS.is(scheme))
port = 0;
return new HttpURI(schem... | [
"public",
"static",
"HttpURI",
"createHttpURI",
"(",
"String",
"scheme",
",",
"String",
"host",
",",
"int",
"port",
",",
"String",
"path",
",",
"String",
"param",
",",
"String",
"query",
",",
"String",
"fragment",
")",
"{",
"if",
"(",
"port",
"==",
"80",... | Construct a normalized URI.
Port is not set if it is the default port.
@param scheme the URI scheme
@param host the URI hose
@param port the URI port
@param path the URI path
@param param the URI param
@param query the URI query
@param fragment the URI fragment
@return the normalized URI | [
"Construct",
"a",
"normalized",
"URI",
".",
"Port",
"is",
"not",
"set",
"if",
"it",
"is",
"the",
"default",
"port",
"."
] | ed3fc75b7c54a65b1e7d8141d01b49144bb423a3 | https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly/src/main/java/com/firefly/codec/http2/model/HttpURI.java#L74-L80 | train |
hypercube1024/firefly | firefly/src/main/java/com/firefly/codec/http2/encode/UrlEncoded.java | UrlEncoded.encode | public static String encode(MultiMap<String> map, Charset charset, boolean equalsForNullValue) {
if (charset == null)
charset = ENCODING;
StringBuilder result = new StringBuilder(128);
boolean delim = false;
for (Map.Entry<String, List<String>> entry : map.entrySet()) {
... | java | public static String encode(MultiMap<String> map, Charset charset, boolean equalsForNullValue) {
if (charset == null)
charset = ENCODING;
StringBuilder result = new StringBuilder(128);
boolean delim = false;
for (Map.Entry<String, List<String>> entry : map.entrySet()) {
... | [
"public",
"static",
"String",
"encode",
"(",
"MultiMap",
"<",
"String",
">",
"map",
",",
"Charset",
"charset",
",",
"boolean",
"equalsForNullValue",
")",
"{",
"if",
"(",
"charset",
"==",
"null",
")",
"charset",
"=",
"ENCODING",
";",
"StringBuilder",
"result"... | Encode MultiMap with % encoding.
@param map the map to encode
@param charset the charset to use for encoding (uses default encoding if null)
@param equalsForNullValue if True, then an '=' is always used, even
for parameters without a value. e.g. <code>"blah?a=&b=&c="</code>.
@return t... | [
"Encode",
"MultiMap",
"with",
"%",
"encoding",
"."
] | ed3fc75b7c54a65b1e7d8141d01b49144bb423a3 | https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly/src/main/java/com/firefly/codec/http2/encode/UrlEncoded.java#L126-L166 | train |
hypercube1024/firefly | firefly/src/main/java/com/firefly/codec/http2/encode/UrlEncoded.java | UrlEncoded.decode88591To | public static void decode88591To(InputStream in, MultiMap<String> map, int maxLength, int maxKeys)
throws IOException {
synchronized (map) {
StringBuffer buffer = new StringBuffer();
String key = null;
String value = null;
int b;
int tota... | java | public static void decode88591To(InputStream in, MultiMap<String> map, int maxLength, int maxKeys)
throws IOException {
synchronized (map) {
StringBuffer buffer = new StringBuffer();
String key = null;
String value = null;
int b;
int tota... | [
"public",
"static",
"void",
"decode88591To",
"(",
"InputStream",
"in",
",",
"MultiMap",
"<",
"String",
">",
"map",
",",
"int",
"maxLength",
",",
"int",
"maxKeys",
")",
"throws",
"IOException",
"{",
"synchronized",
"(",
"map",
")",
"{",
"StringBuffer",
"buffe... | Decoded parameters to MultiMap, using ISO8859-1 encodings.
@param in InputSteam to read
@param map MultiMap to add parameters to
@param maxLength maximum length of form to read
@param maxKeys maximum number of keys to read or -1 for no limit
@throws IOException if unable to decode inputstream as ISO8859... | [
"Decoded",
"parameters",
"to",
"MultiMap",
"using",
"ISO8859",
"-",
"1",
"encodings",
"."
] | ed3fc75b7c54a65b1e7d8141d01b49144bb423a3 | https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly/src/main/java/com/firefly/codec/http2/encode/UrlEncoded.java#L330-L391 | train |
hypercube1024/firefly | firefly-common/src/main/java/com/firefly/utils/io/InputStreamResource.java | InputStreamResource.getInputStream | @Override
public InputStream getInputStream() throws IOException, IllegalStateException {
if (this.read) {
throw new IllegalStateException("InputStream has already been read - " +
"do not use InputStreamResource if a stream needs to be read multiple times");
}
... | java | @Override
public InputStream getInputStream() throws IOException, IllegalStateException {
if (this.read) {
throw new IllegalStateException("InputStream has already been read - " +
"do not use InputStreamResource if a stream needs to be read multiple times");
}
... | [
"@",
"Override",
"public",
"InputStream",
"getInputStream",
"(",
")",
"throws",
"IOException",
",",
"IllegalStateException",
"{",
"if",
"(",
"this",
".",
"read",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"InputStream has already been read - \"",
"+",
... | This implementation throws IllegalStateException if attempting to
read the underlying stream multiple times. | [
"This",
"implementation",
"throws",
"IllegalStateException",
"if",
"attempting",
"to",
"read",
"the",
"underlying",
"stream",
"multiple",
"times",
"."
] | ed3fc75b7c54a65b1e7d8141d01b49144bb423a3 | https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/io/InputStreamResource.java#L76-L84 | train |
hypercube1024/firefly | firefly-db/src/main/java/com/firefly/db/jdbc/helper/DefaultBeanProcessor.java | DefaultBeanProcessor.createBean | private <T> T createBean(ResultSet rs, Class<T> type,
PropertyDescriptor[] props, int[] columnToProperty)
throws SQLException {
T bean = this.newInstance(type);
return populateBean(rs, bean, props, columnToProperty);
} | java | private <T> T createBean(ResultSet rs, Class<T> type,
PropertyDescriptor[] props, int[] columnToProperty)
throws SQLException {
T bean = this.newInstance(type);
return populateBean(rs, bean, props, columnToProperty);
} | [
"private",
"<",
"T",
">",
"T",
"createBean",
"(",
"ResultSet",
"rs",
",",
"Class",
"<",
"T",
">",
"type",
",",
"PropertyDescriptor",
"[",
"]",
"props",
",",
"int",
"[",
"]",
"columnToProperty",
")",
"throws",
"SQLException",
"{",
"T",
"bean",
"=",
"thi... | Creates a new object and initializes its fields from the ResultSet.
@param <T> The type of bean to create
@param rs The result set.
@param type The bean type (the return type of the object).
@param props The property descriptors.
@param columnToProperty The column indi... | [
"Creates",
"a",
"new",
"object",
"and",
"initializes",
"its",
"fields",
"from",
"the",
"ResultSet",
"."
] | ed3fc75b7c54a65b1e7d8141d01b49144bb423a3 | https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-db/src/main/java/com/firefly/db/jdbc/helper/DefaultBeanProcessor.java#L93-L99 | train |
hypercube1024/firefly | firefly-db/src/main/java/com/firefly/db/jdbc/helper/DefaultBeanProcessor.java | DefaultBeanProcessor.populateBean | @Override
public <T> T populateBean(ResultSet rs, T bean) throws SQLException {
Class<?> type = bean.getClass();
PropertyDescriptor[] props = this.propertyDescriptors(type);
int[] columnToProperty = this.mapColumnsToProperties(rs.getMetaData(), props, type);
return populateBean(rs, b... | java | @Override
public <T> T populateBean(ResultSet rs, T bean) throws SQLException {
Class<?> type = bean.getClass();
PropertyDescriptor[] props = this.propertyDescriptors(type);
int[] columnToProperty = this.mapColumnsToProperties(rs.getMetaData(), props, type);
return populateBean(rs, b... | [
"@",
"Override",
"public",
"<",
"T",
">",
"T",
"populateBean",
"(",
"ResultSet",
"rs",
",",
"T",
"bean",
")",
"throws",
"SQLException",
"{",
"Class",
"<",
"?",
">",
"type",
"=",
"bean",
".",
"getClass",
"(",
")",
";",
"PropertyDescriptor",
"[",
"]",
... | Initializes the fields of the provided bean from the ResultSet.
@param <T> The type of bean
@param rs The result set.
@param bean The bean to be populated.
@return An initialized object.
@throws SQLException if a database error occurs. | [
"Initializes",
"the",
"fields",
"of",
"the",
"provided",
"bean",
"from",
"the",
"ResultSet",
"."
] | ed3fc75b7c54a65b1e7d8141d01b49144bb423a3 | https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-db/src/main/java/com/firefly/db/jdbc/helper/DefaultBeanProcessor.java#L110-L116 | train |
hypercube1024/firefly | firefly-db/src/main/java/com/firefly/db/jdbc/helper/DefaultBeanProcessor.java | DefaultBeanProcessor.populateBean | private <T> T populateBean(ResultSet rs, T bean,
PropertyDescriptor[] props, int[] columnToProperty)
throws SQLException {
for (int i = 1; i < columnToProperty.length; i++) {
if (columnToProperty[i] == PROPERTY_NOT_FOUND) {
continue;
... | java | private <T> T populateBean(ResultSet rs, T bean,
PropertyDescriptor[] props, int[] columnToProperty)
throws SQLException {
for (int i = 1; i < columnToProperty.length; i++) {
if (columnToProperty[i] == PROPERTY_NOT_FOUND) {
continue;
... | [
"private",
"<",
"T",
">",
"T",
"populateBean",
"(",
"ResultSet",
"rs",
",",
"T",
"bean",
",",
"PropertyDescriptor",
"[",
"]",
"props",
",",
"int",
"[",
"]",
"columnToProperty",
")",
"throws",
"SQLException",
"{",
"for",
"(",
"int",
"i",
"=",
"1",
";",
... | This method populates a bean from the ResultSet based upon the underlying meta-data.
@param <T> The type of bean
@param rs The result set.
@param bean The bean to be populated.
@param props The property descriptors.
@param columnToProperty The column indices in the res... | [
"This",
"method",
"populates",
"a",
"bean",
"from",
"the",
"ResultSet",
"based",
"upon",
"the",
"underlying",
"meta",
"-",
"data",
"."
] | ed3fc75b7c54a65b1e7d8141d01b49144bb423a3 | https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-db/src/main/java/com/firefly/db/jdbc/helper/DefaultBeanProcessor.java#L129-L155 | train |
hypercube1024/firefly | firefly-db/src/main/java/com/firefly/db/jdbc/helper/DefaultBeanProcessor.java | DefaultBeanProcessor.callSetter | private void callSetter(Object target, PropertyDescriptor prop, Object value)
throws SQLException {
Method setter = getWriteMethod(target, prop, value);
if (setter == null || setter.getParameterTypes().length != 1) {
return;
}
try {
Class<?> firstPa... | java | private void callSetter(Object target, PropertyDescriptor prop, Object value)
throws SQLException {
Method setter = getWriteMethod(target, prop, value);
if (setter == null || setter.getParameterTypes().length != 1) {
return;
}
try {
Class<?> firstPa... | [
"private",
"void",
"callSetter",
"(",
"Object",
"target",
",",
"PropertyDescriptor",
"prop",
",",
"Object",
"value",
")",
"throws",
"SQLException",
"{",
"Method",
"setter",
"=",
"getWriteMethod",
"(",
"target",
",",
"prop",
",",
"value",
")",
";",
"if",
"(",... | Calls the setter method on the target object for the given property.
If no setter method exists for the property, this method does nothing.
@param target The object to set the property on.
@param prop The property to set.
@param value The value to pass into the setter.
@throws SQLException if an error occurs settin... | [
"Calls",
"the",
"setter",
"method",
"on",
"the",
"target",
"object",
"for",
"the",
"given",
"property",
".",
"If",
"no",
"setter",
"method",
"exists",
"for",
"the",
"property",
"this",
"method",
"does",
"nothing",
"."
] | ed3fc75b7c54a65b1e7d8141d01b49144bb423a3 | https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-db/src/main/java/com/firefly/db/jdbc/helper/DefaultBeanProcessor.java#L166-L206 | train |
hypercube1024/firefly | firefly-common/src/main/java/com/firefly/utils/lang/StringParser.java | StringParser.setString | public void setString(String string) {
this.string = string;
if (string != null) {
this.length = string.length();
chars = this.string.toCharArray();
} else {
this.length = 0;
chars = new char[0];
}
reset();
} | java | public void setString(String string) {
this.string = string;
if (string != null) {
this.length = string.length();
chars = this.string.toCharArray();
} else {
this.length = 0;
chars = new char[0];
}
reset();
} | [
"public",
"void",
"setString",
"(",
"String",
"string",
")",
"{",
"this",
".",
"string",
"=",
"string",
";",
"if",
"(",
"string",
"!=",
"null",
")",
"{",
"this",
".",
"length",
"=",
"string",
".",
"length",
"(",
")",
";",
"chars",
"=",
"this",
".",... | Set the String we are currently parsing. The parser state is also reset
to begin at the start of this string.
@param string The string to be parsed. | [
"Set",
"the",
"String",
"we",
"are",
"currently",
"parsing",
".",
"The",
"parser",
"state",
"is",
"also",
"reset",
"to",
"begin",
"at",
"the",
"start",
"of",
"this",
"string",
"."
] | ed3fc75b7c54a65b1e7d8141d01b49144bb423a3 | https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/lang/StringParser.java#L145-L157 | train |
hypercube1024/firefly | firefly-common/src/main/java/com/firefly/utils/lang/StringParser.java | StringParser.extract | public String extract(int start, int end) {
if ((start < 0) || (start >= end) || (end > length))
return ("");
else
return (string.substring(start, end));
} | java | public String extract(int start, int end) {
if ((start < 0) || (start >= end) || (end > length))
return ("");
else
return (string.substring(start, end));
} | [
"public",
"String",
"extract",
"(",
"int",
"start",
",",
"int",
"end",
")",
"{",
"if",
"(",
"(",
"start",
"<",
"0",
")",
"||",
"(",
"start",
">=",
"end",
")",
"||",
"(",
"end",
">",
"length",
")",
")",
"return",
"(",
"\"\"",
")",
";",
"else",
... | Extract and return a substring that starts at the specified position,
and ends at the character before the specified position. If this is
not possible, a zero-length string is returned.
@param start Starting index, zero relative, inclusive
@param end Ending index, zero relative, exclusive
@return The result string ... | [
"Extract",
"and",
"return",
"a",
"substring",
"that",
"starts",
"at",
"the",
"specified",
"position",
"and",
"ends",
"at",
"the",
"character",
"before",
"the",
"specified",
"position",
".",
"If",
"this",
"is",
"not",
"possible",
"a",
"zero",
"-",
"length",
... | ed3fc75b7c54a65b1e7d8141d01b49144bb423a3 | https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/lang/StringParser.java#L202-L209 | train |
hypercube1024/firefly | firefly-db/src/main/java/com/firefly/db/jdbc/helper/DefaultBeanMapHandler.java | DefaultBeanMapHandler.createKey | @SuppressWarnings("unchecked")
@Override
protected K createKey(ResultSet rs) throws SQLException {
return (columnName == null) ?
(K) rs.getObject(columnIndex) :
(K) rs.getObject(columnName);
} | java | @SuppressWarnings("unchecked")
@Override
protected K createKey(ResultSet rs) throws SQLException {
return (columnName == null) ?
(K) rs.getObject(columnIndex) :
(K) rs.getObject(columnName);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"@",
"Override",
"protected",
"K",
"createKey",
"(",
"ResultSet",
"rs",
")",
"throws",
"SQLException",
"{",
"return",
"(",
"columnName",
"==",
"null",
")",
"?",
"(",
"K",
")",
"rs",
".",
"getObject",
"(",... | so getObject will return the appropriate type and the cast will succeed. | [
"so",
"getObject",
"will",
"return",
"the",
"appropriate",
"type",
"and",
"the",
"cast",
"will",
"succeed",
"."
] | ed3fc75b7c54a65b1e7d8141d01b49144bb423a3 | https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-db/src/main/java/com/firefly/db/jdbc/helper/DefaultBeanMapHandler.java#L76-L82 | train |
hypercube1024/firefly | firefly-common/src/main/java/com/firefly/utils/collection/ConcurrentLinkedHashMap.java | ConcurrentLinkedHashMap.segmentFor | private LinkedHashMapSegment<K, V> segmentFor(int hash) {
int h = hash(hash);
return segments[(h >>> segmentShift) & segmentMask];
} | java | private LinkedHashMapSegment<K, V> segmentFor(int hash) {
int h = hash(hash);
return segments[(h >>> segmentShift) & segmentMask];
} | [
"private",
"LinkedHashMapSegment",
"<",
"K",
",",
"V",
">",
"segmentFor",
"(",
"int",
"hash",
")",
"{",
"int",
"h",
"=",
"hash",
"(",
"hash",
")",
";",
"return",
"segments",
"[",
"(",
"h",
">>>",
"segmentShift",
")",
"&",
"segmentMask",
"]",
";",
"}"... | Returns the segment that should be used for key with given hash
@param hash the hash code for the key
@return the segment | [
"Returns",
"the",
"segment",
"that",
"should",
"be",
"used",
"for",
"key",
"with",
"given",
"hash"
] | ed3fc75b7c54a65b1e7d8141d01b49144bb423a3 | https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/collection/ConcurrentLinkedHashMap.java#L225-L228 | train |
hypercube1024/firefly | firefly-common/src/main/java/com/firefly/utils/collection/ConcurrentLinkedHashMap.java | ConcurrentLinkedHashMap.size | @Override
public int size() {
try {
lockAllSegments();
int size = 0;
for (LinkedHashMapSegment<K, V> seg : segments) {
size += seg.size();
}
return size;
} finally {
unlockAllSegments();
}
} | java | @Override
public int size() {
try {
lockAllSegments();
int size = 0;
for (LinkedHashMapSegment<K, V> seg : segments) {
size += seg.size();
}
return size;
} finally {
unlockAllSegments();
}
} | [
"@",
"Override",
"public",
"int",
"size",
"(",
")",
"{",
"try",
"{",
"lockAllSegments",
"(",
")",
";",
"int",
"size",
"=",
"0",
";",
"for",
"(",
"LinkedHashMapSegment",
"<",
"K",
",",
"V",
">",
"seg",
":",
"segments",
")",
"{",
"size",
"+=",
"seg",... | Gets the entry's total number.
@return entry's number | [
"Gets",
"the",
"entry",
"s",
"total",
"number",
"."
] | ed3fc75b7c54a65b1e7d8141d01b49144bb423a3 | https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/collection/ConcurrentLinkedHashMap.java#L245-L257 | train |
hypercube1024/firefly | firefly-common/src/main/java/com/firefly/utils/collection/ConcurrentLinkedHashMap.java | ConcurrentLinkedHashMap.get | @SuppressWarnings("unchecked")
@Override
public V get(Object key) {
LinkedHashMapSegment<K, V> seg = segmentFor(key.hashCode());
try {
seg.lock.lock();
return mapEventListener.onGetEntry((K) key, seg.get(key));
} finally {
seg.lock.unlock();
}
... | java | @SuppressWarnings("unchecked")
@Override
public V get(Object key) {
LinkedHashMapSegment<K, V> seg = segmentFor(key.hashCode());
try {
seg.lock.lock();
return mapEventListener.onGetEntry((K) key, seg.get(key));
} finally {
seg.lock.unlock();
}
... | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"@",
"Override",
"public",
"V",
"get",
"(",
"Object",
"key",
")",
"{",
"LinkedHashMapSegment",
"<",
"K",
",",
"V",
">",
"seg",
"=",
"segmentFor",
"(",
"key",
".",
"hashCode",
"(",
")",
")",
";",
"try"... | Returns a value which the specified key is mapped.
At the same time, this method will call the callback interface, the getting entry event will be triggered.
@param key the key whose associated value is to be returned
@return the value which the specified key is mapped, or
{@code null} if this map contains no mapping ... | [
"Returns",
"a",
"value",
"which",
"the",
"specified",
"key",
"is",
"mapped",
".",
"At",
"the",
"same",
"time",
"this",
"method",
"will",
"call",
"the",
"callback",
"interface",
"the",
"getting",
"entry",
"event",
"will",
"be",
"triggered",
"."
] | ed3fc75b7c54a65b1e7d8141d01b49144bb423a3 | https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/collection/ConcurrentLinkedHashMap.java#L316-L327 | train |
hypercube1024/firefly | firefly-common/src/main/java/com/firefly/utils/collection/ConcurrentLinkedHashMap.java | ConcurrentLinkedHashMap.put | @Override
public V put(K key, V value) {
LinkedHashMapSegment<K, V> seg = segmentFor(key.hashCode());
try {
seg.lock.lock();
return mapEventListener.onPutEntry(key, value, seg.put(key, value));
} finally {
seg.lock.unlock();
}
} | java | @Override
public V put(K key, V value) {
LinkedHashMapSegment<K, V> seg = segmentFor(key.hashCode());
try {
seg.lock.lock();
return mapEventListener.onPutEntry(key, value, seg.put(key, value));
} finally {
seg.lock.unlock();
}
} | [
"@",
"Override",
"public",
"V",
"put",
"(",
"K",
"key",
",",
"V",
"value",
")",
"{",
"LinkedHashMapSegment",
"<",
"K",
",",
"V",
">",
"seg",
"=",
"segmentFor",
"(",
"key",
".",
"hashCode",
"(",
")",
")",
";",
"try",
"{",
"seg",
".",
"lock",
".",
... | Associates the specified value with the specified key in this map.
If the key existed in the map, the entry will be replaced by specified entry.
This method will call the putting entry event when the method is called.
@param key key with which the specified value is to be associated
@param value value to be associat... | [
"Associates",
"the",
"specified",
"value",
"with",
"the",
"specified",
"key",
"in",
"this",
"map",
".",
"If",
"the",
"key",
"existed",
"in",
"the",
"map",
"the",
"entry",
"will",
"be",
"replaced",
"by",
"specified",
"entry",
".",
"This",
"method",
"will",
... | ed3fc75b7c54a65b1e7d8141d01b49144bb423a3 | https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/collection/ConcurrentLinkedHashMap.java#L342-L351 | train |
hypercube1024/firefly | firefly-common/src/main/java/com/firefly/utils/collection/ConcurrentLinkedHashMap.java | ConcurrentLinkedHashMap.remove | @SuppressWarnings("unchecked")
@Override
public V remove(Object key) {
LinkedHashMapSegment<K, V> seg = segmentFor(key.hashCode());
try {
seg.lock.lock();
return mapEventListener.onRemoveEntry((K) key, seg.remove(key));
} finally {
seg.lock.unlock();
... | java | @SuppressWarnings("unchecked")
@Override
public V remove(Object key) {
LinkedHashMapSegment<K, V> seg = segmentFor(key.hashCode());
try {
seg.lock.lock();
return mapEventListener.onRemoveEntry((K) key, seg.remove(key));
} finally {
seg.lock.unlock();
... | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"@",
"Override",
"public",
"V",
"remove",
"(",
"Object",
"key",
")",
"{",
"LinkedHashMapSegment",
"<",
"K",
",",
"V",
">",
"seg",
"=",
"segmentFor",
"(",
"key",
".",
"hashCode",
"(",
")",
")",
";",
"t... | Remove a entry from this map. The removing event will be called.
@param key key whose mapping is to be removed from the map
@return the previous value associated with <tt>key</tt>, or
<tt>null</tt> if there was no mapping for <tt>key</tt>. | [
"Remove",
"a",
"entry",
"from",
"this",
"map",
".",
"The",
"removing",
"event",
"will",
"be",
"called",
"."
] | ed3fc75b7c54a65b1e7d8141d01b49144bb423a3 | https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/collection/ConcurrentLinkedHashMap.java#L360-L370 | train |
hypercube1024/firefly | firefly-common/src/main/java/com/firefly/utils/collection/ConcurrentLinkedHashMap.java | ConcurrentLinkedHashMap.clear | @Override
public void clear() {
try {
lockAllSegments();
for (LinkedHashMapSegment<K, V> seg : segments) {
seg.clear();
}
} finally {
unlockAllSegments();
}
} | java | @Override
public void clear() {
try {
lockAllSegments();
for (LinkedHashMapSegment<K, V> seg : segments) {
seg.clear();
}
} finally {
unlockAllSegments();
}
} | [
"@",
"Override",
"public",
"void",
"clear",
"(",
")",
"{",
"try",
"{",
"lockAllSegments",
"(",
")",
";",
"for",
"(",
"LinkedHashMapSegment",
"<",
"K",
",",
"V",
">",
"seg",
":",
"segments",
")",
"{",
"seg",
".",
"clear",
"(",
")",
";",
"}",
"}",
... | clear all map's entries, but it dosen't trigger the remove callback method | [
"clear",
"all",
"map",
"s",
"entries",
"but",
"it",
"dosen",
"t",
"trigger",
"the",
"remove",
"callback",
"method"
] | ed3fc75b7c54a65b1e7d8141d01b49144bb423a3 | https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/collection/ConcurrentLinkedHashMap.java#L387-L397 | train |
hypercube1024/firefly | firefly-common/src/main/java/com/firefly/utils/collection/ConcurrentLinkedHashMap.java | ConcurrentLinkedHashMap.keySet | @Override
public Set<K> keySet() {
try {
lockAllSegments();
Set<K> set = new HashSet<>();
for (LinkedHashMapSegment<K, V> seg : segments) {
set.addAll(seg.keySet());
}
return set;
} finally {
unlockAllSegments();... | java | @Override
public Set<K> keySet() {
try {
lockAllSegments();
Set<K> set = new HashSet<>();
for (LinkedHashMapSegment<K, V> seg : segments) {
set.addAll(seg.keySet());
}
return set;
} finally {
unlockAllSegments();... | [
"@",
"Override",
"public",
"Set",
"<",
"K",
">",
"keySet",
"(",
")",
"{",
"try",
"{",
"lockAllSegments",
"(",
")",
";",
"Set",
"<",
"K",
">",
"set",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"for",
"(",
"LinkedHashMapSegment",
"<",
"K",
",",
"V... | Gets the all key in this map.
@return a set view of the keys contained in this map | [
"Gets",
"the",
"all",
"key",
"in",
"this",
"map",
"."
] | ed3fc75b7c54a65b1e7d8141d01b49144bb423a3 | https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/collection/ConcurrentLinkedHashMap.java#L404-L416 | train |
hypercube1024/firefly | firefly-common/src/main/java/com/firefly/utils/io/IO.java | IO.copy | public static void copy(File from, File to) throws IOException {
if (from.isDirectory())
copyDir(from, to);
else
copyFile(from, to);
} | java | public static void copy(File from, File to) throws IOException {
if (from.isDirectory())
copyDir(from, to);
else
copyFile(from, to);
} | [
"public",
"static",
"void",
"copy",
"(",
"File",
"from",
",",
"File",
"to",
")",
"throws",
"IOException",
"{",
"if",
"(",
"from",
".",
"isDirectory",
"(",
")",
")",
"copyDir",
"(",
"from",
",",
"to",
")",
";",
"else",
"copyFile",
"(",
"from",
",",
... | Copy files or directories
@param from the file to copy
@param to the destination to copy to
@throws IOException if unable to copy | [
"Copy",
"files",
"or",
"directories"
] | ed3fc75b7c54a65b1e7d8141d01b49144bb423a3 | https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/io/IO.java#L168-L173 | train |
hypercube1024/firefly | firefly-common/src/main/java/com/firefly/utils/lang/ArrayUtils.java | ArrayUtils.addToArray | public static <T> T[] addToArray(T[] array, T item, Class<?> type) {
if (array == null) {
if (type == null && item != null) {
type = item.getClass();
}
@SuppressWarnings("unchecked")
T[] na = (T[]) Array.newInstance(type, 1);
na[0] = it... | java | public static <T> T[] addToArray(T[] array, T item, Class<?> type) {
if (array == null) {
if (type == null && item != null) {
type = item.getClass();
}
@SuppressWarnings("unchecked")
T[] na = (T[]) Array.newInstance(type, 1);
na[0] = it... | [
"public",
"static",
"<",
"T",
">",
"T",
"[",
"]",
"addToArray",
"(",
"T",
"[",
"]",
"array",
",",
"T",
"item",
",",
"Class",
"<",
"?",
">",
"type",
")",
"{",
"if",
"(",
"array",
"==",
"null",
")",
"{",
"if",
"(",
"type",
"==",
"null",
"&&",
... | Add element to 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",
"an",
"array"
] | ed3fc75b7c54a65b1e7d8141d01b49144bb423a3 | https://github.com/hypercube1024/firefly/blob/ed3fc75b7c54a65b1e7d8141d01b49144bb423a3/firefly-common/src/main/java/com/firefly/utils/lang/ArrayUtils.java#L120-L134 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.