id
int32 0
165k
| repo
stringlengths 7
58
| path
stringlengths 12
218
| func_name
stringlengths 3
140
| original_string
stringlengths 73
34.1k
| language
stringclasses 1
value | code
stringlengths 73
34.1k
| code_tokens
list | docstring
stringlengths 3
16k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 105
339
|
|---|---|---|---|---|---|---|---|---|---|---|---|
155,000
|
gnagy/webhejj-commons
|
src/main/java/hu/webhejj/commons/files/FileUtils.java
|
FileUtils.copy
|
public static void copy(InputStream is, OutputStream os) throws IOException {
Asserts.notNullParameter("is", is);
Asserts.notNullParameter("os", os);
try {
byte[] buf = new byte[1024];
int len = 0;
while((len = is.read(buf)) > 0) {
os.write(buf, 0, len);
}
} finally {
if(os != null) {
try {
os.close();
} catch (IOException e) {
// ignore
}
}
if(is != null) {
try {
is.close();
} catch (IOException e) {
// ignore
}
}
}
}
|
java
|
public static void copy(InputStream is, OutputStream os) throws IOException {
Asserts.notNullParameter("is", is);
Asserts.notNullParameter("os", os);
try {
byte[] buf = new byte[1024];
int len = 0;
while((len = is.read(buf)) > 0) {
os.write(buf, 0, len);
}
} finally {
if(os != null) {
try {
os.close();
} catch (IOException e) {
// ignore
}
}
if(is != null) {
try {
is.close();
} catch (IOException e) {
// ignore
}
}
}
}
|
[
"public",
"static",
"void",
"copy",
"(",
"InputStream",
"is",
",",
"OutputStream",
"os",
")",
"throws",
"IOException",
"{",
"Asserts",
".",
"notNullParameter",
"(",
"\"is\"",
",",
"is",
")",
";",
"Asserts",
".",
"notNullParameter",
"(",
"\"os\"",
",",
"os",
")",
";",
"try",
"{",
"byte",
"[",
"]",
"buf",
"=",
"new",
"byte",
"[",
"1024",
"]",
";",
"int",
"len",
"=",
"0",
";",
"while",
"(",
"(",
"len",
"=",
"is",
".",
"read",
"(",
"buf",
")",
")",
">",
"0",
")",
"{",
"os",
".",
"write",
"(",
"buf",
",",
"0",
",",
"len",
")",
";",
"}",
"}",
"finally",
"{",
"if",
"(",
"os",
"!=",
"null",
")",
"{",
"try",
"{",
"os",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"// ignore",
"}",
"}",
"if",
"(",
"is",
"!=",
"null",
")",
"{",
"try",
"{",
"is",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"// ignore",
"}",
"}",
"}",
"}"
] |
copy data from the specified input stream to the specified output stream
|
[
"copy",
"data",
"from",
"the",
"specified",
"input",
"stream",
"to",
"the",
"specified",
"output",
"stream"
] |
270bc6f111ec5761af31d39bd38c40fd914d2eba
|
https://github.com/gnagy/webhejj-commons/blob/270bc6f111ec5761af31d39bd38c40fd914d2eba/src/main/java/hu/webhejj/commons/files/FileUtils.java#L118-L147
|
155,001
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/util/io/MarkdownNotebookOutput.java
|
MarkdownNotebookOutput.setAbsoluteUrl
|
@javax.annotation.Nonnull
public com.simiacryptus.util.io.MarkdownNotebookOutput setAbsoluteUrl(final String absoluteUrl) {
this.absoluteUrl = absoluteUrl;
return this;
}
|
java
|
@javax.annotation.Nonnull
public com.simiacryptus.util.io.MarkdownNotebookOutput setAbsoluteUrl(final String absoluteUrl) {
this.absoluteUrl = absoluteUrl;
return this;
}
|
[
"@",
"javax",
".",
"annotation",
".",
"Nonnull",
"public",
"com",
".",
"simiacryptus",
".",
"util",
".",
"io",
".",
"MarkdownNotebookOutput",
"setAbsoluteUrl",
"(",
"final",
"String",
"absoluteUrl",
")",
"{",
"this",
".",
"absoluteUrl",
"=",
"absoluteUrl",
";",
"return",
"this",
";",
"}"
] |
Sets absolute url.
@param absoluteUrl the absolute url
@return the absolute url
|
[
"Sets",
"absolute",
"url",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/io/MarkdownNotebookOutput.java#L367-L371
|
155,002
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/util/io/MarkdownNotebookOutput.java
|
MarkdownNotebookOutput.linkTo
|
public String linkTo(@javax.annotation.Nonnull final File file) throws IOException {
return codeFile(file);
}
|
java
|
public String linkTo(@javax.annotation.Nonnull final File file) throws IOException {
return codeFile(file);
}
|
[
"public",
"String",
"linkTo",
"(",
"@",
"javax",
".",
"annotation",
".",
"Nonnull",
"final",
"File",
"file",
")",
"throws",
"IOException",
"{",
"return",
"codeFile",
"(",
"file",
")",
";",
"}"
] |
Link to string.
@param file the file
@return the string
@throws IOException the io exception
|
[
"Link",
"to",
"string",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/io/MarkdownNotebookOutput.java#L475-L477
|
155,003
|
james-hu/jabb-core
|
src/main/java/net/sf/jabb/spring/service/AbstractThreadPoolService.java
|
AbstractThreadPoolService.getStatusOfThreadPools
|
public Map<String, ThreadPoolStatus> getStatusOfThreadPools(){
Map<String, ThreadPoolStatus> result = new TreeMap<String, ThreadPoolStatus>();
for (Map.Entry<String, ? extends ThreadPoolExecutor> entry: threadPools.entrySet()){
ThreadPoolStatus status = new ThreadPoolStatus();
status.setName(entry.getKey());
ThreadPoolExecutor pool = entry.getValue();
status.setActive(pool.getActiveCount());
status.setKeepAliveSeconds(pool.getKeepAliveTime(TimeUnit.SECONDS));
status.setLargestSize(pool.getLargestPoolSize());
status.setMaxSize(pool.getMaximumPoolSize());
status.setSize(pool.getPoolSize());
status.setQueueLength(pool.getQueue().size());
result.put(entry.getKey(), status);
}
return result;
}
|
java
|
public Map<String, ThreadPoolStatus> getStatusOfThreadPools(){
Map<String, ThreadPoolStatus> result = new TreeMap<String, ThreadPoolStatus>();
for (Map.Entry<String, ? extends ThreadPoolExecutor> entry: threadPools.entrySet()){
ThreadPoolStatus status = new ThreadPoolStatus();
status.setName(entry.getKey());
ThreadPoolExecutor pool = entry.getValue();
status.setActive(pool.getActiveCount());
status.setKeepAliveSeconds(pool.getKeepAliveTime(TimeUnit.SECONDS));
status.setLargestSize(pool.getLargestPoolSize());
status.setMaxSize(pool.getMaximumPoolSize());
status.setSize(pool.getPoolSize());
status.setQueueLength(pool.getQueue().size());
result.put(entry.getKey(), status);
}
return result;
}
|
[
"public",
"Map",
"<",
"String",
",",
"ThreadPoolStatus",
">",
"getStatusOfThreadPools",
"(",
")",
"{",
"Map",
"<",
"String",
",",
"ThreadPoolStatus",
">",
"result",
"=",
"new",
"TreeMap",
"<",
"String",
",",
"ThreadPoolStatus",
">",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"?",
"extends",
"ThreadPoolExecutor",
">",
"entry",
":",
"threadPools",
".",
"entrySet",
"(",
")",
")",
"{",
"ThreadPoolStatus",
"status",
"=",
"new",
"ThreadPoolStatus",
"(",
")",
";",
"status",
".",
"setName",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
";",
"ThreadPoolExecutor",
"pool",
"=",
"entry",
".",
"getValue",
"(",
")",
";",
"status",
".",
"setActive",
"(",
"pool",
".",
"getActiveCount",
"(",
")",
")",
";",
"status",
".",
"setKeepAliveSeconds",
"(",
"pool",
".",
"getKeepAliveTime",
"(",
"TimeUnit",
".",
"SECONDS",
")",
")",
";",
"status",
".",
"setLargestSize",
"(",
"pool",
".",
"getLargestPoolSize",
"(",
")",
")",
";",
"status",
".",
"setMaxSize",
"(",
"pool",
".",
"getMaximumPoolSize",
"(",
")",
")",
";",
"status",
".",
"setSize",
"(",
"pool",
".",
"getPoolSize",
"(",
")",
")",
";",
"status",
".",
"setQueueLength",
"(",
"pool",
".",
"getQueue",
"(",
")",
".",
"size",
"(",
")",
")",
";",
"result",
".",
"put",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"status",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Get current status of all the thread pools
@return status by names sorted by names
|
[
"Get",
"current",
"status",
"of",
"all",
"the",
"thread",
"pools"
] |
bceed441595c5e5195a7418795f03b69fa7b61e4
|
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/spring/service/AbstractThreadPoolService.java#L214-L229
|
155,004
|
FitLayout/segmentation
|
src/main/java/org/fit/segm/grouping/AreaUtils.java
|
AreaUtils.isOnSameLine
|
public static boolean isOnSameLine(Area a1, Area a2, int threshold)
{
final Rectangular gp1 = a1.getBounds();
final Rectangular gp2 = a2.getBounds();
return (Math.abs(gp1.getY1() - gp2.getY1()) <= threshold
&& Math.abs(gp1.getY2() - gp2.getY2()) <= threshold);
}
|
java
|
public static boolean isOnSameLine(Area a1, Area a2, int threshold)
{
final Rectangular gp1 = a1.getBounds();
final Rectangular gp2 = a2.getBounds();
return (Math.abs(gp1.getY1() - gp2.getY1()) <= threshold
&& Math.abs(gp1.getY2() - gp2.getY2()) <= threshold);
}
|
[
"public",
"static",
"boolean",
"isOnSameLine",
"(",
"Area",
"a1",
",",
"Area",
"a2",
",",
"int",
"threshold",
")",
"{",
"final",
"Rectangular",
"gp1",
"=",
"a1",
".",
"getBounds",
"(",
")",
";",
"final",
"Rectangular",
"gp2",
"=",
"a2",
".",
"getBounds",
"(",
")",
";",
"return",
"(",
"Math",
".",
"abs",
"(",
"gp1",
".",
"getY1",
"(",
")",
"-",
"gp2",
".",
"getY1",
"(",
")",
")",
"<=",
"threshold",
"&&",
"Math",
".",
"abs",
"(",
"gp1",
".",
"getY2",
"(",
")",
"-",
"gp2",
".",
"getY2",
"(",
")",
")",
"<=",
"threshold",
")",
";",
"}"
] |
Checks if the given areas are on the same line.
@param a1
@param a2
@return
|
[
"Checks",
"if",
"the",
"given",
"areas",
"are",
"on",
"the",
"same",
"line",
"."
] |
12998087d576640c2f2a6360cf6088af95eea5f4
|
https://github.com/FitLayout/segmentation/blob/12998087d576640c2f2a6360cf6088af95eea5f4/src/main/java/org/fit/segm/grouping/AreaUtils.java#L59-L65
|
155,005
|
FitLayout/segmentation
|
src/main/java/org/fit/segm/grouping/op/SeparatorSet.java
|
SeparatorSet.isSeparatorAt
|
public boolean isSeparatorAt(int x, int y)
{
return containsSeparatorAt(x, y, bsep) ||
containsSeparatorAt(x, y, hsep) ||
containsSeparatorAt(x, y, vsep);
}
|
java
|
public boolean isSeparatorAt(int x, int y)
{
return containsSeparatorAt(x, y, bsep) ||
containsSeparatorAt(x, y, hsep) ||
containsSeparatorAt(x, y, vsep);
}
|
[
"public",
"boolean",
"isSeparatorAt",
"(",
"int",
"x",
",",
"int",
"y",
")",
"{",
"return",
"containsSeparatorAt",
"(",
"x",
",",
"y",
",",
"bsep",
")",
"||",
"containsSeparatorAt",
"(",
"x",
",",
"y",
",",
"hsep",
")",
"||",
"containsSeparatorAt",
"(",
"x",
",",
"y",
",",
"vsep",
")",
";",
"}"
] |
Checks if a point is covered by a separator.
@param x the point x coordinate
@param y the point y coordinate
@return <code>true</code> if any of the separators in this set covers the specified point
|
[
"Checks",
"if",
"a",
"point",
"is",
"covered",
"by",
"a",
"separator",
"."
] |
12998087d576640c2f2a6360cf6088af95eea5f4
|
https://github.com/FitLayout/segmentation/blob/12998087d576640c2f2a6360cf6088af95eea5f4/src/main/java/org/fit/segm/grouping/op/SeparatorSet.java#L131-L136
|
155,006
|
FitLayout/segmentation
|
src/main/java/org/fit/segm/grouping/op/SeparatorSet.java
|
SeparatorSet.filterMarginalSeparators
|
protected void filterMarginalSeparators()
{
for (Iterator<Separator> it = hsep.iterator(); it.hasNext();)
{
Separator sep = it.next();
if (sep.getY1() == root.getY1() || sep.getY2() == root.getY2())
it.remove();
}
for (Iterator<Separator> it = vsep.iterator(); it.hasNext();)
{
Separator sep = it.next();
if (sep.getX1() == root.getX1() || sep.getX2() == root.getX2())
it.remove();
}
}
|
java
|
protected void filterMarginalSeparators()
{
for (Iterator<Separator> it = hsep.iterator(); it.hasNext();)
{
Separator sep = it.next();
if (sep.getY1() == root.getY1() || sep.getY2() == root.getY2())
it.remove();
}
for (Iterator<Separator> it = vsep.iterator(); it.hasNext();)
{
Separator sep = it.next();
if (sep.getX1() == root.getX1() || sep.getX2() == root.getX2())
it.remove();
}
}
|
[
"protected",
"void",
"filterMarginalSeparators",
"(",
")",
"{",
"for",
"(",
"Iterator",
"<",
"Separator",
">",
"it",
"=",
"hsep",
".",
"iterator",
"(",
")",
";",
"it",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"Separator",
"sep",
"=",
"it",
".",
"next",
"(",
")",
";",
"if",
"(",
"sep",
".",
"getY1",
"(",
")",
"==",
"root",
".",
"getY1",
"(",
")",
"||",
"sep",
".",
"getY2",
"(",
")",
"==",
"root",
".",
"getY2",
"(",
")",
")",
"it",
".",
"remove",
"(",
")",
";",
"}",
"for",
"(",
"Iterator",
"<",
"Separator",
">",
"it",
"=",
"vsep",
".",
"iterator",
"(",
")",
";",
"it",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"Separator",
"sep",
"=",
"it",
".",
"next",
"(",
")",
";",
"if",
"(",
"sep",
".",
"getX1",
"(",
")",
"==",
"root",
".",
"getX1",
"(",
")",
"||",
"sep",
".",
"getX2",
"(",
")",
"==",
"root",
".",
"getX2",
"(",
")",
")",
"it",
".",
"remove",
"(",
")",
";",
"}",
"}"
] |
Removes the separators that are placed on the area borders.
|
[
"Removes",
"the",
"separators",
"that",
"are",
"placed",
"on",
"the",
"area",
"borders",
"."
] |
12998087d576640c2f2a6360cf6088af95eea5f4
|
https://github.com/FitLayout/segmentation/blob/12998087d576640c2f2a6360cf6088af95eea5f4/src/main/java/org/fit/segm/grouping/op/SeparatorSet.java#L189-L203
|
155,007
|
FitLayout/segmentation
|
src/main/java/org/fit/segm/grouping/op/SeparatorSet.java
|
SeparatorSet.filterSeparators
|
protected void filterSeparators()
{
/*int hthreshold = (int) (root.getArea().getDeclaredFontSize() * HSEP_MIN_HEIGHT);
int vthreshold = (int) (root.getArea().getDeclaredFontSize() * VSEP_MIN_WIDTH);*/
int hthreshold = getMinHSepHeight();
int vthreshold = getMinVSepWidth();
for (Iterator<Separator> it = hsep.iterator(); it.hasNext();)
{
Separator sep = it.next();
//Adaptive height threshold: use the font size of the box above the separator for determining the em size for the threshold
AreaImpl above = root.findContentAbove(sep);
if (above != null)
hthreshold = (int) (above.getFontSize() * HSEP_MIN_HEIGHT);
else
hthreshold = (int) (root.getFontSize() * HSEP_MIN_HEIGHT);
//System.out.println("For: " + sep + " limit " + hthreshold + " area " + above);
if (sep.getWeight() < hthreshold)
it.remove();
//System.out.println("removed");
else if (sep.getWidth() / (double) sep.getHeight() < SEP_MIN_RATIO)
it.remove();
}
for (Iterator<Separator> it = vsep.iterator(); it.hasNext();)
{
Separator sep = it.next();
if (sep.getWeight() < vthreshold)
it.remove();
else if (sep.getHeight() / (double) sep.getWidth() < SEP_MIN_RATIO)
it.remove();
}
}
|
java
|
protected void filterSeparators()
{
/*int hthreshold = (int) (root.getArea().getDeclaredFontSize() * HSEP_MIN_HEIGHT);
int vthreshold = (int) (root.getArea().getDeclaredFontSize() * VSEP_MIN_WIDTH);*/
int hthreshold = getMinHSepHeight();
int vthreshold = getMinVSepWidth();
for (Iterator<Separator> it = hsep.iterator(); it.hasNext();)
{
Separator sep = it.next();
//Adaptive height threshold: use the font size of the box above the separator for determining the em size for the threshold
AreaImpl above = root.findContentAbove(sep);
if (above != null)
hthreshold = (int) (above.getFontSize() * HSEP_MIN_HEIGHT);
else
hthreshold = (int) (root.getFontSize() * HSEP_MIN_HEIGHT);
//System.out.println("For: " + sep + " limit " + hthreshold + " area " + above);
if (sep.getWeight() < hthreshold)
it.remove();
//System.out.println("removed");
else if (sep.getWidth() / (double) sep.getHeight() < SEP_MIN_RATIO)
it.remove();
}
for (Iterator<Separator> it = vsep.iterator(); it.hasNext();)
{
Separator sep = it.next();
if (sep.getWeight() < vthreshold)
it.remove();
else if (sep.getHeight() / (double) sep.getWidth() < SEP_MIN_RATIO)
it.remove();
}
}
|
[
"protected",
"void",
"filterSeparators",
"(",
")",
"{",
"/*int hthreshold = (int) (root.getArea().getDeclaredFontSize() * HSEP_MIN_HEIGHT);\n int vthreshold = (int) (root.getArea().getDeclaredFontSize() * VSEP_MIN_WIDTH);*/",
"int",
"hthreshold",
"=",
"getMinHSepHeight",
"(",
")",
";",
"int",
"vthreshold",
"=",
"getMinVSepWidth",
"(",
")",
";",
"for",
"(",
"Iterator",
"<",
"Separator",
">",
"it",
"=",
"hsep",
".",
"iterator",
"(",
")",
";",
"it",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"Separator",
"sep",
"=",
"it",
".",
"next",
"(",
")",
";",
"//Adaptive height threshold: use the font size of the box above the separator for determining the em size for the threshold ",
"AreaImpl",
"above",
"=",
"root",
".",
"findContentAbove",
"(",
"sep",
")",
";",
"if",
"(",
"above",
"!=",
"null",
")",
"hthreshold",
"=",
"(",
"int",
")",
"(",
"above",
".",
"getFontSize",
"(",
")",
"*",
"HSEP_MIN_HEIGHT",
")",
";",
"else",
"hthreshold",
"=",
"(",
"int",
")",
"(",
"root",
".",
"getFontSize",
"(",
")",
"*",
"HSEP_MIN_HEIGHT",
")",
";",
"//System.out.println(\"For: \" + sep + \" limit \" + hthreshold + \" area \" + above);",
"if",
"(",
"sep",
".",
"getWeight",
"(",
")",
"<",
"hthreshold",
")",
"it",
".",
"remove",
"(",
")",
";",
"//System.out.println(\"removed\");",
"else",
"if",
"(",
"sep",
".",
"getWidth",
"(",
")",
"/",
"(",
"double",
")",
"sep",
".",
"getHeight",
"(",
")",
"<",
"SEP_MIN_RATIO",
")",
"it",
".",
"remove",
"(",
")",
";",
"}",
"for",
"(",
"Iterator",
"<",
"Separator",
">",
"it",
"=",
"vsep",
".",
"iterator",
"(",
")",
";",
"it",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"Separator",
"sep",
"=",
"it",
".",
"next",
"(",
")",
";",
"if",
"(",
"sep",
".",
"getWeight",
"(",
")",
"<",
"vthreshold",
")",
"it",
".",
"remove",
"(",
")",
";",
"else",
"if",
"(",
"sep",
".",
"getHeight",
"(",
")",
"/",
"(",
"double",
")",
"sep",
".",
"getWidth",
"(",
")",
"<",
"SEP_MIN_RATIO",
")",
"it",
".",
"remove",
"(",
")",
";",
"}",
"}"
] |
Removes all the separators where the weight is lower than the specified threshold.
|
[
"Removes",
"all",
"the",
"separators",
"where",
"the",
"weight",
"is",
"lower",
"than",
"the",
"specified",
"threshold",
"."
] |
12998087d576640c2f2a6360cf6088af95eea5f4
|
https://github.com/FitLayout/segmentation/blob/12998087d576640c2f2a6360cf6088af95eea5f4/src/main/java/org/fit/segm/grouping/op/SeparatorSet.java#L208-L240
|
155,008
|
FitLayout/segmentation
|
src/main/java/org/fit/segm/grouping/op/SeparatorSet.java
|
SeparatorSet.processIntersectionsSplitHorizontal
|
protected void processIntersectionsSplitHorizontal()
{
boolean change;
do
{
Vector<Separator> newsep = new Vector<Separator>(hsep.size());
change = false;
for (Separator hs : hsep)
{
boolean split = false;
for (Separator vs : vsep)
{
if (hs.intersects(vs))
{
Separator nhs = hs.hsplit(vs);
newsep.add(hs);
if (nhs != null)
newsep.add(nhs);
split = true;
change = true;
break; //do not try other vertical seps
}
}
if (!split)
newsep.add(hs);
}
hsep = newsep;
} while (change);
}
|
java
|
protected void processIntersectionsSplitHorizontal()
{
boolean change;
do
{
Vector<Separator> newsep = new Vector<Separator>(hsep.size());
change = false;
for (Separator hs : hsep)
{
boolean split = false;
for (Separator vs : vsep)
{
if (hs.intersects(vs))
{
Separator nhs = hs.hsplit(vs);
newsep.add(hs);
if (nhs != null)
newsep.add(nhs);
split = true;
change = true;
break; //do not try other vertical seps
}
}
if (!split)
newsep.add(hs);
}
hsep = newsep;
} while (change);
}
|
[
"protected",
"void",
"processIntersectionsSplitHorizontal",
"(",
")",
"{",
"boolean",
"change",
";",
"do",
"{",
"Vector",
"<",
"Separator",
">",
"newsep",
"=",
"new",
"Vector",
"<",
"Separator",
">",
"(",
"hsep",
".",
"size",
"(",
")",
")",
";",
"change",
"=",
"false",
";",
"for",
"(",
"Separator",
"hs",
":",
"hsep",
")",
"{",
"boolean",
"split",
"=",
"false",
";",
"for",
"(",
"Separator",
"vs",
":",
"vsep",
")",
"{",
"if",
"(",
"hs",
".",
"intersects",
"(",
"vs",
")",
")",
"{",
"Separator",
"nhs",
"=",
"hs",
".",
"hsplit",
"(",
"vs",
")",
";",
"newsep",
".",
"add",
"(",
"hs",
")",
";",
"if",
"(",
"nhs",
"!=",
"null",
")",
"newsep",
".",
"add",
"(",
"nhs",
")",
";",
"split",
"=",
"true",
";",
"change",
"=",
"true",
";",
"break",
";",
"//do not try other vertical seps",
"}",
"}",
"if",
"(",
"!",
"split",
")",
"newsep",
".",
"add",
"(",
"hs",
")",
";",
"}",
"hsep",
"=",
"newsep",
";",
"}",
"while",
"(",
"change",
")",
";",
"}"
] |
Processes the separators so that they do not intersect.
The vertical separators are left untouched, the horizontal separators are
split by the vertical ones when necessary.
|
[
"Processes",
"the",
"separators",
"so",
"that",
"they",
"do",
"not",
"intersect",
".",
"The",
"vertical",
"separators",
"are",
"left",
"untouched",
"the",
"horizontal",
"separators",
"are",
"split",
"by",
"the",
"vertical",
"ones",
"when",
"necessary",
"."
] |
12998087d576640c2f2a6360cf6088af95eea5f4
|
https://github.com/FitLayout/segmentation/blob/12998087d576640c2f2a6360cf6088af95eea5f4/src/main/java/org/fit/segm/grouping/op/SeparatorSet.java#L255-L283
|
155,009
|
FitLayout/segmentation
|
src/main/java/org/fit/segm/grouping/op/SeparatorSet.java
|
SeparatorSet.processIntersectionsRemoveHorizontal
|
protected void processIntersectionsRemoveHorizontal()
{
for (Iterator<Separator> hit = hsep.iterator(); hit.hasNext(); )
{
Separator hs = hit.next();
for (Separator vs : vsep)
{
if (hs.intersects(vs))
{
hit.remove();
break;
}
}
}
}
|
java
|
protected void processIntersectionsRemoveHorizontal()
{
for (Iterator<Separator> hit = hsep.iterator(); hit.hasNext(); )
{
Separator hs = hit.next();
for (Separator vs : vsep)
{
if (hs.intersects(vs))
{
hit.remove();
break;
}
}
}
}
|
[
"protected",
"void",
"processIntersectionsRemoveHorizontal",
"(",
")",
"{",
"for",
"(",
"Iterator",
"<",
"Separator",
">",
"hit",
"=",
"hsep",
".",
"iterator",
"(",
")",
";",
"hit",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"Separator",
"hs",
"=",
"hit",
".",
"next",
"(",
")",
";",
"for",
"(",
"Separator",
"vs",
":",
"vsep",
")",
"{",
"if",
"(",
"hs",
".",
"intersects",
"(",
"vs",
")",
")",
"{",
"hit",
".",
"remove",
"(",
")",
";",
"break",
";",
"}",
"}",
"}",
"}"
] |
Processes the separators so that they do not intersect.
The vertical separators are left untouched, the horizontal separators are
removed when they intersect with a vertical one.
|
[
"Processes",
"the",
"separators",
"so",
"that",
"they",
"do",
"not",
"intersect",
".",
"The",
"vertical",
"separators",
"are",
"left",
"untouched",
"the",
"horizontal",
"separators",
"are",
"removed",
"when",
"they",
"intersect",
"with",
"a",
"vertical",
"one",
"."
] |
12998087d576640c2f2a6360cf6088af95eea5f4
|
https://github.com/FitLayout/segmentation/blob/12998087d576640c2f2a6360cf6088af95eea5f4/src/main/java/org/fit/segm/grouping/op/SeparatorSet.java#L290-L304
|
155,010
|
FitLayout/segmentation
|
src/main/java/org/fit/segm/grouping/op/SeparatorSet.java
|
SeparatorSet.findAreaSeparators
|
private void findAreaSeparators(AreaImpl root)
{
bsep = new Vector<Separator>();
for (int i = 0; i < root.getChildCount(); i++)
{
Area child = root.getChildAt(i);
if (child instanceof AreaImpl)
analyzeAreaSeparators((AreaImpl) child);
}
}
|
java
|
private void findAreaSeparators(AreaImpl root)
{
bsep = new Vector<Separator>();
for (int i = 0; i < root.getChildCount(); i++)
{
Area child = root.getChildAt(i);
if (child instanceof AreaImpl)
analyzeAreaSeparators((AreaImpl) child);
}
}
|
[
"private",
"void",
"findAreaSeparators",
"(",
"AreaImpl",
"root",
")",
"{",
"bsep",
"=",
"new",
"Vector",
"<",
"Separator",
">",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"root",
".",
"getChildCount",
"(",
")",
";",
"i",
"++",
")",
"{",
"Area",
"child",
"=",
"root",
".",
"getChildAt",
"(",
"i",
")",
";",
"if",
"(",
"child",
"instanceof",
"AreaImpl",
")",
"analyzeAreaSeparators",
"(",
"(",
"AreaImpl",
")",
"child",
")",
";",
"}",
"}"
] |
Creates a list of separators that are implemented as visual area borders.
|
[
"Creates",
"a",
"list",
"of",
"separators",
"that",
"are",
"implemented",
"as",
"visual",
"area",
"borders",
"."
] |
12998087d576640c2f2a6360cf6088af95eea5f4
|
https://github.com/FitLayout/segmentation/blob/12998087d576640c2f2a6360cf6088af95eea5f4/src/main/java/org/fit/segm/grouping/op/SeparatorSet.java#L318-L327
|
155,011
|
FitLayout/segmentation
|
src/main/java/org/fit/segm/grouping/op/SeparatorSet.java
|
SeparatorSet.analyzeAreaSeparators
|
private void analyzeAreaSeparators(AreaImpl area)
{
boolean isep = area.isExplicitlySeparated() || area.isBackgroundSeparated();
if (isep || area.separatedUp())
bsep.add(new Separator(Separator.BOXH,
area.getX1(), area.getY1(), area.getX2(), area.getY1() + ART_SEP_WIDTH - 1));
if (isep || area.separatedDown())
bsep.add(new Separator(Separator.BOXH,
area.getX1(), area.getY2() - ART_SEP_WIDTH + 1, area.getX2(), area.getY2()));
if (isep || area.separatedLeft())
bsep.add(new Separator(Separator.BOXV,
area.getX1(), area.getY1(), area.getX1() + ART_SEP_WIDTH - 1, area.getY2()));
if (isep || area.separatedRight())
bsep.add(new Separator(Separator.BOXV,
area.getX2() - ART_SEP_WIDTH + 1, area.getY1(), area.getX2(), area.getY2()));
}
|
java
|
private void analyzeAreaSeparators(AreaImpl area)
{
boolean isep = area.isExplicitlySeparated() || area.isBackgroundSeparated();
if (isep || area.separatedUp())
bsep.add(new Separator(Separator.BOXH,
area.getX1(), area.getY1(), area.getX2(), area.getY1() + ART_SEP_WIDTH - 1));
if (isep || area.separatedDown())
bsep.add(new Separator(Separator.BOXH,
area.getX1(), area.getY2() - ART_SEP_WIDTH + 1, area.getX2(), area.getY2()));
if (isep || area.separatedLeft())
bsep.add(new Separator(Separator.BOXV,
area.getX1(), area.getY1(), area.getX1() + ART_SEP_WIDTH - 1, area.getY2()));
if (isep || area.separatedRight())
bsep.add(new Separator(Separator.BOXV,
area.getX2() - ART_SEP_WIDTH + 1, area.getY1(), area.getX2(), area.getY2()));
}
|
[
"private",
"void",
"analyzeAreaSeparators",
"(",
"AreaImpl",
"area",
")",
"{",
"boolean",
"isep",
"=",
"area",
".",
"isExplicitlySeparated",
"(",
")",
"||",
"area",
".",
"isBackgroundSeparated",
"(",
")",
";",
"if",
"(",
"isep",
"||",
"area",
".",
"separatedUp",
"(",
")",
")",
"bsep",
".",
"add",
"(",
"new",
"Separator",
"(",
"Separator",
".",
"BOXH",
",",
"area",
".",
"getX1",
"(",
")",
",",
"area",
".",
"getY1",
"(",
")",
",",
"area",
".",
"getX2",
"(",
")",
",",
"area",
".",
"getY1",
"(",
")",
"+",
"ART_SEP_WIDTH",
"-",
"1",
")",
")",
";",
"if",
"(",
"isep",
"||",
"area",
".",
"separatedDown",
"(",
")",
")",
"bsep",
".",
"add",
"(",
"new",
"Separator",
"(",
"Separator",
".",
"BOXH",
",",
"area",
".",
"getX1",
"(",
")",
",",
"area",
".",
"getY2",
"(",
")",
"-",
"ART_SEP_WIDTH",
"+",
"1",
",",
"area",
".",
"getX2",
"(",
")",
",",
"area",
".",
"getY2",
"(",
")",
")",
")",
";",
"if",
"(",
"isep",
"||",
"area",
".",
"separatedLeft",
"(",
")",
")",
"bsep",
".",
"add",
"(",
"new",
"Separator",
"(",
"Separator",
".",
"BOXV",
",",
"area",
".",
"getX1",
"(",
")",
",",
"area",
".",
"getY1",
"(",
")",
",",
"area",
".",
"getX1",
"(",
")",
"+",
"ART_SEP_WIDTH",
"-",
"1",
",",
"area",
".",
"getY2",
"(",
")",
")",
")",
";",
"if",
"(",
"isep",
"||",
"area",
".",
"separatedRight",
"(",
")",
")",
"bsep",
".",
"add",
"(",
"new",
"Separator",
"(",
"Separator",
".",
"BOXV",
",",
"area",
".",
"getX2",
"(",
")",
"-",
"ART_SEP_WIDTH",
"+",
"1",
",",
"area",
".",
"getY1",
"(",
")",
",",
"area",
".",
"getX2",
"(",
")",
",",
"area",
".",
"getY2",
"(",
")",
")",
")",
";",
"}"
] |
Analyzes the area and detects the separators that are implemented as borders
or background changes.
|
[
"Analyzes",
"the",
"area",
"and",
"detects",
"the",
"separators",
"that",
"are",
"implemented",
"as",
"borders",
"or",
"background",
"changes",
"."
] |
12998087d576640c2f2a6360cf6088af95eea5f4
|
https://github.com/FitLayout/segmentation/blob/12998087d576640c2f2a6360cf6088af95eea5f4/src/main/java/org/fit/segm/grouping/op/SeparatorSet.java#L333-L348
|
155,012
|
FitLayout/segmentation
|
src/main/java/org/fit/segm/grouping/SegmentationAreaTree.java
|
SegmentationAreaTree.findBasicAreas
|
public Area findBasicAreas()
{
AreaImpl rootarea = new AreaImpl(0, 0, 0, 0);
setRoot(rootarea);
rootarea.setAreaTree(this);
rootarea.setPage(page);
for (int i = 0; i < page.getRoot().getChildCount(); i++)
{
Box cbox = page.getRoot().getChildAt(i);
Area sub = new AreaImpl(cbox);
if (sub.getWidth() > 1 || sub.getHeight() > 1)
{
findStandaloneAreas(page.getRoot().getChildAt(i), sub);
rootarea.appendChild(sub);
}
}
createGrids(rootarea);
return rootarea;
}
|
java
|
public Area findBasicAreas()
{
AreaImpl rootarea = new AreaImpl(0, 0, 0, 0);
setRoot(rootarea);
rootarea.setAreaTree(this);
rootarea.setPage(page);
for (int i = 0; i < page.getRoot().getChildCount(); i++)
{
Box cbox = page.getRoot().getChildAt(i);
Area sub = new AreaImpl(cbox);
if (sub.getWidth() > 1 || sub.getHeight() > 1)
{
findStandaloneAreas(page.getRoot().getChildAt(i), sub);
rootarea.appendChild(sub);
}
}
createGrids(rootarea);
return rootarea;
}
|
[
"public",
"Area",
"findBasicAreas",
"(",
")",
"{",
"AreaImpl",
"rootarea",
"=",
"new",
"AreaImpl",
"(",
"0",
",",
"0",
",",
"0",
",",
"0",
")",
";",
"setRoot",
"(",
"rootarea",
")",
";",
"rootarea",
".",
"setAreaTree",
"(",
"this",
")",
";",
"rootarea",
".",
"setPage",
"(",
"page",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"page",
".",
"getRoot",
"(",
")",
".",
"getChildCount",
"(",
")",
";",
"i",
"++",
")",
"{",
"Box",
"cbox",
"=",
"page",
".",
"getRoot",
"(",
")",
".",
"getChildAt",
"(",
"i",
")",
";",
"Area",
"sub",
"=",
"new",
"AreaImpl",
"(",
"cbox",
")",
";",
"if",
"(",
"sub",
".",
"getWidth",
"(",
")",
">",
"1",
"||",
"sub",
".",
"getHeight",
"(",
")",
">",
"1",
")",
"{",
"findStandaloneAreas",
"(",
"page",
".",
"getRoot",
"(",
")",
".",
"getChildAt",
"(",
"i",
")",
",",
"sub",
")",
";",
"rootarea",
".",
"appendChild",
"(",
"sub",
")",
";",
"}",
"}",
"createGrids",
"(",
"rootarea",
")",
";",
"return",
"rootarea",
";",
"}"
] |
Creates the area tree skeleton - selects the visible boxes and converts
them to areas
|
[
"Creates",
"the",
"area",
"tree",
"skeleton",
"-",
"selects",
"the",
"visible",
"boxes",
"and",
"converts",
"them",
"to",
"areas"
] |
12998087d576640c2f2a6360cf6088af95eea5f4
|
https://github.com/FitLayout/segmentation/blob/12998087d576640c2f2a6360cf6088af95eea5f4/src/main/java/org/fit/segm/grouping/SegmentationAreaTree.java#L52-L70
|
155,013
|
FitLayout/segmentation
|
src/main/java/org/fit/segm/grouping/SegmentationAreaTree.java
|
SegmentationAreaTree.findStandaloneAreas
|
private void findStandaloneAreas(Box boxroot, Area arearoot)
{
if (boxroot.isVisible())
{
for (int i = 0; i < boxroot.getChildCount(); i++)
{
Box child = boxroot.getChildAt(i);
if (child.isVisible())
{
if (isVisuallySeparated(child))
{
Area newnode = new AreaImpl(child);
if (newnode.getWidth() > 1 || newnode.getHeight() > 1)
{
findStandaloneAreas(child, newnode);
arearoot.appendChild(newnode);
}
}
else
findStandaloneAreas(child, arearoot);
}
}
}
}
|
java
|
private void findStandaloneAreas(Box boxroot, Area arearoot)
{
if (boxroot.isVisible())
{
for (int i = 0; i < boxroot.getChildCount(); i++)
{
Box child = boxroot.getChildAt(i);
if (child.isVisible())
{
if (isVisuallySeparated(child))
{
Area newnode = new AreaImpl(child);
if (newnode.getWidth() > 1 || newnode.getHeight() > 1)
{
findStandaloneAreas(child, newnode);
arearoot.appendChild(newnode);
}
}
else
findStandaloneAreas(child, arearoot);
}
}
}
}
|
[
"private",
"void",
"findStandaloneAreas",
"(",
"Box",
"boxroot",
",",
"Area",
"arearoot",
")",
"{",
"if",
"(",
"boxroot",
".",
"isVisible",
"(",
")",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"boxroot",
".",
"getChildCount",
"(",
")",
";",
"i",
"++",
")",
"{",
"Box",
"child",
"=",
"boxroot",
".",
"getChildAt",
"(",
"i",
")",
";",
"if",
"(",
"child",
".",
"isVisible",
"(",
")",
")",
"{",
"if",
"(",
"isVisuallySeparated",
"(",
"child",
")",
")",
"{",
"Area",
"newnode",
"=",
"new",
"AreaImpl",
"(",
"child",
")",
";",
"if",
"(",
"newnode",
".",
"getWidth",
"(",
")",
">",
"1",
"||",
"newnode",
".",
"getHeight",
"(",
")",
">",
"1",
")",
"{",
"findStandaloneAreas",
"(",
"child",
",",
"newnode",
")",
";",
"arearoot",
".",
"appendChild",
"(",
"newnode",
")",
";",
"}",
"}",
"else",
"findStandaloneAreas",
"(",
"child",
",",
"arearoot",
")",
";",
"}",
"}",
"}",
"}"
] |
Goes through a box tree and tries to identify the boxes that form standalone
visual areas. From these boxes, new areas are created, which are added to the
area tree. Other boxes are ignored.
@param boxroot the root of the box tree
@param arearoot the root node of the new area tree
|
[
"Goes",
"through",
"a",
"box",
"tree",
"and",
"tries",
"to",
"identify",
"the",
"boxes",
"that",
"form",
"standalone",
"visual",
"areas",
".",
"From",
"these",
"boxes",
"new",
"areas",
"are",
"created",
"which",
"are",
"added",
"to",
"the",
"area",
"tree",
".",
"Other",
"boxes",
"are",
"ignored",
"."
] |
12998087d576640c2f2a6360cf6088af95eea5f4
|
https://github.com/FitLayout/segmentation/blob/12998087d576640c2f2a6360cf6088af95eea5f4/src/main/java/org/fit/segm/grouping/SegmentationAreaTree.java#L103-L126
|
155,014
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/util/lang/CodeUtil.java
|
CodeUtil.getIndent
|
@javax.annotation.Nonnull
public static String getIndent(@javax.annotation.Nonnull final String txt) {
@javax.annotation.Nonnull final Matcher matcher = Pattern.compile("^\\s+").matcher(txt);
return matcher.find() ? matcher.group(0) : "";
}
|
java
|
@javax.annotation.Nonnull
public static String getIndent(@javax.annotation.Nonnull final String txt) {
@javax.annotation.Nonnull final Matcher matcher = Pattern.compile("^\\s+").matcher(txt);
return matcher.find() ? matcher.group(0) : "";
}
|
[
"@",
"javax",
".",
"annotation",
".",
"Nonnull",
"public",
"static",
"String",
"getIndent",
"(",
"@",
"javax",
".",
"annotation",
".",
"Nonnull",
"final",
"String",
"txt",
")",
"{",
"@",
"javax",
".",
"annotation",
".",
"Nonnull",
"final",
"Matcher",
"matcher",
"=",
"Pattern",
".",
"compile",
"(",
"\"^\\\\s+\"",
")",
".",
"matcher",
"(",
"txt",
")",
";",
"return",
"matcher",
".",
"find",
"(",
")",
"?",
"matcher",
".",
"group",
"(",
"0",
")",
":",
"\"\"",
";",
"}"
] |
Gets indent.
@param txt the txt
@return the indent
|
[
"Gets",
"indent",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/lang/CodeUtil.java#L101-L105
|
155,015
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/util/lang/CodeUtil.java
|
CodeUtil.getInnerText
|
public static String getInnerText(@javax.annotation.Nonnull final StackTraceElement callingFrame) throws IOException {
try {
@javax.annotation.Nonnull final File file = com.simiacryptus.util.lang.CodeUtil.findFile(callingFrame);
assert null != file;
final int start = callingFrame.getLineNumber() - 1;
final List<String> allLines = Files.readAllLines(file.toPath());
final String txt = allLines.get(start);
@javax.annotation.Nonnull final String indent = com.simiacryptus.util.lang.CodeUtil.getIndent(txt);
@javax.annotation.Nonnull final ArrayList<String> lines = new ArrayList<>();
for (int i = start + 1; i < allLines.size() && (com.simiacryptus.util.lang.CodeUtil.getIndent(allLines.get(i)).length() > indent.length() || allLines.get(i).trim().isEmpty()); i++) {
final String line = allLines.get(i);
lines.add(line.substring(Math.min(indent.length(), line.length())));
}
return lines.stream().collect(Collectors.joining("\n"));
} catch (@javax.annotation.Nonnull final Throwable e) {
return "";
}
}
|
java
|
public static String getInnerText(@javax.annotation.Nonnull final StackTraceElement callingFrame) throws IOException {
try {
@javax.annotation.Nonnull final File file = com.simiacryptus.util.lang.CodeUtil.findFile(callingFrame);
assert null != file;
final int start = callingFrame.getLineNumber() - 1;
final List<String> allLines = Files.readAllLines(file.toPath());
final String txt = allLines.get(start);
@javax.annotation.Nonnull final String indent = com.simiacryptus.util.lang.CodeUtil.getIndent(txt);
@javax.annotation.Nonnull final ArrayList<String> lines = new ArrayList<>();
for (int i = start + 1; i < allLines.size() && (com.simiacryptus.util.lang.CodeUtil.getIndent(allLines.get(i)).length() > indent.length() || allLines.get(i).trim().isEmpty()); i++) {
final String line = allLines.get(i);
lines.add(line.substring(Math.min(indent.length(), line.length())));
}
return lines.stream().collect(Collectors.joining("\n"));
} catch (@javax.annotation.Nonnull final Throwable e) {
return "";
}
}
|
[
"public",
"static",
"String",
"getInnerText",
"(",
"@",
"javax",
".",
"annotation",
".",
"Nonnull",
"final",
"StackTraceElement",
"callingFrame",
")",
"throws",
"IOException",
"{",
"try",
"{",
"@",
"javax",
".",
"annotation",
".",
"Nonnull",
"final",
"File",
"file",
"=",
"com",
".",
"simiacryptus",
".",
"util",
".",
"lang",
".",
"CodeUtil",
".",
"findFile",
"(",
"callingFrame",
")",
";",
"assert",
"null",
"!=",
"file",
";",
"final",
"int",
"start",
"=",
"callingFrame",
".",
"getLineNumber",
"(",
")",
"-",
"1",
";",
"final",
"List",
"<",
"String",
">",
"allLines",
"=",
"Files",
".",
"readAllLines",
"(",
"file",
".",
"toPath",
"(",
")",
")",
";",
"final",
"String",
"txt",
"=",
"allLines",
".",
"get",
"(",
"start",
")",
";",
"@",
"javax",
".",
"annotation",
".",
"Nonnull",
"final",
"String",
"indent",
"=",
"com",
".",
"simiacryptus",
".",
"util",
".",
"lang",
".",
"CodeUtil",
".",
"getIndent",
"(",
"txt",
")",
";",
"@",
"javax",
".",
"annotation",
".",
"Nonnull",
"final",
"ArrayList",
"<",
"String",
">",
"lines",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"start",
"+",
"1",
";",
"i",
"<",
"allLines",
".",
"size",
"(",
")",
"&&",
"(",
"com",
".",
"simiacryptus",
".",
"util",
".",
"lang",
".",
"CodeUtil",
".",
"getIndent",
"(",
"allLines",
".",
"get",
"(",
"i",
")",
")",
".",
"length",
"(",
")",
">",
"indent",
".",
"length",
"(",
")",
"||",
"allLines",
".",
"get",
"(",
"i",
")",
".",
"trim",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
";",
"i",
"++",
")",
"{",
"final",
"String",
"line",
"=",
"allLines",
".",
"get",
"(",
"i",
")",
";",
"lines",
".",
"add",
"(",
"line",
".",
"substring",
"(",
"Math",
".",
"min",
"(",
"indent",
".",
"length",
"(",
")",
",",
"line",
".",
"length",
"(",
")",
")",
")",
")",
";",
"}",
"return",
"lines",
".",
"stream",
"(",
")",
".",
"collect",
"(",
"Collectors",
".",
"joining",
"(",
"\"\\n\"",
")",
")",
";",
"}",
"catch",
"(",
"@",
"javax",
".",
"annotation",
".",
"Nonnull",
"final",
"Throwable",
"e",
")",
"{",
"return",
"\"\"",
";",
"}",
"}"
] |
Gets heapCopy text.
@param callingFrame the calling frame
@return the heapCopy text
@throws IOException the io exception
|
[
"Gets",
"heapCopy",
"text",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/lang/CodeUtil.java#L114-L131
|
155,016
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/util/lang/CodeUtil.java
|
CodeUtil.getJavadoc
|
public static String getJavadoc(@Nullable final Class<?> clazz) {
try {
if (null == clazz) return null;
@Nullable final File source = com.simiacryptus.util.lang.CodeUtil.findFile(clazz);
if (null == source) return clazz.getName() + " not found";
final List<String> lines = IOUtils.readLines(new FileInputStream(source), Charset.forName("UTF-8"));
final int classDeclarationLine = IntStream.range(0, lines.size())
.filter(i -> lines.get(i).contains("class " + clazz.getSimpleName())).findFirst().getAsInt();
final int firstLine = IntStream.rangeClosed(1, classDeclarationLine).map(i -> classDeclarationLine - i)
.filter(i -> !lines.get(i).matches("\\s*[/\\*@].*")).findFirst().orElse(-1) + 1;
final String javadoc = lines.subList(firstLine, classDeclarationLine).stream()
.filter(s -> s.matches("\\s*[/\\*].*"))
.map(s -> s.replaceFirst("^[ \t]*[/\\*]+", "").trim())
.filter(x -> !x.isEmpty()).reduce((a, b) -> a + "\n" + b).orElse("");
return javadoc.replaceAll("<p>", "\n");
} catch (@javax.annotation.Nonnull final Throwable e) {
e.printStackTrace();
return "";
}
}
|
java
|
public static String getJavadoc(@Nullable final Class<?> clazz) {
try {
if (null == clazz) return null;
@Nullable final File source = com.simiacryptus.util.lang.CodeUtil.findFile(clazz);
if (null == source) return clazz.getName() + " not found";
final List<String> lines = IOUtils.readLines(new FileInputStream(source), Charset.forName("UTF-8"));
final int classDeclarationLine = IntStream.range(0, lines.size())
.filter(i -> lines.get(i).contains("class " + clazz.getSimpleName())).findFirst().getAsInt();
final int firstLine = IntStream.rangeClosed(1, classDeclarationLine).map(i -> classDeclarationLine - i)
.filter(i -> !lines.get(i).matches("\\s*[/\\*@].*")).findFirst().orElse(-1) + 1;
final String javadoc = lines.subList(firstLine, classDeclarationLine).stream()
.filter(s -> s.matches("\\s*[/\\*].*"))
.map(s -> s.replaceFirst("^[ \t]*[/\\*]+", "").trim())
.filter(x -> !x.isEmpty()).reduce((a, b) -> a + "\n" + b).orElse("");
return javadoc.replaceAll("<p>", "\n");
} catch (@javax.annotation.Nonnull final Throwable e) {
e.printStackTrace();
return "";
}
}
|
[
"public",
"static",
"String",
"getJavadoc",
"(",
"@",
"Nullable",
"final",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"try",
"{",
"if",
"(",
"null",
"==",
"clazz",
")",
"return",
"null",
";",
"@",
"Nullable",
"final",
"File",
"source",
"=",
"com",
".",
"simiacryptus",
".",
"util",
".",
"lang",
".",
"CodeUtil",
".",
"findFile",
"(",
"clazz",
")",
";",
"if",
"(",
"null",
"==",
"source",
")",
"return",
"clazz",
".",
"getName",
"(",
")",
"+",
"\" not found\"",
";",
"final",
"List",
"<",
"String",
">",
"lines",
"=",
"IOUtils",
".",
"readLines",
"(",
"new",
"FileInputStream",
"(",
"source",
")",
",",
"Charset",
".",
"forName",
"(",
"\"UTF-8\"",
")",
")",
";",
"final",
"int",
"classDeclarationLine",
"=",
"IntStream",
".",
"range",
"(",
"0",
",",
"lines",
".",
"size",
"(",
")",
")",
".",
"filter",
"(",
"i",
"->",
"lines",
".",
"get",
"(",
"i",
")",
".",
"contains",
"(",
"\"class \"",
"+",
"clazz",
".",
"getSimpleName",
"(",
")",
")",
")",
".",
"findFirst",
"(",
")",
".",
"getAsInt",
"(",
")",
";",
"final",
"int",
"firstLine",
"=",
"IntStream",
".",
"rangeClosed",
"(",
"1",
",",
"classDeclarationLine",
")",
".",
"map",
"(",
"i",
"->",
"classDeclarationLine",
"-",
"i",
")",
".",
"filter",
"(",
"i",
"->",
"!",
"lines",
".",
"get",
"(",
"i",
")",
".",
"matches",
"(",
"\"\\\\s*[/\\\\*@].*\"",
")",
")",
".",
"findFirst",
"(",
")",
".",
"orElse",
"(",
"-",
"1",
")",
"+",
"1",
";",
"final",
"String",
"javadoc",
"=",
"lines",
".",
"subList",
"(",
"firstLine",
",",
"classDeclarationLine",
")",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"s",
"->",
"s",
".",
"matches",
"(",
"\"\\\\s*[/\\\\*].*\"",
")",
")",
".",
"map",
"(",
"s",
"->",
"s",
".",
"replaceFirst",
"(",
"\"^[ \\t]*[/\\\\*]+\"",
",",
"\"\"",
")",
".",
"trim",
"(",
")",
")",
".",
"filter",
"(",
"x",
"->",
"!",
"x",
".",
"isEmpty",
"(",
")",
")",
".",
"reduce",
"(",
"(",
"a",
",",
"b",
")",
"->",
"a",
"+",
"\"\\n\"",
"+",
"b",
")",
".",
"orElse",
"(",
"\"\"",
")",
";",
"return",
"javadoc",
".",
"replaceAll",
"(",
"\"<p>\"",
",",
"\"\\n\"",
")",
";",
"}",
"catch",
"(",
"@",
"javax",
".",
"annotation",
".",
"Nonnull",
"final",
"Throwable",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"return",
"\"\"",
";",
"}",
"}"
] |
Gets javadoc.
@param clazz the clazz
@return the javadoc
|
[
"Gets",
"javadoc",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/lang/CodeUtil.java#L139-L158
|
155,017
|
james-hu/jabb-core
|
src/main/java/net/sf/jabb/util/web/WebMenuItem.java
|
WebMenuItem.addSubItem
|
public void addSubItem(WebMenuItem item){
if (subMenu == null){
subMenu = new ArrayList<WebMenuItem>();
}
subMenu.add(item);
}
|
java
|
public void addSubItem(WebMenuItem item){
if (subMenu == null){
subMenu = new ArrayList<WebMenuItem>();
}
subMenu.add(item);
}
|
[
"public",
"void",
"addSubItem",
"(",
"WebMenuItem",
"item",
")",
"{",
"if",
"(",
"subMenu",
"==",
"null",
")",
"{",
"subMenu",
"=",
"new",
"ArrayList",
"<",
"WebMenuItem",
">",
"(",
")",
";",
"}",
"subMenu",
".",
"add",
"(",
"item",
")",
";",
"}"
] |
Add a MenuItem as the last one in its sub-menu.
@param item
|
[
"Add",
"a",
"MenuItem",
"as",
"the",
"last",
"one",
"in",
"its",
"sub",
"-",
"menu",
"."
] |
bceed441595c5e5195a7418795f03b69fa7b61e4
|
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/util/web/WebMenuItem.java#L29-L34
|
155,018
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/refer/References.java
|
References.put
|
public void put(Object locator, Object component) {
if (locator == null)
throw new NullPointerException("Locator cannot be null");
if (component == null)
throw new NullPointerException("Reference cannot be null");
synchronized (_lock) {
// Add reference to the set
_references.add(new Reference(locator, component));
}
}
|
java
|
public void put(Object locator, Object component) {
if (locator == null)
throw new NullPointerException("Locator cannot be null");
if (component == null)
throw new NullPointerException("Reference cannot be null");
synchronized (_lock) {
// Add reference to the set
_references.add(new Reference(locator, component));
}
}
|
[
"public",
"void",
"put",
"(",
"Object",
"locator",
",",
"Object",
"component",
")",
"{",
"if",
"(",
"locator",
"==",
"null",
")",
"throw",
"new",
"NullPointerException",
"(",
"\"Locator cannot be null\"",
")",
";",
"if",
"(",
"component",
"==",
"null",
")",
"throw",
"new",
"NullPointerException",
"(",
"\"Reference cannot be null\"",
")",
";",
"synchronized",
"(",
"_lock",
")",
"{",
"// Add reference to the set",
"_references",
".",
"add",
"(",
"new",
"Reference",
"(",
"locator",
",",
"component",
")",
")",
";",
"}",
"}"
] |
Puts a new reference into this reference map.
@param locator a locator to find the reference by.
@param component a component reference to be added.
|
[
"Puts",
"a",
"new",
"reference",
"into",
"this",
"reference",
"map",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/refer/References.java#L65-L75
|
155,019
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/refer/References.java
|
References.removeAll
|
public List<Object> removeAll(Object locator) {
List<Object> components = new ArrayList<Object>();
if (locator == null)
return components;
synchronized (_lock) {
for (int index = _references.size() - 1; index >= 0; index--) {
Reference reference = _references.get(index);
if (reference.match(locator)) {
_references.remove(index);
components.add(reference.getComponent());
}
}
}
return components;
}
|
java
|
public List<Object> removeAll(Object locator) {
List<Object> components = new ArrayList<Object>();
if (locator == null)
return components;
synchronized (_lock) {
for (int index = _references.size() - 1; index >= 0; index--) {
Reference reference = _references.get(index);
if (reference.match(locator)) {
_references.remove(index);
components.add(reference.getComponent());
}
}
}
return components;
}
|
[
"public",
"List",
"<",
"Object",
">",
"removeAll",
"(",
"Object",
"locator",
")",
"{",
"List",
"<",
"Object",
">",
"components",
"=",
"new",
"ArrayList",
"<",
"Object",
">",
"(",
")",
";",
"if",
"(",
"locator",
"==",
"null",
")",
"return",
"components",
";",
"synchronized",
"(",
"_lock",
")",
"{",
"for",
"(",
"int",
"index",
"=",
"_references",
".",
"size",
"(",
")",
"-",
"1",
";",
"index",
">=",
"0",
";",
"index",
"--",
")",
"{",
"Reference",
"reference",
"=",
"_references",
".",
"get",
"(",
"index",
")",
";",
"if",
"(",
"reference",
".",
"match",
"(",
"locator",
")",
")",
"{",
"_references",
".",
"remove",
"(",
"index",
")",
";",
"components",
".",
"add",
"(",
"reference",
".",
"getComponent",
"(",
")",
")",
";",
"}",
"}",
"}",
"return",
"components",
";",
"}"
] |
Removes all component references that match the specified locator.
@param locator the locator to remove references by.
@return a list, containing all removed references.
|
[
"Removes",
"all",
"component",
"references",
"that",
"match",
"the",
"specified",
"locator",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/refer/References.java#L110-L127
|
155,020
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/refer/References.java
|
References.getAllLocators
|
public List<Object> getAllLocators() {
List<Object> locators = new ArrayList<Object>();
synchronized (_lock) {
for (Reference reference : _references)
locators.add(reference.getLocator());
}
return locators;
}
|
java
|
public List<Object> getAllLocators() {
List<Object> locators = new ArrayList<Object>();
synchronized (_lock) {
for (Reference reference : _references)
locators.add(reference.getLocator());
}
return locators;
}
|
[
"public",
"List",
"<",
"Object",
">",
"getAllLocators",
"(",
")",
"{",
"List",
"<",
"Object",
">",
"locators",
"=",
"new",
"ArrayList",
"<",
"Object",
">",
"(",
")",
";",
"synchronized",
"(",
"_lock",
")",
"{",
"for",
"(",
"Reference",
"reference",
":",
"_references",
")",
"locators",
".",
"(",
"reference",
".",
"getLocator",
"(",
")",
")",
";",
"}",
"return",
"locators",
";",
"}"
] |
Gets locators for all registered component references in this reference map.
@return a list with component locators.
|
[
"Gets",
"locators",
"for",
"all",
"registered",
"component",
"references",
"in",
"this",
"reference",
"map",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/refer/References.java#L134-L143
|
155,021
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/refer/References.java
|
References.getAll
|
public List<Object> getAll() {
List<Object> components = new ArrayList<Object>();
synchronized (_lock) {
for (Reference reference : _references)
components.add(reference.getComponent());
}
return components;
}
|
java
|
public List<Object> getAll() {
List<Object> components = new ArrayList<Object>();
synchronized (_lock) {
for (Reference reference : _references)
components.add(reference.getComponent());
}
return components;
}
|
[
"public",
"List",
"<",
"Object",
">",
"getAll",
"(",
")",
"{",
"List",
"<",
"Object",
">",
"components",
"=",
"new",
"ArrayList",
"<",
"Object",
">",
"(",
")",
";",
"synchronized",
"(",
"_lock",
")",
"{",
"for",
"(",
"Reference",
"reference",
":",
"_references",
")",
"components",
".",
"(",
"reference",
".",
"getComponent",
"(",
")",
")",
";",
"}",
"return",
"components",
";",
"}"
] |
Gets all component references registered in this reference map.
@return a list with component references.
|
[
"Gets",
"all",
"component",
"references",
"registered",
"in",
"this",
"reference",
"map",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/refer/References.java#L150-L159
|
155,022
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/refer/References.java
|
References.getOneOptional
|
public Object getOneOptional(Object locator) {
try {
List<Object> components = find(Object.class, locator, false);
return components.size() > 0 ? components.get(0) : null;
} catch (Exception ex) {
return null;
}
}
|
java
|
public Object getOneOptional(Object locator) {
try {
List<Object> components = find(Object.class, locator, false);
return components.size() > 0 ? components.get(0) : null;
} catch (Exception ex) {
return null;
}
}
|
[
"public",
"Object",
"getOneOptional",
"(",
"Object",
"locator",
")",
"{",
"try",
"{",
"List",
"<",
"Object",
">",
"components",
"=",
"find",
"(",
"Object",
".",
"class",
",",
"locator",
",",
"false",
")",
";",
"return",
"components",
".",
"size",
"(",
")",
">",
"0",
"?",
"components",
".",
"get",
"(",
"0",
")",
":",
"null",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"return",
"null",
";",
"}",
"}"
] |
Gets an optional component reference that matches specified locator.
@param locator the locator to find references by.
@return a matching component reference or null if nothing was found.
|
[
"Gets",
"an",
"optional",
"component",
"reference",
"that",
"matches",
"specified",
"locator",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/refer/References.java#L167-L174
|
155,023
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/refer/References.java
|
References.getOneOptional
|
public <T> T getOneOptional(Class<T> type, Object locator) {
try {
List<T> components = find(type, locator, false);
return components.size() > 0 ? components.get(0) : null;
} catch (Exception ex) {
return null;
}
}
|
java
|
public <T> T getOneOptional(Class<T> type, Object locator) {
try {
List<T> components = find(type, locator, false);
return components.size() > 0 ? components.get(0) : null;
} catch (Exception ex) {
return null;
}
}
|
[
"public",
"<",
"T",
">",
"T",
"getOneOptional",
"(",
"Class",
"<",
"T",
">",
"type",
",",
"Object",
"locator",
")",
"{",
"try",
"{",
"List",
"<",
"T",
">",
"components",
"=",
"find",
"(",
"type",
",",
"locator",
",",
"false",
")",
";",
"return",
"components",
".",
"size",
"(",
")",
">",
"0",
"?",
"components",
".",
"get",
"(",
"0",
")",
":",
"null",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"return",
"null",
";",
"}",
"}"
] |
Gets an optional component reference that matches specified locator and
matching to the specified type.
@param type the Class type that defined the type of the result.
@param locator the locator to find references by.
@return a matching component reference or null if nothing was found.
|
[
"Gets",
"an",
"optional",
"component",
"reference",
"that",
"matches",
"specified",
"locator",
"and",
"matching",
"to",
"the",
"specified",
"type",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/refer/References.java#L184-L191
|
155,024
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/refer/References.java
|
References.getOneRequired
|
public Object getOneRequired(Object locator) throws ReferenceException {
List<Object> components = find(Object.class, locator, true);
return components.size() > 0 ? components.get(0) : null;
}
|
java
|
public Object getOneRequired(Object locator) throws ReferenceException {
List<Object> components = find(Object.class, locator, true);
return components.size() > 0 ? components.get(0) : null;
}
|
[
"public",
"Object",
"getOneRequired",
"(",
"Object",
"locator",
")",
"throws",
"ReferenceException",
"{",
"List",
"<",
"Object",
">",
"components",
"=",
"find",
"(",
"Object",
".",
"class",
",",
"locator",
",",
"true",
")",
";",
"return",
"components",
".",
"size",
"(",
")",
">",
"0",
"?",
"components",
".",
"get",
"(",
"0",
")",
":",
"null",
";",
"}"
] |
Gets a required component reference that matches specified locator.
@param locator the locator to find a reference by.
@return a matching component reference.
@throws ReferenceException when no references found.
|
[
"Gets",
"a",
"required",
"component",
"reference",
"that",
"matches",
"specified",
"locator",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/refer/References.java#L200-L203
|
155,025
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/refer/References.java
|
References.getOneRequired
|
public <T> T getOneRequired(Class<T> type, Object locator) throws ReferenceException {
List<T> components = find(type, locator, true);
return components.size() > 0 ? components.get(0) : null;
}
|
java
|
public <T> T getOneRequired(Class<T> type, Object locator) throws ReferenceException {
List<T> components = find(type, locator, true);
return components.size() > 0 ? components.get(0) : null;
}
|
[
"public",
"<",
"T",
">",
"T",
"getOneRequired",
"(",
"Class",
"<",
"T",
">",
"type",
",",
"Object",
"locator",
")",
"throws",
"ReferenceException",
"{",
"List",
"<",
"T",
">",
"components",
"=",
"find",
"(",
"type",
",",
"locator",
",",
"true",
")",
";",
"return",
"components",
".",
"size",
"(",
")",
">",
"0",
"?",
"components",
".",
"get",
"(",
"0",
")",
":",
"null",
";",
"}"
] |
Gets a required component reference that matches specified locator and
matching to the specified type.
@param type the Class type that defined the type of the result.
@param locator the locator to find a reference by.
@return a matching component reference.
@throws ReferenceException when no references found.
|
[
"Gets",
"a",
"required",
"component",
"reference",
"that",
"matches",
"specified",
"locator",
"and",
"matching",
"to",
"the",
"specified",
"type",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/refer/References.java#L214-L217
|
155,026
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/refer/References.java
|
References.getRequired
|
public List<Object> getRequired(Object locator) throws ReferenceException {
return find(Object.class, locator, true);
}
|
java
|
public List<Object> getRequired(Object locator) throws ReferenceException {
return find(Object.class, locator, true);
}
|
[
"public",
"List",
"<",
"Object",
">",
"getRequired",
"(",
"Object",
"locator",
")",
"throws",
"ReferenceException",
"{",
"return",
"find",
"(",
"Object",
".",
"class",
",",
"locator",
",",
"true",
")",
";",
"}"
] |
Gets all component references that match specified locator. At least one
component reference must be present. If it doesn't the method throws an
error.
@param locator the locator to find references by.
@return a list with matching component references.
@throws ReferenceException when no references found.
|
[
"Gets",
"all",
"component",
"references",
"that",
"match",
"specified",
"locator",
".",
"At",
"least",
"one",
"component",
"reference",
"must",
"be",
"present",
".",
"If",
"it",
"doesn",
"t",
"the",
"method",
"throws",
"an",
"error",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/refer/References.java#L261-L263
|
155,027
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/refer/References.java
|
References.getRequired
|
public <T> List<T> getRequired(Class<T> type, Object locator) throws ReferenceException {
return find(type, locator, true);
}
|
java
|
public <T> List<T> getRequired(Class<T> type, Object locator) throws ReferenceException {
return find(type, locator, true);
}
|
[
"public",
"<",
"T",
">",
"List",
"<",
"T",
">",
"getRequired",
"(",
"Class",
"<",
"T",
">",
"type",
",",
"Object",
"locator",
")",
"throws",
"ReferenceException",
"{",
"return",
"find",
"(",
"type",
",",
"locator",
",",
"true",
")",
";",
"}"
] |
Gets all component references that match specified locator. At least one
component reference must be present and matching to the specified type.
If it doesn't the method throws an error.
@param type the Class type that defined the type of the result.
@param locator the locator to find references by.
@return a list with matching component references.
@throws ReferenceException when no references found.
|
[
"Gets",
"all",
"component",
"references",
"that",
"match",
"specified",
"locator",
".",
"At",
"least",
"one",
"component",
"reference",
"must",
"be",
"present",
"and",
"matching",
"to",
"the",
"specified",
"type",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/refer/References.java#L277-L279
|
155,028
|
morimekta/utils
|
io-util/src/main/java/net/morimekta/util/io/LineBufferedReader.java
|
LineBufferedReader.getLine
|
@Nonnull
public String getLine() {
if (preLoaded) {
if (bufferOffset >= 0) {
int lineStart = bufferOffset;
if (linePos > 0) {
lineStart -= linePos - 1;
}
int lineEnd = bufferOffset;
while (lineEnd < bufferLimit && buffer[lineEnd] != '\n') {
++lineEnd;
}
return new String(buffer, lineStart, lineEnd - lineStart);
}
} else if (bufferLimit > 0) {
if (Math.abs((linePos - 1) - bufferOffset) < 2) {
// only return the line if the line has not been consolidated before the
// exception. This should avoid showing a bad exception line pointing to
// the wrong content. This should never be the case in pretty-printed
// JSON unless some really really long strings are causing the error.
//
// Since linePos does not exactly follow offset, we must accept +- 1.
return new String(buffer, 0, bufferLimit - (bufferLineEnd ? 1 : 0));
}
}
// Otherwise we don't have the requested line, return empty string.
return "";
}
|
java
|
@Nonnull
public String getLine() {
if (preLoaded) {
if (bufferOffset >= 0) {
int lineStart = bufferOffset;
if (linePos > 0) {
lineStart -= linePos - 1;
}
int lineEnd = bufferOffset;
while (lineEnd < bufferLimit && buffer[lineEnd] != '\n') {
++lineEnd;
}
return new String(buffer, lineStart, lineEnd - lineStart);
}
} else if (bufferLimit > 0) {
if (Math.abs((linePos - 1) - bufferOffset) < 2) {
// only return the line if the line has not been consolidated before the
// exception. This should avoid showing a bad exception line pointing to
// the wrong content. This should never be the case in pretty-printed
// JSON unless some really really long strings are causing the error.
//
// Since linePos does not exactly follow offset, we must accept +- 1.
return new String(buffer, 0, bufferLimit - (bufferLineEnd ? 1 : 0));
}
}
// Otherwise we don't have the requested line, return empty string.
return "";
}
|
[
"@",
"Nonnull",
"public",
"String",
"getLine",
"(",
")",
"{",
"if",
"(",
"preLoaded",
")",
"{",
"if",
"(",
"bufferOffset",
">=",
"0",
")",
"{",
"int",
"lineStart",
"=",
"bufferOffset",
";",
"if",
"(",
"linePos",
">",
"0",
")",
"{",
"lineStart",
"-=",
"linePos",
"-",
"1",
";",
"}",
"int",
"lineEnd",
"=",
"bufferOffset",
";",
"while",
"(",
"lineEnd",
"<",
"bufferLimit",
"&&",
"buffer",
"[",
"lineEnd",
"]",
"!=",
"'",
"'",
")",
"{",
"++",
"lineEnd",
";",
"}",
"return",
"new",
"String",
"(",
"buffer",
",",
"lineStart",
",",
"lineEnd",
"-",
"lineStart",
")",
";",
"}",
"}",
"else",
"if",
"(",
"bufferLimit",
">",
"0",
")",
"{",
"if",
"(",
"Math",
".",
"abs",
"(",
"(",
"linePos",
"-",
"1",
")",
"-",
"bufferOffset",
")",
"<",
"2",
")",
"{",
"// only return the line if the line has not been consolidated before the",
"// exception. This should avoid showing a bad exception line pointing to",
"// the wrong content. This should never be the case in pretty-printed",
"// JSON unless some really really long strings are causing the error.",
"//",
"// Since linePos does not exactly follow offset, we must accept +- 1.",
"return",
"new",
"String",
"(",
"buffer",
",",
"0",
",",
"bufferLimit",
"-",
"(",
"bufferLineEnd",
"?",
"1",
":",
"0",
")",
")",
";",
"}",
"}",
"// Otherwise we don't have the requested line, return empty string.",
"return",
"\"\"",
";",
"}"
] |
Returns the current line in the buffer. Or empty string if not usable.
@return The line string, not including the line-break.
|
[
"Returns",
"the",
"current",
"line",
"in",
"the",
"buffer",
".",
"Or",
"empty",
"string",
"if",
"not",
"usable",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/io/LineBufferedReader.java#L147-L175
|
155,029
|
morimekta/utils
|
io-util/src/main/java/net/morimekta/util/io/LineBufferedReader.java
|
LineBufferedReader.getRestOfLine
|
@Nonnull
public String getRestOfLine() throws IOException {
if (preLoaded) {
if (bufferOffset < 0 || buffer[bufferOffset] == '\n' ||
(lastChar == 0 && !readNextChar())) {
return "";
}
int start = bufferOffset;
int length = 1;
while (readNextChar()) {
if (lastChar == '\n') {
lastChar = 0;
break;
}
++length;
}
return new String(buffer, start, length);
}
if (bufferOffset < 0 || buffer[bufferOffset] == '\n' ||
bufferOffset >= (bufferLimit - 1) ||
(lastChar == 0 && !readNextChar())) {
return "";
}
maybeConsolidateBuffer();
StringBuilder remainderBuilder = new StringBuilder();
do {
int unreadChars = bufferLimit - bufferOffset;
remainderBuilder.append(buffer, bufferOffset, unreadChars - (bufferLineEnd ? 1 : 0));
bufferOffset = bufferLimit;
linePos += unreadChars;
if (bufferLineEnd) {
break;
}
maybeConsolidateBuffer();
} while (bufferOffset < (bufferLimit - 1));
lastChar = 0;
return remainderBuilder.toString();
}
|
java
|
@Nonnull
public String getRestOfLine() throws IOException {
if (preLoaded) {
if (bufferOffset < 0 || buffer[bufferOffset] == '\n' ||
(lastChar == 0 && !readNextChar())) {
return "";
}
int start = bufferOffset;
int length = 1;
while (readNextChar()) {
if (lastChar == '\n') {
lastChar = 0;
break;
}
++length;
}
return new String(buffer, start, length);
}
if (bufferOffset < 0 || buffer[bufferOffset] == '\n' ||
bufferOffset >= (bufferLimit - 1) ||
(lastChar == 0 && !readNextChar())) {
return "";
}
maybeConsolidateBuffer();
StringBuilder remainderBuilder = new StringBuilder();
do {
int unreadChars = bufferLimit - bufferOffset;
remainderBuilder.append(buffer, bufferOffset, unreadChars - (bufferLineEnd ? 1 : 0));
bufferOffset = bufferLimit;
linePos += unreadChars;
if (bufferLineEnd) {
break;
}
maybeConsolidateBuffer();
} while (bufferOffset < (bufferLimit - 1));
lastChar = 0;
return remainderBuilder.toString();
}
|
[
"@",
"Nonnull",
"public",
"String",
"getRestOfLine",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"preLoaded",
")",
"{",
"if",
"(",
"bufferOffset",
"<",
"0",
"||",
"buffer",
"[",
"bufferOffset",
"]",
"==",
"'",
"'",
"||",
"(",
"lastChar",
"==",
"0",
"&&",
"!",
"readNextChar",
"(",
")",
")",
")",
"{",
"return",
"\"\"",
";",
"}",
"int",
"start",
"=",
"bufferOffset",
";",
"int",
"length",
"=",
"1",
";",
"while",
"(",
"readNextChar",
"(",
")",
")",
"{",
"if",
"(",
"lastChar",
"==",
"'",
"'",
")",
"{",
"lastChar",
"=",
"0",
";",
"break",
";",
"}",
"++",
"length",
";",
"}",
"return",
"new",
"String",
"(",
"buffer",
",",
"start",
",",
"length",
")",
";",
"}",
"if",
"(",
"bufferOffset",
"<",
"0",
"||",
"buffer",
"[",
"bufferOffset",
"]",
"==",
"'",
"'",
"||",
"bufferOffset",
">=",
"(",
"bufferLimit",
"-",
"1",
")",
"||",
"(",
"lastChar",
"==",
"0",
"&&",
"!",
"readNextChar",
"(",
")",
")",
")",
"{",
"return",
"\"\"",
";",
"}",
"maybeConsolidateBuffer",
"(",
")",
";",
"StringBuilder",
"remainderBuilder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"do",
"{",
"int",
"unreadChars",
"=",
"bufferLimit",
"-",
"bufferOffset",
";",
"remainderBuilder",
".",
"append",
"(",
"buffer",
",",
"bufferOffset",
",",
"unreadChars",
"-",
"(",
"bufferLineEnd",
"?",
"1",
":",
"0",
")",
")",
";",
"bufferOffset",
"=",
"bufferLimit",
";",
"linePos",
"+=",
"unreadChars",
";",
"if",
"(",
"bufferLineEnd",
")",
"{",
"break",
";",
"}",
"maybeConsolidateBuffer",
"(",
")",
";",
"}",
"while",
"(",
"bufferOffset",
"<",
"(",
"bufferLimit",
"-",
"1",
")",
")",
";",
"lastChar",
"=",
"0",
";",
"return",
"remainderBuilder",
".",
"toString",
"(",
")",
";",
"}"
] |
Return the rest of the current line. This is handy for handling unwanted content
after the last expected token or character.
@return The rest of the last read line. Not including leading and ending whitespaces,
since these are allowed.
@throws IOException If unable to read the rest of the line.
|
[
"Return",
"the",
"rest",
"of",
"the",
"current",
"line",
".",
"This",
"is",
"handy",
"for",
"handling",
"unwanted",
"content",
"after",
"the",
"last",
"expected",
"token",
"or",
"character",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/io/LineBufferedReader.java#L185-L227
|
155,030
|
morimekta/utils
|
io-util/src/main/java/net/morimekta/util/io/LineBufferedReader.java
|
LineBufferedReader.getRemainingLines
|
@Nonnull
public List<String> getRemainingLines(boolean trimAndSkipEmpty) throws IOException {
List<String> out = new ArrayList<>();
StringBuilder builder = new StringBuilder();
while (bufferOffset <= bufferLimit || !bufferLineEnd) {
if (!readNextChar()) {
break;
}
if (lastChar == '\n') {
String line = builder.toString();
if (!trimAndSkipEmpty || !line.trim().isEmpty()) {
out.add(trimAndSkipEmpty ? line.trim() : line);
}
builder = new StringBuilder();
} else {
builder.append((char) lastChar);
}
}
if (builder.length() > 0) {
String line = builder.toString();
if (!trimAndSkipEmpty || !line.trim().isEmpty()) {
out.add(builder.toString());
}
}
return out;
}
|
java
|
@Nonnull
public List<String> getRemainingLines(boolean trimAndSkipEmpty) throws IOException {
List<String> out = new ArrayList<>();
StringBuilder builder = new StringBuilder();
while (bufferOffset <= bufferLimit || !bufferLineEnd) {
if (!readNextChar()) {
break;
}
if (lastChar == '\n') {
String line = builder.toString();
if (!trimAndSkipEmpty || !line.trim().isEmpty()) {
out.add(trimAndSkipEmpty ? line.trim() : line);
}
builder = new StringBuilder();
} else {
builder.append((char) lastChar);
}
}
if (builder.length() > 0) {
String line = builder.toString();
if (!trimAndSkipEmpty || !line.trim().isEmpty()) {
out.add(builder.toString());
}
}
return out;
}
|
[
"@",
"Nonnull",
"public",
"List",
"<",
"String",
">",
"getRemainingLines",
"(",
"boolean",
"trimAndSkipEmpty",
")",
"throws",
"IOException",
"{",
"List",
"<",
"String",
">",
"out",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"while",
"(",
"bufferOffset",
"<=",
"bufferLimit",
"||",
"!",
"bufferLineEnd",
")",
"{",
"if",
"(",
"!",
"readNextChar",
"(",
")",
")",
"{",
"break",
";",
"}",
"if",
"(",
"lastChar",
"==",
"'",
"'",
")",
"{",
"String",
"line",
"=",
"builder",
".",
"toString",
"(",
")",
";",
"if",
"(",
"!",
"trimAndSkipEmpty",
"||",
"!",
"line",
".",
"trim",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"out",
".",
"add",
"(",
"trimAndSkipEmpty",
"?",
"line",
".",
"trim",
"(",
")",
":",
"line",
")",
";",
"}",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"}",
"else",
"{",
"builder",
".",
"append",
"(",
"(",
"char",
")",
"lastChar",
")",
";",
"}",
"}",
"if",
"(",
"builder",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"String",
"line",
"=",
"builder",
".",
"toString",
"(",
")",
";",
"if",
"(",
"!",
"trimAndSkipEmpty",
"||",
"!",
"line",
".",
"trim",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"out",
".",
"add",
"(",
"builder",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"return",
"out",
";",
"}"
] |
Read the rest of input from the reader, and get the lines from there.
This will consume the rest of the content of the reader.
@param trimAndSkipEmpty If lines should be trimmed and empty lines should
be skipped.
@return List of lines after the current.
@throws IOException When failing to read stream to end.
|
[
"Read",
"the",
"rest",
"of",
"input",
"from",
"the",
"reader",
"and",
"get",
"the",
"lines",
"from",
"there",
".",
"This",
"will",
"consume",
"the",
"rest",
"of",
"the",
"content",
"of",
"the",
"reader",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/io/LineBufferedReader.java#L238-L264
|
155,031
|
hudson3-plugins/warnings-plugin
|
src/main/java/hudson/plugins/warnings/GroovyParser.java
|
GroovyParser.readResolve
|
private Object readResolve() {
if (linkName == null) {
linkName = Messages._Warnings_ProjectAction_Name().toString(Locale.ENGLISH);
}
if (trendName == null) {
trendName = Messages._Warnings_Trend_Name().toString(Locale.ENGLISH);
}
parser = createParser();
return this;
}
|
java
|
private Object readResolve() {
if (linkName == null) {
linkName = Messages._Warnings_ProjectAction_Name().toString(Locale.ENGLISH);
}
if (trendName == null) {
trendName = Messages._Warnings_Trend_Name().toString(Locale.ENGLISH);
}
parser = createParser();
return this;
}
|
[
"private",
"Object",
"readResolve",
"(",
")",
"{",
"if",
"(",
"linkName",
"==",
"null",
")",
"{",
"linkName",
"=",
"Messages",
".",
"_Warnings_ProjectAction_Name",
"(",
")",
".",
"toString",
"(",
"Locale",
".",
"ENGLISH",
")",
";",
"}",
"if",
"(",
"trendName",
"==",
"null",
")",
"{",
"trendName",
"=",
"Messages",
".",
"_Warnings_Trend_Name",
"(",
")",
".",
"toString",
"(",
"Locale",
".",
"ENGLISH",
")",
";",
"}",
"parser",
"=",
"createParser",
"(",
")",
";",
"return",
"this",
";",
"}"
] |
Adds link and trend names for 3.x serializations.
@return the created object
|
[
"Adds",
"link",
"and",
"trend",
"names",
"for",
"3",
".",
"x",
"serializations",
"."
] |
462c9f3dffede9120173935567392b22520b0966
|
https://github.com/hudson3-plugins/warnings-plugin/blob/462c9f3dffede9120173935567392b22520b0966/src/main/java/hudson/plugins/warnings/GroovyParser.java#L95-L104
|
155,032
|
morimekta/utils
|
io-util/src/main/java/net/morimekta/util/FileUtil.java
|
FileUtil.deleteRecursively
|
public static void deleteRecursively(Path path) throws IOException {
if (Files.isDirectory(path)) {
Files.list(path).forEach(file -> {
try {
deleteRecursively(file);
} catch (IOException e) {
throw new UncheckedIOException(e.getMessage(), e);
}
});
}
Files.delete(path);
}
|
java
|
public static void deleteRecursively(Path path) throws IOException {
if (Files.isDirectory(path)) {
Files.list(path).forEach(file -> {
try {
deleteRecursively(file);
} catch (IOException e) {
throw new UncheckedIOException(e.getMessage(), e);
}
});
}
Files.delete(path);
}
|
[
"public",
"static",
"void",
"deleteRecursively",
"(",
"Path",
"path",
")",
"throws",
"IOException",
"{",
"if",
"(",
"Files",
".",
"isDirectory",
"(",
"path",
")",
")",
"{",
"Files",
".",
"list",
"(",
"path",
")",
".",
"forEach",
"(",
"file",
"->",
"{",
"try",
"{",
"deleteRecursively",
"(",
"file",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"UncheckedIOException",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}",
")",
";",
"}",
"Files",
".",
"delete",
"(",
"path",
")",
";",
"}"
] |
Delete the file or directory recursively.
@param path The file or directory path.
@throws IOException If delete failed at some point.
|
[
"Delete",
"the",
"file",
"or",
"directory",
"recursively",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/FileUtil.java#L139-L150
|
155,033
|
bushidowallet/bushido-java-service
|
bushido-wallet-service/src/main/java/com/authy/api/Instance.java
|
Instance.getError
|
public Error getError() {
if(isOk())
return error;
try {
JAXBContext context = JAXBContext.newInstance(Error.class);
Unmarshaller unmarshaller = context.createUnmarshaller();
StringReader xml = new StringReader(content);
if(!content.isEmpty())
error = (Error)unmarshaller.unmarshal(new StreamSource(xml));
}
catch(JAXBException e) {
e.printStackTrace();
}
return error;
}
|
java
|
public Error getError() {
if(isOk())
return error;
try {
JAXBContext context = JAXBContext.newInstance(Error.class);
Unmarshaller unmarshaller = context.createUnmarshaller();
StringReader xml = new StringReader(content);
if(!content.isEmpty())
error = (Error)unmarshaller.unmarshal(new StreamSource(xml));
}
catch(JAXBException e) {
e.printStackTrace();
}
return error;
}
|
[
"public",
"Error",
"getError",
"(",
")",
"{",
"if",
"(",
"isOk",
"(",
")",
")",
"return",
"error",
";",
"try",
"{",
"JAXBContext",
"context",
"=",
"JAXBContext",
".",
"newInstance",
"(",
"Error",
".",
"class",
")",
";",
"Unmarshaller",
"unmarshaller",
"=",
"context",
".",
"createUnmarshaller",
"(",
")",
";",
"StringReader",
"xml",
"=",
"new",
"StringReader",
"(",
"content",
")",
";",
"if",
"(",
"!",
"content",
".",
"isEmpty",
"(",
")",
")",
"error",
"=",
"(",
"Error",
")",
"unmarshaller",
".",
"unmarshal",
"(",
"new",
"StreamSource",
"(",
"xml",
")",
")",
";",
"}",
"catch",
"(",
"JAXBException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"return",
"error",
";",
"}"
] |
Return an Error object with the error that have occurred or null.
@return an Error object
|
[
"Return",
"an",
"Error",
"object",
"with",
"the",
"error",
"that",
"have",
"occurred",
"or",
"null",
"."
] |
e1a0157527e57459b509718044d2df44084876a2
|
https://github.com/bushidowallet/bushido-java-service/blob/e1a0157527e57459b509718044d2df44084876a2/bushido-wallet-service/src/main/java/com/authy/api/Instance.java#L49-L66
|
155,034
|
riversun/string-grabber
|
src/main/java/org/riversun/string_grabber/StringCropper.java
|
StringCropper.stringAt
|
public String stringAt(String srcStr, int index) {
if (0 <= index && index < srcStr.length()) {
return String.valueOf(srcStr.charAt(index));
} else {
return "";
}
}
|
java
|
public String stringAt(String srcStr, int index) {
if (0 <= index && index < srcStr.length()) {
return String.valueOf(srcStr.charAt(index));
} else {
return "";
}
}
|
[
"public",
"String",
"stringAt",
"(",
"String",
"srcStr",
",",
"int",
"index",
")",
"{",
"if",
"(",
"0",
"<=",
"index",
"&&",
"index",
"<",
"srcStr",
".",
"length",
"(",
")",
")",
"{",
"return",
"String",
".",
"valueOf",
"(",
"srcStr",
".",
"charAt",
"(",
"index",
")",
")",
";",
"}",
"else",
"{",
"return",
"\"\"",
";",
"}",
"}"
] |
returns string at index
@param srcStr
@param index
@return
|
[
"returns",
"string",
"at",
"index"
] |
b5aadc21fe15f50d35392188dec6ab81dcf8d464
|
https://github.com/riversun/string-grabber/blob/b5aadc21fe15f50d35392188dec6ab81dcf8d464/src/main/java/org/riversun/string_grabber/StringCropper.java#L204-L212
|
155,035
|
riversun/string-grabber
|
src/main/java/org/riversun/string_grabber/StringCropper.java
|
StringCropper.removeTail
|
public String removeTail(String srcStr, int charCount) {
return getLeftOf(srcStr, srcStr.length() - charCount);
}
|
java
|
public String removeTail(String srcStr, int charCount) {
return getLeftOf(srcStr, srcStr.length() - charCount);
}
|
[
"public",
"String",
"removeTail",
"(",
"String",
"srcStr",
",",
"int",
"charCount",
")",
"{",
"return",
"getLeftOf",
"(",
"srcStr",
",",
"srcStr",
".",
"length",
"(",
")",
"-",
"charCount",
")",
";",
"}"
] |
Return the rest of the string that is cropped the number of chars from
the end of string
@param srcStr
@param charCount
@return
|
[
"Return",
"the",
"rest",
"of",
"the",
"string",
"that",
"is",
"cropped",
"the",
"number",
"of",
"chars",
"from",
"the",
"end",
"of",
"string"
] |
b5aadc21fe15f50d35392188dec6ab81dcf8d464
|
https://github.com/riversun/string-grabber/blob/b5aadc21fe15f50d35392188dec6ab81dcf8d464/src/main/java/org/riversun/string_grabber/StringCropper.java#L419-L421
|
155,036
|
riversun/string-grabber
|
src/main/java/org/riversun/string_grabber/StringCropper.java
|
StringCropper.removeHead
|
public String removeHead(String srcStr, int charCount) {
return getRightOf(srcStr, srcStr.length() - charCount);
}
|
java
|
public String removeHead(String srcStr, int charCount) {
return getRightOf(srcStr, srcStr.length() - charCount);
}
|
[
"public",
"String",
"removeHead",
"(",
"String",
"srcStr",
",",
"int",
"charCount",
")",
"{",
"return",
"getRightOf",
"(",
"srcStr",
",",
"srcStr",
".",
"length",
"(",
")",
"-",
"charCount",
")",
";",
"}"
] |
Return the rest of the string that is cropped the number of chars from
the beginning
@param srcStr
@param charCount
@return
|
[
"Return",
"the",
"rest",
"of",
"the",
"string",
"that",
"is",
"cropped",
"the",
"number",
"of",
"chars",
"from",
"the",
"beginning"
] |
b5aadc21fe15f50d35392188dec6ab81dcf8d464
|
https://github.com/riversun/string-grabber/blob/b5aadc21fe15f50d35392188dec6ab81dcf8d464/src/main/java/org/riversun/string_grabber/StringCropper.java#L431-L433
|
155,037
|
riversun/string-grabber
|
src/main/java/org/riversun/string_grabber/StringCropper.java
|
StringCropper.getLeftOf
|
public String getLeftOf(String srcStr, int charCount) {
String retValue = "";
if (isNotBlank(srcStr)) {
int length = srcStr.length();
if (charCount < length) {
retValue = srcStr.substring(0, charCount);
} else {
retValue = srcStr;
}
}
return retValue;
}
|
java
|
public String getLeftOf(String srcStr, int charCount) {
String retValue = "";
if (isNotBlank(srcStr)) {
int length = srcStr.length();
if (charCount < length) {
retValue = srcStr.substring(0, charCount);
} else {
retValue = srcStr;
}
}
return retValue;
}
|
[
"public",
"String",
"getLeftOf",
"(",
"String",
"srcStr",
",",
"int",
"charCount",
")",
"{",
"String",
"retValue",
"=",
"\"\"",
";",
"if",
"(",
"isNotBlank",
"(",
"srcStr",
")",
")",
"{",
"int",
"length",
"=",
"srcStr",
".",
"length",
"(",
")",
";",
"if",
"(",
"charCount",
"<",
"length",
")",
"{",
"retValue",
"=",
"srcStr",
".",
"substring",
"(",
"0",
",",
"charCount",
")",
";",
"}",
"else",
"{",
"retValue",
"=",
"srcStr",
";",
"}",
"}",
"return",
"retValue",
";",
"}"
] |
Returns the number of characters specified from left
@param srcStr
@param charCount
@return
|
[
"Returns",
"the",
"number",
"of",
"characters",
"specified",
"from",
"left"
] |
b5aadc21fe15f50d35392188dec6ab81dcf8d464
|
https://github.com/riversun/string-grabber/blob/b5aadc21fe15f50d35392188dec6ab81dcf8d464/src/main/java/org/riversun/string_grabber/StringCropper.java#L442-L458
|
155,038
|
riversun/string-grabber
|
src/main/java/org/riversun/string_grabber/StringCropper.java
|
StringCropper.getRightOf
|
public String getRightOf(String srcStr, int charCount) {
String retVal = "";
if (isNotBlank(srcStr)) {
int length = srcStr.length();
if (charCount < length) {
retVal = srcStr.substring(length - charCount, length);
} else {
retVal = srcStr;
}
} else {
}
return retVal;
}
|
java
|
public String getRightOf(String srcStr, int charCount) {
String retVal = "";
if (isNotBlank(srcStr)) {
int length = srcStr.length();
if (charCount < length) {
retVal = srcStr.substring(length - charCount, length);
} else {
retVal = srcStr;
}
} else {
}
return retVal;
}
|
[
"public",
"String",
"getRightOf",
"(",
"String",
"srcStr",
",",
"int",
"charCount",
")",
"{",
"String",
"retVal",
"=",
"\"\"",
";",
"if",
"(",
"isNotBlank",
"(",
"srcStr",
")",
")",
"{",
"int",
"length",
"=",
"srcStr",
".",
"length",
"(",
")",
";",
"if",
"(",
"charCount",
"<",
"length",
")",
"{",
"retVal",
"=",
"srcStr",
".",
"substring",
"(",
"length",
"-",
"charCount",
",",
"length",
")",
";",
"}",
"else",
"{",
"retVal",
"=",
"srcStr",
";",
"}",
"}",
"else",
"{",
"}",
"return",
"retVal",
";",
"}"
] |
Returns the number of characters specified from right
@param srcStr
@param charCount
@return
|
[
"Returns",
"the",
"number",
"of",
"characters",
"specified",
"from",
"right"
] |
b5aadc21fe15f50d35392188dec6ab81dcf8d464
|
https://github.com/riversun/string-grabber/blob/b5aadc21fe15f50d35392188dec6ab81dcf8d464/src/main/java/org/riversun/string_grabber/StringCropper.java#L467-L485
|
155,039
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/data/StringValueMap.java
|
StringValueMap.setAsObject
|
public void setAsObject(String key, Object value) {
put(key, StringConverter.toNullableString(value));
}
|
java
|
public void setAsObject(String key, Object value) {
put(key, StringConverter.toNullableString(value));
}
|
[
"public",
"void",
"setAsObject",
"(",
"String",
"key",
",",
"Object",
"value",
")",
"{",
"put",
"(",
"key",
",",
"StringConverter",
".",
"toNullableString",
"(",
"value",
")",
")",
";",
"}"
] |
Sets a new value to map element specified by its index. When the index is not
defined, it resets the entire map value. This method has double purpose
because method overrides are not supported in JavaScript.
@param key (optional) a key of the element to set
@param value a new element or map value.
|
[
"Sets",
"a",
"new",
"value",
"to",
"map",
"element",
"specified",
"by",
"its",
"index",
".",
"When",
"the",
"index",
"is",
"not",
"defined",
"it",
"resets",
"the",
"entire",
"map",
"value",
".",
"This",
"method",
"has",
"double",
"purpose",
"because",
"method",
"overrides",
"are",
"not",
"supported",
"in",
"JavaScript",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/data/StringValueMap.java#L123-L125
|
155,040
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/data/StringValueMap.java
|
StringValueMap.fromString
|
public static StringValueMap fromString(String line) {
StringValueMap result = new StringValueMap();
if (line == null || line.length() == 0)
return result;
// Todo: User tokenizer / decoder
String[] tokens = line.split(";", -1);
for (String token : tokens) {
if (token.length() == 0)
continue;
int index = token.indexOf('=');
String key = index > 0 ? token.substring(0, index).trim() : token.trim();
String val = index > 0 ? token.substring(index + 1).trim() : null;
result.put(key, val);
}
return result;
}
|
java
|
public static StringValueMap fromString(String line) {
StringValueMap result = new StringValueMap();
if (line == null || line.length() == 0)
return result;
// Todo: User tokenizer / decoder
String[] tokens = line.split(";", -1);
for (String token : tokens) {
if (token.length() == 0)
continue;
int index = token.indexOf('=');
String key = index > 0 ? token.substring(0, index).trim() : token.trim();
String val = index > 0 ? token.substring(index + 1).trim() : null;
result.put(key, val);
}
return result;
}
|
[
"public",
"static",
"StringValueMap",
"fromString",
"(",
"String",
"line",
")",
"{",
"StringValueMap",
"result",
"=",
"new",
"StringValueMap",
"(",
")",
";",
"if",
"(",
"line",
"==",
"null",
"||",
"line",
".",
"length",
"(",
")",
"==",
"0",
")",
"return",
"result",
";",
"// Todo: User tokenizer / decoder",
"String",
"[",
"]",
"tokens",
"=",
"line",
".",
"split",
"(",
"\";\"",
",",
"-",
"1",
")",
";",
"for",
"(",
"String",
"token",
":",
"tokens",
")",
"{",
"if",
"(",
"token",
".",
"length",
"(",
")",
"==",
"0",
")",
"continue",
";",
"int",
"index",
"=",
"token",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"String",
"key",
"=",
"index",
">",
"0",
"?",
"token",
".",
"substring",
"(",
"0",
",",
"index",
")",
".",
"trim",
"(",
")",
":",
"token",
".",
"trim",
"(",
")",
";",
"String",
"val",
"=",
"index",
">",
"0",
"?",
"token",
".",
"substring",
"(",
"index",
"+",
"1",
")",
".",
"trim",
"(",
")",
":",
"null",
";",
"result",
".",
"put",
"(",
"key",
",",
"val",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Parses semicolon-separated key-value pairs and returns them as a
StringValueMap.
@param line semicolon-separated key-value list to initialize StringValueMap.
@return a newly created StringValueMap.
|
[
"Parses",
"semicolon",
"-",
"separated",
"key",
"-",
"value",
"pairs",
"and",
"returns",
"them",
"as",
"a",
"StringValueMap",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/data/StringValueMap.java#L696-L714
|
155,041
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/ServiceDirectoryImpl.java
|
ServiceDirectoryImpl.reinitServiceDirectoryManagerFactory
|
public void reinitServiceDirectoryManagerFactory(ServiceDirectoryManagerFactory factory) throws ServiceException{
if (factory == null) {
throw new IllegalArgumentException("The ServiceDirectoryManagerFactory cannot be NULL.");
}
synchronized(this){
if(isShutdown){
ServiceDirectoryError error = new ServiceDirectoryError(ErrorCode.SERVICE_DIRECTORY_IS_SHUTDOWN);
throw new ServiceException(error);
}
if (this.directoryManagerFactory != null) {
if (directoryManagerFactory instanceof Closable) {
((Closable) directoryManagerFactory).stop();
}
LOGGER.info("Resetting ServiceDirectoryManagerFactory, old="
+ this.directoryManagerFactory.getClass().getName()
+ ", new=" + factory.getClass().getName() + ".");
this.directoryManagerFactory = factory;
} else {
this.directoryManagerFactory = factory;
LOGGER.info("Setting ServiceDirectoryManagerFactory, factory="
+ factory.getClass().getName() + ".");
}
this.directoryManagerFactory.initialize(this);
}
}
|
java
|
public void reinitServiceDirectoryManagerFactory(ServiceDirectoryManagerFactory factory) throws ServiceException{
if (factory == null) {
throw new IllegalArgumentException("The ServiceDirectoryManagerFactory cannot be NULL.");
}
synchronized(this){
if(isShutdown){
ServiceDirectoryError error = new ServiceDirectoryError(ErrorCode.SERVICE_DIRECTORY_IS_SHUTDOWN);
throw new ServiceException(error);
}
if (this.directoryManagerFactory != null) {
if (directoryManagerFactory instanceof Closable) {
((Closable) directoryManagerFactory).stop();
}
LOGGER.info("Resetting ServiceDirectoryManagerFactory, old="
+ this.directoryManagerFactory.getClass().getName()
+ ", new=" + factory.getClass().getName() + ".");
this.directoryManagerFactory = factory;
} else {
this.directoryManagerFactory = factory;
LOGGER.info("Setting ServiceDirectoryManagerFactory, factory="
+ factory.getClass().getName() + ".");
}
this.directoryManagerFactory.initialize(this);
}
}
|
[
"public",
"void",
"reinitServiceDirectoryManagerFactory",
"(",
"ServiceDirectoryManagerFactory",
"factory",
")",
"throws",
"ServiceException",
"{",
"if",
"(",
"factory",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The ServiceDirectoryManagerFactory cannot be NULL.\"",
")",
";",
"}",
"synchronized",
"(",
"this",
")",
"{",
"if",
"(",
"isShutdown",
")",
"{",
"ServiceDirectoryError",
"error",
"=",
"new",
"ServiceDirectoryError",
"(",
"ErrorCode",
".",
"SERVICE_DIRECTORY_IS_SHUTDOWN",
")",
";",
"throw",
"new",
"ServiceException",
"(",
"error",
")",
";",
"}",
"if",
"(",
"this",
".",
"directoryManagerFactory",
"!=",
"null",
")",
"{",
"if",
"(",
"directoryManagerFactory",
"instanceof",
"Closable",
")",
"{",
"(",
"(",
"Closable",
")",
"directoryManagerFactory",
")",
".",
"stop",
"(",
")",
";",
"}",
"LOGGER",
".",
"info",
"(",
"\"Resetting ServiceDirectoryManagerFactory, old=\"",
"+",
"this",
".",
"directoryManagerFactory",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\", new=\"",
"+",
"factory",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\".\"",
")",
";",
"this",
".",
"directoryManagerFactory",
"=",
"factory",
";",
"}",
"else",
"{",
"this",
".",
"directoryManagerFactory",
"=",
"factory",
";",
"LOGGER",
".",
"info",
"(",
"\"Setting ServiceDirectoryManagerFactory, factory=\"",
"+",
"factory",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\".\"",
")",
";",
"}",
"this",
".",
"directoryManagerFactory",
".",
"initialize",
"(",
"this",
")",
";",
"}",
"}"
] |
Set the ServiceDirectoryManagerFactory in the sd-api.
@param factory
the ServiceDirectoryManagerFactory.
@throws ServiceException
|
[
"Set",
"the",
"ServiceDirectoryManagerFactory",
"in",
"the",
"sd",
"-",
"api",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/ServiceDirectoryImpl.java#L122-L151
|
155,042
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/ServiceDirectoryImpl.java
|
ServiceDirectoryImpl.shutdown
|
public void shutdown(){
synchronized(this){
if(! isShutdown){
if (directoryManagerFactory != null) {
if (directoryManagerFactory instanceof Closable) {
((Closable) directoryManagerFactory).stop();
}
directoryManagerFactory = null;
}
if (client != null) {
client.close();
client = null;
}
this.isShutdown = true;
}
}
}
|
java
|
public void shutdown(){
synchronized(this){
if(! isShutdown){
if (directoryManagerFactory != null) {
if (directoryManagerFactory instanceof Closable) {
((Closable) directoryManagerFactory).stop();
}
directoryManagerFactory = null;
}
if (client != null) {
client.close();
client = null;
}
this.isShutdown = true;
}
}
}
|
[
"public",
"void",
"shutdown",
"(",
")",
"{",
"synchronized",
"(",
"this",
")",
"{",
"if",
"(",
"!",
"isShutdown",
")",
"{",
"if",
"(",
"directoryManagerFactory",
"!=",
"null",
")",
"{",
"if",
"(",
"directoryManagerFactory",
"instanceof",
"Closable",
")",
"{",
"(",
"(",
"Closable",
")",
"directoryManagerFactory",
")",
".",
"stop",
"(",
")",
";",
"}",
"directoryManagerFactory",
"=",
"null",
";",
"}",
"if",
"(",
"client",
"!=",
"null",
")",
"{",
"client",
".",
"close",
"(",
")",
";",
"client",
"=",
"null",
";",
"}",
"this",
".",
"isShutdown",
"=",
"true",
";",
"}",
"}",
"}"
] |
Shutdown the ServiceDirectory and the ServiceDirectoryManagerFactory.
|
[
"Shutdown",
"the",
"ServiceDirectory",
"and",
"the",
"ServiceDirectoryManagerFactory",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/ServiceDirectoryImpl.java#L189-L205
|
155,043
|
konvergeio/cofoja
|
src/main/java/com/google/java/contract/core/apt/FactoryUtils.java
|
FactoryUtils.getGenericTypeName
|
@Requires("element != null")
@Ensures("result != null")
TypeName getGenericTypeName(TypeParameterElement element) {
String name = element.getSimpleName().toString();
List<? extends TypeMirror> bounds = element.getBounds();
if (bounds.isEmpty()
|| (bounds.size() == 1
&& bounds.get(0).toString().equals("java.lang.Object"))) {
return new TypeName(name);
}
StringBuilder buffer = new StringBuilder();
buffer.append(name);
buffer.append(" extends ");
Iterator<? extends TypeMirror> iter = bounds.iterator();
for (;;) {
buffer.append(iter.next().toString());
if (!iter.hasNext()) {
break;
}
buffer.append(" & ");
}
return new TypeName(buffer.toString());
}
|
java
|
@Requires("element != null")
@Ensures("result != null")
TypeName getGenericTypeName(TypeParameterElement element) {
String name = element.getSimpleName().toString();
List<? extends TypeMirror> bounds = element.getBounds();
if (bounds.isEmpty()
|| (bounds.size() == 1
&& bounds.get(0).toString().equals("java.lang.Object"))) {
return new TypeName(name);
}
StringBuilder buffer = new StringBuilder();
buffer.append(name);
buffer.append(" extends ");
Iterator<? extends TypeMirror> iter = bounds.iterator();
for (;;) {
buffer.append(iter.next().toString());
if (!iter.hasNext()) {
break;
}
buffer.append(" & ");
}
return new TypeName(buffer.toString());
}
|
[
"@",
"Requires",
"(",
"\"element != null\"",
")",
"@",
"Ensures",
"(",
"\"result != null\"",
")",
"TypeName",
"getGenericTypeName",
"(",
"TypeParameterElement",
"element",
")",
"{",
"String",
"name",
"=",
"element",
".",
"getSimpleName",
"(",
")",
".",
"toString",
"(",
")",
";",
"List",
"<",
"?",
"extends",
"TypeMirror",
">",
"bounds",
"=",
"element",
".",
"getBounds",
"(",
")",
";",
"if",
"(",
"bounds",
".",
"isEmpty",
"(",
")",
"||",
"(",
"bounds",
".",
"size",
"(",
")",
"==",
"1",
"&&",
"bounds",
".",
"get",
"(",
"0",
")",
".",
"toString",
"(",
")",
".",
"equals",
"(",
"\"java.lang.Object\"",
")",
")",
")",
"{",
"return",
"new",
"TypeName",
"(",
"name",
")",
";",
"}",
"StringBuilder",
"buffer",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"buffer",
".",
"append",
"(",
"name",
")",
";",
"buffer",
".",
"append",
"(",
"\" extends \"",
")",
";",
"Iterator",
"<",
"?",
"extends",
"TypeMirror",
">",
"iter",
"=",
"bounds",
".",
"iterator",
"(",
")",
";",
"for",
"(",
";",
";",
")",
"{",
"buffer",
".",
"append",
"(",
"iter",
".",
"next",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"if",
"(",
"!",
"iter",
".",
"hasNext",
"(",
")",
")",
"{",
"break",
";",
"}",
"buffer",
".",
"append",
"(",
"\" & \"",
")",
";",
"}",
"return",
"new",
"TypeName",
"(",
"buffer",
".",
"toString",
"(",
")",
")",
";",
"}"
] |
Returns a Java-printable generic type name from the specified
TypeParameterElement.
|
[
"Returns",
"a",
"Java",
"-",
"printable",
"generic",
"type",
"name",
"from",
"the",
"specified",
"TypeParameterElement",
"."
] |
6ded58fa05eb5bf85f16353c8dd4c70bee59121a
|
https://github.com/konvergeio/cofoja/blob/6ded58fa05eb5bf85f16353c8dd4c70bee59121a/src/main/java/com/google/java/contract/core/apt/FactoryUtils.java#L111-L136
|
155,044
|
konvergeio/cofoja
|
src/main/java/com/google/java/contract/core/apt/FactoryUtils.java
|
FactoryUtils.getAnnotationKindForName
|
ElementKind getAnnotationKindForName(AnnotationMirror annotation) {
String annotationName = annotation.getAnnotationType().toString();
ElementKind kind;
if (annotationName.equals("com.google.java.contract.Invariant")) {
kind = ElementKind.INVARIANT;
} else if (annotationName.equals("com.google.java.contract.Requires")) {
kind = ElementKind.REQUIRES;
} else if (annotationName.equals("com.google.java.contract.Ensures")) {
kind = ElementKind.ENSURES;
} else if (annotationName.equals("com.google.java.contract.ThrowEnsures")) {
kind = ElementKind.THROW_ENSURES;
} else {
kind = null;
}
return kind;
}
|
java
|
ElementKind getAnnotationKindForName(AnnotationMirror annotation) {
String annotationName = annotation.getAnnotationType().toString();
ElementKind kind;
if (annotationName.equals("com.google.java.contract.Invariant")) {
kind = ElementKind.INVARIANT;
} else if (annotationName.equals("com.google.java.contract.Requires")) {
kind = ElementKind.REQUIRES;
} else if (annotationName.equals("com.google.java.contract.Ensures")) {
kind = ElementKind.ENSURES;
} else if (annotationName.equals("com.google.java.contract.ThrowEnsures")) {
kind = ElementKind.THROW_ENSURES;
} else {
kind = null;
}
return kind;
}
|
[
"ElementKind",
"getAnnotationKindForName",
"(",
"AnnotationMirror",
"annotation",
")",
"{",
"String",
"annotationName",
"=",
"annotation",
".",
"getAnnotationType",
"(",
")",
".",
"toString",
"(",
")",
";",
"ElementKind",
"kind",
";",
"if",
"(",
"annotationName",
".",
"equals",
"(",
"\"com.google.java.contract.Invariant\"",
")",
")",
"{",
"kind",
"=",
"ElementKind",
".",
"INVARIANT",
";",
"}",
"else",
"if",
"(",
"annotationName",
".",
"equals",
"(",
"\"com.google.java.contract.Requires\"",
")",
")",
"{",
"kind",
"=",
"ElementKind",
".",
"REQUIRES",
";",
"}",
"else",
"if",
"(",
"annotationName",
".",
"equals",
"(",
"\"com.google.java.contract.Ensures\"",
")",
")",
"{",
"kind",
"=",
"ElementKind",
".",
"ENSURES",
";",
"}",
"else",
"if",
"(",
"annotationName",
".",
"equals",
"(",
"\"com.google.java.contract.ThrowEnsures\"",
")",
")",
"{",
"kind",
"=",
"ElementKind",
".",
"THROW_ENSURES",
";",
"}",
"else",
"{",
"kind",
"=",
"null",
";",
"}",
"return",
"kind",
";",
"}"
] |
Gets the contract kind of an annotation given its qualified name.
Returns null if the annotation is not a contract annotation.
@param annotationName the fully qualified name of the annotation
@return the contract type, null if not contracts
|
[
"Gets",
"the",
"contract",
"kind",
"of",
"an",
"annotation",
"given",
"its",
"qualified",
"name",
".",
"Returns",
"null",
"if",
"the",
"annotation",
"is",
"not",
"a",
"contract",
"annotation",
"."
] |
6ded58fa05eb5bf85f16353c8dd4c70bee59121a
|
https://github.com/konvergeio/cofoja/blob/6ded58fa05eb5bf85f16353c8dd4c70bee59121a/src/main/java/com/google/java/contract/core/apt/FactoryUtils.java#L145-L161
|
155,045
|
foundation-runtime/service-directory
|
1.2/sd-client/src/main/java/ServiceDirectoryClient.java
|
ServiceDirectoryClient.getAllServices
|
private void getAllServices() {
try {
List<ModelServiceInstance> instances = new DirectoryServiceRestfulClient().getAllInstances();
for (ModelServiceInstance instance :instances){
printServiceInstance(ServiceInstanceUtils.toServiceInstance(instance));
}
} catch (ServiceException e) {
e.printStackTrace();
fail(e.getServiceDirectoryError().getErrorMessage());
}
}
|
java
|
private void getAllServices() {
try {
List<ModelServiceInstance> instances = new DirectoryServiceRestfulClient().getAllInstances();
for (ModelServiceInstance instance :instances){
printServiceInstance(ServiceInstanceUtils.toServiceInstance(instance));
}
} catch (ServiceException e) {
e.printStackTrace();
fail(e.getServiceDirectoryError().getErrorMessage());
}
}
|
[
"private",
"void",
"getAllServices",
"(",
")",
"{",
"try",
"{",
"List",
"<",
"ModelServiceInstance",
">",
"instances",
"=",
"new",
"DirectoryServiceRestfulClient",
"(",
")",
".",
"getAllInstances",
"(",
")",
";",
"for",
"(",
"ModelServiceInstance",
"instance",
":",
"instances",
")",
"{",
"printServiceInstance",
"(",
"ServiceInstanceUtils",
".",
"toServiceInstance",
"(",
"instance",
")",
")",
";",
"}",
"}",
"catch",
"(",
"ServiceException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"fail",
"(",
"e",
".",
"getServiceDirectoryError",
"(",
")",
".",
"getErrorMessage",
"(",
")",
")",
";",
"}",
"}"
] |
Do the getAllServices command.
|
[
"Do",
"the",
"getAllServices",
"command",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.2/sd-client/src/main/java/ServiceDirectoryClient.java#L230-L240
|
155,046
|
foundation-runtime/service-directory
|
1.2/sd-client/src/main/java/ServiceDirectoryClient.java
|
ServiceDirectoryClient.lookupInstance
|
private void lookupInstance(String args[]) {
String serviceName = args[1];
System.out.println("lookupInstance, serviceName=" + serviceName);
try {
ServiceInstance instance = ServiceDirectory.getLookupManager().lookupInstance(serviceName);
printServiceInstance(instance);
} catch (ServiceException e) {
e.printStackTrace();
fail(e.getServiceDirectoryError().getErrorMessage());
}
}
|
java
|
private void lookupInstance(String args[]) {
String serviceName = args[1];
System.out.println("lookupInstance, serviceName=" + serviceName);
try {
ServiceInstance instance = ServiceDirectory.getLookupManager().lookupInstance(serviceName);
printServiceInstance(instance);
} catch (ServiceException e) {
e.printStackTrace();
fail(e.getServiceDirectoryError().getErrorMessage());
}
}
|
[
"private",
"void",
"lookupInstance",
"(",
"String",
"args",
"[",
"]",
")",
"{",
"String",
"serviceName",
"=",
"args",
"[",
"1",
"]",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"lookupInstance, serviceName=\"",
"+",
"serviceName",
")",
";",
"try",
"{",
"ServiceInstance",
"instance",
"=",
"ServiceDirectory",
".",
"getLookupManager",
"(",
")",
".",
"lookupInstance",
"(",
"serviceName",
")",
";",
"printServiceInstance",
"(",
"instance",
")",
";",
"}",
"catch",
"(",
"ServiceException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"fail",
"(",
"e",
".",
"getServiceDirectoryError",
"(",
")",
".",
"getErrorMessage",
"(",
")",
")",
";",
"}",
"}"
] |
Do the lookupInstance command.
|
[
"Do",
"the",
"lookupInstance",
"command",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.2/sd-client/src/main/java/ServiceDirectoryClient.java#L245-L255
|
155,047
|
foundation-runtime/service-directory
|
1.2/sd-client/src/main/java/ServiceDirectoryClient.java
|
ServiceDirectoryClient.lookupInstances
|
private void lookupInstances(String args[]) {
String serviceName = args[1];
System.out.println("lookupInstances, serviceName=" + serviceName);
try {
List<ServiceInstance> instances = ServiceDirectory.getLookupManager().lookupInstances(serviceName);
if (instances.size() == 0) {
print("");
} else {
for (ServiceInstance instance : instances) {
printServiceInstance(instance);
}
}
} catch (ServiceException e) {
e.printStackTrace();
fail(e.getServiceDirectoryError().getErrorMessage());
}
}
|
java
|
private void lookupInstances(String args[]) {
String serviceName = args[1];
System.out.println("lookupInstances, serviceName=" + serviceName);
try {
List<ServiceInstance> instances = ServiceDirectory.getLookupManager().lookupInstances(serviceName);
if (instances.size() == 0) {
print("");
} else {
for (ServiceInstance instance : instances) {
printServiceInstance(instance);
}
}
} catch (ServiceException e) {
e.printStackTrace();
fail(e.getServiceDirectoryError().getErrorMessage());
}
}
|
[
"private",
"void",
"lookupInstances",
"(",
"String",
"args",
"[",
"]",
")",
"{",
"String",
"serviceName",
"=",
"args",
"[",
"1",
"]",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"lookupInstances, serviceName=\"",
"+",
"serviceName",
")",
";",
"try",
"{",
"List",
"<",
"ServiceInstance",
">",
"instances",
"=",
"ServiceDirectory",
".",
"getLookupManager",
"(",
")",
".",
"lookupInstances",
"(",
"serviceName",
")",
";",
"if",
"(",
"instances",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"print",
"(",
"\"\"",
")",
";",
"}",
"else",
"{",
"for",
"(",
"ServiceInstance",
"instance",
":",
"instances",
")",
"{",
"printServiceInstance",
"(",
"instance",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"ServiceException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"fail",
"(",
"e",
".",
"getServiceDirectoryError",
"(",
")",
".",
"getErrorMessage",
"(",
")",
")",
";",
"}",
"}"
] |
Do the lookupInstances command.
|
[
"Do",
"the",
"lookupInstances",
"command",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.2/sd-client/src/main/java/ServiceDirectoryClient.java#L260-L276
|
155,048
|
foundation-runtime/service-directory
|
1.2/sd-client/src/main/java/ServiceDirectoryClient.java
|
ServiceDirectoryClient.jsonToProvidedServiceInstance
|
private ProvidedServiceInstance jsonToProvidedServiceInstance(String jsonString) throws JsonParseException, JsonMappingException, IOException{
return deserialize(jsonString.getBytes(), ProvidedServiceInstance.class);
}
|
java
|
private ProvidedServiceInstance jsonToProvidedServiceInstance(String jsonString) throws JsonParseException, JsonMappingException, IOException{
return deserialize(jsonString.getBytes(), ProvidedServiceInstance.class);
}
|
[
"private",
"ProvidedServiceInstance",
"jsonToProvidedServiceInstance",
"(",
"String",
"jsonString",
")",
"throws",
"JsonParseException",
",",
"JsonMappingException",
",",
"IOException",
"{",
"return",
"deserialize",
"(",
"jsonString",
".",
"getBytes",
"(",
")",
",",
"ProvidedServiceInstance",
".",
"class",
")",
";",
"}"
] |
Convert the ProvidedServiceInstance Json String to ProvidedServiceInstance.
@param jsonString
the ProvidedServiceInstance Json String.
@return
the ProvidedServiceInstance Object.
@throws JsonParseException
@throws JsonMappingException
@throws IOException
|
[
"Convert",
"the",
"ProvidedServiceInstance",
"Json",
"String",
"to",
"ProvidedServiceInstance",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.2/sd-client/src/main/java/ServiceDirectoryClient.java#L310-L312
|
155,049
|
foundation-runtime/service-directory
|
1.2/sd-client/src/main/java/ServiceDirectoryClient.java
|
ServiceDirectoryClient.printServiceInstance
|
private void printServiceInstance(ServiceInstance instance) {
print("\nServiceInstance\n-------------------------");
if (instance == null) {
print("null");
return;
}
print("serviceName: " + instance.getServiceName());
print("status: " + instance.getStatus());
print("uri: " + instance.getUri());
print("address: " + instance.getAddress());
print("monitorEnabled: " + instance.isMonitorEnabled());
print("metadata:");
Map<String, String> meta = instance.getMetadata();
for (Entry<String, String> entry : meta.entrySet()) {
print(" " + entry.getKey() + " => " + entry.getValue());
}
}
|
java
|
private void printServiceInstance(ServiceInstance instance) {
print("\nServiceInstance\n-------------------------");
if (instance == null) {
print("null");
return;
}
print("serviceName: " + instance.getServiceName());
print("status: " + instance.getStatus());
print("uri: " + instance.getUri());
print("address: " + instance.getAddress());
print("monitorEnabled: " + instance.isMonitorEnabled());
print("metadata:");
Map<String, String> meta = instance.getMetadata();
for (Entry<String, String> entry : meta.entrySet()) {
print(" " + entry.getKey() + " => " + entry.getValue());
}
}
|
[
"private",
"void",
"printServiceInstance",
"(",
"ServiceInstance",
"instance",
")",
"{",
"print",
"(",
"\"\\nServiceInstance\\n-------------------------\"",
")",
";",
"if",
"(",
"instance",
"==",
"null",
")",
"{",
"print",
"(",
"\"null\"",
")",
";",
"return",
";",
"}",
"print",
"(",
"\"serviceName: \"",
"+",
"instance",
".",
"getServiceName",
"(",
")",
")",
";",
"print",
"(",
"\"status: \"",
"+",
"instance",
".",
"getStatus",
"(",
")",
")",
";",
"print",
"(",
"\"uri: \"",
"+",
"instance",
".",
"getUri",
"(",
")",
")",
";",
"print",
"(",
"\"address: \"",
"+",
"instance",
".",
"getAddress",
"(",
")",
")",
";",
"print",
"(",
"\"monitorEnabled: \"",
"+",
"instance",
".",
"isMonitorEnabled",
"(",
")",
")",
";",
"print",
"(",
"\"metadata:\"",
")",
";",
"Map",
"<",
"String",
",",
"String",
">",
"meta",
"=",
"instance",
".",
"getMetadata",
"(",
")",
";",
"for",
"(",
"Entry",
"<",
"String",
",",
"String",
">",
"entry",
":",
"meta",
".",
"entrySet",
"(",
")",
")",
"{",
"print",
"(",
"\" \"",
"+",
"entry",
".",
"getKey",
"(",
")",
"+",
"\" => \"",
"+",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}"
] |
Print the ServiceInstance to console.
@param instance the ServiceInstance.
|
[
"Print",
"the",
"ServiceInstance",
"to",
"console",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.2/sd-client/src/main/java/ServiceDirectoryClient.java#L327-L343
|
155,050
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/RegistrationManagerImpl.java
|
RegistrationManagerImpl.stop
|
@Override
public void stop(){
if (isStarted) {
synchronized (this) {
if (isStarted) {
if (getRegistrationService() instanceof Closable) {
((Closable) getRegistrationService()).stop();
}
isStarted = false;
}
}
}
}
|
java
|
@Override
public void stop(){
if (isStarted) {
synchronized (this) {
if (isStarted) {
if (getRegistrationService() instanceof Closable) {
((Closable) getRegistrationService()).stop();
}
isStarted = false;
}
}
}
}
|
[
"@",
"Override",
"public",
"void",
"stop",
"(",
")",
"{",
"if",
"(",
"isStarted",
")",
"{",
"synchronized",
"(",
"this",
")",
"{",
"if",
"(",
"isStarted",
")",
"{",
"if",
"(",
"getRegistrationService",
"(",
")",
"instanceof",
"Closable",
")",
"{",
"(",
"(",
"Closable",
")",
"getRegistrationService",
"(",
")",
")",
".",
"stop",
"(",
")",
";",
"}",
"isStarted",
"=",
"false",
";",
"}",
"}",
"}",
"}"
] |
Stop the RegistrationManagerImpl
it is idempotent, it can be invoked in multiple times while in same state. But not thread safe.
|
[
"Stop",
"the",
"RegistrationManagerImpl"
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/RegistrationManagerImpl.java#L91-L104
|
155,051
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/config/ConfigParams.java
|
ConfigParams.getSectionNames
|
public List<String> getSectionNames() {
List<String> sections = new ArrayList<String>();
for (Map.Entry<String, String> entry : this.entrySet()) {
String key = entry.getKey();
int pos = key.indexOf('.');
if (pos > 0)
key = key.substring(0, pos);
// Perform case sensitive search
boolean found = false;
for (String section : sections) {
if (section.equalsIgnoreCase(key)) {
found = true;
break;
}
}
if (!found)
sections.add(key);
}
return sections;
}
|
java
|
public List<String> getSectionNames() {
List<String> sections = new ArrayList<String>();
for (Map.Entry<String, String> entry : this.entrySet()) {
String key = entry.getKey();
int pos = key.indexOf('.');
if (pos > 0)
key = key.substring(0, pos);
// Perform case sensitive search
boolean found = false;
for (String section : sections) {
if (section.equalsIgnoreCase(key)) {
found = true;
break;
}
}
if (!found)
sections.add(key);
}
return sections;
}
|
[
"public",
"List",
"<",
"String",
">",
"getSectionNames",
"(",
")",
"{",
"List",
"<",
"String",
">",
"sections",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"String",
">",
"entry",
":",
"this",
".",
"entrySet",
"(",
")",
")",
"{",
"String",
"key",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"int",
"pos",
"=",
"key",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"pos",
">",
"0",
")",
"key",
"=",
"key",
".",
"substring",
"(",
"0",
",",
"pos",
")",
";",
"// Perform case sensitive search",
"boolean",
"found",
"=",
"false",
";",
"for",
"(",
"String",
"section",
":",
"sections",
")",
"{",
"if",
"(",
"section",
".",
"equalsIgnoreCase",
"(",
"key",
")",
")",
"{",
"found",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"!",
"found",
")",
"sections",
".",
"add",
"(",
"key",
")",
";",
"}",
"return",
"sections",
";",
"}"
] |
Gets a list with all 1st level section names.
@return a list of section names stored in this ConfigMap.
|
[
"Gets",
"a",
"list",
"with",
"all",
"1st",
"level",
"section",
"names",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/config/ConfigParams.java#L68-L91
|
155,052
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/config/ConfigParams.java
|
ConfigParams.getSection
|
public ConfigParams getSection(String section) {
ConfigParams result = new ConfigParams();
String prefix = section + ".";
for (Map.Entry<String, String> entry : this.entrySet()) {
String key = entry.getKey();
// Prevents exception on the next line
if (key.length() < prefix.length())
continue;
// Perform case sensitive match
String keyPrefix = key.substring(0, prefix.length());
if (keyPrefix.equalsIgnoreCase(prefix)) {
key = key.substring(prefix.length());
result.put(key, entry.getValue());
}
}
return result;
}
|
java
|
public ConfigParams getSection(String section) {
ConfigParams result = new ConfigParams();
String prefix = section + ".";
for (Map.Entry<String, String> entry : this.entrySet()) {
String key = entry.getKey();
// Prevents exception on the next line
if (key.length() < prefix.length())
continue;
// Perform case sensitive match
String keyPrefix = key.substring(0, prefix.length());
if (keyPrefix.equalsIgnoreCase(prefix)) {
key = key.substring(prefix.length());
result.put(key, entry.getValue());
}
}
return result;
}
|
[
"public",
"ConfigParams",
"getSection",
"(",
"String",
"section",
")",
"{",
"ConfigParams",
"result",
"=",
"new",
"ConfigParams",
"(",
")",
";",
"String",
"prefix",
"=",
"section",
"+",
"\".\"",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"String",
">",
"entry",
":",
"this",
".",
"entrySet",
"(",
")",
")",
"{",
"String",
"key",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"// Prevents exception on the next line",
"if",
"(",
"key",
".",
"length",
"(",
")",
"<",
"prefix",
".",
"length",
"(",
")",
")",
"continue",
";",
"// Perform case sensitive match",
"String",
"keyPrefix",
"=",
"key",
".",
"substring",
"(",
"0",
",",
"prefix",
".",
"length",
"(",
")",
")",
";",
"if",
"(",
"keyPrefix",
".",
"equalsIgnoreCase",
"(",
"prefix",
")",
")",
"{",
"key",
"=",
"key",
".",
"substring",
"(",
"prefix",
".",
"length",
"(",
")",
")",
";",
"result",
".",
"put",
"(",
"key",
",",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
] |
Gets parameters from specific section stored in this ConfigMap. The section
name is removed from parameter keys.
@param section name of the section to retrieve configuration parameters from.
@return all configuration parameters that belong to the section named
'section'.
|
[
"Gets",
"parameters",
"from",
"specific",
"section",
"stored",
"in",
"this",
"ConfigMap",
".",
"The",
"section",
"name",
"is",
"removed",
"from",
"parameter",
"keys",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/config/ConfigParams.java#L101-L121
|
155,053
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/config/ConfigParams.java
|
ConfigParams.addSection
|
public void addSection(String section, ConfigParams sectionParams) {
if (section == null)
throw new NullPointerException("Section name cannot be null");
if (sectionParams != null) {
for (Map.Entry<String, String> entry : sectionParams.entrySet()) {
String key = entry.getKey();
if (key.length() > 0 && section.length() > 0)
key = section + "." + key;
else if (key.length() == 0)
key = section;
String value = entry.getValue();
put(key, value);
}
}
}
|
java
|
public void addSection(String section, ConfigParams sectionParams) {
if (section == null)
throw new NullPointerException("Section name cannot be null");
if (sectionParams != null) {
for (Map.Entry<String, String> entry : sectionParams.entrySet()) {
String key = entry.getKey();
if (key.length() > 0 && section.length() > 0)
key = section + "." + key;
else if (key.length() == 0)
key = section;
String value = entry.getValue();
put(key, value);
}
}
}
|
[
"public",
"void",
"addSection",
"(",
"String",
"section",
",",
"ConfigParams",
"sectionParams",
")",
"{",
"if",
"(",
"section",
"==",
"null",
")",
"throw",
"new",
"NullPointerException",
"(",
"\"Section name cannot be null\"",
")",
";",
"if",
"(",
"sectionParams",
"!=",
"null",
")",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"String",
">",
"entry",
":",
"sectionParams",
".",
"entrySet",
"(",
")",
")",
"{",
"String",
"key",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"if",
"(",
"key",
".",
"length",
"(",
")",
">",
"0",
"&&",
"section",
".",
"length",
"(",
")",
">",
"0",
")",
"key",
"=",
"section",
"+",
"\".\"",
"+",
"key",
";",
"else",
"if",
"(",
"key",
".",
"length",
"(",
")",
"==",
"0",
")",
"key",
"=",
"section",
";",
"String",
"value",
"=",
"entry",
".",
"getValue",
"(",
")",
";",
"put",
"(",
"key",
",",
"value",
")",
";",
"}",
"}",
"}"
] |
Adds parameters into this ConfigParams under specified section. Keys for the
new parameters are appended with section dot prefix.
@param section name of the section where add new parameters
@param sectionParams new parameters to be added.
|
[
"Adds",
"parameters",
"into",
"this",
"ConfigParams",
"under",
"specified",
"section",
".",
"Keys",
"for",
"the",
"new",
"parameters",
"are",
"appended",
"with",
"section",
"dot",
"prefix",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/config/ConfigParams.java#L130-L148
|
155,054
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/config/ConfigParams.java
|
ConfigParams.override
|
public ConfigParams override(ConfigParams configParams) {
StringValueMap map = StringValueMap.fromMaps(this, configParams);
return new ConfigParams(map);
}
|
java
|
public ConfigParams override(ConfigParams configParams) {
StringValueMap map = StringValueMap.fromMaps(this, configParams);
return new ConfigParams(map);
}
|
[
"public",
"ConfigParams",
"override",
"(",
"ConfigParams",
"configParams",
")",
"{",
"StringValueMap",
"map",
"=",
"StringValueMap",
".",
"fromMaps",
"(",
"this",
",",
"configParams",
")",
";",
"return",
"new",
"ConfigParams",
"(",
"map",
")",
";",
"}"
] |
Overrides parameters with new values from specified ConfigParams and returns
a new ConfigParams object.
@param configParams ConfigMap with parameters to override the current values.
@return a new ConfigParams object.
@see ConfigParams#setDefaults(ConfigParams)
|
[
"Overrides",
"parameters",
"with",
"new",
"values",
"from",
"specified",
"ConfigParams",
"and",
"returns",
"a",
"new",
"ConfigParams",
"object",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/config/ConfigParams.java#L159-L162
|
155,055
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/config/ConfigParams.java
|
ConfigParams.setDefaults
|
public ConfigParams setDefaults(ConfigParams defaultConfigParams) {
StringValueMap map = StringValueMap.fromMaps(defaultConfigParams, this);
return new ConfigParams(map);
}
|
java
|
public ConfigParams setDefaults(ConfigParams defaultConfigParams) {
StringValueMap map = StringValueMap.fromMaps(defaultConfigParams, this);
return new ConfigParams(map);
}
|
[
"public",
"ConfigParams",
"setDefaults",
"(",
"ConfigParams",
"defaultConfigParams",
")",
"{",
"StringValueMap",
"map",
"=",
"StringValueMap",
".",
"fromMaps",
"(",
"defaultConfigParams",
",",
"this",
")",
";",
"return",
"new",
"ConfigParams",
"(",
"map",
")",
";",
"}"
] |
Set default values from specified ConfigParams and returns a new ConfigParams
object.
@param defaultConfigParams ConfigMap with default parameter values.
@return a new ConfigParams object.
@see ConfigParams#override(ConfigParams)
|
[
"Set",
"default",
"values",
"from",
"specified",
"ConfigParams",
"and",
"returns",
"a",
"new",
"ConfigParams",
"object",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/config/ConfigParams.java#L173-L176
|
155,056
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/config/ConfigParams.java
|
ConfigParams.fromValue
|
public static ConfigParams fromValue(Object value) {
Map<String, Object> map = RecursiveObjectReader.getProperties(value);
return new ConfigParams(map);
}
|
java
|
public static ConfigParams fromValue(Object value) {
Map<String, Object> map = RecursiveObjectReader.getProperties(value);
return new ConfigParams(map);
}
|
[
"public",
"static",
"ConfigParams",
"fromValue",
"(",
"Object",
"value",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"map",
"=",
"RecursiveObjectReader",
".",
"getProperties",
"(",
"value",
")",
";",
"return",
"new",
"ConfigParams",
"(",
"map",
")",
";",
"}"
] |
Creates a new ConfigParams object filled with key-value pairs from specified
object.
@param value an object with key-value pairs used to initialize a new
ConfigParams.
@return a new ConfigParams object.
@see RecursiveObjectReader#getProperties(Object)
|
[
"Creates",
"a",
"new",
"ConfigParams",
"object",
"filled",
"with",
"key",
"-",
"value",
"pairs",
"from",
"specified",
"object",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/config/ConfigParams.java#L188-L191
|
155,057
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/config/ConfigParams.java
|
ConfigParams.fromTuples
|
public static ConfigParams fromTuples(Object... tuples) {
StringValueMap map = StringValueMap.fromTuplesArray(tuples);
return new ConfigParams(map);
}
|
java
|
public static ConfigParams fromTuples(Object... tuples) {
StringValueMap map = StringValueMap.fromTuplesArray(tuples);
return new ConfigParams(map);
}
|
[
"public",
"static",
"ConfigParams",
"fromTuples",
"(",
"Object",
"...",
"tuples",
")",
"{",
"StringValueMap",
"map",
"=",
"StringValueMap",
".",
"fromTuplesArray",
"(",
"tuples",
")",
";",
"return",
"new",
"ConfigParams",
"(",
"map",
")",
";",
"}"
] |
Creates a new ConfigParams object filled with provided key-value pairs called
tuples. Tuples parameters contain a sequence of key1, value1, key2, value2,
... pairs.
@param tuples the tuples to fill a new ConfigParams object.
@return a new ConfigParams object.
@see StringValueMap#fromTuplesArray(Object[])
|
[
"Creates",
"a",
"new",
"ConfigParams",
"object",
"filled",
"with",
"provided",
"key",
"-",
"value",
"pairs",
"called",
"tuples",
".",
"Tuples",
"parameters",
"contain",
"a",
"sequence",
"of",
"key1",
"value1",
"key2",
"value2",
"...",
"pairs",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/config/ConfigParams.java#L203-L206
|
155,058
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/config/ConfigParams.java
|
ConfigParams.fromString
|
public static ConfigParams fromString(String line) {
StringValueMap map = StringValueMap.fromString(line);
return new ConfigParams(map);
}
|
java
|
public static ConfigParams fromString(String line) {
StringValueMap map = StringValueMap.fromString(line);
return new ConfigParams(map);
}
|
[
"public",
"static",
"ConfigParams",
"fromString",
"(",
"String",
"line",
")",
"{",
"StringValueMap",
"map",
"=",
"StringValueMap",
".",
"fromString",
"(",
"line",
")",
";",
"return",
"new",
"ConfigParams",
"(",
"map",
")",
";",
"}"
] |
Creates a new ConfigParams object filled with key-value pairs serialized as a
string.
@param line a string with serialized key-value pairs as
"key1=value1;key2=value2;..." Example:
"Key1=123;Key2=ABC;Key3=2016-09-16T00:00:00.00Z"
@return a new ConfigParams object.
@see StringValueMap#fromString(String)
|
[
"Creates",
"a",
"new",
"ConfigParams",
"object",
"filled",
"with",
"key",
"-",
"value",
"pairs",
"serialized",
"as",
"a",
"string",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/config/ConfigParams.java#L219-L222
|
155,059
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/config/ConfigParams.java
|
ConfigParams.mergeConfigs
|
public static ConfigParams mergeConfigs(ConfigParams... configs) {
StringValueMap map = StringValueMap.fromMaps(configs);
return new ConfigParams(map);
}
|
java
|
public static ConfigParams mergeConfigs(ConfigParams... configs) {
StringValueMap map = StringValueMap.fromMaps(configs);
return new ConfigParams(map);
}
|
[
"public",
"static",
"ConfigParams",
"mergeConfigs",
"(",
"ConfigParams",
"...",
"configs",
")",
"{",
"StringValueMap",
"map",
"=",
"StringValueMap",
".",
"fromMaps",
"(",
"configs",
")",
";",
"return",
"new",
"ConfigParams",
"(",
"map",
")",
";",
"}"
] |
Merges two or more ConfigParams into one. The following ConfigParams override
previously defined parameters.
@param configs a list of ConfigParams objects to be merged.
@return a new ConfigParams object.
@see StringValueMap#fromMaps(Map...)
|
[
"Merges",
"two",
"or",
"more",
"ConfigParams",
"into",
"one",
".",
"The",
"following",
"ConfigParams",
"override",
"previously",
"defined",
"parameters",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/config/ConfigParams.java#L233-L236
|
155,060
|
foundation-runtime/service-directory
|
1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/HeartbeatDirectoryRegistrationService.java
|
HeartbeatDirectoryRegistrationService.registerCachedServiceInstance
|
private void registerCachedServiceInstance(ProvidedServiceInstance instance, ServiceInstanceHealth registryHealth) {
try {
write.lock();
ServiceInstanceId id = new ServiceInstanceId(instance.getServiceName(),
instance.getProviderId());
CachedProviderServiceInstance cachedInstance = getCacheServiceInstances().get(id);
if(cachedInstance == null){
cachedInstance = new CachedProviderServiceInstance(
instance);
getCacheServiceInstances().put(id, cachedInstance);
}
if(LOGGER.isDebugEnabled()){
LOGGER.debug("add cached ProvidedServiceInstance: {}.", cachedInstance.toString());
}
cachedInstance.setServiceInstanceHealth(registryHealth);
} finally {
write.unlock();
}
}
|
java
|
private void registerCachedServiceInstance(ProvidedServiceInstance instance, ServiceInstanceHealth registryHealth) {
try {
write.lock();
ServiceInstanceId id = new ServiceInstanceId(instance.getServiceName(),
instance.getProviderId());
CachedProviderServiceInstance cachedInstance = getCacheServiceInstances().get(id);
if(cachedInstance == null){
cachedInstance = new CachedProviderServiceInstance(
instance);
getCacheServiceInstances().put(id, cachedInstance);
}
if(LOGGER.isDebugEnabled()){
LOGGER.debug("add cached ProvidedServiceInstance: {}.", cachedInstance.toString());
}
cachedInstance.setServiceInstanceHealth(registryHealth);
} finally {
write.unlock();
}
}
|
[
"private",
"void",
"registerCachedServiceInstance",
"(",
"ProvidedServiceInstance",
"instance",
",",
"ServiceInstanceHealth",
"registryHealth",
")",
"{",
"try",
"{",
"write",
".",
"lock",
"(",
")",
";",
"ServiceInstanceId",
"id",
"=",
"new",
"ServiceInstanceId",
"(",
"instance",
".",
"getServiceName",
"(",
")",
",",
"instance",
".",
"getProviderId",
"(",
")",
")",
";",
"CachedProviderServiceInstance",
"cachedInstance",
"=",
"getCacheServiceInstances",
"(",
")",
".",
"get",
"(",
"id",
")",
";",
"if",
"(",
"cachedInstance",
"==",
"null",
")",
"{",
"cachedInstance",
"=",
"new",
"CachedProviderServiceInstance",
"(",
"instance",
")",
";",
"getCacheServiceInstances",
"(",
")",
".",
"put",
"(",
"id",
",",
"cachedInstance",
")",
";",
"}",
"if",
"(",
"LOGGER",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"\"add cached ProvidedServiceInstance: {}.\"",
",",
"cachedInstance",
".",
"toString",
"(",
")",
")",
";",
"}",
"cachedInstance",
".",
"setServiceInstanceHealth",
"(",
"registryHealth",
")",
";",
"}",
"finally",
"{",
"write",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] |
Register a ProvidedServiceInstance to the Cache.
Add/update the ProvidedServiceInstance in the cache.
It is thread safe.
@param instance
the ProvidedServiceInstance.
@param registryHealth
the ServiceInstanceHealth callback.
|
[
"Register",
"a",
"ProvidedServiceInstance",
"to",
"the",
"Cache",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/HeartbeatDirectoryRegistrationService.java#L290-L310
|
155,061
|
foundation-runtime/service-directory
|
1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/HeartbeatDirectoryRegistrationService.java
|
HeartbeatDirectoryRegistrationService.editCachedServiceInstance
|
private void editCachedServiceInstance(ProvidedServiceInstance instance) {
try {
write.lock();
ServiceInstanceId id = new ServiceInstanceId(instance.getServiceName(),
instance.getProviderId());
CachedProviderServiceInstance cachedInstance = getCacheServiceInstances().get(id);
if(cachedInstance != null){
cachedInstance.setMonitorEnabled(instance.isMonitorEnabled());
cachedInstance.setStatus(instance.getStatus());
}
LOGGER.debug("update cached ProvidedServiceInstance: {}.", cachedInstance.toString());
} finally {
write.unlock();
}
}
|
java
|
private void editCachedServiceInstance(ProvidedServiceInstance instance) {
try {
write.lock();
ServiceInstanceId id = new ServiceInstanceId(instance.getServiceName(),
instance.getProviderId());
CachedProviderServiceInstance cachedInstance = getCacheServiceInstances().get(id);
if(cachedInstance != null){
cachedInstance.setMonitorEnabled(instance.isMonitorEnabled());
cachedInstance.setStatus(instance.getStatus());
}
LOGGER.debug("update cached ProvidedServiceInstance: {}.", cachedInstance.toString());
} finally {
write.unlock();
}
}
|
[
"private",
"void",
"editCachedServiceInstance",
"(",
"ProvidedServiceInstance",
"instance",
")",
"{",
"try",
"{",
"write",
".",
"lock",
"(",
")",
";",
"ServiceInstanceId",
"id",
"=",
"new",
"ServiceInstanceId",
"(",
"instance",
".",
"getServiceName",
"(",
")",
",",
"instance",
".",
"getProviderId",
"(",
")",
")",
";",
"CachedProviderServiceInstance",
"cachedInstance",
"=",
"getCacheServiceInstances",
"(",
")",
".",
"get",
"(",
"id",
")",
";",
"if",
"(",
"cachedInstance",
"!=",
"null",
")",
"{",
"cachedInstance",
".",
"setMonitorEnabled",
"(",
"instance",
".",
"isMonitorEnabled",
"(",
")",
")",
";",
"cachedInstance",
".",
"setStatus",
"(",
"instance",
".",
"getStatus",
"(",
")",
")",
";",
"}",
"LOGGER",
".",
"debug",
"(",
"\"update cached ProvidedServiceInstance: {}.\"",
",",
"cachedInstance",
".",
"toString",
"(",
")",
")",
";",
"}",
"finally",
"{",
"write",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] |
Edit the Cached ProvidedServiceInstance when updateService is called.
It is thread safe.
@param instance
the ProvidedServiceInstance.
|
[
"Edit",
"the",
"Cached",
"ProvidedServiceInstance",
"when",
"updateService",
"is",
"called",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/HeartbeatDirectoryRegistrationService.java#L320-L336
|
155,062
|
foundation-runtime/service-directory
|
1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/HeartbeatDirectoryRegistrationService.java
|
HeartbeatDirectoryRegistrationService.getCachedServiceInstance
|
private CachedProviderServiceInstance getCachedServiceInstance(
String serviceName, String providerId) {
try {
read.lock();
ServiceInstanceId id = new ServiceInstanceId(serviceName, providerId);
return getCacheServiceInstances().get(id);
} finally {
read.unlock();
}
}
|
java
|
private CachedProviderServiceInstance getCachedServiceInstance(
String serviceName, String providerId) {
try {
read.lock();
ServiceInstanceId id = new ServiceInstanceId(serviceName, providerId);
return getCacheServiceInstances().get(id);
} finally {
read.unlock();
}
}
|
[
"private",
"CachedProviderServiceInstance",
"getCachedServiceInstance",
"(",
"String",
"serviceName",
",",
"String",
"providerId",
")",
"{",
"try",
"{",
"read",
".",
"lock",
"(",
")",
";",
"ServiceInstanceId",
"id",
"=",
"new",
"ServiceInstanceId",
"(",
"serviceName",
",",
"providerId",
")",
";",
"return",
"getCacheServiceInstances",
"(",
")",
".",
"get",
"(",
"id",
")",
";",
"}",
"finally",
"{",
"read",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] |
Get the Cached ProvidedServiceInstance by serviceName and providerId.
It is thread safe.
@param serviceName
the serviceName
@param providerId
the providerId
@return
the CachedProviderServiceInstance
|
[
"Get",
"the",
"Cached",
"ProvidedServiceInstance",
"by",
"serviceName",
"and",
"providerId",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/HeartbeatDirectoryRegistrationService.java#L350-L359
|
155,063
|
foundation-runtime/service-directory
|
1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/HeartbeatDirectoryRegistrationService.java
|
HeartbeatDirectoryRegistrationService.unregisterCachedServiceInstance
|
private void unregisterCachedServiceInstance(
String serviceName, String providerId) {
try {
write.lock();
ServiceInstanceId id = new ServiceInstanceId(serviceName, providerId);
getCacheServiceInstances().remove(id);
LOGGER.debug(
"delete cached ProvidedServiceInstance, serviceName={}, providerId={}.",
serviceName, providerId);
} finally {
write.unlock();
}
}
|
java
|
private void unregisterCachedServiceInstance(
String serviceName, String providerId) {
try {
write.lock();
ServiceInstanceId id = new ServiceInstanceId(serviceName, providerId);
getCacheServiceInstances().remove(id);
LOGGER.debug(
"delete cached ProvidedServiceInstance, serviceName={}, providerId={}.",
serviceName, providerId);
} finally {
write.unlock();
}
}
|
[
"private",
"void",
"unregisterCachedServiceInstance",
"(",
"String",
"serviceName",
",",
"String",
"providerId",
")",
"{",
"try",
"{",
"write",
".",
"lock",
"(",
")",
";",
"ServiceInstanceId",
"id",
"=",
"new",
"ServiceInstanceId",
"(",
"serviceName",
",",
"providerId",
")",
";",
"getCacheServiceInstances",
"(",
")",
".",
"remove",
"(",
"id",
")",
";",
"LOGGER",
".",
"debug",
"(",
"\"delete cached ProvidedServiceInstance, serviceName={}, providerId={}.\"",
",",
"serviceName",
",",
"providerId",
")",
";",
"}",
"finally",
"{",
"write",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] |
Delete the Cached ProvidedServiceInstance by serviceName and providerId.
It is thread safe.
@param serviceName
the serviceName.
@param providerId
the providerId.
|
[
"Delete",
"the",
"Cached",
"ProvidedServiceInstance",
"by",
"serviceName",
"and",
"providerId",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/HeartbeatDirectoryRegistrationService.java#L371-L383
|
155,064
|
app55/app55-java
|
src/support/java/com/googlecode/openbeans/beancontext/BeanContextServicesSupport.java
|
BeanContextServicesSupport.releaseServicesForChild
|
private void releaseServicesForChild(BCSSChild bcssChild, boolean delegatedServices)
{
if (bcssChild.serviceRecords == null || bcssChild.serviceRecords.isEmpty())
{
return;
}
synchronized (bcssChild.child)
{
Object records[] = bcssChild.serviceRecords.toArray();
for (int i = 0; i < records.length; i++)
{
ServiceRecord rec = (ServiceRecord) records[i];
if (delegatedServices)
{
if (rec.isDelegate)
{
releaseServiceWithoutCheck(rec.child, bcssChild, rec.requestor, rec.service, true);
}
}
else
{
releaseServiceWithoutCheck(rec.child, bcssChild, rec.requestor, rec.service, false);
}
}
}
}
|
java
|
private void releaseServicesForChild(BCSSChild bcssChild, boolean delegatedServices)
{
if (bcssChild.serviceRecords == null || bcssChild.serviceRecords.isEmpty())
{
return;
}
synchronized (bcssChild.child)
{
Object records[] = bcssChild.serviceRecords.toArray();
for (int i = 0; i < records.length; i++)
{
ServiceRecord rec = (ServiceRecord) records[i];
if (delegatedServices)
{
if (rec.isDelegate)
{
releaseServiceWithoutCheck(rec.child, bcssChild, rec.requestor, rec.service, true);
}
}
else
{
releaseServiceWithoutCheck(rec.child, bcssChild, rec.requestor, rec.service, false);
}
}
}
}
|
[
"private",
"void",
"releaseServicesForChild",
"(",
"BCSSChild",
"bcssChild",
",",
"boolean",
"delegatedServices",
")",
"{",
"if",
"(",
"bcssChild",
".",
"serviceRecords",
"==",
"null",
"||",
"bcssChild",
".",
"serviceRecords",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
";",
"}",
"synchronized",
"(",
"bcssChild",
".",
"child",
")",
"{",
"Object",
"records",
"[",
"]",
"=",
"bcssChild",
".",
"serviceRecords",
".",
"toArray",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"records",
".",
"length",
";",
"i",
"++",
")",
"{",
"ServiceRecord",
"rec",
"=",
"(",
"ServiceRecord",
")",
"records",
"[",
"i",
"]",
";",
"if",
"(",
"delegatedServices",
")",
"{",
"if",
"(",
"rec",
".",
"isDelegate",
")",
"{",
"releaseServiceWithoutCheck",
"(",
"rec",
".",
"child",
",",
"bcssChild",
",",
"rec",
".",
"requestor",
",",
"rec",
".",
"service",
",",
"true",
")",
";",
"}",
"}",
"else",
"{",
"releaseServiceWithoutCheck",
"(",
"rec",
".",
"child",
",",
"bcssChild",
",",
"rec",
".",
"requestor",
",",
"rec",
".",
"service",
",",
"false",
")",
";",
"}",
"}",
"}",
"}"
] |
Release all services requested by the given child.
@param bcssChild
a child
@param delegatedServices
only release services that are delegated to parent context
|
[
"Release",
"all",
"services",
"requested",
"by",
"the",
"given",
"child",
"."
] |
73e51d0f3141a859dfbd37ca9becef98477e553e
|
https://github.com/app55/app55-java/blob/73e51d0f3141a859dfbd37ca9becef98477e553e/src/support/java/com/googlecode/openbeans/beancontext/BeanContextServicesSupport.java#L469-L494
|
155,065
|
app55/app55-java
|
src/support/java/com/googlecode/openbeans/beancontext/BeanContextServicesSupport.java
|
BeanContextServicesSupport.getService
|
public Object getService(BeanContextChild child, Object requestor, Class serviceClass, Object serviceSelector, BeanContextServiceRevokedListener bcsrl)
throws TooManyListenersException
{
if (child == null || requestor == null || serviceClass == null || bcsrl == null)
{
throw new NullPointerException();
}
BCSSChild bcssChild = null;
BeanContextServiceProvider provider = null;
Object service = null;
boolean isDelegate = false;
synchronized (globalHierarchyLock)
{
// check child
synchronized (children)
{
bcssChild = (BCSSChild) children.get(child);
}
if (bcssChild == null)
{
throw new IllegalArgumentException(Messages.getString("beans.65"));
}
// try local service
provider = getLocalServiceProvider(serviceClass);
if (provider != null)
{
service = provider.getService(getBeanContextServicesPeer(), requestor, serviceClass, serviceSelector);
}
// no local service, try delegate
if (service == null && proxy != null)
{
provider = proxy;
service = proxy.getService(getBeanContextServicesPeer(), requestor, serviceClass, serviceSelector, bcsrl);
isDelegate = true;
}
}
if (service != null)
{
// save record
synchronized (child)
{
if (bcssChild.serviceRecords == null)
{
bcssChild.serviceRecords = new ArrayList<ServiceRecord>();
}
bcssChild.serviceRecords.add(new ServiceRecord(provider, child, requestor, serviceClass, bcsrl, service, isDelegate));
}
}
return service;
}
|
java
|
public Object getService(BeanContextChild child, Object requestor, Class serviceClass, Object serviceSelector, BeanContextServiceRevokedListener bcsrl)
throws TooManyListenersException
{
if (child == null || requestor == null || serviceClass == null || bcsrl == null)
{
throw new NullPointerException();
}
BCSSChild bcssChild = null;
BeanContextServiceProvider provider = null;
Object service = null;
boolean isDelegate = false;
synchronized (globalHierarchyLock)
{
// check child
synchronized (children)
{
bcssChild = (BCSSChild) children.get(child);
}
if (bcssChild == null)
{
throw new IllegalArgumentException(Messages.getString("beans.65"));
}
// try local service
provider = getLocalServiceProvider(serviceClass);
if (provider != null)
{
service = provider.getService(getBeanContextServicesPeer(), requestor, serviceClass, serviceSelector);
}
// no local service, try delegate
if (service == null && proxy != null)
{
provider = proxy;
service = proxy.getService(getBeanContextServicesPeer(), requestor, serviceClass, serviceSelector, bcsrl);
isDelegate = true;
}
}
if (service != null)
{
// save record
synchronized (child)
{
if (bcssChild.serviceRecords == null)
{
bcssChild.serviceRecords = new ArrayList<ServiceRecord>();
}
bcssChild.serviceRecords.add(new ServiceRecord(provider, child, requestor, serviceClass, bcsrl, service, isDelegate));
}
}
return service;
}
|
[
"public",
"Object",
"getService",
"(",
"BeanContextChild",
"child",
",",
"Object",
"requestor",
",",
"Class",
"serviceClass",
",",
"Object",
"serviceSelector",
",",
"BeanContextServiceRevokedListener",
"bcsrl",
")",
"throws",
"TooManyListenersException",
"{",
"if",
"(",
"child",
"==",
"null",
"||",
"requestor",
"==",
"null",
"||",
"serviceClass",
"==",
"null",
"||",
"bcsrl",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
")",
";",
"}",
"BCSSChild",
"bcssChild",
"=",
"null",
";",
"BeanContextServiceProvider",
"provider",
"=",
"null",
";",
"Object",
"service",
"=",
"null",
";",
"boolean",
"isDelegate",
"=",
"false",
";",
"synchronized",
"(",
"globalHierarchyLock",
")",
"{",
"// check child",
"synchronized",
"(",
"children",
")",
"{",
"bcssChild",
"=",
"(",
"BCSSChild",
")",
"children",
".",
"get",
"(",
"child",
")",
";",
"}",
"if",
"(",
"bcssChild",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"Messages",
".",
"getString",
"(",
"\"beans.65\"",
")",
")",
";",
"}",
"// try local service",
"provider",
"=",
"getLocalServiceProvider",
"(",
"serviceClass",
")",
";",
"if",
"(",
"provider",
"!=",
"null",
")",
"{",
"service",
"=",
"provider",
".",
"getService",
"(",
"getBeanContextServicesPeer",
"(",
")",
",",
"requestor",
",",
"serviceClass",
",",
"serviceSelector",
")",
";",
"}",
"// no local service, try delegate",
"if",
"(",
"service",
"==",
"null",
"&&",
"proxy",
"!=",
"null",
")",
"{",
"provider",
"=",
"proxy",
";",
"service",
"=",
"proxy",
".",
"getService",
"(",
"getBeanContextServicesPeer",
"(",
")",
",",
"requestor",
",",
"serviceClass",
",",
"serviceSelector",
",",
"bcsrl",
")",
";",
"isDelegate",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"service",
"!=",
"null",
")",
"{",
"// save record",
"synchronized",
"(",
"child",
")",
"{",
"if",
"(",
"bcssChild",
".",
"serviceRecords",
"==",
"null",
")",
"{",
"bcssChild",
".",
"serviceRecords",
"=",
"new",
"ArrayList",
"<",
"ServiceRecord",
">",
"(",
")",
";",
"}",
"bcssChild",
".",
"serviceRecords",
".",
"add",
"(",
"new",
"ServiceRecord",
"(",
"provider",
",",
"child",
",",
"requestor",
",",
"serviceClass",
",",
"bcsrl",
",",
"service",
",",
"isDelegate",
")",
")",
";",
"}",
"}",
"return",
"service",
";",
"}"
] |
Get a service instance on behalf of the specified child of this context, by calling the registered service provider, or by delegating to the parent
context.
@param child
the child that request service
@param requestor
the requestor object
@param serviceClass
the service class
@param serviceSelector
the service selectors
@param bcsrl
the <code>BeanContextServiceRevokedListener</code>
@return a service instance on behalf of the specified child of this context
@throws IllegalArgumentException
if <code>child</code> is not a child of this context
@throws TooManyListenersException
@see com.googlecode.openbeans.beancontext.BeanContextServices#getService(com.googlecode.openbeans.beancontext.BeanContextChild, java.lang.Object,
java.lang.Class, java.lang.Object, com.googlecode.openbeans.beancontext.BeanContextServiceRevokedListener)
|
[
"Get",
"a",
"service",
"instance",
"on",
"behalf",
"of",
"the",
"specified",
"child",
"of",
"this",
"context",
"by",
"calling",
"the",
"registered",
"service",
"provider",
"or",
"by",
"delegating",
"to",
"the",
"parent",
"context",
"."
] |
73e51d0f3141a859dfbd37ca9becef98477e553e
|
https://github.com/app55/app55-java/blob/73e51d0f3141a859dfbd37ca9becef98477e553e/src/support/java/com/googlecode/openbeans/beancontext/BeanContextServicesSupport.java#L669-L724
|
155,066
|
app55/app55-java
|
src/support/java/com/googlecode/openbeans/beancontext/BeanContextServicesSupport.java
|
BeanContextServicesSupport.hasService
|
public boolean hasService(Class serviceClass)
{
if (serviceClass == null)
{
throw new NullPointerException();
}
boolean has;
synchronized (services)
{
has = services.containsKey(serviceClass);
}
if (!has && getBeanContext() instanceof BeanContextServices)
{
has = ((BeanContextServices) getBeanContext()).hasService(serviceClass);
}
return has;
}
|
java
|
public boolean hasService(Class serviceClass)
{
if (serviceClass == null)
{
throw new NullPointerException();
}
boolean has;
synchronized (services)
{
has = services.containsKey(serviceClass);
}
if (!has && getBeanContext() instanceof BeanContextServices)
{
has = ((BeanContextServices) getBeanContext()).hasService(serviceClass);
}
return has;
}
|
[
"public",
"boolean",
"hasService",
"(",
"Class",
"serviceClass",
")",
"{",
"if",
"(",
"serviceClass",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
")",
";",
"}",
"boolean",
"has",
";",
"synchronized",
"(",
"services",
")",
"{",
"has",
"=",
"services",
".",
"containsKey",
"(",
"serviceClass",
")",
";",
"}",
"if",
"(",
"!",
"has",
"&&",
"getBeanContext",
"(",
")",
"instanceof",
"BeanContextServices",
")",
"{",
"has",
"=",
"(",
"(",
"BeanContextServices",
")",
"getBeanContext",
"(",
")",
")",
".",
"hasService",
"(",
"serviceClass",
")",
";",
"}",
"return",
"has",
";",
"}"
] |
Checks whether a service is registed in this context or the parent context.
@param serviceClass
the service class
@return true if the service is registered
@see com.googlecode.openbeans.beancontext.BeanContextServices#hasService(java.lang.Class)
|
[
"Checks",
"whether",
"a",
"service",
"is",
"registed",
"in",
"this",
"context",
"or",
"the",
"parent",
"context",
"."
] |
73e51d0f3141a859dfbd37ca9becef98477e553e
|
https://github.com/app55/app55-java/blob/73e51d0f3141a859dfbd37ca9becef98477e553e/src/support/java/com/googlecode/openbeans/beancontext/BeanContextServicesSupport.java#L734-L751
|
155,067
|
app55/app55-java
|
src/support/java/com/googlecode/openbeans/beancontext/BeanContextServicesSupport.java
|
BeanContextServicesSupport.releaseService
|
public void releaseService(BeanContextChild child, Object requestor, Object service)
{
if (child == null || requestor == null || service == null)
{
throw new NullPointerException();
}
synchronized (globalHierarchyLock)
{
BCSSChild bcssChild;
synchronized (children)
{
bcssChild = (BCSSChild) children.get(child);
}
if (bcssChild == null)
{
throw new IllegalArgumentException(Messages.getString("beans.65"));
}
releaseServiceWithoutCheck(child, bcssChild, requestor, service, false);
}
}
|
java
|
public void releaseService(BeanContextChild child, Object requestor, Object service)
{
if (child == null || requestor == null || service == null)
{
throw new NullPointerException();
}
synchronized (globalHierarchyLock)
{
BCSSChild bcssChild;
synchronized (children)
{
bcssChild = (BCSSChild) children.get(child);
}
if (bcssChild == null)
{
throw new IllegalArgumentException(Messages.getString("beans.65"));
}
releaseServiceWithoutCheck(child, bcssChild, requestor, service, false);
}
}
|
[
"public",
"void",
"releaseService",
"(",
"BeanContextChild",
"child",
",",
"Object",
"requestor",
",",
"Object",
"service",
")",
"{",
"if",
"(",
"child",
"==",
"null",
"||",
"requestor",
"==",
"null",
"||",
"service",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
")",
";",
"}",
"synchronized",
"(",
"globalHierarchyLock",
")",
"{",
"BCSSChild",
"bcssChild",
";",
"synchronized",
"(",
"children",
")",
"{",
"bcssChild",
"=",
"(",
"BCSSChild",
")",
"children",
".",
"get",
"(",
"child",
")",
";",
"}",
"if",
"(",
"bcssChild",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"Messages",
".",
"getString",
"(",
"\"beans.65\"",
")",
")",
";",
"}",
"releaseServiceWithoutCheck",
"(",
"child",
",",
"bcssChild",
",",
"requestor",
",",
"service",
",",
"false",
")",
";",
"}",
"}"
] |
Release a service which has been requested previously.
@param child
the child that request the service
@param requestor
the requestor object
@param service
the service instance
@throws IllegalArgumentException
if <code>child</code> is not a child of this context
|
[
"Release",
"a",
"service",
"which",
"has",
"been",
"requested",
"previously",
"."
] |
73e51d0f3141a859dfbd37ca9becef98477e553e
|
https://github.com/app55/app55-java/blob/73e51d0f3141a859dfbd37ca9becef98477e553e/src/support/java/com/googlecode/openbeans/beancontext/BeanContextServicesSupport.java#L824-L845
|
155,068
|
app55/app55-java
|
src/support/java/com/googlecode/openbeans/beancontext/BeanContextServicesSupport.java
|
BeanContextServicesSupport.releaseServiceWithoutCheck
|
private void releaseServiceWithoutCheck(BeanContextChild child, BCSSChild bcssChild, Object requestor, Object service, boolean callRevokedListener)
{
if (bcssChild.serviceRecords == null || bcssChild.serviceRecords.isEmpty())
{
return;
}
synchronized (child)
{
// scan record
for (Iterator iter = bcssChild.serviceRecords.iterator(); iter.hasNext();)
{
ServiceRecord rec = (ServiceRecord) iter.next();
if (rec.requestor == requestor && rec.service == service)
{
// release service
rec.provider.releaseService(getBeanContextServicesPeer(), requestor, service);
// call service revoked listener
if (callRevokedListener && rec.revokedListener != null)
{
rec.revokedListener.serviceRevoked(new BeanContextServiceRevokedEvent(getBeanContextServicesPeer(), rec.serviceClass, true));
}
// remove record
iter.remove();
break;
}
}
}
}
|
java
|
private void releaseServiceWithoutCheck(BeanContextChild child, BCSSChild bcssChild, Object requestor, Object service, boolean callRevokedListener)
{
if (bcssChild.serviceRecords == null || bcssChild.serviceRecords.isEmpty())
{
return;
}
synchronized (child)
{
// scan record
for (Iterator iter = bcssChild.serviceRecords.iterator(); iter.hasNext();)
{
ServiceRecord rec = (ServiceRecord) iter.next();
if (rec.requestor == requestor && rec.service == service)
{
// release service
rec.provider.releaseService(getBeanContextServicesPeer(), requestor, service);
// call service revoked listener
if (callRevokedListener && rec.revokedListener != null)
{
rec.revokedListener.serviceRevoked(new BeanContextServiceRevokedEvent(getBeanContextServicesPeer(), rec.serviceClass, true));
}
// remove record
iter.remove();
break;
}
}
}
}
|
[
"private",
"void",
"releaseServiceWithoutCheck",
"(",
"BeanContextChild",
"child",
",",
"BCSSChild",
"bcssChild",
",",
"Object",
"requestor",
",",
"Object",
"service",
",",
"boolean",
"callRevokedListener",
")",
"{",
"if",
"(",
"bcssChild",
".",
"serviceRecords",
"==",
"null",
"||",
"bcssChild",
".",
"serviceRecords",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
";",
"}",
"synchronized",
"(",
"child",
")",
"{",
"// scan record",
"for",
"(",
"Iterator",
"iter",
"=",
"bcssChild",
".",
"serviceRecords",
".",
"iterator",
"(",
")",
";",
"iter",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"ServiceRecord",
"rec",
"=",
"(",
"ServiceRecord",
")",
"iter",
".",
"next",
"(",
")",
";",
"if",
"(",
"rec",
".",
"requestor",
"==",
"requestor",
"&&",
"rec",
".",
"service",
"==",
"service",
")",
"{",
"// release service",
"rec",
".",
"provider",
".",
"releaseService",
"(",
"getBeanContextServicesPeer",
"(",
")",
",",
"requestor",
",",
"service",
")",
";",
"// call service revoked listener",
"if",
"(",
"callRevokedListener",
"&&",
"rec",
".",
"revokedListener",
"!=",
"null",
")",
"{",
"rec",
".",
"revokedListener",
".",
"serviceRevoked",
"(",
"new",
"BeanContextServiceRevokedEvent",
"(",
"getBeanContextServicesPeer",
"(",
")",
",",
"rec",
".",
"serviceClass",
",",
"true",
")",
")",
";",
"}",
"// remove record",
"iter",
".",
"remove",
"(",
")",
";",
"break",
";",
"}",
"}",
"}",
"}"
] |
Releases a service without checking the membership of the child.
|
[
"Releases",
"a",
"service",
"without",
"checking",
"the",
"membership",
"of",
"the",
"child",
"."
] |
73e51d0f3141a859dfbd37ca9becef98477e553e
|
https://github.com/app55/app55-java/blob/73e51d0f3141a859dfbd37ca9becef98477e553e/src/support/java/com/googlecode/openbeans/beancontext/BeanContextServicesSupport.java#L850-L879
|
155,069
|
app55/app55-java
|
src/support/java/com/googlecode/openbeans/beancontext/BeanContextServicesSupport.java
|
BeanContextServicesSupport.notifyServiceRevokedToServiceUsers
|
private void notifyServiceRevokedToServiceUsers(Class serviceClass, BeanContextServiceProvider serviceProvider, boolean revokeCurrentServicesNow)
{
synchronized (children)
{
for (Iterator iter = bcsChildren(); iter.hasNext();)
{
BCSSChild bcssChild = (BCSSChild) iter.next();
notifyServiceRevokedToServiceUsers(serviceClass, serviceProvider, revokeCurrentServicesNow, bcssChild);
}
}
}
|
java
|
private void notifyServiceRevokedToServiceUsers(Class serviceClass, BeanContextServiceProvider serviceProvider, boolean revokeCurrentServicesNow)
{
synchronized (children)
{
for (Iterator iter = bcsChildren(); iter.hasNext();)
{
BCSSChild bcssChild = (BCSSChild) iter.next();
notifyServiceRevokedToServiceUsers(serviceClass, serviceProvider, revokeCurrentServicesNow, bcssChild);
}
}
}
|
[
"private",
"void",
"notifyServiceRevokedToServiceUsers",
"(",
"Class",
"serviceClass",
",",
"BeanContextServiceProvider",
"serviceProvider",
",",
"boolean",
"revokeCurrentServicesNow",
")",
"{",
"synchronized",
"(",
"children",
")",
"{",
"for",
"(",
"Iterator",
"iter",
"=",
"bcsChildren",
"(",
")",
";",
"iter",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"BCSSChild",
"bcssChild",
"=",
"(",
"BCSSChild",
")",
"iter",
".",
"next",
"(",
")",
";",
"notifyServiceRevokedToServiceUsers",
"(",
"serviceClass",
",",
"serviceProvider",
",",
"revokeCurrentServicesNow",
",",
"bcssChild",
")",
";",
"}",
"}",
"}"
] |
Notify all children that a service has been revoked.
|
[
"Notify",
"all",
"children",
"that",
"a",
"service",
"has",
"been",
"revoked",
"."
] |
73e51d0f3141a859dfbd37ca9becef98477e553e
|
https://github.com/app55/app55-java/blob/73e51d0f3141a859dfbd37ca9becef98477e553e/src/support/java/com/googlecode/openbeans/beancontext/BeanContextServicesSupport.java#L956-L966
|
155,070
|
app55/app55-java
|
src/support/java/com/googlecode/openbeans/beancontext/BeanContextServicesSupport.java
|
BeanContextServicesSupport.notifyServiceRevokedToServiceUsers
|
private void notifyServiceRevokedToServiceUsers(Class serviceClass, BeanContextServiceProvider serviceProvider, boolean revokeCurrentServicesNow,
BCSSChild bcssChild)
{
if (bcssChild.serviceRecords == null || bcssChild.serviceRecords.isEmpty())
{
return;
}
synchronized (bcssChild.child)
{
for (Iterator it = bcssChild.serviceRecords.iterator(); it.hasNext();)
{
ServiceRecord rec = (ServiceRecord) it.next();
if (rec.serviceClass == serviceClass && rec.provider == serviceProvider && rec.revokedListener != null && !rec.isDelegate)
{
rec.revokedListener
.serviceRevoked(new BeanContextServiceRevokedEvent(getBeanContextServicesPeer(), serviceClass, revokeCurrentServicesNow));
// prevent duplicate notification
rec.revokedListener = null;
}
}
}
}
|
java
|
private void notifyServiceRevokedToServiceUsers(Class serviceClass, BeanContextServiceProvider serviceProvider, boolean revokeCurrentServicesNow,
BCSSChild bcssChild)
{
if (bcssChild.serviceRecords == null || bcssChild.serviceRecords.isEmpty())
{
return;
}
synchronized (bcssChild.child)
{
for (Iterator it = bcssChild.serviceRecords.iterator(); it.hasNext();)
{
ServiceRecord rec = (ServiceRecord) it.next();
if (rec.serviceClass == serviceClass && rec.provider == serviceProvider && rec.revokedListener != null && !rec.isDelegate)
{
rec.revokedListener
.serviceRevoked(new BeanContextServiceRevokedEvent(getBeanContextServicesPeer(), serviceClass, revokeCurrentServicesNow));
// prevent duplicate notification
rec.revokedListener = null;
}
}
}
}
|
[
"private",
"void",
"notifyServiceRevokedToServiceUsers",
"(",
"Class",
"serviceClass",
",",
"BeanContextServiceProvider",
"serviceProvider",
",",
"boolean",
"revokeCurrentServicesNow",
",",
"BCSSChild",
"bcssChild",
")",
"{",
"if",
"(",
"bcssChild",
".",
"serviceRecords",
"==",
"null",
"||",
"bcssChild",
".",
"serviceRecords",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
";",
"}",
"synchronized",
"(",
"bcssChild",
".",
"child",
")",
"{",
"for",
"(",
"Iterator",
"it",
"=",
"bcssChild",
".",
"serviceRecords",
".",
"iterator",
"(",
")",
";",
"it",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"ServiceRecord",
"rec",
"=",
"(",
"ServiceRecord",
")",
"it",
".",
"next",
"(",
")",
";",
"if",
"(",
"rec",
".",
"serviceClass",
"==",
"serviceClass",
"&&",
"rec",
".",
"provider",
"==",
"serviceProvider",
"&&",
"rec",
".",
"revokedListener",
"!=",
"null",
"&&",
"!",
"rec",
".",
"isDelegate",
")",
"{",
"rec",
".",
"revokedListener",
".",
"serviceRevoked",
"(",
"new",
"BeanContextServiceRevokedEvent",
"(",
"getBeanContextServicesPeer",
"(",
")",
",",
"serviceClass",
",",
"revokeCurrentServicesNow",
")",
")",
";",
"// prevent duplicate notification",
"rec",
".",
"revokedListener",
"=",
"null",
";",
"}",
"}",
"}",
"}"
] |
Notify the given child that a service has been revoked.
|
[
"Notify",
"the",
"given",
"child",
"that",
"a",
"service",
"has",
"been",
"revoked",
"."
] |
73e51d0f3141a859dfbd37ca9becef98477e553e
|
https://github.com/app55/app55-java/blob/73e51d0f3141a859dfbd37ca9becef98477e553e/src/support/java/com/googlecode/openbeans/beancontext/BeanContextServicesSupport.java#L971-L992
|
155,071
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMPredicate.java
|
JMPredicate.getGreater
|
public static Predicate<Number> getGreater(Number target) {
return number -> number.doubleValue() > target.doubleValue();
}
|
java
|
public static Predicate<Number> getGreater(Number target) {
return number -> number.doubleValue() > target.doubleValue();
}
|
[
"public",
"static",
"Predicate",
"<",
"Number",
">",
"getGreater",
"(",
"Number",
"target",
")",
"{",
"return",
"number",
"->",
"number",
".",
"doubleValue",
"(",
")",
">",
"target",
".",
"doubleValue",
"(",
")",
";",
"}"
] |
Gets greater.
@param target the target
@return the greater
|
[
"Gets",
"greater",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMPredicate.java#L55-L57
|
155,072
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMPredicate.java
|
JMPredicate.getGreaterOrEqual
|
public static Predicate<Number> getGreaterOrEqual(Number target) {
return number -> number.doubleValue() >= target.doubleValue();
}
|
java
|
public static Predicate<Number> getGreaterOrEqual(Number target) {
return number -> number.doubleValue() >= target.doubleValue();
}
|
[
"public",
"static",
"Predicate",
"<",
"Number",
">",
"getGreaterOrEqual",
"(",
"Number",
"target",
")",
"{",
"return",
"number",
"->",
"number",
".",
"doubleValue",
"(",
")",
">=",
"target",
".",
"doubleValue",
"(",
")",
";",
"}"
] |
Gets greater or equal.
@param target the target
@return the greater or equal
|
[
"Gets",
"greater",
"or",
"equal",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMPredicate.java#L65-L67
|
155,073
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMPredicate.java
|
JMPredicate.getLess
|
public static Predicate<Number> getLess(Number target) {
return number -> number.doubleValue() < target.doubleValue();
}
|
java
|
public static Predicate<Number> getLess(Number target) {
return number -> number.doubleValue() < target.doubleValue();
}
|
[
"public",
"static",
"Predicate",
"<",
"Number",
">",
"getLess",
"(",
"Number",
"target",
")",
"{",
"return",
"number",
"->",
"number",
".",
"doubleValue",
"(",
")",
"<",
"target",
".",
"doubleValue",
"(",
")",
";",
"}"
] |
Gets less.
@param target the target
@return the less
|
[
"Gets",
"less",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMPredicate.java#L75-L77
|
155,074
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMPredicate.java
|
JMPredicate.getLessOrEqual
|
public static Predicate<Number> getLessOrEqual(Number target) {
return number -> number.doubleValue() <= target.doubleValue();
}
|
java
|
public static Predicate<Number> getLessOrEqual(Number target) {
return number -> number.doubleValue() <= target.doubleValue();
}
|
[
"public",
"static",
"Predicate",
"<",
"Number",
">",
"getLessOrEqual",
"(",
"Number",
"target",
")",
"{",
"return",
"number",
"->",
"number",
".",
"doubleValue",
"(",
")",
"<=",
"target",
".",
"doubleValue",
"(",
")",
";",
"}"
] |
Gets less or equal.
@param target the target
@return the less or equal
|
[
"Gets",
"less",
"or",
"equal",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMPredicate.java#L85-L87
|
155,075
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMPredicate.java
|
JMPredicate.peekToRun
|
public static <T> Predicate<T> peekToRun(Runnable block) {
return target -> JMLambda.getTrueAfterRunning(block);
}
|
java
|
public static <T> Predicate<T> peekToRun(Runnable block) {
return target -> JMLambda.getTrueAfterRunning(block);
}
|
[
"public",
"static",
"<",
"T",
">",
"Predicate",
"<",
"T",
">",
"peekToRun",
"(",
"Runnable",
"block",
")",
"{",
"return",
"target",
"->",
"JMLambda",
".",
"getTrueAfterRunning",
"(",
"block",
")",
";",
"}"
] |
Peek to run predicate.
@param <T> the type parameter
@param block the block
@return the predicate
|
[
"Peek",
"to",
"run",
"predicate",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMPredicate.java#L296-L298
|
155,076
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMPredicate.java
|
JMPredicate.peek
|
public static <T> Predicate<T> peek(Consumer<T> consumer) {
return target -> JMLambda
.getTrueAfterRunning(() -> consumer.accept(target));
}
|
java
|
public static <T> Predicate<T> peek(Consumer<T> consumer) {
return target -> JMLambda
.getTrueAfterRunning(() -> consumer.accept(target));
}
|
[
"public",
"static",
"<",
"T",
">",
"Predicate",
"<",
"T",
">",
"peek",
"(",
"Consumer",
"<",
"T",
">",
"consumer",
")",
"{",
"return",
"target",
"->",
"JMLambda",
".",
"getTrueAfterRunning",
"(",
"(",
")",
"->",
"consumer",
".",
"accept",
"(",
"target",
")",
")",
";",
"}"
] |
Peek predicate.
@param <T> the type parameter
@param consumer the consumer
@return the predicate
|
[
"Peek",
"predicate",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMPredicate.java#L307-L310
|
155,077
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMPredicate.java
|
JMPredicate.peekSOPL
|
public static <T> Predicate<T> peekSOPL() {
return target -> JMLambda
.getTrueAfterRunning(() -> System.out.println(target));
}
|
java
|
public static <T> Predicate<T> peekSOPL() {
return target -> JMLambda
.getTrueAfterRunning(() -> System.out.println(target));
}
|
[
"public",
"static",
"<",
"T",
">",
"Predicate",
"<",
"T",
">",
"peekSOPL",
"(",
")",
"{",
"return",
"target",
"->",
"JMLambda",
".",
"getTrueAfterRunning",
"(",
"(",
")",
"->",
"System",
".",
"out",
".",
"println",
"(",
"target",
")",
")",
";",
"}"
] |
Peek sopl predicate.
@param <T> the type parameter
@return the predicate
|
[
"Peek",
"sopl",
"predicate",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMPredicate.java#L318-L321
|
155,078
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMPredicate.java
|
JMPredicate.getEquals
|
public static <T> Predicate<T> getEquals(T target2) {
return target -> target.equals(target2);
}
|
java
|
public static <T> Predicate<T> getEquals(T target2) {
return target -> target.equals(target2);
}
|
[
"public",
"static",
"<",
"T",
">",
"Predicate",
"<",
"T",
">",
"getEquals",
"(",
"T",
"target2",
")",
"{",
"return",
"target",
"->",
"target",
".",
"equals",
"(",
"target2",
")",
";",
"}"
] |
Gets equals.
@param <T> the type parameter
@param target2 the target 2
@return the equals
|
[
"Gets",
"equals",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMPredicate.java#L330-L332
|
155,079
|
morimekta/utils
|
android-util/src/main/java/android/util/Base64.java
|
Base64.validate
|
private static int validate(byte[] decodabet, byte from) {
byte b = decodabet[from & 0x7F];
if (b < 0) {
throw new IllegalArgumentException(String.format(
"Bad Base64%s character '%s'",
(decodabet == _URL_SAFE_DECODABET ? " url safe" : ""),
escape(from)));
}
return b;
}
|
java
|
private static int validate(byte[] decodabet, byte from) {
byte b = decodabet[from & 0x7F];
if (b < 0) {
throw new IllegalArgumentException(String.format(
"Bad Base64%s character '%s'",
(decodabet == _URL_SAFE_DECODABET ? " url safe" : ""),
escape(from)));
}
return b;
}
|
[
"private",
"static",
"int",
"validate",
"(",
"byte",
"[",
"]",
"decodabet",
",",
"byte",
"from",
")",
"{",
"byte",
"b",
"=",
"decodabet",
"[",
"from",
"&",
"0x7F",
"]",
";",
"if",
"(",
"b",
"<",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"String",
".",
"format",
"(",
"\"Bad Base64%s character '%s'\"",
",",
"(",
"decodabet",
"==",
"_URL_SAFE_DECODABET",
"?",
"\" url safe\"",
":",
"\"\"",
")",
",",
"escape",
"(",
"from",
")",
")",
")",
";",
"}",
"return",
"b",
";",
"}"
] |
Validate char byte and revalculate to data byte value or throw IllegalArgumentException.
@param decodabet The decodabet to use.
@param from The char byte to check.
@return The value byte.
@throws IllegalArgumentException If the char is not valid for the alphabet.
|
[
"Validate",
"char",
"byte",
"and",
"revalculate",
"to",
"data",
"byte",
"value",
"or",
"throw",
"IllegalArgumentException",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/android-util/src/main/java/android/util/Base64.java#L552-L561
|
155,080
|
Sonoport/freesound-java
|
src/main/java/com/sonoport/freesound/query/sound/AbstractSoundUploadQuery.java
|
AbstractSoundUploadQuery.tag
|
@SuppressWarnings("unchecked")
public T tag(final String tag) {
if (this.tags == null) {
this.tags = new HashSet<>();
}
this.tags.add(tag);
return (T) this;
}
|
java
|
@SuppressWarnings("unchecked")
public T tag(final String tag) {
if (this.tags == null) {
this.tags = new HashSet<>();
}
this.tags.add(tag);
return (T) this;
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"T",
"tag",
"(",
"final",
"String",
"tag",
")",
"{",
"if",
"(",
"this",
".",
"tags",
"==",
"null",
")",
"{",
"this",
".",
"tags",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"}",
"this",
".",
"tags",
".",
"add",
"(",
"tag",
")",
";",
"return",
"(",
"T",
")",
"this",
";",
"}"
] |
Specify an individual tag associated with the sound.
@param tag The tag associated with the sound
@return The current {@link UploadSound} instance
|
[
"Specify",
"an",
"individual",
"tag",
"associated",
"with",
"the",
"sound",
"."
] |
ab029e25de068c6f8cc028bc7f916938fd97c036
|
https://github.com/Sonoport/freesound-java/blob/ab029e25de068c6f8cc028bc7f916938fd97c036/src/main/java/com/sonoport/freesound/query/sound/AbstractSoundUploadQuery.java#L163-L171
|
155,081
|
Sonoport/freesound-java
|
src/main/java/com/sonoport/freesound/query/sound/AbstractSoundUploadQuery.java
|
AbstractSoundUploadQuery.tags
|
@SuppressWarnings("unchecked")
public T tags(final Collection<String> tags) {
if (this.tags == null) {
this.tags = new HashSet<>();
}
this.tags.addAll(tags);
return (T) this;
}
|
java
|
@SuppressWarnings("unchecked")
public T tags(final Collection<String> tags) {
if (this.tags == null) {
this.tags = new HashSet<>();
}
this.tags.addAll(tags);
return (T) this;
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"T",
"tags",
"(",
"final",
"Collection",
"<",
"String",
">",
"tags",
")",
"{",
"if",
"(",
"this",
".",
"tags",
"==",
"null",
")",
"{",
"this",
".",
"tags",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"}",
"this",
".",
"tags",
".",
"addAll",
"(",
"tags",
")",
";",
"return",
"(",
"T",
")",
"this",
";",
"}"
] |
Specify the tags associated with the sound.
@param tags The tags associated with the sound
@return The current {@link UploadSound} instance
|
[
"Specify",
"the",
"tags",
"associated",
"with",
"the",
"sound",
"."
] |
ab029e25de068c6f8cc028bc7f916938fd97c036
|
https://github.com/Sonoport/freesound-java/blob/ab029e25de068c6f8cc028bc7f916938fd97c036/src/main/java/com/sonoport/freesound/query/sound/AbstractSoundUploadQuery.java#L179-L188
|
155,082
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMPath.java
|
JMPath.getFileStorePathList
|
public static List<Path> getFileStorePathList() {
return getFileStoreList().stream().map(Object::toString)
.map(toString -> toString.substring(0,
toString.indexOf(JMString.SPACE)))
.map(JMPath::getPath).collect(toList());
}
|
java
|
public static List<Path> getFileStorePathList() {
return getFileStoreList().stream().map(Object::toString)
.map(toString -> toString.substring(0,
toString.indexOf(JMString.SPACE)))
.map(JMPath::getPath).collect(toList());
}
|
[
"public",
"static",
"List",
"<",
"Path",
">",
"getFileStorePathList",
"(",
")",
"{",
"return",
"getFileStoreList",
"(",
")",
".",
"stream",
"(",
")",
".",
"map",
"(",
"Object",
"::",
"toString",
")",
".",
"map",
"(",
"toString",
"->",
"toString",
".",
"substring",
"(",
"0",
",",
"toString",
".",
"indexOf",
"(",
"JMString",
".",
"SPACE",
")",
")",
")",
".",
"map",
"(",
"JMPath",
"::",
"getPath",
")",
".",
"collect",
"(",
"toList",
"(",
")",
")",
";",
"}"
] |
Gets file store path list.
@return the file store path list
|
[
"Gets",
"file",
"store",
"path",
"list",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMPath.java#L197-L202
|
155,083
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMPath.java
|
JMPath.getParentAsOpt
|
public static Optional<Path> getParentAsOpt(Path path) {
return Optional.ofNullable(path.getParent()).filter(ExistFilter);
}
|
java
|
public static Optional<Path> getParentAsOpt(Path path) {
return Optional.ofNullable(path.getParent()).filter(ExistFilter);
}
|
[
"public",
"static",
"Optional",
"<",
"Path",
">",
"getParentAsOpt",
"(",
"Path",
"path",
")",
"{",
"return",
"Optional",
".",
"ofNullable",
"(",
"path",
".",
"getParent",
"(",
")",
")",
".",
"filter",
"(",
"ExistFilter",
")",
";",
"}"
] |
Gets parent as opt.
@param path the path
@return the parent as opt
|
[
"Gets",
"parent",
"as",
"opt",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMPath.java#L224-L226
|
155,084
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMPath.java
|
JMPath.getChildDirectoryPathStream
|
public static Stream<Path> getChildDirectoryPathStream(Path path,
Predicate<Path> filter) {
return getChildrenPathStream(path)
.filter(DirectoryAndNotSymbolicLinkFilter.and(filter));
}
|
java
|
public static Stream<Path> getChildDirectoryPathStream(Path path,
Predicate<Path> filter) {
return getChildrenPathStream(path)
.filter(DirectoryAndNotSymbolicLinkFilter.and(filter));
}
|
[
"public",
"static",
"Stream",
"<",
"Path",
">",
"getChildDirectoryPathStream",
"(",
"Path",
"path",
",",
"Predicate",
"<",
"Path",
">",
"filter",
")",
"{",
"return",
"getChildrenPathStream",
"(",
"path",
")",
".",
"filter",
"(",
"DirectoryAndNotSymbolicLinkFilter",
".",
"and",
"(",
"filter",
")",
")",
";",
"}"
] |
Gets child directory path stream.
@param path the path
@param filter the filter
@return the child directory path stream
|
[
"Gets",
"child",
"directory",
"path",
"stream",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMPath.java#L316-L320
|
155,085
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMPath.java
|
JMPath.getChildFilePathStream
|
public static Stream<Path> getChildFilePathStream(Path path,
Predicate<Path> filter) {
return getChildrenPathStream(path)
.filter(RegularFileFilter.and(filter));
}
|
java
|
public static Stream<Path> getChildFilePathStream(Path path,
Predicate<Path> filter) {
return getChildrenPathStream(path)
.filter(RegularFileFilter.and(filter));
}
|
[
"public",
"static",
"Stream",
"<",
"Path",
">",
"getChildFilePathStream",
"(",
"Path",
"path",
",",
"Predicate",
"<",
"Path",
">",
"filter",
")",
"{",
"return",
"getChildrenPathStream",
"(",
"path",
")",
".",
"filter",
"(",
"RegularFileFilter",
".",
"and",
"(",
"filter",
")",
")",
";",
"}"
] |
Gets child file path stream.
@param path the path
@param filter the filter
@return the child file path stream
|
[
"Gets",
"child",
"file",
"path",
"stream",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMPath.java#L339-L343
|
155,086
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMPath.java
|
JMPath.getAncestorPathList
|
public static List<Path> getAncestorPathList(Path startPath) {
List<Path> ancestorPathList = new ArrayList<>();
buildPathListOfAncestorDirectory(ancestorPathList, startPath);
Collections.reverse(ancestorPathList);
return ancestorPathList;
}
|
java
|
public static List<Path> getAncestorPathList(Path startPath) {
List<Path> ancestorPathList = new ArrayList<>();
buildPathListOfAncestorDirectory(ancestorPathList, startPath);
Collections.reverse(ancestorPathList);
return ancestorPathList;
}
|
[
"public",
"static",
"List",
"<",
"Path",
">",
"getAncestorPathList",
"(",
"Path",
"startPath",
")",
"{",
"List",
"<",
"Path",
">",
"ancestorPathList",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"buildPathListOfAncestorDirectory",
"(",
"ancestorPathList",
",",
"startPath",
")",
";",
"Collections",
".",
"reverse",
"(",
"ancestorPathList",
")",
";",
"return",
"ancestorPathList",
";",
"}"
] |
Gets ancestor path list.
@param startPath the start path
@return the ancestor path list
|
[
"Gets",
"ancestor",
"path",
"list",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMPath.java#L351-L356
|
155,087
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMPath.java
|
JMPath.getFilePathExtensionAsOpt
|
public static Optional<String> getFilePathExtensionAsOpt(Path path) {
return JMOptional
.getNullableAndFilteredOptional(path, RegularFileFilter)
.map(JMPath::getLastName).map(JMString::getExtension)
.filter(getIsEmpty().negate());
}
|
java
|
public static Optional<String> getFilePathExtensionAsOpt(Path path) {
return JMOptional
.getNullableAndFilteredOptional(path, RegularFileFilter)
.map(JMPath::getLastName).map(JMString::getExtension)
.filter(getIsEmpty().negate());
}
|
[
"public",
"static",
"Optional",
"<",
"String",
">",
"getFilePathExtensionAsOpt",
"(",
"Path",
"path",
")",
"{",
"return",
"JMOptional",
".",
"getNullableAndFilteredOptional",
"(",
"path",
",",
"RegularFileFilter",
")",
".",
"map",
"(",
"JMPath",
"::",
"getLastName",
")",
".",
"map",
"(",
"JMString",
"::",
"getExtension",
")",
".",
"filter",
"(",
"getIsEmpty",
"(",
")",
".",
"negate",
"(",
")",
")",
";",
"}"
] |
Gets file path extension as opt.
@param path the path
@return the file path extension as opt
|
[
"Gets",
"file",
"path",
"extension",
"as",
"opt",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMPath.java#L739-L744
|
155,088
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMPath.java
|
JMPath.extractSubPath
|
public static Path extractSubPath(Path basePath, Path sourcePath) {
return sourcePath.subpath(basePath.getNameCount() - 1,
sourcePath.getNameCount());
}
|
java
|
public static Path extractSubPath(Path basePath, Path sourcePath) {
return sourcePath.subpath(basePath.getNameCount() - 1,
sourcePath.getNameCount());
}
|
[
"public",
"static",
"Path",
"extractSubPath",
"(",
"Path",
"basePath",
",",
"Path",
"sourcePath",
")",
"{",
"return",
"sourcePath",
".",
"subpath",
"(",
"basePath",
".",
"getNameCount",
"(",
")",
"-",
"1",
",",
"sourcePath",
".",
"getNameCount",
"(",
")",
")",
";",
"}"
] |
Extract sub path path.
@param basePath the base path
@param sourcePath the source path
@return the path
|
[
"Extract",
"sub",
"path",
"path",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMPath.java#L833-L836
|
155,089
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMPath.java
|
JMPath.buildRelativeDestinationPath
|
public static Path buildRelativeDestinationPath(Path destinationDirPath,
Path baseDirPath, Path sourcePath) {
Path extractSubPath = extractSubPath(baseDirPath, sourcePath);
return destinationDirPath.resolve(extractSubPath);
}
|
java
|
public static Path buildRelativeDestinationPath(Path destinationDirPath,
Path baseDirPath, Path sourcePath) {
Path extractSubPath = extractSubPath(baseDirPath, sourcePath);
return destinationDirPath.resolve(extractSubPath);
}
|
[
"public",
"static",
"Path",
"buildRelativeDestinationPath",
"(",
"Path",
"destinationDirPath",
",",
"Path",
"baseDirPath",
",",
"Path",
"sourcePath",
")",
"{",
"Path",
"extractSubPath",
"=",
"extractSubPath",
"(",
"baseDirPath",
",",
"sourcePath",
")",
";",
"return",
"destinationDirPath",
".",
"resolve",
"(",
"extractSubPath",
")",
";",
"}"
] |
Build relative destination path path.
@param destinationDirPath the destination dir path
@param baseDirPath the base dir path
@param sourcePath the source path
@return the path
|
[
"Build",
"relative",
"destination",
"path",
"path",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMPath.java#L846-L850
|
155,090
|
FitLayout/segmentation
|
src/main/java/org/fit/segm/grouping/Config.java
|
Config.createGroupAnalyzer
|
public static GroupAnalyzer createGroupAnalyzer(AreaImpl root)
{
//return new org.fit.segm.grouping.op.GroupAnalyzerByGrouping(root);
//return new org.fit.segm.grouping.op.GroupAnalyzerBySeparators(root);
//return new org.fit.segm.grouping.op.GroupAnalyzerByGroupingAndSeparators(root);
//return new org.fit.segm.grouping.op.GroupAnalyzerByFlooding(root);
return new org.fit.segm.grouping.op.GroupAnalyzerByStyles(root, 1, false);
}
|
java
|
public static GroupAnalyzer createGroupAnalyzer(AreaImpl root)
{
//return new org.fit.segm.grouping.op.GroupAnalyzerByGrouping(root);
//return new org.fit.segm.grouping.op.GroupAnalyzerBySeparators(root);
//return new org.fit.segm.grouping.op.GroupAnalyzerByGroupingAndSeparators(root);
//return new org.fit.segm.grouping.op.GroupAnalyzerByFlooding(root);
return new org.fit.segm.grouping.op.GroupAnalyzerByStyles(root, 1, false);
}
|
[
"public",
"static",
"GroupAnalyzer",
"createGroupAnalyzer",
"(",
"AreaImpl",
"root",
")",
"{",
"//return new org.fit.segm.grouping.op.GroupAnalyzerByGrouping(root);",
"//return new org.fit.segm.grouping.op.GroupAnalyzerBySeparators(root);",
"//return new org.fit.segm.grouping.op.GroupAnalyzerByGroupingAndSeparators(root);",
"//return new org.fit.segm.grouping.op.GroupAnalyzerByFlooding(root);",
"return",
"new",
"org",
".",
"fit",
".",
"segm",
".",
"grouping",
".",
"op",
".",
"GroupAnalyzerByStyles",
"(",
"root",
",",
"1",
",",
"false",
")",
";",
"}"
] |
Creates a group analyzer for an area using the selected implementation.
@param root the root area for separator detection
@return the created group analyzer
|
[
"Creates",
"a",
"group",
"analyzer",
"for",
"an",
"area",
"using",
"the",
"selected",
"implementation",
"."
] |
12998087d576640c2f2a6360cf6088af95eea5f4
|
https://github.com/FitLayout/segmentation/blob/12998087d576640c2f2a6360cf6088af95eea5f4/src/main/java/org/fit/segm/grouping/Config.java#L51-L58
|
155,091
|
FitLayout/segmentation
|
src/main/java/org/fit/segm/grouping/Config.java
|
Config.createSeparators
|
public static SeparatorSet createSeparators(AreaImpl root)
{
SeparatorSet sset;
//sset = new SeparatorSetHV(root);
sset = new SeparatorSetHVS(root);
//sset = new SeparatorSetColumns(root);
//sset = new SeparatorSetSim(root);
//sset = new SeparatorSetGrid(root);
sset.applyFinalFilters();
return sset;
}
|
java
|
public static SeparatorSet createSeparators(AreaImpl root)
{
SeparatorSet sset;
//sset = new SeparatorSetHV(root);
sset = new SeparatorSetHVS(root);
//sset = new SeparatorSetColumns(root);
//sset = new SeparatorSetSim(root);
//sset = new SeparatorSetGrid(root);
sset.applyFinalFilters();
return sset;
}
|
[
"public",
"static",
"SeparatorSet",
"createSeparators",
"(",
"AreaImpl",
"root",
")",
"{",
"SeparatorSet",
"sset",
";",
"//sset = new SeparatorSetHV(root);",
"sset",
"=",
"new",
"SeparatorSetHVS",
"(",
"root",
")",
";",
"//sset = new SeparatorSetColumns(root);",
"//sset = new SeparatorSetSim(root);",
"//sset = new SeparatorSetGrid(root);",
"sset",
".",
"applyFinalFilters",
"(",
")",
";",
"return",
"sset",
";",
"}"
] |
Creates the separators for an area using the selected algorithm
@param root the root area
@return the created separator set
|
[
"Creates",
"the",
"separators",
"for",
"an",
"area",
"using",
"the",
"selected",
"algorithm"
] |
12998087d576640c2f2a6360cf6088af95eea5f4
|
https://github.com/FitLayout/segmentation/blob/12998087d576640c2f2a6360cf6088af95eea5f4/src/main/java/org/fit/segm/grouping/Config.java#L65-L76
|
155,092
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/util/Util.java
|
Util.binaryStream
|
public static Stream<byte[]> binaryStream(final String path, @javax.annotation.Nonnull final String name, final int skip, final int recordSize) throws IOException {
@javax.annotation.Nonnull final File file = new File(path, name);
final byte[] fileData = IOUtils.toByteArray(new BufferedInputStream(new GZIPInputStream(new BufferedInputStream(new FileInputStream(file)))));
@javax.annotation.Nonnull final DataInputStream in = new DataInputStream(new ByteArrayInputStream(fileData));
in.skip(skip);
return com.simiacryptus.util.Util.toIterator(new BinaryChunkIterator(in, recordSize));
}
|
java
|
public static Stream<byte[]> binaryStream(final String path, @javax.annotation.Nonnull final String name, final int skip, final int recordSize) throws IOException {
@javax.annotation.Nonnull final File file = new File(path, name);
final byte[] fileData = IOUtils.toByteArray(new BufferedInputStream(new GZIPInputStream(new BufferedInputStream(new FileInputStream(file)))));
@javax.annotation.Nonnull final DataInputStream in = new DataInputStream(new ByteArrayInputStream(fileData));
in.skip(skip);
return com.simiacryptus.util.Util.toIterator(new BinaryChunkIterator(in, recordSize));
}
|
[
"public",
"static",
"Stream",
"<",
"byte",
"[",
"]",
">",
"binaryStream",
"(",
"final",
"String",
"path",
",",
"@",
"javax",
".",
"annotation",
".",
"Nonnull",
"final",
"String",
"name",
",",
"final",
"int",
"skip",
",",
"final",
"int",
"recordSize",
")",
"throws",
"IOException",
"{",
"@",
"javax",
".",
"annotation",
".",
"Nonnull",
"final",
"File",
"file",
"=",
"new",
"File",
"(",
"path",
",",
"name",
")",
";",
"final",
"byte",
"[",
"]",
"fileData",
"=",
"IOUtils",
".",
"toByteArray",
"(",
"new",
"BufferedInputStream",
"(",
"new",
"GZIPInputStream",
"(",
"new",
"BufferedInputStream",
"(",
"new",
"FileInputStream",
"(",
"file",
")",
")",
")",
")",
")",
";",
"@",
"javax",
".",
"annotation",
".",
"Nonnull",
"final",
"DataInputStream",
"in",
"=",
"new",
"DataInputStream",
"(",
"new",
"ByteArrayInputStream",
"(",
"fileData",
")",
")",
";",
"in",
".",
"skip",
"(",
"skip",
")",
";",
"return",
"com",
".",
"simiacryptus",
".",
"util",
".",
"Util",
".",
"toIterator",
"(",
"new",
"BinaryChunkIterator",
"(",
"in",
",",
"recordSize",
")",
")",
";",
"}"
] |
Binary stream stream.
@param path the path
@param name the name
@param skip the skip
@param recordSize the record size
@return the stream
@throws IOException the io exception
|
[
"Binary",
"stream",
"stream",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/Util.java#L97-L103
|
155,093
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/util/Util.java
|
Util.cache
|
public static <F, T> Function<F, T> cache(@javax.annotation.Nonnull final Function<F, T> inner) {
@javax.annotation.Nonnull final LoadingCache<F, T> cache = CacheBuilder.newBuilder().build(new CacheLoader<F, T>() {
@Override
public T load(final F key) throws Exception {
return inner.apply(key);
}
});
return cache::apply;
}
|
java
|
public static <F, T> Function<F, T> cache(@javax.annotation.Nonnull final Function<F, T> inner) {
@javax.annotation.Nonnull final LoadingCache<F, T> cache = CacheBuilder.newBuilder().build(new CacheLoader<F, T>() {
@Override
public T load(final F key) throws Exception {
return inner.apply(key);
}
});
return cache::apply;
}
|
[
"public",
"static",
"<",
"F",
",",
"T",
">",
"Function",
"<",
"F",
",",
"T",
">",
"cache",
"(",
"@",
"javax",
".",
"annotation",
".",
"Nonnull",
"final",
"Function",
"<",
"F",
",",
"T",
">",
"inner",
")",
"{",
"@",
"javax",
".",
"annotation",
".",
"Nonnull",
"final",
"LoadingCache",
"<",
"F",
",",
"T",
">",
"cache",
"=",
"CacheBuilder",
".",
"newBuilder",
"(",
")",
".",
"build",
"(",
"new",
"CacheLoader",
"<",
"F",
",",
"T",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"T",
"load",
"(",
"final",
"F",
"key",
")",
"throws",
"Exception",
"{",
"return",
"inner",
".",
"apply",
"(",
"key",
")",
";",
"}",
"}",
")",
";",
"return",
"cache",
"::",
"apply",
";",
"}"
] |
Cache function.
@param <F> the type parameter
@param <T> the type parameter
@param inner the heapCopy
@return the function
|
[
"Cache",
"function",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/Util.java#L113-L121
|
155,094
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/util/Util.java
|
Util.cacheFile
|
public static File cacheFile(@javax.annotation.Nonnull final String url, @javax.annotation.Nonnull final String file) throws IOException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
if (!new File(file).exists()) {
IOUtils.copy(get(url), new FileOutputStream(file));
}
return new File(file);
}
|
java
|
public static File cacheFile(@javax.annotation.Nonnull final String url, @javax.annotation.Nonnull final String file) throws IOException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
if (!new File(file).exists()) {
IOUtils.copy(get(url), new FileOutputStream(file));
}
return new File(file);
}
|
[
"public",
"static",
"File",
"cacheFile",
"(",
"@",
"javax",
".",
"annotation",
".",
"Nonnull",
"final",
"String",
"url",
",",
"@",
"javax",
".",
"annotation",
".",
"Nonnull",
"final",
"String",
"file",
")",
"throws",
"IOException",
",",
"NoSuchAlgorithmException",
",",
"KeyStoreException",
",",
"KeyManagementException",
"{",
"if",
"(",
"!",
"new",
"File",
"(",
"file",
")",
".",
"exists",
"(",
")",
")",
"{",
"IOUtils",
".",
"copy",
"(",
"get",
"(",
"url",
")",
",",
"new",
"FileOutputStream",
"(",
"file",
")",
")",
";",
"}",
"return",
"new",
"File",
"(",
"file",
")",
";",
"}"
] |
Cache file file.
@param url the url
@param file the file
@return the file
@throws IOException the io exception
@throws NoSuchAlgorithmException the no such algorithm exception
@throws KeyStoreException the key store exception
@throws KeyManagementException the key management exception
|
[
"Cache",
"file",
"file",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/Util.java#L200-L205
|
155,095
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/util/Util.java
|
Util.cvt
|
@javax.annotation.Nonnull
public static TemporalUnit cvt(@javax.annotation.Nonnull final TimeUnit units) {
switch (units) {
case DAYS:
return ChronoUnit.DAYS;
case HOURS:
return ChronoUnit.HOURS;
case MINUTES:
return ChronoUnit.MINUTES;
case SECONDS:
return ChronoUnit.SECONDS;
case NANOSECONDS:
return ChronoUnit.NANOS;
case MICROSECONDS:
return ChronoUnit.MICROS;
case MILLISECONDS:
return ChronoUnit.MILLIS;
default:
throw new IllegalArgumentException(units.toString());
}
}
|
java
|
@javax.annotation.Nonnull
public static TemporalUnit cvt(@javax.annotation.Nonnull final TimeUnit units) {
switch (units) {
case DAYS:
return ChronoUnit.DAYS;
case HOURS:
return ChronoUnit.HOURS;
case MINUTES:
return ChronoUnit.MINUTES;
case SECONDS:
return ChronoUnit.SECONDS;
case NANOSECONDS:
return ChronoUnit.NANOS;
case MICROSECONDS:
return ChronoUnit.MICROS;
case MILLISECONDS:
return ChronoUnit.MILLIS;
default:
throw new IllegalArgumentException(units.toString());
}
}
|
[
"@",
"javax",
".",
"annotation",
".",
"Nonnull",
"public",
"static",
"TemporalUnit",
"cvt",
"(",
"@",
"javax",
".",
"annotation",
".",
"Nonnull",
"final",
"TimeUnit",
"units",
")",
"{",
"switch",
"(",
"units",
")",
"{",
"case",
"DAYS",
":",
"return",
"ChronoUnit",
".",
"DAYS",
";",
"case",
"HOURS",
":",
"return",
"ChronoUnit",
".",
"HOURS",
";",
"case",
"MINUTES",
":",
"return",
"ChronoUnit",
".",
"MINUTES",
";",
"case",
"SECONDS",
":",
"return",
"ChronoUnit",
".",
"SECONDS",
";",
"case",
"NANOSECONDS",
":",
"return",
"ChronoUnit",
".",
"NANOS",
";",
"case",
"MICROSECONDS",
":",
"return",
"ChronoUnit",
".",
"MICROS",
";",
"case",
"MILLISECONDS",
":",
"return",
"ChronoUnit",
".",
"MILLIS",
";",
"default",
":",
"throw",
"new",
"IllegalArgumentException",
"(",
"units",
".",
"toString",
"(",
")",
")",
";",
"}",
"}"
] |
Cvt temporal unit.
@param units the units
@return the temporal unit
|
[
"Cvt",
"temporal",
"unit",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/Util.java#L291-L311
|
155,096
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/util/Util.java
|
Util.mkString
|
public static String mkString(@javax.annotation.Nonnull final String separator, final String... strs) {
return Arrays.asList(strs).stream().collect(Collectors.joining(separator));
}
|
java
|
public static String mkString(@javax.annotation.Nonnull final String separator, final String... strs) {
return Arrays.asList(strs).stream().collect(Collectors.joining(separator));
}
|
[
"public",
"static",
"String",
"mkString",
"(",
"@",
"javax",
".",
"annotation",
".",
"Nonnull",
"final",
"String",
"separator",
",",
"final",
"String",
"...",
"strs",
")",
"{",
"return",
"Arrays",
".",
"asList",
"(",
"strs",
")",
".",
"stream",
"(",
")",
".",
"collect",
"(",
"Collectors",
".",
"joining",
"(",
"separator",
")",
")",
";",
"}"
] |
Mk string string.
@param separator the separator
@param strs the strs
@return the string
|
[
"Mk",
"string",
"string",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/Util.java#L345-L347
|
155,097
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/util/Util.java
|
Util.pathTo
|
public static String pathTo(@javax.annotation.Nonnull final File from, @javax.annotation.Nonnull final File to) {
return from.toPath().relativize(to.toPath()).toString().replaceAll("\\\\", "/");
}
|
java
|
public static String pathTo(@javax.annotation.Nonnull final File from, @javax.annotation.Nonnull final File to) {
return from.toPath().relativize(to.toPath()).toString().replaceAll("\\\\", "/");
}
|
[
"public",
"static",
"String",
"pathTo",
"(",
"@",
"javax",
".",
"annotation",
".",
"Nonnull",
"final",
"File",
"from",
",",
"@",
"javax",
".",
"annotation",
".",
"Nonnull",
"final",
"File",
"to",
")",
"{",
"return",
"from",
".",
"toPath",
"(",
")",
".",
"relativize",
"(",
"to",
".",
"toPath",
"(",
")",
")",
".",
"toString",
"(",
")",
".",
"replaceAll",
"(",
"\"\\\\\\\\\"",
",",
"\"/\"",
")",
";",
"}"
] |
Path to string.
@param from the from
@param to the to
@return the string
|
[
"Path",
"to",
"string",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/Util.java#L356-L358
|
155,098
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/util/Util.java
|
Util.resize
|
@Nullable
public static BufferedImage resize(@Nullable final BufferedImage image) {
if (null == image) return image;
final int width = Math.min(image.getWidth(), 800);
if (width == image.getWidth()) return image;
final int height = image.getHeight() * width / image.getWidth();
@javax.annotation.Nonnull final BufferedImage rerender = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
final Graphics gfx = rerender.getGraphics();
@javax.annotation.Nonnull final RenderingHints hints = new RenderingHints(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
((Graphics2D) gfx).setRenderingHints(hints);
gfx.drawImage(image, 0, 0, rerender.getWidth(), rerender.getHeight(), null);
return rerender;
}
|
java
|
@Nullable
public static BufferedImage resize(@Nullable final BufferedImage image) {
if (null == image) return image;
final int width = Math.min(image.getWidth(), 800);
if (width == image.getWidth()) return image;
final int height = image.getHeight() * width / image.getWidth();
@javax.annotation.Nonnull final BufferedImage rerender = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
final Graphics gfx = rerender.getGraphics();
@javax.annotation.Nonnull final RenderingHints hints = new RenderingHints(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
((Graphics2D) gfx).setRenderingHints(hints);
gfx.drawImage(image, 0, 0, rerender.getWidth(), rerender.getHeight(), null);
return rerender;
}
|
[
"@",
"Nullable",
"public",
"static",
"BufferedImage",
"resize",
"(",
"@",
"Nullable",
"final",
"BufferedImage",
"image",
")",
"{",
"if",
"(",
"null",
"==",
"image",
")",
"return",
"image",
";",
"final",
"int",
"width",
"=",
"Math",
".",
"min",
"(",
"image",
".",
"getWidth",
"(",
")",
",",
"800",
")",
";",
"if",
"(",
"width",
"==",
"image",
".",
"getWidth",
"(",
")",
")",
"return",
"image",
";",
"final",
"int",
"height",
"=",
"image",
".",
"getHeight",
"(",
")",
"*",
"width",
"/",
"image",
".",
"getWidth",
"(",
")",
";",
"@",
"javax",
".",
"annotation",
".",
"Nonnull",
"final",
"BufferedImage",
"rerender",
"=",
"new",
"BufferedImage",
"(",
"width",
",",
"height",
",",
"BufferedImage",
".",
"TYPE_INT_ARGB",
")",
";",
"final",
"Graphics",
"gfx",
"=",
"rerender",
".",
"getGraphics",
"(",
")",
";",
"@",
"javax",
".",
"annotation",
".",
"Nonnull",
"final",
"RenderingHints",
"hints",
"=",
"new",
"RenderingHints",
"(",
"RenderingHints",
".",
"KEY_INTERPOLATION",
",",
"RenderingHints",
".",
"VALUE_INTERPOLATION_BICUBIC",
")",
";",
"(",
"(",
"Graphics2D",
")",
"gfx",
")",
".",
"setRenderingHints",
"(",
"hints",
")",
";",
"gfx",
".",
"drawImage",
"(",
"image",
",",
"0",
",",
"0",
",",
"rerender",
".",
"getWidth",
"(",
")",
",",
"rerender",
".",
"getHeight",
"(",
")",
",",
"null",
")",
";",
"return",
"rerender",
";",
"}"
] |
Resize buffered image.
@param image the image
@return the buffered image
|
[
"Resize",
"buffered",
"image",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/Util.java#L418-L430
|
155,099
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/util/Util.java
|
Util.toImage
|
public static BufferedImage toImage(@javax.annotation.Nonnull final Component component) {
try {
com.simiacryptus.util.Util.layout(component);
@javax.annotation.Nonnull final BufferedImage img = new BufferedImage(component.getWidth(), component.getHeight(), BufferedImage.TYPE_INT_ARGB_PRE);
final Graphics2D g = img.createGraphics();
g.setColor(component.getForeground());
g.setFont(component.getFont());
component.print(g);
return img;
} catch (@javax.annotation.Nonnull final Exception e) {
return null;
}
}
|
java
|
public static BufferedImage toImage(@javax.annotation.Nonnull final Component component) {
try {
com.simiacryptus.util.Util.layout(component);
@javax.annotation.Nonnull final BufferedImage img = new BufferedImage(component.getWidth(), component.getHeight(), BufferedImage.TYPE_INT_ARGB_PRE);
final Graphics2D g = img.createGraphics();
g.setColor(component.getForeground());
g.setFont(component.getFont());
component.print(g);
return img;
} catch (@javax.annotation.Nonnull final Exception e) {
return null;
}
}
|
[
"public",
"static",
"BufferedImage",
"toImage",
"(",
"@",
"javax",
".",
"annotation",
".",
"Nonnull",
"final",
"Component",
"component",
")",
"{",
"try",
"{",
"com",
".",
"simiacryptus",
".",
"util",
".",
"Util",
".",
"layout",
"(",
"component",
")",
";",
"@",
"javax",
".",
"annotation",
".",
"Nonnull",
"final",
"BufferedImage",
"img",
"=",
"new",
"BufferedImage",
"(",
"component",
".",
"getWidth",
"(",
")",
",",
"component",
".",
"getHeight",
"(",
")",
",",
"BufferedImage",
".",
"TYPE_INT_ARGB_PRE",
")",
";",
"final",
"Graphics2D",
"g",
"=",
"img",
".",
"createGraphics",
"(",
")",
";",
"g",
".",
"setColor",
"(",
"component",
".",
"getForeground",
"(",
")",
")",
";",
"g",
".",
"setFont",
"(",
"component",
".",
"getFont",
"(",
")",
")",
";",
"component",
".",
"print",
"(",
"g",
")",
";",
"return",
"img",
";",
"}",
"catch",
"(",
"@",
"javax",
".",
"annotation",
".",
"Nonnull",
"final",
"Exception",
"e",
")",
"{",
"return",
"null",
";",
"}",
"}"
] |
To image buffered image.
@param component the component
@return the buffered image
|
[
"To",
"image",
"buffered",
"image",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/Util.java#L438-L450
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.