id
int32 0
165k
| repo
stringlengths 7
58
| path
stringlengths 12
218
| func_name
stringlengths 3
140
| original_string
stringlengths 73
34.1k
| language
stringclasses 1
value | code
stringlengths 73
34.1k
| code_tokens
list | docstring
stringlengths 3
16k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 105
339
|
|---|---|---|---|---|---|---|---|---|---|---|---|
155,100
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/util/Util.java
|
Util.toIterator
|
public static <T> Stream<T> toIterator(@javax.annotation.Nonnull final Iterator<T> iterator) {
return StreamSupport.stream(Spliterators.spliterator(iterator, 1, Spliterator.ORDERED), false);
}
|
java
|
public static <T> Stream<T> toIterator(@javax.annotation.Nonnull final Iterator<T> iterator) {
return StreamSupport.stream(Spliterators.spliterator(iterator, 1, Spliterator.ORDERED), false);
}
|
[
"public",
"static",
"<",
"T",
">",
"Stream",
"<",
"T",
">",
"toIterator",
"(",
"@",
"javax",
".",
"annotation",
".",
"Nonnull",
"final",
"Iterator",
"<",
"T",
">",
"iterator",
")",
"{",
"return",
"StreamSupport",
".",
"stream",
"(",
"Spliterators",
".",
"spliterator",
"(",
"iterator",
",",
"1",
",",
"Spliterator",
".",
"ORDERED",
")",
",",
"false",
")",
";",
"}"
] |
To iterator stream.
@param <T> the type parameter
@param iterator the iterator
@return the stream
|
[
"To",
"iterator",
"stream",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/Util.java#L490-L492
|
155,101
|
oliverdodd/jlorem
|
src/main/java/net/_01001111/text/LoremIpsum.java
|
LoremIpsum.words
|
public String words(int count) {
StringBuilder s = new StringBuilder();
while (count-- > 0)
s.append(randomWord()).append(" ");
return s.toString().trim();
}
|
java
|
public String words(int count) {
StringBuilder s = new StringBuilder();
while (count-- > 0)
s.append(randomWord()).append(" ");
return s.toString().trim();
}
|
[
"public",
"String",
"words",
"(",
"int",
"count",
")",
"{",
"StringBuilder",
"s",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"while",
"(",
"count",
"--",
">",
"0",
")",
"s",
".",
"append",
"(",
"randomWord",
"(",
")",
")",
".",
"append",
"(",
"\" \"",
")",
";",
"return",
"s",
".",
"toString",
"(",
")",
".",
"trim",
"(",
")",
";",
"}"
] |
Get a string of words
@param count
- the number of words to fetch
|
[
"Get",
"a",
"string",
"of",
"words"
] |
135740679bce418322c62125f1c5dad50f5c0204
|
https://github.com/oliverdodd/jlorem/blob/135740679bce418322c62125f1c5dad50f5c0204/src/main/java/net/_01001111/text/LoremIpsum.java#L73-L78
|
155,102
|
PureSolTechnologies/commons
|
osgi/src/main/java/com/puresoltechnologies/commons/osgi/AbstractActivator.java
|
AbstractActivator.deregisterServices
|
private void deregisterServices() {
Iterator<ServiceRegistration<?>> serviceIterator = serviceRegistrations.iterator();
while (serviceIterator.hasNext()) {
ServiceRegistration<?> serviceReference = serviceIterator.next();
serviceReference.unregister();
serviceIterator.remove();
}
}
|
java
|
private void deregisterServices() {
Iterator<ServiceRegistration<?>> serviceIterator = serviceRegistrations.iterator();
while (serviceIterator.hasNext()) {
ServiceRegistration<?> serviceReference = serviceIterator.next();
serviceReference.unregister();
serviceIterator.remove();
}
}
|
[
"private",
"void",
"deregisterServices",
"(",
")",
"{",
"Iterator",
"<",
"ServiceRegistration",
"<",
"?",
">",
">",
"serviceIterator",
"=",
"serviceRegistrations",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"serviceIterator",
".",
"hasNext",
"(",
")",
")",
"{",
"ServiceRegistration",
"<",
"?",
">",
"serviceReference",
"=",
"serviceIterator",
".",
"next",
"(",
")",
";",
"serviceReference",
".",
"unregister",
"(",
")",
";",
"serviceIterator",
".",
"remove",
"(",
")",
";",
"}",
"}"
] |
This method de-registers all former registered services.
|
[
"This",
"method",
"de",
"-",
"registers",
"all",
"former",
"registered",
"services",
"."
] |
f98c23d8841a1ff61632ff17fe7d24f99dbc1d44
|
https://github.com/PureSolTechnologies/commons/blob/f98c23d8841a1ff61632ff17fe7d24f99dbc1d44/osgi/src/main/java/com/puresoltechnologies/commons/osgi/AbstractActivator.java#L74-L81
|
155,103
|
PureSolTechnologies/commons
|
osgi/src/main/java/com/puresoltechnologies/commons/osgi/AbstractActivator.java
|
AbstractActivator.registerService
|
public final <T> ServiceRegistration<?> registerService(Class<T> iface, T instance) {
Hashtable<String, String> properties = new Hashtable<String, String>();
return registerService(iface, instance, properties);
}
|
java
|
public final <T> ServiceRegistration<?> registerService(Class<T> iface, T instance) {
Hashtable<String, String> properties = new Hashtable<String, String>();
return registerService(iface, instance, properties);
}
|
[
"public",
"final",
"<",
"T",
">",
"ServiceRegistration",
"<",
"?",
">",
"registerService",
"(",
"Class",
"<",
"T",
">",
"iface",
",",
"T",
"instance",
")",
"{",
"Hashtable",
"<",
"String",
",",
"String",
">",
"properties",
"=",
"new",
"Hashtable",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"return",
"registerService",
"(",
"iface",
",",
"instance",
",",
"properties",
")",
";",
"}"
] |
This method should be used to register services. Services registered with
this method auto deregistered during bundle stop.
@param iface
is the interface of the service to be used for later retrieval.
@param instance
is an instance of the object to be registered as service for
interface iface.
@param <T>
is the service interface.
@return A {@link ServiceRegistration} is returned of the newly registered
service.
|
[
"This",
"method",
"should",
"be",
"used",
"to",
"register",
"services",
".",
"Services",
"registered",
"with",
"this",
"method",
"auto",
"deregistered",
"during",
"bundle",
"stop",
"."
] |
f98c23d8841a1ff61632ff17fe7d24f99dbc1d44
|
https://github.com/PureSolTechnologies/commons/blob/f98c23d8841a1ff61632ff17fe7d24f99dbc1d44/osgi/src/main/java/com/puresoltechnologies/commons/osgi/AbstractActivator.java#L112-L115
|
155,104
|
PureSolTechnologies/commons
|
osgi/src/main/java/com/puresoltechnologies/commons/osgi/AbstractActivator.java
|
AbstractActivator.registerService
|
public final <T> ServiceRegistration<?> registerService(Class<T> iface, T instance,
Dictionary<String, String> dictionary) {
logger.info(
"Register service '{}' for interface '{}' (context='" + context.getBundle().getSymbolicName() + "').",
instance.getClass().getName(), iface.getName());
ServiceRegistration<?> serviceRegistration = context.registerService(iface, instance, dictionary);
serviceRegistrations.add(serviceRegistration);
return serviceRegistration;
}
|
java
|
public final <T> ServiceRegistration<?> registerService(Class<T> iface, T instance,
Dictionary<String, String> dictionary) {
logger.info(
"Register service '{}' for interface '{}' (context='" + context.getBundle().getSymbolicName() + "').",
instance.getClass().getName(), iface.getName());
ServiceRegistration<?> serviceRegistration = context.registerService(iface, instance, dictionary);
serviceRegistrations.add(serviceRegistration);
return serviceRegistration;
}
|
[
"public",
"final",
"<",
"T",
">",
"ServiceRegistration",
"<",
"?",
">",
"registerService",
"(",
"Class",
"<",
"T",
">",
"iface",
",",
"T",
"instance",
",",
"Dictionary",
"<",
"String",
",",
"String",
">",
"dictionary",
")",
"{",
"logger",
".",
"info",
"(",
"\"Register service '{}' for interface '{}' (context='\"",
"+",
"context",
".",
"getBundle",
"(",
")",
".",
"getSymbolicName",
"(",
")",
"+",
"\"').\"",
",",
"instance",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
",",
"iface",
".",
"getName",
"(",
")",
")",
";",
"ServiceRegistration",
"<",
"?",
">",
"serviceRegistration",
"=",
"context",
".",
"registerService",
"(",
"iface",
",",
"instance",
",",
"dictionary",
")",
";",
"serviceRegistrations",
".",
"add",
"(",
"serviceRegistration",
")",
";",
"return",
"serviceRegistration",
";",
"}"
] |
This method should be used to register services. Services registered with
this method auto de-registered during bundle stop.
@param iface
is the interface of the service to be used for later retrieval.
@param instance
is an instance of the object to be registered as service for
interface iface.
@param dictionary
is a {@link Dictionary} of settings to be added to the service
registration.
@param <T>
is the service interface.
@return A {@link ServiceRegistration} is returned of the newly registered
service.
|
[
"This",
"method",
"should",
"be",
"used",
"to",
"register",
"services",
".",
"Services",
"registered",
"with",
"this",
"method",
"auto",
"de",
"-",
"registered",
"during",
"bundle",
"stop",
"."
] |
f98c23d8841a1ff61632ff17fe7d24f99dbc1d44
|
https://github.com/PureSolTechnologies/commons/blob/f98c23d8841a1ff61632ff17fe7d24f99dbc1d44/osgi/src/main/java/com/puresoltechnologies/commons/osgi/AbstractActivator.java#L134-L142
|
155,105
|
james-hu/jabb-core
|
src/main/java/net/sf/jabb/util/stat/ConcurrentBigIntegerMinMaxHolder.java
|
ConcurrentBigIntegerMinMaxHolder.toBigInteger
|
protected BigInteger toBigInteger(Number number){
if (number == null){
return null;
}
Class<?> claz = number.getClass();
if (claz == BigInteger.class){
return (BigInteger)number;
}else if (claz == BigDecimal.class){
return ((BigDecimal)number).toBigInteger();
}else if (claz == Double.class){
return new BigDecimal((Double)number).toBigInteger();
}else if (claz == Float.class){
return new BigDecimal((Float)number).toBigInteger();
}else{
return BigInteger.valueOf(number.longValue());
}
}
|
java
|
protected BigInteger toBigInteger(Number number){
if (number == null){
return null;
}
Class<?> claz = number.getClass();
if (claz == BigInteger.class){
return (BigInteger)number;
}else if (claz == BigDecimal.class){
return ((BigDecimal)number).toBigInteger();
}else if (claz == Double.class){
return new BigDecimal((Double)number).toBigInteger();
}else if (claz == Float.class){
return new BigDecimal((Float)number).toBigInteger();
}else{
return BigInteger.valueOf(number.longValue());
}
}
|
[
"protected",
"BigInteger",
"toBigInteger",
"(",
"Number",
"number",
")",
"{",
"if",
"(",
"number",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"Class",
"<",
"?",
">",
"claz",
"=",
"number",
".",
"getClass",
"(",
")",
";",
"if",
"(",
"claz",
"==",
"BigInteger",
".",
"class",
")",
"{",
"return",
"(",
"BigInteger",
")",
"number",
";",
"}",
"else",
"if",
"(",
"claz",
"==",
"BigDecimal",
".",
"class",
")",
"{",
"return",
"(",
"(",
"BigDecimal",
")",
"number",
")",
".",
"toBigInteger",
"(",
")",
";",
"}",
"else",
"if",
"(",
"claz",
"==",
"Double",
".",
"class",
")",
"{",
"return",
"new",
"BigDecimal",
"(",
"(",
"Double",
")",
"number",
")",
".",
"toBigInteger",
"(",
")",
";",
"}",
"else",
"if",
"(",
"claz",
"==",
"Float",
".",
"class",
")",
"{",
"return",
"new",
"BigDecimal",
"(",
"(",
"Float",
")",
"number",
")",
".",
"toBigInteger",
"(",
")",
";",
"}",
"else",
"{",
"return",
"BigInteger",
".",
"valueOf",
"(",
"number",
".",
"longValue",
"(",
")",
")",
";",
"}",
"}"
] |
Convert a number to a big integer and try the best to preserve precision
@param number the number
@return the big integer, can be null if the number is null
|
[
"Convert",
"a",
"number",
"to",
"a",
"big",
"integer",
"and",
"try",
"the",
"best",
"to",
"preserve",
"precision"
] |
bceed441595c5e5195a7418795f03b69fa7b61e4
|
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/util/stat/ConcurrentBigIntegerMinMaxHolder.java#L109-L125
|
155,106
|
FitLayout/segmentation
|
src/main/java/org/fit/segm/grouping/op/GroupAnalyzer.java
|
GroupAnalyzer.findSuperArea
|
public AreaImpl findSuperArea(AreaImpl sub, Vector<AreaImpl> selected)
{
/* This is a simple testing SuperArea implementation. It groups each
* subarea with its first sibling area.*/
AreaImpl ret = new AreaImpl(0, 0, 0, 0);
ret.setPage(sub.getPage());
AreaImpl sibl = (AreaImpl) sub.getNextSibling();
selected.removeAllElements();
selected.add(sub);
if (sibl != null)
{
selected.add(sibl);
}
return ret;
}
|
java
|
public AreaImpl findSuperArea(AreaImpl sub, Vector<AreaImpl> selected)
{
/* This is a simple testing SuperArea implementation. It groups each
* subarea with its first sibling area.*/
AreaImpl ret = new AreaImpl(0, 0, 0, 0);
ret.setPage(sub.getPage());
AreaImpl sibl = (AreaImpl) sub.getNextSibling();
selected.removeAllElements();
selected.add(sub);
if (sibl != null)
{
selected.add(sibl);
}
return ret;
}
|
[
"public",
"AreaImpl",
"findSuperArea",
"(",
"AreaImpl",
"sub",
",",
"Vector",
"<",
"AreaImpl",
">",
"selected",
")",
"{",
"/* This is a simple testing SuperArea implementation. It groups each \n \t * subarea with its first sibling area.*/",
"AreaImpl",
"ret",
"=",
"new",
"AreaImpl",
"(",
"0",
",",
"0",
",",
"0",
",",
"0",
")",
";",
"ret",
".",
"setPage",
"(",
"sub",
".",
"getPage",
"(",
")",
")",
";",
"AreaImpl",
"sibl",
"=",
"(",
"AreaImpl",
")",
"sub",
".",
"getNextSibling",
"(",
")",
";",
"selected",
".",
"removeAllElements",
"(",
")",
";",
"selected",
".",
"add",
"(",
"sub",
")",
";",
"if",
"(",
"sibl",
"!=",
"null",
")",
"{",
"selected",
".",
"add",
"(",
"sibl",
")",
";",
"}",
"return",
"ret",
";",
"}"
] |
Starts with a specified subarea and finds all the subareas that
may be joined with the first one. Returns an empty area and the vector
of the areas inside. The subareas are not automatically added to the
new area because this would cause their removal from the parent area.
@param sub the subnode to start with
@param selected a vector that will be filled with the selected subnodes
that should be contained in the new area
@return the new empty area
|
[
"Starts",
"with",
"a",
"specified",
"subarea",
"and",
"finds",
"all",
"the",
"subareas",
"that",
"may",
"be",
"joined",
"with",
"the",
"first",
"one",
".",
"Returns",
"an",
"empty",
"area",
"and",
"the",
"vector",
"of",
"the",
"areas",
"inside",
".",
"The",
"subareas",
"are",
"not",
"automatically",
"added",
"to",
"the",
"new",
"area",
"because",
"this",
"would",
"cause",
"their",
"removal",
"from",
"the",
"parent",
"area",
"."
] |
12998087d576640c2f2a6360cf6088af95eea5f4
|
https://github.com/FitLayout/segmentation/blob/12998087d576640c2f2a6360cf6088af95eea5f4/src/main/java/org/fit/segm/grouping/op/GroupAnalyzer.java#L47-L61
|
155,107
|
iorga-group/iraj
|
iraj/src/main/java/com/iorga/iraj/servlet/CacheAwareServlet.java
|
CacheAwareServlet.doHead
|
@Override
protected void doHead(final HttpServletRequest request, final HttpServletResponse response) throws IOException, ServletException {
// Serve the requested resource, without the data content
serveResource(request, response, false);
}
|
java
|
@Override
protected void doHead(final HttpServletRequest request, final HttpServletResponse response) throws IOException, ServletException {
// Serve the requested resource, without the data content
serveResource(request, response, false);
}
|
[
"@",
"Override",
"protected",
"void",
"doHead",
"(",
"final",
"HttpServletRequest",
"request",
",",
"final",
"HttpServletResponse",
"response",
")",
"throws",
"IOException",
",",
"ServletException",
"{",
"// Serve the requested resource, without the data content",
"serveResource",
"(",
"request",
",",
"response",
",",
"false",
")",
";",
"}"
] |
Process a HEAD request for the specified resource.
@param request
The servlet request we are processing
@param response
The servlet response we are creating
@exception IOException
if an input/output error occurs
@exception ServletException
if a servlet-specified error occurs
|
[
"Process",
"a",
"HEAD",
"request",
"for",
"the",
"specified",
"resource",
"."
] |
5fdee26464248f29833610de402275eb64505542
|
https://github.com/iorga-group/iraj/blob/5fdee26464248f29833610de402275eb64505542/iraj/src/main/java/com/iorga/iraj/servlet/CacheAwareServlet.java#L184-L190
|
155,108
|
iorga-group/iraj
|
iraj/src/main/java/com/iorga/iraj/servlet/CacheAwareServlet.java
|
CacheAwareServlet.checkIfHeaders
|
protected boolean checkIfHeaders(final HttpServletRequest request, final HttpServletResponse response,
final Attributes resourceAttributes) throws IOException {
return checkIfMatch(request, response, resourceAttributes)
&& checkIfModifiedSince(request, response, resourceAttributes)
&& checkIfNoneMatch(request, response, resourceAttributes)
&& checkIfUnmodifiedSince(request, response, resourceAttributes);
}
|
java
|
protected boolean checkIfHeaders(final HttpServletRequest request, final HttpServletResponse response,
final Attributes resourceAttributes) throws IOException {
return checkIfMatch(request, response, resourceAttributes)
&& checkIfModifiedSince(request, response, resourceAttributes)
&& checkIfNoneMatch(request, response, resourceAttributes)
&& checkIfUnmodifiedSince(request, response, resourceAttributes);
}
|
[
"protected",
"boolean",
"checkIfHeaders",
"(",
"final",
"HttpServletRequest",
"request",
",",
"final",
"HttpServletResponse",
"response",
",",
"final",
"Attributes",
"resourceAttributes",
")",
"throws",
"IOException",
"{",
"return",
"checkIfMatch",
"(",
"request",
",",
"response",
",",
"resourceAttributes",
")",
"&&",
"checkIfModifiedSince",
"(",
"request",
",",
"response",
",",
"resourceAttributes",
")",
"&&",
"checkIfNoneMatch",
"(",
"request",
",",
"response",
",",
"resourceAttributes",
")",
"&&",
"checkIfUnmodifiedSince",
"(",
"request",
",",
"response",
",",
"resourceAttributes",
")",
";",
"}"
] |
Check if the conditions specified in the optional If headers are
satisfied.
@param request
The servlet request we are processing
@param response
The servlet response we are creating
@param resourceAttributes
The resource information
@return boolean true if the resource meets all the specified conditions,
and false if any of the conditions is not satisfied, in which
case request processing is stopped
|
[
"Check",
"if",
"the",
"conditions",
"specified",
"in",
"the",
"optional",
"If",
"headers",
"are",
"satisfied",
"."
] |
5fdee26464248f29833610de402275eb64505542
|
https://github.com/iorga-group/iraj/blob/5fdee26464248f29833610de402275eb64505542/iraj/src/main/java/com/iorga/iraj/servlet/CacheAwareServlet.java#L636-L643
|
155,109
|
iorga-group/iraj
|
iraj/src/main/java/com/iorga/iraj/servlet/CacheAwareServlet.java
|
CacheAwareServlet.checkIfMatch
|
protected boolean checkIfMatch(final HttpServletRequest request, final HttpServletResponse response, final Attributes resourceAttributes)
throws IOException {
final String eTag = resourceAttributes.getETag();
final String headerValue = request.getHeader("If-Match");
if (headerValue != null) {
if (headerValue.indexOf('*') == -1) {
final StringTokenizer commaTokenizer = new StringTokenizer(headerValue, ",");
boolean conditionSatisfied = false;
while (!conditionSatisfied && commaTokenizer.hasMoreTokens()) {
final String currentToken = commaTokenizer.nextToken();
if (currentToken.trim().equals(eTag))
conditionSatisfied = true;
}
// If none of the given ETags match, 412 Precodition failed is
// sent back
if (!conditionSatisfied) {
response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED);
return false;
}
}
}
return true;
}
|
java
|
protected boolean checkIfMatch(final HttpServletRequest request, final HttpServletResponse response, final Attributes resourceAttributes)
throws IOException {
final String eTag = resourceAttributes.getETag();
final String headerValue = request.getHeader("If-Match");
if (headerValue != null) {
if (headerValue.indexOf('*') == -1) {
final StringTokenizer commaTokenizer = new StringTokenizer(headerValue, ",");
boolean conditionSatisfied = false;
while (!conditionSatisfied && commaTokenizer.hasMoreTokens()) {
final String currentToken = commaTokenizer.nextToken();
if (currentToken.trim().equals(eTag))
conditionSatisfied = true;
}
// If none of the given ETags match, 412 Precodition failed is
// sent back
if (!conditionSatisfied) {
response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED);
return false;
}
}
}
return true;
}
|
[
"protected",
"boolean",
"checkIfMatch",
"(",
"final",
"HttpServletRequest",
"request",
",",
"final",
"HttpServletResponse",
"response",
",",
"final",
"Attributes",
"resourceAttributes",
")",
"throws",
"IOException",
"{",
"final",
"String",
"eTag",
"=",
"resourceAttributes",
".",
"getETag",
"(",
")",
";",
"final",
"String",
"headerValue",
"=",
"request",
".",
"getHeader",
"(",
"\"If-Match\"",
")",
";",
"if",
"(",
"headerValue",
"!=",
"null",
")",
"{",
"if",
"(",
"headerValue",
".",
"indexOf",
"(",
"'",
"'",
")",
"==",
"-",
"1",
")",
"{",
"final",
"StringTokenizer",
"commaTokenizer",
"=",
"new",
"StringTokenizer",
"(",
"headerValue",
",",
"\",\"",
")",
";",
"boolean",
"conditionSatisfied",
"=",
"false",
";",
"while",
"(",
"!",
"conditionSatisfied",
"&&",
"commaTokenizer",
".",
"hasMoreTokens",
"(",
")",
")",
"{",
"final",
"String",
"currentToken",
"=",
"commaTokenizer",
".",
"nextToken",
"(",
")",
";",
"if",
"(",
"currentToken",
".",
"trim",
"(",
")",
".",
"equals",
"(",
"eTag",
")",
")",
"conditionSatisfied",
"=",
"true",
";",
"}",
"// If none of the given ETags match, 412 Precodition failed is",
"// sent back",
"if",
"(",
"!",
"conditionSatisfied",
")",
"{",
"response",
".",
"sendError",
"(",
"HttpServletResponse",
".",
"SC_PRECONDITION_FAILED",
")",
";",
"return",
"false",
";",
"}",
"}",
"}",
"return",
"true",
";",
"}"
] |
Check if the if-match condition is satisfied.
@param request
The servlet request we are processing
@param response
The servlet response we are creating
@param resourceAttributes
File object
@return boolean true if the resource meets the specified condition, and
false if the condition is not satisfied, in which case request
processing is stopped
|
[
"Check",
"if",
"the",
"if",
"-",
"match",
"condition",
"is",
"satisfied",
"."
] |
5fdee26464248f29833610de402275eb64505542
|
https://github.com/iorga-group/iraj/blob/5fdee26464248f29833610de402275eb64505542/iraj/src/main/java/com/iorga/iraj/servlet/CacheAwareServlet.java#L658-L685
|
155,110
|
iorga-group/iraj
|
iraj/src/main/java/com/iorga/iraj/servlet/CacheAwareServlet.java
|
CacheAwareServlet.checkIfModifiedSince
|
protected boolean checkIfModifiedSince(final HttpServletRequest request, final HttpServletResponse response, final Attributes resourceAttributes) {
try {
final long headerValue = request.getDateHeader("If-Modified-Since");
final long lastModified = resourceAttributes.getLastModified();
if (headerValue != -1) {
// If an If-None-Match header has been specified, if modified
// since
// is ignored.
if ((request.getHeader("If-None-Match") == null) && (lastModified < headerValue + 1000)) {
// The entity has not been modified since the date
// specified by the client. This is not an error case.
response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
response.setHeader("ETag", resourceAttributes.getETag());
return false;
}
}
} catch (final IllegalArgumentException illegalArgument) {
return true;
}
return true;
}
|
java
|
protected boolean checkIfModifiedSince(final HttpServletRequest request, final HttpServletResponse response, final Attributes resourceAttributes) {
try {
final long headerValue = request.getDateHeader("If-Modified-Since");
final long lastModified = resourceAttributes.getLastModified();
if (headerValue != -1) {
// If an If-None-Match header has been specified, if modified
// since
// is ignored.
if ((request.getHeader("If-None-Match") == null) && (lastModified < headerValue + 1000)) {
// The entity has not been modified since the date
// specified by the client. This is not an error case.
response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
response.setHeader("ETag", resourceAttributes.getETag());
return false;
}
}
} catch (final IllegalArgumentException illegalArgument) {
return true;
}
return true;
}
|
[
"protected",
"boolean",
"checkIfModifiedSince",
"(",
"final",
"HttpServletRequest",
"request",
",",
"final",
"HttpServletResponse",
"response",
",",
"final",
"Attributes",
"resourceAttributes",
")",
"{",
"try",
"{",
"final",
"long",
"headerValue",
"=",
"request",
".",
"getDateHeader",
"(",
"\"If-Modified-Since\"",
")",
";",
"final",
"long",
"lastModified",
"=",
"resourceAttributes",
".",
"getLastModified",
"(",
")",
";",
"if",
"(",
"headerValue",
"!=",
"-",
"1",
")",
"{",
"// If an If-None-Match header has been specified, if modified",
"// since",
"// is ignored.",
"if",
"(",
"(",
"request",
".",
"getHeader",
"(",
"\"If-None-Match\"",
")",
"==",
"null",
")",
"&&",
"(",
"lastModified",
"<",
"headerValue",
"+",
"1000",
")",
")",
"{",
"// The entity has not been modified since the date",
"// specified by the client. This is not an error case.",
"response",
".",
"setStatus",
"(",
"HttpServletResponse",
".",
"SC_NOT_MODIFIED",
")",
";",
"response",
".",
"setHeader",
"(",
"\"ETag\"",
",",
"resourceAttributes",
".",
"getETag",
"(",
")",
")",
";",
"return",
"false",
";",
"}",
"}",
"}",
"catch",
"(",
"final",
"IllegalArgumentException",
"illegalArgument",
")",
"{",
"return",
"true",
";",
"}",
"return",
"true",
";",
"}"
] |
Check if the if-modified-since condition is satisfied.
@param request
The servlet request we are processing
@param response
The servlet response we are creating
@param resourceAttributes
File object
@return boolean true if the resource meets the specified condition, and
false if the condition is not satisfied, in which case request
processing is stopped
|
[
"Check",
"if",
"the",
"if",
"-",
"modified",
"-",
"since",
"condition",
"is",
"satisfied",
"."
] |
5fdee26464248f29833610de402275eb64505542
|
https://github.com/iorga-group/iraj/blob/5fdee26464248f29833610de402275eb64505542/iraj/src/main/java/com/iorga/iraj/servlet/CacheAwareServlet.java#L700-L722
|
155,111
|
iorga-group/iraj
|
iraj/src/main/java/com/iorga/iraj/servlet/CacheAwareServlet.java
|
CacheAwareServlet.checkIfNoneMatch
|
protected boolean checkIfNoneMatch(final HttpServletRequest request, final HttpServletResponse response, final Attributes resourceAttributes)
throws IOException {
final String eTag = resourceAttributes.getETag();
final String headerValue = request.getHeader("If-None-Match");
if (headerValue != null) {
boolean conditionSatisfied = false;
if (!headerValue.equals("*")) {
final StringTokenizer commaTokenizer = new StringTokenizer(headerValue, ",");
while (!conditionSatisfied && commaTokenizer.hasMoreTokens()) {
final String currentToken = commaTokenizer.nextToken();
if (currentToken.trim().equals(eTag))
conditionSatisfied = true;
}
} else {
conditionSatisfied = true;
}
if (conditionSatisfied) {
// For GET and HEAD, we should respond with
// 304 Not Modified.
// For every other method, 412 Precondition Failed is sent
// back.
if (("GET".equals(request.getMethod())) || ("HEAD".equals(request.getMethod()))) {
response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
response.setHeader("ETag", eTag);
return false;
}
response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED);
return false;
}
}
return true;
}
|
java
|
protected boolean checkIfNoneMatch(final HttpServletRequest request, final HttpServletResponse response, final Attributes resourceAttributes)
throws IOException {
final String eTag = resourceAttributes.getETag();
final String headerValue = request.getHeader("If-None-Match");
if (headerValue != null) {
boolean conditionSatisfied = false;
if (!headerValue.equals("*")) {
final StringTokenizer commaTokenizer = new StringTokenizer(headerValue, ",");
while (!conditionSatisfied && commaTokenizer.hasMoreTokens()) {
final String currentToken = commaTokenizer.nextToken();
if (currentToken.trim().equals(eTag))
conditionSatisfied = true;
}
} else {
conditionSatisfied = true;
}
if (conditionSatisfied) {
// For GET and HEAD, we should respond with
// 304 Not Modified.
// For every other method, 412 Precondition Failed is sent
// back.
if (("GET".equals(request.getMethod())) || ("HEAD".equals(request.getMethod()))) {
response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
response.setHeader("ETag", eTag);
return false;
}
response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED);
return false;
}
}
return true;
}
|
[
"protected",
"boolean",
"checkIfNoneMatch",
"(",
"final",
"HttpServletRequest",
"request",
",",
"final",
"HttpServletResponse",
"response",
",",
"final",
"Attributes",
"resourceAttributes",
")",
"throws",
"IOException",
"{",
"final",
"String",
"eTag",
"=",
"resourceAttributes",
".",
"getETag",
"(",
")",
";",
"final",
"String",
"headerValue",
"=",
"request",
".",
"getHeader",
"(",
"\"If-None-Match\"",
")",
";",
"if",
"(",
"headerValue",
"!=",
"null",
")",
"{",
"boolean",
"conditionSatisfied",
"=",
"false",
";",
"if",
"(",
"!",
"headerValue",
".",
"equals",
"(",
"\"*\"",
")",
")",
"{",
"final",
"StringTokenizer",
"commaTokenizer",
"=",
"new",
"StringTokenizer",
"(",
"headerValue",
",",
"\",\"",
")",
";",
"while",
"(",
"!",
"conditionSatisfied",
"&&",
"commaTokenizer",
".",
"hasMoreTokens",
"(",
")",
")",
"{",
"final",
"String",
"currentToken",
"=",
"commaTokenizer",
".",
"nextToken",
"(",
")",
";",
"if",
"(",
"currentToken",
".",
"trim",
"(",
")",
".",
"equals",
"(",
"eTag",
")",
")",
"conditionSatisfied",
"=",
"true",
";",
"}",
"}",
"else",
"{",
"conditionSatisfied",
"=",
"true",
";",
"}",
"if",
"(",
"conditionSatisfied",
")",
"{",
"// For GET and HEAD, we should respond with",
"// 304 Not Modified.",
"// For every other method, 412 Precondition Failed is sent",
"// back.",
"if",
"(",
"(",
"\"GET\"",
".",
"equals",
"(",
"request",
".",
"getMethod",
"(",
")",
")",
")",
"||",
"(",
"\"HEAD\"",
".",
"equals",
"(",
"request",
".",
"getMethod",
"(",
")",
")",
")",
")",
"{",
"response",
".",
"setStatus",
"(",
"HttpServletResponse",
".",
"SC_NOT_MODIFIED",
")",
";",
"response",
".",
"setHeader",
"(",
"\"ETag\"",
",",
"eTag",
")",
";",
"return",
"false",
";",
"}",
"response",
".",
"sendError",
"(",
"HttpServletResponse",
".",
"SC_PRECONDITION_FAILED",
")",
";",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Check if the if-none-match condition is satisfied.
@param request
The servlet request we are processing
@param response
The servlet response we are creating
@param resourceAttributes
File object
@return boolean true if the resource meets the specified condition, and
false if the condition is not satisfied, in which case request
processing is stopped
|
[
"Check",
"if",
"the",
"if",
"-",
"none",
"-",
"match",
"condition",
"is",
"satisfied",
"."
] |
5fdee26464248f29833610de402275eb64505542
|
https://github.com/iorga-group/iraj/blob/5fdee26464248f29833610de402275eb64505542/iraj/src/main/java/com/iorga/iraj/servlet/CacheAwareServlet.java#L737-L777
|
155,112
|
iorga-group/iraj
|
iraj/src/main/java/com/iorga/iraj/servlet/CacheAwareServlet.java
|
CacheAwareServlet.checkIfUnmodifiedSince
|
protected boolean checkIfUnmodifiedSince(final HttpServletRequest request, final HttpServletResponse response, final Attributes resourceAttributes)
throws IOException {
try {
final long lastModified = resourceAttributes.getLastModified();
final long headerValue = request.getDateHeader("If-Unmodified-Since");
if (headerValue != -1) {
if (lastModified >= (headerValue + 1000)) {
// The entity has not been modified since the date
// specified by the client. This is not an error case.
response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED);
return false;
}
}
} catch (final IllegalArgumentException illegalArgument) {
return true;
}
return true;
}
|
java
|
protected boolean checkIfUnmodifiedSince(final HttpServletRequest request, final HttpServletResponse response, final Attributes resourceAttributes)
throws IOException {
try {
final long lastModified = resourceAttributes.getLastModified();
final long headerValue = request.getDateHeader("If-Unmodified-Since");
if (headerValue != -1) {
if (lastModified >= (headerValue + 1000)) {
// The entity has not been modified since the date
// specified by the client. This is not an error case.
response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED);
return false;
}
}
} catch (final IllegalArgumentException illegalArgument) {
return true;
}
return true;
}
|
[
"protected",
"boolean",
"checkIfUnmodifiedSince",
"(",
"final",
"HttpServletRequest",
"request",
",",
"final",
"HttpServletResponse",
"response",
",",
"final",
"Attributes",
"resourceAttributes",
")",
"throws",
"IOException",
"{",
"try",
"{",
"final",
"long",
"lastModified",
"=",
"resourceAttributes",
".",
"getLastModified",
"(",
")",
";",
"final",
"long",
"headerValue",
"=",
"request",
".",
"getDateHeader",
"(",
"\"If-Unmodified-Since\"",
")",
";",
"if",
"(",
"headerValue",
"!=",
"-",
"1",
")",
"{",
"if",
"(",
"lastModified",
">=",
"(",
"headerValue",
"+",
"1000",
")",
")",
"{",
"// The entity has not been modified since the date",
"// specified by the client. This is not an error case.",
"response",
".",
"sendError",
"(",
"HttpServletResponse",
".",
"SC_PRECONDITION_FAILED",
")",
";",
"return",
"false",
";",
"}",
"}",
"}",
"catch",
"(",
"final",
"IllegalArgumentException",
"illegalArgument",
")",
"{",
"return",
"true",
";",
"}",
"return",
"true",
";",
"}"
] |
Check if the if-unmodified-since condition is satisfied.
@param request
The servlet request we are processing
@param response
The servlet response we are creating
@param resourceAttributes
File object
@return boolean true if the resource meets the specified condition, and
false if the condition is not satisfied, in which case request
processing is stopped
|
[
"Check",
"if",
"the",
"if",
"-",
"unmodified",
"-",
"since",
"condition",
"is",
"satisfied",
"."
] |
5fdee26464248f29833610de402275eb64505542
|
https://github.com/iorga-group/iraj/blob/5fdee26464248f29833610de402275eb64505542/iraj/src/main/java/com/iorga/iraj/servlet/CacheAwareServlet.java#L792-L809
|
155,113
|
morimekta/utils
|
console-util/src/main/java/net/morimekta/console/terminal/ProgressManager.java
|
ProgressManager.close
|
@Override
public void close() {
synchronized (startedTasks) {
if (executor.isShutdown()) {
return;
}
// ... stop updater thread. Do not interrupt.
executor.shutdown();
try {
updater.get();
} catch (InterruptedException | CancellationException | ExecutionException ignore) {
// Ignore these closing thread errors.
}
// And stop all the tasks, do interrupting.
for (InternalTask task : startedTasks) {
task.cancel(true);
}
for (InternalTask task : queuedTasks) {
task.close();
}
try {
executor.awaitTermination(100L, TimeUnit.MILLISECONDS);
} catch (InterruptedException ignore) {
Thread.currentThread().interrupt();
}
}
}
|
java
|
@Override
public void close() {
synchronized (startedTasks) {
if (executor.isShutdown()) {
return;
}
// ... stop updater thread. Do not interrupt.
executor.shutdown();
try {
updater.get();
} catch (InterruptedException | CancellationException | ExecutionException ignore) {
// Ignore these closing thread errors.
}
// And stop all the tasks, do interrupting.
for (InternalTask task : startedTasks) {
task.cancel(true);
}
for (InternalTask task : queuedTasks) {
task.close();
}
try {
executor.awaitTermination(100L, TimeUnit.MILLISECONDS);
} catch (InterruptedException ignore) {
Thread.currentThread().interrupt();
}
}
}
|
[
"@",
"Override",
"public",
"void",
"close",
"(",
")",
"{",
"synchronized",
"(",
"startedTasks",
")",
"{",
"if",
"(",
"executor",
".",
"isShutdown",
"(",
")",
")",
"{",
"return",
";",
"}",
"// ... stop updater thread. Do not interrupt.",
"executor",
".",
"shutdown",
"(",
")",
";",
"try",
"{",
"updater",
".",
"get",
"(",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"|",
"CancellationException",
"|",
"ExecutionException",
"ignore",
")",
"{",
"// Ignore these closing thread errors.",
"}",
"// And stop all the tasks, do interrupting.",
"for",
"(",
"InternalTask",
"task",
":",
"startedTasks",
")",
"{",
"task",
".",
"cancel",
"(",
"true",
")",
";",
"}",
"for",
"(",
"InternalTask",
"task",
":",
"queuedTasks",
")",
"{",
"task",
".",
"close",
"(",
")",
";",
"}",
"try",
"{",
"executor",
".",
"awaitTermination",
"(",
"100L",
",",
"TimeUnit",
".",
"MILLISECONDS",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"ignore",
")",
"{",
"Thread",
".",
"currentThread",
"(",
")",
".",
"interrupt",
"(",
")",
";",
"}",
"}",
"}"
] |
Close the progress and all tasks associated with it.
|
[
"Close",
"the",
"progress",
"and",
"all",
"tasks",
"associated",
"with",
"it",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/console-util/src/main/java/net/morimekta/console/terminal/ProgressManager.java#L140-L167
|
155,114
|
morimekta/utils
|
console-util/src/main/java/net/morimekta/console/terminal/ProgressManager.java
|
ProgressManager.waitAbortable
|
public void waitAbortable() throws IOException, InterruptedException {
try {
isWaiting.set(true);
terminal.waitAbortable(updater);
} finally {
close();
updateLines();
terminal.finish();
}
}
|
java
|
public void waitAbortable() throws IOException, InterruptedException {
try {
isWaiting.set(true);
terminal.waitAbortable(updater);
} finally {
close();
updateLines();
terminal.finish();
}
}
|
[
"public",
"void",
"waitAbortable",
"(",
")",
"throws",
"IOException",
",",
"InterruptedException",
"{",
"try",
"{",
"isWaiting",
".",
"set",
"(",
"true",
")",
";",
"terminal",
".",
"waitAbortable",
"(",
"updater",
")",
";",
"}",
"finally",
"{",
"close",
"(",
")",
";",
"updateLines",
"(",
")",
";",
"terminal",
".",
"finish",
"(",
")",
";",
"}",
"}"
] |
Wait for all scheduled tasks to finish allowing the user to abort all
tasks with <ctrl>-C.
@throws IOException If interrupted by user.
@throws InterruptedException If interrupted by system or other threads.
|
[
"Wait",
"for",
"all",
"scheduled",
"tasks",
"to",
"finish",
"allowing",
"the",
"user",
"to",
"abort",
"all",
"tasks",
"with",
"<",
";",
"ctrl>",
";",
"-",
"C",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/console-util/src/main/java/net/morimekta/console/terminal/ProgressManager.java#L176-L185
|
155,115
|
PureSolTechnologies/parsers
|
parsers/src/main/java/com/puresoltechnologies/parsers/parser/ParseTreeNode.java
|
ParseTreeNode.getChild
|
public ParseTreeNode getChild(String name) throws TreeException {
ParseTreeNode result = null;
for (ParseTreeNode child : children) {
if (child.getName().equals(name)) {
if (result != null) {
throw new TreeException("Child '" + name + "'is multiply defined!");
}
result = child;
}
}
return result;
}
|
java
|
public ParseTreeNode getChild(String name) throws TreeException {
ParseTreeNode result = null;
for (ParseTreeNode child : children) {
if (child.getName().equals(name)) {
if (result != null) {
throw new TreeException("Child '" + name + "'is multiply defined!");
}
result = child;
}
}
return result;
}
|
[
"public",
"ParseTreeNode",
"getChild",
"(",
"String",
"name",
")",
"throws",
"TreeException",
"{",
"ParseTreeNode",
"result",
"=",
"null",
";",
"for",
"(",
"ParseTreeNode",
"child",
":",
"children",
")",
"{",
"if",
"(",
"child",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"name",
")",
")",
"{",
"if",
"(",
"result",
"!=",
"null",
")",
"{",
"throw",
"new",
"TreeException",
"(",
"\"Child '\"",
"+",
"name",
"+",
"\"'is multiply defined!\"",
")",
";",
"}",
"result",
"=",
"child",
";",
"}",
"}",
"return",
"result",
";",
"}"
] |
This method returns the child with the given name from this node.
It is used to extract exactly one child from this node. To get more children,
use {@link #getChildren()} for that purpose.
@param name
is the name of the child.
@return The child is returned if found. Otherwise null is returned.
@throws TreeException
is thrown if there is more than one child with the given name.
|
[
"This",
"method",
"returns",
"the",
"child",
"with",
"the",
"given",
"name",
"from",
"this",
"node",
"."
] |
61077223b90d3768ff9445ae13036343c98b63cd
|
https://github.com/PureSolTechnologies/parsers/blob/61077223b90d3768ff9445ae13036343c98b63cd/parsers/src/main/java/com/puresoltechnologies/parsers/parser/ParseTreeNode.java#L193-L204
|
155,116
|
PureSolTechnologies/parsers
|
parsers/src/main/java/com/puresoltechnologies/parsers/parser/ParseTreeNode.java
|
ParseTreeNode.hasChild
|
public boolean hasChild(String name) {
for (ParseTreeNode child : children) {
if (child.getName().equals(name)) {
return true;
}
}
return false;
}
|
java
|
public boolean hasChild(String name) {
for (ParseTreeNode child : children) {
if (child.getName().equals(name)) {
return true;
}
}
return false;
}
|
[
"public",
"boolean",
"hasChild",
"(",
"String",
"name",
")",
"{",
"for",
"(",
"ParseTreeNode",
"child",
":",
"children",
")",
"{",
"if",
"(",
"child",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"name",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
This method look for a child with a given name.
@param name
is the name to look for.
@return true is returned in case a child with the specified name exists.
|
[
"This",
"method",
"look",
"for",
"a",
"child",
"with",
"a",
"given",
"name",
"."
] |
61077223b90d3768ff9445ae13036343c98b63cd
|
https://github.com/PureSolTechnologies/parsers/blob/61077223b90d3768ff9445ae13036343c98b63cd/parsers/src/main/java/com/puresoltechnologies/parsers/parser/ParseTreeNode.java#L230-L237
|
155,117
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/text/CharTrie.java
|
CharTrie.reducer
|
public static BiFunction<CharTrie, CharTrie, CharTrie> reducer(BiFunction<TrieNode, TrieNode, TreeMap<Character, Long>> fn) {
return (left, right) -> left.reduce(right, fn);
}
|
java
|
public static BiFunction<CharTrie, CharTrie, CharTrie> reducer(BiFunction<TrieNode, TrieNode, TreeMap<Character, Long>> fn) {
return (left, right) -> left.reduce(right, fn);
}
|
[
"public",
"static",
"BiFunction",
"<",
"CharTrie",
",",
"CharTrie",
",",
"CharTrie",
">",
"reducer",
"(",
"BiFunction",
"<",
"TrieNode",
",",
"TrieNode",
",",
"TreeMap",
"<",
"Character",
",",
"Long",
">",
">",
"fn",
")",
"{",
"return",
"(",
"left",
",",
"right",
")",
"->",
"left",
".",
"reduce",
"(",
"right",
",",
"fn",
")",
";",
"}"
] |
Reducer bi function.
@param fn the fn
@return the bi function
|
[
"Reducer",
"bi",
"function",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/text/CharTrie.java#L87-L89
|
155,118
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/text/CharTrie.java
|
CharTrie.ensureParentIndexCapacity
|
synchronized void ensureParentIndexCapacity(int start, int length, int parentId) {
int end = start + length;
if (null == parentIndex) {
parentIndex = new int[end];
Arrays.fill(parentIndex, parentId);
}
else {
int newLength = parentIndex.length;
while (newLength < end) newLength *= 2;
if (newLength > parentIndex.length) {
parentIndex = Arrays.copyOfRange(parentIndex, 0, newLength);
Arrays.fill(parentIndex, end, newLength, -1);
}
Arrays.fill(parentIndex, start, end, parentId);
}
if (null == godparentIndex) {
godparentIndex = new int[end];
Arrays.fill(godparentIndex, -1);
}
else {
int newLength = godparentIndex.length;
while (newLength < end) newLength *= 2;
if (newLength > godparentIndex.length) {
int prevLength = godparentIndex.length;
godparentIndex = Arrays.copyOfRange(godparentIndex, 0, newLength);
Arrays.fill(godparentIndex, prevLength, newLength, -1);
}
}
}
|
java
|
synchronized void ensureParentIndexCapacity(int start, int length, int parentId) {
int end = start + length;
if (null == parentIndex) {
parentIndex = new int[end];
Arrays.fill(parentIndex, parentId);
}
else {
int newLength = parentIndex.length;
while (newLength < end) newLength *= 2;
if (newLength > parentIndex.length) {
parentIndex = Arrays.copyOfRange(parentIndex, 0, newLength);
Arrays.fill(parentIndex, end, newLength, -1);
}
Arrays.fill(parentIndex, start, end, parentId);
}
if (null == godparentIndex) {
godparentIndex = new int[end];
Arrays.fill(godparentIndex, -1);
}
else {
int newLength = godparentIndex.length;
while (newLength < end) newLength *= 2;
if (newLength > godparentIndex.length) {
int prevLength = godparentIndex.length;
godparentIndex = Arrays.copyOfRange(godparentIndex, 0, newLength);
Arrays.fill(godparentIndex, prevLength, newLength, -1);
}
}
}
|
[
"synchronized",
"void",
"ensureParentIndexCapacity",
"(",
"int",
"start",
",",
"int",
"length",
",",
"int",
"parentId",
")",
"{",
"int",
"end",
"=",
"start",
"+",
"length",
";",
"if",
"(",
"null",
"==",
"parentIndex",
")",
"{",
"parentIndex",
"=",
"new",
"int",
"[",
"end",
"]",
";",
"Arrays",
".",
"fill",
"(",
"parentIndex",
",",
"parentId",
")",
";",
"}",
"else",
"{",
"int",
"newLength",
"=",
"parentIndex",
".",
"length",
";",
"while",
"(",
"newLength",
"<",
"end",
")",
"newLength",
"*=",
"2",
";",
"if",
"(",
"newLength",
">",
"parentIndex",
".",
"length",
")",
"{",
"parentIndex",
"=",
"Arrays",
".",
"copyOfRange",
"(",
"parentIndex",
",",
"0",
",",
"newLength",
")",
";",
"Arrays",
".",
"fill",
"(",
"parentIndex",
",",
"end",
",",
"newLength",
",",
"-",
"1",
")",
";",
"}",
"Arrays",
".",
"fill",
"(",
"parentIndex",
",",
"start",
",",
"end",
",",
"parentId",
")",
";",
"}",
"if",
"(",
"null",
"==",
"godparentIndex",
")",
"{",
"godparentIndex",
"=",
"new",
"int",
"[",
"end",
"]",
";",
"Arrays",
".",
"fill",
"(",
"godparentIndex",
",",
"-",
"1",
")",
";",
"}",
"else",
"{",
"int",
"newLength",
"=",
"godparentIndex",
".",
"length",
";",
"while",
"(",
"newLength",
"<",
"end",
")",
"newLength",
"*=",
"2",
";",
"if",
"(",
"newLength",
">",
"godparentIndex",
".",
"length",
")",
"{",
"int",
"prevLength",
"=",
"godparentIndex",
".",
"length",
";",
"godparentIndex",
"=",
"Arrays",
".",
"copyOfRange",
"(",
"godparentIndex",
",",
"0",
",",
"newLength",
")",
";",
"Arrays",
".",
"fill",
"(",
"godparentIndex",
",",
"prevLength",
",",
"newLength",
",",
"-",
"1",
")",
";",
"}",
"}",
"}"
] |
Ensure parent index capacity.
@param start the start
@param length the length
@param parentId the parent id
|
[
"Ensure",
"parent",
"index",
"capacity",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/text/CharTrie.java#L118-L146
|
155,119
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/text/CharTrie.java
|
CharTrie.reverse
|
public CharTrie reverse() {
CharTrie result = new CharTrieIndex();
TreeMap<Character, ? extends TrieNode> childrenMap = root().getChildrenMap();
reverseSubtree(childrenMap, result.root());
return result.recomputeCursorDetails();
}
|
java
|
public CharTrie reverse() {
CharTrie result = new CharTrieIndex();
TreeMap<Character, ? extends TrieNode> childrenMap = root().getChildrenMap();
reverseSubtree(childrenMap, result.root());
return result.recomputeCursorDetails();
}
|
[
"public",
"CharTrie",
"reverse",
"(",
")",
"{",
"CharTrie",
"result",
"=",
"new",
"CharTrieIndex",
"(",
")",
";",
"TreeMap",
"<",
"Character",
",",
"?",
"extends",
"TrieNode",
">",
"childrenMap",
"=",
"root",
"(",
")",
".",
"getChildrenMap",
"(",
")",
";",
"reverseSubtree",
"(",
"childrenMap",
",",
"result",
".",
"root",
"(",
")",
")",
";",
"return",
"result",
".",
"recomputeCursorDetails",
"(",
")",
";",
"}"
] |
Reverse char trie.
@return the char trie
|
[
"Reverse",
"char",
"trie",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/text/CharTrie.java#L153-L158
|
155,120
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/text/CharTrie.java
|
CharTrie.rewrite
|
public CharTrie rewrite(BiFunction<TrieNode, Map<Character, TrieNode>, TreeMap<Character, Long>> fn) {
CharTrie result = new CharTrieIndex();
rewriteSubtree(root(), result.root(), fn);
return result.recomputeCursorDetails();
}
|
java
|
public CharTrie rewrite(BiFunction<TrieNode, Map<Character, TrieNode>, TreeMap<Character, Long>> fn) {
CharTrie result = new CharTrieIndex();
rewriteSubtree(root(), result.root(), fn);
return result.recomputeCursorDetails();
}
|
[
"public",
"CharTrie",
"rewrite",
"(",
"BiFunction",
"<",
"TrieNode",
",",
"Map",
"<",
"Character",
",",
"TrieNode",
">",
",",
"TreeMap",
"<",
"Character",
",",
"Long",
">",
">",
"fn",
")",
"{",
"CharTrie",
"result",
"=",
"new",
"CharTrieIndex",
"(",
")",
";",
"rewriteSubtree",
"(",
"root",
"(",
")",
",",
"result",
".",
"root",
"(",
")",
",",
"fn",
")",
";",
"return",
"result",
".",
"recomputeCursorDetails",
"(",
")",
";",
"}"
] |
Rewrite char trie.
@param fn the fn
@return the char trie
|
[
"Rewrite",
"char",
"trie",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/text/CharTrie.java#L180-L184
|
155,121
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/text/CharTrie.java
|
CharTrie.add
|
public CharTrie add(CharTrie z) {
return reduceSimple(z, (left, right) -> (null == left ? 0 : left) + (null == right ? 0 : right));
}
|
java
|
public CharTrie add(CharTrie z) {
return reduceSimple(z, (left, right) -> (null == left ? 0 : left) + (null == right ? 0 : right));
}
|
[
"public",
"CharTrie",
"add",
"(",
"CharTrie",
"z",
")",
"{",
"return",
"reduceSimple",
"(",
"z",
",",
"(",
"left",
",",
"right",
")",
"->",
"(",
"null",
"==",
"left",
"?",
"0",
":",
"left",
")",
"+",
"(",
"null",
"==",
"right",
"?",
"0",
":",
"right",
")",
")",
";",
"}"
] |
Add char trie.
@param z the z
@return the char trie
|
[
"Add",
"char",
"trie",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/text/CharTrie.java#L205-L207
|
155,122
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/text/CharTrie.java
|
CharTrie.product
|
public CharTrie product(CharTrie z) {
return reduceSimple(z, (left, right) -> (null == left ? 0 : left) * (null == right ? 0 : right));
}
|
java
|
public CharTrie product(CharTrie z) {
return reduceSimple(z, (left, right) -> (null == left ? 0 : left) * (null == right ? 0 : right));
}
|
[
"public",
"CharTrie",
"product",
"(",
"CharTrie",
"z",
")",
"{",
"return",
"reduceSimple",
"(",
"z",
",",
"(",
"left",
",",
"right",
")",
"->",
"(",
"null",
"==",
"left",
"?",
"0",
":",
"left",
")",
"*",
"(",
"null",
"==",
"right",
"?",
"0",
":",
"right",
")",
")",
";",
"}"
] |
Product char trie.
@param z the z
@return the char trie
|
[
"Product",
"char",
"trie",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/text/CharTrie.java#L215-L217
|
155,123
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/text/CharTrie.java
|
CharTrie.divide
|
public CharTrie divide(CharTrie z, int factor) {
return reduceSimple(z, (left, right) -> (null == right ? 0 : ((null == left ? 0 : left) * factor / right)));
}
|
java
|
public CharTrie divide(CharTrie z, int factor) {
return reduceSimple(z, (left, right) -> (null == right ? 0 : ((null == left ? 0 : left) * factor / right)));
}
|
[
"public",
"CharTrie",
"divide",
"(",
"CharTrie",
"z",
",",
"int",
"factor",
")",
"{",
"return",
"reduceSimple",
"(",
"z",
",",
"(",
"left",
",",
"right",
")",
"->",
"(",
"null",
"==",
"right",
"?",
"0",
":",
"(",
"(",
"null",
"==",
"left",
"?",
"0",
":",
"left",
")",
"*",
"factor",
"/",
"right",
")",
")",
")",
";",
"}"
] |
Divide char trie.
@param z the z
@param factor the factor
@return the char trie
|
[
"Divide",
"char",
"trie",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/text/CharTrie.java#L226-L228
|
155,124
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/text/CharTrie.java
|
CharTrie.reduceSimple
|
public CharTrie reduceSimple(CharTrie z, BiFunction<Long, Long, Long> fn) {
return reduce(z, (left, right) -> {
TreeMap<Character, ? extends TrieNode> leftChildren = null == left ? new TreeMap<>() : left.getChildrenMap();
TreeMap<Character, ? extends TrieNode> rightChildren = null == right ? new TreeMap<>() : right.getChildrenMap();
Map<Character, Long> map = Stream.of(rightChildren.keySet(), leftChildren.keySet()).flatMap(x -> x.stream()).distinct().collect(Collectors.toMap(c -> c, (Character c) -> {
assert (null != leftChildren);
assert (null != rightChildren);
assert (null != c);
TrieNode leftChild = leftChildren.get(c);
Long l = null == leftChild ? null : leftChild.getCursorCount();
TrieNode rightChild = rightChildren.get(c);
Long r = null == rightChild ? null : rightChild.getCursorCount();
return fn.apply(l, r);
}));
return new TreeMap<>(map);
});
}
|
java
|
public CharTrie reduceSimple(CharTrie z, BiFunction<Long, Long, Long> fn) {
return reduce(z, (left, right) -> {
TreeMap<Character, ? extends TrieNode> leftChildren = null == left ? new TreeMap<>() : left.getChildrenMap();
TreeMap<Character, ? extends TrieNode> rightChildren = null == right ? new TreeMap<>() : right.getChildrenMap();
Map<Character, Long> map = Stream.of(rightChildren.keySet(), leftChildren.keySet()).flatMap(x -> x.stream()).distinct().collect(Collectors.toMap(c -> c, (Character c) -> {
assert (null != leftChildren);
assert (null != rightChildren);
assert (null != c);
TrieNode leftChild = leftChildren.get(c);
Long l = null == leftChild ? null : leftChild.getCursorCount();
TrieNode rightChild = rightChildren.get(c);
Long r = null == rightChild ? null : rightChild.getCursorCount();
return fn.apply(l, r);
}));
return new TreeMap<>(map);
});
}
|
[
"public",
"CharTrie",
"reduceSimple",
"(",
"CharTrie",
"z",
",",
"BiFunction",
"<",
"Long",
",",
"Long",
",",
"Long",
">",
"fn",
")",
"{",
"return",
"reduce",
"(",
"z",
",",
"(",
"left",
",",
"right",
")",
"->",
"{",
"TreeMap",
"<",
"Character",
",",
"?",
"extends",
"TrieNode",
">",
"leftChildren",
"=",
"null",
"==",
"left",
"?",
"new",
"TreeMap",
"<>",
"(",
")",
":",
"left",
".",
"getChildrenMap",
"(",
")",
";",
"TreeMap",
"<",
"Character",
",",
"?",
"extends",
"TrieNode",
">",
"rightChildren",
"=",
"null",
"==",
"right",
"?",
"new",
"TreeMap",
"<>",
"(",
")",
":",
"right",
".",
"getChildrenMap",
"(",
")",
";",
"Map",
"<",
"Character",
",",
"Long",
">",
"map",
"=",
"Stream",
".",
"of",
"(",
"rightChildren",
".",
"keySet",
"(",
")",
",",
"leftChildren",
".",
"keySet",
"(",
")",
")",
".",
"flatMap",
"(",
"x",
"->",
"x",
".",
"stream",
"(",
")",
")",
".",
"distinct",
"(",
")",
".",
"collect",
"(",
"Collectors",
".",
"toMap",
"(",
"c",
"->",
"c",
",",
"(",
"Character",
"c",
")",
"->",
"{",
"assert",
"(",
"null",
"!=",
"leftChildren",
")",
";",
"assert",
"(",
"null",
"!=",
"rightChildren",
")",
";",
"assert",
"(",
"null",
"!=",
"c",
")",
";",
"TrieNode",
"leftChild",
"=",
"leftChildren",
".",
"get",
"(",
"c",
")",
";",
"Long",
"l",
"=",
"null",
"==",
"leftChild",
"?",
"null",
":",
"leftChild",
".",
"getCursorCount",
"(",
")",
";",
"TrieNode",
"rightChild",
"=",
"rightChildren",
".",
"get",
"(",
"c",
")",
";",
"Long",
"r",
"=",
"null",
"==",
"rightChild",
"?",
"null",
":",
"rightChild",
".",
"getCursorCount",
"(",
")",
";",
"return",
"fn",
".",
"apply",
"(",
"l",
",",
"r",
")",
";",
"}",
")",
")",
";",
"return",
"new",
"TreeMap",
"<>",
"(",
"map",
")",
";",
"}",
")",
";",
"}"
] |
Reduce simple char trie.
@param z the z
@param fn the fn
@return the char trie
|
[
"Reduce",
"simple",
"char",
"trie",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/text/CharTrie.java#L237-L253
|
155,125
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/text/CharTrie.java
|
CharTrie.reduce
|
public CharTrie reduce(CharTrie right, BiFunction<TrieNode, TrieNode, TreeMap<Character, Long>> fn) {
CharTrie result = new CharTrieIndex();
reduceSubtree(root(), right.root(), result.root(), fn);
return result.recomputeCursorDetails();
}
|
java
|
public CharTrie reduce(CharTrie right, BiFunction<TrieNode, TrieNode, TreeMap<Character, Long>> fn) {
CharTrie result = new CharTrieIndex();
reduceSubtree(root(), right.root(), result.root(), fn);
return result.recomputeCursorDetails();
}
|
[
"public",
"CharTrie",
"reduce",
"(",
"CharTrie",
"right",
",",
"BiFunction",
"<",
"TrieNode",
",",
"TrieNode",
",",
"TreeMap",
"<",
"Character",
",",
"Long",
">",
">",
"fn",
")",
"{",
"CharTrie",
"result",
"=",
"new",
"CharTrieIndex",
"(",
")",
";",
"reduceSubtree",
"(",
"root",
"(",
")",
",",
"right",
".",
"root",
"(",
")",
",",
"result",
".",
"root",
"(",
")",
",",
"fn",
")",
";",
"return",
"result",
".",
"recomputeCursorDetails",
"(",
")",
";",
"}"
] |
Reduce char trie.
@param right the right
@param fn the fn
@return the char trie
|
[
"Reduce",
"char",
"trie",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/text/CharTrie.java#L262-L266
|
155,126
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/text/CharTrie.java
|
CharTrie.recomputeCursorDetails
|
CharTrie recomputeCursorDetails() {
godparentIndex = new int[getNodeCount()];
parentIndex = new int[getNodeCount()];
Arrays.fill(godparentIndex, 0, godparentIndex.length, -1);
Arrays.fill(parentIndex, 0, parentIndex.length, -1);
System.gc();
recomputeCursorTotals(root());
System.gc();
recomputeCursorPositions(root(), 0);
System.gc();
return this;
}
|
java
|
CharTrie recomputeCursorDetails() {
godparentIndex = new int[getNodeCount()];
parentIndex = new int[getNodeCount()];
Arrays.fill(godparentIndex, 0, godparentIndex.length, -1);
Arrays.fill(parentIndex, 0, parentIndex.length, -1);
System.gc();
recomputeCursorTotals(root());
System.gc();
recomputeCursorPositions(root(), 0);
System.gc();
return this;
}
|
[
"CharTrie",
"recomputeCursorDetails",
"(",
")",
"{",
"godparentIndex",
"=",
"new",
"int",
"[",
"getNodeCount",
"(",
")",
"]",
";",
"parentIndex",
"=",
"new",
"int",
"[",
"getNodeCount",
"(",
")",
"]",
";",
"Arrays",
".",
"fill",
"(",
"godparentIndex",
",",
"0",
",",
"godparentIndex",
".",
"length",
",",
"-",
"1",
")",
";",
"Arrays",
".",
"fill",
"(",
"parentIndex",
",",
"0",
",",
"parentIndex",
".",
"length",
",",
"-",
"1",
")",
";",
"System",
".",
"gc",
"(",
")",
";",
"recomputeCursorTotals",
"(",
"root",
"(",
")",
")",
";",
"System",
".",
"gc",
"(",
")",
";",
"recomputeCursorPositions",
"(",
"root",
"(",
")",
",",
"0",
")",
";",
"System",
".",
"gc",
"(",
")",
";",
"return",
"this",
";",
"}"
] |
Recompute cursor details char trie.
@return the char trie
|
[
"Recompute",
"cursor",
"details",
"char",
"trie",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/text/CharTrie.java#L273-L284
|
155,127
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/text/CharTrie.java
|
CharTrie.matchEnd
|
public TrieNode matchEnd(String search) {
if (search.isEmpty()) return root();
int min = 0;
int max = search.length();
int i = Math.min(max, 12);
int winner = -1;
while (max > min) {
String attempt = search.substring(search.length() - i);
TrieNode cursor = traverse(attempt);
if (cursor.getString().equals(attempt)) {
min = Math.max(min, i + 1);
winner = Math.max(winner, i);
}
else {
max = Math.min(max, i - 1);
}
i = (3 * max + min) / 4;
}
if (winner < 0) return root();
String matched = search.substring(search.length() - winner);
return traverse(matched);
}
|
java
|
public TrieNode matchEnd(String search) {
if (search.isEmpty()) return root();
int min = 0;
int max = search.length();
int i = Math.min(max, 12);
int winner = -1;
while (max > min) {
String attempt = search.substring(search.length() - i);
TrieNode cursor = traverse(attempt);
if (cursor.getString().equals(attempt)) {
min = Math.max(min, i + 1);
winner = Math.max(winner, i);
}
else {
max = Math.min(max, i - 1);
}
i = (3 * max + min) / 4;
}
if (winner < 0) return root();
String matched = search.substring(search.length() - winner);
return traverse(matched);
}
|
[
"public",
"TrieNode",
"matchEnd",
"(",
"String",
"search",
")",
"{",
"if",
"(",
"search",
".",
"isEmpty",
"(",
")",
")",
"return",
"root",
"(",
")",
";",
"int",
"min",
"=",
"0",
";",
"int",
"max",
"=",
"search",
".",
"length",
"(",
")",
";",
"int",
"i",
"=",
"Math",
".",
"min",
"(",
"max",
",",
"12",
")",
";",
"int",
"winner",
"=",
"-",
"1",
";",
"while",
"(",
"max",
">",
"min",
")",
"{",
"String",
"attempt",
"=",
"search",
".",
"substring",
"(",
"search",
".",
"length",
"(",
")",
"-",
"i",
")",
";",
"TrieNode",
"cursor",
"=",
"traverse",
"(",
"attempt",
")",
";",
"if",
"(",
"cursor",
".",
"getString",
"(",
")",
".",
"equals",
"(",
"attempt",
")",
")",
"{",
"min",
"=",
"Math",
".",
"max",
"(",
"min",
",",
"i",
"+",
"1",
")",
";",
"winner",
"=",
"Math",
".",
"max",
"(",
"winner",
",",
"i",
")",
";",
"}",
"else",
"{",
"max",
"=",
"Math",
".",
"min",
"(",
"max",
",",
"i",
"-",
"1",
")",
";",
"}",
"i",
"=",
"(",
"3",
"*",
"max",
"+",
"min",
")",
"/",
"4",
";",
"}",
"if",
"(",
"winner",
"<",
"0",
")",
"return",
"root",
"(",
")",
";",
"String",
"matched",
"=",
"search",
".",
"substring",
"(",
"search",
".",
"length",
"(",
")",
"-",
"winner",
")",
";",
"return",
"traverse",
"(",
"matched",
")",
";",
"}"
] |
Match end trie node.
@param search the search
@return the trie node
|
[
"Match",
"end",
"trie",
"node",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/text/CharTrie.java#L349-L370
|
155,128
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/text/CharTrie.java
|
CharTrie.matchPredictor
|
public TrieNode matchPredictor(String search) {
TrieNode cursor = matchEnd(search);
if (cursor.getNumberOfChildren() > 0) {
return cursor;
}
String string = cursor.getString();
if (string.isEmpty()) return null;
return matchPredictor(string.substring(1));
}
|
java
|
public TrieNode matchPredictor(String search) {
TrieNode cursor = matchEnd(search);
if (cursor.getNumberOfChildren() > 0) {
return cursor;
}
String string = cursor.getString();
if (string.isEmpty()) return null;
return matchPredictor(string.substring(1));
}
|
[
"public",
"TrieNode",
"matchPredictor",
"(",
"String",
"search",
")",
"{",
"TrieNode",
"cursor",
"=",
"matchEnd",
"(",
"search",
")",
";",
"if",
"(",
"cursor",
".",
"getNumberOfChildren",
"(",
")",
">",
"0",
")",
"{",
"return",
"cursor",
";",
"}",
"String",
"string",
"=",
"cursor",
".",
"getString",
"(",
")",
";",
"if",
"(",
"string",
".",
"isEmpty",
"(",
")",
")",
"return",
"null",
";",
"return",
"matchPredictor",
"(",
"string",
".",
"substring",
"(",
"1",
")",
")",
";",
"}"
] |
Match predictor trie node.
@param search the search
@return the trie node
|
[
"Match",
"predictor",
"trie",
"node",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/text/CharTrie.java#L378-L386
|
155,129
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/text/CharTrie.java
|
CharTrie.tokens
|
public Set<Character> tokens() {
return root().getChildrenMap().keySet().stream()
.filter(c -> c != END_OF_STRING && c != FALLBACK && c != ESCAPE)
.collect(Collectors.toSet());
}
|
java
|
public Set<Character> tokens() {
return root().getChildrenMap().keySet().stream()
.filter(c -> c != END_OF_STRING && c != FALLBACK && c != ESCAPE)
.collect(Collectors.toSet());
}
|
[
"public",
"Set",
"<",
"Character",
">",
"tokens",
"(",
")",
"{",
"return",
"root",
"(",
")",
".",
"getChildrenMap",
"(",
")",
".",
"keySet",
"(",
")",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"c",
"->",
"c",
"!=",
"END_OF_STRING",
"&&",
"c",
"!=",
"FALLBACK",
"&&",
"c",
"!=",
"ESCAPE",
")",
".",
"collect",
"(",
"Collectors",
".",
"toSet",
"(",
")",
")",
";",
"}"
] |
Tokens set.
@return the set
|
[
"Tokens",
"set",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/text/CharTrie.java#L471-L475
|
155,130
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/text/CharTrie.java
|
CharTrie.max
|
public <T extends Comparable<T>> Stream<TrieNode> max(Function<TrieNode, T> fn, int maxResults) {
return max(fn, maxResults, root());
}
|
java
|
public <T extends Comparable<T>> Stream<TrieNode> max(Function<TrieNode, T> fn, int maxResults) {
return max(fn, maxResults, root());
}
|
[
"public",
"<",
"T",
"extends",
"Comparable",
"<",
"T",
">",
">",
"Stream",
"<",
"TrieNode",
">",
"max",
"(",
"Function",
"<",
"TrieNode",
",",
"T",
">",
"fn",
",",
"int",
"maxResults",
")",
"{",
"return",
"max",
"(",
"fn",
",",
"maxResults",
",",
"root",
"(",
")",
")",
";",
"}"
] |
Max stream.
@param <T> the type parameter
@param fn the fn
@param maxResults the max results
@return the stream
|
[
"Max",
"stream",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/text/CharTrie.java#L495-L497
|
155,131
|
lialun/EasyCache
|
easycache/src/main/java/li/allan/easycache/TimeUtils.java
|
TimeUtils.parseDurationString
|
public static int parseDurationString(String timeStr) {
int seconds = 0;
Matcher matcher = timeStringPattern.matcher(timeStr);
while (matcher.find()) {
String s = matcher.group();
String[] parts = s.split("(?<=[yMwdhms])(?=\\d)|(?<=\\d)(?=[yMwdhms])");
int numb = Integer.parseInt(parts[0]);
String type = parts[1];
switch (type) {
case "s":
seconds = seconds + (numb);
break;
case "m":
seconds = seconds + (numb * 60);
break;
case "h":
seconds = seconds + (numb * 60 * 60);
break;
case "d":
seconds = seconds + (numb * 60 * 60 * 24);
break;
case "w":
seconds = seconds + (numb * 60 * 60 * 24 * 7);
break;
case "M":
seconds = seconds + (numb * 60 * 60 * 24 * 30);
break;
case "y":
seconds = seconds + (numb * 60 * 60 * 24 * 365);
break;
default:
}
}
return seconds;
}
|
java
|
public static int parseDurationString(String timeStr) {
int seconds = 0;
Matcher matcher = timeStringPattern.matcher(timeStr);
while (matcher.find()) {
String s = matcher.group();
String[] parts = s.split("(?<=[yMwdhms])(?=\\d)|(?<=\\d)(?=[yMwdhms])");
int numb = Integer.parseInt(parts[0]);
String type = parts[1];
switch (type) {
case "s":
seconds = seconds + (numb);
break;
case "m":
seconds = seconds + (numb * 60);
break;
case "h":
seconds = seconds + (numb * 60 * 60);
break;
case "d":
seconds = seconds + (numb * 60 * 60 * 24);
break;
case "w":
seconds = seconds + (numb * 60 * 60 * 24 * 7);
break;
case "M":
seconds = seconds + (numb * 60 * 60 * 24 * 30);
break;
case "y":
seconds = seconds + (numb * 60 * 60 * 24 * 365);
break;
default:
}
}
return seconds;
}
|
[
"public",
"static",
"int",
"parseDurationString",
"(",
"String",
"timeStr",
")",
"{",
"int",
"seconds",
"=",
"0",
";",
"Matcher",
"matcher",
"=",
"timeStringPattern",
".",
"matcher",
"(",
"timeStr",
")",
";",
"while",
"(",
"matcher",
".",
"find",
"(",
")",
")",
"{",
"String",
"s",
"=",
"matcher",
".",
"group",
"(",
")",
";",
"String",
"[",
"]",
"parts",
"=",
"s",
".",
"split",
"(",
"\"(?<=[yMwdhms])(?=\\\\d)|(?<=\\\\d)(?=[yMwdhms])\"",
")",
";",
"int",
"numb",
"=",
"Integer",
".",
"parseInt",
"(",
"parts",
"[",
"0",
"]",
")",
";",
"String",
"type",
"=",
"parts",
"[",
"1",
"]",
";",
"switch",
"(",
"type",
")",
"{",
"case",
"\"s\"",
":",
"seconds",
"=",
"seconds",
"+",
"(",
"numb",
")",
";",
"break",
";",
"case",
"\"m\"",
":",
"seconds",
"=",
"seconds",
"+",
"(",
"numb",
"*",
"60",
")",
";",
"break",
";",
"case",
"\"h\"",
":",
"seconds",
"=",
"seconds",
"+",
"(",
"numb",
"*",
"60",
"*",
"60",
")",
";",
"break",
";",
"case",
"\"d\"",
":",
"seconds",
"=",
"seconds",
"+",
"(",
"numb",
"*",
"60",
"*",
"60",
"*",
"24",
")",
";",
"break",
";",
"case",
"\"w\"",
":",
"seconds",
"=",
"seconds",
"+",
"(",
"numb",
"*",
"60",
"*",
"60",
"*",
"24",
"*",
"7",
")",
";",
"break",
";",
"case",
"\"M\"",
":",
"seconds",
"=",
"seconds",
"+",
"(",
"numb",
"*",
"60",
"*",
"60",
"*",
"24",
"*",
"30",
")",
";",
"break",
";",
"case",
"\"y\"",
":",
"seconds",
"=",
"seconds",
"+",
"(",
"numb",
"*",
"60",
"*",
"60",
"*",
"24",
"*",
"365",
")",
";",
"break",
";",
"default",
":",
"}",
"}",
"return",
"seconds",
";",
"}"
] |
parseToSeconds duration string like 'nYnMnDnHnMnS' to seconds
@param timeStr duration string like 'nYnMnDnHnMnS'
@return duration in seconds
|
[
"parseToSeconds",
"duration",
"string",
"like",
"nYnMnDnHnMnS",
"to",
"seconds"
] |
21b5abb1f6408cb9ce78f486c98cd87b9d893d72
|
https://github.com/lialun/EasyCache/blob/21b5abb1f6408cb9ce78f486c98cd87b9d893d72/easycache/src/main/java/li/allan/easycache/TimeUtils.java#L125-L159
|
155,132
|
james-hu/jabb-core
|
src/main/java/net/sf/jabb/drools/MapBasedFact.java
|
MapBasedFact.associateWithPackage
|
public void associateWithPackage(org.drools.core.rule.Package pkg){
factTemplate = pkg.getFactTemplate(factTemplateName);
}
|
java
|
public void associateWithPackage(org.drools.core.rule.Package pkg){
factTemplate = pkg.getFactTemplate(factTemplateName);
}
|
[
"public",
"void",
"associateWithPackage",
"(",
"org",
".",
"drools",
".",
"core",
".",
"rule",
".",
"Package",
"pkg",
")",
"{",
"factTemplate",
"=",
"pkg",
".",
"getFactTemplate",
"(",
"factTemplateName",
")",
";",
"}"
] |
Associate this fact with a package which has a FactTemplate defined with the same FactTemplate name
@param pkg
|
[
"Associate",
"this",
"fact",
"with",
"a",
"package",
"which",
"has",
"a",
"FactTemplate",
"defined",
"with",
"the",
"same",
"FactTemplate",
"name"
] |
bceed441595c5e5195a7418795f03b69fa7b61e4
|
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/drools/MapBasedFact.java#L63-L65
|
155,133
|
morimekta/utils
|
console-util/src/main/java/net/morimekta/console/chr/Color.java
|
Color.mkString
|
private static String mkString(TreeSet<Integer> values) {
StringBuilder builder = new StringBuilder();
builder.append("\033["); // escape.
boolean first = true;
for (int i : values) {
if (first) {
first = false;
} else {
builder.append(';');
}
builder.append(String.format("%d", i));
}
builder.append("m");
return builder.toString();
}
|
java
|
private static String mkString(TreeSet<Integer> values) {
StringBuilder builder = new StringBuilder();
builder.append("\033["); // escape.
boolean first = true;
for (int i : values) {
if (first) {
first = false;
} else {
builder.append(';');
}
builder.append(String.format("%d", i));
}
builder.append("m");
return builder.toString();
}
|
[
"private",
"static",
"String",
"mkString",
"(",
"TreeSet",
"<",
"Integer",
">",
"values",
")",
"{",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"builder",
".",
"append",
"(",
"\"\\033[\"",
")",
";",
"// escape.",
"boolean",
"first",
"=",
"true",
";",
"for",
"(",
"int",
"i",
":",
"values",
")",
"{",
"if",
"(",
"first",
")",
"{",
"first",
"=",
"false",
";",
"}",
"else",
"{",
"builder",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"builder",
".",
"append",
"(",
"String",
".",
"format",
"(",
"\"%d\"",
",",
"i",
")",
")",
";",
"}",
"builder",
".",
"append",
"(",
"\"m\"",
")",
";",
"return",
"builder",
".",
"toString",
"(",
")",
";",
"}"
] |
Generate the color string.
@param values The values combine into the color string.
@return The shell color-settings string.
|
[
"Generate",
"the",
"color",
"string",
"."
] |
dc987485902f1a7d58169c89c61db97425a6226d
|
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/console-util/src/main/java/net/morimekta/console/chr/Color.java#L140-L154
|
155,134
|
m-szalik/rest-client
|
src/main/java/org/jsoftware/restclient/plugins/GetMethodCachePlugin.java
|
GetMethodCachePlugin.headerEq
|
private boolean headerEq(HttpRequestBase request, String headerName, String headerValue) {
Header[] headers = request.getAllHeaders();
if (headers != null) {
for(Header h : headers) {
if (headerName.equalsIgnoreCase(h.getName()) && headerValue.equalsIgnoreCase(h.getValue())) {
return true;
}
}
}
return false;
}
|
java
|
private boolean headerEq(HttpRequestBase request, String headerName, String headerValue) {
Header[] headers = request.getAllHeaders();
if (headers != null) {
for(Header h : headers) {
if (headerName.equalsIgnoreCase(h.getName()) && headerValue.equalsIgnoreCase(h.getValue())) {
return true;
}
}
}
return false;
}
|
[
"private",
"boolean",
"headerEq",
"(",
"HttpRequestBase",
"request",
",",
"String",
"headerName",
",",
"String",
"headerValue",
")",
"{",
"Header",
"[",
"]",
"headers",
"=",
"request",
".",
"getAllHeaders",
"(",
")",
";",
"if",
"(",
"headers",
"!=",
"null",
")",
"{",
"for",
"(",
"Header",
"h",
":",
"headers",
")",
"{",
"if",
"(",
"headerName",
".",
"equalsIgnoreCase",
"(",
"h",
".",
"getName",
"(",
")",
")",
"&&",
"headerValue",
".",
"equalsIgnoreCase",
"(",
"h",
".",
"getValue",
"(",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] |
Check if request contains header with value
@param request request
@param headerName header name
@param headerValue header value to check
|
[
"Check",
"if",
"request",
"contains",
"header",
"with",
"value"
] |
14a0ab6a19b97183282bac71f3a3b237e45a5bf3
|
https://github.com/m-szalik/rest-client/blob/14a0ab6a19b97183282bac71f3a3b237e45a5bf3/src/main/java/org/jsoftware/restclient/plugins/GetMethodCachePlugin.java#L102-L112
|
155,135
|
JM-Lab/utils-java8
|
src/main/java/kr/jm/utils/JavascriptEvaluator.java
|
JavascriptEvaluator.eval
|
public static Object eval(String script) {
try {
return getScriptEngine().eval(script);
} catch (Exception e) {
return JMExceptionManager
.handleExceptionAndReturnNull(log, e, "eval", script);
}
}
|
java
|
public static Object eval(String script) {
try {
return getScriptEngine().eval(script);
} catch (Exception e) {
return JMExceptionManager
.handleExceptionAndReturnNull(log, e, "eval", script);
}
}
|
[
"public",
"static",
"Object",
"eval",
"(",
"String",
"script",
")",
"{",
"try",
"{",
"return",
"getScriptEngine",
"(",
")",
".",
"eval",
"(",
"script",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"return",
"JMExceptionManager",
".",
"handleExceptionAndReturnNull",
"(",
"log",
",",
"e",
",",
"\"eval\"",
",",
"script",
")",
";",
"}",
"}"
] |
Eval object.
@param script the script
@return the object
|
[
"Eval",
"object",
"."
] |
9e407b3f28a7990418a1e877229fa8344f4d78a5
|
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/JavascriptEvaluator.java#L25-L32
|
155,136
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java
|
DirectoryServiceClient.setDirectoryServers
|
public void setDirectoryServers(List<String> servers){
if(servers == null || servers.size() == 0){
return;
}
directoryServers = new DirectoryServers(servers);
connection.setDirectoryServers(directoryServers.getNextDirectoryServer());
}
|
java
|
public void setDirectoryServers(List<String> servers){
if(servers == null || servers.size() == 0){
return;
}
directoryServers = new DirectoryServers(servers);
connection.setDirectoryServers(directoryServers.getNextDirectoryServer());
}
|
[
"public",
"void",
"setDirectoryServers",
"(",
"List",
"<",
"String",
">",
"servers",
")",
"{",
"if",
"(",
"servers",
"==",
"null",
"||",
"servers",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"return",
";",
"}",
"directoryServers",
"=",
"new",
"DirectoryServers",
"(",
"servers",
")",
";",
"connection",
".",
"setDirectoryServers",
"(",
"directoryServers",
".",
"getNextDirectoryServer",
"(",
")",
")",
";",
"}"
] |
Set the Directory Server list.
@param servers
the Directory Server list.
|
[
"Set",
"the",
"Directory",
"Server",
"list",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java#L170-L176
|
155,137
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java
|
DirectoryServiceClient.setUser
|
public void setUser(String userName, String password){
if(userName != null && ! userName.isEmpty()){
connection.setDirectoryUser(userName, password);
}
}
|
java
|
public void setUser(String userName, String password){
if(userName != null && ! userName.isEmpty()){
connection.setDirectoryUser(userName, password);
}
}
|
[
"public",
"void",
"setUser",
"(",
"String",
"userName",
",",
"String",
"password",
")",
"{",
"if",
"(",
"userName",
"!=",
"null",
"&&",
"!",
"userName",
".",
"isEmpty",
"(",
")",
")",
"{",
"connection",
".",
"setDirectoryUser",
"(",
"userName",
",",
"password",
")",
";",
"}",
"}"
] |
Set the user for the DirectoryServiceClient.
It will ask the DirectoryConnection to do authentication again.
@param userName
the user name.
@param password
the password.
|
[
"Set",
"the",
"user",
"for",
"the",
"DirectoryServiceClient",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java#L198-L202
|
155,138
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java
|
DirectoryServiceClient.createUser
|
public void createUser(User user, String password){
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.CreateUser);
byte[] secret = null;
if(password != null && ! password.isEmpty()){
secret = ObfuscatUtil.base64Encode(password.getBytes());
}
CreateUserProtocol p = new CreateUserProtocol(user, secret);
connection.submitRequest(header, p, null);
}
|
java
|
public void createUser(User user, String password){
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.CreateUser);
byte[] secret = null;
if(password != null && ! password.isEmpty()){
secret = ObfuscatUtil.base64Encode(password.getBytes());
}
CreateUserProtocol p = new CreateUserProtocol(user, secret);
connection.submitRequest(header, p, null);
}
|
[
"public",
"void",
"createUser",
"(",
"User",
"user",
",",
"String",
"password",
")",
"{",
"ProtocolHeader",
"header",
"=",
"new",
"ProtocolHeader",
"(",
")",
";",
"header",
".",
"setType",
"(",
"ProtocolType",
".",
"CreateUser",
")",
";",
"byte",
"[",
"]",
"secret",
"=",
"null",
";",
"if",
"(",
"password",
"!=",
"null",
"&&",
"!",
"password",
".",
"isEmpty",
"(",
")",
")",
"{",
"secret",
"=",
"ObfuscatUtil",
".",
"base64Encode",
"(",
"password",
".",
"getBytes",
"(",
")",
")",
";",
"}",
"CreateUserProtocol",
"p",
"=",
"new",
"CreateUserProtocol",
"(",
"user",
",",
"secret",
")",
";",
"connection",
".",
"submitRequest",
"(",
"header",
",",
"p",
",",
"null",
")",
";",
"}"
] |
Create a User.
@param user
the User.
@param password
the user password.
|
[
"Create",
"a",
"User",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java#L212-L222
|
155,139
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java
|
DirectoryServiceClient.setUserPassword
|
public void setUserPassword(String userName, String password) {
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.SetUserPassword);
byte[] secret = null;
if(password != null && ! password.isEmpty()){
secret = ObfuscatUtil.base64Encode(password.getBytes());
}
SetUserPasswordProtocol p = new SetUserPasswordProtocol(userName, secret);
connection.submitRequest(header, p, null);
}
|
java
|
public void setUserPassword(String userName, String password) {
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.SetUserPassword);
byte[] secret = null;
if(password != null && ! password.isEmpty()){
secret = ObfuscatUtil.base64Encode(password.getBytes());
}
SetUserPasswordProtocol p = new SetUserPasswordProtocol(userName, secret);
connection.submitRequest(header, p, null);
}
|
[
"public",
"void",
"setUserPassword",
"(",
"String",
"userName",
",",
"String",
"password",
")",
"{",
"ProtocolHeader",
"header",
"=",
"new",
"ProtocolHeader",
"(",
")",
";",
"header",
".",
"setType",
"(",
"ProtocolType",
".",
"SetUserPassword",
")",
";",
"byte",
"[",
"]",
"secret",
"=",
"null",
";",
"if",
"(",
"password",
"!=",
"null",
"&&",
"!",
"password",
".",
"isEmpty",
"(",
")",
")",
"{",
"secret",
"=",
"ObfuscatUtil",
".",
"base64Encode",
"(",
"password",
".",
"getBytes",
"(",
")",
")",
";",
"}",
"SetUserPasswordProtocol",
"p",
"=",
"new",
"SetUserPasswordProtocol",
"(",
"userName",
",",
"secret",
")",
";",
"connection",
".",
"submitRequest",
"(",
"header",
",",
"p",
",",
"null",
")",
";",
"}"
] |
Set user password.
@param userName
the user name.
@param password
the user password.
|
[
"Set",
"user",
"password",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java#L232-L244
|
155,140
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java
|
DirectoryServiceClient.deleteUser
|
public void deleteUser(String userName){
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.DeleteUser);
DeleteUserProtocol p = new DeleteUserProtocol(userName);
connection.submitRequest(header, p, null);
}
|
java
|
public void deleteUser(String userName){
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.DeleteUser);
DeleteUserProtocol p = new DeleteUserProtocol(userName);
connection.submitRequest(header, p, null);
}
|
[
"public",
"void",
"deleteUser",
"(",
"String",
"userName",
")",
"{",
"ProtocolHeader",
"header",
"=",
"new",
"ProtocolHeader",
"(",
")",
";",
"header",
".",
"setType",
"(",
"ProtocolType",
".",
"DeleteUser",
")",
";",
"DeleteUserProtocol",
"p",
"=",
"new",
"DeleteUserProtocol",
"(",
"userName",
")",
";",
"connection",
".",
"submitRequest",
"(",
"header",
",",
"p",
",",
"null",
")",
";",
"}"
] |
Delete user by name.
@param userName
the user name.
|
[
"Delete",
"user",
"by",
"name",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java#L252-L259
|
155,141
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java
|
DirectoryServiceClient.getAllUser
|
public List<User> getAllUser(){
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.GetAllUser);
Response resp = connection.submitRequest(header, null, null);
return ((GetAllUserResponse) resp).getUsers();
}
|
java
|
public List<User> getAllUser(){
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.GetAllUser);
Response resp = connection.submitRequest(header, null, null);
return ((GetAllUserResponse) resp).getUsers();
}
|
[
"public",
"List",
"<",
"User",
">",
"getAllUser",
"(",
")",
"{",
"ProtocolHeader",
"header",
"=",
"new",
"ProtocolHeader",
"(",
")",
";",
"header",
".",
"setType",
"(",
"ProtocolType",
".",
"GetAllUser",
")",
";",
"Response",
"resp",
"=",
"connection",
".",
"submitRequest",
"(",
"header",
",",
"null",
",",
"null",
")",
";",
"return",
"(",
"(",
"GetAllUserResponse",
")",
"resp",
")",
".",
"getUsers",
"(",
")",
";",
"}"
] |
Get all Users.
@return
the user list.
|
[
"Get",
"all",
"Users",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java#L282-L288
|
155,142
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java
|
DirectoryServiceClient.getUser
|
public User getUser(String name){
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.GetUser);
GetUserProtocol p = new GetUserProtocol(name);
Response resp = connection.submitRequest(header, p, null);
return ((GetUserResponse) resp).getUser();
}
|
java
|
public User getUser(String name){
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.GetUser);
GetUserProtocol p = new GetUserProtocol(name);
Response resp = connection.submitRequest(header, p, null);
return ((GetUserResponse) resp).getUser();
}
|
[
"public",
"User",
"getUser",
"(",
"String",
"name",
")",
"{",
"ProtocolHeader",
"header",
"=",
"new",
"ProtocolHeader",
"(",
")",
";",
"header",
".",
"setType",
"(",
"ProtocolType",
".",
"GetUser",
")",
";",
"GetUserProtocol",
"p",
"=",
"new",
"GetUserProtocol",
"(",
"name",
")",
";",
"Response",
"resp",
"=",
"connection",
".",
"submitRequest",
"(",
"header",
",",
"p",
",",
"null",
")",
";",
"return",
"(",
"(",
"GetUserResponse",
")",
"resp",
")",
".",
"getUser",
"(",
")",
";",
"}"
] |
Get user by name.
@param name
the user name.
@return
the User.
|
[
"Get",
"user",
"by",
"name",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java#L298-L306
|
155,143
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java
|
DirectoryServiceClient.setACL
|
public void setACL(ACL acl){
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.SetACL);
SetACLProtocol p = new SetACLProtocol(acl);
connection.submitRequest(header, p, null);
}
|
java
|
public void setACL(ACL acl){
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.SetACL);
SetACLProtocol p = new SetACLProtocol(acl);
connection.submitRequest(header, p, null);
}
|
[
"public",
"void",
"setACL",
"(",
"ACL",
"acl",
")",
"{",
"ProtocolHeader",
"header",
"=",
"new",
"ProtocolHeader",
"(",
")",
";",
"header",
".",
"setType",
"(",
"ProtocolType",
".",
"SetACL",
")",
";",
"SetACLProtocol",
"p",
"=",
"new",
"SetACLProtocol",
"(",
"acl",
")",
";",
"connection",
".",
"submitRequest",
"(",
"header",
",",
"p",
",",
"null",
")",
";",
"}"
] |
Set ACL.
@param acl
the ACL.
|
[
"Set",
"ACL",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java#L314-L321
|
155,144
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java
|
DirectoryServiceClient.getACL
|
public ACL getACL(AuthScheme scheme, String id){
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.GetACL);
GetACLProtocol p = new GetACLProtocol(scheme, id);
Response resp = connection.submitRequest(header, p, null);
return ((GetACLResponse) resp).getAcl();
}
|
java
|
public ACL getACL(AuthScheme scheme, String id){
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.GetACL);
GetACLProtocol p = new GetACLProtocol(scheme, id);
Response resp = connection.submitRequest(header, p, null);
return ((GetACLResponse) resp).getAcl();
}
|
[
"public",
"ACL",
"getACL",
"(",
"AuthScheme",
"scheme",
",",
"String",
"id",
")",
"{",
"ProtocolHeader",
"header",
"=",
"new",
"ProtocolHeader",
"(",
")",
";",
"header",
".",
"setType",
"(",
"ProtocolType",
".",
"GetACL",
")",
";",
"GetACLProtocol",
"p",
"=",
"new",
"GetACLProtocol",
"(",
"scheme",
",",
"id",
")",
";",
"Response",
"resp",
"=",
"connection",
".",
"submitRequest",
"(",
"header",
",",
"p",
",",
"null",
")",
";",
"return",
"(",
"(",
"GetACLResponse",
")",
"resp",
")",
".",
"getAcl",
"(",
")",
";",
"}"
] |
Get the ACL.
@param scheme
the AuthScheme.
@param id
the identity.
@return
the ACL.
|
[
"Get",
"the",
"ACL",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java#L333-L341
|
155,145
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java
|
DirectoryServiceClient.registerServiceInstance
|
public void registerServiceInstance(ProvidedServiceInstance instance, final RegistrationCallback cb, Object context){
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.RegisterServiceInstance);
RegisterServiceInstanceProtocol p = new RegisterServiceInstanceProtocol(instance);
ProtocolCallback pcb = new ProtocolCallback(){
@Override
public void call(boolean result, Response response,
ErrorCode error, Object ctx) {
cb.call(result, error, ctx);
}
};
connection.submitCallbackRequest(header, p, pcb, context);
}
|
java
|
public void registerServiceInstance(ProvidedServiceInstance instance, final RegistrationCallback cb, Object context){
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.RegisterServiceInstance);
RegisterServiceInstanceProtocol p = new RegisterServiceInstanceProtocol(instance);
ProtocolCallback pcb = new ProtocolCallback(){
@Override
public void call(boolean result, Response response,
ErrorCode error, Object ctx) {
cb.call(result, error, ctx);
}
};
connection.submitCallbackRequest(header, p, pcb, context);
}
|
[
"public",
"void",
"registerServiceInstance",
"(",
"ProvidedServiceInstance",
"instance",
",",
"final",
"RegistrationCallback",
"cb",
",",
"Object",
"context",
")",
"{",
"ProtocolHeader",
"header",
"=",
"new",
"ProtocolHeader",
"(",
")",
";",
"header",
".",
"setType",
"(",
"ProtocolType",
".",
"RegisterServiceInstance",
")",
";",
"RegisterServiceInstanceProtocol",
"p",
"=",
"new",
"RegisterServiceInstanceProtocol",
"(",
"instance",
")",
";",
"ProtocolCallback",
"pcb",
"=",
"new",
"ProtocolCallback",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"call",
"(",
"boolean",
"result",
",",
"Response",
"response",
",",
"ErrorCode",
"error",
",",
"Object",
"ctx",
")",
"{",
"cb",
".",
"call",
"(",
"result",
",",
"error",
",",
"ctx",
")",
";",
"}",
"}",
";",
"connection",
".",
"submitCallbackRequest",
"(",
"header",
",",
"p",
",",
"pcb",
",",
"context",
")",
";",
"}"
] |
Register ServiceInstance with Callback.
@param instance
the ProvidedServiceInstance.
@param cb
the callback.
@param context
the context Object.
|
[
"Register",
"ServiceInstance",
"with",
"Callback",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java#L370-L389
|
155,146
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java
|
DirectoryServiceClient.updateServiceInstanceStatus
|
public void updateServiceInstanceStatus(String serviceName, String instanceId, OperationalStatus status){
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.UpdateServiceInstanceStatus);
UpdateServiceInstanceStatusProtocol p = new UpdateServiceInstanceStatusProtocol(serviceName, instanceId, status);
connection.submitRequest(header, p, null);
}
|
java
|
public void updateServiceInstanceStatus(String serviceName, String instanceId, OperationalStatus status){
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.UpdateServiceInstanceStatus);
UpdateServiceInstanceStatusProtocol p = new UpdateServiceInstanceStatusProtocol(serviceName, instanceId, status);
connection.submitRequest(header, p, null);
}
|
[
"public",
"void",
"updateServiceInstanceStatus",
"(",
"String",
"serviceName",
",",
"String",
"instanceId",
",",
"OperationalStatus",
"status",
")",
"{",
"ProtocolHeader",
"header",
"=",
"new",
"ProtocolHeader",
"(",
")",
";",
"header",
".",
"setType",
"(",
"ProtocolType",
".",
"UpdateServiceInstanceStatus",
")",
";",
"UpdateServiceInstanceStatusProtocol",
"p",
"=",
"new",
"UpdateServiceInstanceStatusProtocol",
"(",
"serviceName",
",",
"instanceId",
",",
"status",
")",
";",
"connection",
".",
"submitRequest",
"(",
"header",
",",
"p",
",",
"null",
")",
";",
"}"
] |
Update ServiceInstance status.
@param serviceName
the service name.
@param instanceId
the instanceId.
@param status
the OeperationalStatus.
|
[
"Update",
"ServiceInstance",
"status",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java#L401-L407
|
155,147
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java
|
DirectoryServiceClient.updateServiceInstanceStatus
|
public void updateServiceInstanceStatus(String serviceName, String instanceId, OperationalStatus status, final RegistrationCallback cb, Object context){
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.UpdateServiceInstanceStatus);
UpdateServiceInstanceStatusProtocol p = new UpdateServiceInstanceStatusProtocol(serviceName, instanceId, status);
ProtocolCallback pcb = new ProtocolCallback(){
@Override
public void call(boolean result, Response response,
ErrorCode error, Object ctx) {
cb.call(result, error, ctx);
}
};
connection.submitCallbackRequest(header, p, pcb, context);
}
|
java
|
public void updateServiceInstanceStatus(String serviceName, String instanceId, OperationalStatus status, final RegistrationCallback cb, Object context){
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.UpdateServiceInstanceStatus);
UpdateServiceInstanceStatusProtocol p = new UpdateServiceInstanceStatusProtocol(serviceName, instanceId, status);
ProtocolCallback pcb = new ProtocolCallback(){
@Override
public void call(boolean result, Response response,
ErrorCode error, Object ctx) {
cb.call(result, error, ctx);
}
};
connection.submitCallbackRequest(header, p, pcb, context);
}
|
[
"public",
"void",
"updateServiceInstanceStatus",
"(",
"String",
"serviceName",
",",
"String",
"instanceId",
",",
"OperationalStatus",
"status",
",",
"final",
"RegistrationCallback",
"cb",
",",
"Object",
"context",
")",
"{",
"ProtocolHeader",
"header",
"=",
"new",
"ProtocolHeader",
"(",
")",
";",
"header",
".",
"setType",
"(",
"ProtocolType",
".",
"UpdateServiceInstanceStatus",
")",
";",
"UpdateServiceInstanceStatusProtocol",
"p",
"=",
"new",
"UpdateServiceInstanceStatusProtocol",
"(",
"serviceName",
",",
"instanceId",
",",
"status",
")",
";",
"ProtocolCallback",
"pcb",
"=",
"new",
"ProtocolCallback",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"call",
"(",
"boolean",
"result",
",",
"Response",
"response",
",",
"ErrorCode",
"error",
",",
"Object",
"ctx",
")",
"{",
"cb",
".",
"call",
"(",
"result",
",",
"error",
",",
"ctx",
")",
";",
"}",
"}",
";",
"connection",
".",
"submitCallbackRequest",
"(",
"header",
",",
"p",
",",
"pcb",
",",
"context",
")",
";",
"}"
] |
Update ServiceInstance status with Callback.
@param serviceName
the servicename.
@param instanceId
the instanceId.
@param status
the OperationalStaus
@param cb
the Callback.
@param context
the context object.
|
[
"Update",
"ServiceInstance",
"status",
"with",
"Callback",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java#L423-L440
|
155,148
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java
|
DirectoryServiceClient.updateServiceInstanceInternalStatus
|
public void updateServiceInstanceInternalStatus(String serviceName, String instanceId, OperationalStatus status){
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.UpdateServiceInstanceInternalStatus);
UpdateServiceInstanceInternalStatusProtocol protocol = new UpdateServiceInstanceInternalStatusProtocol(serviceName, instanceId, status);
connection.submitRequest(header, protocol, null);
}
|
java
|
public void updateServiceInstanceInternalStatus(String serviceName, String instanceId, OperationalStatus status){
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.UpdateServiceInstanceInternalStatus);
UpdateServiceInstanceInternalStatusProtocol protocol = new UpdateServiceInstanceInternalStatusProtocol(serviceName, instanceId, status);
connection.submitRequest(header, protocol, null);
}
|
[
"public",
"void",
"updateServiceInstanceInternalStatus",
"(",
"String",
"serviceName",
",",
"String",
"instanceId",
",",
"OperationalStatus",
"status",
")",
"{",
"ProtocolHeader",
"header",
"=",
"new",
"ProtocolHeader",
"(",
")",
";",
"header",
".",
"setType",
"(",
"ProtocolType",
".",
"UpdateServiceInstanceInternalStatus",
")",
";",
"UpdateServiceInstanceInternalStatusProtocol",
"protocol",
"=",
"new",
"UpdateServiceInstanceInternalStatusProtocol",
"(",
"serviceName",
",",
"instanceId",
",",
"status",
")",
";",
"connection",
".",
"submitRequest",
"(",
"header",
",",
"protocol",
",",
"null",
")",
";",
"}"
] |
Update ServiceInstance internal status.
@param serviceName
the service name.
@param instanceId
the instanceId.
@param status
the OeperationalStatus.
|
[
"Update",
"ServiceInstance",
"internal",
"status",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java#L452-L458
|
155,149
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java
|
DirectoryServiceClient.updateServiceInstanceInternalStatus
|
public void updateServiceInstanceInternalStatus(String serviceName, String instanceId, OperationalStatus status, final RegistrationCallback cb, Object context){
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.UpdateServiceInstanceInternalStatus);
UpdateServiceInstanceInternalStatusProtocol protocol = new UpdateServiceInstanceInternalStatusProtocol(serviceName, instanceId, status);
ProtocolCallback pcb = new ProtocolCallback(){
@Override
public void call(boolean result, Response response,
ErrorCode error, Object ctx) {
cb.call(result, error, ctx);
}
};
connection.submitCallbackRequest(header, protocol, pcb, context);
}
|
java
|
public void updateServiceInstanceInternalStatus(String serviceName, String instanceId, OperationalStatus status, final RegistrationCallback cb, Object context){
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.UpdateServiceInstanceInternalStatus);
UpdateServiceInstanceInternalStatusProtocol protocol = new UpdateServiceInstanceInternalStatusProtocol(serviceName, instanceId, status);
ProtocolCallback pcb = new ProtocolCallback(){
@Override
public void call(boolean result, Response response,
ErrorCode error, Object ctx) {
cb.call(result, error, ctx);
}
};
connection.submitCallbackRequest(header, protocol, pcb, context);
}
|
[
"public",
"void",
"updateServiceInstanceInternalStatus",
"(",
"String",
"serviceName",
",",
"String",
"instanceId",
",",
"OperationalStatus",
"status",
",",
"final",
"RegistrationCallback",
"cb",
",",
"Object",
"context",
")",
"{",
"ProtocolHeader",
"header",
"=",
"new",
"ProtocolHeader",
"(",
")",
";",
"header",
".",
"setType",
"(",
"ProtocolType",
".",
"UpdateServiceInstanceInternalStatus",
")",
";",
"UpdateServiceInstanceInternalStatusProtocol",
"protocol",
"=",
"new",
"UpdateServiceInstanceInternalStatusProtocol",
"(",
"serviceName",
",",
"instanceId",
",",
"status",
")",
";",
"ProtocolCallback",
"pcb",
"=",
"new",
"ProtocolCallback",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"call",
"(",
"boolean",
"result",
",",
"Response",
"response",
",",
"ErrorCode",
"error",
",",
"Object",
"ctx",
")",
"{",
"cb",
".",
"call",
"(",
"result",
",",
"error",
",",
"ctx",
")",
";",
"}",
"}",
";",
"connection",
".",
"submitCallbackRequest",
"(",
"header",
",",
"protocol",
",",
"pcb",
",",
"context",
")",
";",
"}"
] |
Update ServiceInstance internal status with Callback.
@param serviceName
the servicename.
@param instanceId
the instanceId.
@param status
the OperationalStaus
@param cb
the Callback.
@param context
the context object.
|
[
"Update",
"ServiceInstance",
"internal",
"status",
"with",
"Callback",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java#L474-L491
|
155,150
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java
|
DirectoryServiceClient.updateServiceInstance
|
public void updateServiceInstance(ProvidedServiceInstance instance){
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.UpdateServiceInstance);
UpdateServiceInstanceProtocol p = new UpdateServiceInstanceProtocol(instance);
connection.submitRequest(header, p, null);
}
|
java
|
public void updateServiceInstance(ProvidedServiceInstance instance){
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.UpdateServiceInstance);
UpdateServiceInstanceProtocol p = new UpdateServiceInstanceProtocol(instance);
connection.submitRequest(header, p, null);
}
|
[
"public",
"void",
"updateServiceInstance",
"(",
"ProvidedServiceInstance",
"instance",
")",
"{",
"ProtocolHeader",
"header",
"=",
"new",
"ProtocolHeader",
"(",
")",
";",
"header",
".",
"setType",
"(",
"ProtocolType",
".",
"UpdateServiceInstance",
")",
";",
"UpdateServiceInstanceProtocol",
"p",
"=",
"new",
"UpdateServiceInstanceProtocol",
"(",
"instance",
")",
";",
"connection",
".",
"submitRequest",
"(",
"header",
",",
"p",
",",
"null",
")",
";",
"}"
] |
Update the ServiceInstance.
@param instance
the ServiceInstance.
|
[
"Update",
"the",
"ServiceInstance",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java#L547-L553
|
155,151
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java
|
DirectoryServiceClient.updateServiceInstance
|
public void updateServiceInstance(ProvidedServiceInstance instance, final RegistrationCallback cb, Object context){
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.UpdateServiceInstance);
UpdateServiceInstanceProtocol p = new UpdateServiceInstanceProtocol(instance);
ProtocolCallback pcb = new ProtocolCallback(){
@Override
public void call(boolean result, Response response,
ErrorCode error, Object ctx) {
cb.call(result, error, ctx);
}
};
connection.submitCallbackRequest(header, p, pcb, context);
}
|
java
|
public void updateServiceInstance(ProvidedServiceInstance instance, final RegistrationCallback cb, Object context){
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.UpdateServiceInstance);
UpdateServiceInstanceProtocol p = new UpdateServiceInstanceProtocol(instance);
ProtocolCallback pcb = new ProtocolCallback(){
@Override
public void call(boolean result, Response response,
ErrorCode error, Object ctx) {
cb.call(result, error, ctx);
}
};
connection.submitCallbackRequest(header, p, pcb, context);
}
|
[
"public",
"void",
"updateServiceInstance",
"(",
"ProvidedServiceInstance",
"instance",
",",
"final",
"RegistrationCallback",
"cb",
",",
"Object",
"context",
")",
"{",
"ProtocolHeader",
"header",
"=",
"new",
"ProtocolHeader",
"(",
")",
";",
"header",
".",
"setType",
"(",
"ProtocolType",
".",
"UpdateServiceInstance",
")",
";",
"UpdateServiceInstanceProtocol",
"p",
"=",
"new",
"UpdateServiceInstanceProtocol",
"(",
"instance",
")",
";",
"ProtocolCallback",
"pcb",
"=",
"new",
"ProtocolCallback",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"call",
"(",
"boolean",
"result",
",",
"Response",
"response",
",",
"ErrorCode",
"error",
",",
"Object",
"ctx",
")",
"{",
"cb",
".",
"call",
"(",
"result",
",",
"error",
",",
"ctx",
")",
";",
"}",
"}",
";",
"connection",
".",
"submitCallbackRequest",
"(",
"header",
",",
"p",
",",
"pcb",
",",
"context",
")",
";",
"}"
] |
Update the ServiceInstance with callback.
@param instance
the ServiceInstance.
@param cb
the Callback.
@param context
the context object.
|
[
"Update",
"the",
"ServiceInstance",
"with",
"callback",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java#L565-L580
|
155,152
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java
|
DirectoryServiceClient.updateServiceInstanceUri
|
public void updateServiceInstanceUri(String serviceName, String instanceId, String uri){
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.UpdateServiceInstanceUri);
UpdateServiceInstanceUriProtocol p = new UpdateServiceInstanceUriProtocol(serviceName, instanceId, uri);
connection.submitRequest(header, p, null);
}
|
java
|
public void updateServiceInstanceUri(String serviceName, String instanceId, String uri){
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.UpdateServiceInstanceUri);
UpdateServiceInstanceUriProtocol p = new UpdateServiceInstanceUriProtocol(serviceName, instanceId, uri);
connection.submitRequest(header, p, null);
}
|
[
"public",
"void",
"updateServiceInstanceUri",
"(",
"String",
"serviceName",
",",
"String",
"instanceId",
",",
"String",
"uri",
")",
"{",
"ProtocolHeader",
"header",
"=",
"new",
"ProtocolHeader",
"(",
")",
";",
"header",
".",
"setType",
"(",
"ProtocolType",
".",
"UpdateServiceInstanceUri",
")",
";",
"UpdateServiceInstanceUriProtocol",
"p",
"=",
"new",
"UpdateServiceInstanceUriProtocol",
"(",
"serviceName",
",",
"instanceId",
",",
"uri",
")",
";",
"connection",
".",
"submitRequest",
"(",
"header",
",",
"p",
",",
"null",
")",
";",
"}"
] |
Update ServiceInstance URI.
@param serviceName
the service name.
@param instanceId
the instance id.
@param uri
the new URI.
|
[
"Update",
"ServiceInstance",
"URI",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java#L592-L598
|
155,153
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java
|
DirectoryServiceClient.updateServiceInstanceUri
|
public void updateServiceInstanceUri(String serviceName, String instanceId, String uri, final RegistrationCallback cb, Object context){
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.UpdateServiceInstanceUri);
UpdateServiceInstanceUriProtocol p = new UpdateServiceInstanceUriProtocol(serviceName, instanceId, uri);
ProtocolCallback pcb = new ProtocolCallback(){
@Override
public void call(boolean result, Response response,
ErrorCode error, Object ctx) {
cb.call(result, error, ctx);
}
};
connection.submitCallbackRequest(header, p, pcb, context);
}
|
java
|
public void updateServiceInstanceUri(String serviceName, String instanceId, String uri, final RegistrationCallback cb, Object context){
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.UpdateServiceInstanceUri);
UpdateServiceInstanceUriProtocol p = new UpdateServiceInstanceUriProtocol(serviceName, instanceId, uri);
ProtocolCallback pcb = new ProtocolCallback(){
@Override
public void call(boolean result, Response response,
ErrorCode error, Object ctx) {
cb.call(result, error, ctx);
}
};
connection.submitCallbackRequest(header, p, pcb, context);
}
|
[
"public",
"void",
"updateServiceInstanceUri",
"(",
"String",
"serviceName",
",",
"String",
"instanceId",
",",
"String",
"uri",
",",
"final",
"RegistrationCallback",
"cb",
",",
"Object",
"context",
")",
"{",
"ProtocolHeader",
"header",
"=",
"new",
"ProtocolHeader",
"(",
")",
";",
"header",
".",
"setType",
"(",
"ProtocolType",
".",
"UpdateServiceInstanceUri",
")",
";",
"UpdateServiceInstanceUriProtocol",
"p",
"=",
"new",
"UpdateServiceInstanceUriProtocol",
"(",
"serviceName",
",",
"instanceId",
",",
"uri",
")",
";",
"ProtocolCallback",
"pcb",
"=",
"new",
"ProtocolCallback",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"call",
"(",
"boolean",
"result",
",",
"Response",
"response",
",",
"ErrorCode",
"error",
",",
"Object",
"ctx",
")",
"{",
"cb",
".",
"call",
"(",
"result",
",",
"error",
",",
"ctx",
")",
";",
"}",
"}",
";",
"connection",
".",
"submitCallbackRequest",
"(",
"header",
",",
"p",
",",
"pcb",
",",
"context",
")",
";",
"}"
] |
Update ServiceInstance URI in Callback.
@param serviceName
the service name.
@param instanceId
the instanceId.
@param uri
the new URI.
@param cb
the Callback.
@param context
the object context.
|
[
"Update",
"ServiceInstance",
"URI",
"in",
"Callback",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java#L614-L629
|
155,154
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java
|
DirectoryServiceClient.unregisterServiceInstance
|
public void unregisterServiceInstance(String serviceName, String instanceId){
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.UnregisterServiceInstance);
UnregisterServiceInstanceProtocol p = new UnregisterServiceInstanceProtocol(serviceName, instanceId);
connection.submitRequest(header, p, null);
}
|
java
|
public void unregisterServiceInstance(String serviceName, String instanceId){
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.UnregisterServiceInstance);
UnregisterServiceInstanceProtocol p = new UnregisterServiceInstanceProtocol(serviceName, instanceId);
connection.submitRequest(header, p, null);
}
|
[
"public",
"void",
"unregisterServiceInstance",
"(",
"String",
"serviceName",
",",
"String",
"instanceId",
")",
"{",
"ProtocolHeader",
"header",
"=",
"new",
"ProtocolHeader",
"(",
")",
";",
"header",
".",
"setType",
"(",
"ProtocolType",
".",
"UnregisterServiceInstance",
")",
";",
"UnregisterServiceInstanceProtocol",
"p",
"=",
"new",
"UnregisterServiceInstanceProtocol",
"(",
"serviceName",
",",
"instanceId",
")",
";",
"connection",
".",
"submitRequest",
"(",
"header",
",",
"p",
",",
"null",
")",
";",
"}"
] |
Unregister the ServiceInstance.
@param serviceName
the service name.
@param instanceId
the instanceId.
|
[
"Unregister",
"the",
"ServiceInstance",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java#L639-L645
|
155,155
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java
|
DirectoryServiceClient.unregisterServiceInstance
|
public void unregisterServiceInstance(String serviceName, String instanceId, final RegistrationCallback cb, Object context){
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.UnregisterServiceInstance);
UnregisterServiceInstanceProtocol p = new UnregisterServiceInstanceProtocol(serviceName, instanceId);
ProtocolCallback pcb = new ProtocolCallback(){
@Override
public void call(boolean result, Response response,
ErrorCode error, Object ctx) {
cb.call(result, error, ctx);
}
};
connection.submitCallbackRequest(header, p, pcb, context);
}
|
java
|
public void unregisterServiceInstance(String serviceName, String instanceId, final RegistrationCallback cb, Object context){
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.UnregisterServiceInstance);
UnregisterServiceInstanceProtocol p = new UnregisterServiceInstanceProtocol(serviceName, instanceId);
ProtocolCallback pcb = new ProtocolCallback(){
@Override
public void call(boolean result, Response response,
ErrorCode error, Object ctx) {
cb.call(result, error, ctx);
}
};
connection.submitCallbackRequest(header, p, pcb, context);
}
|
[
"public",
"void",
"unregisterServiceInstance",
"(",
"String",
"serviceName",
",",
"String",
"instanceId",
",",
"final",
"RegistrationCallback",
"cb",
",",
"Object",
"context",
")",
"{",
"ProtocolHeader",
"header",
"=",
"new",
"ProtocolHeader",
"(",
")",
";",
"header",
".",
"setType",
"(",
"ProtocolType",
".",
"UnregisterServiceInstance",
")",
";",
"UnregisterServiceInstanceProtocol",
"p",
"=",
"new",
"UnregisterServiceInstanceProtocol",
"(",
"serviceName",
",",
"instanceId",
")",
";",
"ProtocolCallback",
"pcb",
"=",
"new",
"ProtocolCallback",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"call",
"(",
"boolean",
"result",
",",
"Response",
"response",
",",
"ErrorCode",
"error",
",",
"Object",
"ctx",
")",
"{",
"cb",
".",
"call",
"(",
"result",
",",
"error",
",",
"ctx",
")",
";",
"}",
"}",
";",
"connection",
".",
"submitCallbackRequest",
"(",
"header",
",",
"p",
",",
"pcb",
",",
"context",
")",
";",
"}"
] |
Unregister the ServiceInstance in Callback.
@param serviceName
the service name.
@param instanceId
the instanceId.
@param cb
the Callback.
@param context
the Callback context object.
|
[
"Unregister",
"the",
"ServiceInstance",
"in",
"Callback",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java#L659-L674
|
155,156
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java
|
DirectoryServiceClient.getService
|
public ModelService getService(String serviceName, Watcher watcher){
WatcherRegistration wcb = null;
if (watcher != null) {
wcb = new WatcherRegistration(serviceName, watcher);
}
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.GetService);
GetServiceProtocol p = new GetServiceProtocol(serviceName);
p.setWatcher(watcher != null);
GetServiceResponse resp ;
resp = (GetServiceResponse) connection.submitRequest(header, p, wcb);
return resp.getService();
}
|
java
|
public ModelService getService(String serviceName, Watcher watcher){
WatcherRegistration wcb = null;
if (watcher != null) {
wcb = new WatcherRegistration(serviceName, watcher);
}
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.GetService);
GetServiceProtocol p = new GetServiceProtocol(serviceName);
p.setWatcher(watcher != null);
GetServiceResponse resp ;
resp = (GetServiceResponse) connection.submitRequest(header, p, wcb);
return resp.getService();
}
|
[
"public",
"ModelService",
"getService",
"(",
"String",
"serviceName",
",",
"Watcher",
"watcher",
")",
"{",
"WatcherRegistration",
"wcb",
"=",
"null",
";",
"if",
"(",
"watcher",
"!=",
"null",
")",
"{",
"wcb",
"=",
"new",
"WatcherRegistration",
"(",
"serviceName",
",",
"watcher",
")",
";",
"}",
"ProtocolHeader",
"header",
"=",
"new",
"ProtocolHeader",
"(",
")",
";",
"header",
".",
"setType",
"(",
"ProtocolType",
".",
"GetService",
")",
";",
"GetServiceProtocol",
"p",
"=",
"new",
"GetServiceProtocol",
"(",
"serviceName",
")",
";",
"p",
".",
"setWatcher",
"(",
"watcher",
"!=",
"null",
")",
";",
"GetServiceResponse",
"resp",
";",
"resp",
"=",
"(",
"GetServiceResponse",
")",
"connection",
".",
"submitRequest",
"(",
"header",
",",
"p",
",",
"wcb",
")",
";",
"return",
"resp",
".",
"getService",
"(",
")",
";",
"}"
] |
Get the Service.
@param serviceName
the serviceName.
@param watcher
the Watcher.
@return
the ModelService.
|
[
"Get",
"the",
"Service",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java#L686-L700
|
155,157
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java
|
DirectoryServiceClient.getService
|
public void getService(String serviceName, final GetServiceCallback cb, Object context){
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.GetService);
GetServiceProtocol p = new GetServiceProtocol(serviceName);
p.setWatcher(false);
ProtocolCallback pcb = new ProtocolCallback(){
@Override
public void call(boolean result, Response response,
ErrorCode error, Object ctx) {
ModelService rsp = null;
if(response != null){
rsp = ((GetServiceResponse) response).getService();
}
cb.call(result, rsp, error, ctx);
}
};
connection.submitCallbackRequest(header, p, pcb, context);
}
|
java
|
public void getService(String serviceName, final GetServiceCallback cb, Object context){
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.GetService);
GetServiceProtocol p = new GetServiceProtocol(serviceName);
p.setWatcher(false);
ProtocolCallback pcb = new ProtocolCallback(){
@Override
public void call(boolean result, Response response,
ErrorCode error, Object ctx) {
ModelService rsp = null;
if(response != null){
rsp = ((GetServiceResponse) response).getService();
}
cb.call(result, rsp, error, ctx);
}
};
connection.submitCallbackRequest(header, p, pcb, context);
}
|
[
"public",
"void",
"getService",
"(",
"String",
"serviceName",
",",
"final",
"GetServiceCallback",
"cb",
",",
"Object",
"context",
")",
"{",
"ProtocolHeader",
"header",
"=",
"new",
"ProtocolHeader",
"(",
")",
";",
"header",
".",
"setType",
"(",
"ProtocolType",
".",
"GetService",
")",
";",
"GetServiceProtocol",
"p",
"=",
"new",
"GetServiceProtocol",
"(",
"serviceName",
")",
";",
"p",
".",
"setWatcher",
"(",
"false",
")",
";",
"ProtocolCallback",
"pcb",
"=",
"new",
"ProtocolCallback",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"call",
"(",
"boolean",
"result",
",",
"Response",
"response",
",",
"ErrorCode",
"error",
",",
"Object",
"ctx",
")",
"{",
"ModelService",
"rsp",
"=",
"null",
";",
"if",
"(",
"response",
"!=",
"null",
")",
"{",
"rsp",
"=",
"(",
"(",
"GetServiceResponse",
")",
"response",
")",
".",
"getService",
"(",
")",
";",
"}",
"cb",
".",
"call",
"(",
"result",
",",
"rsp",
",",
"error",
",",
"ctx",
")",
";",
"}",
"}",
";",
"connection",
".",
"submitCallbackRequest",
"(",
"header",
",",
"p",
",",
"pcb",
",",
"context",
")",
";",
"}"
] |
Get Service in Callback.
@param serviceName
the serviceName.
@param cb
the Callback.
@param context
the callback context object.
|
[
"Get",
"Service",
"in",
"Callback",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java#L712-L734
|
155,158
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java
|
DirectoryServiceClient.asyncGetService
|
public ServiceDirectoryFuture asyncGetService(String serviceName, Watcher watcher){
WatcherRegistration wcb = null;
if (watcher != null) {
wcb = new WatcherRegistration(serviceName, watcher);
}
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.GetService);
GetServiceProtocol p = new GetServiceProtocol(serviceName);
p.setWatcher(false);
return connection.submitAsyncRequest(header, p, wcb);
}
|
java
|
public ServiceDirectoryFuture asyncGetService(String serviceName, Watcher watcher){
WatcherRegistration wcb = null;
if (watcher != null) {
wcb = new WatcherRegistration(serviceName, watcher);
}
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.GetService);
GetServiceProtocol p = new GetServiceProtocol(serviceName);
p.setWatcher(false);
return connection.submitAsyncRequest(header, p, wcb);
}
|
[
"public",
"ServiceDirectoryFuture",
"asyncGetService",
"(",
"String",
"serviceName",
",",
"Watcher",
"watcher",
")",
"{",
"WatcherRegistration",
"wcb",
"=",
"null",
";",
"if",
"(",
"watcher",
"!=",
"null",
")",
"{",
"wcb",
"=",
"new",
"WatcherRegistration",
"(",
"serviceName",
",",
"watcher",
")",
";",
"}",
"ProtocolHeader",
"header",
"=",
"new",
"ProtocolHeader",
"(",
")",
";",
"header",
".",
"setType",
"(",
"ProtocolType",
".",
"GetService",
")",
";",
"GetServiceProtocol",
"p",
"=",
"new",
"GetServiceProtocol",
"(",
"serviceName",
")",
";",
"p",
".",
"setWatcher",
"(",
"false",
")",
";",
"return",
"connection",
".",
"submitAsyncRequest",
"(",
"header",
",",
"p",
",",
"wcb",
")",
";",
"}"
] |
Asynchronized get Service.
@param serviceName
the service name.
@param watcher
the watcher.
@return
the ServiceDirectoryFuture
|
[
"Asynchronized",
"get",
"Service",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java#L746-L758
|
155,159
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java
|
DirectoryServiceClient.getAllInstances
|
public List<ModelServiceInstance> getAllInstances(){
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.GetAllServices);
GetAllServicesResponse resp = (GetAllServicesResponse) connection.submitRequest(header, null, null);
return resp.getInstances();
}
|
java
|
public List<ModelServiceInstance> getAllInstances(){
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.GetAllServices);
GetAllServicesResponse resp = (GetAllServicesResponse) connection.submitRequest(header, null, null);
return resp.getInstances();
}
|
[
"public",
"List",
"<",
"ModelServiceInstance",
">",
"getAllInstances",
"(",
")",
"{",
"ProtocolHeader",
"header",
"=",
"new",
"ProtocolHeader",
"(",
")",
";",
"header",
".",
"setType",
"(",
"ProtocolType",
".",
"GetAllServices",
")",
";",
"GetAllServicesResponse",
"resp",
"=",
"(",
"GetAllServicesResponse",
")",
"connection",
".",
"submitRequest",
"(",
"header",
",",
"null",
",",
"null",
")",
";",
"return",
"resp",
".",
"getInstances",
"(",
")",
";",
"}"
] |
Get All ModelServiceInstance in the ServiceDirectory.
@return
the ModelServiceInstance List.
|
[
"Get",
"All",
"ModelServiceInstance",
"in",
"the",
"ServiceDirectory",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java#L766-L772
|
155,160
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java
|
DirectoryServiceClient.queryService
|
public List<ModelServiceInstance> queryService(List<StringCommand> commands){
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.QueryService);
List<QueryCommand> cs = new ArrayList<QueryCommand>();
for(StringCommand c : commands){
cs.add(c.getStringCommand());
}
QueryServiceProtocol p = new QueryServiceProtocol(cs);
QueryServiceResponse resp ;
resp = (QueryServiceResponse) connection.submitRequest(header, p, null);
return resp.getInstances();
}
|
java
|
public List<ModelServiceInstance> queryService(List<StringCommand> commands){
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.QueryService);
List<QueryCommand> cs = new ArrayList<QueryCommand>();
for(StringCommand c : commands){
cs.add(c.getStringCommand());
}
QueryServiceProtocol p = new QueryServiceProtocol(cs);
QueryServiceResponse resp ;
resp = (QueryServiceResponse) connection.submitRequest(header, p, null);
return resp.getInstances();
}
|
[
"public",
"List",
"<",
"ModelServiceInstance",
">",
"queryService",
"(",
"List",
"<",
"StringCommand",
">",
"commands",
")",
"{",
"ProtocolHeader",
"header",
"=",
"new",
"ProtocolHeader",
"(",
")",
";",
"header",
".",
"setType",
"(",
"ProtocolType",
".",
"QueryService",
")",
";",
"List",
"<",
"QueryCommand",
">",
"cs",
"=",
"new",
"ArrayList",
"<",
"QueryCommand",
">",
"(",
")",
";",
"for",
"(",
"StringCommand",
"c",
":",
"commands",
")",
"{",
"cs",
".",
"add",
"(",
"c",
".",
"getStringCommand",
"(",
")",
")",
";",
"}",
"QueryServiceProtocol",
"p",
"=",
"new",
"QueryServiceProtocol",
"(",
"cs",
")",
";",
"QueryServiceResponse",
"resp",
";",
"resp",
"=",
"(",
"QueryServiceResponse",
")",
"connection",
".",
"submitRequest",
"(",
"header",
",",
"p",
",",
"null",
")",
";",
"return",
"resp",
".",
"getInstances",
"(",
")",
";",
"}"
] |
Query Service.
it is the synchronized method.
@param commands
the StringCommand list.
@return
the ModelServiceInstance list.
|
[
"Query",
"Service",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java#L820-L834
|
155,161
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java
|
DirectoryServiceClient.queryService
|
public void queryService(List<StringCommand> commands, final QueryServiceCallback cb, Object context){
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.QueryService);
List<QueryCommand> cs = new ArrayList<QueryCommand>();
for(StringCommand c : commands){
cs.add(c.getStringCommand());
}
QueryServiceProtocol p = new QueryServiceProtocol(cs);
ProtocolCallback pcb = new ProtocolCallback(){
@Override
public void call(boolean result, Response response,
ErrorCode error, Object ctx) {
List<ModelServiceInstance> rsp = null;
if(response != null){
rsp = ((QueryServiceResponse) response).getInstances();
}
cb.call(result, rsp, error, ctx);
}
};
connection.submitCallbackRequest(header, p, pcb, context);
}
|
java
|
public void queryService(List<StringCommand> commands, final QueryServiceCallback cb, Object context){
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.QueryService);
List<QueryCommand> cs = new ArrayList<QueryCommand>();
for(StringCommand c : commands){
cs.add(c.getStringCommand());
}
QueryServiceProtocol p = new QueryServiceProtocol(cs);
ProtocolCallback pcb = new ProtocolCallback(){
@Override
public void call(boolean result, Response response,
ErrorCode error, Object ctx) {
List<ModelServiceInstance> rsp = null;
if(response != null){
rsp = ((QueryServiceResponse) response).getInstances();
}
cb.call(result, rsp, error, ctx);
}
};
connection.submitCallbackRequest(header, p, pcb, context);
}
|
[
"public",
"void",
"queryService",
"(",
"List",
"<",
"StringCommand",
">",
"commands",
",",
"final",
"QueryServiceCallback",
"cb",
",",
"Object",
"context",
")",
"{",
"ProtocolHeader",
"header",
"=",
"new",
"ProtocolHeader",
"(",
")",
";",
"header",
".",
"setType",
"(",
"ProtocolType",
".",
"QueryService",
")",
";",
"List",
"<",
"QueryCommand",
">",
"cs",
"=",
"new",
"ArrayList",
"<",
"QueryCommand",
">",
"(",
")",
";",
"for",
"(",
"StringCommand",
"c",
":",
"commands",
")",
"{",
"cs",
".",
"add",
"(",
"c",
".",
"getStringCommand",
"(",
")",
")",
";",
"}",
"QueryServiceProtocol",
"p",
"=",
"new",
"QueryServiceProtocol",
"(",
"cs",
")",
";",
"ProtocolCallback",
"pcb",
"=",
"new",
"ProtocolCallback",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"call",
"(",
"boolean",
"result",
",",
"Response",
"response",
",",
"ErrorCode",
"error",
",",
"Object",
"ctx",
")",
"{",
"List",
"<",
"ModelServiceInstance",
">",
"rsp",
"=",
"null",
";",
"if",
"(",
"response",
"!=",
"null",
")",
"{",
"rsp",
"=",
"(",
"(",
"QueryServiceResponse",
")",
"response",
")",
".",
"getInstances",
"(",
")",
";",
"}",
"cb",
".",
"call",
"(",
"result",
",",
"rsp",
",",
"error",
",",
"ctx",
")",
";",
"}",
"}",
";",
"connection",
".",
"submitCallbackRequest",
"(",
"header",
",",
"p",
",",
"pcb",
",",
"context",
")",
";",
"}"
] |
Query service in Callback.
@param commands
the StringCommand list.
@param cb
the Callback.
@param context
the Callback context object.
|
[
"Query",
"service",
"in",
"Callback",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java#L846-L872
|
155,162
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java
|
DirectoryServiceClient.asyncQueryService
|
public ServiceDirectoryFuture asyncQueryService(List<StringCommand> commands){
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.QueryService);
List<QueryCommand> cs = new ArrayList<QueryCommand>();
for(StringCommand c : commands){
cs.add(c.getStringCommand());
}
QueryServiceProtocol p = new QueryServiceProtocol(cs);
return connection.submitAsyncRequest(header, p, null);
}
|
java
|
public ServiceDirectoryFuture asyncQueryService(List<StringCommand> commands){
ProtocolHeader header = new ProtocolHeader();
header.setType(ProtocolType.QueryService);
List<QueryCommand> cs = new ArrayList<QueryCommand>();
for(StringCommand c : commands){
cs.add(c.getStringCommand());
}
QueryServiceProtocol p = new QueryServiceProtocol(cs);
return connection.submitAsyncRequest(header, p, null);
}
|
[
"public",
"ServiceDirectoryFuture",
"asyncQueryService",
"(",
"List",
"<",
"StringCommand",
">",
"commands",
")",
"{",
"ProtocolHeader",
"header",
"=",
"new",
"ProtocolHeader",
"(",
")",
";",
"header",
".",
"setType",
"(",
"ProtocolType",
".",
"QueryService",
")",
";",
"List",
"<",
"QueryCommand",
">",
"cs",
"=",
"new",
"ArrayList",
"<",
"QueryCommand",
">",
"(",
")",
";",
"for",
"(",
"StringCommand",
"c",
":",
"commands",
")",
"{",
"cs",
".",
"add",
"(",
"c",
".",
"getStringCommand",
"(",
")",
")",
";",
"}",
"QueryServiceProtocol",
"p",
"=",
"new",
"QueryServiceProtocol",
"(",
"cs",
")",
";",
"return",
"connection",
".",
"submitAsyncRequest",
"(",
"header",
",",
"p",
",",
"null",
")",
";",
"}"
] |
Asynchronized query service.
@param commands
the StringCommand list.
@return
the ServiceDirectoryFuture.
|
[
"Asynchronized",
"query",
"service",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java#L882-L893
|
155,163
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java
|
DirectoryServiceClient.close
|
public void close(){
if(connection != null){
try {
connection.close();
} catch (IOException e) {
LOGGER.warn("Close the DirectoryConnection get exception - " + e.getMessage());
}
connection = null;
}
if(watcherManager != null){
watcherManager.cleanup();
watcherManager = null;
}
}
|
java
|
public void close(){
if(connection != null){
try {
connection.close();
} catch (IOException e) {
LOGGER.warn("Close the DirectoryConnection get exception - " + e.getMessage());
}
connection = null;
}
if(watcherManager != null){
watcherManager.cleanup();
watcherManager = null;
}
}
|
[
"public",
"void",
"close",
"(",
")",
"{",
"if",
"(",
"connection",
"!=",
"null",
")",
"{",
"try",
"{",
"connection",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"LOGGER",
".",
"warn",
"(",
"\"Close the DirectoryConnection get exception - \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"connection",
"=",
"null",
";",
"}",
"if",
"(",
"watcherManager",
"!=",
"null",
")",
"{",
"watcherManager",
".",
"cleanup",
"(",
")",
";",
"watcherManager",
"=",
"null",
";",
"}",
"}"
] |
Close the DirectoryServiceClient.
|
[
"Close",
"the",
"DirectoryServiceClient",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java#L918-L931
|
155,164
|
foundation-runtime/service-directory
|
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java
|
DirectoryServiceClient.getDirectorySocket
|
private DirectorySocket getDirectorySocket(){
DirectorySocket socket = null;
if(ServiceDirectory.getServiceDirectoryConfig().containsProperty(SD_API_DIRECTORY_SOCKET_PROVIDER_PROPERTY)){
String provider = ServiceDirectory.getServiceDirectoryConfig().getString(SD_API_DIRECTORY_SOCKET_PROVIDER_PROPERTY);
try{
Class<?> provideClass = Class.forName(provider);
if (DirectorySocket.class
.isAssignableFrom(provideClass)) {
socket = (DirectorySocket) provideClass.newInstance();
}
}catch(Exception e){
LOGGER.warn("fail to initialize the DirectorySocket provider - " + provider, e);
}
}
if(socket == null){
return new WSDirectorySocket();
}else {
return socket;
}
}
|
java
|
private DirectorySocket getDirectorySocket(){
DirectorySocket socket = null;
if(ServiceDirectory.getServiceDirectoryConfig().containsProperty(SD_API_DIRECTORY_SOCKET_PROVIDER_PROPERTY)){
String provider = ServiceDirectory.getServiceDirectoryConfig().getString(SD_API_DIRECTORY_SOCKET_PROVIDER_PROPERTY);
try{
Class<?> provideClass = Class.forName(provider);
if (DirectorySocket.class
.isAssignableFrom(provideClass)) {
socket = (DirectorySocket) provideClass.newInstance();
}
}catch(Exception e){
LOGGER.warn("fail to initialize the DirectorySocket provider - " + provider, e);
}
}
if(socket == null){
return new WSDirectorySocket();
}else {
return socket;
}
}
|
[
"private",
"DirectorySocket",
"getDirectorySocket",
"(",
")",
"{",
"DirectorySocket",
"socket",
"=",
"null",
";",
"if",
"(",
"ServiceDirectory",
".",
"getServiceDirectoryConfig",
"(",
")",
".",
"containsProperty",
"(",
"SD_API_DIRECTORY_SOCKET_PROVIDER_PROPERTY",
")",
")",
"{",
"String",
"provider",
"=",
"ServiceDirectory",
".",
"getServiceDirectoryConfig",
"(",
")",
".",
"getString",
"(",
"SD_API_DIRECTORY_SOCKET_PROVIDER_PROPERTY",
")",
";",
"try",
"{",
"Class",
"<",
"?",
">",
"provideClass",
"=",
"Class",
".",
"forName",
"(",
"provider",
")",
";",
"if",
"(",
"DirectorySocket",
".",
"class",
".",
"isAssignableFrom",
"(",
"provideClass",
")",
")",
"{",
"socket",
"=",
"(",
"DirectorySocket",
")",
"provideClass",
".",
"newInstance",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOGGER",
".",
"warn",
"(",
"\"fail to initialize the DirectorySocket provider - \"",
"+",
"provider",
",",
"e",
")",
";",
"}",
"}",
"if",
"(",
"socket",
"==",
"null",
")",
"{",
"return",
"new",
"WSDirectorySocket",
"(",
")",
";",
"}",
"else",
"{",
"return",
"socket",
";",
"}",
"}"
] |
Get the DirectorySoeckt.
@return
the DirectorySocket.
|
[
"Get",
"the",
"DirectorySoeckt",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java#L939-L959
|
155,165
|
gnagy/webhejj-commons
|
src/main/java/hu/webhejj/commons/beans/PropertyChangeSupport.java
|
PropertyChangeSupport.addPropertyChangeListener
|
public synchronized void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
if(!ArrayUtils.contains(listener, getPropertyChangeListeners(propertyName))) {
super.addPropertyChangeListener(propertyName, listener);
}
}
|
java
|
public synchronized void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
if(!ArrayUtils.contains(listener, getPropertyChangeListeners(propertyName))) {
super.addPropertyChangeListener(propertyName, listener);
}
}
|
[
"public",
"synchronized",
"void",
"addPropertyChangeListener",
"(",
"String",
"propertyName",
",",
"PropertyChangeListener",
"listener",
")",
"{",
"if",
"(",
"!",
"ArrayUtils",
".",
"contains",
"(",
"listener",
",",
"getPropertyChangeListeners",
"(",
"propertyName",
")",
")",
")",
"{",
"super",
".",
"addPropertyChangeListener",
"(",
"propertyName",
",",
"listener",
")",
";",
"}",
"}"
] |
add listener if not already added to property
|
[
"add",
"listener",
"if",
"not",
"already",
"added",
"to",
"property"
] |
270bc6f111ec5761af31d39bd38c40fd914d2eba
|
https://github.com/gnagy/webhejj-commons/blob/270bc6f111ec5761af31d39bd38c40fd914d2eba/src/main/java/hu/webhejj/commons/beans/PropertyChangeSupport.java#L37-L41
|
155,166
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/util/data/SerialArrayList.java
|
SerialArrayList.add
|
public SerialArrayList<U> add(SerialArrayList<U> right) {
return new SerialArrayList<U>(factory, this, right);
}
|
java
|
public SerialArrayList<U> add(SerialArrayList<U> right) {
return new SerialArrayList<U>(factory, this, right);
}
|
[
"public",
"SerialArrayList",
"<",
"U",
">",
"add",
"(",
"SerialArrayList",
"<",
"U",
">",
"right",
")",
"{",
"return",
"new",
"SerialArrayList",
"<",
"U",
">",
"(",
"factory",
",",
"this",
",",
"right",
")",
";",
"}"
] |
Add serial array list.
@param right the right
@return the serial array list
|
[
"Add",
"serial",
"array",
"list",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/data/SerialArrayList.java#L117-L119
|
155,167
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/util/data/SerialArrayList.java
|
SerialArrayList.get
|
public U get(int i) {
ByteBuffer view = getView(i);
try {
return factory.read(view);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
|
java
|
public U get(int i) {
ByteBuffer view = getView(i);
try {
return factory.read(view);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
|
[
"public",
"U",
"get",
"(",
"int",
"i",
")",
"{",
"ByteBuffer",
"view",
"=",
"getView",
"(",
"i",
")",
";",
"try",
"{",
"return",
"factory",
".",
"read",
"(",
"view",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}"
] |
Get u.
@param i the
@return the u
|
[
"Get",
"u",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/data/SerialArrayList.java#L144-L151
|
155,168
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/util/data/SerialArrayList.java
|
SerialArrayList.update
|
public synchronized U update(int i, Function<U, U> updater) {
U updated = updater.apply(this.get(i));
set(i, updated);
return updated;
}
|
java
|
public synchronized U update(int i, Function<U, U> updater) {
U updated = updater.apply(this.get(i));
set(i, updated);
return updated;
}
|
[
"public",
"synchronized",
"U",
"update",
"(",
"int",
"i",
",",
"Function",
"<",
"U",
",",
"U",
">",
"updater",
")",
"{",
"U",
"updated",
"=",
"updater",
".",
"apply",
"(",
"this",
".",
"get",
"(",
"i",
")",
")",
";",
"set",
"(",
"i",
",",
"updated",
")",
";",
"return",
"updated",
";",
"}"
] |
Update u.
@param i the
@param updater the updater
@return the u
|
[
"Update",
"u",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/data/SerialArrayList.java#L172-L176
|
155,169
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/util/data/SerialArrayList.java
|
SerialArrayList.addAll
|
public synchronized int addAll(Collection<U> data) {
int startIndex = length();
putAll(data, startIndex);
return startIndex;
}
|
java
|
public synchronized int addAll(Collection<U> data) {
int startIndex = length();
putAll(data, startIndex);
return startIndex;
}
|
[
"public",
"synchronized",
"int",
"addAll",
"(",
"Collection",
"<",
"U",
">",
"data",
")",
"{",
"int",
"startIndex",
"=",
"length",
"(",
")",
";",
"putAll",
"(",
"data",
",",
"startIndex",
")",
";",
"return",
"startIndex",
";",
"}"
] |
Add all int.
@param data the data
@return the int
|
[
"Add",
"all",
"int",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/data/SerialArrayList.java#L217-L221
|
155,170
|
james-hu/jabb-core
|
src/main/java/net/sf/jabb/web/action/VfsTreeAction.java
|
VfsTreeAction.populateTreeNodeData
|
protected JsTreeNodeData populateTreeNodeData(FileObject root, FileObject file) throws FileSystemException {
boolean noChild = true;
FileType type = file.getType();
if (type.equals(FileType.FOLDER) || type.equals(FileType.FILE_OR_FOLDER)){
noChild = file.getChildren().length == 0;
}
String relativePath = root.getName().getRelativeName(file.getName());
return populateTreeNodeData(file, noChild, relativePath);
}
|
java
|
protected JsTreeNodeData populateTreeNodeData(FileObject root, FileObject file) throws FileSystemException {
boolean noChild = true;
FileType type = file.getType();
if (type.equals(FileType.FOLDER) || type.equals(FileType.FILE_OR_FOLDER)){
noChild = file.getChildren().length == 0;
}
String relativePath = root.getName().getRelativeName(file.getName());
return populateTreeNodeData(file, noChild, relativePath);
}
|
[
"protected",
"JsTreeNodeData",
"populateTreeNodeData",
"(",
"FileObject",
"root",
",",
"FileObject",
"file",
")",
"throws",
"FileSystemException",
"{",
"boolean",
"noChild",
"=",
"true",
";",
"FileType",
"type",
"=",
"file",
".",
"getType",
"(",
")",
";",
"if",
"(",
"type",
".",
"equals",
"(",
"FileType",
".",
"FOLDER",
")",
"||",
"type",
".",
"equals",
"(",
"FileType",
".",
"FILE_OR_FOLDER",
")",
")",
"{",
"noChild",
"=",
"file",
".",
"getChildren",
"(",
")",
".",
"length",
"==",
"0",
";",
"}",
"String",
"relativePath",
"=",
"root",
".",
"getName",
"(",
")",
".",
"getRelativeName",
"(",
"file",
".",
"getName",
"(",
")",
")",
";",
"return",
"populateTreeNodeData",
"(",
"file",
",",
"noChild",
",",
"relativePath",
")",
";",
"}"
] |
Populate a node.
@param root Relative root directory.
@param file The file object.
@return The node data structure which presents the file.
@throws FileSystemException
|
[
"Populate",
"a",
"node",
"."
] |
bceed441595c5e5195a7418795f03b69fa7b61e4
|
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/web/action/VfsTreeAction.java#L137-L145
|
155,171
|
james-hu/jabb-core
|
src/main/java/net/sf/jabb/web/action/VfsTreeAction.java
|
VfsTreeAction.populateTreeNodeData
|
protected JsTreeNodeData populateTreeNodeData(FileObject file, boolean noChild, String relativePath) throws FileSystemException {
JsTreeNodeData node = new JsTreeNodeData();
String baseName = file.getName().getBaseName();
FileContent content = file.getContent();
FileType type = file.getType();
node.setData(baseName);
Map<String, Object> attr = new HashMap<String, Object>();
node.setAttr(attr);
attr.put("id", relativePath);
attr.put("rel", type.getName());
attr.put("fileType", type.getName());
if (content != null){
long fileLastModifiedTime = file.getContent().getLastModifiedTime();
attr.put("fileLastModifiedTime", fileLastModifiedTime);
attr.put("fileLastModifiedTimeForDisplay", DateFormat.getDateTimeInstance().format(new Date(fileLastModifiedTime)));
if (file.getType() != FileType.FOLDER){
attr.put("fileSize", content.getSize());
attr.put("fileSizeForDisplay", FileUtils.byteCountToDisplaySize(content.getSize()));
}
}
// these fields should not appear in JSON for leaf nodes
if (!noChild){
node.setState(JsTreeNodeData.STATE_CLOSED);
}
return node;
}
|
java
|
protected JsTreeNodeData populateTreeNodeData(FileObject file, boolean noChild, String relativePath) throws FileSystemException {
JsTreeNodeData node = new JsTreeNodeData();
String baseName = file.getName().getBaseName();
FileContent content = file.getContent();
FileType type = file.getType();
node.setData(baseName);
Map<String, Object> attr = new HashMap<String, Object>();
node.setAttr(attr);
attr.put("id", relativePath);
attr.put("rel", type.getName());
attr.put("fileType", type.getName());
if (content != null){
long fileLastModifiedTime = file.getContent().getLastModifiedTime();
attr.put("fileLastModifiedTime", fileLastModifiedTime);
attr.put("fileLastModifiedTimeForDisplay", DateFormat.getDateTimeInstance().format(new Date(fileLastModifiedTime)));
if (file.getType() != FileType.FOLDER){
attr.put("fileSize", content.getSize());
attr.put("fileSizeForDisplay", FileUtils.byteCountToDisplaySize(content.getSize()));
}
}
// these fields should not appear in JSON for leaf nodes
if (!noChild){
node.setState(JsTreeNodeData.STATE_CLOSED);
}
return node;
}
|
[
"protected",
"JsTreeNodeData",
"populateTreeNodeData",
"(",
"FileObject",
"file",
",",
"boolean",
"noChild",
",",
"String",
"relativePath",
")",
"throws",
"FileSystemException",
"{",
"JsTreeNodeData",
"node",
"=",
"new",
"JsTreeNodeData",
"(",
")",
";",
"String",
"baseName",
"=",
"file",
".",
"getName",
"(",
")",
".",
"getBaseName",
"(",
")",
";",
"FileContent",
"content",
"=",
"file",
".",
"getContent",
"(",
")",
";",
"FileType",
"type",
"=",
"file",
".",
"getType",
"(",
")",
";",
"node",
".",
"setData",
"(",
"baseName",
")",
";",
"Map",
"<",
"String",
",",
"Object",
">",
"attr",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"node",
".",
"setAttr",
"(",
"attr",
")",
";",
"attr",
".",
"put",
"(",
"\"id\"",
",",
"relativePath",
")",
";",
"attr",
".",
"put",
"(",
"\"rel\"",
",",
"type",
".",
"getName",
"(",
")",
")",
";",
"attr",
".",
"put",
"(",
"\"fileType\"",
",",
"type",
".",
"getName",
"(",
")",
")",
";",
"if",
"(",
"content",
"!=",
"null",
")",
"{",
"long",
"fileLastModifiedTime",
"=",
"file",
".",
"getContent",
"(",
")",
".",
"getLastModifiedTime",
"(",
")",
";",
"attr",
".",
"put",
"(",
"\"fileLastModifiedTime\"",
",",
"fileLastModifiedTime",
")",
";",
"attr",
".",
"put",
"(",
"\"fileLastModifiedTimeForDisplay\"",
",",
"DateFormat",
".",
"getDateTimeInstance",
"(",
")",
".",
"format",
"(",
"new",
"Date",
"(",
"fileLastModifiedTime",
")",
")",
")",
";",
"if",
"(",
"file",
".",
"getType",
"(",
")",
"!=",
"FileType",
".",
"FOLDER",
")",
"{",
"attr",
".",
"put",
"(",
"\"fileSize\"",
",",
"content",
".",
"getSize",
"(",
")",
")",
";",
"attr",
".",
"put",
"(",
"\"fileSizeForDisplay\"",
",",
"FileUtils",
".",
"byteCountToDisplaySize",
"(",
"content",
".",
"getSize",
"(",
")",
")",
")",
";",
"}",
"}",
"// these fields should not appear in JSON for leaf nodes\r",
"if",
"(",
"!",
"noChild",
")",
"{",
"node",
".",
"setState",
"(",
"JsTreeNodeData",
".",
"STATE_CLOSED",
")",
";",
"}",
"return",
"node",
";",
"}"
] |
It transforms FileObject into JsTreeNodeData.
@param file the file whose information will be encapsulated in the node data structure.
@return The node data structure which presents the file.
@throws FileSystemException
|
[
"It",
"transforms",
"FileObject",
"into",
"JsTreeNodeData",
"."
] |
bceed441595c5e5195a7418795f03b69fa7b61e4
|
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/web/action/VfsTreeAction.java#L152-L181
|
155,172
|
steveash/bushwhacker
|
bushwhacker/src/main/java/com/github/steveash/bushwhacker/rules/HandlerMaker.java
|
HandlerMaker.buildHandlersFor
|
public CompositeExceptionHandler buildHandlersFor(XmlRules rules) {
ImmutableList.Builder<RuleExceptionHandler> builder = ImmutableList.builder();
for (XmlRules.ExceptionRule rule : rules.getExceptionRules()) {
builder.add(buildHandlerFor(rule));
}
return new CompositeExceptionHandler(builder.build());
}
|
java
|
public CompositeExceptionHandler buildHandlersFor(XmlRules rules) {
ImmutableList.Builder<RuleExceptionHandler> builder = ImmutableList.builder();
for (XmlRules.ExceptionRule rule : rules.getExceptionRules()) {
builder.add(buildHandlerFor(rule));
}
return new CompositeExceptionHandler(builder.build());
}
|
[
"public",
"CompositeExceptionHandler",
"buildHandlersFor",
"(",
"XmlRules",
"rules",
")",
"{",
"ImmutableList",
".",
"Builder",
"<",
"RuleExceptionHandler",
">",
"builder",
"=",
"ImmutableList",
".",
"builder",
"(",
")",
";",
"for",
"(",
"XmlRules",
".",
"ExceptionRule",
"rule",
":",
"rules",
".",
"getExceptionRules",
"(",
")",
")",
"{",
"builder",
".",
"add",
"(",
"buildHandlerFor",
"(",
"rule",
")",
")",
";",
"}",
"return",
"new",
"CompositeExceptionHandler",
"(",
"builder",
".",
"build",
"(",
")",
")",
";",
"}"
] |
translate the xml rules in to specific predicates to return RuleExceHandler
|
[
"translate",
"the",
"xml",
"rules",
"in",
"to",
"specific",
"predicates",
"to",
"return",
"RuleExceHandler"
] |
93958dea1f4e1d881e863970fd12b857278813c1
|
https://github.com/steveash/bushwhacker/blob/93958dea1f4e1d881e863970fd12b857278813c1/bushwhacker/src/main/java/com/github/steveash/bushwhacker/rules/HandlerMaker.java#L27-L33
|
155,173
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/util/binary/bitset/CountTreeBitsCollection.java
|
CountTreeBitsCollection.computeSums
|
public TreeMap<Bits, Long> computeSums() {
final TreeMap<Bits, Long> sums = new TreeMap<Bits, Long>();
long total = 0;
for (final Entry<Bits, AtomicInteger> e : this.map.entrySet()) {
sums.put(e.getKey(), total += e.getValue().get());
}
return sums;
}
|
java
|
public TreeMap<Bits, Long> computeSums() {
final TreeMap<Bits, Long> sums = new TreeMap<Bits, Long>();
long total = 0;
for (final Entry<Bits, AtomicInteger> e : this.map.entrySet()) {
sums.put(e.getKey(), total += e.getValue().get());
}
return sums;
}
|
[
"public",
"TreeMap",
"<",
"Bits",
",",
"Long",
">",
"computeSums",
"(",
")",
"{",
"final",
"TreeMap",
"<",
"Bits",
",",
"Long",
">",
"sums",
"=",
"new",
"TreeMap",
"<",
"Bits",
",",
"Long",
">",
"(",
")",
";",
"long",
"total",
"=",
"0",
";",
"for",
"(",
"final",
"Entry",
"<",
"Bits",
",",
"AtomicInteger",
">",
"e",
":",
"this",
".",
"map",
".",
"entrySet",
"(",
")",
")",
"{",
"sums",
".",
"put",
"(",
"e",
".",
"getKey",
"(",
")",
",",
"total",
"+=",
"e",
".",
"getValue",
"(",
")",
".",
"get",
"(",
")",
")",
";",
"}",
"return",
"sums",
";",
"}"
] |
Compute sums tree run.
@return the tree run
|
[
"Compute",
"sums",
"tree",
"run",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/binary/bitset/CountTreeBitsCollection.java#L129-L136
|
155,174
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/util/binary/bitset/CountTreeBitsCollection.java
|
CountTreeBitsCollection.readBranchCounts
|
protected BranchCounts readBranchCounts(final BitInputStream in,
final Bits code, final long size) throws IOException {
final BranchCounts branchCounts = new BranchCounts(code, size);
final CodeType currentCodeType = this.getType(code);
long maximum = size;
// Get terminals
if (currentCodeType == CodeType.Unknown) {
branchCounts.terminals = this.readTerminalCount(in, maximum);
}
else if (currentCodeType == CodeType.Terminal) {
branchCounts.terminals = size;
}
else {
branchCounts.terminals = 0;
}
maximum -= branchCounts.terminals;
// Get zero-suffixed primary
if (maximum > 0) {
assert Thread.currentThread().getStackTrace().length < 100;
branchCounts.zeroCount = this.readZeroBranchSize(in, maximum, code);
}
maximum -= branchCounts.zeroCount;
branchCounts.oneCount = maximum;
return branchCounts;
}
|
java
|
protected BranchCounts readBranchCounts(final BitInputStream in,
final Bits code, final long size) throws IOException {
final BranchCounts branchCounts = new BranchCounts(code, size);
final CodeType currentCodeType = this.getType(code);
long maximum = size;
// Get terminals
if (currentCodeType == CodeType.Unknown) {
branchCounts.terminals = this.readTerminalCount(in, maximum);
}
else if (currentCodeType == CodeType.Terminal) {
branchCounts.terminals = size;
}
else {
branchCounts.terminals = 0;
}
maximum -= branchCounts.terminals;
// Get zero-suffixed primary
if (maximum > 0) {
assert Thread.currentThread().getStackTrace().length < 100;
branchCounts.zeroCount = this.readZeroBranchSize(in, maximum, code);
}
maximum -= branchCounts.zeroCount;
branchCounts.oneCount = maximum;
return branchCounts;
}
|
[
"protected",
"BranchCounts",
"readBranchCounts",
"(",
"final",
"BitInputStream",
"in",
",",
"final",
"Bits",
"code",
",",
"final",
"long",
"size",
")",
"throws",
"IOException",
"{",
"final",
"BranchCounts",
"branchCounts",
"=",
"new",
"BranchCounts",
"(",
"code",
",",
"size",
")",
";",
"final",
"CodeType",
"currentCodeType",
"=",
"this",
".",
"getType",
"(",
"code",
")",
";",
"long",
"maximum",
"=",
"size",
";",
"// Get terminals",
"if",
"(",
"currentCodeType",
"==",
"CodeType",
".",
"Unknown",
")",
"{",
"branchCounts",
".",
"terminals",
"=",
"this",
".",
"readTerminalCount",
"(",
"in",
",",
"maximum",
")",
";",
"}",
"else",
"if",
"(",
"currentCodeType",
"==",
"CodeType",
".",
"Terminal",
")",
"{",
"branchCounts",
".",
"terminals",
"=",
"size",
";",
"}",
"else",
"{",
"branchCounts",
".",
"terminals",
"=",
"0",
";",
"}",
"maximum",
"-=",
"branchCounts",
".",
"terminals",
";",
"// Get zero-suffixed primary",
"if",
"(",
"maximum",
">",
"0",
")",
"{",
"assert",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getStackTrace",
"(",
")",
".",
"length",
"<",
"100",
";",
"branchCounts",
".",
"zeroCount",
"=",
"this",
".",
"readZeroBranchSize",
"(",
"in",
",",
"maximum",
",",
"code",
")",
";",
"}",
"maximum",
"-=",
"branchCounts",
".",
"zeroCount",
";",
"branchCounts",
".",
"oneCount",
"=",
"maximum",
";",
"return",
"branchCounts",
";",
"}"
] |
Read branch counts branch counts.
@param in the in
@param code the code
@param size the size
@return the branch counts
@throws IOException the io exception
|
[
"Read",
"branch",
"counts",
"branch",
"counts",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/binary/bitset/CountTreeBitsCollection.java#L191-L217
|
155,175
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/util/binary/bitset/CountTreeBitsCollection.java
|
CountTreeBitsCollection.readTerminalCount
|
protected long readTerminalCount(final BitInputStream in, final long size)
throws IOException {
if (SERIALIZATION_CHECKS) {
in.expect(SerializationChecks.BeforeTerminal);
}
final long readBoundedLong = in.readBoundedLong(1 + size);
if (SERIALIZATION_CHECKS) {
in.expect(SerializationChecks.AfterTerminal);
}
return readBoundedLong;
}
|
java
|
protected long readTerminalCount(final BitInputStream in, final long size)
throws IOException {
if (SERIALIZATION_CHECKS) {
in.expect(SerializationChecks.BeforeTerminal);
}
final long readBoundedLong = in.readBoundedLong(1 + size);
if (SERIALIZATION_CHECKS) {
in.expect(SerializationChecks.AfterTerminal);
}
return readBoundedLong;
}
|
[
"protected",
"long",
"readTerminalCount",
"(",
"final",
"BitInputStream",
"in",
",",
"final",
"long",
"size",
")",
"throws",
"IOException",
"{",
"if",
"(",
"SERIALIZATION_CHECKS",
")",
"{",
"in",
".",
"expect",
"(",
"SerializationChecks",
".",
"BeforeTerminal",
")",
";",
"}",
"final",
"long",
"readBoundedLong",
"=",
"in",
".",
"readBoundedLong",
"(",
"1",
"+",
"size",
")",
";",
"if",
"(",
"SERIALIZATION_CHECKS",
")",
"{",
"in",
".",
"expect",
"(",
"SerializationChecks",
".",
"AfterTerminal",
")",
";",
"}",
"return",
"readBoundedLong",
";",
"}"
] |
Read terminal count long.
@param in the in
@param size the size
@return the long
@throws IOException the io exception
|
[
"Read",
"terminal",
"count",
"long",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/binary/bitset/CountTreeBitsCollection.java#L227-L237
|
155,176
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/util/binary/bitset/CountTreeBitsCollection.java
|
CountTreeBitsCollection.readZeroBranchSize
|
protected long readZeroBranchSize(final BitInputStream in, final long max,
final Bits code) throws IOException {
if (0 == max) {
return 0;
}
final long value;
if (SERIALIZATION_CHECKS) {
in.expect(SerializationChecks.BeforeCount);
}
if (this.useBinomials) {
value = Gaussian.fromBinomial(0.5, max).decode(in, max);
}
else {
value = in.readBoundedLong(1 + max);
}
if (SERIALIZATION_CHECKS) {
in.expect(SerializationChecks.AfterCount);
}
return value;
}
|
java
|
protected long readZeroBranchSize(final BitInputStream in, final long max,
final Bits code) throws IOException {
if (0 == max) {
return 0;
}
final long value;
if (SERIALIZATION_CHECKS) {
in.expect(SerializationChecks.BeforeCount);
}
if (this.useBinomials) {
value = Gaussian.fromBinomial(0.5, max).decode(in, max);
}
else {
value = in.readBoundedLong(1 + max);
}
if (SERIALIZATION_CHECKS) {
in.expect(SerializationChecks.AfterCount);
}
return value;
}
|
[
"protected",
"long",
"readZeroBranchSize",
"(",
"final",
"BitInputStream",
"in",
",",
"final",
"long",
"max",
",",
"final",
"Bits",
"code",
")",
"throws",
"IOException",
"{",
"if",
"(",
"0",
"==",
"max",
")",
"{",
"return",
"0",
";",
"}",
"final",
"long",
"value",
";",
"if",
"(",
"SERIALIZATION_CHECKS",
")",
"{",
"in",
".",
"expect",
"(",
"SerializationChecks",
".",
"BeforeCount",
")",
";",
"}",
"if",
"(",
"this",
".",
"useBinomials",
")",
"{",
"value",
"=",
"Gaussian",
".",
"fromBinomial",
"(",
"0.5",
",",
"max",
")",
".",
"decode",
"(",
"in",
",",
"max",
")",
";",
"}",
"else",
"{",
"value",
"=",
"in",
".",
"readBoundedLong",
"(",
"1",
"+",
"max",
")",
";",
"}",
"if",
"(",
"SERIALIZATION_CHECKS",
")",
"{",
"in",
".",
"expect",
"(",
"SerializationChecks",
".",
"AfterCount",
")",
";",
"}",
"return",
"value",
";",
"}"
] |
Read zero branch size long.
@param in the in
@param max the max
@param code the code
@return the long
@throws IOException the io exception
|
[
"Read",
"zero",
"branch",
"size",
"long",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/binary/bitset/CountTreeBitsCollection.java#L248-L267
|
155,177
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/util/binary/bitset/CountTreeBitsCollection.java
|
CountTreeBitsCollection.sum
|
public long sum(final Collection<Long> values) {
long total = 0;
for (final Long v : values) {
total += v;
}
return total;
}
|
java
|
public long sum(final Collection<Long> values) {
long total = 0;
for (final Long v : values) {
total += v;
}
return total;
}
|
[
"public",
"long",
"sum",
"(",
"final",
"Collection",
"<",
"Long",
">",
"values",
")",
"{",
"long",
"total",
"=",
"0",
";",
"for",
"(",
"final",
"Long",
"v",
":",
"values",
")",
"{",
"total",
"+=",
"v",
";",
"}",
"return",
"total",
";",
"}"
] |
Sum long.
@param values the values
@return the long
|
[
"Sum",
"long",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/binary/bitset/CountTreeBitsCollection.java#L286-L292
|
155,178
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/util/binary/bitset/CountTreeBitsCollection.java
|
CountTreeBitsCollection.writeBranchCounts
|
protected void writeBranchCounts(final BranchCounts branch,
final BitOutputStream out) throws IOException {
final CodeType currentCodeType = this.getType(branch.path);
long maximum = branch.size;
assert maximum >= branch.terminals;
if (currentCodeType == CodeType.Unknown) {
this.writeTerminalCount(out, branch.terminals, maximum);
}
else if (currentCodeType == CodeType.Terminal) {
assert branch.size == branch.terminals;
assert 0 == branch.zeroCount;
assert 0 == branch.oneCount;
}
else assert currentCodeType != CodeType.Prefix || 0 == branch.terminals;
maximum -= branch.terminals;
assert maximum >= branch.zeroCount;
if (0 < maximum) {
this.writeZeroBranchSize(out, branch.zeroCount, maximum, branch.path);
maximum -= branch.zeroCount;
}
else {
assert 0 == branch.zeroCount;
}
assert maximum == branch.oneCount;
}
|
java
|
protected void writeBranchCounts(final BranchCounts branch,
final BitOutputStream out) throws IOException {
final CodeType currentCodeType = this.getType(branch.path);
long maximum = branch.size;
assert maximum >= branch.terminals;
if (currentCodeType == CodeType.Unknown) {
this.writeTerminalCount(out, branch.terminals, maximum);
}
else if (currentCodeType == CodeType.Terminal) {
assert branch.size == branch.terminals;
assert 0 == branch.zeroCount;
assert 0 == branch.oneCount;
}
else assert currentCodeType != CodeType.Prefix || 0 == branch.terminals;
maximum -= branch.terminals;
assert maximum >= branch.zeroCount;
if (0 < maximum) {
this.writeZeroBranchSize(out, branch.zeroCount, maximum, branch.path);
maximum -= branch.zeroCount;
}
else {
assert 0 == branch.zeroCount;
}
assert maximum == branch.oneCount;
}
|
[
"protected",
"void",
"writeBranchCounts",
"(",
"final",
"BranchCounts",
"branch",
",",
"final",
"BitOutputStream",
"out",
")",
"throws",
"IOException",
"{",
"final",
"CodeType",
"currentCodeType",
"=",
"this",
".",
"getType",
"(",
"branch",
".",
"path",
")",
";",
"long",
"maximum",
"=",
"branch",
".",
"size",
";",
"assert",
"maximum",
">=",
"branch",
".",
"terminals",
";",
"if",
"(",
"currentCodeType",
"==",
"CodeType",
".",
"Unknown",
")",
"{",
"this",
".",
"writeTerminalCount",
"(",
"out",
",",
"branch",
".",
"terminals",
",",
"maximum",
")",
";",
"}",
"else",
"if",
"(",
"currentCodeType",
"==",
"CodeType",
".",
"Terminal",
")",
"{",
"assert",
"branch",
".",
"size",
"==",
"branch",
".",
"terminals",
";",
"assert",
"0",
"==",
"branch",
".",
"zeroCount",
";",
"assert",
"0",
"==",
"branch",
".",
"oneCount",
";",
"}",
"else",
"assert",
"currentCodeType",
"!=",
"CodeType",
".",
"Prefix",
"||",
"0",
"==",
"branch",
".",
"terminals",
";",
"maximum",
"-=",
"branch",
".",
"terminals",
";",
"assert",
"maximum",
">=",
"branch",
".",
"zeroCount",
";",
"if",
"(",
"0",
"<",
"maximum",
")",
"{",
"this",
".",
"writeZeroBranchSize",
"(",
"out",
",",
"branch",
".",
"zeroCount",
",",
"maximum",
",",
"branch",
".",
"path",
")",
";",
"maximum",
"-=",
"branch",
".",
"zeroCount",
";",
"}",
"else",
"{",
"assert",
"0",
"==",
"branch",
".",
"zeroCount",
";",
"}",
"assert",
"maximum",
"==",
"branch",
".",
"oneCount",
";",
"}"
] |
Write branch counts.
@param branch the branch
@param out the out
@throws IOException the io exception
|
[
"Write",
"branch",
"counts",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/binary/bitset/CountTreeBitsCollection.java#L407-L432
|
155,179
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/util/binary/bitset/CountTreeBitsCollection.java
|
CountTreeBitsCollection.writeTerminalCount
|
protected void writeTerminalCount(final BitOutputStream out,
final long value, final long max) throws IOException {
assert 0 <= value;
assert max >= value;
if (SERIALIZATION_CHECKS) {
out.write(SerializationChecks.BeforeTerminal);
}
out.writeBoundedLong(value, 1 + max);
if (SERIALIZATION_CHECKS) {
out.write(SerializationChecks.AfterTerminal);
}
}
|
java
|
protected void writeTerminalCount(final BitOutputStream out,
final long value, final long max) throws IOException {
assert 0 <= value;
assert max >= value;
if (SERIALIZATION_CHECKS) {
out.write(SerializationChecks.BeforeTerminal);
}
out.writeBoundedLong(value, 1 + max);
if (SERIALIZATION_CHECKS) {
out.write(SerializationChecks.AfterTerminal);
}
}
|
[
"protected",
"void",
"writeTerminalCount",
"(",
"final",
"BitOutputStream",
"out",
",",
"final",
"long",
"value",
",",
"final",
"long",
"max",
")",
"throws",
"IOException",
"{",
"assert",
"0",
"<=",
"value",
";",
"assert",
"max",
">=",
"value",
";",
"if",
"(",
"SERIALIZATION_CHECKS",
")",
"{",
"out",
".",
"write",
"(",
"SerializationChecks",
".",
"BeforeTerminal",
")",
";",
"}",
"out",
".",
"writeBoundedLong",
"(",
"value",
",",
"1",
"+",
"max",
")",
";",
"if",
"(",
"SERIALIZATION_CHECKS",
")",
"{",
"out",
".",
"write",
"(",
"SerializationChecks",
".",
"AfterTerminal",
")",
";",
"}",
"}"
] |
Write terminal count.
@param out the out
@param value the value
@param max the max
@throws IOException the io exception
|
[
"Write",
"terminal",
"count",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/binary/bitset/CountTreeBitsCollection.java#L442-L453
|
155,180
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/util/binary/bitset/CountTreeBitsCollection.java
|
CountTreeBitsCollection.writeZeroBranchSize
|
protected void writeZeroBranchSize(final BitOutputStream out,
final long value, final long max, final Bits bits) throws IOException {
assert 0 <= value;
assert max >= value;
if (SERIALIZATION_CHECKS) {
out.write(SerializationChecks.BeforeCount);
}
if (this.useBinomials) {
Gaussian.fromBinomial(0.5, max).encode(out, value, max);
}
else {
out.writeBoundedLong(value, 1 + max);
}
if (SERIALIZATION_CHECKS) {
out.write(SerializationChecks.AfterCount);
}
}
|
java
|
protected void writeZeroBranchSize(final BitOutputStream out,
final long value, final long max, final Bits bits) throws IOException {
assert 0 <= value;
assert max >= value;
if (SERIALIZATION_CHECKS) {
out.write(SerializationChecks.BeforeCount);
}
if (this.useBinomials) {
Gaussian.fromBinomial(0.5, max).encode(out, value, max);
}
else {
out.writeBoundedLong(value, 1 + max);
}
if (SERIALIZATION_CHECKS) {
out.write(SerializationChecks.AfterCount);
}
}
|
[
"protected",
"void",
"writeZeroBranchSize",
"(",
"final",
"BitOutputStream",
"out",
",",
"final",
"long",
"value",
",",
"final",
"long",
"max",
",",
"final",
"Bits",
"bits",
")",
"throws",
"IOException",
"{",
"assert",
"0",
"<=",
"value",
";",
"assert",
"max",
">=",
"value",
";",
"if",
"(",
"SERIALIZATION_CHECKS",
")",
"{",
"out",
".",
"write",
"(",
"SerializationChecks",
".",
"BeforeCount",
")",
";",
"}",
"if",
"(",
"this",
".",
"useBinomials",
")",
"{",
"Gaussian",
".",
"fromBinomial",
"(",
"0.5",
",",
"max",
")",
".",
"encode",
"(",
"out",
",",
"value",
",",
"max",
")",
";",
"}",
"else",
"{",
"out",
".",
"writeBoundedLong",
"(",
"value",
",",
"1",
"+",
"max",
")",
";",
"}",
"if",
"(",
"SERIALIZATION_CHECKS",
")",
"{",
"out",
".",
"write",
"(",
"SerializationChecks",
".",
"AfterCount",
")",
";",
"}",
"}"
] |
Write zero branch size.
@param out the out
@param value the value
@param max the max
@param bits the bits
@throws IOException the io exception
|
[
"Write",
"zero",
"branch",
"size",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/binary/bitset/CountTreeBitsCollection.java#L464-L480
|
155,181
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/text/CharTrieIndex.java
|
CharTrieIndex.indexWords
|
public static CharTrie indexWords(Collection<String> documents, int maxLevels, int minWeight) {
return create(documents, maxLevels, minWeight, true);
}
|
java
|
public static CharTrie indexWords(Collection<String> documents, int maxLevels, int minWeight) {
return create(documents, maxLevels, minWeight, true);
}
|
[
"public",
"static",
"CharTrie",
"indexWords",
"(",
"Collection",
"<",
"String",
">",
"documents",
",",
"int",
"maxLevels",
",",
"int",
"minWeight",
")",
"{",
"return",
"create",
"(",
"documents",
",",
"maxLevels",
",",
"minWeight",
",",
"true",
")",
";",
"}"
] |
Index words char trie.
@param documents the documents
@param maxLevels the max levels
@param minWeight the min weight
@return the char trie
|
[
"Index",
"words",
"char",
"trie",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/text/CharTrieIndex.java#L77-L79
|
155,182
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/text/CharTrieIndex.java
|
CharTrieIndex.indexFulltext
|
public static CharTrie indexFulltext(Collection<String> documents, int maxLevels, int minWeight) {
return create(documents, maxLevels, minWeight, false);
}
|
java
|
public static CharTrie indexFulltext(Collection<String> documents, int maxLevels, int minWeight) {
return create(documents, maxLevels, minWeight, false);
}
|
[
"public",
"static",
"CharTrie",
"indexFulltext",
"(",
"Collection",
"<",
"String",
">",
"documents",
",",
"int",
"maxLevels",
",",
"int",
"minWeight",
")",
"{",
"return",
"create",
"(",
"documents",
",",
"maxLevels",
",",
"minWeight",
",",
"false",
")",
";",
"}"
] |
Index fulltext char trie.
@param documents the documents
@param maxLevels the max levels
@param minWeight the min weight
@return the char trie
|
[
"Index",
"fulltext",
"char",
"trie",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/text/CharTrieIndex.java#L89-L91
|
155,183
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/text/CharTrieIndex.java
|
CharTrieIndex.index
|
public CharTrieIndex index(int maxLevels, int minWeight) {
AtomicInteger numberSplit = new AtomicInteger(0);
int depth = -1;
do {
numberSplit.set(0);
if (0 == ++depth) {
numberSplit.incrementAndGet();
root().split();
}
else {
root().streamDecendents(depth).forEach(node -> {
TrieNode godparent = node.godparent();
if (node.getDepth() < maxLevels) {
if (null == godparent || godparent.getCursorCount() > minWeight) {
if (node.getChar() != NodewalkerCodec.END_OF_STRING || node.getDepth() == 0) {
((IndexNode) node).split();
numberSplit.incrementAndGet();
}
}
}
});
}
} while (numberSplit.get() > 0);
return this;
}
|
java
|
public CharTrieIndex index(int maxLevels, int minWeight) {
AtomicInteger numberSplit = new AtomicInteger(0);
int depth = -1;
do {
numberSplit.set(0);
if (0 == ++depth) {
numberSplit.incrementAndGet();
root().split();
}
else {
root().streamDecendents(depth).forEach(node -> {
TrieNode godparent = node.godparent();
if (node.getDepth() < maxLevels) {
if (null == godparent || godparent.getCursorCount() > minWeight) {
if (node.getChar() != NodewalkerCodec.END_OF_STRING || node.getDepth() == 0) {
((IndexNode) node).split();
numberSplit.incrementAndGet();
}
}
}
});
}
} while (numberSplit.get() > 0);
return this;
}
|
[
"public",
"CharTrieIndex",
"index",
"(",
"int",
"maxLevels",
",",
"int",
"minWeight",
")",
"{",
"AtomicInteger",
"numberSplit",
"=",
"new",
"AtomicInteger",
"(",
"0",
")",
";",
"int",
"depth",
"=",
"-",
"1",
";",
"do",
"{",
"numberSplit",
".",
"set",
"(",
"0",
")",
";",
"if",
"(",
"0",
"==",
"++",
"depth",
")",
"{",
"numberSplit",
".",
"incrementAndGet",
"(",
")",
";",
"root",
"(",
")",
".",
"split",
"(",
")",
";",
"}",
"else",
"{",
"root",
"(",
")",
".",
"streamDecendents",
"(",
"depth",
")",
".",
"forEach",
"(",
"node",
"->",
"{",
"TrieNode",
"godparent",
"=",
"node",
".",
"godparent",
"(",
")",
";",
"if",
"(",
"node",
".",
"getDepth",
"(",
")",
"<",
"maxLevels",
")",
"{",
"if",
"(",
"null",
"==",
"godparent",
"||",
"godparent",
".",
"getCursorCount",
"(",
")",
">",
"minWeight",
")",
"{",
"if",
"(",
"node",
".",
"getChar",
"(",
")",
"!=",
"NodewalkerCodec",
".",
"END_OF_STRING",
"||",
"node",
".",
"getDepth",
"(",
")",
"==",
"0",
")",
"{",
"(",
"(",
"IndexNode",
")",
"node",
")",
".",
"split",
"(",
")",
";",
"numberSplit",
".",
"incrementAndGet",
"(",
")",
";",
"}",
"}",
"}",
"}",
")",
";",
"}",
"}",
"while",
"(",
"numberSplit",
".",
"get",
"(",
")",
">",
"0",
")",
";",
"return",
"this",
";",
"}"
] |
Creates the index tree using the accumulated documents
@param maxLevels - Maximum depth of the tree to build
@param minWeight - Minimum number of cursors for a node to be index using, exclusive bound
@return this char trie index
|
[
"Creates",
"the",
"index",
"tree",
"using",
"the",
"accumulated",
"documents"
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/text/CharTrieIndex.java#L166-L191
|
155,184
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/text/CharTrieIndex.java
|
CharTrieIndex.addDocument
|
public int addDocument(String document) {
if (root().getNumberOfChildren() >= 0) {
throw new IllegalStateException("Tree sorting has begun");
}
final int index;
synchronized (this) {
index = documents.size();
documents.add(document);
}
cursors.addAll(
IntStream.range(0, document.length() + 1).mapToObj(i -> new CursorData(index, i)).collect(Collectors.toList()));
nodes.update(0, node -> node.setCursorCount(cursors.length()));
return index;
}
|
java
|
public int addDocument(String document) {
if (root().getNumberOfChildren() >= 0) {
throw new IllegalStateException("Tree sorting has begun");
}
final int index;
synchronized (this) {
index = documents.size();
documents.add(document);
}
cursors.addAll(
IntStream.range(0, document.length() + 1).mapToObj(i -> new CursorData(index, i)).collect(Collectors.toList()));
nodes.update(0, node -> node.setCursorCount(cursors.length()));
return index;
}
|
[
"public",
"int",
"addDocument",
"(",
"String",
"document",
")",
"{",
"if",
"(",
"root",
"(",
")",
".",
"getNumberOfChildren",
"(",
")",
">=",
"0",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Tree sorting has begun\"",
")",
";",
"}",
"final",
"int",
"index",
";",
"synchronized",
"(",
"this",
")",
"{",
"index",
"=",
"documents",
".",
"size",
"(",
")",
";",
"documents",
".",
"add",
"(",
"document",
")",
";",
"}",
"cursors",
".",
"addAll",
"(",
"IntStream",
".",
"range",
"(",
"0",
",",
"document",
".",
"length",
"(",
")",
"+",
"1",
")",
".",
"mapToObj",
"(",
"i",
"->",
"new",
"CursorData",
"(",
"index",
",",
"i",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
")",
";",
"nodes",
".",
"update",
"(",
"0",
",",
"node",
"->",
"node",
".",
"setCursorCount",
"(",
"cursors",
".",
"length",
"(",
")",
")",
")",
";",
"return",
"index",
";",
"}"
] |
Adds a document to be indexed. This can only be performed before splitting.
@param document the document
@return this int
|
[
"Adds",
"a",
"document",
"to",
"be",
"indexed",
".",
"This",
"can",
"only",
"be",
"performed",
"before",
"splitting",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/text/CharTrieIndex.java#L220-L233
|
155,185
|
SimiaCryptus/utilities
|
java-util/src/main/java/com/simiacryptus/text/CharTrieIndex.java
|
CharTrieIndex.addAlphabet
|
public CharTrie addAlphabet(String document) {
document.chars().mapToObj(i -> new String(Character.toChars(i))).forEach(s -> addDocument(s));
return this;
}
|
java
|
public CharTrie addAlphabet(String document) {
document.chars().mapToObj(i -> new String(Character.toChars(i))).forEach(s -> addDocument(s));
return this;
}
|
[
"public",
"CharTrie",
"addAlphabet",
"(",
"String",
"document",
")",
"{",
"document",
".",
"chars",
"(",
")",
".",
"mapToObj",
"(",
"i",
"->",
"new",
"String",
"(",
"Character",
".",
"toChars",
"(",
"i",
")",
")",
")",
".",
"forEach",
"(",
"s",
"->",
"addDocument",
"(",
"s",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Add alphabet char trie.
@param document the document
@return the char trie
|
[
"Add",
"alphabet",
"char",
"trie",
"."
] |
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
|
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/text/CharTrieIndex.java#L241-L244
|
155,186
|
foundation-runtime/service-directory
|
1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/ServiceDirectoryImpl.java
|
ServiceDirectoryImpl.reinitServiceDirectoryManagerFactory
|
public void reinitServiceDirectoryManagerFactory(ServiceDirectoryManagerFactory factory) throws ServiceException{
if (factory == null) {
throw new ServiceException(ErrorCode.SERVICE_DIRECTORY_NULL_ARGUMENT_ERROR,
ErrorCode.SERVICE_DIRECTORY_NULL_ARGUMENT_ERROR.getMessageTemplate(),
"ServiceDirectoryManagerFactory");
}
synchronized(this){
if(isShutdown){
throw new ServiceException(ErrorCode.SERVICE_DIRECTORY_IS_SHUTDOWN);
}
if (this.directoryManagerFactory != null) {
directoryManagerFactory.stop();
LOGGER.info(
"Resetting ServiceDirectoryManagerFactory, old={}, new={}.",
this.directoryManagerFactory.getClass().getName(),
factory.getClass().getName());
this.directoryManagerFactory = factory;
} else {
this.directoryManagerFactory = factory;
LOGGER.info("Setting ServiceDirectoryManagerFactory, factory={}.",
factory.getClass().getName());
}
directoryManagerFactory.start();
}
}
|
java
|
public void reinitServiceDirectoryManagerFactory(ServiceDirectoryManagerFactory factory) throws ServiceException{
if (factory == null) {
throw new ServiceException(ErrorCode.SERVICE_DIRECTORY_NULL_ARGUMENT_ERROR,
ErrorCode.SERVICE_DIRECTORY_NULL_ARGUMENT_ERROR.getMessageTemplate(),
"ServiceDirectoryManagerFactory");
}
synchronized(this){
if(isShutdown){
throw new ServiceException(ErrorCode.SERVICE_DIRECTORY_IS_SHUTDOWN);
}
if (this.directoryManagerFactory != null) {
directoryManagerFactory.stop();
LOGGER.info(
"Resetting ServiceDirectoryManagerFactory, old={}, new={}.",
this.directoryManagerFactory.getClass().getName(),
factory.getClass().getName());
this.directoryManagerFactory = factory;
} else {
this.directoryManagerFactory = factory;
LOGGER.info("Setting ServiceDirectoryManagerFactory, factory={}.",
factory.getClass().getName());
}
directoryManagerFactory.start();
}
}
|
[
"public",
"void",
"reinitServiceDirectoryManagerFactory",
"(",
"ServiceDirectoryManagerFactory",
"factory",
")",
"throws",
"ServiceException",
"{",
"if",
"(",
"factory",
"==",
"null",
")",
"{",
"throw",
"new",
"ServiceException",
"(",
"ErrorCode",
".",
"SERVICE_DIRECTORY_NULL_ARGUMENT_ERROR",
",",
"ErrorCode",
".",
"SERVICE_DIRECTORY_NULL_ARGUMENT_ERROR",
".",
"getMessageTemplate",
"(",
")",
",",
"\"ServiceDirectoryManagerFactory\"",
")",
";",
"}",
"synchronized",
"(",
"this",
")",
"{",
"if",
"(",
"isShutdown",
")",
"{",
"throw",
"new",
"ServiceException",
"(",
"ErrorCode",
".",
"SERVICE_DIRECTORY_IS_SHUTDOWN",
")",
";",
"}",
"if",
"(",
"this",
".",
"directoryManagerFactory",
"!=",
"null",
")",
"{",
"directoryManagerFactory",
".",
"stop",
"(",
")",
";",
"LOGGER",
".",
"info",
"(",
"\"Resetting ServiceDirectoryManagerFactory, old={}, new={}.\"",
",",
"this",
".",
"directoryManagerFactory",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
",",
"factory",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"this",
".",
"directoryManagerFactory",
"=",
"factory",
";",
"}",
"else",
"{",
"this",
".",
"directoryManagerFactory",
"=",
"factory",
";",
"LOGGER",
".",
"info",
"(",
"\"Setting ServiceDirectoryManagerFactory, factory={}.\"",
",",
"factory",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"}",
"directoryManagerFactory",
".",
"start",
"(",
")",
";",
"}",
"}"
] |
Set the ServiceDirectoryManagerFactory.
@param factory
the ServiceDirectoryManagerFactory.
@throws ServiceException
|
[
"Set",
"the",
"ServiceDirectoryManagerFactory",
"."
] |
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
|
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/ServiceDirectoryImpl.java#L166-L196
|
155,187
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/run/Parameters.java
|
Parameters.get
|
@Override
public Object get(String key) {
if (key == null)
return null;
else if (key.indexOf('.') > 0)
return RecursiveObjectReader.getProperty(this, key);
else
return super.get(key);
}
|
java
|
@Override
public Object get(String key) {
if (key == null)
return null;
else if (key.indexOf('.') > 0)
return RecursiveObjectReader.getProperty(this, key);
else
return super.get(key);
}
|
[
"@",
"Override",
"public",
"Object",
"get",
"(",
"String",
"key",
")",
"{",
"if",
"(",
"key",
"==",
"null",
")",
"return",
"null",
";",
"else",
"if",
"(",
"key",
".",
"indexOf",
"(",
"'",
"'",
")",
">",
"0",
")",
"return",
"RecursiveObjectReader",
".",
"getProperty",
"(",
"this",
",",
"key",
")",
";",
"else",
"return",
"super",
".",
"get",
"(",
"key",
")",
";",
"}"
] |
Gets a map element specified by its key.
The key can be defined using dot notation and allows to recursively access
elements of elements.
@param key a key of the element to get.
@return the value of the map element.
|
[
"Gets",
"a",
"map",
"element",
"specified",
"by",
"its",
"key",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/run/Parameters.java#L53-L61
|
155,188
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/run/Parameters.java
|
Parameters.put
|
@Override
public Object put(String key, Object value) {
if (key == null)
return null;
else if (key.indexOf('.') > 0)
RecursiveObjectWriter.setProperty(this, key, value);
else
super.put(key, value);
return value;
}
|
java
|
@Override
public Object put(String key, Object value) {
if (key == null)
return null;
else if (key.indexOf('.') > 0)
RecursiveObjectWriter.setProperty(this, key, value);
else
super.put(key, value);
return value;
}
|
[
"@",
"Override",
"public",
"Object",
"put",
"(",
"String",
"key",
",",
"Object",
"value",
")",
"{",
"if",
"(",
"key",
"==",
"null",
")",
"return",
"null",
";",
"else",
"if",
"(",
"key",
".",
"indexOf",
"(",
"'",
"'",
")",
">",
"0",
")",
"RecursiveObjectWriter",
".",
"setProperty",
"(",
"this",
",",
"key",
",",
"value",
")",
";",
"else",
"super",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"return",
"value",
";",
"}"
] |
Puts a new value into map element specified by its key.
The key can be defined using dot notation and allows to recursively access
elements of elements.
@param key a key of the element to put.
@param value a new value for map element.
|
[
"Puts",
"a",
"new",
"value",
"into",
"map",
"element",
"specified",
"by",
"its",
"key",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/run/Parameters.java#L72-L81
|
155,189
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/run/Parameters.java
|
Parameters.getAsNullableParameters
|
public Parameters getAsNullableParameters(String key) {
AnyValueMap value = getAsNullableMap(key);
return value != null ? new Parameters(value) : null;
}
|
java
|
public Parameters getAsNullableParameters(String key) {
AnyValueMap value = getAsNullableMap(key);
return value != null ? new Parameters(value) : null;
}
|
[
"public",
"Parameters",
"getAsNullableParameters",
"(",
"String",
"key",
")",
"{",
"AnyValueMap",
"value",
"=",
"getAsNullableMap",
"(",
"key",
")",
";",
"return",
"value",
"!=",
"null",
"?",
"new",
"Parameters",
"(",
"value",
")",
":",
"null",
";",
"}"
] |
Converts map element into an Parameters or returns null if conversion is not
possible.
@param key a key of element to get.
@return Parameters value of the element or null if conversion is not
supported.
|
[
"Converts",
"map",
"element",
"into",
"an",
"Parameters",
"or",
"returns",
"null",
"if",
"conversion",
"is",
"not",
"possible",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/run/Parameters.java#L91-L94
|
155,190
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/run/Parameters.java
|
Parameters.getAsParameters
|
public Parameters getAsParameters(String key) {
AnyValueMap value = getAsMap(key);
return new Parameters(value);
}
|
java
|
public Parameters getAsParameters(String key) {
AnyValueMap value = getAsMap(key);
return new Parameters(value);
}
|
[
"public",
"Parameters",
"getAsParameters",
"(",
"String",
"key",
")",
"{",
"AnyValueMap",
"value",
"=",
"getAsMap",
"(",
"key",
")",
";",
"return",
"new",
"Parameters",
"(",
"value",
")",
";",
"}"
] |
Converts map element into an Parameters or returns empty Parameters if
conversion is not possible.
@param key a key of element to get.
@return Parameters value of the element or empty Parameters if conversion is
not supported.
|
[
"Converts",
"map",
"element",
"into",
"an",
"Parameters",
"or",
"returns",
"empty",
"Parameters",
"if",
"conversion",
"is",
"not",
"possible",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/run/Parameters.java#L104-L107
|
155,191
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/run/Parameters.java
|
Parameters.getAsParametersWithDefault
|
public Parameters getAsParametersWithDefault(String key, Parameters defaultValue) {
Parameters result = getAsNullableParameters(key);
return result != null ? result : defaultValue;
}
|
java
|
public Parameters getAsParametersWithDefault(String key, Parameters defaultValue) {
Parameters result = getAsNullableParameters(key);
return result != null ? result : defaultValue;
}
|
[
"public",
"Parameters",
"getAsParametersWithDefault",
"(",
"String",
"key",
",",
"Parameters",
"defaultValue",
")",
"{",
"Parameters",
"result",
"=",
"getAsNullableParameters",
"(",
"key",
")",
";",
"return",
"result",
"!=",
"null",
"?",
"result",
":",
"defaultValue",
";",
"}"
] |
Converts map element into an Parameters or returns default value if
conversion is not possible.
@param key a key of element to get.
@param defaultValue the default value
@return Parameters value of the element or default value if conversion is not
supported.
|
[
"Converts",
"map",
"element",
"into",
"an",
"Parameters",
"or",
"returns",
"default",
"value",
"if",
"conversion",
"is",
"not",
"possible",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/run/Parameters.java#L118-L121
|
155,192
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/run/Parameters.java
|
Parameters.override
|
public Parameters override(Parameters parameters, boolean recursive) {
Parameters result = new Parameters();
if (recursive) {
RecursiveObjectWriter.copyProperties(result, this);
RecursiveObjectWriter.copyProperties(result, parameters);
} else {
ObjectWriter.setProperties(result, this);
ObjectWriter.setProperties(result, parameters);
}
return result;
}
|
java
|
public Parameters override(Parameters parameters, boolean recursive) {
Parameters result = new Parameters();
if (recursive) {
RecursiveObjectWriter.copyProperties(result, this);
RecursiveObjectWriter.copyProperties(result, parameters);
} else {
ObjectWriter.setProperties(result, this);
ObjectWriter.setProperties(result, parameters);
}
return result;
}
|
[
"public",
"Parameters",
"override",
"(",
"Parameters",
"parameters",
",",
"boolean",
"recursive",
")",
"{",
"Parameters",
"result",
"=",
"new",
"Parameters",
"(",
")",
";",
"if",
"(",
"recursive",
")",
"{",
"RecursiveObjectWriter",
".",
"copyProperties",
"(",
"result",
",",
"this",
")",
";",
"RecursiveObjectWriter",
".",
"copyProperties",
"(",
"result",
",",
"parameters",
")",
";",
"}",
"else",
"{",
"ObjectWriter",
".",
"setProperties",
"(",
"result",
",",
"this",
")",
";",
"ObjectWriter",
".",
"setProperties",
"(",
"result",
",",
"parameters",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Overrides parameters with new values from specified Parameters and returns a
new Parameters object.
@param parameters Parameters with parameters to override the current values.
@param recursive (optional) true to perform deep copy, and false for shallow
copy. Default: false
@return a new Parameters object.
|
[
"Overrides",
"parameters",
"with",
"new",
"values",
"from",
"specified",
"Parameters",
"and",
"returns",
"a",
"new",
"Parameters",
"object",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/run/Parameters.java#L157-L167
|
155,193
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/run/Parameters.java
|
Parameters.setDefaults
|
public Parameters setDefaults(Parameters defaultParameters, boolean recursive) {
Parameters result = new Parameters();
if (recursive) {
RecursiveObjectWriter.copyProperties(result, defaultParameters);
RecursiveObjectWriter.copyProperties(result, this);
} else {
ObjectWriter.setProperties(result, defaultParameters);
ObjectWriter.setProperties(result, this);
}
return result;
}
|
java
|
public Parameters setDefaults(Parameters defaultParameters, boolean recursive) {
Parameters result = new Parameters();
if (recursive) {
RecursiveObjectWriter.copyProperties(result, defaultParameters);
RecursiveObjectWriter.copyProperties(result, this);
} else {
ObjectWriter.setProperties(result, defaultParameters);
ObjectWriter.setProperties(result, this);
}
return result;
}
|
[
"public",
"Parameters",
"setDefaults",
"(",
"Parameters",
"defaultParameters",
",",
"boolean",
"recursive",
")",
"{",
"Parameters",
"result",
"=",
"new",
"Parameters",
"(",
")",
";",
"if",
"(",
"recursive",
")",
"{",
"RecursiveObjectWriter",
".",
"copyProperties",
"(",
"result",
",",
"defaultParameters",
")",
";",
"RecursiveObjectWriter",
".",
"copyProperties",
"(",
"result",
",",
"this",
")",
";",
"}",
"else",
"{",
"ObjectWriter",
".",
"setProperties",
"(",
"result",
",",
"defaultParameters",
")",
";",
"ObjectWriter",
".",
"setProperties",
"(",
"result",
",",
"this",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Set default values from specified Parameters and returns a new Parameters
object.
@param defaultParameters Parameters with default parameter values.
@param recursive (optional) true to perform deep copy, and false for
shallow copy. Default: false
@return a new Parameters object.
|
[
"Set",
"default",
"values",
"from",
"specified",
"Parameters",
"and",
"returns",
"a",
"new",
"Parameters",
"object",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/run/Parameters.java#L189-L199
|
155,194
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/run/Parameters.java
|
Parameters.pick
|
public Parameters pick(String... paths) {
Parameters result = new Parameters();
for (String path : paths) {
if (containsKey(path))
result.put(path, get(path));
}
return result;
}
|
java
|
public Parameters pick(String... paths) {
Parameters result = new Parameters();
for (String path : paths) {
if (containsKey(path))
result.put(path, get(path));
}
return result;
}
|
[
"public",
"Parameters",
"pick",
"(",
"String",
"...",
"paths",
")",
"{",
"Parameters",
"result",
"=",
"new",
"Parameters",
"(",
")",
";",
"for",
"(",
"String",
"path",
":",
"paths",
")",
"{",
"if",
"(",
"containsKey",
"(",
"path",
")",
")",
"result",
".",
"put",
"(",
"path",
",",
"get",
"(",
"path",
")",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Picks select parameters from this Parameters and returns them as a new
Parameters object.
@param paths keys to be picked and copied over to new Parameters.
@return a new Parameters object.
|
[
"Picks",
"select",
"parameters",
"from",
"this",
"Parameters",
"and",
"returns",
"them",
"as",
"a",
"new",
"Parameters",
"object",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/run/Parameters.java#L219-L226
|
155,195
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/run/Parameters.java
|
Parameters.omit
|
public Parameters omit(String... paths) {
Parameters result = new Parameters(this);
for (String path : paths)
result.remove(path);
return result;
}
|
java
|
public Parameters omit(String... paths) {
Parameters result = new Parameters(this);
for (String path : paths)
result.remove(path);
return result;
}
|
[
"public",
"Parameters",
"omit",
"(",
"String",
"...",
"paths",
")",
"{",
"Parameters",
"result",
"=",
"new",
"Parameters",
"(",
"this",
")",
";",
"for",
"(",
"String",
"path",
":",
"paths",
")",
"result",
".",
"remove",
"(",
"path",
")",
";",
"return",
"result",
";",
"}"
] |
Omits selected parameters from this Parameters and returns the rest as a new
Parameters object.
@param paths keys to be omitted from copying over to new Parameters.
@return a new Parameters object.
|
[
"Omits",
"selected",
"parameters",
"from",
"this",
"Parameters",
"and",
"returns",
"the",
"rest",
"as",
"a",
"new",
"Parameters",
"object",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/run/Parameters.java#L235-L240
|
155,196
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/run/Parameters.java
|
Parameters.fromTuples
|
public static Parameters fromTuples(Object... tuples) {
AnyValueMap map = AnyValueMap.fromTuplesArray(tuples);
return new Parameters(map);
}
|
java
|
public static Parameters fromTuples(Object... tuples) {
AnyValueMap map = AnyValueMap.fromTuplesArray(tuples);
return new Parameters(map);
}
|
[
"public",
"static",
"Parameters",
"fromTuples",
"(",
"Object",
"...",
"tuples",
")",
"{",
"AnyValueMap",
"map",
"=",
"AnyValueMap",
".",
"fromTuplesArray",
"(",
"tuples",
")",
";",
"return",
"new",
"Parameters",
"(",
"map",
")",
";",
"}"
] |
Creates a new Parameters object filled with provided key-value pairs called
tuples. Tuples parameters contain a sequence of key1, value1, key2, value2,
... pairs.
@param tuples the tuples to fill a new Parameters object.
@return a new Parameters object.
@see AnyValueMap#fromTuplesArray(Object[])
|
[
"Creates",
"a",
"new",
"Parameters",
"object",
"filled",
"with",
"provided",
"key",
"-",
"value",
"pairs",
"called",
"tuples",
".",
"Tuples",
"parameters",
"contain",
"a",
"sequence",
"of",
"key1",
"value1",
"key2",
"value2",
"...",
"pairs",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/run/Parameters.java#L262-L265
|
155,197
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/run/Parameters.java
|
Parameters.mergeParams
|
public static Parameters mergeParams(Parameters... parameters) {
AnyValueMap map = AnyValueMap.fromMaps(parameters);
return new Parameters(map);
}
|
java
|
public static Parameters mergeParams(Parameters... parameters) {
AnyValueMap map = AnyValueMap.fromMaps(parameters);
return new Parameters(map);
}
|
[
"public",
"static",
"Parameters",
"mergeParams",
"(",
"Parameters",
"...",
"parameters",
")",
"{",
"AnyValueMap",
"map",
"=",
"AnyValueMap",
".",
"fromMaps",
"(",
"parameters",
")",
";",
"return",
"new",
"Parameters",
"(",
"map",
")",
";",
"}"
] |
Merges two or more Parameters into one. The following Parameters override
previously defined parameters.
@param parameters a list of Parameters objects to be merged.
@return a new Parameters object.
@see AnyValueMap#fromMaps(Map...)
|
[
"Merges",
"two",
"or",
"more",
"Parameters",
"into",
"one",
".",
"The",
"following",
"Parameters",
"override",
"previously",
"defined",
"parameters",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/run/Parameters.java#L276-L279
|
155,198
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/run/Parameters.java
|
Parameters.fromJson
|
public static Parameters fromJson(String json) {
Map<String, Object> map = JsonConverter.toNullableMap(json);
return map != null ? new Parameters(map) : new Parameters();
}
|
java
|
public static Parameters fromJson(String json) {
Map<String, Object> map = JsonConverter.toNullableMap(json);
return map != null ? new Parameters(map) : new Parameters();
}
|
[
"public",
"static",
"Parameters",
"fromJson",
"(",
"String",
"json",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"map",
"=",
"JsonConverter",
".",
"toNullableMap",
"(",
"json",
")",
";",
"return",
"map",
"!=",
"null",
"?",
"new",
"Parameters",
"(",
"map",
")",
":",
"new",
"Parameters",
"(",
")",
";",
"}"
] |
Creates new Parameters from JSON object.
@param json a JSON string containing parameters.
@return a new Parameters object.
@see JsonConverter#toNullableMap(String)
|
[
"Creates",
"new",
"Parameters",
"from",
"JSON",
"object",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/run/Parameters.java#L289-L292
|
155,199
|
pip-services3-java/pip-services3-commons-java
|
src/org/pipservices3/commons/run/Parameters.java
|
Parameters.fromConfig
|
public static Parameters fromConfig(ConfigParams config) {
Parameters result = new Parameters();
if (config == null || config.size() == 0)
return result;
for (Map.Entry<String, String> entry : config.entrySet()) {
result.put(entry.getKey(), entry.getValue());
}
return result;
}
|
java
|
public static Parameters fromConfig(ConfigParams config) {
Parameters result = new Parameters();
if (config == null || config.size() == 0)
return result;
for (Map.Entry<String, String> entry : config.entrySet()) {
result.put(entry.getKey(), entry.getValue());
}
return result;
}
|
[
"public",
"static",
"Parameters",
"fromConfig",
"(",
"ConfigParams",
"config",
")",
"{",
"Parameters",
"result",
"=",
"new",
"Parameters",
"(",
")",
";",
"if",
"(",
"config",
"==",
"null",
"||",
"config",
".",
"size",
"(",
")",
"==",
"0",
")",
"return",
"result",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"String",
">",
"entry",
":",
"config",
".",
"entrySet",
"(",
")",
")",
"{",
"result",
".",
"put",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Creates new Parameters from ConfigMap object.
@param config a ConfigParams that contain parameters.
@return a new Parameters object.
@see ConfigParams
|
[
"Creates",
"new",
"Parameters",
"from",
"ConfigMap",
"object",
"."
] |
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
|
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/run/Parameters.java#L302-L313
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.