id
int32 0
165k
| repo
stringlengths 7
58
| path
stringlengths 12
218
| func_name
stringlengths 3
140
| original_string
stringlengths 73
34.1k
| language
stringclasses 1
value | code
stringlengths 73
34.1k
| code_tokens
list | docstring
stringlengths 3
16k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 105
339
|
|---|---|---|---|---|---|---|---|---|---|---|---|
154,700
|
foundation-runtime/service-directory
|
1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryLookupService.java
|
DirectoryLookupService.getModelServiceInstance
|
public ModelServiceInstance getModelServiceInstance(String serviceName, String instanceId){
ModelService service = getModelService(serviceName);
if(service != null && service.getServiceInstances() != null ){
for(ModelServiceInstance instance : service.getServiceInstances()){
if(instance.getInstanceId().equals(instanceId)){
return instance;
}
}
}
return null;
}
|
java
|
public ModelServiceInstance getModelServiceInstance(String serviceName, String instanceId){
ModelService service = getModelService(serviceName);
if(service != null && service.getServiceInstances() != null ){
for(ModelServiceInstance instance : service.getServiceInstances()){
if(instance.getInstanceId().equals(instanceId)){
return instance;
}
}
}
return null;
}
|
[
"public",
"ModelServiceInstance",
"getModelServiceInstance",
"(",
"String",
"serviceName",
",",
"String",
"instanceId",
")",
"{",
"ModelService",
"service",
"=",
"getModelService",
"(",
"serviceName",
")",
";",
"if",
"(",
"service",
"!=",
"null",
"&&",
"service",
".",
"getServiceInstances",
"(",
")",
"!=",
"null",
")",
"{",
"for",
"(",
"ModelServiceInstance",
"instance",
":",
"service",
".",
"getServiceInstances",
"(",
")",
")",
"{",
"if",
"(",
"instance",
".",
"getInstanceId",
"(",
")",
".",
"equals",
"(",
"instanceId",
")",
")",
"{",
"return",
"instance",
";",
"}",
"}",
"}",
"return",
"null",
";",
"}"
] |
Get the ModelServiceInstance by serviceName and instanceId.
@param serviceName
the service name.
@param instanceId
the instanceId.
@return
the ModelServiceInstance.
|
[
"Get",
"the",
"ModelServiceInstance",
"by",
"serviceName",
"and",
"instanceId",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryLookupService.java#L102-L112
|
154,701
|
foundation-runtime/service-directory
|
1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryLookupService.java
|
DirectoryLookupService.getModelInstancesByMetadataKey
|
public List<ModelServiceInstance> getModelInstancesByMetadataKey(String keyName){
ModelMetadataKey key = getModelMetadataKey(keyName);
if(key == null || key.getServiceInstances().isEmpty()){
return Collections.<ModelServiceInstance>emptyList();
}else{
return new ArrayList<ModelServiceInstance>(key.getServiceInstances());
}
}
|
java
|
public List<ModelServiceInstance> getModelInstancesByMetadataKey(String keyName){
ModelMetadataKey key = getModelMetadataKey(keyName);
if(key == null || key.getServiceInstances().isEmpty()){
return Collections.<ModelServiceInstance>emptyList();
}else{
return new ArrayList<ModelServiceInstance>(key.getServiceInstances());
}
}
|
[
"public",
"List",
"<",
"ModelServiceInstance",
">",
"getModelInstancesByMetadataKey",
"(",
"String",
"keyName",
")",
"{",
"ModelMetadataKey",
"key",
"=",
"getModelMetadataKey",
"(",
"keyName",
")",
";",
"if",
"(",
"key",
"==",
"null",
"||",
"key",
".",
"getServiceInstances",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"Collections",
".",
"<",
"ModelServiceInstance",
">",
"emptyList",
"(",
")",
";",
"}",
"else",
"{",
"return",
"new",
"ArrayList",
"<",
"ModelServiceInstance",
">",
"(",
"key",
".",
"getServiceInstances",
"(",
")",
")",
";",
"}",
"}"
] |
Get the ModelServiceInstance list that contains the metadata key.
@param keyName
the metadata key name.
@return
the UP ModelServiceInstances that has the metadata key.
|
[
"Get",
"the",
"ModelServiceInstance",
"list",
"that",
"contains",
"the",
"metadata",
"key",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryLookupService.java#L122-L129
|
154,702
|
foundation-runtime/service-directory
|
1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryLookupService.java
|
DirectoryLookupService.onServiceInstanceUnavailable
|
protected void onServiceInstanceUnavailable(ServiceInstance instance){
if(instance == null){
return ;
}
String serviceName = instance.getServiceName();
List<NotificationHandler> handlerList = new ArrayList<NotificationHandler>();
synchronized (notificationHandlers) {
if (notificationHandlers.containsKey(serviceName)) {
handlerList.addAll(notificationHandlers.get(serviceName));
}
}
for(NotificationHandler h : handlerList) {
h.serviceInstanceUnavailable(instance);
}
}
|
java
|
protected void onServiceInstanceUnavailable(ServiceInstance instance){
if(instance == null){
return ;
}
String serviceName = instance.getServiceName();
List<NotificationHandler> handlerList = new ArrayList<NotificationHandler>();
synchronized (notificationHandlers) {
if (notificationHandlers.containsKey(serviceName)) {
handlerList.addAll(notificationHandlers.get(serviceName));
}
}
for(NotificationHandler h : handlerList) {
h.serviceInstanceUnavailable(instance);
}
}
|
[
"protected",
"void",
"onServiceInstanceUnavailable",
"(",
"ServiceInstance",
"instance",
")",
"{",
"if",
"(",
"instance",
"==",
"null",
")",
"{",
"return",
";",
"}",
"String",
"serviceName",
"=",
"instance",
".",
"getServiceName",
"(",
")",
";",
"List",
"<",
"NotificationHandler",
">",
"handlerList",
"=",
"new",
"ArrayList",
"<",
"NotificationHandler",
">",
"(",
")",
";",
"synchronized",
"(",
"notificationHandlers",
")",
"{",
"if",
"(",
"notificationHandlers",
".",
"containsKey",
"(",
"serviceName",
")",
")",
"{",
"handlerList",
".",
"addAll",
"(",
"notificationHandlers",
".",
"get",
"(",
"serviceName",
")",
")",
";",
"}",
"}",
"for",
"(",
"NotificationHandler",
"h",
":",
"handlerList",
")",
"{",
"h",
".",
"serviceInstanceUnavailable",
"(",
"instance",
")",
";",
"}",
"}"
] |
Invoke the serviceInstanceUnavailable of the NotificationHandler.
@param instance
the ServiceInstance.
|
[
"Invoke",
"the",
"serviceInstanceUnavailable",
"of",
"the",
"NotificationHandler",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryLookupService.java#L269-L283
|
154,703
|
foundation-runtime/service-directory
|
1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryLookupService.java
|
DirectoryLookupService.onServiceInstanceChanged
|
protected void onServiceInstanceChanged(ServiceInstance instance){
String serviceName = instance.getServiceName();
List<NotificationHandler> handlerList = new ArrayList<NotificationHandler>();
synchronized (notificationHandlers) {
if (notificationHandlers.containsKey(serviceName)) {
handlerList.addAll(notificationHandlers.get(serviceName));
}
}
for (NotificationHandler h : handlerList) {
h.serviceInstanceChange(instance);
}
}
|
java
|
protected void onServiceInstanceChanged(ServiceInstance instance){
String serviceName = instance.getServiceName();
List<NotificationHandler> handlerList = new ArrayList<NotificationHandler>();
synchronized (notificationHandlers) {
if (notificationHandlers.containsKey(serviceName)) {
handlerList.addAll(notificationHandlers.get(serviceName));
}
}
for (NotificationHandler h : handlerList) {
h.serviceInstanceChange(instance);
}
}
|
[
"protected",
"void",
"onServiceInstanceChanged",
"(",
"ServiceInstance",
"instance",
")",
"{",
"String",
"serviceName",
"=",
"instance",
".",
"getServiceName",
"(",
")",
";",
"List",
"<",
"NotificationHandler",
">",
"handlerList",
"=",
"new",
"ArrayList",
"<",
"NotificationHandler",
">",
"(",
")",
";",
"synchronized",
"(",
"notificationHandlers",
")",
"{",
"if",
"(",
"notificationHandlers",
".",
"containsKey",
"(",
"serviceName",
")",
")",
"{",
"handlerList",
".",
"addAll",
"(",
"notificationHandlers",
".",
"get",
"(",
"serviceName",
")",
")",
";",
"}",
"}",
"for",
"(",
"NotificationHandler",
"h",
":",
"handlerList",
")",
"{",
"h",
".",
"serviceInstanceChange",
"(",
"instance",
")",
";",
"}",
"}"
] |
Invoke the serviceInstanceChange of the NotificationHandler.
@param instance
the ServiceInstance.
|
[
"Invoke",
"the",
"serviceInstanceChange",
"of",
"the",
"NotificationHandler",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryLookupService.java#L291-L302
|
154,704
|
foundation-runtime/service-directory
|
1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryLookupService.java
|
DirectoryLookupService.onServiceInstanceAvailable
|
protected void onServiceInstanceAvailable(ServiceInstance instance){
String serviceName = instance.getServiceName();
List<NotificationHandler> handlerList = new ArrayList<NotificationHandler>();
synchronized (notificationHandlers) {
if (notificationHandlers.containsKey(serviceName)) {
handlerList.addAll(notificationHandlers.get(serviceName));
}
}
for (NotificationHandler h : handlerList) {
h.serviceInstanceAvailable(instance);
}
}
|
java
|
protected void onServiceInstanceAvailable(ServiceInstance instance){
String serviceName = instance.getServiceName();
List<NotificationHandler> handlerList = new ArrayList<NotificationHandler>();
synchronized (notificationHandlers) {
if (notificationHandlers.containsKey(serviceName)) {
handlerList.addAll(notificationHandlers.get(serviceName));
}
}
for (NotificationHandler h : handlerList) {
h.serviceInstanceAvailable(instance);
}
}
|
[
"protected",
"void",
"onServiceInstanceAvailable",
"(",
"ServiceInstance",
"instance",
")",
"{",
"String",
"serviceName",
"=",
"instance",
".",
"getServiceName",
"(",
")",
";",
"List",
"<",
"NotificationHandler",
">",
"handlerList",
"=",
"new",
"ArrayList",
"<",
"NotificationHandler",
">",
"(",
")",
";",
"synchronized",
"(",
"notificationHandlers",
")",
"{",
"if",
"(",
"notificationHandlers",
".",
"containsKey",
"(",
"serviceName",
")",
")",
"{",
"handlerList",
".",
"addAll",
"(",
"notificationHandlers",
".",
"get",
"(",
"serviceName",
")",
")",
";",
"}",
"}",
"for",
"(",
"NotificationHandler",
"h",
":",
"handlerList",
")",
"{",
"h",
".",
"serviceInstanceAvailable",
"(",
"instance",
")",
";",
"}",
"}"
] |
Invoke the serviceInstanceAvailable of the NotificationHandler.
@param instance
the ServiceInstance.
|
[
"Invoke",
"the",
"serviceInstanceAvailable",
"of",
"the",
"NotificationHandler",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryLookupService.java#L310-L321
|
154,705
|
gnagy/webhejj-commons
|
src/main/java/hu/webhejj/commons/collections/CollectionUtils.java
|
CollectionUtils.asFlatList
|
public static <E> List<E> asFlatList(Iterable<E>... iterables) {
List<E> list = new ArrayList<E>();
for(Iterable<E> iterable: iterables) {
for(E e: iterable) {
list.add(e);
}
}
return list;
}
|
java
|
public static <E> List<E> asFlatList(Iterable<E>... iterables) {
List<E> list = new ArrayList<E>();
for(Iterable<E> iterable: iterables) {
for(E e: iterable) {
list.add(e);
}
}
return list;
}
|
[
"public",
"static",
"<",
"E",
">",
"List",
"<",
"E",
">",
"asFlatList",
"(",
"Iterable",
"<",
"E",
">",
"...",
"iterables",
")",
"{",
"List",
"<",
"E",
">",
"list",
"=",
"new",
"ArrayList",
"<",
"E",
">",
"(",
")",
";",
"for",
"(",
"Iterable",
"<",
"E",
">",
"iterable",
":",
"iterables",
")",
"{",
"for",
"(",
"E",
"e",
":",
"iterable",
")",
"{",
"list",
".",
"add",
"(",
"e",
")",
";",
"}",
"}",
"return",
"list",
";",
"}"
] |
Adds elements from one or more iterables to a single flat list
@param <E> item type
@param iterables iterables to take elements from
@return list containing items from all iterables
|
[
"Adds",
"elements",
"from",
"one",
"or",
"more",
"iterables",
"to",
"a",
"single",
"flat",
"list"
] |
270bc6f111ec5761af31d39bd38c40fd914d2eba
|
https://github.com/gnagy/webhejj-commons/blob/270bc6f111ec5761af31d39bd38c40fd914d2eba/src/main/java/hu/webhejj/commons/collections/CollectionUtils.java#L46-L54
|
154,706
|
gnagy/webhejj-commons
|
src/main/java/hu/webhejj/commons/collections/CollectionUtils.java
|
CollectionUtils.dump
|
public static void dump(Appendable appendable, Iterable<?> items) {
try {
for(Object item: items) {
appendable.append(String.valueOf(item));
appendable.append("\n");
}
} catch (IOException e) {
throw new RuntimeException("An error occured while appending", e);
}
}
|
java
|
public static void dump(Appendable appendable, Iterable<?> items) {
try {
for(Object item: items) {
appendable.append(String.valueOf(item));
appendable.append("\n");
}
} catch (IOException e) {
throw new RuntimeException("An error occured while appending", e);
}
}
|
[
"public",
"static",
"void",
"dump",
"(",
"Appendable",
"appendable",
",",
"Iterable",
"<",
"?",
">",
"items",
")",
"{",
"try",
"{",
"for",
"(",
"Object",
"item",
":",
"items",
")",
"{",
"appendable",
".",
"append",
"(",
"String",
".",
"valueOf",
"(",
"item",
")",
")",
";",
"appendable",
".",
"append",
"(",
"\"\\n\"",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"An error occured while appending\"",
",",
"e",
")",
";",
"}",
"}"
] |
Writes the string value of the specified items to appendable,
wrapping an eventual IOException into a RuntimeException
@param appendable to append values to
@param items items to dump
|
[
"Writes",
"the",
"string",
"value",
"of",
"the",
"specified",
"items",
"to",
"appendable",
"wrapping",
"an",
"eventual",
"IOException",
"into",
"a",
"RuntimeException"
] |
270bc6f111ec5761af31d39bd38c40fd914d2eba
|
https://github.com/gnagy/webhejj-commons/blob/270bc6f111ec5761af31d39bd38c40fd914d2eba/src/main/java/hu/webhejj/commons/collections/CollectionUtils.java#L63-L72
|
154,707
|
RogerParkinson/madura-objects-parent
|
madura-utils/src/main/java/nz/co/senanque/parser/Parser.java
|
Parser.debug
|
protected void debug(TextProvider textProvider)
{
if (!m_debug) return;
Throwable t = new Throwable();
StackTraceElement e[] = t.getStackTrace();
StackTraceElement ste = e[1];
String indent = "";
for (int i=0;i<m_indent;i++)
indent +=" ";
log.debug("{}SUCCESS {}:{}",indent,ste.getMethodName(),textProvider.debug());
}
|
java
|
protected void debug(TextProvider textProvider)
{
if (!m_debug) return;
Throwable t = new Throwable();
StackTraceElement e[] = t.getStackTrace();
StackTraceElement ste = e[1];
String indent = "";
for (int i=0;i<m_indent;i++)
indent +=" ";
log.debug("{}SUCCESS {}:{}",indent,ste.getMethodName(),textProvider.debug());
}
|
[
"protected",
"void",
"debug",
"(",
"TextProvider",
"textProvider",
")",
"{",
"if",
"(",
"!",
"m_debug",
")",
"return",
";",
"Throwable",
"t",
"=",
"new",
"Throwable",
"(",
")",
";",
"StackTraceElement",
"e",
"[",
"]",
"=",
"t",
".",
"getStackTrace",
"(",
")",
";",
"StackTraceElement",
"ste",
"=",
"e",
"[",
"1",
"]",
";",
"String",
"indent",
"=",
"\"\"",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"m_indent",
";",
"i",
"++",
")",
"indent",
"+=",
"\"",
"\"",
";",
"log",
".",
"debug",
"(",
"\"{}SUCCESS {}:{}\"",
",",
"indent",
",",
"ste",
".",
"getMethodName",
"(",
")",
",",
"textProvider",
".",
"debug",
"(",
")",
")",
";",
"}"
] |
Report the debug information to the logger
|
[
"Report",
"the",
"debug",
"information",
"to",
"the",
"logger"
] |
9b5385dd0437611f0ce8506f63646e018d06fb8e
|
https://github.com/RogerParkinson/madura-objects-parent/blob/9b5385dd0437611f0ce8506f63646e018d06fb8e/madura-utils/src/main/java/nz/co/senanque/parser/Parser.java#L56-L66
|
154,708
|
RogerParkinson/madura-objects-parent
|
madura-utils/src/main/java/nz/co/senanque/parser/Parser.java
|
Parser.clearLeadingSpaces
|
public void clearLeadingSpaces(TextProvider textProvider)
{
while (true)
{
mark(textProvider);
char c;
try
{
c = getNextChar(textProvider);
}
catch (ExceededBufferSizeException e)
{
return;
}
catch (ParserException e)
{
// ignore problems at this point
return;
}
if (c == 0)
{
if (m_textProviderStack.size() > 0)
{
textProvider.close();
textProvider = (TextProvider)m_textProviderStack.pop();
}
break;
}
if (" \t\r\n".indexOf(c) == -1)
{
reset(textProvider);
break;
}
unmark(textProvider);
}
}
|
java
|
public void clearLeadingSpaces(TextProvider textProvider)
{
while (true)
{
mark(textProvider);
char c;
try
{
c = getNextChar(textProvider);
}
catch (ExceededBufferSizeException e)
{
return;
}
catch (ParserException e)
{
// ignore problems at this point
return;
}
if (c == 0)
{
if (m_textProviderStack.size() > 0)
{
textProvider.close();
textProvider = (TextProvider)m_textProviderStack.pop();
}
break;
}
if (" \t\r\n".indexOf(c) == -1)
{
reset(textProvider);
break;
}
unmark(textProvider);
}
}
|
[
"public",
"void",
"clearLeadingSpaces",
"(",
"TextProvider",
"textProvider",
")",
"{",
"while",
"(",
"true",
")",
"{",
"mark",
"(",
"textProvider",
")",
";",
"char",
"c",
";",
"try",
"{",
"c",
"=",
"getNextChar",
"(",
"textProvider",
")",
";",
"}",
"catch",
"(",
"ExceededBufferSizeException",
"e",
")",
"{",
"return",
";",
"}",
"catch",
"(",
"ParserException",
"e",
")",
"{",
"// ignore problems at this point",
"return",
";",
"}",
"if",
"(",
"c",
"==",
"0",
")",
"{",
"if",
"(",
"m_textProviderStack",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"textProvider",
".",
"close",
"(",
")",
";",
"textProvider",
"=",
"(",
"TextProvider",
")",
"m_textProviderStack",
".",
"pop",
"(",
")",
";",
"}",
"break",
";",
"}",
"if",
"(",
"\" \\t\\r\\n\"",
".",
"indexOf",
"(",
"c",
")",
"==",
"-",
"1",
")",
"{",
"reset",
"(",
"textProvider",
")",
";",
"break",
";",
"}",
"unmark",
"(",
"textProvider",
")",
";",
"}",
"}"
] |
Jump over leading spaces
Custom match methods normally call this before trying to match anything
@param textProvider
|
[
"Jump",
"over",
"leading",
"spaces",
"Custom",
"match",
"methods",
"normally",
"call",
"this",
"before",
"trying",
"to",
"match",
"anything"
] |
9b5385dd0437611f0ce8506f63646e018d06fb8e
|
https://github.com/RogerParkinson/madura-objects-parent/blob/9b5385dd0437611f0ce8506f63646e018d06fb8e/madura-utils/src/main/java/nz/co/senanque/parser/Parser.java#L179-L216
|
154,709
|
RogerParkinson/madura-objects-parent
|
madura-utils/src/main/java/nz/co/senanque/parser/Parser.java
|
Parser.exactOrError
|
public boolean exactOrError(String match,TextProvider textProvider)
{
if (!exact(match,textProvider,false))
{
throw new ParserException("Expected "+match,textProvider);
}
return true;
}
|
java
|
public boolean exactOrError(String match,TextProvider textProvider)
{
if (!exact(match,textProvider,false))
{
throw new ParserException("Expected "+match,textProvider);
}
return true;
}
|
[
"public",
"boolean",
"exactOrError",
"(",
"String",
"match",
",",
"TextProvider",
"textProvider",
")",
"{",
"if",
"(",
"!",
"exact",
"(",
"match",
",",
"textProvider",
",",
"false",
")",
")",
"{",
"throw",
"new",
"ParserException",
"(",
"\"Expected \"",
"+",
"match",
",",
"textProvider",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
Match against the passed string.
Case is ignored if the ignoreCase flag is set.
@param match
@param textProvider
@return true if matched
|
[
"Match",
"against",
"the",
"passed",
"string",
".",
"Case",
"is",
"ignored",
"if",
"the",
"ignoreCase",
"flag",
"is",
"set",
"."
] |
9b5385dd0437611f0ce8506f63646e018d06fb8e
|
https://github.com/RogerParkinson/madura-objects-parent/blob/9b5385dd0437611f0ce8506f63646e018d06fb8e/madura-utils/src/main/java/nz/co/senanque/parser/Parser.java#L225-L232
|
154,710
|
RogerParkinson/madura-objects-parent
|
madura-utils/src/main/java/nz/co/senanque/parser/Parser.java
|
Parser.endOfData
|
public boolean endOfData(TextProvider textProvider)
{
clearLastToken(textProvider);
clearLeadingSpaces(textProvider);
mark(textProvider);
if (m_debug)
debug("testing",textProvider);
try
{
char c = getNextChar(textProvider);
if (c == 0) {
unmark(textProvider);
return true;
}
}
catch (Exception e)
{
unmark(textProvider);
debug(textProvider);
return true;
}
reset(textProvider);
return false;
}
|
java
|
public boolean endOfData(TextProvider textProvider)
{
clearLastToken(textProvider);
clearLeadingSpaces(textProvider);
mark(textProvider);
if (m_debug)
debug("testing",textProvider);
try
{
char c = getNextChar(textProvider);
if (c == 0) {
unmark(textProvider);
return true;
}
}
catch (Exception e)
{
unmark(textProvider);
debug(textProvider);
return true;
}
reset(textProvider);
return false;
}
|
[
"public",
"boolean",
"endOfData",
"(",
"TextProvider",
"textProvider",
")",
"{",
"clearLastToken",
"(",
"textProvider",
")",
";",
"clearLeadingSpaces",
"(",
"textProvider",
")",
";",
"mark",
"(",
"textProvider",
")",
";",
"if",
"(",
"m_debug",
")",
"debug",
"(",
"\"testing\"",
",",
"textProvider",
")",
";",
"try",
"{",
"char",
"c",
"=",
"getNextChar",
"(",
"textProvider",
")",
";",
"if",
"(",
"c",
"==",
"0",
")",
"{",
"unmark",
"(",
"textProvider",
")",
";",
"return",
"true",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"unmark",
"(",
"textProvider",
")",
";",
"debug",
"(",
"textProvider",
")",
";",
"return",
"true",
";",
"}",
"reset",
"(",
"textProvider",
")",
";",
"return",
"false",
";",
"}"
] |
Test to see if we are at the end of the data
@param textProvider
@return true if matches
|
[
"Test",
"to",
"see",
"if",
"we",
"are",
"at",
"the",
"end",
"of",
"the",
"data"
] |
9b5385dd0437611f0ce8506f63646e018d06fb8e
|
https://github.com/RogerParkinson/madura-objects-parent/blob/9b5385dd0437611f0ce8506f63646e018d06fb8e/madura-utils/src/main/java/nz/co/senanque/parser/Parser.java#L315-L338
|
154,711
|
RogerParkinson/madura-objects-parent
|
madura-utils/src/main/java/nz/co/senanque/parser/Parser.java
|
Parser.alphaNum
|
public boolean alphaNum(TextProvider textProvider)
{
clearLastToken(textProvider);
clearLeadingSpaces(textProvider);
mark(textProvider);
if (m_debug)
debug("testing",textProvider);
StringBuilder sb = new StringBuilder();
while (true)
{
char c = getNextChar(textProvider);
if (!Character.isLetterOrDigit(c)) break;
remark(textProvider);
sb.append(c);
}
reset(textProvider); // removes last char
if (sb.toString().length() == 0) return false;
textProvider.setLastToken(sb.toString());
debug(textProvider);
return true;
}
|
java
|
public boolean alphaNum(TextProvider textProvider)
{
clearLastToken(textProvider);
clearLeadingSpaces(textProvider);
mark(textProvider);
if (m_debug)
debug("testing",textProvider);
StringBuilder sb = new StringBuilder();
while (true)
{
char c = getNextChar(textProvider);
if (!Character.isLetterOrDigit(c)) break;
remark(textProvider);
sb.append(c);
}
reset(textProvider); // removes last char
if (sb.toString().length() == 0) return false;
textProvider.setLastToken(sb.toString());
debug(textProvider);
return true;
}
|
[
"public",
"boolean",
"alphaNum",
"(",
"TextProvider",
"textProvider",
")",
"{",
"clearLastToken",
"(",
"textProvider",
")",
";",
"clearLeadingSpaces",
"(",
"textProvider",
")",
";",
"mark",
"(",
"textProvider",
")",
";",
"if",
"(",
"m_debug",
")",
"debug",
"(",
"\"testing\"",
",",
"textProvider",
")",
";",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"while",
"(",
"true",
")",
"{",
"char",
"c",
"=",
"getNextChar",
"(",
"textProvider",
")",
";",
"if",
"(",
"!",
"Character",
".",
"isLetterOrDigit",
"(",
"c",
")",
")",
"break",
";",
"remark",
"(",
"textProvider",
")",
";",
"sb",
".",
"append",
"(",
"c",
")",
";",
"}",
"reset",
"(",
"textProvider",
")",
";",
"// removes last char",
"if",
"(",
"sb",
".",
"toString",
"(",
")",
".",
"length",
"(",
")",
"==",
"0",
")",
"return",
"false",
";",
"textProvider",
".",
"setLastToken",
"(",
"sb",
".",
"toString",
"(",
")",
")",
";",
"debug",
"(",
"textProvider",
")",
";",
"return",
"true",
";",
"}"
] |
See if there is an alphanumeric
@param textProvider
@return true if matched
|
[
"See",
"if",
"there",
"is",
"an",
"alphanumeric"
] |
9b5385dd0437611f0ce8506f63646e018d06fb8e
|
https://github.com/RogerParkinson/madura-objects-parent/blob/9b5385dd0437611f0ce8506f63646e018d06fb8e/madura-utils/src/main/java/nz/co/senanque/parser/Parser.java#L437-L459
|
154,712
|
RogerParkinson/madura-objects-parent
|
madura-utils/src/main/java/nz/co/senanque/parser/Parser.java
|
Parser.any
|
public boolean any(TextProvider textProvider)
{
clearLastToken(textProvider);
clearLeadingSpaces(textProvider);
mark(textProvider);
if (m_debug)
debug("testing",textProvider);
StringBuilder sb = new StringBuilder();
while (true)
{
char c = getNextChar(textProvider);
if (c == ' ' || c == '\t' || c == '\r' || c == '\n' || c == 0)
{
break;
}
sb.append(c);
}
unmark(textProvider);
String s = sb.toString().trim();
if (s.length() == 0) return false;
textProvider.setLastToken(s);
debug(textProvider);
return true;
}
|
java
|
public boolean any(TextProvider textProvider)
{
clearLastToken(textProvider);
clearLeadingSpaces(textProvider);
mark(textProvider);
if (m_debug)
debug("testing",textProvider);
StringBuilder sb = new StringBuilder();
while (true)
{
char c = getNextChar(textProvider);
if (c == ' ' || c == '\t' || c == '\r' || c == '\n' || c == 0)
{
break;
}
sb.append(c);
}
unmark(textProvider);
String s = sb.toString().trim();
if (s.length() == 0) return false;
textProvider.setLastToken(s);
debug(textProvider);
return true;
}
|
[
"public",
"boolean",
"any",
"(",
"TextProvider",
"textProvider",
")",
"{",
"clearLastToken",
"(",
"textProvider",
")",
";",
"clearLeadingSpaces",
"(",
"textProvider",
")",
";",
"mark",
"(",
"textProvider",
")",
";",
"if",
"(",
"m_debug",
")",
"debug",
"(",
"\"testing\"",
",",
"textProvider",
")",
";",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"while",
"(",
"true",
")",
"{",
"char",
"c",
"=",
"getNextChar",
"(",
"textProvider",
")",
";",
"if",
"(",
"c",
"==",
"'",
"'",
"||",
"c",
"==",
"'",
"'",
"||",
"c",
"==",
"'",
"'",
"||",
"c",
"==",
"'",
"'",
"||",
"c",
"==",
"0",
")",
"{",
"break",
";",
"}",
"sb",
".",
"append",
"(",
"c",
")",
";",
"}",
"unmark",
"(",
"textProvider",
")",
";",
"String",
"s",
"=",
"sb",
".",
"toString",
"(",
")",
".",
"trim",
"(",
")",
";",
"if",
"(",
"s",
".",
"length",
"(",
")",
"==",
"0",
")",
"return",
"false",
";",
"textProvider",
".",
"setLastToken",
"(",
"s",
")",
";",
"debug",
"(",
"textProvider",
")",
";",
"return",
"true",
";",
"}"
] |
Match the next space bounded string
@param textProvider
@return true if matched
|
[
"Match",
"the",
"next",
"space",
"bounded",
"string"
] |
9b5385dd0437611f0ce8506f63646e018d06fb8e
|
https://github.com/RogerParkinson/madura-objects-parent/blob/9b5385dd0437611f0ce8506f63646e018d06fb8e/madura-utils/src/main/java/nz/co/senanque/parser/Parser.java#L564-L588
|
154,713
|
RogerParkinson/madura-objects-parent
|
madura-utils/src/main/java/nz/co/senanque/parser/Parser.java
|
Parser.quotedString
|
public boolean quotedString(char quote,TextProvider textProvider)
{
clearLastToken(textProvider);
clearLeadingSpaces(textProvider);
mark(textProvider);
if (m_debug)
debug("testing "+quote,textProvider);
if (getNextChar(textProvider) != quote)
{
reset(textProvider);
return false;
}
char lastChar = 0;
char c = 0;
StringBuilder sb = new StringBuilder();
while (true)
{
lastChar = c;
c = getNextChar(textProvider);
if (c == 0) {
unmark(textProvider);
return false;
}
if (c == quote && lastChar != '\\') break;
sb.append(c);
}
unmark(textProvider);
String s = sb.toString().trim();
if (s.length() == 0) return false;
textProvider.setLastToken(s);
debug(textProvider);
return true;
}
|
java
|
public boolean quotedString(char quote,TextProvider textProvider)
{
clearLastToken(textProvider);
clearLeadingSpaces(textProvider);
mark(textProvider);
if (m_debug)
debug("testing "+quote,textProvider);
if (getNextChar(textProvider) != quote)
{
reset(textProvider);
return false;
}
char lastChar = 0;
char c = 0;
StringBuilder sb = new StringBuilder();
while (true)
{
lastChar = c;
c = getNextChar(textProvider);
if (c == 0) {
unmark(textProvider);
return false;
}
if (c == quote && lastChar != '\\') break;
sb.append(c);
}
unmark(textProvider);
String s = sb.toString().trim();
if (s.length() == 0) return false;
textProvider.setLastToken(s);
debug(textProvider);
return true;
}
|
[
"public",
"boolean",
"quotedString",
"(",
"char",
"quote",
",",
"TextProvider",
"textProvider",
")",
"{",
"clearLastToken",
"(",
"textProvider",
")",
";",
"clearLeadingSpaces",
"(",
"textProvider",
")",
";",
"mark",
"(",
"textProvider",
")",
";",
"if",
"(",
"m_debug",
")",
"debug",
"(",
"\"testing \"",
"+",
"quote",
",",
"textProvider",
")",
";",
"if",
"(",
"getNextChar",
"(",
"textProvider",
")",
"!=",
"quote",
")",
"{",
"reset",
"(",
"textProvider",
")",
";",
"return",
"false",
";",
"}",
"char",
"lastChar",
"=",
"0",
";",
"char",
"c",
"=",
"0",
";",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"while",
"(",
"true",
")",
"{",
"lastChar",
"=",
"c",
";",
"c",
"=",
"getNextChar",
"(",
"textProvider",
")",
";",
"if",
"(",
"c",
"==",
"0",
")",
"{",
"unmark",
"(",
"textProvider",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"c",
"==",
"quote",
"&&",
"lastChar",
"!=",
"'",
"'",
")",
"break",
";",
"sb",
".",
"append",
"(",
"c",
")",
";",
"}",
"unmark",
"(",
"textProvider",
")",
";",
"String",
"s",
"=",
"sb",
".",
"toString",
"(",
")",
".",
"trim",
"(",
")",
";",
"if",
"(",
"s",
".",
"length",
"(",
")",
"==",
"0",
")",
"return",
"false",
";",
"textProvider",
".",
"setLastToken",
"(",
"s",
")",
";",
"debug",
"(",
"textProvider",
")",
";",
"return",
"true",
";",
"}"
] |
Match a quoted string. The quotes have to be present but they
are removed from the result. Quotes inside the string can be
'quoted' using the '\' character eg \"
@param quote style
@param textProvider
@return true if matched
|
[
"Match",
"a",
"quoted",
"string",
".",
"The",
"quotes",
"have",
"to",
"be",
"present",
"but",
"they",
"are",
"removed",
"from",
"the",
"result",
".",
"Quotes",
"inside",
"the",
"string",
"can",
"be",
"quoted",
"using",
"the",
"\\",
"character",
"eg",
"\\"
] |
9b5385dd0437611f0ce8506f63646e018d06fb8e
|
https://github.com/RogerParkinson/madura-objects-parent/blob/9b5385dd0437611f0ce8506f63646e018d06fb8e/madura-utils/src/main/java/nz/co/senanque/parser/Parser.java#L635-L668
|
154,714
|
RogerParkinson/madura-objects-parent
|
madura-utils/src/main/java/nz/co/senanque/parser/Parser.java
|
Parser.getBracketedToken
|
public boolean getBracketedToken(char start, char end, TextProvider textProvider)
{
clearLastToken(textProvider);
clearLeadingSpaces(textProvider);
mark(textProvider);
if (m_debug)
debug("testing " + start + " " + end,textProvider);
StringBuilder sb = new StringBuilder();
char c = getNextChar(textProvider);
if (c != start)
{
reset(textProvider);
return false;
}
int brackets = 0;
while (true)
{
if (c == start) brackets++;
if (c == end) brackets--;
sb.append(c);
if (brackets < 1) break;
c = getNextChar(textProvider);
if (c == 0)
{
reset(textProvider);
return false;
}
}
unmark(textProvider);
String s = sb.toString().trim();
if (s.length() == 0) return false;
textProvider.setLastToken(s);
debug(textProvider);
return true;
}
|
java
|
public boolean getBracketedToken(char start, char end, TextProvider textProvider)
{
clearLastToken(textProvider);
clearLeadingSpaces(textProvider);
mark(textProvider);
if (m_debug)
debug("testing " + start + " " + end,textProvider);
StringBuilder sb = new StringBuilder();
char c = getNextChar(textProvider);
if (c != start)
{
reset(textProvider);
return false;
}
int brackets = 0;
while (true)
{
if (c == start) brackets++;
if (c == end) brackets--;
sb.append(c);
if (brackets < 1) break;
c = getNextChar(textProvider);
if (c == 0)
{
reset(textProvider);
return false;
}
}
unmark(textProvider);
String s = sb.toString().trim();
if (s.length() == 0) return false;
textProvider.setLastToken(s);
debug(textProvider);
return true;
}
|
[
"public",
"boolean",
"getBracketedToken",
"(",
"char",
"start",
",",
"char",
"end",
",",
"TextProvider",
"textProvider",
")",
"{",
"clearLastToken",
"(",
"textProvider",
")",
";",
"clearLeadingSpaces",
"(",
"textProvider",
")",
";",
"mark",
"(",
"textProvider",
")",
";",
"if",
"(",
"m_debug",
")",
"debug",
"(",
"\"testing \"",
"+",
"start",
"+",
"\" \"",
"+",
"end",
",",
"textProvider",
")",
";",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"char",
"c",
"=",
"getNextChar",
"(",
"textProvider",
")",
";",
"if",
"(",
"c",
"!=",
"start",
")",
"{",
"reset",
"(",
"textProvider",
")",
";",
"return",
"false",
";",
"}",
"int",
"brackets",
"=",
"0",
";",
"while",
"(",
"true",
")",
"{",
"if",
"(",
"c",
"==",
"start",
")",
"brackets",
"++",
";",
"if",
"(",
"c",
"==",
"end",
")",
"brackets",
"--",
";",
"sb",
".",
"append",
"(",
"c",
")",
";",
"if",
"(",
"brackets",
"<",
"1",
")",
"break",
";",
"c",
"=",
"getNextChar",
"(",
"textProvider",
")",
";",
"if",
"(",
"c",
"==",
"0",
")",
"{",
"reset",
"(",
"textProvider",
")",
";",
"return",
"false",
";",
"}",
"}",
"unmark",
"(",
"textProvider",
")",
";",
"String",
"s",
"=",
"sb",
".",
"toString",
"(",
")",
".",
"trim",
"(",
")",
";",
"if",
"(",
"s",
".",
"length",
"(",
")",
"==",
"0",
")",
"return",
"false",
";",
"textProvider",
".",
"setLastToken",
"(",
"s",
")",
";",
"debug",
"(",
"textProvider",
")",
";",
"return",
"true",
";",
"}"
] |
Match a bracketed token given the start bracket and the end bracket
The result includes the brackets.
@param start
@param end
@param textProvider
@return true if match
|
[
"Match",
"a",
"bracketed",
"token",
"given",
"the",
"start",
"bracket",
"and",
"the",
"end",
"bracket",
"The",
"result",
"includes",
"the",
"brackets",
"."
] |
9b5385dd0437611f0ce8506f63646e018d06fb8e
|
https://github.com/RogerParkinson/madura-objects-parent/blob/9b5385dd0437611f0ce8506f63646e018d06fb8e/madura-utils/src/main/java/nz/co/senanque/parser/Parser.java#L678-L714
|
154,715
|
gnagy/webhejj-commons
|
src/main/java/hu/webhejj/commons/collections/Histogram.java
|
Histogram.add
|
public int add(T item) {
Integer count = map.get(item);
if(count == null) {
map.put(item, 1);
return 1;
} else {
map.put(item, count + 1);
return count + 1;
}
}
|
java
|
public int add(T item) {
Integer count = map.get(item);
if(count == null) {
map.put(item, 1);
return 1;
} else {
map.put(item, count + 1);
return count + 1;
}
}
|
[
"public",
"int",
"add",
"(",
"T",
"item",
")",
"{",
"Integer",
"count",
"=",
"map",
".",
"get",
"(",
"item",
")",
";",
"if",
"(",
"count",
"==",
"null",
")",
"{",
"map",
".",
"put",
"(",
"item",
",",
"1",
")",
";",
"return",
"1",
";",
"}",
"else",
"{",
"map",
".",
"put",
"(",
"item",
",",
"count",
"+",
"1",
")",
";",
"return",
"count",
"+",
"1",
";",
"}",
"}"
] |
add item to histogram, increasing its frequency by one
|
[
"add",
"item",
"to",
"histogram",
"increasing",
"its",
"frequency",
"by",
"one"
] |
270bc6f111ec5761af31d39bd38c40fd914d2eba
|
https://github.com/gnagy/webhejj-commons/blob/270bc6f111ec5761af31d39bd38c40fd914d2eba/src/main/java/hu/webhejj/commons/collections/Histogram.java#L27-L38
|
154,716
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMString.java
|
JMString.isNumber
|
public static boolean isNumber(String numberString) {
return Optional.ofNullable(numberPattern)
.orElseGet(() -> numberPattern = Pattern.compile(NumberPattern))
.matcher(numberString).matches();
}
|
java
|
public static boolean isNumber(String numberString) {
return Optional.ofNullable(numberPattern)
.orElseGet(() -> numberPattern = Pattern.compile(NumberPattern))
.matcher(numberString).matches();
}
|
[
"public",
"static",
"boolean",
"isNumber",
"(",
"String",
"numberString",
")",
"{",
"return",
"Optional",
".",
"ofNullable",
"(",
"numberPattern",
")",
".",
"orElseGet",
"(",
"(",
")",
"->",
"numberPattern",
"=",
"Pattern",
".",
"compile",
"(",
"NumberPattern",
")",
")",
".",
"matcher",
"(",
"numberString",
")",
".",
"matches",
"(",
")",
";",
"}"
] |
Is number boolean.
@param numberString the number string
@return the boolean
|
[
"Is",
"number",
"boolean",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMString.java#L92-L96
|
154,717
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMString.java
|
JMString.isWord
|
public static boolean isWord(String wordString) {
return Optional.ofNullable(wordPattern)
.orElseGet(() -> wordPattern = Pattern.compile(WordPattern))
.matcher(wordString).matches();
}
|
java
|
public static boolean isWord(String wordString) {
return Optional.ofNullable(wordPattern)
.orElseGet(() -> wordPattern = Pattern.compile(WordPattern))
.matcher(wordString).matches();
}
|
[
"public",
"static",
"boolean",
"isWord",
"(",
"String",
"wordString",
")",
"{",
"return",
"Optional",
".",
"ofNullable",
"(",
"wordPattern",
")",
".",
"orElseGet",
"(",
"(",
")",
"->",
"wordPattern",
"=",
"Pattern",
".",
"compile",
"(",
"WordPattern",
")",
")",
".",
"matcher",
"(",
"wordString",
")",
".",
"matches",
"(",
")",
";",
"}"
] |
Is word boolean.
@param wordString the word string
@return the boolean
|
[
"Is",
"word",
"boolean",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMString.java#L104-L108
|
154,718
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMString.java
|
JMString.joiningWith
|
public static String joiningWith(Stream<String> stringStream,
CharSequence delimiter) {
return stringStream.collect(Collectors.joining(delimiter));
}
|
java
|
public static String joiningWith(Stream<String> stringStream,
CharSequence delimiter) {
return stringStream.collect(Collectors.joining(delimiter));
}
|
[
"public",
"static",
"String",
"joiningWith",
"(",
"Stream",
"<",
"String",
">",
"stringStream",
",",
"CharSequence",
"delimiter",
")",
"{",
"return",
"stringStream",
".",
"collect",
"(",
"Collectors",
".",
"joining",
"(",
"delimiter",
")",
")",
";",
"}"
] |
Joining with string.
@param stringStream the string stream
@param delimiter the delimiter
@return the string
|
[
"Joining",
"with",
"string",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMString.java#L127-L130
|
154,719
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMString.java
|
JMString.getPrefixOfFileName
|
public static String getPrefixOfFileName(String fileName) {
int dotIndex = fileName.lastIndexOf(DOT);
return dotIndex > 0 ? fileName.substring(0, dotIndex) : fileName;
}
|
java
|
public static String getPrefixOfFileName(String fileName) {
int dotIndex = fileName.lastIndexOf(DOT);
return dotIndex > 0 ? fileName.substring(0, dotIndex) : fileName;
}
|
[
"public",
"static",
"String",
"getPrefixOfFileName",
"(",
"String",
"fileName",
")",
"{",
"int",
"dotIndex",
"=",
"fileName",
".",
"lastIndexOf",
"(",
"DOT",
")",
";",
"return",
"dotIndex",
">",
"0",
"?",
"fileName",
".",
"substring",
"(",
"0",
",",
"dotIndex",
")",
":",
"fileName",
";",
"}"
] |
Gets prefix of file name.
@param fileName the file name
@return the prefix of file name
|
[
"Gets",
"prefix",
"of",
"file",
"name",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMString.java#L338-L341
|
154,720
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMString.java
|
JMString.getExtension
|
public static String getExtension(String fileName) {
int dotIndex = fileName.lastIndexOf(DOT);
return dotIndex > 0 ? fileName.substring(dotIndex) : EMPTY;
}
|
java
|
public static String getExtension(String fileName) {
int dotIndex = fileName.lastIndexOf(DOT);
return dotIndex > 0 ? fileName.substring(dotIndex) : EMPTY;
}
|
[
"public",
"static",
"String",
"getExtension",
"(",
"String",
"fileName",
")",
"{",
"int",
"dotIndex",
"=",
"fileName",
".",
"lastIndexOf",
"(",
"DOT",
")",
";",
"return",
"dotIndex",
">",
"0",
"?",
"fileName",
".",
"substring",
"(",
"dotIndex",
")",
":",
"EMPTY",
";",
"}"
] |
Gets extension.
@param fileName the file name
@return the extension
|
[
"Gets",
"extension",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMString.java#L349-L352
|
154,721
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/data/FilterParams.java
|
FilterParams.fromTuples
|
public static FilterParams fromTuples(Object... tuples) {
StringValueMap map = StringValueMap.fromTuplesArray(tuples);
return new FilterParams(map);
}
|
java
|
public static FilterParams fromTuples(Object... tuples) {
StringValueMap map = StringValueMap.fromTuplesArray(tuples);
return new FilterParams(map);
}
|
[
"public",
"static",
"FilterParams",
"fromTuples",
"(",
"Object",
"...",
"tuples",
")",
"{",
"StringValueMap",
"map",
"=",
"StringValueMap",
".",
"fromTuplesArray",
"(",
"tuples",
")",
";",
"return",
"new",
"FilterParams",
"(",
"map",
")",
";",
"}"
] |
Creates a new FilterParams from a list of key-value pairs called tuples.
@param tuples a list of values where odd elements are keys and the following
even elements are values
@return a newly created FilterParams.
|
[
"Creates",
"a",
"new",
"FilterParams",
"from",
"a",
"list",
"of",
"key",
"-",
"value",
"pairs",
"called",
"tuples",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/data/FilterParams.java#L47-L50
|
154,722
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/data/FilterParams.java
|
FilterParams.fromString
|
public static FilterParams fromString(String line) {
StringValueMap map = StringValueMap.fromString(line);
return new FilterParams(map);
}
|
java
|
public static FilterParams fromString(String line) {
StringValueMap map = StringValueMap.fromString(line);
return new FilterParams(map);
}
|
[
"public",
"static",
"FilterParams",
"fromString",
"(",
"String",
"line",
")",
"{",
"StringValueMap",
"map",
"=",
"StringValueMap",
".",
"fromString",
"(",
"line",
")",
";",
"return",
"new",
"FilterParams",
"(",
"map",
")",
";",
"}"
] |
Parses semicolon-separated key-value pairs and returns them as a
FilterParams.
@param line semicolon-separated key-value list to initialize FilterParams.
@return a newly created FilterParams.
@see StringValueMap#toString()
|
[
"Parses",
"semicolon",
"-",
"separated",
"key",
"-",
"value",
"pairs",
"and",
"returns",
"them",
"as",
"a",
"FilterParams",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/data/FilterParams.java#L61-L64
|
154,723
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/data/FilterParams.java
|
FilterParams.fromValue
|
public static FilterParams fromValue(Object value) {
if (value instanceof FilterParams)
return (FilterParams) value;
AnyValueMap map = AnyValueMap.fromValue(value);
return new FilterParams(map);
}
|
java
|
public static FilterParams fromValue(Object value) {
if (value instanceof FilterParams)
return (FilterParams) value;
AnyValueMap map = AnyValueMap.fromValue(value);
return new FilterParams(map);
}
|
[
"public",
"static",
"FilterParams",
"fromValue",
"(",
"Object",
"value",
")",
"{",
"if",
"(",
"value",
"instanceof",
"FilterParams",
")",
"return",
"(",
"FilterParams",
")",
"value",
";",
"AnyValueMap",
"map",
"=",
"AnyValueMap",
".",
"fromValue",
"(",
"value",
")",
";",
"return",
"new",
"FilterParams",
"(",
"map",
")",
";",
"}"
] |
Converts specified value into FilterParams.
@param value value to be converted
@return a newly created FilterParams.
|
[
"Converts",
"specified",
"value",
"into",
"FilterParams",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/data/FilterParams.java#L72-L78
|
154,724
|
james-hu/jabb-core
|
src/main/java/net/sf/jabb/util/db/StartAndStopSQL.java
|
StartAndStopSQL.executeSQL
|
protected void executeSQL(String sql){
Connection conn = null;
Statement stmt = null;
if (useAnt){
try{
AntSqlExec sqlExec = new AntSqlExec(dataSource, sql, delimiter, delimiterType);
sqlExec.execute();
log.info("SQL executed with Ant: " + sql);
}catch(BuildException be){
throw new RuntimeException("Failed to execute SQL with Ant (" + be.getMessage() + "): " + sql, be);
}
}else{
try {
conn = dataSource.getConnection();
stmt = conn.createStatement();
stmt.execute(sql);
log.info("SQL executed: " + sql);
}catch(SQLException sqle){
throw new RuntimeException("Failed to execute SQL (" + sqle.getMessage() + "): " + sql, sqle);
}finally{
ConnectionUtility.closeConnection(conn, stmt);
}
}
}
|
java
|
protected void executeSQL(String sql){
Connection conn = null;
Statement stmt = null;
if (useAnt){
try{
AntSqlExec sqlExec = new AntSqlExec(dataSource, sql, delimiter, delimiterType);
sqlExec.execute();
log.info("SQL executed with Ant: " + sql);
}catch(BuildException be){
throw new RuntimeException("Failed to execute SQL with Ant (" + be.getMessage() + "): " + sql, be);
}
}else{
try {
conn = dataSource.getConnection();
stmt = conn.createStatement();
stmt.execute(sql);
log.info("SQL executed: " + sql);
}catch(SQLException sqle){
throw new RuntimeException("Failed to execute SQL (" + sqle.getMessage() + "): " + sql, sqle);
}finally{
ConnectionUtility.closeConnection(conn, stmt);
}
}
}
|
[
"protected",
"void",
"executeSQL",
"(",
"String",
"sql",
")",
"{",
"Connection",
"conn",
"=",
"null",
";",
"Statement",
"stmt",
"=",
"null",
";",
"if",
"(",
"useAnt",
")",
"{",
"try",
"{",
"AntSqlExec",
"sqlExec",
"=",
"new",
"AntSqlExec",
"(",
"dataSource",
",",
"sql",
",",
"delimiter",
",",
"delimiterType",
")",
";",
"sqlExec",
".",
"execute",
"(",
")",
";",
"log",
".",
"info",
"(",
"\"SQL executed with Ant: \"",
"+",
"sql",
")",
";",
"}",
"catch",
"(",
"BuildException",
"be",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Failed to execute SQL with Ant (\"",
"+",
"be",
".",
"getMessage",
"(",
")",
"+",
"\"): \"",
"+",
"sql",
",",
"be",
")",
";",
"}",
"}",
"else",
"{",
"try",
"{",
"conn",
"=",
"dataSource",
".",
"getConnection",
"(",
")",
";",
"stmt",
"=",
"conn",
".",
"createStatement",
"(",
")",
";",
"stmt",
".",
"execute",
"(",
"sql",
")",
";",
"log",
".",
"info",
"(",
"\"SQL executed: \"",
"+",
"sql",
")",
";",
"}",
"catch",
"(",
"SQLException",
"sqle",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Failed to execute SQL (\"",
"+",
"sqle",
".",
"getMessage",
"(",
")",
"+",
"\"): \"",
"+",
"sql",
",",
"sqle",
")",
";",
"}",
"finally",
"{",
"ConnectionUtility",
".",
"closeConnection",
"(",
"conn",
",",
"stmt",
")",
";",
"}",
"}",
"}"
] |
Execute one SQL statement. RuntimeException will be thrown if SQLException was caught.
@param sql the statement to be executed
|
[
"Execute",
"one",
"SQL",
"statement",
".",
"RuntimeException",
"will",
"be",
"thrown",
"if",
"SQLException",
"was",
"caught",
"."
] |
bceed441595c5e5195a7418795f03b69fa7b61e4
|
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/util/db/StartAndStopSQL.java#L86-L110
|
154,725
|
james-hu/jabb-core
|
src/main/java/net/sf/jabb/util/db/StartAndStopSQL.java
|
StartAndStopSQL.isInCondition
|
protected boolean isInCondition(String sql){
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try{
conn = dataSource.getConnection();
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
rs.next();
long result = rs.getInt(1);
log.debug("Result from the condition checking SQL is " + result + " : " + sql);
return result > 0;
} catch (SQLException sqle) {
throw new RuntimeException("Unable to check condition (" + sqle.getMessage() + ") for: " + sql, sqle);
}finally{
ConnectionUtility.closeConnection(conn, stmt, rs);
}
}
|
java
|
protected boolean isInCondition(String sql){
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try{
conn = dataSource.getConnection();
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
rs.next();
long result = rs.getInt(1);
log.debug("Result from the condition checking SQL is " + result + " : " + sql);
return result > 0;
} catch (SQLException sqle) {
throw new RuntimeException("Unable to check condition (" + sqle.getMessage() + ") for: " + sql, sqle);
}finally{
ConnectionUtility.closeConnection(conn, stmt, rs);
}
}
|
[
"protected",
"boolean",
"isInCondition",
"(",
"String",
"sql",
")",
"{",
"Connection",
"conn",
"=",
"null",
";",
"Statement",
"stmt",
"=",
"null",
";",
"ResultSet",
"rs",
"=",
"null",
";",
"try",
"{",
"conn",
"=",
"dataSource",
".",
"getConnection",
"(",
")",
";",
"stmt",
"=",
"conn",
".",
"createStatement",
"(",
")",
";",
"rs",
"=",
"stmt",
".",
"executeQuery",
"(",
"sql",
")",
";",
"rs",
".",
"next",
"(",
")",
";",
"long",
"result",
"=",
"rs",
".",
"getInt",
"(",
"1",
")",
";",
"log",
".",
"debug",
"(",
"\"Result from the condition checking SQL is \"",
"+",
"result",
"+",
"\" : \"",
"+",
"sql",
")",
";",
"return",
"result",
">",
"0",
";",
"}",
"catch",
"(",
"SQLException",
"sqle",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Unable to check condition (\"",
"+",
"sqle",
".",
"getMessage",
"(",
")",
"+",
"\") for: \"",
"+",
"sql",
",",
"sqle",
")",
";",
"}",
"finally",
"{",
"ConnectionUtility",
".",
"closeConnection",
"(",
"conn",
",",
"stmt",
",",
"rs",
")",
";",
"}",
"}"
] |
Check if the database is in a specific condition by checking the result of a SQL statement
@param sql the SQL statement that would return a number
@return true if the returned number is greater than 0
|
[
"Check",
"if",
"the",
"database",
"is",
"in",
"a",
"specific",
"condition",
"by",
"checking",
"the",
"result",
"of",
"a",
"SQL",
"statement"
] |
bceed441595c5e5195a7418795f03b69fa7b61e4
|
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/util/db/StartAndStopSQL.java#L187-L204
|
154,726
|
james-hu/jabb-core
|
src/main/java/net/sf/jabb/util/db/StartAndStopSQL.java
|
StartAndStopSQL.isInConditionResource
|
protected boolean isInConditionResource(String resource){
Resource sqlResource = context.getResource(resource);
InputStream in = null;
String sql = null;
try{
in = sqlResource.getInputStream();
sql = IOUtils.toString(in);
} catch(IOException ioe){
throw new RuntimeException("Failed to get condition SQL (" + ioe.getMessage() + ") from: " + resource, ioe);
}finally{
IOUtils.closeQuietly(in);
}
if (StringUtils.isNotBlank(sql)){
return isInCondition(sql);
}else{
return true;
}
}
|
java
|
protected boolean isInConditionResource(String resource){
Resource sqlResource = context.getResource(resource);
InputStream in = null;
String sql = null;
try{
in = sqlResource.getInputStream();
sql = IOUtils.toString(in);
} catch(IOException ioe){
throw new RuntimeException("Failed to get condition SQL (" + ioe.getMessage() + ") from: " + resource, ioe);
}finally{
IOUtils.closeQuietly(in);
}
if (StringUtils.isNotBlank(sql)){
return isInCondition(sql);
}else{
return true;
}
}
|
[
"protected",
"boolean",
"isInConditionResource",
"(",
"String",
"resource",
")",
"{",
"Resource",
"sqlResource",
"=",
"context",
".",
"getResource",
"(",
"resource",
")",
";",
"InputStream",
"in",
"=",
"null",
";",
"String",
"sql",
"=",
"null",
";",
"try",
"{",
"in",
"=",
"sqlResource",
".",
"getInputStream",
"(",
")",
";",
"sql",
"=",
"IOUtils",
".",
"toString",
"(",
"in",
")",
";",
"}",
"catch",
"(",
"IOException",
"ioe",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Failed to get condition SQL (\"",
"+",
"ioe",
".",
"getMessage",
"(",
")",
"+",
"\") from: \"",
"+",
"resource",
",",
"ioe",
")",
";",
"}",
"finally",
"{",
"IOUtils",
".",
"closeQuietly",
"(",
"in",
")",
";",
"}",
"if",
"(",
"StringUtils",
".",
"isNotBlank",
"(",
"sql",
")",
")",
"{",
"return",
"isInCondition",
"(",
"sql",
")",
";",
"}",
"else",
"{",
"return",
"true",
";",
"}",
"}"
] |
Check if the database is in a specific condition by checking the result of a SQL statement loaded as a resource.
@param resource the resource containing the SQL statement that would return a number
@return true if the returned number is greater than 0
|
[
"Check",
"if",
"the",
"database",
"is",
"in",
"a",
"specific",
"condition",
"by",
"checking",
"the",
"result",
"of",
"a",
"SQL",
"statement",
"loaded",
"as",
"a",
"resource",
"."
] |
bceed441595c5e5195a7418795f03b69fa7b61e4
|
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/util/db/StartAndStopSQL.java#L211-L228
|
154,727
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/helper/JMRandom.java
|
JMRandom.getBoundedNumber
|
public static int getBoundedNumber(Random random, int inclusiveLowerBound,
int exclusiveUpperBound) {
return random.nextInt(exclusiveUpperBound - inclusiveLowerBound) +
inclusiveLowerBound;
}
|
java
|
public static int getBoundedNumber(Random random, int inclusiveLowerBound,
int exclusiveUpperBound) {
return random.nextInt(exclusiveUpperBound - inclusiveLowerBound) +
inclusiveLowerBound;
}
|
[
"public",
"static",
"int",
"getBoundedNumber",
"(",
"Random",
"random",
",",
"int",
"inclusiveLowerBound",
",",
"int",
"exclusiveUpperBound",
")",
"{",
"return",
"random",
".",
"nextInt",
"(",
"exclusiveUpperBound",
"-",
"inclusiveLowerBound",
")",
"+",
"inclusiveLowerBound",
";",
"}"
] |
Gets bounded number.
@param random the random
@param inclusiveLowerBound the inclusive lower bound
@param exclusiveUpperBound the exclusive upper bound
@return the bounded number
|
[
"Gets",
"bounded",
"number",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMRandom.java#L48-L52
|
154,728
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/JMRegex.java
|
JMRegex.getMatchedListByGroup
|
public List<String> getMatchedListByGroup(String targetString) {
return getMatcherAsOpt(targetString)
.map(matcher -> rangeClosed(1, matcher.groupCount())
.mapToObj(matcher::group).map(Object::toString)
.collect(toList())).orElseGet(Collections::emptyList);
}
|
java
|
public List<String> getMatchedListByGroup(String targetString) {
return getMatcherAsOpt(targetString)
.map(matcher -> rangeClosed(1, matcher.groupCount())
.mapToObj(matcher::group).map(Object::toString)
.collect(toList())).orElseGet(Collections::emptyList);
}
|
[
"public",
"List",
"<",
"String",
">",
"getMatchedListByGroup",
"(",
"String",
"targetString",
")",
"{",
"return",
"getMatcherAsOpt",
"(",
"targetString",
")",
".",
"map",
"(",
"matcher",
"->",
"rangeClosed",
"(",
"1",
",",
"matcher",
".",
"groupCount",
"(",
")",
")",
".",
"mapToObj",
"(",
"matcher",
"::",
"group",
")",
".",
"map",
"(",
"Object",
"::",
"toString",
")",
".",
"collect",
"(",
"toList",
"(",
")",
")",
")",
".",
"orElseGet",
"(",
"Collections",
"::",
"emptyList",
")",
";",
"}"
] |
Gets matched list by group.
@param targetString the target string
@return the matched list by group
|
[
"Gets",
"matched",
"list",
"by",
"group",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/JMRegex.java#L114-L119
|
154,729
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/JMRegex.java
|
JMRegex.getGroupNameValueMap
|
public Map<String, String> getGroupNameValueMap(String targetString) {
return getMatcherAsOpt(targetString)
.map(matcher -> groupNameList.stream()
.collect(Collectors
.toMap(Function.identity(), matcher::group)))
.orElseGet(Collections::emptyMap);
}
|
java
|
public Map<String, String> getGroupNameValueMap(String targetString) {
return getMatcherAsOpt(targetString)
.map(matcher -> groupNameList.stream()
.collect(Collectors
.toMap(Function.identity(), matcher::group)))
.orElseGet(Collections::emptyMap);
}
|
[
"public",
"Map",
"<",
"String",
",",
"String",
">",
"getGroupNameValueMap",
"(",
"String",
"targetString",
")",
"{",
"return",
"getMatcherAsOpt",
"(",
"targetString",
")",
".",
"map",
"(",
"matcher",
"->",
"groupNameList",
".",
"stream",
"(",
")",
".",
"collect",
"(",
"Collectors",
".",
"toMap",
"(",
"Function",
".",
"identity",
"(",
")",
",",
"matcher",
"::",
"group",
")",
")",
")",
".",
"orElseGet",
"(",
"Collections",
"::",
"emptyMap",
")",
";",
"}"
] |
Gets group name value map.
@param targetString the target string
@return the group name value map
|
[
"Gets",
"group",
"name",
"value",
"map",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/JMRegex.java#L127-L133
|
154,730
|
morimekta/utils
|
console-util/src/main/java/net/morimekta/console/terminal/Terminal.java
|
Terminal.executeAbortable
|
public <T> T executeAbortable(ExecutorService exec, Callable<T> callable)
throws IOException, InterruptedException, ExecutionException {
Future<T> task = exec.submit(callable);
waitAbortable(task);
return task.get();
}
|
java
|
public <T> T executeAbortable(ExecutorService exec, Callable<T> callable)
throws IOException, InterruptedException, ExecutionException {
Future<T> task = exec.submit(callable);
waitAbortable(task);
return task.get();
}
|
[
"public",
"<",
"T",
">",
"T",
"executeAbortable",
"(",
"ExecutorService",
"exec",
",",
"Callable",
"<",
"T",
">",
"callable",
")",
"throws",
"IOException",
",",
"InterruptedException",
",",
"ExecutionException",
"{",
"Future",
"<",
"T",
">",
"task",
"=",
"exec",
".",
"submit",
"(",
"callable",
")",
";",
"waitAbortable",
"(",
"task",
")",
";",
"return",
"task",
".",
"get",
"(",
")",
";",
"}"
] |
Execute callable, which may not be interruptable by itself, but listen to
terminal input and abort the task if CTRL-C is pressed.
@param exec The executor to run task on.
@param callable The callable function.
@param <T> The return type of the callable.
@return The result of the callable.
@throws IOException If aborted or read failure.
@throws InterruptedException If interrupted while waiting.
@throws ExecutionException If execution failed.
|
[
"Execute",
"callable",
"which",
"may",
"not",
"be",
"interruptable",
"by",
"itself",
"but",
"listen",
"to",
"terminal",
"input",
"and",
"abort",
"the",
"task",
"if",
"CTRL",
"-",
"C",
"is",
"pressed",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/console-util/src/main/java/net/morimekta/console/terminal/Terminal.java#L226-L231
|
154,731
|
morimekta/utils
|
console-util/src/main/java/net/morimekta/console/terminal/Terminal.java
|
Terminal.finish
|
public void finish() {
try {
if (switcher.getCurrentMode() == STTYMode.RAW && lineCount > 0) {
out.write('\r');
out.write('\n');
out.flush();
}
lineCount = 0;
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
|
java
|
public void finish() {
try {
if (switcher.getCurrentMode() == STTYMode.RAW && lineCount > 0) {
out.write('\r');
out.write('\n');
out.flush();
}
lineCount = 0;
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
|
[
"public",
"void",
"finish",
"(",
")",
"{",
"try",
"{",
"if",
"(",
"switcher",
".",
"getCurrentMode",
"(",
")",
"==",
"STTYMode",
".",
"RAW",
"&&",
"lineCount",
">",
"0",
")",
"{",
"out",
".",
"write",
"(",
"'",
"'",
")",
";",
"out",
".",
"write",
"(",
"'",
"'",
")",
";",
"out",
".",
"flush",
"(",
")",
";",
"}",
"lineCount",
"=",
"0",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"UncheckedIOException",
"(",
"e",
")",
";",
"}",
"}"
] |
Finish the current set of lines and continue below.
|
[
"Finish",
"the",
"current",
"set",
"of",
"lines",
"and",
"continue",
"below",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/console-util/src/main/java/net/morimekta/console/terminal/Terminal.java#L300-L311
|
154,732
|
foundation-runtime/service-directory
|
2.0/sd-core/src/main/java/com/cisco/oss/foundation/directory/Configurations.java
|
Configurations.getConfiguration
|
public static Configuration getConfiguration(){
if(configurations == null){
configurations = ConfigurationFactory.getConfiguration();
LOGGER.info("Initialized the Configurations.");
}
return configurations;
}
|
java
|
public static Configuration getConfiguration(){
if(configurations == null){
configurations = ConfigurationFactory.getConfiguration();
LOGGER.info("Initialized the Configurations.");
}
return configurations;
}
|
[
"public",
"static",
"Configuration",
"getConfiguration",
"(",
")",
"{",
"if",
"(",
"configurations",
"==",
"null",
")",
"{",
"configurations",
"=",
"ConfigurationFactory",
".",
"getConfiguration",
"(",
")",
";",
"LOGGER",
".",
"info",
"(",
"\"Initialized the Configurations.\"",
")",
";",
"}",
"return",
"configurations",
";",
"}"
] |
Get the Configuration.
@return
the Apache Configuration.
|
[
"Get",
"the",
"Configuration",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-core/src/main/java/com/cisco/oss/foundation/directory/Configurations.java#L56-L62
|
154,733
|
foundation-runtime/service-directory
|
2.0/sd-core/src/main/java/com/cisco/oss/foundation/directory/Configurations.java
|
Configurations.getStringArray
|
public static String[] getStringArray(String name){
if(getConfiguration().containsKey(name)){
return getConfiguration().getStringArray(name);
}
return null;
}
|
java
|
public static String[] getStringArray(String name){
if(getConfiguration().containsKey(name)){
return getConfiguration().getStringArray(name);
}
return null;
}
|
[
"public",
"static",
"String",
"[",
"]",
"getStringArray",
"(",
"String",
"name",
")",
"{",
"if",
"(",
"getConfiguration",
"(",
")",
".",
"containsKey",
"(",
"name",
")",
")",
"{",
"return",
"getConfiguration",
"(",
")",
".",
"getStringArray",
"(",
"name",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Get the property object as String Array.
@param name
property name.
@return
property value as String Array.
|
[
"Get",
"the",
"property",
"object",
"as",
"String",
"Array",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-core/src/main/java/com/cisco/oss/foundation/directory/Configurations.java#L276-L281
|
154,734
|
foundation-runtime/service-directory
|
2.0/sd-core/src/main/java/com/cisco/oss/foundation/directory/Configurations.java
|
Configurations.getList
|
public static List<Object> getList(String name){
if(getConfiguration().containsKey(name)){
return getConfiguration().getList(name);
}
return null;
}
|
java
|
public static List<Object> getList(String name){
if(getConfiguration().containsKey(name)){
return getConfiguration().getList(name);
}
return null;
}
|
[
"public",
"static",
"List",
"<",
"Object",
">",
"getList",
"(",
"String",
"name",
")",
"{",
"if",
"(",
"getConfiguration",
"(",
")",
".",
"containsKey",
"(",
"name",
")",
")",
"{",
"return",
"getConfiguration",
"(",
")",
".",
"getList",
"(",
"name",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Get the property object as List.
@param name
property name.
@return
property value as List.
|
[
"Get",
"the",
"property",
"object",
"as",
"List",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-core/src/main/java/com/cisco/oss/foundation/directory/Configurations.java#L291-L296
|
154,735
|
foundation-runtime/service-directory
|
2.0/sd-core/src/main/java/com/cisco/oss/foundation/directory/Configurations.java
|
Configurations.loadCustomerProperties
|
public static void loadCustomerProperties(Properties props){
for(Entry<Object, Object> entry : props.entrySet()){
setProperty((String)entry.getKey(), entry.getValue());
}
}
|
java
|
public static void loadCustomerProperties(Properties props){
for(Entry<Object, Object> entry : props.entrySet()){
setProperty((String)entry.getKey(), entry.getValue());
}
}
|
[
"public",
"static",
"void",
"loadCustomerProperties",
"(",
"Properties",
"props",
")",
"{",
"for",
"(",
"Entry",
"<",
"Object",
",",
"Object",
">",
"entry",
":",
"props",
".",
"entrySet",
"(",
")",
")",
"{",
"setProperty",
"(",
"(",
"String",
")",
"entry",
".",
"getKey",
"(",
")",
",",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}"
] |
Load the customer Properties to Configurations.
@param props
the customer Properties.
|
[
"Load",
"the",
"customer",
"Properties",
"to",
"Configurations",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-core/src/main/java/com/cisco/oss/foundation/directory/Configurations.java#L316-L320
|
154,736
|
PureSolTechnologies/parsers
|
parsers/src/main/java/com/puresoltechnologies/parsers/parser/functions/Closure0.java
|
Closure0.calc
|
public LR0ItemSet calc(LR0ItemSet initialItemSet) {
LR0ItemSet result = closures.get(initialItemSet);
if (result == null) {
return calculate(initialItemSet);
}
return result;
}
|
java
|
public LR0ItemSet calc(LR0ItemSet initialItemSet) {
LR0ItemSet result = closures.get(initialItemSet);
if (result == null) {
return calculate(initialItemSet);
}
return result;
}
|
[
"public",
"LR0ItemSet",
"calc",
"(",
"LR0ItemSet",
"initialItemSet",
")",
"{",
"LR0ItemSet",
"result",
"=",
"closures",
".",
"get",
"(",
"initialItemSet",
")",
";",
"if",
"(",
"result",
"==",
"null",
")",
"{",
"return",
"calculate",
"(",
"initialItemSet",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
This is the closure method for a set of items. This method is described
in the Dragon Book 4.6.2.
@param initialItemSet
is the {@link LR0ItemSet} to be used.
@return A complete set of items is returned containing the parameter
items and all calculated extensions.
|
[
"This",
"is",
"the",
"closure",
"method",
"for",
"a",
"set",
"of",
"items",
".",
"This",
"method",
"is",
"described",
"in",
"the",
"Dragon",
"Book",
"4",
".",
"6",
".",
"2",
"."
] |
61077223b90d3768ff9445ae13036343c98b63cd
|
https://github.com/PureSolTechnologies/parsers/blob/61077223b90d3768ff9445ae13036343c98b63cd/parsers/src/main/java/com/puresoltechnologies/parsers/parser/functions/Closure0.java#L57-L63
|
154,737
|
foundation-runtime/service-directory
|
1.2/sd-core/src/main/java/com/cisco/oss/foundation/directory/entity/InstanceChange.java
|
InstanceChange.toServiceInstanceChange
|
public static InstanceChange<ServiceInstance> toServiceInstanceChange(InstanceChange<ModelServiceInstance> modelInstanceChange){
Objects.requireNonNull(modelInstanceChange);
return new InstanceChange<ServiceInstance>(modelInstanceChange.changedTimeMills,
modelInstanceChange.serviceName,
modelInstanceChange.changeType,
modelInstanceChange.from==null?null:toServiceInstance(modelInstanceChange.from),
modelInstanceChange.to==null?null:toServiceInstance(modelInstanceChange.to));
}
|
java
|
public static InstanceChange<ServiceInstance> toServiceInstanceChange(InstanceChange<ModelServiceInstance> modelInstanceChange){
Objects.requireNonNull(modelInstanceChange);
return new InstanceChange<ServiceInstance>(modelInstanceChange.changedTimeMills,
modelInstanceChange.serviceName,
modelInstanceChange.changeType,
modelInstanceChange.from==null?null:toServiceInstance(modelInstanceChange.from),
modelInstanceChange.to==null?null:toServiceInstance(modelInstanceChange.to));
}
|
[
"public",
"static",
"InstanceChange",
"<",
"ServiceInstance",
">",
"toServiceInstanceChange",
"(",
"InstanceChange",
"<",
"ModelServiceInstance",
">",
"modelInstanceChange",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"modelInstanceChange",
")",
";",
"return",
"new",
"InstanceChange",
"<",
"ServiceInstance",
">",
"(",
"modelInstanceChange",
".",
"changedTimeMills",
",",
"modelInstanceChange",
".",
"serviceName",
",",
"modelInstanceChange",
".",
"changeType",
",",
"modelInstanceChange",
".",
"from",
"==",
"null",
"?",
"null",
":",
"toServiceInstance",
"(",
"modelInstanceChange",
".",
"from",
")",
",",
"modelInstanceChange",
".",
"to",
"==",
"null",
"?",
"null",
":",
"toServiceInstance",
"(",
"modelInstanceChange",
".",
"to",
")",
")",
";",
"}"
] |
Convert the model service instance change to the service instance change object
@param modelInstanceChange
@return InstanceChange<ServiceInstance>
|
[
"Convert",
"the",
"model",
"service",
"instance",
"change",
"to",
"the",
"service",
"instance",
"change",
"object"
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.2/sd-core/src/main/java/com/cisco/oss/foundation/directory/entity/InstanceChange.java#L97-L104
|
154,738
|
hudson3-plugins/warnings-plugin
|
src/main/java/hudson/plugins/warnings/parser/GroovyExpressionMatcher.java
|
GroovyExpressionMatcher.createWarning
|
public Warning createWarning(final Matcher matcher) {
compileScriptIfNotYetDone();
Binding binding = new Binding();
binding.setVariable("matcher", matcher);
Object result = null;
try {
compiled.setBinding(binding);
result = compiled.run();
if (result instanceof Warning) {
return (Warning)result;
}
}
catch (Exception exception) { // NOCHECKSTYLE: catch all exceptions of the Groovy script
LOGGER.log(Level.SEVERE, "Groovy dynamic warnings parser: exception during parsing: ", exception);
}
return falsePositive;
}
|
java
|
public Warning createWarning(final Matcher matcher) {
compileScriptIfNotYetDone();
Binding binding = new Binding();
binding.setVariable("matcher", matcher);
Object result = null;
try {
compiled.setBinding(binding);
result = compiled.run();
if (result instanceof Warning) {
return (Warning)result;
}
}
catch (Exception exception) { // NOCHECKSTYLE: catch all exceptions of the Groovy script
LOGGER.log(Level.SEVERE, "Groovy dynamic warnings parser: exception during parsing: ", exception);
}
return falsePositive;
}
|
[
"public",
"Warning",
"createWarning",
"(",
"final",
"Matcher",
"matcher",
")",
"{",
"compileScriptIfNotYetDone",
"(",
")",
";",
"Binding",
"binding",
"=",
"new",
"Binding",
"(",
")",
";",
"binding",
".",
"setVariable",
"(",
"\"matcher\"",
",",
"matcher",
")",
";",
"Object",
"result",
"=",
"null",
";",
"try",
"{",
"compiled",
".",
"setBinding",
"(",
"binding",
")",
";",
"result",
"=",
"compiled",
".",
"run",
"(",
")",
";",
"if",
"(",
"result",
"instanceof",
"Warning",
")",
"{",
"return",
"(",
"Warning",
")",
"result",
";",
"}",
"}",
"catch",
"(",
"Exception",
"exception",
")",
"{",
"// NOCHECKSTYLE: catch all exceptions of the Groovy script\r",
"LOGGER",
".",
"log",
"(",
"Level",
".",
"SEVERE",
",",
"\"Groovy dynamic warnings parser: exception during parsing: \"",
",",
"exception",
")",
";",
"}",
"return",
"falsePositive",
";",
"}"
] |
Creates a new annotation for the specified match.
@param matcher
the regular expression matcher
@return a new annotation for the specified pattern
|
[
"Creates",
"a",
"new",
"annotation",
"for",
"the",
"specified",
"match",
"."
] |
462c9f3dffede9120173935567392b22520b0966
|
https://github.com/hudson3-plugins/warnings-plugin/blob/462c9f3dffede9120173935567392b22520b0966/src/main/java/hudson/plugins/warnings/parser/GroovyExpressionMatcher.java#L62-L79
|
154,739
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/text/IndexNode.java
|
IndexNode.getCursorsByDocument
|
public Map<String, List<Cursor>> getCursorsByDocument() {
return this.getCursors().collect(Collectors.groupingBy((Cursor x) -> x.getDocument()));
}
|
java
|
public Map<String, List<Cursor>> getCursorsByDocument() {
return this.getCursors().collect(Collectors.groupingBy((Cursor x) -> x.getDocument()));
}
|
[
"public",
"Map",
"<",
"String",
",",
"List",
"<",
"Cursor",
">",
">",
"getCursorsByDocument",
"(",
")",
"{",
"return",
"this",
".",
"getCursors",
"(",
")",
".",
"collect",
"(",
"Collectors",
".",
"groupingBy",
"(",
"(",
"Cursor",
"x",
")",
"->",
"x",
".",
"getDocument",
"(",
")",
")",
")",
";",
"}"
] |
Gets cursors by document.
@return the cursors by document
|
[
"Gets",
"cursors",
"by",
"document",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/text/IndexNode.java#L63-L65
|
154,740
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/text/IndexNode.java
|
IndexNode.getCursors
|
public Stream<Cursor> getCursors() {
return LongStream.range(0, getData().cursorCount).mapToObj(i -> {
return new Cursor((CharTrieIndex) this.trie, ((CharTrieIndex) this.trie).cursors.get((int) (i + getData().firstCursorIndex)), getDepth());
});
}
|
java
|
public Stream<Cursor> getCursors() {
return LongStream.range(0, getData().cursorCount).mapToObj(i -> {
return new Cursor((CharTrieIndex) this.trie, ((CharTrieIndex) this.trie).cursors.get((int) (i + getData().firstCursorIndex)), getDepth());
});
}
|
[
"public",
"Stream",
"<",
"Cursor",
">",
"getCursors",
"(",
")",
"{",
"return",
"LongStream",
".",
"range",
"(",
"0",
",",
"getData",
"(",
")",
".",
"cursorCount",
")",
".",
"mapToObj",
"(",
"i",
"->",
"{",
"return",
"new",
"Cursor",
"(",
"(",
"CharTrieIndex",
")",
"this",
".",
"trie",
",",
"(",
"(",
"CharTrieIndex",
")",
"this",
".",
"trie",
")",
".",
"cursors",
".",
"get",
"(",
"(",
"int",
")",
"(",
"i",
"+",
"getData",
"(",
")",
".",
"firstCursorIndex",
")",
")",
",",
"getDepth",
"(",
")",
")",
";",
"}",
")",
";",
"}"
] |
Gets cursors.
@return the cursors
|
[
"Gets",
"cursors",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/text/IndexNode.java#L72-L76
|
154,741
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/text/IndexNode.java
|
IndexNode.split
|
public TrieNode split() {
if (getData().firstChildIndex < 0) {
TreeMap<Character, SerialArrayList<CursorData>> sortedChildren = new TreeMap<>(getCursors().parallel()
.collect(Collectors.groupingBy(y -> y.next().getToken(),
Collectors.reducing(new SerialArrayList<>(CursorType.INSTANCE, 0),
cursor -> new SerialArrayList<>(CursorType.INSTANCE, cursor.data),
(left, right) -> left.add(right)))));
long cursorWriteIndex = getData().firstCursorIndex;
//System.err.println(String.format("Splitting %s into children: %s", getDebugString(), sortedChildren.keySet()));
ArrayList<NodeData> childNodes = new ArrayList<>(sortedChildren.size());
for (Map.Entry<Character, SerialArrayList<CursorData>> e : sortedChildren.entrySet()) {
int length = e.getValue().length();
((CharTrieIndex) this.trie).cursors.putAll(e.getValue(), (int) cursorWriteIndex);
childNodes.add(new NodeData(e.getKey(), (short) -1, -1, length, cursorWriteIndex));
cursorWriteIndex += length;
}
int firstChildIndex = this.trie.nodes.addAll(childNodes);
short size = (short) childNodes.size();
trie.ensureParentIndexCapacity(firstChildIndex, size, index);
this.trie.nodes.update(index, data -> {
return data
.setFirstChildIndex(firstChildIndex)
.setNumberOfChildren(size);
});
return new IndexNode(this.trie, getDepth(), index, getParent());
}
else {
return this;
}
}
|
java
|
public TrieNode split() {
if (getData().firstChildIndex < 0) {
TreeMap<Character, SerialArrayList<CursorData>> sortedChildren = new TreeMap<>(getCursors().parallel()
.collect(Collectors.groupingBy(y -> y.next().getToken(),
Collectors.reducing(new SerialArrayList<>(CursorType.INSTANCE, 0),
cursor -> new SerialArrayList<>(CursorType.INSTANCE, cursor.data),
(left, right) -> left.add(right)))));
long cursorWriteIndex = getData().firstCursorIndex;
//System.err.println(String.format("Splitting %s into children: %s", getDebugString(), sortedChildren.keySet()));
ArrayList<NodeData> childNodes = new ArrayList<>(sortedChildren.size());
for (Map.Entry<Character, SerialArrayList<CursorData>> e : sortedChildren.entrySet()) {
int length = e.getValue().length();
((CharTrieIndex) this.trie).cursors.putAll(e.getValue(), (int) cursorWriteIndex);
childNodes.add(new NodeData(e.getKey(), (short) -1, -1, length, cursorWriteIndex));
cursorWriteIndex += length;
}
int firstChildIndex = this.trie.nodes.addAll(childNodes);
short size = (short) childNodes.size();
trie.ensureParentIndexCapacity(firstChildIndex, size, index);
this.trie.nodes.update(index, data -> {
return data
.setFirstChildIndex(firstChildIndex)
.setNumberOfChildren(size);
});
return new IndexNode(this.trie, getDepth(), index, getParent());
}
else {
return this;
}
}
|
[
"public",
"TrieNode",
"split",
"(",
")",
"{",
"if",
"(",
"getData",
"(",
")",
".",
"firstChildIndex",
"<",
"0",
")",
"{",
"TreeMap",
"<",
"Character",
",",
"SerialArrayList",
"<",
"CursorData",
">",
">",
"sortedChildren",
"=",
"new",
"TreeMap",
"<>",
"(",
"getCursors",
"(",
")",
".",
"parallel",
"(",
")",
".",
"collect",
"(",
"Collectors",
".",
"groupingBy",
"(",
"y",
"->",
"y",
".",
"next",
"(",
")",
".",
"getToken",
"(",
")",
",",
"Collectors",
".",
"reducing",
"(",
"new",
"SerialArrayList",
"<>",
"(",
"CursorType",
".",
"INSTANCE",
",",
"0",
")",
",",
"cursor",
"->",
"new",
"SerialArrayList",
"<>",
"(",
"CursorType",
".",
"INSTANCE",
",",
"cursor",
".",
"data",
")",
",",
"(",
"left",
",",
"right",
")",
"->",
"left",
".",
"add",
"(",
"right",
")",
")",
")",
")",
")",
";",
"long",
"cursorWriteIndex",
"=",
"getData",
"(",
")",
".",
"firstCursorIndex",
";",
"//System.err.println(String.format(\"Splitting %s into children: %s\", getDebugString(), sortedChildren.keySet()));",
"ArrayList",
"<",
"NodeData",
">",
"childNodes",
"=",
"new",
"ArrayList",
"<>",
"(",
"sortedChildren",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"Character",
",",
"SerialArrayList",
"<",
"CursorData",
">",
">",
"e",
":",
"sortedChildren",
".",
"entrySet",
"(",
")",
")",
"{",
"int",
"length",
"=",
"e",
".",
"getValue",
"(",
")",
".",
"length",
"(",
")",
";",
"(",
"(",
"CharTrieIndex",
")",
"this",
".",
"trie",
")",
".",
"cursors",
".",
"putAll",
"(",
"e",
".",
"getValue",
"(",
")",
",",
"(",
"int",
")",
"cursorWriteIndex",
")",
";",
"childNodes",
".",
"add",
"(",
"new",
"NodeData",
"(",
"e",
".",
"getKey",
"(",
")",
",",
"(",
"short",
")",
"-",
"1",
",",
"-",
"1",
",",
"length",
",",
"cursorWriteIndex",
")",
")",
";",
"cursorWriteIndex",
"+=",
"length",
";",
"}",
"int",
"firstChildIndex",
"=",
"this",
".",
"trie",
".",
"nodes",
".",
"addAll",
"(",
"childNodes",
")",
";",
"short",
"size",
"=",
"(",
"short",
")",
"childNodes",
".",
"size",
"(",
")",
";",
"trie",
".",
"ensureParentIndexCapacity",
"(",
"firstChildIndex",
",",
"size",
",",
"index",
")",
";",
"this",
".",
"trie",
".",
"nodes",
".",
"update",
"(",
"index",
",",
"data",
"->",
"{",
"return",
"data",
".",
"setFirstChildIndex",
"(",
"firstChildIndex",
")",
".",
"setNumberOfChildren",
"(",
"size",
")",
";",
"}",
")",
";",
"return",
"new",
"IndexNode",
"(",
"this",
".",
"trie",
",",
"getDepth",
"(",
")",
",",
"index",
",",
"getParent",
"(",
")",
")",
";",
"}",
"else",
"{",
"return",
"this",
";",
"}",
"}"
] |
Split trie node.
@return the trie node
|
[
"Split",
"trie",
"node",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/text/IndexNode.java#L83-L112
|
154,742
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/text/IndexNode.java
|
IndexNode.visitFirstIndex
|
public IndexNode visitFirstIndex(Consumer<? super IndexNode> visitor) {
visitor.accept(this);
IndexNode refresh = refresh();
refresh.getChildren().forEach(n -> n.visitFirstIndex(visitor));
return refresh;
}
|
java
|
public IndexNode visitFirstIndex(Consumer<? super IndexNode> visitor) {
visitor.accept(this);
IndexNode refresh = refresh();
refresh.getChildren().forEach(n -> n.visitFirstIndex(visitor));
return refresh;
}
|
[
"public",
"IndexNode",
"visitFirstIndex",
"(",
"Consumer",
"<",
"?",
"super",
"IndexNode",
">",
"visitor",
")",
"{",
"visitor",
".",
"accept",
"(",
"this",
")",
";",
"IndexNode",
"refresh",
"=",
"refresh",
"(",
")",
";",
"refresh",
".",
"getChildren",
"(",
")",
".",
"forEach",
"(",
"n",
"->",
"n",
".",
"visitFirstIndex",
"(",
"visitor",
")",
")",
";",
"return",
"refresh",
";",
"}"
] |
Visit first index index node.
@param visitor the visitor
@return the index node
|
[
"Visit",
"first",
"index",
"index",
"node",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/text/IndexNode.java#L135-L140
|
154,743
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/text/IndexNode.java
|
IndexNode.visitLastIndex
|
public IndexNode visitLastIndex(Consumer<? super IndexNode> visitor) {
getChildren().forEach(n -> n.visitLastIndex(visitor));
visitor.accept(this);
return refresh();
}
|
java
|
public IndexNode visitLastIndex(Consumer<? super IndexNode> visitor) {
getChildren().forEach(n -> n.visitLastIndex(visitor));
visitor.accept(this);
return refresh();
}
|
[
"public",
"IndexNode",
"visitLastIndex",
"(",
"Consumer",
"<",
"?",
"super",
"IndexNode",
">",
"visitor",
")",
"{",
"getChildren",
"(",
")",
".",
"forEach",
"(",
"n",
"->",
"n",
".",
"visitLastIndex",
"(",
"visitor",
")",
")",
";",
"visitor",
".",
"accept",
"(",
"this",
")",
";",
"return",
"refresh",
"(",
")",
";",
"}"
] |
Visit last index index node.
@param visitor the visitor
@return the index node
|
[
"Visit",
"last",
"index",
"index",
"node",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/text/IndexNode.java#L148-L152
|
154,744
|
bushidowallet/bushido-java-service
|
bushido-service-lib/src/main/java/com/bccapi/bitlib/crypto/PublicKeyRing.java
|
PublicKeyRing.addPublicKey
|
public void addPublicKey(PublicKey key, NetworkParameters network) {
Address address = Address.fromStandardPublicKey(key, network);
_addresses.add(address);
_addressSet.add(address);
_publicKeys.put(address, key);
}
|
java
|
public void addPublicKey(PublicKey key, NetworkParameters network) {
Address address = Address.fromStandardPublicKey(key, network);
_addresses.add(address);
_addressSet.add(address);
_publicKeys.put(address, key);
}
|
[
"public",
"void",
"addPublicKey",
"(",
"PublicKey",
"key",
",",
"NetworkParameters",
"network",
")",
"{",
"Address",
"address",
"=",
"Address",
".",
"fromStandardPublicKey",
"(",
"key",
",",
"network",
")",
";",
"_addresses",
".",
"add",
"(",
"address",
")",
";",
"_addressSet",
".",
"add",
"(",
"address",
")",
";",
"_publicKeys",
".",
"put",
"(",
"address",
",",
"key",
")",
";",
"}"
] |
Add a public key to the key ring.
@param key public key
@param network Bitcoin network to talk to
|
[
"Add",
"a",
"public",
"key",
"to",
"the",
"key",
"ring",
"."
] |
e1a0157527e57459b509718044d2df44084876a2
|
https://github.com/bushidowallet/bushido-java-service/blob/e1a0157527e57459b509718044d2df44084876a2/bushido-service-lib/src/main/java/com/bccapi/bitlib/crypto/PublicKeyRing.java#L25-L30
|
154,745
|
ksclarke/vertx-pairtree
|
src/main/java/info/freelibrary/pairtree/PairtreeFactory.java
|
PairtreeFactory.getPrefixedPairtree
|
public Pairtree getPrefixedPairtree(final String aPrefix, final File aDirectory) throws PairtreeException {
return new FsPairtree(aPrefix, myVertx, getDirPath(aDirectory));
}
|
java
|
public Pairtree getPrefixedPairtree(final String aPrefix, final File aDirectory) throws PairtreeException {
return new FsPairtree(aPrefix, myVertx, getDirPath(aDirectory));
}
|
[
"public",
"Pairtree",
"getPrefixedPairtree",
"(",
"final",
"String",
"aPrefix",
",",
"final",
"File",
"aDirectory",
")",
"throws",
"PairtreeException",
"{",
"return",
"new",
"FsPairtree",
"(",
"aPrefix",
",",
"myVertx",
",",
"getDirPath",
"(",
"aDirectory",
")",
")",
";",
"}"
] |
Gets a file system based Pairtree using the supplied directory as the Pairtree root and the supplied prefix as
the Pairtree prefix.
@param aPrefix A Pairtree prefix
@param aDirectory A directory to use for the Pairtree root
@return A Pairtree root
@throws PairtreeException If there is trouble creating the Pairtree
|
[
"Gets",
"a",
"file",
"system",
"based",
"Pairtree",
"using",
"the",
"supplied",
"directory",
"as",
"the",
"Pairtree",
"root",
"and",
"the",
"supplied",
"prefix",
"as",
"the",
"Pairtree",
"prefix",
"."
] |
b2ea1e32057e5df262e9265540d346a732b718df
|
https://github.com/ksclarke/vertx-pairtree/blob/b2ea1e32057e5df262e9265540d346a732b718df/src/main/java/info/freelibrary/pairtree/PairtreeFactory.java#L83-L85
|
154,746
|
ksclarke/vertx-pairtree
|
src/main/java/info/freelibrary/pairtree/PairtreeFactory.java
|
PairtreeFactory.getPairtree
|
public Pairtree getPairtree(final String aBucket, final String aBucketPath) throws PairtreeException {
if (myAccessKey.isPresent() && mySecretKey.isPresent()) {
final String accessKey = myAccessKey.get();
final String secretKey = mySecretKey.get();
if (myRegion.isPresent()) {
return new S3Pairtree(myVertx, aBucket, aBucketPath, accessKey, secretKey, myRegion.get());
} else {
return new S3Pairtree(myVertx, aBucket, aBucketPath, accessKey, secretKey);
}
} else {
throw new PairtreeException(MessageCodes.PT_021);
}
}
|
java
|
public Pairtree getPairtree(final String aBucket, final String aBucketPath) throws PairtreeException {
if (myAccessKey.isPresent() && mySecretKey.isPresent()) {
final String accessKey = myAccessKey.get();
final String secretKey = mySecretKey.get();
if (myRegion.isPresent()) {
return new S3Pairtree(myVertx, aBucket, aBucketPath, accessKey, secretKey, myRegion.get());
} else {
return new S3Pairtree(myVertx, aBucket, aBucketPath, accessKey, secretKey);
}
} else {
throw new PairtreeException(MessageCodes.PT_021);
}
}
|
[
"public",
"Pairtree",
"getPairtree",
"(",
"final",
"String",
"aBucket",
",",
"final",
"String",
"aBucketPath",
")",
"throws",
"PairtreeException",
"{",
"if",
"(",
"myAccessKey",
".",
"isPresent",
"(",
")",
"&&",
"mySecretKey",
".",
"isPresent",
"(",
")",
")",
"{",
"final",
"String",
"accessKey",
"=",
"myAccessKey",
".",
"get",
"(",
")",
";",
"final",
"String",
"secretKey",
"=",
"mySecretKey",
".",
"get",
"(",
")",
";",
"if",
"(",
"myRegion",
".",
"isPresent",
"(",
")",
")",
"{",
"return",
"new",
"S3Pairtree",
"(",
"myVertx",
",",
"aBucket",
",",
"aBucketPath",
",",
"accessKey",
",",
"secretKey",
",",
"myRegion",
".",
"get",
"(",
")",
")",
";",
"}",
"else",
"{",
"return",
"new",
"S3Pairtree",
"(",
"myVertx",
",",
"aBucket",
",",
"aBucketPath",
",",
"accessKey",
",",
"secretKey",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"PairtreeException",
"(",
"MessageCodes",
".",
"PT_021",
")",
";",
"}",
"}"
] |
Gets the S3 based Pairtree using the supplied S3 bucket and bucket path.
@param aBucket An S3 bucket in which to create the Pairtree
@param aBucketPath A path in the S3 bucket at which to put the Pairtree
@return A Pairtree root
@throws PairtreeException If there is trouble creating the Pairtree
|
[
"Gets",
"the",
"S3",
"based",
"Pairtree",
"using",
"the",
"supplied",
"S3",
"bucket",
"and",
"bucket",
"path",
"."
] |
b2ea1e32057e5df262e9265540d346a732b718df
|
https://github.com/ksclarke/vertx-pairtree/blob/b2ea1e32057e5df262e9265540d346a732b718df/src/main/java/info/freelibrary/pairtree/PairtreeFactory.java#L140-L153
|
154,747
|
ksclarke/vertx-pairtree
|
src/main/java/info/freelibrary/pairtree/PairtreeFactory.java
|
PairtreeFactory.getPairtree
|
public Pairtree getPairtree(final String aBucket, final String aAccessKey, final String aSecretKey) {
return new S3Pairtree(myVertx, aBucket, aAccessKey, aSecretKey);
}
|
java
|
public Pairtree getPairtree(final String aBucket, final String aAccessKey, final String aSecretKey) {
return new S3Pairtree(myVertx, aBucket, aAccessKey, aSecretKey);
}
|
[
"public",
"Pairtree",
"getPairtree",
"(",
"final",
"String",
"aBucket",
",",
"final",
"String",
"aAccessKey",
",",
"final",
"String",
"aSecretKey",
")",
"{",
"return",
"new",
"S3Pairtree",
"(",
"myVertx",
",",
"aBucket",
",",
"aAccessKey",
",",
"aSecretKey",
")",
";",
"}"
] |
Creates a Pairtree using the supplied bucket and AWS credentials.
@param aBucket An S3 bucket
@param aAccessKey An AWS access key
@param aSecretKey An AWS secret key
@return A Pairtree
|
[
"Creates",
"a",
"Pairtree",
"using",
"the",
"supplied",
"bucket",
"and",
"AWS",
"credentials",
"."
] |
b2ea1e32057e5df262e9265540d346a732b718df
|
https://github.com/ksclarke/vertx-pairtree/blob/b2ea1e32057e5df262e9265540d346a732b718df/src/main/java/info/freelibrary/pairtree/PairtreeFactory.java#L188-L190
|
154,748
|
ksclarke/vertx-pairtree
|
src/main/java/info/freelibrary/pairtree/PairtreeFactory.java
|
PairtreeFactory.getPrefixedPairtree
|
public Pairtree getPrefixedPairtree(final String aPrefix, final String aBucket, final String aBucketPath,
final String aAccessKey, final String aSecretKey) {
return new S3Pairtree(aPrefix, myVertx, aBucket, aBucketPath, aAccessKey, aSecretKey);
}
|
java
|
public Pairtree getPrefixedPairtree(final String aPrefix, final String aBucket, final String aBucketPath,
final String aAccessKey, final String aSecretKey) {
return new S3Pairtree(aPrefix, myVertx, aBucket, aBucketPath, aAccessKey, aSecretKey);
}
|
[
"public",
"Pairtree",
"getPrefixedPairtree",
"(",
"final",
"String",
"aPrefix",
",",
"final",
"String",
"aBucket",
",",
"final",
"String",
"aBucketPath",
",",
"final",
"String",
"aAccessKey",
",",
"final",
"String",
"aSecretKey",
")",
"{",
"return",
"new",
"S3Pairtree",
"(",
"aPrefix",
",",
"myVertx",
",",
"aBucket",
",",
"aBucketPath",
",",
"aAccessKey",
",",
"aSecretKey",
")",
";",
"}"
] |
Creates a Pairtree, with the supplied prefix, using the supplied S3 bucket and internal bucket path.
@param aPrefix A Pairtree prefix
@param aBucket An S3 bucket
@param aBucketPath A path in the S3 bucket to the Pairtree root
@param aAccessKey An AWS access key
@param aSecretKey An AWS secret key
@return A Pairtree
|
[
"Creates",
"a",
"Pairtree",
"with",
"the",
"supplied",
"prefix",
"using",
"the",
"supplied",
"S3",
"bucket",
"and",
"internal",
"bucket",
"path",
"."
] |
b2ea1e32057e5df262e9265540d346a732b718df
|
https://github.com/ksclarke/vertx-pairtree/blob/b2ea1e32057e5df262e9265540d346a732b718df/src/main/java/info/freelibrary/pairtree/PairtreeFactory.java#L274-L277
|
154,749
|
PureSolTechnologies/commons
|
types/src/main/java/com/puresoltechnologies/commons/types/EmailAddress.java
|
EmailAddress.validate
|
public static void validate(String address) throws IllegalEmailAddressException {
if (address == null) {
throw new IllegalEmailAddressException("<null>", "Email address is null.");
}
if (address.length() > 254) {
throw new IllegalEmailAddressException(address, "Email address is longer than 254 characters.");
}
String[] parts = address.split("@");
if (parts.length < 2) {
int index = address.indexOf('@');
if (index == 0) {
throw new IllegalEmailAddressException(address, "Local part must not be empty.");
} else if (index == (address.length() - 1)) {
throw new IllegalEmailAddressException(address, "Domain part must not be empty.");
}
throw new IllegalEmailAddressException(address, "No @ character included.");
}
if (parts.length > 2) {
throw new IllegalEmailAddressException(address, "Multiple @ characters included.");
}
try {
validateDomainPart(parts[1]);
validateLocalPart(parts[0]);
} catch (IllegalEmailAddressException e) {
throw new IllegalEmailAddressException(address, e.getReason());
}
}
|
java
|
public static void validate(String address) throws IllegalEmailAddressException {
if (address == null) {
throw new IllegalEmailAddressException("<null>", "Email address is null.");
}
if (address.length() > 254) {
throw new IllegalEmailAddressException(address, "Email address is longer than 254 characters.");
}
String[] parts = address.split("@");
if (parts.length < 2) {
int index = address.indexOf('@');
if (index == 0) {
throw new IllegalEmailAddressException(address, "Local part must not be empty.");
} else if (index == (address.length() - 1)) {
throw new IllegalEmailAddressException(address, "Domain part must not be empty.");
}
throw new IllegalEmailAddressException(address, "No @ character included.");
}
if (parts.length > 2) {
throw new IllegalEmailAddressException(address, "Multiple @ characters included.");
}
try {
validateDomainPart(parts[1]);
validateLocalPart(parts[0]);
} catch (IllegalEmailAddressException e) {
throw new IllegalEmailAddressException(address, e.getReason());
}
}
|
[
"public",
"static",
"void",
"validate",
"(",
"String",
"address",
")",
"throws",
"IllegalEmailAddressException",
"{",
"if",
"(",
"address",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalEmailAddressException",
"(",
"\"<null>\"",
",",
"\"Email address is null.\"",
")",
";",
"}",
"if",
"(",
"address",
".",
"length",
"(",
")",
">",
"254",
")",
"{",
"throw",
"new",
"IllegalEmailAddressException",
"(",
"address",
",",
"\"Email address is longer than 254 characters.\"",
")",
";",
"}",
"String",
"[",
"]",
"parts",
"=",
"address",
".",
"split",
"(",
"\"@\"",
")",
";",
"if",
"(",
"parts",
".",
"length",
"<",
"2",
")",
"{",
"int",
"index",
"=",
"address",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"index",
"==",
"0",
")",
"{",
"throw",
"new",
"IllegalEmailAddressException",
"(",
"address",
",",
"\"Local part must not be empty.\"",
")",
";",
"}",
"else",
"if",
"(",
"index",
"==",
"(",
"address",
".",
"length",
"(",
")",
"-",
"1",
")",
")",
"{",
"throw",
"new",
"IllegalEmailAddressException",
"(",
"address",
",",
"\"Domain part must not be empty.\"",
")",
";",
"}",
"throw",
"new",
"IllegalEmailAddressException",
"(",
"address",
",",
"\"No @ character included.\"",
")",
";",
"}",
"if",
"(",
"parts",
".",
"length",
">",
"2",
")",
"{",
"throw",
"new",
"IllegalEmailAddressException",
"(",
"address",
",",
"\"Multiple @ characters included.\"",
")",
";",
"}",
"try",
"{",
"validateDomainPart",
"(",
"parts",
"[",
"1",
"]",
")",
";",
"validateLocalPart",
"(",
"parts",
"[",
"0",
"]",
")",
";",
"}",
"catch",
"(",
"IllegalEmailAddressException",
"e",
")",
"{",
"throw",
"new",
"IllegalEmailAddressException",
"(",
"address",
",",
"e",
".",
"getReason",
"(",
")",
")",
";",
"}",
"}"
] |
Validates an email address format.
@param address is the email address string to validate.
@throws IllegalEmailAddressException is thrown in case of an invalid address.
|
[
"Validates",
"an",
"email",
"address",
"format",
"."
] |
f98c23d8841a1ff61632ff17fe7d24f99dbc1d44
|
https://github.com/PureSolTechnologies/commons/blob/f98c23d8841a1ff61632ff17fe7d24f99dbc1d44/types/src/main/java/com/puresoltechnologies/commons/types/EmailAddress.java#L46-L72
|
154,750
|
lorenzodee/jBlubble
|
jblubble-sample/src/main/java/com/orangeandbronze/jblubble/sample/PersonController.java
|
PersonController.getPersonById
|
protected Person getPersonById(String id) {
Person person = null;
try {
Long personId = Long.valueOf(id);
if (logger.isDebugEnabled()) {
logger.debug("Retrieving Person with id=[{}]", personId);
}
person = entityManager.find(Person.class, personId);
} catch (NumberFormatException e) {
if (logger.isWarnEnabled()) {
logger.warn("Invalid number format: {}", id);
}
}
if (person == null) {
throw new IllegalArgumentException();
}
return person;
}
|
java
|
protected Person getPersonById(String id) {
Person person = null;
try {
Long personId = Long.valueOf(id);
if (logger.isDebugEnabled()) {
logger.debug("Retrieving Person with id=[{}]", personId);
}
person = entityManager.find(Person.class, personId);
} catch (NumberFormatException e) {
if (logger.isWarnEnabled()) {
logger.warn("Invalid number format: {}", id);
}
}
if (person == null) {
throw new IllegalArgumentException();
}
return person;
}
|
[
"protected",
"Person",
"getPersonById",
"(",
"String",
"id",
")",
"{",
"Person",
"person",
"=",
"null",
";",
"try",
"{",
"Long",
"personId",
"=",
"Long",
".",
"valueOf",
"(",
"id",
")",
";",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"logger",
".",
"debug",
"(",
"\"Retrieving Person with id=[{}]\"",
",",
"personId",
")",
";",
"}",
"person",
"=",
"entityManager",
".",
"find",
"(",
"Person",
".",
"class",
",",
"personId",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"e",
")",
"{",
"if",
"(",
"logger",
".",
"isWarnEnabled",
"(",
")",
")",
"{",
"logger",
".",
"warn",
"(",
"\"Invalid number format: {}\"",
",",
"id",
")",
";",
"}",
"}",
"if",
"(",
"person",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"}",
"return",
"person",
";",
"}"
] |
Retrieves the person with the given id. Throwing an
IllegalArgumentException if there is no such person.
@param id
the given id
@return the person with the given id
|
[
"Retrieves",
"the",
"person",
"with",
"the",
"given",
"id",
".",
"Throwing",
"an",
"IllegalArgumentException",
"if",
"there",
"is",
"no",
"such",
"person",
"."
] |
7ce26dadeaaa45e5d15bc2786eb882aabd771e52
|
https://github.com/lorenzodee/jBlubble/blob/7ce26dadeaaa45e5d15bc2786eb882aabd771e52/jblubble-sample/src/main/java/com/orangeandbronze/jblubble/sample/PersonController.java#L77-L94
|
154,751
|
james-hu/jabb-core
|
src/main/java/net/sf/jabb/util/parallel/BackoffStrategies.java
|
BackoffStrategies.fixedBackoff
|
public static BackoffStrategy fixedBackoff(long sleepTime, TimeUnit timeUnit) throws IllegalStateException {
Preconditions.checkNotNull(timeUnit, "The time unit may not be null");
return new FixedBackoffStrategy(timeUnit.toMillis(sleepTime));
}
|
java
|
public static BackoffStrategy fixedBackoff(long sleepTime, TimeUnit timeUnit) throws IllegalStateException {
Preconditions.checkNotNull(timeUnit, "The time unit may not be null");
return new FixedBackoffStrategy(timeUnit.toMillis(sleepTime));
}
|
[
"public",
"static",
"BackoffStrategy",
"fixedBackoff",
"(",
"long",
"sleepTime",
",",
"TimeUnit",
"timeUnit",
")",
"throws",
"IllegalStateException",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"timeUnit",
",",
"\"The time unit may not be null\"",
")",
";",
"return",
"new",
"FixedBackoffStrategy",
"(",
"timeUnit",
".",
"toMillis",
"(",
"sleepTime",
")",
")",
";",
"}"
] |
Returns a backoff strategy that waits a fixed amount of time before retrying.
@param sleepTime the time to wait
@param timeUnit the unit of the time to wait
@return a backoff strategy that waits a fixed amount of time
@throws IllegalStateException if the wait time is < 0
|
[
"Returns",
"a",
"backoff",
"strategy",
"that",
"waits",
"a",
"fixed",
"amount",
"of",
"time",
"before",
"retrying",
"."
] |
bceed441595c5e5195a7418795f03b69fa7b61e4
|
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/util/parallel/BackoffStrategies.java#L58-L61
|
154,752
|
james-hu/jabb-core
|
src/main/java/net/sf/jabb/util/parallel/BackoffStrategies.java
|
BackoffStrategies.linearBackoff
|
public static BackoffStrategy linearBackoff(long initialSleepTime, TimeUnit initialSleepTimeUnit,
long increment, TimeUnit incrementTimeUnit) {
Preconditions.checkNotNull(initialSleepTimeUnit, "The initial wait time unit may not be null");
Preconditions.checkNotNull(incrementTimeUnit, "The increment time unit may not be null");
return new LinearBackoffStrategy(initialSleepTimeUnit.toMillis(initialSleepTime),
incrementTimeUnit.toMillis(increment));
}
|
java
|
public static BackoffStrategy linearBackoff(long initialSleepTime, TimeUnit initialSleepTimeUnit,
long increment, TimeUnit incrementTimeUnit) {
Preconditions.checkNotNull(initialSleepTimeUnit, "The initial wait time unit may not be null");
Preconditions.checkNotNull(incrementTimeUnit, "The increment time unit may not be null");
return new LinearBackoffStrategy(initialSleepTimeUnit.toMillis(initialSleepTime),
incrementTimeUnit.toMillis(increment));
}
|
[
"public",
"static",
"BackoffStrategy",
"linearBackoff",
"(",
"long",
"initialSleepTime",
",",
"TimeUnit",
"initialSleepTimeUnit",
",",
"long",
"increment",
",",
"TimeUnit",
"incrementTimeUnit",
")",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"initialSleepTimeUnit",
",",
"\"The initial wait time unit may not be null\"",
")",
";",
"Preconditions",
".",
"checkNotNull",
"(",
"incrementTimeUnit",
",",
"\"The increment time unit may not be null\"",
")",
";",
"return",
"new",
"LinearBackoffStrategy",
"(",
"initialSleepTimeUnit",
".",
"toMillis",
"(",
"initialSleepTime",
")",
",",
"incrementTimeUnit",
".",
"toMillis",
"(",
"increment",
")",
")",
";",
"}"
] |
Returns a strategy that waits a fixed amount of time after the first
failed attempt and in incrementing amounts of time after each additional
failed attempt.
@param initialSleepTime the time to wait before retrying the first time
@param initialSleepTimeUnit the unit of the initial wait time
@param increment the increment added to the previous wait time after each failed attempt
@param incrementTimeUnit the unit of the increment
@return a backoff strategy that incrementally waits an additional fixed time after each failed attempt
|
[
"Returns",
"a",
"strategy",
"that",
"waits",
"a",
"fixed",
"amount",
"of",
"time",
"after",
"the",
"first",
"failed",
"attempt",
"and",
"in",
"incrementing",
"amounts",
"of",
"time",
"after",
"each",
"additional",
"failed",
"attempt",
"."
] |
bceed441595c5e5195a7418795f03b69fa7b61e4
|
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/util/parallel/BackoffStrategies.java#L144-L150
|
154,753
|
james-hu/jabb-core
|
src/main/java/net/sf/jabb/util/parallel/BackoffStrategies.java
|
BackoffStrategies.exponentialBackoff
|
public static BackoffStrategy exponentialBackoff(long maximumTime, TimeUnit maximumTimeUnit) {
Preconditions.checkNotNull(maximumTimeUnit, "The maximum time unit may not be null");
return new ExponentialBackoffStrategy(1, maximumTimeUnit.toMillis(maximumTime));
}
|
java
|
public static BackoffStrategy exponentialBackoff(long maximumTime, TimeUnit maximumTimeUnit) {
Preconditions.checkNotNull(maximumTimeUnit, "The maximum time unit may not be null");
return new ExponentialBackoffStrategy(1, maximumTimeUnit.toMillis(maximumTime));
}
|
[
"public",
"static",
"BackoffStrategy",
"exponentialBackoff",
"(",
"long",
"maximumTime",
",",
"TimeUnit",
"maximumTimeUnit",
")",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"maximumTimeUnit",
",",
"\"The maximum time unit may not be null\"",
")",
";",
"return",
"new",
"ExponentialBackoffStrategy",
"(",
"1",
",",
"maximumTimeUnit",
".",
"toMillis",
"(",
"maximumTime",
")",
")",
";",
"}"
] |
Returns a strategy which waits for an exponential amount of time after the first failed attempt,
and in exponentially incrementing amounts after each failed attempt up to the maximumTime.
@param maximumTime the maximum time to wait
@param maximumTimeUnit the unit of the maximum time
@return a backoff strategy that increments with each failed attempt using exponential backoff
|
[
"Returns",
"a",
"strategy",
"which",
"waits",
"for",
"an",
"exponential",
"amount",
"of",
"time",
"after",
"the",
"first",
"failed",
"attempt",
"and",
"in",
"exponentially",
"incrementing",
"amounts",
"after",
"each",
"failed",
"attempt",
"up",
"to",
"the",
"maximumTime",
"."
] |
bceed441595c5e5195a7418795f03b69fa7b61e4
|
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/util/parallel/BackoffStrategies.java#L185-L188
|
154,754
|
james-hu/jabb-core
|
src/main/java/net/sf/jabb/util/parallel/BackoffStrategies.java
|
BackoffStrategies.join
|
public static BackoffStrategy join(BackoffStrategy... backoffStrategies) {
Preconditions.checkState(backoffStrategies.length > 0, "Must have at least one backoff strategy");
List<BackoffStrategy> waitStrategyList = Lists.newArrayList(backoffStrategies);
Preconditions.checkState(!waitStrategyList.contains(null), "Cannot have a null backoff strategy");
return new CompositeBackoffStrategy(waitStrategyList);
}
|
java
|
public static BackoffStrategy join(BackoffStrategy... backoffStrategies) {
Preconditions.checkState(backoffStrategies.length > 0, "Must have at least one backoff strategy");
List<BackoffStrategy> waitStrategyList = Lists.newArrayList(backoffStrategies);
Preconditions.checkState(!waitStrategyList.contains(null), "Cannot have a null backoff strategy");
return new CompositeBackoffStrategy(waitStrategyList);
}
|
[
"public",
"static",
"BackoffStrategy",
"join",
"(",
"BackoffStrategy",
"...",
"backoffStrategies",
")",
"{",
"Preconditions",
".",
"checkState",
"(",
"backoffStrategies",
".",
"length",
">",
"0",
",",
"\"Must have at least one backoff strategy\"",
")",
";",
"List",
"<",
"BackoffStrategy",
">",
"waitStrategyList",
"=",
"Lists",
".",
"newArrayList",
"(",
"backoffStrategies",
")",
";",
"Preconditions",
".",
"checkState",
"(",
"!",
"waitStrategyList",
".",
"contains",
"(",
"null",
")",
",",
"\"Cannot have a null backoff strategy\"",
")",
";",
"return",
"new",
"CompositeBackoffStrategy",
"(",
"waitStrategyList",
")",
";",
"}"
] |
Joins one or more wait strategies to derive a composite backoff strategy.
The new joined strategy will have a wait time which is total of all wait times computed one after another in order.
@param backoffStrategies Wait strategies that need to be applied one after another for computing the wait time.
@return A composite backoff strategy
|
[
"Joins",
"one",
"or",
"more",
"wait",
"strategies",
"to",
"derive",
"a",
"composite",
"backoff",
"strategy",
".",
"The",
"new",
"joined",
"strategy",
"will",
"have",
"a",
"wait",
"time",
"which",
"is",
"total",
"of",
"all",
"wait",
"times",
"computed",
"one",
"after",
"another",
"in",
"order",
"."
] |
bceed441595c5e5195a7418795f03b69fa7b61e4
|
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/util/parallel/BackoffStrategies.java#L306-L311
|
154,755
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/convert/JsonConverter.java
|
JsonConverter.fromJson
|
public static <T> T fromJson(Class<T> type, String value)
throws JsonMappingException, JsonParseException, IOException {
if (value == null)
return null;
return _mapper.readValue(value, type);
}
|
java
|
public static <T> T fromJson(Class<T> type, String value)
throws JsonMappingException, JsonParseException, IOException {
if (value == null)
return null;
return _mapper.readValue(value, type);
}
|
[
"public",
"static",
"<",
"T",
">",
"T",
"fromJson",
"(",
"Class",
"<",
"T",
">",
"type",
",",
"String",
"value",
")",
"throws",
"JsonMappingException",
",",
"JsonParseException",
",",
"IOException",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"return",
"null",
";",
"return",
"_mapper",
".",
"readValue",
"(",
"value",
",",
"type",
")",
";",
"}"
] |
Converts JSON string into a value of type specified by Class type.
@param type the Class type for the data type into which 'value' is to be converted.
@param value the JSON string to convert.
@return converted object value or null when value is null.
@throws JsonMappingException when conversion fails for mapping reason.
@throws JsonParseException when conversion fails for parse reason.
@throws IOException when conversion fails for input/output stream reason.
|
[
"Converts",
"JSON",
"string",
"into",
"a",
"value",
"of",
"type",
"specified",
"by",
"Class",
"type",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/convert/JsonConverter.java#L42-L47
|
154,756
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/convert/JsonConverter.java
|
JsonConverter.toJson
|
public static String toJson(Object value) throws JsonProcessingException {
if (value == null)
return null;
return _mapper.writeValueAsString(value);
}
|
java
|
public static String toJson(Object value) throws JsonProcessingException {
if (value == null)
return null;
return _mapper.writeValueAsString(value);
}
|
[
"public",
"static",
"String",
"toJson",
"(",
"Object",
"value",
")",
"throws",
"JsonProcessingException",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"return",
"null",
";",
"return",
"_mapper",
".",
"writeValueAsString",
"(",
"value",
")",
";",
"}"
] |
Converts value into JSON string.
@param value the value to convert.
@return JSON string or null when value is null.
@throws JsonProcessingException when conversion fails for any reason.
|
[
"Converts",
"value",
"into",
"JSON",
"string",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/convert/JsonConverter.java#L56-L60
|
154,757
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/convert/JsonConverter.java
|
JsonConverter.toNullableMap
|
public static Map<String, Object> toNullableMap(String value) {
if (value == null)
return null;
try {
Map<String, Object> map = _mapper.readValue((String) value, typeRef);
return RecursiveMapConverter.toNullableMap(map);
} catch (Exception ex) {
return null;
}
}
|
java
|
public static Map<String, Object> toNullableMap(String value) {
if (value == null)
return null;
try {
Map<String, Object> map = _mapper.readValue((String) value, typeRef);
return RecursiveMapConverter.toNullableMap(map);
} catch (Exception ex) {
return null;
}
}
|
[
"public",
"static",
"Map",
"<",
"String",
",",
"Object",
">",
"toNullableMap",
"(",
"String",
"value",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"return",
"null",
";",
"try",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"map",
"=",
"_mapper",
".",
"readValue",
"(",
"(",
"String",
")",
"value",
",",
"typeRef",
")",
";",
"return",
"RecursiveMapConverter",
".",
"toNullableMap",
"(",
"map",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"return",
"null",
";",
"}",
"}"
] |
Converts JSON string into map object or returns null when conversion is not
possible.
@param value the JSON string to convert.
@return Map object value or null when conversion is not supported.
@see MapConverter#toNullableMap(Object)
|
[
"Converts",
"JSON",
"string",
"into",
"map",
"object",
"or",
"returns",
"null",
"when",
"conversion",
"is",
"not",
"possible",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/convert/JsonConverter.java#L71-L81
|
154,758
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/convert/JsonConverter.java
|
JsonConverter.toMap
|
public static Map<String, Object> toMap(String value) {
Map<String, Object> result = toNullableMap(value);
return result != null ? result : new HashMap<String, Object>();
}
|
java
|
public static Map<String, Object> toMap(String value) {
Map<String, Object> result = toNullableMap(value);
return result != null ? result : new HashMap<String, Object>();
}
|
[
"public",
"static",
"Map",
"<",
"String",
",",
"Object",
">",
"toMap",
"(",
"String",
"value",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"result",
"=",
"toNullableMap",
"(",
"value",
")",
";",
"return",
"result",
"!=",
"null",
"?",
"result",
":",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"}"
] |
Converts JSON string into map object or returns empty map when conversion is
not possible.
@param value the JSON string to convert.
@return Map object value or empty object when conversion is not supported.
@see JsonConverter#toNullableMap(String)
|
[
"Converts",
"JSON",
"string",
"into",
"map",
"object",
"or",
"returns",
"empty",
"map",
"when",
"conversion",
"is",
"not",
"possible",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/convert/JsonConverter.java#L92-L95
|
154,759
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/convert/JsonConverter.java
|
JsonConverter.toMapWithDefault
|
public static Map<String, Object> toMapWithDefault(String value, Map<String, Object> defaultValue) {
Map<String, Object> result = toNullableMap(value);
return result != null ? result : defaultValue;
}
|
java
|
public static Map<String, Object> toMapWithDefault(String value, Map<String, Object> defaultValue) {
Map<String, Object> result = toNullableMap(value);
return result != null ? result : defaultValue;
}
|
[
"public",
"static",
"Map",
"<",
"String",
",",
"Object",
">",
"toMapWithDefault",
"(",
"String",
"value",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"defaultValue",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"result",
"=",
"toNullableMap",
"(",
"value",
")",
";",
"return",
"result",
"!=",
"null",
"?",
"result",
":",
"defaultValue",
";",
"}"
] |
Converts JSON string into map object or returns default value when conversion
is not possible.
@param value the JSON string to convert.
@param defaultValue the default value.
@return Map object value or default when conversion is not supported.
@see JsonConverter#toNullableMap(String)
|
[
"Converts",
"JSON",
"string",
"into",
"map",
"object",
"or",
"returns",
"default",
"value",
"when",
"conversion",
"is",
"not",
"possible",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/convert/JsonConverter.java#L107-L110
|
154,760
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/stats/NumberSummaryStatistics.java
|
NumberSummaryStatistics.addAll
|
public <N extends Number> NumberSummaryStatistics addAll(
Stream<N> numberStream) {
return addAll(numberStream.collect(toList()));
}
|
java
|
public <N extends Number> NumberSummaryStatistics addAll(
Stream<N> numberStream) {
return addAll(numberStream.collect(toList()));
}
|
[
"public",
"<",
"N",
"extends",
"Number",
">",
"NumberSummaryStatistics",
"addAll",
"(",
"Stream",
"<",
"N",
">",
"numberStream",
")",
"{",
"return",
"addAll",
"(",
"numberStream",
".",
"collect",
"(",
"toList",
"(",
")",
")",
")",
";",
"}"
] |
Add all number summary statistics.
@param <N> the type parameter
@param numberStream the number stream
@return the number summary statistics
|
[
"Add",
"all",
"number",
"summary",
"statistics",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/stats/NumberSummaryStatistics.java#L66-L69
|
154,761
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/stats/NumberSummaryStatistics.java
|
NumberSummaryStatistics.getStatsFieldMap
|
public Map<StatsField, Number> getStatsFieldMap() {
return Arrays.stream(StatsField.values())
.collect(toMap(Function.identity(), this::getStats));
}
|
java
|
public Map<StatsField, Number> getStatsFieldMap() {
return Arrays.stream(StatsField.values())
.collect(toMap(Function.identity(), this::getStats));
}
|
[
"public",
"Map",
"<",
"StatsField",
",",
"Number",
">",
"getStatsFieldMap",
"(",
")",
"{",
"return",
"Arrays",
".",
"stream",
"(",
"StatsField",
".",
"values",
"(",
")",
")",
".",
"collect",
"(",
"toMap",
"(",
"Function",
".",
"identity",
"(",
")",
",",
"this",
"::",
"getStats",
")",
")",
";",
"}"
] |
Gets stats field map.
@return the stats field map
|
[
"Gets",
"stats",
"field",
"map",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/stats/NumberSummaryStatistics.java#L223-L226
|
154,762
|
G2G3Digital/substeps-framework
|
core/src/main/java/com/technophobia/substeps/runner/setupteardown/BeforeAndAfterMethods.java
|
BeforeAndAfterMethods.sortMethodList
|
private void sortMethodList() {
// order of execution is base classes first, then the order of
// processorClasses, reversed for tear downs
// build up the order:
final List<Class<?>> hierarchy = new ArrayList<Class<?>>();
if (initialisationClasses != null) {
for (int i = initialisationClasses.length; i > 0; i--) {
hierarchy.addAll(classHierarchyFor(initialisationClasses[i - 1]));
}
}
sortMethodLists(hierarchy);
}
|
java
|
private void sortMethodList() {
// order of execution is base classes first, then the order of
// processorClasses, reversed for tear downs
// build up the order:
final List<Class<?>> hierarchy = new ArrayList<Class<?>>();
if (initialisationClasses != null) {
for (int i = initialisationClasses.length; i > 0; i--) {
hierarchy.addAll(classHierarchyFor(initialisationClasses[i - 1]));
}
}
sortMethodLists(hierarchy);
}
|
[
"private",
"void",
"sortMethodList",
"(",
")",
"{",
"// order of execution is base classes first, then the order of",
"// processorClasses, reversed for tear downs",
"// build up the order:",
"final",
"List",
"<",
"Class",
"<",
"?",
">",
">",
"hierarchy",
"=",
"new",
"ArrayList",
"<",
"Class",
"<",
"?",
">",
">",
"(",
")",
";",
"if",
"(",
"initialisationClasses",
"!=",
"null",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"initialisationClasses",
".",
"length",
";",
"i",
">",
"0",
";",
"i",
"--",
")",
"{",
"hierarchy",
".",
"addAll",
"(",
"classHierarchyFor",
"(",
"initialisationClasses",
"[",
"i",
"-",
"1",
"]",
")",
")",
";",
"}",
"}",
"sortMethodLists",
"(",
"hierarchy",
")",
";",
"}"
] |
from the previous base class
|
[
"from",
"the",
"previous",
"base",
"class"
] |
c1ec6487e1673a7dae54b5e7b62a96f602cd280a
|
https://github.com/G2G3Digital/substeps-framework/blob/c1ec6487e1673a7dae54b5e7b62a96f602cd280a/core/src/main/java/com/technophobia/substeps/runner/setupteardown/BeforeAndAfterMethods.java#L67-L82
|
154,763
|
morimekta/utils
|
io-util/src/main/java/net/morimekta/util/io/BinaryReader.java
|
BinaryReader.expectShort
|
public short expectShort() throws IOException {
int b1 = in.read();
if (b1 < 0) {
throw new IOException("Missing byte 1 to expected short");
}
int b2 = in.read();
if (b2 < 0) {
throw new IOException("Missing byte 2 to expected short");
}
return (short) unshift2bytes(b1, b2);
}
|
java
|
public short expectShort() throws IOException {
int b1 = in.read();
if (b1 < 0) {
throw new IOException("Missing byte 1 to expected short");
}
int b2 = in.read();
if (b2 < 0) {
throw new IOException("Missing byte 2 to expected short");
}
return (short) unshift2bytes(b1, b2);
}
|
[
"public",
"short",
"expectShort",
"(",
")",
"throws",
"IOException",
"{",
"int",
"b1",
"=",
"in",
".",
"read",
"(",
")",
";",
"if",
"(",
"b1",
"<",
"0",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Missing byte 1 to expected short\"",
")",
";",
"}",
"int",
"b2",
"=",
"in",
".",
"read",
"(",
")",
";",
"if",
"(",
"b2",
"<",
"0",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Missing byte 2 to expected short\"",
")",
";",
"}",
"return",
"(",
"short",
")",
"unshift2bytes",
"(",
"b1",
",",
"b2",
")",
";",
"}"
] |
Read a short from the input stream.
@return The number read.
@throws IOException if unable to read from stream.
|
[
"Read",
"a",
"short",
"from",
"the",
"input",
"stream",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/io/BinaryReader.java#L129-L139
|
154,764
|
morimekta/utils
|
io-util/src/main/java/net/morimekta/util/io/BinaryReader.java
|
BinaryReader.expectInt
|
public int expectInt() throws IOException {
int b1 = in.read();
if (b1 < 0) {
throw new IOException("Missing byte 1 to expected int");
}
int b2 = in.read();
if (b2 < 0) {
throw new IOException("Missing byte 2 to expected int");
}
int b3 = in.read();
if (b3 < 0) {
throw new IOException("Missing byte 3 to expected int");
}
int b4 = in.read();
if (b4 < 0) {
throw new IOException("Missing byte 4 to expected int");
}
return unshift4bytes(b1, b2, b3, b4);
}
|
java
|
public int expectInt() throws IOException {
int b1 = in.read();
if (b1 < 0) {
throw new IOException("Missing byte 1 to expected int");
}
int b2 = in.read();
if (b2 < 0) {
throw new IOException("Missing byte 2 to expected int");
}
int b3 = in.read();
if (b3 < 0) {
throw new IOException("Missing byte 3 to expected int");
}
int b4 = in.read();
if (b4 < 0) {
throw new IOException("Missing byte 4 to expected int");
}
return unshift4bytes(b1, b2, b3, b4);
}
|
[
"public",
"int",
"expectInt",
"(",
")",
"throws",
"IOException",
"{",
"int",
"b1",
"=",
"in",
".",
"read",
"(",
")",
";",
"if",
"(",
"b1",
"<",
"0",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Missing byte 1 to expected int\"",
")",
";",
"}",
"int",
"b2",
"=",
"in",
".",
"read",
"(",
")",
";",
"if",
"(",
"b2",
"<",
"0",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Missing byte 2 to expected int\"",
")",
";",
"}",
"int",
"b3",
"=",
"in",
".",
"read",
"(",
")",
";",
"if",
"(",
"b3",
"<",
"0",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Missing byte 3 to expected int\"",
")",
";",
"}",
"int",
"b4",
"=",
"in",
".",
"read",
"(",
")",
";",
"if",
"(",
"b4",
"<",
"0",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Missing byte 4 to expected int\"",
")",
";",
"}",
"return",
"unshift4bytes",
"(",
"b1",
",",
"b2",
",",
"b3",
",",
"b4",
")",
";",
"}"
] |
Read an int from the input stream.
@return The number read.
@throws IOException if unable to read from stream.
|
[
"Read",
"an",
"int",
"from",
"the",
"input",
"stream",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/io/BinaryReader.java#L147-L165
|
154,765
|
morimekta/utils
|
io-util/src/main/java/net/morimekta/util/io/BinaryReader.java
|
BinaryReader.expectLong
|
public long expectLong() throws IOException {
int b1 = in.read();
if (b1 < 0) {
throw new IOException("Missing byte 1 to expected long");
}
int b2 = in.read();
if (b2 < 0) {
throw new IOException("Missing byte 2 to expected long");
}
int b3 = in.read();
if (b3 < 0) {
throw new IOException("Missing byte 3 to expected long");
}
long b4 = in.read();
if (b4 < 0) {
throw new IOException("Missing byte 4 to expected long");
}
long b5 = in.read();
if (b5 < 0) {
throw new IOException("Missing byte 5 to expected long");
}
long b6 = in.read();
if (b6 < 0) {
throw new IOException("Missing byte 6 to expected long");
}
long b7 = in.read();
if (b7 < 0) {
throw new IOException("Missing byte 7 to expected long");
}
long b8 = in.read();
if (b8 < 0) {
throw new IOException("Missing byte 8 to expected long");
}
return unshift8bytes(b1, b2, b3, b4, b5, b6, b7, b8);
}
|
java
|
public long expectLong() throws IOException {
int b1 = in.read();
if (b1 < 0) {
throw new IOException("Missing byte 1 to expected long");
}
int b2 = in.read();
if (b2 < 0) {
throw new IOException("Missing byte 2 to expected long");
}
int b3 = in.read();
if (b3 < 0) {
throw new IOException("Missing byte 3 to expected long");
}
long b4 = in.read();
if (b4 < 0) {
throw new IOException("Missing byte 4 to expected long");
}
long b5 = in.read();
if (b5 < 0) {
throw new IOException("Missing byte 5 to expected long");
}
long b6 = in.read();
if (b6 < 0) {
throw new IOException("Missing byte 6 to expected long");
}
long b7 = in.read();
if (b7 < 0) {
throw new IOException("Missing byte 7 to expected long");
}
long b8 = in.read();
if (b8 < 0) {
throw new IOException("Missing byte 8 to expected long");
}
return unshift8bytes(b1, b2, b3, b4, b5, b6, b7, b8);
}
|
[
"public",
"long",
"expectLong",
"(",
")",
"throws",
"IOException",
"{",
"int",
"b1",
"=",
"in",
".",
"read",
"(",
")",
";",
"if",
"(",
"b1",
"<",
"0",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Missing byte 1 to expected long\"",
")",
";",
"}",
"int",
"b2",
"=",
"in",
".",
"read",
"(",
")",
";",
"if",
"(",
"b2",
"<",
"0",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Missing byte 2 to expected long\"",
")",
";",
"}",
"int",
"b3",
"=",
"in",
".",
"read",
"(",
")",
";",
"if",
"(",
"b3",
"<",
"0",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Missing byte 3 to expected long\"",
")",
";",
"}",
"long",
"b4",
"=",
"in",
".",
"read",
"(",
")",
";",
"if",
"(",
"b4",
"<",
"0",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Missing byte 4 to expected long\"",
")",
";",
"}",
"long",
"b5",
"=",
"in",
".",
"read",
"(",
")",
";",
"if",
"(",
"b5",
"<",
"0",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Missing byte 5 to expected long\"",
")",
";",
"}",
"long",
"b6",
"=",
"in",
".",
"read",
"(",
")",
";",
"if",
"(",
"b6",
"<",
"0",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Missing byte 6 to expected long\"",
")",
";",
"}",
"long",
"b7",
"=",
"in",
".",
"read",
"(",
")",
";",
"if",
"(",
"b7",
"<",
"0",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Missing byte 7 to expected long\"",
")",
";",
"}",
"long",
"b8",
"=",
"in",
".",
"read",
"(",
")",
";",
"if",
"(",
"b8",
"<",
"0",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Missing byte 8 to expected long\"",
")",
";",
"}",
"return",
"unshift8bytes",
"(",
"b1",
",",
"b2",
",",
"b3",
",",
"b4",
",",
"b5",
",",
"b6",
",",
"b7",
",",
"b8",
")",
";",
"}"
] |
Read a long int from the input stream.
@return The number read.
@throws IOException if unable to read from stream.
|
[
"Read",
"a",
"long",
"int",
"from",
"the",
"input",
"stream",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/io/BinaryReader.java#L173-L208
|
154,766
|
morimekta/utils
|
io-util/src/main/java/net/morimekta/util/io/BinaryReader.java
|
BinaryReader.expectUnsigned
|
public int expectUnsigned(int bytes) throws IOException {
switch (bytes) {
case 4:
return expectUInt32();
case 3:
return expectUInt24();
case 2:
return expectUInt16();
case 1:
return expectUInt8();
}
throw new IllegalArgumentException("Unsupported byte count for unsigned: " + bytes);
}
|
java
|
public int expectUnsigned(int bytes) throws IOException {
switch (bytes) {
case 4:
return expectUInt32();
case 3:
return expectUInt24();
case 2:
return expectUInt16();
case 1:
return expectUInt8();
}
throw new IllegalArgumentException("Unsupported byte count for unsigned: " + bytes);
}
|
[
"public",
"int",
"expectUnsigned",
"(",
"int",
"bytes",
")",
"throws",
"IOException",
"{",
"switch",
"(",
"bytes",
")",
"{",
"case",
"4",
":",
"return",
"expectUInt32",
"(",
")",
";",
"case",
"3",
":",
"return",
"expectUInt24",
"(",
")",
";",
"case",
"2",
":",
"return",
"expectUInt16",
"(",
")",
";",
"case",
"1",
":",
"return",
"expectUInt8",
"(",
")",
";",
"}",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unsupported byte count for unsigned: \"",
"+",
"bytes",
")",
";",
"}"
] |
Read an unsigned number from the input stream.
@param bytes Number of bytes to read.
@return The number read.
@throws IOException if unable to read from stream.
|
[
"Read",
"an",
"unsigned",
"number",
"from",
"the",
"input",
"stream",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/io/BinaryReader.java#L348-L360
|
154,767
|
morimekta/utils
|
io-util/src/main/java/net/morimekta/util/io/BinaryReader.java
|
BinaryReader.expectSigned
|
public long expectSigned(int bytes) throws IOException {
switch (bytes) {
case 8:
return expectLong();
case 4:
return expectInt();
case 2:
return expectShort();
case 1:
return expectByte();
}
throw new IllegalArgumentException("Unsupported byte count for signed: " + bytes);
}
|
java
|
public long expectSigned(int bytes) throws IOException {
switch (bytes) {
case 8:
return expectLong();
case 4:
return expectInt();
case 2:
return expectShort();
case 1:
return expectByte();
}
throw new IllegalArgumentException("Unsupported byte count for signed: " + bytes);
}
|
[
"public",
"long",
"expectSigned",
"(",
"int",
"bytes",
")",
"throws",
"IOException",
"{",
"switch",
"(",
"bytes",
")",
"{",
"case",
"8",
":",
"return",
"expectLong",
"(",
")",
";",
"case",
"4",
":",
"return",
"expectInt",
"(",
")",
";",
"case",
"2",
":",
"return",
"expectShort",
"(",
")",
";",
"case",
"1",
":",
"return",
"expectByte",
"(",
")",
";",
"}",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unsupported byte count for signed: \"",
"+",
"bytes",
")",
";",
"}"
] |
Read an signed number from the input stream.
@param bytes Number of bytes to read.
@return The number read.
@throws IOException if unable to read from stream.
|
[
"Read",
"an",
"signed",
"number",
"from",
"the",
"input",
"stream",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/io/BinaryReader.java#L369-L381
|
154,768
|
gnagy/webhejj-commons
|
src/main/java/hu/webhejj/commons/files/Directory.java
|
Directory.clear
|
public boolean clear() {
boolean result = false;
for(File file: base.listFiles()) {
result = result | FileUtils.deleteRecursive(file);
}
return result;
}
|
java
|
public boolean clear() {
boolean result = false;
for(File file: base.listFiles()) {
result = result | FileUtils.deleteRecursive(file);
}
return result;
}
|
[
"public",
"boolean",
"clear",
"(",
")",
"{",
"boolean",
"result",
"=",
"false",
";",
"for",
"(",
"File",
"file",
":",
"base",
".",
"listFiles",
"(",
")",
")",
"{",
"result",
"=",
"result",
"|",
"FileUtils",
".",
"deleteRecursive",
"(",
"file",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Deletes all children of this directory
@return true if at least one child was deleted, false otherwise
|
[
"Deletes",
"all",
"children",
"of",
"this",
"directory"
] |
270bc6f111ec5761af31d39bd38c40fd914d2eba
|
https://github.com/gnagy/webhejj-commons/blob/270bc6f111ec5761af31d39bd38c40fd914d2eba/src/main/java/hu/webhejj/commons/files/Directory.java#L100-L107
|
154,769
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/JMFileAppender.java
|
JMFileAppender.appendAndClose
|
public static Path appendAndClose(String filePath, Charset charset,
String writingString) {
return new JMFileAppender(filePath, charset).append(writingString)
.closeAndGetFilePath();
}
|
java
|
public static Path appendAndClose(String filePath, Charset charset,
String writingString) {
return new JMFileAppender(filePath, charset).append(writingString)
.closeAndGetFilePath();
}
|
[
"public",
"static",
"Path",
"appendAndClose",
"(",
"String",
"filePath",
",",
"Charset",
"charset",
",",
"String",
"writingString",
")",
"{",
"return",
"new",
"JMFileAppender",
"(",
"filePath",
",",
"charset",
")",
".",
"append",
"(",
"writingString",
")",
".",
"closeAndGetFilePath",
"(",
")",
";",
"}"
] |
Append and close path.
@param filePath the file path
@param charset the charset
@param writingString the writing string
@return the path
|
[
"Append",
"and",
"close",
"path",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/JMFileAppender.java#L99-L103
|
154,770
|
PureSolTechnologies/parsers
|
parsers/src/main/java/com/puresoltechnologies/parsers/parser/functions/Follow.java
|
Follow.addFinishToStart
|
private void addFinishToStart() {
follow.get(grammar.getProductions().get(0).getName()).add(FinishTerminal.getInstance());
}
|
java
|
private void addFinishToStart() {
follow.get(grammar.getProductions().get(0).getName()).add(FinishTerminal.getInstance());
}
|
[
"private",
"void",
"addFinishToStart",
"(",
")",
"{",
"follow",
".",
"get",
"(",
"grammar",
".",
"getProductions",
"(",
")",
".",
"get",
"(",
"0",
")",
".",
"getName",
"(",
")",
")",
".",
"add",
"(",
"FinishTerminal",
".",
"getInstance",
"(",
")",
")",
";",
"}"
] |
This method ass the finish construction to the start symbol. If a start
symbol is defined by StartProduction this construction is used. If the there
is no such production, the fist production is used.
This is rule 1 from Dragon book:
1) Platzieren Sie $ in FOLLOW(S), wobei S das Startsymbol und $ die rechte
Endmarkierung fuer die Eingabe sind.
|
[
"This",
"method",
"ass",
"the",
"finish",
"construction",
"to",
"the",
"start",
"symbol",
".",
"If",
"a",
"start",
"symbol",
"is",
"defined",
"by",
"StartProduction",
"this",
"construction",
"is",
"used",
".",
"If",
"the",
"there",
"is",
"no",
"such",
"production",
"the",
"fist",
"production",
"is",
"used",
"."
] |
61077223b90d3768ff9445ae13036343c98b63cd
|
https://github.com/PureSolTechnologies/parsers/blob/61077223b90d3768ff9445ae13036343c98b63cd/parsers/src/main/java/com/puresoltechnologies/parsers/parser/functions/Follow.java#L74-L76
|
154,771
|
foundation-runtime/service-directory
|
2.0/sd-core/src/main/java/com/cisco/oss/foundation/directory/utils/WebSocketSerializer.java
|
WebSocketSerializer.getProtocolSerializer
|
public static ProtocolSerializer getProtocolSerializer(ProtocolHeader header, Protocol protocol) throws JsonGenerationException, JsonMappingException, IOException{
final String s = serializeProtocol(header, protocol);
return new ProtocolSerializer(){
@Override
public String serializerAsString() {
return s;
}
};
}
|
java
|
public static ProtocolSerializer getProtocolSerializer(ProtocolHeader header, Protocol protocol) throws JsonGenerationException, JsonMappingException, IOException{
final String s = serializeProtocol(header, protocol);
return new ProtocolSerializer(){
@Override
public String serializerAsString() {
return s;
}
};
}
|
[
"public",
"static",
"ProtocolSerializer",
"getProtocolSerializer",
"(",
"ProtocolHeader",
"header",
",",
"Protocol",
"protocol",
")",
"throws",
"JsonGenerationException",
",",
"JsonMappingException",
",",
"IOException",
"{",
"final",
"String",
"s",
"=",
"serializeProtocol",
"(",
"header",
",",
"protocol",
")",
";",
"return",
"new",
"ProtocolSerializer",
"(",
")",
"{",
"@",
"Override",
"public",
"String",
"serializerAsString",
"(",
")",
"{",
"return",
"s",
";",
"}",
"}",
";",
"}"
] |
Serialize the Protocol.
@param header
the ProtocolHeader.
@param protocol
the Protocol.
@return
the ProtocolSerializer.
@throws JsonGenerationException
@throws JsonMappingException
@throws IOException
|
[
"Serialize",
"the",
"Protocol",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-core/src/main/java/com/cisco/oss/foundation/directory/utils/WebSocketSerializer.java#L79-L89
|
154,772
|
foundation-runtime/service-directory
|
2.0/sd-core/src/main/java/com/cisco/oss/foundation/directory/utils/WebSocketSerializer.java
|
WebSocketSerializer.getProtocolDeserializer
|
public static ProtocolDeserializer getProtocolDeserializer(String jsonStr) throws JsonParseException, JsonMappingException, IOException{
final ProtocolPair p = mapper.readValue(jsonStr, ProtocolPair.class);
Protocol pp = null;
if(p.getType() != null){
pp = (Protocol) mapper.readValue(p.getProtocol(), p.getType());
}
final Protocol resp = pp;
return new ProtocolDeserializer(){
@Override
public ProtocolHeader deserializerProtocolHeader() {
return p.getProtocolHeader();
}
@Override
public Protocol deserializerProtocol() {
return resp;
}
};
}
|
java
|
public static ProtocolDeserializer getProtocolDeserializer(String jsonStr) throws JsonParseException, JsonMappingException, IOException{
final ProtocolPair p = mapper.readValue(jsonStr, ProtocolPair.class);
Protocol pp = null;
if(p.getType() != null){
pp = (Protocol) mapper.readValue(p.getProtocol(), p.getType());
}
final Protocol resp = pp;
return new ProtocolDeserializer(){
@Override
public ProtocolHeader deserializerProtocolHeader() {
return p.getProtocolHeader();
}
@Override
public Protocol deserializerProtocol() {
return resp;
}
};
}
|
[
"public",
"static",
"ProtocolDeserializer",
"getProtocolDeserializer",
"(",
"String",
"jsonStr",
")",
"throws",
"JsonParseException",
",",
"JsonMappingException",
",",
"IOException",
"{",
"final",
"ProtocolPair",
"p",
"=",
"mapper",
".",
"readValue",
"(",
"jsonStr",
",",
"ProtocolPair",
".",
"class",
")",
";",
"Protocol",
"pp",
"=",
"null",
";",
"if",
"(",
"p",
".",
"getType",
"(",
")",
"!=",
"null",
")",
"{",
"pp",
"=",
"(",
"Protocol",
")",
"mapper",
".",
"readValue",
"(",
"p",
".",
"getProtocol",
"(",
")",
",",
"p",
".",
"getType",
"(",
")",
")",
";",
"}",
"final",
"Protocol",
"resp",
"=",
"pp",
";",
"return",
"new",
"ProtocolDeserializer",
"(",
")",
"{",
"@",
"Override",
"public",
"ProtocolHeader",
"deserializerProtocolHeader",
"(",
")",
"{",
"return",
"p",
".",
"getProtocolHeader",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"Protocol",
"deserializerProtocol",
"(",
")",
"{",
"return",
"resp",
";",
"}",
"}",
";",
"}"
] |
Deserialize the Protocol Json String.
@param jsonStr
the Protocol Json String
@return
the ProtocolDeserializer.
@throws JsonParseException
@throws JsonMappingException
@throws IOException
|
[
"Deserialize",
"the",
"Protocol",
"Json",
"String",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-core/src/main/java/com/cisco/oss/foundation/directory/utils/WebSocketSerializer.java#L102-L123
|
154,773
|
foundation-runtime/service-directory
|
2.0/sd-core/src/main/java/com/cisco/oss/foundation/directory/utils/WebSocketSerializer.java
|
WebSocketSerializer.getResponseDeserializer
|
public static ResponseDeserializer getResponseDeserializer(String jsonStr) throws JsonParseException, JsonMappingException, IOException{
final ResponsePair p = mapper.readValue(jsonStr, ResponsePair.class);
Response rr = null;
if(p.getType() != null){
rr = (Response) mapper.readValue(p.getResponse(), p.getType());
}
final Response resp = rr;
return new ResponseDeserializer(){
@Override
public ResponseHeader deserializerResponseHeader() {
return p.getResponseHeader();
}
@Override
public Response deserializerResponse() {
return resp;
}
};
}
|
java
|
public static ResponseDeserializer getResponseDeserializer(String jsonStr) throws JsonParseException, JsonMappingException, IOException{
final ResponsePair p = mapper.readValue(jsonStr, ResponsePair.class);
Response rr = null;
if(p.getType() != null){
rr = (Response) mapper.readValue(p.getResponse(), p.getType());
}
final Response resp = rr;
return new ResponseDeserializer(){
@Override
public ResponseHeader deserializerResponseHeader() {
return p.getResponseHeader();
}
@Override
public Response deserializerResponse() {
return resp;
}
};
}
|
[
"public",
"static",
"ResponseDeserializer",
"getResponseDeserializer",
"(",
"String",
"jsonStr",
")",
"throws",
"JsonParseException",
",",
"JsonMappingException",
",",
"IOException",
"{",
"final",
"ResponsePair",
"p",
"=",
"mapper",
".",
"readValue",
"(",
"jsonStr",
",",
"ResponsePair",
".",
"class",
")",
";",
"Response",
"rr",
"=",
"null",
";",
"if",
"(",
"p",
".",
"getType",
"(",
")",
"!=",
"null",
")",
"{",
"rr",
"=",
"(",
"Response",
")",
"mapper",
".",
"readValue",
"(",
"p",
".",
"getResponse",
"(",
")",
",",
"p",
".",
"getType",
"(",
")",
")",
";",
"}",
"final",
"Response",
"resp",
"=",
"rr",
";",
"return",
"new",
"ResponseDeserializer",
"(",
")",
"{",
"@",
"Override",
"public",
"ResponseHeader",
"deserializerResponseHeader",
"(",
")",
"{",
"return",
"p",
".",
"getResponseHeader",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"Response",
"deserializerResponse",
"(",
")",
"{",
"return",
"resp",
";",
"}",
"}",
";",
"}"
] |
Deserialize the Response Json String.
@param jsonStr
The Response Json String.
@return
the ResponseDeserializer.
@throws JsonParseException
@throws JsonMappingException
@throws IOException
|
[
"Deserialize",
"the",
"Response",
"Json",
"String",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-core/src/main/java/com/cisco/oss/foundation/directory/utils/WebSocketSerializer.java#L136-L158
|
154,774
|
foundation-runtime/service-directory
|
2.0/sd-core/src/main/java/com/cisco/oss/foundation/directory/utils/WebSocketSerializer.java
|
WebSocketSerializer.serializeProtocol
|
private static String serializeProtocol(ProtocolHeader header, Protocol protocol) throws JsonGenerationException, JsonMappingException, IOException{
ProtocolPair p = new ProtocolPair();
p.setProtocolHeader(header);
if(protocol == null){
p.setType(null);
} else {
p.setType(protocol.getClass());
}
p.setProtocol(toJsonStr(protocol));
return toJsonStr(p);
}
|
java
|
private static String serializeProtocol(ProtocolHeader header, Protocol protocol) throws JsonGenerationException, JsonMappingException, IOException{
ProtocolPair p = new ProtocolPair();
p.setProtocolHeader(header);
if(protocol == null){
p.setType(null);
} else {
p.setType(protocol.getClass());
}
p.setProtocol(toJsonStr(protocol));
return toJsonStr(p);
}
|
[
"private",
"static",
"String",
"serializeProtocol",
"(",
"ProtocolHeader",
"header",
",",
"Protocol",
"protocol",
")",
"throws",
"JsonGenerationException",
",",
"JsonMappingException",
",",
"IOException",
"{",
"ProtocolPair",
"p",
"=",
"new",
"ProtocolPair",
"(",
")",
";",
"p",
".",
"setProtocolHeader",
"(",
"header",
")",
";",
"if",
"(",
"protocol",
"==",
"null",
")",
"{",
"p",
".",
"setType",
"(",
"null",
")",
";",
"}",
"else",
"{",
"p",
".",
"setType",
"(",
"protocol",
".",
"getClass",
"(",
")",
")",
";",
"}",
"p",
".",
"setProtocol",
"(",
"toJsonStr",
"(",
"protocol",
")",
")",
";",
"return",
"toJsonStr",
"(",
"p",
")",
";",
"}"
] |
Serialize the Protocol to JSON String.
@param header
the ProtocolHeader.
@param protocol
the Protocol.
@return
the JSON String.
@throws JsonGenerationException
@throws JsonMappingException
@throws IOException
|
[
"Serialize",
"the",
"Protocol",
"to",
"JSON",
"String",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-core/src/main/java/com/cisco/oss/foundation/directory/utils/WebSocketSerializer.java#L198-L208
|
154,775
|
foundation-runtime/service-directory
|
2.0/sd-core/src/main/java/com/cisco/oss/foundation/directory/utils/WebSocketSerializer.java
|
WebSocketSerializer.toJsonStr
|
private static String toJsonStr(Object object) throws JsonGenerationException, JsonMappingException, IOException{
return mapper.writeValueAsString(object);
}
|
java
|
private static String toJsonStr(Object object) throws JsonGenerationException, JsonMappingException, IOException{
return mapper.writeValueAsString(object);
}
|
[
"private",
"static",
"String",
"toJsonStr",
"(",
"Object",
"object",
")",
"throws",
"JsonGenerationException",
",",
"JsonMappingException",
",",
"IOException",
"{",
"return",
"mapper",
".",
"writeValueAsString",
"(",
"object",
")",
";",
"}"
] |
Transfer Object to JSON String.
@param object
the target Object.
@return
JSON String.
@throws JsonGenerationException
@throws JsonMappingException
@throws IOException
|
[
"Transfer",
"Object",
"to",
"JSON",
"String",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-core/src/main/java/com/cisco/oss/foundation/directory/utils/WebSocketSerializer.java#L221-L223
|
154,776
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/text/TextAnalysis.java
|
TextAnalysis.combine
|
public static String combine(String left, String right, int minOverlap) {
if (left.length() < minOverlap) return null;
if (right.length() < minOverlap) return null;
int bestOffset = Integer.MAX_VALUE;
for (int offset = minOverlap - left.length(); offset < right.length() - minOverlap; offset++) {
boolean match = true;
for (int posLeft = Math.max(0, -offset); posLeft < Math.min(left.length(), right.length() - offset); posLeft++) {
if (left.charAt(posLeft) != right.charAt(posLeft + offset)) {
match = false;
break;
}
}
if (match) {
if (Math.abs(bestOffset) > Math.abs(offset)) bestOffset = offset;
}
}
if (bestOffset < Integer.MAX_VALUE) {
String combined = left;
if (bestOffset > 0) {
combined = right.substring(0, bestOffset) + combined;
}
if (left.length() + bestOffset < right.length()) {
combined = combined + right.substring(left.length() + bestOffset);
}
return combined;
}
else {
return null;
}
}
|
java
|
public static String combine(String left, String right, int minOverlap) {
if (left.length() < minOverlap) return null;
if (right.length() < minOverlap) return null;
int bestOffset = Integer.MAX_VALUE;
for (int offset = minOverlap - left.length(); offset < right.length() - minOverlap; offset++) {
boolean match = true;
for (int posLeft = Math.max(0, -offset); posLeft < Math.min(left.length(), right.length() - offset); posLeft++) {
if (left.charAt(posLeft) != right.charAt(posLeft + offset)) {
match = false;
break;
}
}
if (match) {
if (Math.abs(bestOffset) > Math.abs(offset)) bestOffset = offset;
}
}
if (bestOffset < Integer.MAX_VALUE) {
String combined = left;
if (bestOffset > 0) {
combined = right.substring(0, bestOffset) + combined;
}
if (left.length() + bestOffset < right.length()) {
combined = combined + right.substring(left.length() + bestOffset);
}
return combined;
}
else {
return null;
}
}
|
[
"public",
"static",
"String",
"combine",
"(",
"String",
"left",
",",
"String",
"right",
",",
"int",
"minOverlap",
")",
"{",
"if",
"(",
"left",
".",
"length",
"(",
")",
"<",
"minOverlap",
")",
"return",
"null",
";",
"if",
"(",
"right",
".",
"length",
"(",
")",
"<",
"minOverlap",
")",
"return",
"null",
";",
"int",
"bestOffset",
"=",
"Integer",
".",
"MAX_VALUE",
";",
"for",
"(",
"int",
"offset",
"=",
"minOverlap",
"-",
"left",
".",
"length",
"(",
")",
";",
"offset",
"<",
"right",
".",
"length",
"(",
")",
"-",
"minOverlap",
";",
"offset",
"++",
")",
"{",
"boolean",
"match",
"=",
"true",
";",
"for",
"(",
"int",
"posLeft",
"=",
"Math",
".",
"max",
"(",
"0",
",",
"-",
"offset",
")",
";",
"posLeft",
"<",
"Math",
".",
"min",
"(",
"left",
".",
"length",
"(",
")",
",",
"right",
".",
"length",
"(",
")",
"-",
"offset",
")",
";",
"posLeft",
"++",
")",
"{",
"if",
"(",
"left",
".",
"charAt",
"(",
"posLeft",
")",
"!=",
"right",
".",
"charAt",
"(",
"posLeft",
"+",
"offset",
")",
")",
"{",
"match",
"=",
"false",
";",
"break",
";",
"}",
"}",
"if",
"(",
"match",
")",
"{",
"if",
"(",
"Math",
".",
"abs",
"(",
"bestOffset",
")",
">",
"Math",
".",
"abs",
"(",
"offset",
")",
")",
"bestOffset",
"=",
"offset",
";",
"}",
"}",
"if",
"(",
"bestOffset",
"<",
"Integer",
".",
"MAX_VALUE",
")",
"{",
"String",
"combined",
"=",
"left",
";",
"if",
"(",
"bestOffset",
">",
"0",
")",
"{",
"combined",
"=",
"right",
".",
"substring",
"(",
"0",
",",
"bestOffset",
")",
"+",
"combined",
";",
"}",
"if",
"(",
"left",
".",
"length",
"(",
")",
"+",
"bestOffset",
"<",
"right",
".",
"length",
"(",
")",
")",
"{",
"combined",
"=",
"combined",
"+",
"right",
".",
"substring",
"(",
"left",
".",
"length",
"(",
")",
"+",
"bestOffset",
")",
";",
"}",
"return",
"combined",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] |
Combine string.
@param left the left
@param right the right
@param minOverlap the min overlap
@return the string
|
[
"Combine",
"string",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/text/TextAnalysis.java#L58-L87
|
154,777
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/text/TextAnalysis.java
|
TextAnalysis.keywords
|
public List<String> keywords(final String source) {
Map<String, Long> wordCounts = splitChars(source, DEFAULT_THRESHOLD).stream().collect(Collectors.groupingBy(x -> x, Collectors.counting()));
wordCounts = aggregateKeywords(wordCounts);
return wordCounts.entrySet().stream().filter(x -> x.getValue() > 1)
.sorted(Comparator.comparing(x -> -entropy(x.getKey()) * Math.pow(x.getValue(), 0.3)))
.map(e -> {
if (isVerbose()) {
verbose.println(String.format("KEYWORD: \"%s\" - %s * %.3f / %s", e.getKey(), e.getValue(), entropy(e.getKey()), e.getKey().length()));
}
return e.getKey();
}).collect(Collectors.toList());
}
|
java
|
public List<String> keywords(final String source) {
Map<String, Long> wordCounts = splitChars(source, DEFAULT_THRESHOLD).stream().collect(Collectors.groupingBy(x -> x, Collectors.counting()));
wordCounts = aggregateKeywords(wordCounts);
return wordCounts.entrySet().stream().filter(x -> x.getValue() > 1)
.sorted(Comparator.comparing(x -> -entropy(x.getKey()) * Math.pow(x.getValue(), 0.3)))
.map(e -> {
if (isVerbose()) {
verbose.println(String.format("KEYWORD: \"%s\" - %s * %.3f / %s", e.getKey(), e.getValue(), entropy(e.getKey()), e.getKey().length()));
}
return e.getKey();
}).collect(Collectors.toList());
}
|
[
"public",
"List",
"<",
"String",
">",
"keywords",
"(",
"final",
"String",
"source",
")",
"{",
"Map",
"<",
"String",
",",
"Long",
">",
"wordCounts",
"=",
"splitChars",
"(",
"source",
",",
"DEFAULT_THRESHOLD",
")",
".",
"stream",
"(",
")",
".",
"collect",
"(",
"Collectors",
".",
"groupingBy",
"(",
"x",
"->",
"x",
",",
"Collectors",
".",
"counting",
"(",
")",
")",
")",
";",
"wordCounts",
"=",
"aggregateKeywords",
"(",
"wordCounts",
")",
";",
"return",
"wordCounts",
".",
"entrySet",
"(",
")",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"x",
"->",
"x",
".",
"getValue",
"(",
")",
">",
"1",
")",
".",
"sorted",
"(",
"Comparator",
".",
"comparing",
"(",
"x",
"->",
"-",
"entropy",
"(",
"x",
".",
"getKey",
"(",
")",
")",
"*",
"Math",
".",
"pow",
"(",
"x",
".",
"getValue",
"(",
")",
",",
"0.3",
")",
")",
")",
".",
"map",
"(",
"e",
"->",
"{",
"if",
"(",
"isVerbose",
"(",
")",
")",
"{",
"verbose",
".",
"println",
"(",
"String",
".",
"format",
"(",
"\"KEYWORD: \\\"%s\\\" - %s * %.3f / %s\"",
",",
"e",
".",
"getKey",
"(",
")",
",",
"e",
".",
"getValue",
"(",
")",
",",
"entropy",
"(",
"e",
".",
"getKey",
"(",
")",
")",
",",
"e",
".",
"getKey",
"(",
")",
".",
"length",
"(",
")",
")",
")",
";",
"}",
"return",
"e",
".",
"getKey",
"(",
")",
";",
"}",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"}"
] |
Keywords list.
@param source the source
@return the list
|
[
"Keywords",
"list",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/text/TextAnalysis.java#L99-L110
|
154,778
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/text/TextAnalysis.java
|
TextAnalysis.spelling
|
public double spelling(final String source) {
assert (source.startsWith("|"));
assert (source.endsWith("|"));
WordSpelling original = new WordSpelling(source);
WordSpelling corrected = IntStream.range(0, 1).mapToObj(i -> buildCorrection(original)).min(Comparator.comparingDouble(x -> x.sum)).get();
return corrected.sum;
}
|
java
|
public double spelling(final String source) {
assert (source.startsWith("|"));
assert (source.endsWith("|"));
WordSpelling original = new WordSpelling(source);
WordSpelling corrected = IntStream.range(0, 1).mapToObj(i -> buildCorrection(original)).min(Comparator.comparingDouble(x -> x.sum)).get();
return corrected.sum;
}
|
[
"public",
"double",
"spelling",
"(",
"final",
"String",
"source",
")",
"{",
"assert",
"(",
"source",
".",
"startsWith",
"(",
"\"|\"",
")",
")",
";",
"assert",
"(",
"source",
".",
"endsWith",
"(",
"\"|\"",
")",
")",
";",
"WordSpelling",
"original",
"=",
"new",
"WordSpelling",
"(",
"source",
")",
";",
"WordSpelling",
"corrected",
"=",
"IntStream",
".",
"range",
"(",
"0",
",",
"1",
")",
".",
"mapToObj",
"(",
"i",
"->",
"buildCorrection",
"(",
"original",
")",
")",
".",
"min",
"(",
"Comparator",
".",
"comparingDouble",
"(",
"x",
"->",
"x",
".",
"sum",
")",
")",
".",
"get",
"(",
")",
";",
"return",
"corrected",
".",
"sum",
";",
"}"
] |
Spelling double.
@param source the source
@return the double
|
[
"Spelling",
"double",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/text/TextAnalysis.java#L143-L149
|
154,779
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/text/TextAnalysis.java
|
TextAnalysis.splitMatches
|
public List<String> splitMatches(String text, int minSize) {
TrieNode node = inner.root();
List<String> matches = new ArrayList<>();
String accumulator = "";
for (int i = 0; i < text.length(); i++) {
short prevDepth = node.getDepth();
TrieNode prevNode = node;
node = node.getContinuation(text.charAt(i));
if (null == node) node = inner.root();
if (!accumulator.isEmpty() && (node.getDepth() < prevDepth || (prevNode.hasChildren() && node.getDepth() == prevDepth))) {
if (accumulator.length() > minSize) {
matches.add(accumulator);
node = ((Optional<TrieNode>) inner.root().getChild(text.charAt(i))).orElse(inner.root());
}
accumulator = "";
}
else if (!accumulator.isEmpty()) {
accumulator += text.charAt(i);
}
else if (accumulator.isEmpty() && node.getDepth() > prevDepth) {
accumulator = node.getString();
}
}
List<String> tokenization = new ArrayList<>();
for (String match : matches) {
int index = text.indexOf(match);
assert (index >= 0);
if (index > 0) tokenization.add(text.substring(0, index));
tokenization.add(text.substring(index, index + match.length()));
text = text.substring(index + match.length());
}
tokenization.add(text);
return tokenization;
}
|
java
|
public List<String> splitMatches(String text, int minSize) {
TrieNode node = inner.root();
List<String> matches = new ArrayList<>();
String accumulator = "";
for (int i = 0; i < text.length(); i++) {
short prevDepth = node.getDepth();
TrieNode prevNode = node;
node = node.getContinuation(text.charAt(i));
if (null == node) node = inner.root();
if (!accumulator.isEmpty() && (node.getDepth() < prevDepth || (prevNode.hasChildren() && node.getDepth() == prevDepth))) {
if (accumulator.length() > minSize) {
matches.add(accumulator);
node = ((Optional<TrieNode>) inner.root().getChild(text.charAt(i))).orElse(inner.root());
}
accumulator = "";
}
else if (!accumulator.isEmpty()) {
accumulator += text.charAt(i);
}
else if (accumulator.isEmpty() && node.getDepth() > prevDepth) {
accumulator = node.getString();
}
}
List<String> tokenization = new ArrayList<>();
for (String match : matches) {
int index = text.indexOf(match);
assert (index >= 0);
if (index > 0) tokenization.add(text.substring(0, index));
tokenization.add(text.substring(index, index + match.length()));
text = text.substring(index + match.length());
}
tokenization.add(text);
return tokenization;
}
|
[
"public",
"List",
"<",
"String",
">",
"splitMatches",
"(",
"String",
"text",
",",
"int",
"minSize",
")",
"{",
"TrieNode",
"node",
"=",
"inner",
".",
"root",
"(",
")",
";",
"List",
"<",
"String",
">",
"matches",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"String",
"accumulator",
"=",
"\"\"",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"text",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"short",
"prevDepth",
"=",
"node",
".",
"getDepth",
"(",
")",
";",
"TrieNode",
"prevNode",
"=",
"node",
";",
"node",
"=",
"node",
".",
"getContinuation",
"(",
"text",
".",
"charAt",
"(",
"i",
")",
")",
";",
"if",
"(",
"null",
"==",
"node",
")",
"node",
"=",
"inner",
".",
"root",
"(",
")",
";",
"if",
"(",
"!",
"accumulator",
".",
"isEmpty",
"(",
")",
"&&",
"(",
"node",
".",
"getDepth",
"(",
")",
"<",
"prevDepth",
"||",
"(",
"prevNode",
".",
"hasChildren",
"(",
")",
"&&",
"node",
".",
"getDepth",
"(",
")",
"==",
"prevDepth",
")",
")",
")",
"{",
"if",
"(",
"accumulator",
".",
"length",
"(",
")",
">",
"minSize",
")",
"{",
"matches",
".",
"add",
"(",
"accumulator",
")",
";",
"node",
"=",
"(",
"(",
"Optional",
"<",
"TrieNode",
">",
")",
"inner",
".",
"root",
"(",
")",
".",
"getChild",
"(",
"text",
".",
"charAt",
"(",
"i",
")",
")",
")",
".",
"orElse",
"(",
"inner",
".",
"root",
"(",
")",
")",
";",
"}",
"accumulator",
"=",
"\"\"",
";",
"}",
"else",
"if",
"(",
"!",
"accumulator",
".",
"isEmpty",
"(",
")",
")",
"{",
"accumulator",
"+=",
"text",
".",
"charAt",
"(",
"i",
")",
";",
"}",
"else",
"if",
"(",
"accumulator",
".",
"isEmpty",
"(",
")",
"&&",
"node",
".",
"getDepth",
"(",
")",
">",
"prevDepth",
")",
"{",
"accumulator",
"=",
"node",
".",
"getString",
"(",
")",
";",
"}",
"}",
"List",
"<",
"String",
">",
"tokenization",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"String",
"match",
":",
"matches",
")",
"{",
"int",
"index",
"=",
"text",
".",
"indexOf",
"(",
"match",
")",
";",
"assert",
"(",
"index",
">=",
"0",
")",
";",
"if",
"(",
"index",
">",
"0",
")",
"tokenization",
".",
"add",
"(",
"text",
".",
"substring",
"(",
"0",
",",
"index",
")",
")",
";",
"tokenization",
".",
"add",
"(",
"text",
".",
"substring",
"(",
"index",
",",
"index",
"+",
"match",
".",
"length",
"(",
")",
")",
")",
";",
"text",
"=",
"text",
".",
"substring",
"(",
"index",
"+",
"match",
".",
"length",
"(",
")",
")",
";",
"}",
"tokenization",
".",
"add",
"(",
"text",
")",
";",
"return",
"tokenization",
";",
"}"
] |
Split matches list.
@param text the text
@param minSize the min size
@return the list
|
[
"Split",
"matches",
"list",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/text/TextAnalysis.java#L187-L220
|
154,780
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/text/TextAnalysis.java
|
TextAnalysis.splitChars
|
public List<String> splitChars(final String source, double threshold) {
List<String> output = new ArrayList<>();
int wordStart = 0;
double aposterioriNatsPrev = 0;
boolean isIncreasing = false;
double prevLink = 0;
for (int i = 1; i < source.length(); i++) {
String priorText = source.substring(0, i);
TrieNode priorNode = getMaxentPrior(priorText);
double aprioriNats = entropy(priorNode, priorNode.getParent());
String followingText = source.substring(i - 1, source.length());
TrieNode followingNode = getMaxentPost(followingText);
TrieNode godparent = followingNode.godparent();
double aposterioriNats = entropy(followingNode, godparent);
//double jointNats = getJointNats(priorNode, followingNode);
double linkNats = aprioriNats + aposterioriNatsPrev;
if (isVerbose()) {
verbose.println(String.format("%10s\t%10s\t%s",
'"' + priorNode.getString().replaceAll("\n", "\\n") + '"',
'"' + followingNode.getString().replaceAll("\n", "\\n") + '"',
Arrays.asList(aprioriNats, aposterioriNats, linkNats
).stream().map(x -> String.format("%.4f", x)).collect(Collectors.joining("\t"))));
}
String word = i < 2 ? "" : source.substring(wordStart, i - 2);
if (isIncreasing && linkNats < prevLink && prevLink > threshold && word.length() > 2) {
wordStart = i - 2;
output.add(word);
if (isVerbose()) verbose.println(String.format("Recognized token \"%s\"", word));
prevLink = linkNats;
aposterioriNatsPrev = aposterioriNats;
isIncreasing = false;
}
else {
if (linkNats > prevLink) isIncreasing = true;
prevLink = linkNats;
aposterioriNatsPrev = aposterioriNats;
}
}
return output;
}
|
java
|
public List<String> splitChars(final String source, double threshold) {
List<String> output = new ArrayList<>();
int wordStart = 0;
double aposterioriNatsPrev = 0;
boolean isIncreasing = false;
double prevLink = 0;
for (int i = 1; i < source.length(); i++) {
String priorText = source.substring(0, i);
TrieNode priorNode = getMaxentPrior(priorText);
double aprioriNats = entropy(priorNode, priorNode.getParent());
String followingText = source.substring(i - 1, source.length());
TrieNode followingNode = getMaxentPost(followingText);
TrieNode godparent = followingNode.godparent();
double aposterioriNats = entropy(followingNode, godparent);
//double jointNats = getJointNats(priorNode, followingNode);
double linkNats = aprioriNats + aposterioriNatsPrev;
if (isVerbose()) {
verbose.println(String.format("%10s\t%10s\t%s",
'"' + priorNode.getString().replaceAll("\n", "\\n") + '"',
'"' + followingNode.getString().replaceAll("\n", "\\n") + '"',
Arrays.asList(aprioriNats, aposterioriNats, linkNats
).stream().map(x -> String.format("%.4f", x)).collect(Collectors.joining("\t"))));
}
String word = i < 2 ? "" : source.substring(wordStart, i - 2);
if (isIncreasing && linkNats < prevLink && prevLink > threshold && word.length() > 2) {
wordStart = i - 2;
output.add(word);
if (isVerbose()) verbose.println(String.format("Recognized token \"%s\"", word));
prevLink = linkNats;
aposterioriNatsPrev = aposterioriNats;
isIncreasing = false;
}
else {
if (linkNats > prevLink) isIncreasing = true;
prevLink = linkNats;
aposterioriNatsPrev = aposterioriNats;
}
}
return output;
}
|
[
"public",
"List",
"<",
"String",
">",
"splitChars",
"(",
"final",
"String",
"source",
",",
"double",
"threshold",
")",
"{",
"List",
"<",
"String",
">",
"output",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"int",
"wordStart",
"=",
"0",
";",
"double",
"aposterioriNatsPrev",
"=",
"0",
";",
"boolean",
"isIncreasing",
"=",
"false",
";",
"double",
"prevLink",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"source",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"String",
"priorText",
"=",
"source",
".",
"substring",
"(",
"0",
",",
"i",
")",
";",
"TrieNode",
"priorNode",
"=",
"getMaxentPrior",
"(",
"priorText",
")",
";",
"double",
"aprioriNats",
"=",
"entropy",
"(",
"priorNode",
",",
"priorNode",
".",
"getParent",
"(",
")",
")",
";",
"String",
"followingText",
"=",
"source",
".",
"substring",
"(",
"i",
"-",
"1",
",",
"source",
".",
"length",
"(",
")",
")",
";",
"TrieNode",
"followingNode",
"=",
"getMaxentPost",
"(",
"followingText",
")",
";",
"TrieNode",
"godparent",
"=",
"followingNode",
".",
"godparent",
"(",
")",
";",
"double",
"aposterioriNats",
"=",
"entropy",
"(",
"followingNode",
",",
"godparent",
")",
";",
"//double jointNats = getJointNats(priorNode, followingNode);",
"double",
"linkNats",
"=",
"aprioriNats",
"+",
"aposterioriNatsPrev",
";",
"if",
"(",
"isVerbose",
"(",
")",
")",
"{",
"verbose",
".",
"println",
"(",
"String",
".",
"format",
"(",
"\"%10s\\t%10s\\t%s\"",
",",
"'",
"'",
"+",
"priorNode",
".",
"getString",
"(",
")",
".",
"replaceAll",
"(",
"\"\\n\"",
",",
"\"\\\\n\"",
")",
"+",
"'",
"'",
",",
"'",
"'",
"+",
"followingNode",
".",
"getString",
"(",
")",
".",
"replaceAll",
"(",
"\"\\n\"",
",",
"\"\\\\n\"",
")",
"+",
"'",
"'",
",",
"Arrays",
".",
"asList",
"(",
"aprioriNats",
",",
"aposterioriNats",
",",
"linkNats",
")",
".",
"stream",
"(",
")",
".",
"map",
"(",
"x",
"->",
"String",
".",
"format",
"(",
"\"%.4f\"",
",",
"x",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"joining",
"(",
"\"\\t\"",
")",
")",
")",
")",
";",
"}",
"String",
"word",
"=",
"i",
"<",
"2",
"?",
"\"\"",
":",
"source",
".",
"substring",
"(",
"wordStart",
",",
"i",
"-",
"2",
")",
";",
"if",
"(",
"isIncreasing",
"&&",
"linkNats",
"<",
"prevLink",
"&&",
"prevLink",
">",
"threshold",
"&&",
"word",
".",
"length",
"(",
")",
">",
"2",
")",
"{",
"wordStart",
"=",
"i",
"-",
"2",
";",
"output",
".",
"add",
"(",
"word",
")",
";",
"if",
"(",
"isVerbose",
"(",
")",
")",
"verbose",
".",
"println",
"(",
"String",
".",
"format",
"(",
"\"Recognized token \\\"%s\\\"\"",
",",
"word",
")",
")",
";",
"prevLink",
"=",
"linkNats",
";",
"aposterioriNatsPrev",
"=",
"aposterioriNats",
";",
"isIncreasing",
"=",
"false",
";",
"}",
"else",
"{",
"if",
"(",
"linkNats",
">",
"prevLink",
")",
"isIncreasing",
"=",
"true",
";",
"prevLink",
"=",
"linkNats",
";",
"aposterioriNatsPrev",
"=",
"aposterioriNats",
";",
"}",
"}",
"return",
"output",
";",
"}"
] |
Split chars list.
@param source the source
@param threshold the threshold
@return the list
|
[
"Split",
"chars",
"list",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/text/TextAnalysis.java#L229-L270
|
154,781
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/text/TextAnalysis.java
|
TextAnalysis.entropy
|
public double entropy(final String source) {
double output = 0;
for (int i = 1; i < source.length(); i++) {
TrieNode node = this.inner.matchEnd(source.substring(0, i));
Optional<? extends TrieNode> child = node.getChild(source.charAt(i));
while (!child.isPresent()) {
output += Math.log(1.0 / node.getCursorCount());
node = node.godparent();
child = node.getChild(source.charAt(i));
}
output += Math.log(child.get().getCursorCount() * 1.0 / node.getCursorCount());
}
return -output / Math.log(2);
}
|
java
|
public double entropy(final String source) {
double output = 0;
for (int i = 1; i < source.length(); i++) {
TrieNode node = this.inner.matchEnd(source.substring(0, i));
Optional<? extends TrieNode> child = node.getChild(source.charAt(i));
while (!child.isPresent()) {
output += Math.log(1.0 / node.getCursorCount());
node = node.godparent();
child = node.getChild(source.charAt(i));
}
output += Math.log(child.get().getCursorCount() * 1.0 / node.getCursorCount());
}
return -output / Math.log(2);
}
|
[
"public",
"double",
"entropy",
"(",
"final",
"String",
"source",
")",
"{",
"double",
"output",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"source",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"TrieNode",
"node",
"=",
"this",
".",
"inner",
".",
"matchEnd",
"(",
"source",
".",
"substring",
"(",
"0",
",",
"i",
")",
")",
";",
"Optional",
"<",
"?",
"extends",
"TrieNode",
">",
"child",
"=",
"node",
".",
"getChild",
"(",
"source",
".",
"charAt",
"(",
"i",
")",
")",
";",
"while",
"(",
"!",
"child",
".",
"isPresent",
"(",
")",
")",
"{",
"output",
"+=",
"Math",
".",
"log",
"(",
"1.0",
"/",
"node",
".",
"getCursorCount",
"(",
")",
")",
";",
"node",
"=",
"node",
".",
"godparent",
"(",
")",
";",
"child",
"=",
"node",
".",
"getChild",
"(",
"source",
".",
"charAt",
"(",
"i",
")",
")",
";",
"}",
"output",
"+=",
"Math",
".",
"log",
"(",
"child",
".",
"get",
"(",
")",
".",
"getCursorCount",
"(",
")",
"*",
"1.0",
"/",
"node",
".",
"getCursorCount",
"(",
")",
")",
";",
"}",
"return",
"-",
"output",
"/",
"Math",
".",
"log",
"(",
"2",
")",
";",
"}"
] |
Entropy double.
@param source the source
@return the double
|
[
"Entropy",
"double",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/text/TextAnalysis.java#L339-L352
|
154,782
|
picoff/java-commons
|
src/main/java/com/picoff/commons/net/InetAddressAnonymizer.java
|
InetAddressAnonymizer.anonymize
|
public static InetAddress anonymize(final InetAddress inetAddress) throws UnknownHostException {
if (inetAddress.isAnyLocalAddress() || inetAddress.isLoopbackAddress()) {
return inetAddress;
}
final int mask = inetAddress instanceof Inet4Address ? 24 : 48;
return truncate(inetAddress, mask);
}
|
java
|
public static InetAddress anonymize(final InetAddress inetAddress) throws UnknownHostException {
if (inetAddress.isAnyLocalAddress() || inetAddress.isLoopbackAddress()) {
return inetAddress;
}
final int mask = inetAddress instanceof Inet4Address ? 24 : 48;
return truncate(inetAddress, mask);
}
|
[
"public",
"static",
"InetAddress",
"anonymize",
"(",
"final",
"InetAddress",
"inetAddress",
")",
"throws",
"UnknownHostException",
"{",
"if",
"(",
"inetAddress",
".",
"isAnyLocalAddress",
"(",
")",
"||",
"inetAddress",
".",
"isLoopbackAddress",
"(",
")",
")",
"{",
"return",
"inetAddress",
";",
"}",
"final",
"int",
"mask",
"=",
"inetAddress",
"instanceof",
"Inet4Address",
"?",
"24",
":",
"48",
";",
"return",
"truncate",
"(",
"inetAddress",
",",
"mask",
")",
";",
"}"
] |
IPv4 addresses have their length truncated to 24 bits, IPv6 to 48 bits
|
[
"IPv4",
"addresses",
"have",
"their",
"length",
"truncated",
"to",
"24",
"bits",
"IPv6",
"to",
"48",
"bits"
] |
522d12db77c240edfb62db10a3eb8e0023b87317
|
https://github.com/picoff/java-commons/blob/522d12db77c240edfb62db10a3eb8e0023b87317/src/main/java/com/picoff/commons/net/InetAddressAnonymizer.java#L26-L33
|
154,783
|
lotaris/jee-validation
|
src/main/java/com/lotaris/jee/validation/preprocessing/ApiPreprocessingContext.java
|
ApiPreprocessingContext.process
|
public ApiPreprocessingContext process(Object object) throws ApiErrorsException {
if (result != null) {
throw new IllegalStateException("This preprocessing context has already been used; create another one.");
}
result = preprocessor.process(object, this);
if (failOnErrors && apiErrorResponse.hasErrors()) {
throw new ApiErrorsException(apiErrorResponse);
}
return this;
}
|
java
|
public ApiPreprocessingContext process(Object object) throws ApiErrorsException {
if (result != null) {
throw new IllegalStateException("This preprocessing context has already been used; create another one.");
}
result = preprocessor.process(object, this);
if (failOnErrors && apiErrorResponse.hasErrors()) {
throw new ApiErrorsException(apiErrorResponse);
}
return this;
}
|
[
"public",
"ApiPreprocessingContext",
"process",
"(",
"Object",
"object",
")",
"throws",
"ApiErrorsException",
"{",
"if",
"(",
"result",
"!=",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"This preprocessing context has already been used; create another one.\"",
")",
";",
"}",
"result",
"=",
"preprocessor",
".",
"process",
"(",
"object",
",",
"this",
")",
";",
"if",
"(",
"failOnErrors",
"&&",
"apiErrorResponse",
".",
"hasErrors",
"(",
")",
")",
"{",
"throw",
"new",
"ApiErrorsException",
"(",
"apiErrorResponse",
")",
";",
"}",
"return",
"this",
";",
"}"
] |
Runs preprocessing on the specified object.
@param object the object to preprocess
@return a result object indicating whether the preprocessing chain completed successfully and
containing the errors collected during preprocessing (note that a successful chain may
produce errors such as validation errors)
@throws ApiErrorsException if any of the preprocessors adds errors to the error collector
|
[
"Runs",
"preprocessing",
"on",
"the",
"specified",
"object",
"."
] |
feefff820b5a67c7471a13e08fdaf2d60bb3ad16
|
https://github.com/lotaris/jee-validation/blob/feefff820b5a67c7471a13e08fdaf2d60bb3ad16/src/main/java/com/lotaris/jee/validation/preprocessing/ApiPreprocessingContext.java#L71-L83
|
154,784
|
lotaris/jee-validation
|
src/main/java/com/lotaris/jee/validation/preprocessing/ApiPreprocessingContext.java
|
ApiPreprocessingContext.validateWith
|
public ApiPreprocessingContext validateWith(IValidator... apiValidators) {
for (IValidator apiValidator : apiValidators) {
if (apiValidator == null) {
throw new IllegalArgumentException("Validator cannot be null");
}
this.validators.add(apiValidator);
}
return this;
}
|
java
|
public ApiPreprocessingContext validateWith(IValidator... apiValidators) {
for (IValidator apiValidator : apiValidators) {
if (apiValidator == null) {
throw new IllegalArgumentException("Validator cannot be null");
}
this.validators.add(apiValidator);
}
return this;
}
|
[
"public",
"ApiPreprocessingContext",
"validateWith",
"(",
"IValidator",
"...",
"apiValidators",
")",
"{",
"for",
"(",
"IValidator",
"apiValidator",
":",
"apiValidators",
")",
"{",
"if",
"(",
"apiValidator",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Validator cannot be null\"",
")",
";",
"}",
"this",
".",
"validators",
".",
"add",
"(",
"apiValidator",
")",
";",
"}",
"return",
"this",
";",
"}"
] |
Adds the specified validators to be run on the preprocessed object after bean validations.
@param apiValidators the validators to run
@return this updated context
@see AbstractValidator
|
[
"Adds",
"the",
"specified",
"validators",
"to",
"be",
"run",
"on",
"the",
"preprocessed",
"object",
"after",
"bean",
"validations",
"."
] |
feefff820b5a67c7471a13e08fdaf2d60bb3ad16
|
https://github.com/lotaris/jee-validation/blob/feefff820b5a67c7471a13e08fdaf2d60bb3ad16/src/main/java/com/lotaris/jee/validation/preprocessing/ApiPreprocessingContext.java#L125-L133
|
154,785
|
zandero/http
|
src/main/java/com/zandero/http/RequestUtils.java
|
RequestUtils.getHeader
|
public static String getHeader(HttpServletRequest request, String header) {
// noting to search in or nothing to be found
if (request == null || StringUtils.isNullOrEmptyTrimmed(header)) {
return null;
}
return request.getHeader(header);
}
|
java
|
public static String getHeader(HttpServletRequest request, String header) {
// noting to search in or nothing to be found
if (request == null || StringUtils.isNullOrEmptyTrimmed(header)) {
return null;
}
return request.getHeader(header);
}
|
[
"public",
"static",
"String",
"getHeader",
"(",
"HttpServletRequest",
"request",
",",
"String",
"header",
")",
"{",
"// noting to search in or nothing to be found",
"if",
"(",
"request",
"==",
"null",
"||",
"StringUtils",
".",
"isNullOrEmptyTrimmed",
"(",
"header",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"request",
".",
"getHeader",
"(",
"header",
")",
";",
"}"
] |
Returns header from given request
@param request to search for header
@param header name
@return header value or null if not found
|
[
"Returns",
"header",
"from",
"given",
"request"
] |
909eb879f1193adf24545360c3b76bd813865f65
|
https://github.com/zandero/http/blob/909eb879f1193adf24545360c3b76bd813865f65/src/main/java/com/zandero/http/RequestUtils.java#L46-L54
|
154,786
|
zandero/http
|
src/main/java/com/zandero/http/RequestUtils.java
|
RequestUtils.getDomain
|
public static String getDomain(HttpServletRequest request) {
if (request == null) {
return null;
}
return UrlUtils.resolveDomain(request.getServerName());
}
|
java
|
public static String getDomain(HttpServletRequest request) {
if (request == null) {
return null;
}
return UrlUtils.resolveDomain(request.getServerName());
}
|
[
"public",
"static",
"String",
"getDomain",
"(",
"HttpServletRequest",
"request",
")",
"{",
"if",
"(",
"request",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"UrlUtils",
".",
"resolveDomain",
"(",
"request",
".",
"getServerName",
"(",
")",
")",
";",
"}"
] |
Resolves domain name from given URL
@param request to get domain name from
@return domain name or null if not resolved
|
[
"Resolves",
"domain",
"name",
"from",
"given",
"URL"
] |
909eb879f1193adf24545360c3b76bd813865f65
|
https://github.com/zandero/http/blob/909eb879f1193adf24545360c3b76bd813865f65/src/main/java/com/zandero/http/RequestUtils.java#L62-L69
|
154,787
|
zandero/http
|
src/main/java/com/zandero/http/RequestUtils.java
|
RequestUtils.isIpAddressAllowed
|
public static boolean isIpAddressAllowed(String ipAddress, String... whitelist) {
if (StringUtils.isNullOrEmpty(ipAddress) || whitelist == null || whitelist.length == 0) {
return false;
}
for (String address : whitelist) {
if (ipAddress.equals(address)) {
return true;
}
if (address.contains("/")) { // is range definition
SubnetUtils utils = new SubnetUtils(address);
utils.setInclusiveHostCount(true);
if (utils.getInfo().isInRange(ipAddress)) {
return true;
}
}
}
return false;
}
|
java
|
public static boolean isIpAddressAllowed(String ipAddress, String... whitelist) {
if (StringUtils.isNullOrEmpty(ipAddress) || whitelist == null || whitelist.length == 0) {
return false;
}
for (String address : whitelist) {
if (ipAddress.equals(address)) {
return true;
}
if (address.contains("/")) { // is range definition
SubnetUtils utils = new SubnetUtils(address);
utils.setInclusiveHostCount(true);
if (utils.getInfo().isInRange(ipAddress)) {
return true;
}
}
}
return false;
}
|
[
"public",
"static",
"boolean",
"isIpAddressAllowed",
"(",
"String",
"ipAddress",
",",
"String",
"...",
"whitelist",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isNullOrEmpty",
"(",
"ipAddress",
")",
"||",
"whitelist",
"==",
"null",
"||",
"whitelist",
".",
"length",
"==",
"0",
")",
"{",
"return",
"false",
";",
"}",
"for",
"(",
"String",
"address",
":",
"whitelist",
")",
"{",
"if",
"(",
"ipAddress",
".",
"equals",
"(",
"address",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"address",
".",
"contains",
"(",
"\"/\"",
")",
")",
"{",
"// is range definition",
"SubnetUtils",
"utils",
"=",
"new",
"SubnetUtils",
"(",
"address",
")",
";",
"utils",
".",
"setInclusiveHostCount",
"(",
"true",
")",
";",
"if",
"(",
"utils",
".",
"getInfo",
"(",
")",
".",
"isInRange",
"(",
"ipAddress",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] |
Compares ipAddress with one of the ip addresses listed
@param ipAddress ip address to compare
@param whitelist list of ip addresses ... an be a range ip ... in format 123.123.123.123/28 where last part is a subnet range
@return true if allowed, false if not
|
[
"Compares",
"ipAddress",
"with",
"one",
"of",
"the",
"ip",
"addresses",
"listed"
] |
909eb879f1193adf24545360c3b76bd813865f65
|
https://github.com/zandero/http/blob/909eb879f1193adf24545360c3b76bd813865f65/src/main/java/com/zandero/http/RequestUtils.java#L128-L152
|
154,788
|
zandero/http
|
src/main/java/com/zandero/http/RequestUtils.java
|
RequestUtils.checkBasicAuth
|
public static boolean checkBasicAuth(HttpServletRequest servletRequest, String username, String password) {
String basicAuth = servletRequest.getHeader("Authorization");
if (StringUtils.isNullOrEmptyTrimmed(basicAuth) || !basicAuth.startsWith("Basic ")) {
return false;
}
String base64Credentials = basicAuth.substring("Basic".length()).trim();
String credentials = new String(Base64.getDecoder().decode(base64Credentials), Charset.forName("UTF-8"));
// credentials = username:password
final String[] values = credentials.split(":", 2);
if (values.length != 2) {
return false;
}
return StringUtils.equals(values[0], username) && StringUtils.equals(values[1], password);
}
|
java
|
public static boolean checkBasicAuth(HttpServletRequest servletRequest, String username, String password) {
String basicAuth = servletRequest.getHeader("Authorization");
if (StringUtils.isNullOrEmptyTrimmed(basicAuth) || !basicAuth.startsWith("Basic ")) {
return false;
}
String base64Credentials = basicAuth.substring("Basic".length()).trim();
String credentials = new String(Base64.getDecoder().decode(base64Credentials), Charset.forName("UTF-8"));
// credentials = username:password
final String[] values = credentials.split(":", 2);
if (values.length != 2) {
return false;
}
return StringUtils.equals(values[0], username) && StringUtils.equals(values[1], password);
}
|
[
"public",
"static",
"boolean",
"checkBasicAuth",
"(",
"HttpServletRequest",
"servletRequest",
",",
"String",
"username",
",",
"String",
"password",
")",
"{",
"String",
"basicAuth",
"=",
"servletRequest",
".",
"getHeader",
"(",
"\"Authorization\"",
")",
";",
"if",
"(",
"StringUtils",
".",
"isNullOrEmptyTrimmed",
"(",
"basicAuth",
")",
"||",
"!",
"basicAuth",
".",
"startsWith",
"(",
"\"Basic \"",
")",
")",
"{",
"return",
"false",
";",
"}",
"String",
"base64Credentials",
"=",
"basicAuth",
".",
"substring",
"(",
"\"Basic\"",
".",
"length",
"(",
")",
")",
".",
"trim",
"(",
")",
";",
"String",
"credentials",
"=",
"new",
"String",
"(",
"Base64",
".",
"getDecoder",
"(",
")",
".",
"decode",
"(",
"base64Credentials",
")",
",",
"Charset",
".",
"forName",
"(",
"\"UTF-8\"",
")",
")",
";",
"// credentials = username:password",
"final",
"String",
"[",
"]",
"values",
"=",
"credentials",
".",
"split",
"(",
"\":\"",
",",
"2",
")",
";",
"if",
"(",
"values",
".",
"length",
"!=",
"2",
")",
"{",
"return",
"false",
";",
"}",
"return",
"StringUtils",
".",
"equals",
"(",
"values",
"[",
"0",
"]",
",",
"username",
")",
"&&",
"StringUtils",
".",
"equals",
"(",
"values",
"[",
"1",
"]",
",",
"password",
")",
";",
"}"
] |
Checks if request is made by cron job
@param servletRequest must be GET request with cron job basic authorization set
@param username to check agains
@param password to check against
@return true if cron job request, false if not
|
[
"Checks",
"if",
"request",
"is",
"made",
"by",
"cron",
"job"
] |
909eb879f1193adf24545360c3b76bd813865f65
|
https://github.com/zandero/http/blob/909eb879f1193adf24545360c3b76bd813865f65/src/main/java/com/zandero/http/RequestUtils.java#L162-L179
|
154,789
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/stats/StatsMap.java
|
StatsMap.merge
|
public StatsMap merge(StatsMap statsMap) {
synchronized (statsFieldNumberMap) {
statsFieldNumberMap
.put(count, statsFieldNumberMap.get(count).longValue() +
statsMap.get(count).longValue());
statsFieldNumberMap
.put(sum, statsFieldNumberMap.get(sum).doubleValue() +
statsMap.get(sum).doubleValue());
statsFieldNumberMap
.put(min, statsFieldNumberMap.get(min).doubleValue() <
statsMap.get(min)
.doubleValue() ? statsFieldNumberMap
.get(min).doubleValue() : statsMap.get(min)
.doubleValue());
statsFieldNumberMap
.put(max, statsFieldNumberMap.get(max).doubleValue() >
statsMap.get(max)
.doubleValue() ? statsFieldNumberMap
.get(max).doubleValue() : statsMap.get(max)
.doubleValue());
statsFieldNumberMap
.put(avg, statsFieldNumberMap.get(sum).doubleValue() /
statsFieldNumberMap.get(count).doubleValue());
return this;
}
}
|
java
|
public StatsMap merge(StatsMap statsMap) {
synchronized (statsFieldNumberMap) {
statsFieldNumberMap
.put(count, statsFieldNumberMap.get(count).longValue() +
statsMap.get(count).longValue());
statsFieldNumberMap
.put(sum, statsFieldNumberMap.get(sum).doubleValue() +
statsMap.get(sum).doubleValue());
statsFieldNumberMap
.put(min, statsFieldNumberMap.get(min).doubleValue() <
statsMap.get(min)
.doubleValue() ? statsFieldNumberMap
.get(min).doubleValue() : statsMap.get(min)
.doubleValue());
statsFieldNumberMap
.put(max, statsFieldNumberMap.get(max).doubleValue() >
statsMap.get(max)
.doubleValue() ? statsFieldNumberMap
.get(max).doubleValue() : statsMap.get(max)
.doubleValue());
statsFieldNumberMap
.put(avg, statsFieldNumberMap.get(sum).doubleValue() /
statsFieldNumberMap.get(count).doubleValue());
return this;
}
}
|
[
"public",
"StatsMap",
"merge",
"(",
"StatsMap",
"statsMap",
")",
"{",
"synchronized",
"(",
"statsFieldNumberMap",
")",
"{",
"statsFieldNumberMap",
".",
"put",
"(",
"count",
",",
"statsFieldNumberMap",
".",
"get",
"(",
"count",
")",
".",
"longValue",
"(",
")",
"+",
"statsMap",
".",
"get",
"(",
"count",
")",
".",
"longValue",
"(",
")",
")",
";",
"statsFieldNumberMap",
".",
"put",
"(",
"sum",
",",
"statsFieldNumberMap",
".",
"get",
"(",
"sum",
")",
".",
"doubleValue",
"(",
")",
"+",
"statsMap",
".",
"get",
"(",
"sum",
")",
".",
"doubleValue",
"(",
")",
")",
";",
"statsFieldNumberMap",
".",
"put",
"(",
"min",
",",
"statsFieldNumberMap",
".",
"get",
"(",
"min",
")",
".",
"doubleValue",
"(",
")",
"<",
"statsMap",
".",
"get",
"(",
"min",
")",
".",
"doubleValue",
"(",
")",
"?",
"statsFieldNumberMap",
".",
"get",
"(",
"min",
")",
".",
"doubleValue",
"(",
")",
":",
"statsMap",
".",
"get",
"(",
"min",
")",
".",
"doubleValue",
"(",
")",
")",
";",
"statsFieldNumberMap",
".",
"put",
"(",
"max",
",",
"statsFieldNumberMap",
".",
"get",
"(",
"max",
")",
".",
"doubleValue",
"(",
")",
">",
"statsMap",
".",
"get",
"(",
"max",
")",
".",
"doubleValue",
"(",
")",
"?",
"statsFieldNumberMap",
".",
"get",
"(",
"max",
")",
".",
"doubleValue",
"(",
")",
":",
"statsMap",
".",
"get",
"(",
"max",
")",
".",
"doubleValue",
"(",
")",
")",
";",
"statsFieldNumberMap",
".",
"put",
"(",
"avg",
",",
"statsFieldNumberMap",
".",
"get",
"(",
"sum",
")",
".",
"doubleValue",
"(",
")",
"/",
"statsFieldNumberMap",
".",
"get",
"(",
"count",
")",
".",
"doubleValue",
"(",
")",
")",
";",
"return",
"this",
";",
"}",
"}"
] |
Merge stats map.
@param statsMap the stats map
@return the stats map
|
[
"Merge",
"stats",
"map",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/stats/StatsMap.java#L106-L131
|
154,790
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/stats/StatsMap.java
|
StatsMap.changeIntoStatsFieldStringMap
|
public static Map<String, Number> changeIntoStatsFieldStringMap(
StatsMap statsMap) {
return JMMap.newChangedKeyMap(statsMap, StatsField::name);
}
|
java
|
public static Map<String, Number> changeIntoStatsFieldStringMap(
StatsMap statsMap) {
return JMMap.newChangedKeyMap(statsMap, StatsField::name);
}
|
[
"public",
"static",
"Map",
"<",
"String",
",",
"Number",
">",
"changeIntoStatsFieldStringMap",
"(",
"StatsMap",
"statsMap",
")",
"{",
"return",
"JMMap",
".",
"newChangedKeyMap",
"(",
"statsMap",
",",
"StatsField",
"::",
"name",
")",
";",
"}"
] |
Change into stats field string map map.
@param statsMap the stats map
@return the map
|
[
"Change",
"into",
"stats",
"field",
"string",
"map",
"map",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/stats/StatsMap.java#L148-L151
|
154,791
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/stats/StatsMap.java
|
StatsMap.changeIntoStatsMap
|
public static StatsMap changeIntoStatsMap(
Map<String, Number> statsFieldStringMap) {
return new StatsMap(JMMap.newChangedKeyMap(statsFieldStringMap,
StatsField::valueOf));
}
|
java
|
public static StatsMap changeIntoStatsMap(
Map<String, Number> statsFieldStringMap) {
return new StatsMap(JMMap.newChangedKeyMap(statsFieldStringMap,
StatsField::valueOf));
}
|
[
"public",
"static",
"StatsMap",
"changeIntoStatsMap",
"(",
"Map",
"<",
"String",
",",
"Number",
">",
"statsFieldStringMap",
")",
"{",
"return",
"new",
"StatsMap",
"(",
"JMMap",
".",
"newChangedKeyMap",
"(",
"statsFieldStringMap",
",",
"StatsField",
"::",
"valueOf",
")",
")",
";",
"}"
] |
Change into stats map stats map.
@param statsFieldStringMap the stats field string map
@return the stats map
|
[
"Change",
"into",
"stats",
"map",
"stats",
"map",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/stats/StatsMap.java#L159-L163
|
154,792
|
Sproutigy/Java-Commons-Binary
|
src/main/java/com/sproutigy/commons/binary/Binary.java
|
Binary.toTempFile
|
public String toTempFile() throws IOException {
File file = File.createTempFile(UUID.randomUUID().toString(), ".binary.tmp");
file.deleteOnExit();
toFile(file);
return file.getAbsolutePath();
}
|
java
|
public String toTempFile() throws IOException {
File file = File.createTempFile(UUID.randomUUID().toString(), ".binary.tmp");
file.deleteOnExit();
toFile(file);
return file.getAbsolutePath();
}
|
[
"public",
"String",
"toTempFile",
"(",
")",
"throws",
"IOException",
"{",
"File",
"file",
"=",
"File",
".",
"createTempFile",
"(",
"UUID",
".",
"randomUUID",
"(",
")",
".",
"toString",
"(",
")",
",",
"\".binary.tmp\"",
")",
";",
"file",
".",
"deleteOnExit",
"(",
")",
";",
"toFile",
"(",
"file",
")",
";",
"return",
"file",
".",
"getAbsolutePath",
"(",
")",
";",
"}"
] |
Creates new temporary file with random name and returns full path to the file
@return Temporary file path string
|
[
"Creates",
"new",
"temporary",
"file",
"with",
"random",
"name",
"and",
"returns",
"full",
"path",
"to",
"the",
"file"
] |
547ab53d16e454d53ed5cef1d1ee514ec2d7c726
|
https://github.com/Sproutigy/Java-Commons-Binary/blob/547ab53d16e454d53ed5cef1d1ee514ec2d7c726/src/main/java/com/sproutigy/commons/binary/Binary.java#L166-L171
|
154,793
|
Sproutigy/Java-Commons-Binary
|
src/main/java/com/sproutigy/commons/binary/Binary.java
|
Binary.toByteArray
|
public int toByteArray(byte[] target, int targetOffset) throws IOException {
long length = length();
if ((long)targetOffset + length > Integer.MAX_VALUE) {
throw new IOException("Unable to write - too big data");
}
if (target.length < targetOffset + length) {
throw new IOException("Insufficient target byte array size");
}
if (length < 0) {
length = 0;
int curOffset = targetOffset;
InputStream in = asStream();
try {
int readbyte;
while ((readbyte = in.read()) != EOF) {
target[curOffset] = (byte) readbyte;
curOffset++;
length++;
}
} finally {
in.close();
}
}
else
{
System.arraycopy(asByteArray(false), 0, target, targetOffset, (int)length);
}
return (int)length;
}
|
java
|
public int toByteArray(byte[] target, int targetOffset) throws IOException {
long length = length();
if ((long)targetOffset + length > Integer.MAX_VALUE) {
throw new IOException("Unable to write - too big data");
}
if (target.length < targetOffset + length) {
throw new IOException("Insufficient target byte array size");
}
if (length < 0) {
length = 0;
int curOffset = targetOffset;
InputStream in = asStream();
try {
int readbyte;
while ((readbyte = in.read()) != EOF) {
target[curOffset] = (byte) readbyte;
curOffset++;
length++;
}
} finally {
in.close();
}
}
else
{
System.arraycopy(asByteArray(false), 0, target, targetOffset, (int)length);
}
return (int)length;
}
|
[
"public",
"int",
"toByteArray",
"(",
"byte",
"[",
"]",
"target",
",",
"int",
"targetOffset",
")",
"throws",
"IOException",
"{",
"long",
"length",
"=",
"length",
"(",
")",
";",
"if",
"(",
"(",
"long",
")",
"targetOffset",
"+",
"length",
">",
"Integer",
".",
"MAX_VALUE",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Unable to write - too big data\"",
")",
";",
"}",
"if",
"(",
"target",
".",
"length",
"<",
"targetOffset",
"+",
"length",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Insufficient target byte array size\"",
")",
";",
"}",
"if",
"(",
"length",
"<",
"0",
")",
"{",
"length",
"=",
"0",
";",
"int",
"curOffset",
"=",
"targetOffset",
";",
"InputStream",
"in",
"=",
"asStream",
"(",
")",
";",
"try",
"{",
"int",
"readbyte",
";",
"while",
"(",
"(",
"readbyte",
"=",
"in",
".",
"read",
"(",
")",
")",
"!=",
"EOF",
")",
"{",
"target",
"[",
"curOffset",
"]",
"=",
"(",
"byte",
")",
"readbyte",
";",
"curOffset",
"++",
";",
"length",
"++",
";",
"}",
"}",
"finally",
"{",
"in",
".",
"close",
"(",
")",
";",
"}",
"}",
"else",
"{",
"System",
".",
"arraycopy",
"(",
"asByteArray",
"(",
"false",
")",
",",
"0",
",",
"target",
",",
"targetOffset",
",",
"(",
"int",
")",
"length",
")",
";",
"}",
"return",
"(",
"int",
")",
"length",
";",
"}"
] |
Writes data to some existing byte array starting from specific offset
@param target byte array destination
@param targetOffset destination offset to start
@return length of source (written) data
@throws IOException
|
[
"Writes",
"data",
"to",
"some",
"existing",
"byte",
"array",
"starting",
"from",
"specific",
"offset"
] |
547ab53d16e454d53ed5cef1d1ee514ec2d7c726
|
https://github.com/Sproutigy/Java-Commons-Binary/blob/547ab53d16e454d53ed5cef1d1ee514ec2d7c726/src/main/java/com/sproutigy/commons/binary/Binary.java#L264-L293
|
154,794
|
Sproutigy/Java-Commons-Binary
|
src/main/java/com/sproutigy/commons/binary/Binary.java
|
Binary.asBase64
|
public String asBase64() throws IOException {
return asBase64(BaseEncoding.Dialect.STANDARD, BaseEncoding.Padding.STANDARD);
}
|
java
|
public String asBase64() throws IOException {
return asBase64(BaseEncoding.Dialect.STANDARD, BaseEncoding.Padding.STANDARD);
}
|
[
"public",
"String",
"asBase64",
"(",
")",
"throws",
"IOException",
"{",
"return",
"asBase64",
"(",
"BaseEncoding",
".",
"Dialect",
".",
"STANDARD",
",",
"BaseEncoding",
".",
"Padding",
".",
"STANDARD",
")",
";",
"}"
] |
Represent as Base 64 with standard dialect and standard padding
@return Base 64 encoded string
|
[
"Represent",
"as",
"Base",
"64",
"with",
"standard",
"dialect",
"and",
"standard",
"padding"
] |
547ab53d16e454d53ed5cef1d1ee514ec2d7c726
|
https://github.com/Sproutigy/Java-Commons-Binary/blob/547ab53d16e454d53ed5cef1d1ee514ec2d7c726/src/main/java/com/sproutigy/commons/binary/Binary.java#L316-L318
|
154,795
|
Sproutigy/Java-Commons-Binary
|
src/main/java/com/sproutigy/commons/binary/Binary.java
|
Binary.asBase64
|
public String asBase64(BaseEncoding.Dialect dialect, BaseEncoding.Padding padding) throws IOException {
String standardBase64 = DatatypeConverter.printBase64Binary(asByteArray(false));
if (dialect == BaseEncoding.Dialect.STANDARD && padding == BaseEncoding.Padding.STANDARD) {
return standardBase64;
}
StringBuilder safeBase64 = new StringBuilder(standardBase64.length());
for(int i=0; i<standardBase64.length(); i++) {
char c = standardBase64.charAt(i);
if (dialect == BaseEncoding.Dialect.SAFE) {
if (c == '+') c = '-';
else if (c == '/') c = '_';
}
if (c == '=') {
if (padding == BaseEncoding.Padding.STANDARD) {
safeBase64.append('=');
}
else if (padding == BaseEncoding.Padding.SAFE) {
safeBase64.append('.');
}
} else {
safeBase64.append(c);
}
}
return safeBase64.toString();
}
|
java
|
public String asBase64(BaseEncoding.Dialect dialect, BaseEncoding.Padding padding) throws IOException {
String standardBase64 = DatatypeConverter.printBase64Binary(asByteArray(false));
if (dialect == BaseEncoding.Dialect.STANDARD && padding == BaseEncoding.Padding.STANDARD) {
return standardBase64;
}
StringBuilder safeBase64 = new StringBuilder(standardBase64.length());
for(int i=0; i<standardBase64.length(); i++) {
char c = standardBase64.charAt(i);
if (dialect == BaseEncoding.Dialect.SAFE) {
if (c == '+') c = '-';
else if (c == '/') c = '_';
}
if (c == '=') {
if (padding == BaseEncoding.Padding.STANDARD) {
safeBase64.append('=');
}
else if (padding == BaseEncoding.Padding.SAFE) {
safeBase64.append('.');
}
} else {
safeBase64.append(c);
}
}
return safeBase64.toString();
}
|
[
"public",
"String",
"asBase64",
"(",
"BaseEncoding",
".",
"Dialect",
"dialect",
",",
"BaseEncoding",
".",
"Padding",
"padding",
")",
"throws",
"IOException",
"{",
"String",
"standardBase64",
"=",
"DatatypeConverter",
".",
"printBase64Binary",
"(",
"asByteArray",
"(",
"false",
")",
")",
";",
"if",
"(",
"dialect",
"==",
"BaseEncoding",
".",
"Dialect",
".",
"STANDARD",
"&&",
"padding",
"==",
"BaseEncoding",
".",
"Padding",
".",
"STANDARD",
")",
"{",
"return",
"standardBase64",
";",
"}",
"StringBuilder",
"safeBase64",
"=",
"new",
"StringBuilder",
"(",
"standardBase64",
".",
"length",
"(",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"standardBase64",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"char",
"c",
"=",
"standardBase64",
".",
"charAt",
"(",
"i",
")",
";",
"if",
"(",
"dialect",
"==",
"BaseEncoding",
".",
"Dialect",
".",
"SAFE",
")",
"{",
"if",
"(",
"c",
"==",
"'",
"'",
")",
"c",
"=",
"'",
"'",
";",
"else",
"if",
"(",
"c",
"==",
"'",
"'",
")",
"c",
"=",
"'",
"'",
";",
"}",
"if",
"(",
"c",
"==",
"'",
"'",
")",
"{",
"if",
"(",
"padding",
"==",
"BaseEncoding",
".",
"Padding",
".",
"STANDARD",
")",
"{",
"safeBase64",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"else",
"if",
"(",
"padding",
"==",
"BaseEncoding",
".",
"Padding",
".",
"SAFE",
")",
"{",
"safeBase64",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"}",
"else",
"{",
"safeBase64",
".",
"append",
"(",
"c",
")",
";",
"}",
"}",
"return",
"safeBase64",
".",
"toString",
"(",
")",
";",
"}"
] |
Represent as Base 64 with customized dialect and padding
@return Base 64 encoded string
|
[
"Represent",
"as",
"Base",
"64",
"with",
"customized",
"dialect",
"and",
"padding"
] |
547ab53d16e454d53ed5cef1d1ee514ec2d7c726
|
https://github.com/Sproutigy/Java-Commons-Binary/blob/547ab53d16e454d53ed5cef1d1ee514ec2d7c726/src/main/java/com/sproutigy/commons/binary/Binary.java#L340-L367
|
154,796
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/query/QueryCriterionSerializer.java
|
QueryCriterionSerializer.serialize
|
public static String serialize(QueryCriterion queryCriterion){
if(queryCriterion instanceof EqualQueryCriterion){
EqualQueryCriterion criterion = (EqualQueryCriterion) queryCriterion;
return criterion.getMetadataKey() + " equals " + escapeString(criterion.getCriterion());
} else if(queryCriterion instanceof NotEqualQueryCriterion){
NotEqualQueryCriterion criterion = (NotEqualQueryCriterion) queryCriterion;
return criterion.getMetadataKey() + " not equals " + escapeString(criterion.getCriterion());
} else if(queryCriterion instanceof ContainQueryCriterion){
ContainQueryCriterion criterion = (ContainQueryCriterion) queryCriterion;
return criterion.getMetadataKey();
} else if(queryCriterion instanceof NotContainQueryCriterion){
NotContainQueryCriterion criterion = (NotContainQueryCriterion) queryCriterion;
return "not " + criterion.getMetadataKey();
} else if(queryCriterion instanceof InQueryCriterion){
InQueryCriterion criterion = (InQueryCriterion) queryCriterion;
StringBuilder sb = new StringBuilder(criterion.getMetadataKey());
sb.append(" in [ ");
for(String s : criterion.getCriterion()){
sb.append(escapeString(s)).append(", ");
}
sb.append("]");
return sb.toString();
} else if(queryCriterion instanceof NotInQueryCriterion){
NotInQueryCriterion criterion = (NotInQueryCriterion) queryCriterion;
StringBuilder sb = new StringBuilder(criterion.getMetadataKey());
sb.append(" not in [ ");
for(String s : criterion.getCriterion()){
sb.append(escapeString(s)).append(", ");
}
sb.append("]");
return sb.toString();
} else if(queryCriterion instanceof PatternQueryCriterion){
PatternQueryCriterion criterion = (PatternQueryCriterion) queryCriterion;
return criterion.getMetadataKey() + " matches " + escapeString(criterion.getCriterion());
}
return "";
}
|
java
|
public static String serialize(QueryCriterion queryCriterion){
if(queryCriterion instanceof EqualQueryCriterion){
EqualQueryCriterion criterion = (EqualQueryCriterion) queryCriterion;
return criterion.getMetadataKey() + " equals " + escapeString(criterion.getCriterion());
} else if(queryCriterion instanceof NotEqualQueryCriterion){
NotEqualQueryCriterion criterion = (NotEqualQueryCriterion) queryCriterion;
return criterion.getMetadataKey() + " not equals " + escapeString(criterion.getCriterion());
} else if(queryCriterion instanceof ContainQueryCriterion){
ContainQueryCriterion criterion = (ContainQueryCriterion) queryCriterion;
return criterion.getMetadataKey();
} else if(queryCriterion instanceof NotContainQueryCriterion){
NotContainQueryCriterion criterion = (NotContainQueryCriterion) queryCriterion;
return "not " + criterion.getMetadataKey();
} else if(queryCriterion instanceof InQueryCriterion){
InQueryCriterion criterion = (InQueryCriterion) queryCriterion;
StringBuilder sb = new StringBuilder(criterion.getMetadataKey());
sb.append(" in [ ");
for(String s : criterion.getCriterion()){
sb.append(escapeString(s)).append(", ");
}
sb.append("]");
return sb.toString();
} else if(queryCriterion instanceof NotInQueryCriterion){
NotInQueryCriterion criterion = (NotInQueryCriterion) queryCriterion;
StringBuilder sb = new StringBuilder(criterion.getMetadataKey());
sb.append(" not in [ ");
for(String s : criterion.getCriterion()){
sb.append(escapeString(s)).append(", ");
}
sb.append("]");
return sb.toString();
} else if(queryCriterion instanceof PatternQueryCriterion){
PatternQueryCriterion criterion = (PatternQueryCriterion) queryCriterion;
return criterion.getMetadataKey() + " matches " + escapeString(criterion.getCriterion());
}
return "";
}
|
[
"public",
"static",
"String",
"serialize",
"(",
"QueryCriterion",
"queryCriterion",
")",
"{",
"if",
"(",
"queryCriterion",
"instanceof",
"EqualQueryCriterion",
")",
"{",
"EqualQueryCriterion",
"criterion",
"=",
"(",
"EqualQueryCriterion",
")",
"queryCriterion",
";",
"return",
"criterion",
".",
"getMetadataKey",
"(",
")",
"+",
"\" equals \"",
"+",
"escapeString",
"(",
"criterion",
".",
"getCriterion",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"queryCriterion",
"instanceof",
"NotEqualQueryCriterion",
")",
"{",
"NotEqualQueryCriterion",
"criterion",
"=",
"(",
"NotEqualQueryCriterion",
")",
"queryCriterion",
";",
"return",
"criterion",
".",
"getMetadataKey",
"(",
")",
"+",
"\" not equals \"",
"+",
"escapeString",
"(",
"criterion",
".",
"getCriterion",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"queryCriterion",
"instanceof",
"ContainQueryCriterion",
")",
"{",
"ContainQueryCriterion",
"criterion",
"=",
"(",
"ContainQueryCriterion",
")",
"queryCriterion",
";",
"return",
"criterion",
".",
"getMetadataKey",
"(",
")",
";",
"}",
"else",
"if",
"(",
"queryCriterion",
"instanceof",
"NotContainQueryCriterion",
")",
"{",
"NotContainQueryCriterion",
"criterion",
"=",
"(",
"NotContainQueryCriterion",
")",
"queryCriterion",
";",
"return",
"\"not \"",
"+",
"criterion",
".",
"getMetadataKey",
"(",
")",
";",
"}",
"else",
"if",
"(",
"queryCriterion",
"instanceof",
"InQueryCriterion",
")",
"{",
"InQueryCriterion",
"criterion",
"=",
"(",
"InQueryCriterion",
")",
"queryCriterion",
";",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
"criterion",
".",
"getMetadataKey",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\" in [ \"",
")",
";",
"for",
"(",
"String",
"s",
":",
"criterion",
".",
"getCriterion",
"(",
")",
")",
"{",
"sb",
".",
"append",
"(",
"escapeString",
"(",
"s",
")",
")",
".",
"append",
"(",
"\", \"",
")",
";",
"}",
"sb",
".",
"append",
"(",
"\"]\"",
")",
";",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}",
"else",
"if",
"(",
"queryCriterion",
"instanceof",
"NotInQueryCriterion",
")",
"{",
"NotInQueryCriterion",
"criterion",
"=",
"(",
"NotInQueryCriterion",
")",
"queryCriterion",
";",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
"criterion",
".",
"getMetadataKey",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\" not in [ \"",
")",
";",
"for",
"(",
"String",
"s",
":",
"criterion",
".",
"getCriterion",
"(",
")",
")",
"{",
"sb",
".",
"append",
"(",
"escapeString",
"(",
"s",
")",
")",
".",
"append",
"(",
"\", \"",
")",
";",
"}",
"sb",
".",
"append",
"(",
"\"]\"",
")",
";",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}",
"else",
"if",
"(",
"queryCriterion",
"instanceof",
"PatternQueryCriterion",
")",
"{",
"PatternQueryCriterion",
"criterion",
"=",
"(",
"PatternQueryCriterion",
")",
"queryCriterion",
";",
"return",
"criterion",
".",
"getMetadataKey",
"(",
")",
"+",
"\" matches \"",
"+",
"escapeString",
"(",
"criterion",
".",
"getCriterion",
"(",
")",
")",
";",
"}",
"return",
"\"\"",
";",
"}"
] |
serialize the QueryCriterion to a String expression.
This String expression can be deserialized by the deserialze method back.
@param queryCriterion
the QueryCriterion.
@return
the String expression.
|
[
"serialize",
"the",
"QueryCriterion",
"to",
"a",
"String",
"expression",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/query/QueryCriterionSerializer.java#L46-L82
|
154,797
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/query/QueryCriterionSerializer.java
|
QueryCriterionSerializer.deserializeServiceInstanceQuery
|
public static ServiceInstanceQuery deserializeServiceInstanceQuery(String cli){
char [] delimeter = {';'};
ServiceInstanceQuery query = new ServiceInstanceQuery();
for(String statement : splitStringByDelimeters(cli, delimeter, false)){
QueryCriterion criterion = deserialize(statement);
if(criterion != null){
query.addQueryCriterion(criterion);
}
};
return query;
}
|
java
|
public static ServiceInstanceQuery deserializeServiceInstanceQuery(String cli){
char [] delimeter = {';'};
ServiceInstanceQuery query = new ServiceInstanceQuery();
for(String statement : splitStringByDelimeters(cli, delimeter, false)){
QueryCriterion criterion = deserialize(statement);
if(criterion != null){
query.addQueryCriterion(criterion);
}
};
return query;
}
|
[
"public",
"static",
"ServiceInstanceQuery",
"deserializeServiceInstanceQuery",
"(",
"String",
"cli",
")",
"{",
"char",
"[",
"]",
"delimeter",
"=",
"{",
"'",
"'",
"}",
";",
"ServiceInstanceQuery",
"query",
"=",
"new",
"ServiceInstanceQuery",
"(",
")",
";",
"for",
"(",
"String",
"statement",
":",
"splitStringByDelimeters",
"(",
"cli",
",",
"delimeter",
",",
"false",
")",
")",
"{",
"QueryCriterion",
"criterion",
"=",
"deserialize",
"(",
"statement",
")",
";",
"if",
"(",
"criterion",
"!=",
"null",
")",
"{",
"query",
".",
"addQueryCriterion",
"(",
"criterion",
")",
";",
"}",
"}",
";",
"return",
"query",
";",
"}"
] |
Deserialize the ServiceInstanceQuery command line String expression.
Deserialize the ServiceInstanceQuery command line to the ServiceInstanceQuery.
@param cli
the ServiceInstanceQuery command line String expression.
@return
the QueryCriterion statement String list.
|
[
"Deserialize",
"the",
"ServiceInstanceQuery",
"command",
"line",
"String",
"expression",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/query/QueryCriterionSerializer.java#L185-L195
|
154,798
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/query/QueryCriterionSerializer.java
|
QueryCriterionSerializer.serializeServiceInstanceQuery
|
public static String serializeServiceInstanceQuery(ServiceInstanceQuery query){
List<QueryCriterion> criteria = query.getCriteria();
StringBuilder sb = new StringBuilder();
for(QueryCriterion criterion : criteria){
String statement = serialize(criterion);
if(statement != null && ! statement.isEmpty()){
sb.append(statement).append(";");
}
}
return sb.toString();
}
|
java
|
public static String serializeServiceInstanceQuery(ServiceInstanceQuery query){
List<QueryCriterion> criteria = query.getCriteria();
StringBuilder sb = new StringBuilder();
for(QueryCriterion criterion : criteria){
String statement = serialize(criterion);
if(statement != null && ! statement.isEmpty()){
sb.append(statement).append(";");
}
}
return sb.toString();
}
|
[
"public",
"static",
"String",
"serializeServiceInstanceQuery",
"(",
"ServiceInstanceQuery",
"query",
")",
"{",
"List",
"<",
"QueryCriterion",
">",
"criteria",
"=",
"query",
".",
"getCriteria",
"(",
")",
";",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"QueryCriterion",
"criterion",
":",
"criteria",
")",
"{",
"String",
"statement",
"=",
"serialize",
"(",
"criterion",
")",
";",
"if",
"(",
"statement",
"!=",
"null",
"&&",
"!",
"statement",
".",
"isEmpty",
"(",
")",
")",
"{",
"sb",
".",
"append",
"(",
"statement",
")",
".",
"append",
"(",
"\";\"",
")",
";",
"}",
"}",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] |
Serialze the ServiceInstanceQuery to the command line string expression.
@param query
the ServiceInstanceQuery.
@return
the string expression.
|
[
"Serialze",
"the",
"ServiceInstanceQuery",
"to",
"the",
"command",
"line",
"string",
"expression",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/query/QueryCriterionSerializer.java#L205-L215
|
154,799
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/query/QueryCriterionSerializer.java
|
QueryCriterionSerializer.unescapeString
|
private static String unescapeString(String str){
if(str.startsWith("\"") && str.endsWith("\"")){
String s = str.replaceAll("\\\\\"", "\"");
return s.substring(1, s.length() -1);
}
return null;
}
|
java
|
private static String unescapeString(String str){
if(str.startsWith("\"") && str.endsWith("\"")){
String s = str.replaceAll("\\\\\"", "\"");
return s.substring(1, s.length() -1);
}
return null;
}
|
[
"private",
"static",
"String",
"unescapeString",
"(",
"String",
"str",
")",
"{",
"if",
"(",
"str",
".",
"startsWith",
"(",
"\"\\\"\"",
")",
"&&",
"str",
".",
"endsWith",
"(",
"\"\\\"\"",
")",
")",
"{",
"String",
"s",
"=",
"str",
".",
"replaceAll",
"(",
"\"\\\\\\\\\\\"\"",
",",
"\"\\\"\"",
")",
";",
"return",
"s",
".",
"substring",
"(",
"1",
",",
"s",
".",
"length",
"(",
")",
"-",
"1",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Unescape the QueryCriterion String.
remove the head and tail ", switch \" to ".
@param str
the escaped String.
@return
the origin String.
|
[
"Unescape",
"the",
"QueryCriterion",
"String",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/query/QueryCriterionSerializer.java#L241-L247
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.