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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
156,000 | SimiaCryptus/utilities | java-util/src/main/java/com/simiacryptus/util/StreamNanoHTTPD.java | StreamNanoHTTPD.create | @javax.annotation.Nonnull
public static OutputStream create(final int port, @javax.annotation.Nonnull final File path, final String mimeType) throws IOException {
return new com.simiacryptus.util.StreamNanoHTTPD(port, mimeType, path).init().dataReciever;
} | java | @javax.annotation.Nonnull
public static OutputStream create(final int port, @javax.annotation.Nonnull final File path, final String mimeType) throws IOException {
return new com.simiacryptus.util.StreamNanoHTTPD(port, mimeType, path).init().dataReciever;
} | [
"@",
"javax",
".",
"annotation",
".",
"Nonnull",
"public",
"static",
"OutputStream",
"create",
"(",
"final",
"int",
"port",
",",
"@",
"javax",
".",
"annotation",
".",
"Nonnull",
"final",
"File",
"path",
",",
"final",
"String",
"mimeType",
")",
"throws",
"I... | Create output stream.
@param port the port
@param path the path
@param mimeType the mime type
@return the output stream
@throws IOException the io exception | [
"Create",
"output",
"stream",
"."
] | b5a5e73449aae57de7dbfca2ed7a074432c5b17e | https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/StreamNanoHTTPD.java#L139-L142 |
156,001 | SimiaCryptus/utilities | java-util/src/main/java/com/simiacryptus/util/StreamNanoHTTPD.java | StreamNanoHTTPD.addAsyncHandler | public void addAsyncHandler(final String path, final String mimeType, @javax.annotation.Nonnull final Consumer<OutputStream> logic, final boolean async) {
addSessionHandler(path, com.simiacryptus.util.StreamNanoHTTPD.asyncHandler(pool, mimeType, logic, async));
} | java | public void addAsyncHandler(final String path, final String mimeType, @javax.annotation.Nonnull final Consumer<OutputStream> logic, final boolean async) {
addSessionHandler(path, com.simiacryptus.util.StreamNanoHTTPD.asyncHandler(pool, mimeType, logic, async));
} | [
"public",
"void",
"addAsyncHandler",
"(",
"final",
"String",
"path",
",",
"final",
"String",
"mimeType",
",",
"@",
"javax",
".",
"annotation",
".",
"Nonnull",
"final",
"Consumer",
"<",
"OutputStream",
">",
"logic",
",",
"final",
"boolean",
"async",
")",
"{",... | Add async handler.
@param path the path
@param mimeType the mime type
@param logic the logic
@param async the async | [
"Add",
"async",
"handler",
"."
] | b5a5e73449aae57de7dbfca2ed7a074432c5b17e | https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/StreamNanoHTTPD.java#L175-L177 |
156,002 | SimiaCryptus/utilities | java-util/src/main/java/com/simiacryptus/util/StreamNanoHTTPD.java | StreamNanoHTTPD.addSessionHandler | public Function<IHTTPSession, Response> addSessionHandler(final String path, final Function<IHTTPSession, Response> value) {
return customHandlers.put(path, value);
} | java | public Function<IHTTPSession, Response> addSessionHandler(final String path, final Function<IHTTPSession, Response> value) {
return customHandlers.put(path, value);
} | [
"public",
"Function",
"<",
"IHTTPSession",
",",
"Response",
">",
"addSessionHandler",
"(",
"final",
"String",
"path",
",",
"final",
"Function",
"<",
"IHTTPSession",
",",
"Response",
">",
"value",
")",
"{",
"return",
"customHandlers",
".",
"put",
"(",
"path",
... | Add session handler function.
@param path the path
@param value the value
@return the function | [
"Add",
"session",
"handler",
"function",
"."
] | b5a5e73449aae57de7dbfca2ed7a074432c5b17e | https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/StreamNanoHTTPD.java#L186-L188 |
156,003 | SimiaCryptus/utilities | java-util/src/main/java/com/simiacryptus/util/StreamNanoHTTPD.java | StreamNanoHTTPD.init | @javax.annotation.Nonnull
public com.simiacryptus.util.StreamNanoHTTPD init() throws IOException {
com.simiacryptus.util.StreamNanoHTTPD.this.start(30000);
new Thread(() -> {
try {
Thread.sleep(100);
if(null != gatewayUri) Desktop.getDesktop().browse(gatewayUri);
} catch (@javax.annotation.Nonnull final Exception e) {
e.printStackTrace();
}
}).start();
return this;
} | java | @javax.annotation.Nonnull
public com.simiacryptus.util.StreamNanoHTTPD init() throws IOException {
com.simiacryptus.util.StreamNanoHTTPD.this.start(30000);
new Thread(() -> {
try {
Thread.sleep(100);
if(null != gatewayUri) Desktop.getDesktop().browse(gatewayUri);
} catch (@javax.annotation.Nonnull final Exception e) {
e.printStackTrace();
}
}).start();
return this;
} | [
"@",
"javax",
".",
"annotation",
".",
"Nonnull",
"public",
"com",
".",
"simiacryptus",
".",
"util",
".",
"StreamNanoHTTPD",
"init",
"(",
")",
"throws",
"IOException",
"{",
"com",
".",
"simiacryptus",
".",
"util",
".",
"StreamNanoHTTPD",
".",
"this",
".",
"... | Init stream nano httpd.
@return the stream nano httpd
@throws IOException the io exception | [
"Init",
"stream",
"nano",
"httpd",
"."
] | b5a5e73449aae57de7dbfca2ed7a074432c5b17e | https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/StreamNanoHTTPD.java#L208-L220 |
156,004 | morimekta/utils | io-util/src/main/java/net/morimekta/util/Slice.java | Slice.strEquals | public final boolean strEquals(byte[] a, int aOff, int aLen) {
if (aLen != len) {
return false;
}
for (int i = 0; i < len; ++i) {
if (a[aOff + i] != fb[off + i]) {
return false;
}
}
return true;
} | java | public final boolean strEquals(byte[] a, int aOff, int aLen) {
if (aLen != len) {
return false;
}
for (int i = 0; i < len; ++i) {
if (a[aOff + i] != fb[off + i]) {
return false;
}
}
return true;
} | [
"public",
"final",
"boolean",
"strEquals",
"(",
"byte",
"[",
"]",
"a",
",",
"int",
"aOff",
",",
"int",
"aLen",
")",
"{",
"if",
"(",
"aLen",
"!=",
"len",
")",
"{",
"return",
"false",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"... | Checks if the slice is equal to a portion of a given byte array.
@param a The array to compare with.
@param aOff The offset to compare with in the array.
@param aLen The length to compare with.
@return True if equal. | [
"Checks",
"if",
"the",
"slice",
"is",
"equal",
"to",
"a",
"portion",
"of",
"a",
"given",
"byte",
"array",
"."
] | dc987485902f1a7d58169c89c61db97425a6226d | https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/Slice.java#L173-L183 |
156,005 | trellis-ldp-archive/trellis-app | src/main/java/org/trellisldp/app/config/KafkaConfiguration.java | KafkaConfiguration.set | @JsonAnySetter
public void set(final String name, final String value) {
other.put(name, value);
} | java | @JsonAnySetter
public void set(final String name, final String value) {
other.put(name, value);
} | [
"@",
"JsonAnySetter",
"public",
"void",
"set",
"(",
"final",
"String",
"name",
",",
"final",
"String",
"value",
")",
"{",
"other",
".",
"put",
"(",
"name",
",",
"value",
")",
";",
"}"
] | Set configuration values dynamically
@param name the configuration name
@param value the value | [
"Set",
"configuration",
"values",
"dynamically"
] | b34d123b31af22042a5c0186fb959399bb6b28a8 | https://github.com/trellis-ldp-archive/trellis-app/blob/b34d123b31af22042a5c0186fb959399bb6b28a8/src/main/java/org/trellisldp/app/config/KafkaConfiguration.java#L75-L78 |
156,006 | trellis-ldp-archive/trellis-app | src/main/java/org/trellisldp/app/config/KafkaConfiguration.java | KafkaConfiguration.asProperties | public Properties asProperties() {
final Properties props = new Properties();
other.forEach(props::setProperty);
props.setProperty("bootstrap.servers", bootstrapServers);
return props;
} | java | public Properties asProperties() {
final Properties props = new Properties();
other.forEach(props::setProperty);
props.setProperty("bootstrap.servers", bootstrapServers);
return props;
} | [
"public",
"Properties",
"asProperties",
"(",
")",
"{",
"final",
"Properties",
"props",
"=",
"new",
"Properties",
"(",
")",
";",
"other",
".",
"forEach",
"(",
"props",
"::",
"setProperty",
")",
";",
"props",
".",
"setProperty",
"(",
"\"bootstrap.servers\"",
"... | Get all configuration values in a Properties object
@return the properties | [
"Get",
"all",
"configuration",
"values",
"in",
"a",
"Properties",
"object"
] | b34d123b31af22042a5c0186fb959399bb6b28a8 | https://github.com/trellis-ldp-archive/trellis-app/blob/b34d123b31af22042a5c0186fb959399bb6b28a8/src/main/java/org/trellisldp/app/config/KafkaConfiguration.java#L84-L89 |
156,007 | SimiaCryptus/utilities | java-util/src/main/java/com/simiacryptus/util/CountCollection.java | CountCollection.count | protected int count(final T key) {
final AtomicInteger counter = this.map.get(key);
if (null == counter) {
return 0;
}
return counter.get();
} | java | protected int count(final T key) {
final AtomicInteger counter = this.map.get(key);
if (null == counter) {
return 0;
}
return counter.get();
} | [
"protected",
"int",
"count",
"(",
"final",
"T",
"key",
")",
"{",
"final",
"AtomicInteger",
"counter",
"=",
"this",
".",
"map",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"null",
"==",
"counter",
")",
"{",
"return",
"0",
";",
"}",
"return",
"count... | Count int.
@param key the key
@return the int | [
"Count",
"int",
"."
] | b5a5e73449aae57de7dbfca2ed7a074432c5b17e | https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/CountCollection.java#L81-L87 |
156,008 | SimiaCryptus/utilities | java-util/src/main/java/com/simiacryptus/util/CountCollection.java | CountCollection.getList | public List<T> getList() {
final ArrayList<T> list = new ArrayList<T>();
for (final Entry<T, AtomicInteger> e : this.map.entrySet()) {
for (int i = 0; i < e.getValue().get(); i++) {
list.add(e.getKey());
}
}
return list;
} | java | public List<T> getList() {
final ArrayList<T> list = new ArrayList<T>();
for (final Entry<T, AtomicInteger> e : this.map.entrySet()) {
for (int i = 0; i < e.getValue().get(); i++) {
list.add(e.getKey());
}
}
return list;
} | [
"public",
"List",
"<",
"T",
">",
"getList",
"(",
")",
"{",
"final",
"ArrayList",
"<",
"T",
">",
"list",
"=",
"new",
"ArrayList",
"<",
"T",
">",
"(",
")",
";",
"for",
"(",
"final",
"Entry",
"<",
"T",
",",
"AtomicInteger",
">",
"e",
":",
"this",
... | Gets list.
@return the list | [
"Gets",
"list",
"."
] | b5a5e73449aae57de7dbfca2ed7a074432c5b17e | https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/CountCollection.java#L103-L111 |
156,009 | SimiaCryptus/utilities | java-util/src/main/java/com/simiacryptus/util/CountCollection.java | CountCollection.getMap | public Map<T, Integer> getMap() {
return Maps.transformEntries(this.map,
new EntryTransformer<T, AtomicInteger, Integer>() {
@Override
public Integer transformEntry(final T key, final AtomicInteger value) {
return value.get();
}
});
} | java | public Map<T, Integer> getMap() {
return Maps.transformEntries(this.map,
new EntryTransformer<T, AtomicInteger, Integer>() {
@Override
public Integer transformEntry(final T key, final AtomicInteger value) {
return value.get();
}
});
} | [
"public",
"Map",
"<",
"T",
",",
"Integer",
">",
"getMap",
"(",
")",
"{",
"return",
"Maps",
".",
"transformEntries",
"(",
"this",
".",
"map",
",",
"new",
"EntryTransformer",
"<",
"T",
",",
"AtomicInteger",
",",
"Integer",
">",
"(",
")",
"{",
"@",
"Ove... | Gets map.
@return the map | [
"Gets",
"map",
"."
] | b5a5e73449aae57de7dbfca2ed7a074432c5b17e | https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/CountCollection.java#L118-L126 |
156,010 | foundation-runtime/service-directory | 1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryRegistrationService.java | DirectoryRegistrationService.registerService | public void registerService(ProvidedServiceInstance serviceInstance, ServiceInstanceHealth registryHealth) {
// Monitor disabled ProvidedServiceInstance should not have the ServiceInstanceHealth.
if(serviceInstance.isMonitorEnabled()== false){
throw new ServiceException(ErrorCode.SERVICE_INSTANCE_HEALTH_ERROR);
}
registerService(serviceInstance);
} | java | public void registerService(ProvidedServiceInstance serviceInstance, ServiceInstanceHealth registryHealth) {
// Monitor disabled ProvidedServiceInstance should not have the ServiceInstanceHealth.
if(serviceInstance.isMonitorEnabled()== false){
throw new ServiceException(ErrorCode.SERVICE_INSTANCE_HEALTH_ERROR);
}
registerService(serviceInstance);
} | [
"public",
"void",
"registerService",
"(",
"ProvidedServiceInstance",
"serviceInstance",
",",
"ServiceInstanceHealth",
"registryHealth",
")",
"{",
"// Monitor disabled ProvidedServiceInstance should not have the ServiceInstanceHealth.",
"if",
"(",
"serviceInstance",
".",
"isMonitorEna... | Register a ProvidedServiceInstance with the ServiceInstanceHealth callback.
@param serviceInstance
the ProvidedServiceInstance.
@param registryHealth
the ServiceInstanceHealth callback. | [
"Register",
"a",
"ProvidedServiceInstance",
"with",
"the",
"ServiceInstanceHealth",
"callback",
"."
] | a7bdefe173dc99e75eff4a24e07e6407e62f2ed4 | https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryRegistrationService.java#L102-L108 |
156,011 | foundation-runtime/service-directory | 1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryRegistrationService.java | DirectoryRegistrationService.updateServiceUri | public void updateServiceUri(String serviceName, String providerId,
String uri) {
getServiceDirectoryClient().updateInstanceUri(serviceName, providerId,
uri, disableOwnerError);
} | java | public void updateServiceUri(String serviceName, String providerId,
String uri) {
getServiceDirectoryClient().updateInstanceUri(serviceName, providerId,
uri, disableOwnerError);
} | [
"public",
"void",
"updateServiceUri",
"(",
"String",
"serviceName",
",",
"String",
"providerId",
",",
"String",
"uri",
")",
"{",
"getServiceDirectoryClient",
"(",
")",
".",
"updateInstanceUri",
"(",
"serviceName",
",",
"providerId",
",",
"uri",
",",
"disableOwnerE... | Update the uri attribute of the ProvidedServiceInstance
The ProvidedServiceInstance is uniquely identified by serviceName and providerId
@param serviceName
the serviceName of the ProvidedServiceInstance.
@param providerId
the providerId of the ProvidedServiceInstance.
@param uri
the new uri. | [
"Update",
"the",
"uri",
"attribute",
"of",
"the",
"ProvidedServiceInstance",
"The",
"ProvidedServiceInstance",
"is",
"uniquely",
"identified",
"by",
"serviceName",
"and",
"providerId"
] | a7bdefe173dc99e75eff4a24e07e6407e62f2ed4 | https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryRegistrationService.java#L121-L125 |
156,012 | foundation-runtime/service-directory | 1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryRegistrationService.java | DirectoryRegistrationService.unregisterService | public void unregisterService(String serviceName, String providerId) {
getServiceDirectoryClient().unregisterInstance(serviceName, providerId, disableOwnerError);
} | java | public void unregisterService(String serviceName, String providerId) {
getServiceDirectoryClient().unregisterInstance(serviceName, providerId, disableOwnerError);
} | [
"public",
"void",
"unregisterService",
"(",
"String",
"serviceName",
",",
"String",
"providerId",
")",
"{",
"getServiceDirectoryClient",
"(",
")",
".",
"unregisterInstance",
"(",
"serviceName",
",",
"providerId",
",",
"disableOwnerError",
")",
";",
"}"
] | Unregister a ProvidedServiceInstance
The ProvidedServiceInstance is uniquely identified by serviceName and providerId
@param serviceName
the serviceName of ProvidedServiceInstance.
@param providerId
the provierId of ProvidedServiceInstance. | [
"Unregister",
"a",
"ProvidedServiceInstance",
"The",
"ProvidedServiceInstance",
"is",
"uniquely",
"identified",
"by",
"serviceName",
"and",
"providerId"
] | a7bdefe173dc99e75eff4a24e07e6407e62f2ed4 | https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryRegistrationService.java#L165-L167 |
156,013 | PureSolTechnologies/genesis | controller/src/main/java/com/puresoltechnologies/genesis/controller/GenesisController.java | GenesisController.migrate | public boolean migrate(Version targetVersion) {
printRunHeader("MIGRATE");
StopWatch stopWatch = new StopWatch();
stopWatch.start();
boolean success = false;
try {
transform(targetVersion);
success = true;
} catch (TransformationException | InvalidSequenceException e) {
e.printStackTrace(System.err);
}
stopWatch.stop();
printRunFooter(success, stopWatch);
return success;
} | java | public boolean migrate(Version targetVersion) {
printRunHeader("MIGRATE");
StopWatch stopWatch = new StopWatch();
stopWatch.start();
boolean success = false;
try {
transform(targetVersion);
success = true;
} catch (TransformationException | InvalidSequenceException e) {
e.printStackTrace(System.err);
}
stopWatch.stop();
printRunFooter(success, stopWatch);
return success;
} | [
"public",
"boolean",
"migrate",
"(",
"Version",
"targetVersion",
")",
"{",
"printRunHeader",
"(",
"\"MIGRATE\"",
")",
";",
"StopWatch",
"stopWatch",
"=",
"new",
"StopWatch",
"(",
")",
";",
"stopWatch",
".",
"start",
"(",
")",
";",
"boolean",
"success",
"=",
... | Runs the migration to a specified version.
@param targetVersion
is the version to which the migration is to run to.
@return <code>true</code> is returned in case of a successful migration.
<code>false</code> is returned otherwise. | [
"Runs",
"the",
"migration",
"to",
"a",
"specified",
"version",
"."
] | 1031027c5edcfeaad670896802058f78a2f7b159 | https://github.com/PureSolTechnologies/genesis/blob/1031027c5edcfeaad670896802058f78a2f7b159/controller/src/main/java/com/puresoltechnologies/genesis/controller/GenesisController.java#L144-L158 |
156,014 | hudson3-plugins/warnings-plugin | src/main/java/hudson/plugins/warnings/WarningsProjectAction.java | WarningsProjectAction.createBuildHistory | @Override
protected BuildHistory createBuildHistory() {
AbstractBuild<?, ?> lastFinishedBuild = getLastFinishedBuild();
if (lastFinishedBuild == null) {
return new NullBuildHistory();
}
else {
return createHistory(lastFinishedBuild);
}
} | java | @Override
protected BuildHistory createBuildHistory() {
AbstractBuild<?, ?> lastFinishedBuild = getLastFinishedBuild();
if (lastFinishedBuild == null) {
return new NullBuildHistory();
}
else {
return createHistory(lastFinishedBuild);
}
} | [
"@",
"Override",
"protected",
"BuildHistory",
"createBuildHistory",
"(",
")",
"{",
"AbstractBuild",
"<",
"?",
",",
"?",
">",
"lastFinishedBuild",
"=",
"getLastFinishedBuild",
"(",
")",
";",
"if",
"(",
"lastFinishedBuild",
"==",
"null",
")",
"{",
"return",
"new... | Creates the build history.
@return build history | [
"Creates",
"the",
"build",
"history",
"."
] | 462c9f3dffede9120173935567392b22520b0966 | https://github.com/hudson3-plugins/warnings-plugin/blob/462c9f3dffede9120173935567392b22520b0966/src/main/java/hudson/plugins/warnings/WarningsProjectAction.java#L96-L105 |
156,015 | foundation-runtime/service-directory | 2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/lb/RoundRobinLoadBalancer.java | RoundRobinLoadBalancer.vote | @Override
public ServiceInstance vote() {
List<ModelServiceInstance> instances = getServiceInstanceList();
if(instances == null || instances.isEmpty()){
return null;
}
int i = index.getAndIncrement();
int pos = i % instances.size();
ModelServiceInstance instance = instances.get(pos);
return ServiceInstanceUtils.transferFromModelServiceInstance(instance);
} | java | @Override
public ServiceInstance vote() {
List<ModelServiceInstance> instances = getServiceInstanceList();
if(instances == null || instances.isEmpty()){
return null;
}
int i = index.getAndIncrement();
int pos = i % instances.size();
ModelServiceInstance instance = instances.get(pos);
return ServiceInstanceUtils.transferFromModelServiceInstance(instance);
} | [
"@",
"Override",
"public",
"ServiceInstance",
"vote",
"(",
")",
"{",
"List",
"<",
"ModelServiceInstance",
">",
"instances",
"=",
"getServiceInstanceList",
"(",
")",
";",
"if",
"(",
"instances",
"==",
"null",
"||",
"instances",
".",
"isEmpty",
"(",
")",
")",
... | Vote a ServiceInstance based on the LoadBalancer algorithm.
@return
the voted ServiceInstance. | [
"Vote",
"a",
"ServiceInstance",
"based",
"on",
"the",
"LoadBalancer",
"algorithm",
"."
] | a7bdefe173dc99e75eff4a24e07e6407e62f2ed4 | https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/lb/RoundRobinLoadBalancer.java#L59-L69 |
156,016 | ansell/restlet-utils | src/main/java/com/github/ansell/restletutils/RestletUtilSesameRealm.java | RestletUtilSesameRealm.addRootGroup | public void addRootGroup(final Group nextRootGroup)
{
this.getRootGroups().add(nextRootGroup);
RepositoryConnection conn = null;
try
{
conn = this.repository.getConnection();
conn.begin();
this.storeGroup(nextRootGroup, conn, true);
conn.commit();
}
catch(final RepositoryException e)
{
this.log.error("Found exception while storing root group", e);
if(conn != null)
{
try
{
conn.rollback();
}
catch(final RepositoryException e1)
{
this.log.error("Found exception while trying to roll back connection", e1);
}
}
}
finally
{
if(conn != null)
{
try
{
conn.close();
}
catch(final RepositoryException e)
{
this.log.error("Found exception closing repository connection", e);
}
}
}
} | java | public void addRootGroup(final Group nextRootGroup)
{
this.getRootGroups().add(nextRootGroup);
RepositoryConnection conn = null;
try
{
conn = this.repository.getConnection();
conn.begin();
this.storeGroup(nextRootGroup, conn, true);
conn.commit();
}
catch(final RepositoryException e)
{
this.log.error("Found exception while storing root group", e);
if(conn != null)
{
try
{
conn.rollback();
}
catch(final RepositoryException e1)
{
this.log.error("Found exception while trying to roll back connection", e1);
}
}
}
finally
{
if(conn != null)
{
try
{
conn.close();
}
catch(final RepositoryException e)
{
this.log.error("Found exception closing repository connection", e);
}
}
}
} | [
"public",
"void",
"addRootGroup",
"(",
"final",
"Group",
"nextRootGroup",
")",
"{",
"this",
".",
"getRootGroups",
"(",
")",
".",
"add",
"(",
"nextRootGroup",
")",
";",
"RepositoryConnection",
"conn",
"=",
"null",
";",
"try",
"{",
"conn",
"=",
"this",
".",
... | Adds a fully populated root group to the underlying repository, including a statement
indicating that this group is a root group.
@param nextRootGroup The next root group to add. | [
"Adds",
"a",
"fully",
"populated",
"root",
"group",
"to",
"the",
"underlying",
"repository",
"including",
"a",
"statement",
"indicating",
"that",
"this",
"group",
"is",
"a",
"root",
"group",
"."
] | 6c39a3e91aa8295936af1dbfccd6ba27230c40a9 | https://github.com/ansell/restlet-utils/blob/6c39a3e91aa8295936af1dbfccd6ba27230c40a9/src/main/java/com/github/ansell/restletutils/RestletUtilSesameRealm.java#L335-L378 |
156,017 | ansell/restlet-utils | src/main/java/com/github/ansell/restletutils/RestletUtilSesameRealm.java | RestletUtilSesameRealm.buildRestletUserFromSparqlResult | protected RestletUtilUser buildRestletUserFromSparqlResult(final String userIdentifier, final BindingSet bindingSet)
{
// log.info("result={}", bindingSet);
String userEmail = bindingSet.getValue("userEmail").stringValue();
// TODO: When hashed, need to unhash here
char[] userSecret = null;
if(bindingSet.hasBinding("userSecret"))
{
userSecret = bindingSet.getValue("userSecret").stringValue().toCharArray();
}
String userFirstName = null;
if(bindingSet.hasBinding("userFirstName"))
{
userFirstName = bindingSet.getValue("userFirstName").stringValue();
}
String userLastName = null;
if(bindingSet.hasBinding("userLastName"))
{
userLastName = bindingSet.getValue("userLastName").stringValue();
}
return new RestletUtilUser(userIdentifier, userSecret, userFirstName, userLastName, userEmail);
} | java | protected RestletUtilUser buildRestletUserFromSparqlResult(final String userIdentifier, final BindingSet bindingSet)
{
// log.info("result={}", bindingSet);
String userEmail = bindingSet.getValue("userEmail").stringValue();
// TODO: When hashed, need to unhash here
char[] userSecret = null;
if(bindingSet.hasBinding("userSecret"))
{
userSecret = bindingSet.getValue("userSecret").stringValue().toCharArray();
}
String userFirstName = null;
if(bindingSet.hasBinding("userFirstName"))
{
userFirstName = bindingSet.getValue("userFirstName").stringValue();
}
String userLastName = null;
if(bindingSet.hasBinding("userLastName"))
{
userLastName = bindingSet.getValue("userLastName").stringValue();
}
return new RestletUtilUser(userIdentifier, userSecret, userFirstName, userLastName, userEmail);
} | [
"protected",
"RestletUtilUser",
"buildRestletUserFromSparqlResult",
"(",
"final",
"String",
"userIdentifier",
",",
"final",
"BindingSet",
"bindingSet",
")",
"{",
"// log.info(\"result={}\", bindingSet);",
"String",
"userEmail",
"=",
"bindingSet",
".",
"getValue",
"(",
"\"us... | Builds a RestletUtilUser from the data retrieved in a SPARQL result.
@param userIdentifier
The unique identifier of the User.
@param bindingSet
Results of a single user from SPARQL.
@return A RestletUtilUser account. | [
"Builds",
"a",
"RestletUtilUser",
"from",
"the",
"data",
"retrieved",
"in",
"a",
"SPARQL",
"result",
"."
] | 6c39a3e91aa8295936af1dbfccd6ba27230c40a9 | https://github.com/ansell/restlet-utils/blob/6c39a3e91aa8295936af1dbfccd6ba27230c40a9/src/main/java/com/github/ansell/restletutils/RestletUtilSesameRealm.java#L596-L619 |
156,018 | ansell/restlet-utils | src/main/java/com/github/ansell/restletutils/RestletUtilSesameRealm.java | RestletUtilSesameRealm.buildSparqlQueryToFindUser | protected String buildSparqlQueryToFindUser(final String userIdentifier, boolean findAllUsers)
{
if(!findAllUsers && userIdentifier == null)
{
throw new NullPointerException("User identifier was null");
}
final StringBuilder query = new StringBuilder();
query.append(" SELECT ?userIdentifier ?userUri ?userSecret ?userFirstName ?userLastName ?userEmail ");
query.append(" WHERE ");
query.append(" { ");
query.append(" ?userUri a ");
query.append(RenderUtils.getSPARQLQueryString(SesameRealmConstants.OAS_USER));
query.append(" . ");
query.append(" ?userUri ");
query.append(RenderUtils.getSPARQLQueryString(SesameRealmConstants.OAS_USERIDENTIFIER));
query.append(" ?userIdentifier . ");
query.append(" OPTIONAL{ ?userUri ");
query.append(RenderUtils.getSPARQLQueryString(SesameRealmConstants.OAS_USERSECRET));
query.append(" ?userSecret . } ");
query.append(" OPTIONAL{ ?userUri ");
query.append(RenderUtils.getSPARQLQueryString(SesameRealmConstants.OAS_USERFIRSTNAME));
query.append(" ?userFirstName . } ");
query.append(" OPTIONAL{ ?userUri ");
query.append(RenderUtils.getSPARQLQueryString(SesameRealmConstants.OAS_USERLASTNAME));
query.append(" ?userLastName . } ");
query.append(" OPTIONAL{ ?userUri ");
query.append(RenderUtils.getSPARQLQueryString(SesameRealmConstants.OAS_USEREMAIL));
query.append(" ?userEmail . } ");
if(!findAllUsers)
{
query.append(" FILTER(str(?userIdentifier) = \"" + RenderUtils.escape(userIdentifier) + "\") ");
}
query.append(" } ");
return query.toString();
} | java | protected String buildSparqlQueryToFindUser(final String userIdentifier, boolean findAllUsers)
{
if(!findAllUsers && userIdentifier == null)
{
throw new NullPointerException("User identifier was null");
}
final StringBuilder query = new StringBuilder();
query.append(" SELECT ?userIdentifier ?userUri ?userSecret ?userFirstName ?userLastName ?userEmail ");
query.append(" WHERE ");
query.append(" { ");
query.append(" ?userUri a ");
query.append(RenderUtils.getSPARQLQueryString(SesameRealmConstants.OAS_USER));
query.append(" . ");
query.append(" ?userUri ");
query.append(RenderUtils.getSPARQLQueryString(SesameRealmConstants.OAS_USERIDENTIFIER));
query.append(" ?userIdentifier . ");
query.append(" OPTIONAL{ ?userUri ");
query.append(RenderUtils.getSPARQLQueryString(SesameRealmConstants.OAS_USERSECRET));
query.append(" ?userSecret . } ");
query.append(" OPTIONAL{ ?userUri ");
query.append(RenderUtils.getSPARQLQueryString(SesameRealmConstants.OAS_USERFIRSTNAME));
query.append(" ?userFirstName . } ");
query.append(" OPTIONAL{ ?userUri ");
query.append(RenderUtils.getSPARQLQueryString(SesameRealmConstants.OAS_USERLASTNAME));
query.append(" ?userLastName . } ");
query.append(" OPTIONAL{ ?userUri ");
query.append(RenderUtils.getSPARQLQueryString(SesameRealmConstants.OAS_USEREMAIL));
query.append(" ?userEmail . } ");
if(!findAllUsers)
{
query.append(" FILTER(str(?userIdentifier) = \"" + RenderUtils.escape(userIdentifier) + "\") ");
}
query.append(" } ");
return query.toString();
} | [
"protected",
"String",
"buildSparqlQueryToFindUser",
"(",
"final",
"String",
"userIdentifier",
",",
"boolean",
"findAllUsers",
")",
"{",
"if",
"(",
"!",
"findAllUsers",
"&&",
"userIdentifier",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\... | Builds a SPARQL query to retrieve details of a RestletUtilUser. This method could be
overridden to search for other information regarding a user.
@param userIdentifier
The unique identifier of the User to search for.
@param findAllUsers True to find all users, and false to only find the specified user.
@return A String representation of the SPARQL Select query | [
"Builds",
"a",
"SPARQL",
"query",
"to",
"retrieve",
"details",
"of",
"a",
"RestletUtilUser",
".",
"This",
"method",
"could",
"be",
"overridden",
"to",
"search",
"for",
"other",
"information",
"regarding",
"a",
"user",
"."
] | 6c39a3e91aa8295936af1dbfccd6ba27230c40a9 | https://github.com/ansell/restlet-utils/blob/6c39a3e91aa8295936af1dbfccd6ba27230c40a9/src/main/java/com/github/ansell/restletutils/RestletUtilSesameRealm.java#L630-L666 |
156,019 | ansell/restlet-utils | src/main/java/com/github/ansell/restletutils/RestletUtilSesameRealm.java | RestletUtilSesameRealm.findRoles | public Set<Role> findRoles(final Set<Group> userGroups)
{
final Set<Role> result = new HashSet<Role>();
for(final RoleMapping mapping : this.getRoleMappings())
{
final Object source = mapping.getSource();
if((userGroups != null) && userGroups.contains(source))
{
result.add(mapping.getTarget());
}
}
return result;
} | java | public Set<Role> findRoles(final Set<Group> userGroups)
{
final Set<Role> result = new HashSet<Role>();
for(final RoleMapping mapping : this.getRoleMappings())
{
final Object source = mapping.getSource();
if((userGroups != null) && userGroups.contains(source))
{
result.add(mapping.getTarget());
}
}
return result;
} | [
"public",
"Set",
"<",
"Role",
">",
"findRoles",
"(",
"final",
"Set",
"<",
"Group",
">",
"userGroups",
")",
"{",
"final",
"Set",
"<",
"Role",
">",
"result",
"=",
"new",
"HashSet",
"<",
"Role",
">",
"(",
")",
";",
"for",
"(",
"final",
"RoleMapping",
... | Finds the roles mapped to given user groups.
@param userGroups
The user groups.
@return The roles found. | [
"Finds",
"the",
"roles",
"mapped",
"to",
"given",
"user",
"groups",
"."
] | 6c39a3e91aa8295936af1dbfccd6ba27230c40a9 | https://github.com/ansell/restlet-utils/blob/6c39a3e91aa8295936af1dbfccd6ba27230c40a9/src/main/java/com/github/ansell/restletutils/RestletUtilSesameRealm.java#L899-L914 |
156,020 | ansell/restlet-utils | src/main/java/com/github/ansell/restletutils/RestletUtilSesameRealm.java | RestletUtilSesameRealm.getRootGroups | public List<Group> getRootGroups()
{
List<Group> results = this.cachedRootGroups;
if(results == null)
{
synchronized(this)
{
results = this.cachedRootGroups;
if(results == null)
{
results = new ArrayList<Group>();
RepositoryConnection conn = null;
try
{
conn = this.getRepository().getConnection();
final RepositoryResult<Statement> rootGroupStatements =
conn.getStatements(null, RDF.TYPE, SesameRealmConstants.OAS_ROOTGROUP, true,
this.getContexts());
try
{
while(rootGroupStatements.hasNext())
{
final Statement nextRootGroupStatement = rootGroupStatements.next();
if(nextRootGroupStatement.getSubject() instanceof URI)
{
final URI nextRootGroupUri = (URI)nextRootGroupStatement.getSubject();
// add the group recursively to enable member groups to be added
// recursively
results.add(this.createGroupHierarchy(null, conn, nextRootGroupUri));
}
else
{
this.log.warn("Not including root group as it did not have a URI identifier: {}",
nextRootGroupStatement);
}
}
}
finally
{
rootGroupStatements.close();
}
}
catch(final RepositoryException e)
{
this.log.error("Found exception while trying to get root groups", e);
}
finally
{
try
{
if(conn != null)
{
conn.close();
}
}
catch(final RepositoryException e)
{
this.log.error("Found unexpected exception while closing repository connection", e);
}
}
this.cachedRootGroups = results;
}
}
}
return results;
// throw new RuntimeException(
// "TODO: Implement code not to rely on getting a complete list of groups where possible");
// return this.rootGroups;
} | java | public List<Group> getRootGroups()
{
List<Group> results = this.cachedRootGroups;
if(results == null)
{
synchronized(this)
{
results = this.cachedRootGroups;
if(results == null)
{
results = new ArrayList<Group>();
RepositoryConnection conn = null;
try
{
conn = this.getRepository().getConnection();
final RepositoryResult<Statement> rootGroupStatements =
conn.getStatements(null, RDF.TYPE, SesameRealmConstants.OAS_ROOTGROUP, true,
this.getContexts());
try
{
while(rootGroupStatements.hasNext())
{
final Statement nextRootGroupStatement = rootGroupStatements.next();
if(nextRootGroupStatement.getSubject() instanceof URI)
{
final URI nextRootGroupUri = (URI)nextRootGroupStatement.getSubject();
// add the group recursively to enable member groups to be added
// recursively
results.add(this.createGroupHierarchy(null, conn, nextRootGroupUri));
}
else
{
this.log.warn("Not including root group as it did not have a URI identifier: {}",
nextRootGroupStatement);
}
}
}
finally
{
rootGroupStatements.close();
}
}
catch(final RepositoryException e)
{
this.log.error("Found exception while trying to get root groups", e);
}
finally
{
try
{
if(conn != null)
{
conn.close();
}
}
catch(final RepositoryException e)
{
this.log.error("Found unexpected exception while closing repository connection", e);
}
}
this.cachedRootGroups = results;
}
}
}
return results;
// throw new RuntimeException(
// "TODO: Implement code not to rely on getting a complete list of groups where possible");
// return this.rootGroups;
} | [
"public",
"List",
"<",
"Group",
">",
"getRootGroups",
"(",
")",
"{",
"List",
"<",
"Group",
">",
"results",
"=",
"this",
".",
"cachedRootGroups",
";",
"if",
"(",
"results",
"==",
"null",
")",
"{",
"synchronized",
"(",
"this",
")",
"{",
"results",
"=",
... | Returns the modifiable list of root groups.
@return The modifiable list of root groups. | [
"Returns",
"the",
"modifiable",
"list",
"of",
"root",
"groups",
"."
] | 6c39a3e91aa8295936af1dbfccd6ba27230c40a9 | https://github.com/ansell/restlet-utils/blob/6c39a3e91aa8295936af1dbfccd6ba27230c40a9/src/main/java/com/github/ansell/restletutils/RestletUtilSesameRealm.java#L1238-L1315 |
156,021 | ansell/restlet-utils | src/main/java/com/github/ansell/restletutils/RestletUtilSesameRealm.java | RestletUtilSesameRealm.getUsers | public List<RestletUtilUser> getUsers()
{
List<RestletUtilUser> result = new ArrayList<RestletUtilUser>();
RepositoryConnection conn = null;
try
{
conn = this.repository.getConnection();
final String query = this.buildSparqlQueryToFindUser(null, true);
this.log.debug("findUser: query={}", query);
final TupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, query);
final TupleQueryResult queryResult = tupleQuery.evaluate();
try
{
while(queryResult.hasNext())
{
final BindingSet bindingSet = queryResult.next();
Binding binding = bindingSet.getBinding("userIdentifier");
result.add(this.buildRestletUserFromSparqlResult(binding.getValue().stringValue(), bindingSet));
}
}
finally
{
queryResult.close();
}
}
catch(final RepositoryException e)
{
throw new RuntimeException("Failure finding user in repository", e);
}
catch(final MalformedQueryException e)
{
throw new RuntimeException("Failure finding user in repository", e);
}
catch(final QueryEvaluationException e)
{
throw new RuntimeException("Failure finding user in repository", e);
}
finally
{
try
{
conn.close();
}
catch(final RepositoryException e)
{
this.log.error("Failure to close connection", e);
}
}
return Collections.unmodifiableList(result);
} | java | public List<RestletUtilUser> getUsers()
{
List<RestletUtilUser> result = new ArrayList<RestletUtilUser>();
RepositoryConnection conn = null;
try
{
conn = this.repository.getConnection();
final String query = this.buildSparqlQueryToFindUser(null, true);
this.log.debug("findUser: query={}", query);
final TupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, query);
final TupleQueryResult queryResult = tupleQuery.evaluate();
try
{
while(queryResult.hasNext())
{
final BindingSet bindingSet = queryResult.next();
Binding binding = bindingSet.getBinding("userIdentifier");
result.add(this.buildRestletUserFromSparqlResult(binding.getValue().stringValue(), bindingSet));
}
}
finally
{
queryResult.close();
}
}
catch(final RepositoryException e)
{
throw new RuntimeException("Failure finding user in repository", e);
}
catch(final MalformedQueryException e)
{
throw new RuntimeException("Failure finding user in repository", e);
}
catch(final QueryEvaluationException e)
{
throw new RuntimeException("Failure finding user in repository", e);
}
finally
{
try
{
conn.close();
}
catch(final RepositoryException e)
{
this.log.error("Failure to close connection", e);
}
}
return Collections.unmodifiableList(result);
} | [
"public",
"List",
"<",
"RestletUtilUser",
">",
"getUsers",
"(",
")",
"{",
"List",
"<",
"RestletUtilUser",
">",
"result",
"=",
"new",
"ArrayList",
"<",
"RestletUtilUser",
">",
"(",
")",
";",
"RepositoryConnection",
"conn",
"=",
"null",
";",
"try",
"{",
"con... | Returns an unmodifiable list of users.
@return An unmodifiable list of users. | [
"Returns",
"an",
"unmodifiable",
"list",
"of",
"users",
"."
] | 6c39a3e91aa8295936af1dbfccd6ba27230c40a9 | https://github.com/ansell/restlet-utils/blob/6c39a3e91aa8295936af1dbfccd6ba27230c40a9/src/main/java/com/github/ansell/restletutils/RestletUtilSesameRealm.java#L1338-L1396 |
156,022 | ansell/restlet-utils | src/main/java/com/github/ansell/restletutils/RestletUtilSesameRealm.java | RestletUtilSesameRealm.storeGroup | private void storeGroup(final Group nextGroup, final RepositoryConnection conn, final boolean isRootGroup)
throws RepositoryException
{
if(conn.hasStatement(null, SesameRealmConstants.OAS_GROUPNAME, this.vf.createLiteral(nextGroup.getName()),
true, this.getContexts()))
{
// TODO: Create an update method
throw new RuntimeException(
"A user with the given identifier already exists. Cannot add a new user with that identifier.");
}
final URI nextGroupUUID =
this.vf.createURI("urn:oas:group:", nextGroup.getName() + ":" + UUID.randomUUID().toString());
conn.add(this.vf.createStatement(nextGroupUUID, RDF.TYPE, SesameRealmConstants.OAS_GROUP), this.getContexts());
if(isRootGroup)
{
conn.add(this.vf.createStatement(nextGroupUUID, RDF.TYPE, SesameRealmConstants.OAS_ROOTGROUP),
this.getContexts());
}
conn.add(
this.vf.createStatement(nextGroupUUID, SesameRealmConstants.OAS_GROUPNAME,
this.vf.createLiteral(nextGroup.getName())), this.getContexts());
conn.add(
this.vf.createStatement(nextGroupUUID, SesameRealmConstants.OAS_GROUPDESCRIPTION,
this.vf.createLiteral(nextGroup.getDescription())), this.getContexts());
conn.add(
this.vf.createStatement(nextGroupUUID, SesameRealmConstants.OAS_GROUPINHERITINGROLES,
this.vf.createLiteral(nextGroup.isInheritingRoles())), this.getContexts());
// only store users who cannot be found based on their identifier
for(final User nextUser : nextGroup.getMemberUsers())
{
if(this.findUser(nextUser.getIdentifier()) == null)
{
final URI nextUserUri = this.addUser(nextUser);
}
}
if(!nextGroup.getMemberGroups().isEmpty())
{
for(final Group nextMemberGroup : nextGroup.getMemberGroups())
{
// always set rootGroup parameter to false when recursing into member groups
this.storeGroup(nextMemberGroup, conn, false);
}
}
} | java | private void storeGroup(final Group nextGroup, final RepositoryConnection conn, final boolean isRootGroup)
throws RepositoryException
{
if(conn.hasStatement(null, SesameRealmConstants.OAS_GROUPNAME, this.vf.createLiteral(nextGroup.getName()),
true, this.getContexts()))
{
// TODO: Create an update method
throw new RuntimeException(
"A user with the given identifier already exists. Cannot add a new user with that identifier.");
}
final URI nextGroupUUID =
this.vf.createURI("urn:oas:group:", nextGroup.getName() + ":" + UUID.randomUUID().toString());
conn.add(this.vf.createStatement(nextGroupUUID, RDF.TYPE, SesameRealmConstants.OAS_GROUP), this.getContexts());
if(isRootGroup)
{
conn.add(this.vf.createStatement(nextGroupUUID, RDF.TYPE, SesameRealmConstants.OAS_ROOTGROUP),
this.getContexts());
}
conn.add(
this.vf.createStatement(nextGroupUUID, SesameRealmConstants.OAS_GROUPNAME,
this.vf.createLiteral(nextGroup.getName())), this.getContexts());
conn.add(
this.vf.createStatement(nextGroupUUID, SesameRealmConstants.OAS_GROUPDESCRIPTION,
this.vf.createLiteral(nextGroup.getDescription())), this.getContexts());
conn.add(
this.vf.createStatement(nextGroupUUID, SesameRealmConstants.OAS_GROUPINHERITINGROLES,
this.vf.createLiteral(nextGroup.isInheritingRoles())), this.getContexts());
// only store users who cannot be found based on their identifier
for(final User nextUser : nextGroup.getMemberUsers())
{
if(this.findUser(nextUser.getIdentifier()) == null)
{
final URI nextUserUri = this.addUser(nextUser);
}
}
if(!nextGroup.getMemberGroups().isEmpty())
{
for(final Group nextMemberGroup : nextGroup.getMemberGroups())
{
// always set rootGroup parameter to false when recursing into member groups
this.storeGroup(nextMemberGroup, conn, false);
}
}
} | [
"private",
"void",
"storeGroup",
"(",
"final",
"Group",
"nextGroup",
",",
"final",
"RepositoryConnection",
"conn",
",",
"final",
"boolean",
"isRootGroup",
")",
"throws",
"RepositoryException",
"{",
"if",
"(",
"conn",
".",
"hasStatement",
"(",
"null",
",",
"Sesam... | Stores the group, including a root group statement if rootGroup is true.
@param nextGroup
@param isRootGroup
@throws RepositoryException | [
"Stores",
"the",
"group",
"including",
"a",
"root",
"group",
"statement",
"if",
"rootGroup",
"is",
"true",
"."
] | 6c39a3e91aa8295936af1dbfccd6ba27230c40a9 | https://github.com/ansell/restlet-utils/blob/6c39a3e91aa8295936af1dbfccd6ba27230c40a9/src/main/java/com/github/ansell/restletutils/RestletUtilSesameRealm.java#L1511-L1561 |
156,023 | ansell/restlet-utils | src/main/java/com/github/ansell/restletutils/RestletUtilSesameRealm.java | RestletUtilSesameRealm.unmap | public void unmap(final Group group, final Role role)
{
this.unmap(role, SesameRealmConstants.OAS_ROLEMAPPEDGROUP, group.getName());
} | java | public void unmap(final Group group, final Role role)
{
this.unmap(role, SesameRealmConstants.OAS_ROLEMAPPEDGROUP, group.getName());
} | [
"public",
"void",
"unmap",
"(",
"final",
"Group",
"group",
",",
"final",
"Role",
"role",
")",
"{",
"this",
".",
"unmap",
"(",
"role",
",",
"SesameRealmConstants",
".",
"OAS_ROLEMAPPEDGROUP",
",",
"group",
".",
"getName",
"(",
")",
")",
";",
"}"
] | Unmaps a group defined in a component from a role defined in the application.
@param group
The source group.
@param role
The target role. | [
"Unmaps",
"a",
"group",
"defined",
"in",
"a",
"component",
"from",
"a",
"role",
"defined",
"in",
"the",
"application",
"."
] | 6c39a3e91aa8295936af1dbfccd6ba27230c40a9 | https://github.com/ansell/restlet-utils/blob/6c39a3e91aa8295936af1dbfccd6ba27230c40a9/src/main/java/com/github/ansell/restletutils/RestletUtilSesameRealm.java#L1571-L1574 |
156,024 | ansell/restlet-utils | src/main/java/com/github/ansell/restletutils/RestletUtilSesameRealm.java | RestletUtilSesameRealm.unmap | public void unmap(final RestletUtilUser user, final Role role)
{
this.unmap(role, SesameRealmConstants.OAS_ROLEMAPPEDUSER, user.getIdentifier());
} | java | public void unmap(final RestletUtilUser user, final Role role)
{
this.unmap(role, SesameRealmConstants.OAS_ROLEMAPPEDUSER, user.getIdentifier());
} | [
"public",
"void",
"unmap",
"(",
"final",
"RestletUtilUser",
"user",
",",
"final",
"Role",
"role",
")",
"{",
"this",
".",
"unmap",
"(",
"role",
",",
"SesameRealmConstants",
".",
"OAS_ROLEMAPPEDUSER",
",",
"user",
".",
"getIdentifier",
"(",
")",
")",
";",
"}... | Unmaps a user defined in a component from a role defined in the application.
@param user
The source user.
@param role
The target role. | [
"Unmaps",
"a",
"user",
"defined",
"in",
"a",
"component",
"from",
"a",
"role",
"defined",
"in",
"the",
"application",
"."
] | 6c39a3e91aa8295936af1dbfccd6ba27230c40a9 | https://github.com/ansell/restlet-utils/blob/6c39a3e91aa8295936af1dbfccd6ba27230c40a9/src/main/java/com/github/ansell/restletutils/RestletUtilSesameRealm.java#L1584-L1587 |
156,025 | andreitognolo/raidenjpa | raidenjpa-core/src/main/java/org/raidenjpa/reflection/Cloner.java | Cloner.shallowCopy | @SuppressWarnings("unchecked")
public static <T> T shallowCopy(T original) {
Class<? extends T> clazz = (Class<? extends T>) original.getClass();
BeanClass<? extends T> beanClass = (BeanClass<? extends T>) classes.get(clazz);
if (beanClass == null) {
beanClass = BeanClass.buildFrom(clazz);
classes.put(clazz, beanClass);
}
return shallowCopyHelper(original, beanClass);
} | java | @SuppressWarnings("unchecked")
public static <T> T shallowCopy(T original) {
Class<? extends T> clazz = (Class<? extends T>) original.getClass();
BeanClass<? extends T> beanClass = (BeanClass<? extends T>) classes.get(clazz);
if (beanClass == null) {
beanClass = BeanClass.buildFrom(clazz);
classes.put(clazz, beanClass);
}
return shallowCopyHelper(original, beanClass);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"<",
"T",
">",
"T",
"shallowCopy",
"(",
"T",
"original",
")",
"{",
"Class",
"<",
"?",
"extends",
"T",
">",
"clazz",
"=",
"(",
"Class",
"<",
"?",
"extends",
"T",
">",
")",
"origin... | Requires a no-args constructor
@param original
@return shallow copy of original | [
"Requires",
"a",
"no",
"-",
"args",
"constructor"
] | 1c6e320f9f9d26c89e54f41eab1ef123815d2f06 | https://github.com/andreitognolo/raidenjpa/blob/1c6e320f9f9d26c89e54f41eab1ef123815d2f06/raidenjpa-core/src/main/java/org/raidenjpa/reflection/Cloner.java#L16-L28 |
156,026 | JM-Lab/utils-java8 | src/main/java/kr/jm/utils/helper/JMFiles.java | JMFiles.append | public static Writer append(Writer writer, String string) {
try {
writer.append(string);
writer.flush();
return writer;
} catch (IOException e) {
return JMExceptionManager.handleExceptionAndReturn(log, e,
"append", () -> writer, string);
}
} | java | public static Writer append(Writer writer, String string) {
try {
writer.append(string);
writer.flush();
return writer;
} catch (IOException e) {
return JMExceptionManager.handleExceptionAndReturn(log, e,
"append", () -> writer, string);
}
} | [
"public",
"static",
"Writer",
"append",
"(",
"Writer",
"writer",
",",
"String",
"string",
")",
"{",
"try",
"{",
"writer",
".",
"append",
"(",
"string",
")",
";",
"writer",
".",
"flush",
"(",
")",
";",
"return",
"writer",
";",
"}",
"catch",
"(",
"IOEx... | Append writer.
@param writer the writer
@param string the string
@return the writer | [
"Append",
"writer",
"."
] | 9e407b3f28a7990418a1e877229fa8344f4d78a5 | https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMFiles.java#L33-L42 |
156,027 | JM-Lab/utils-java8 | src/main/java/kr/jm/utils/helper/JMFiles.java | JMFiles.appendLine | public static Writer appendLine(Writer writer, String line) {
return append(writer, line + JMString.LINE_SEPARATOR);
} | java | public static Writer appendLine(Writer writer, String line) {
return append(writer, line + JMString.LINE_SEPARATOR);
} | [
"public",
"static",
"Writer",
"appendLine",
"(",
"Writer",
"writer",
",",
"String",
"line",
")",
"{",
"return",
"append",
"(",
"writer",
",",
"line",
"+",
"JMString",
".",
"LINE_SEPARATOR",
")",
";",
"}"
] | Append line writer.
@param writer the writer
@param line the line
@return the writer | [
"Append",
"line",
"writer",
"."
] | 9e407b3f28a7990418a1e877229fa8344f4d78a5 | https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMFiles.java#L51-L53 |
156,028 | JM-Lab/utils-java8 | src/main/java/kr/jm/utils/helper/JMFiles.java | JMFiles.buildBufferedAppendWriter | public static Writer buildBufferedAppendWriter(Path path, Charset charset) {
try {
if (JMPath.notExists(path))
JMPathOperation.createFileWithParentDirectories(path);
return Files.newBufferedWriter(path, charset, StandardOpenOption
.APPEND);
} catch (IOException e) {
return JMExceptionManager.handleExceptionAndReturnNull(log, e,
"buildBufferedAppendWriter", path, charset);
}
} | java | public static Writer buildBufferedAppendWriter(Path path, Charset charset) {
try {
if (JMPath.notExists(path))
JMPathOperation.createFileWithParentDirectories(path);
return Files.newBufferedWriter(path, charset, StandardOpenOption
.APPEND);
} catch (IOException e) {
return JMExceptionManager.handleExceptionAndReturnNull(log, e,
"buildBufferedAppendWriter", path, charset);
}
} | [
"public",
"static",
"Writer",
"buildBufferedAppendWriter",
"(",
"Path",
"path",
",",
"Charset",
"charset",
")",
"{",
"try",
"{",
"if",
"(",
"JMPath",
".",
"notExists",
"(",
"path",
")",
")",
"JMPathOperation",
".",
"createFileWithParentDirectories",
"(",
"path",... | Build buffered append writer writer.
@param path the path
@param charset the charset
@return the writer | [
"Build",
"buffered",
"append",
"writer",
"writer",
"."
] | 9e407b3f28a7990418a1e877229fa8344f4d78a5 | https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMFiles.java#L72-L82 |
156,029 | JM-Lab/utils-java8 | src/main/java/kr/jm/utils/helper/JMFiles.java | JMFiles.writeString | public static boolean writeString(String inputString, File targetFile) {
if (!targetFile.exists()) {
try {
Files.write(targetFile.toPath(), inputString.getBytes());
} catch (IOException e) {
return JMExceptionManager.handleExceptionAndReturnFalse(log, e,
"writeString", inputString, targetFile);
}
}
return true;
} | java | public static boolean writeString(String inputString, File targetFile) {
if (!targetFile.exists()) {
try {
Files.write(targetFile.toPath(), inputString.getBytes());
} catch (IOException e) {
return JMExceptionManager.handleExceptionAndReturnFalse(log, e,
"writeString", inputString, targetFile);
}
}
return true;
} | [
"public",
"static",
"boolean",
"writeString",
"(",
"String",
"inputString",
",",
"File",
"targetFile",
")",
"{",
"if",
"(",
"!",
"targetFile",
".",
"exists",
"(",
")",
")",
"{",
"try",
"{",
"Files",
".",
"write",
"(",
"targetFile",
".",
"toPath",
"(",
... | Write string boolean.
@param inputString the input string
@param targetFile the target file
@return the boolean | [
"Write",
"string",
"boolean",
"."
] | 9e407b3f28a7990418a1e877229fa8344f4d78a5 | https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMFiles.java#L91-L101 |
156,030 | JM-Lab/utils-java8 | src/main/java/kr/jm/utils/helper/JMFiles.java | JMFiles.createEmptyFile | public static boolean createEmptyFile(File file) {
try {
file.getParentFile().mkdirs();
return file.createNewFile();
} catch (Exception e) {
return JMExceptionManager.handleExceptionAndReturnFalse(log, e,
"createEmptyFile", file);
}
} | java | public static boolean createEmptyFile(File file) {
try {
file.getParentFile().mkdirs();
return file.createNewFile();
} catch (Exception e) {
return JMExceptionManager.handleExceptionAndReturnFalse(log, e,
"createEmptyFile", file);
}
} | [
"public",
"static",
"boolean",
"createEmptyFile",
"(",
"File",
"file",
")",
"{",
"try",
"{",
"file",
".",
"getParentFile",
"(",
")",
".",
"mkdirs",
"(",
")",
";",
"return",
"file",
".",
"createNewFile",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e... | Create empty file boolean.
@param file the file
@return the boolean | [
"Create",
"empty",
"file",
"boolean",
"."
] | 9e407b3f28a7990418a1e877229fa8344f4d78a5 | https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/helper/JMFiles.java#L364-L373 |
156,031 | G2G3Digital/substeps-framework | core/src/main/java/com/technophobia/substeps/model/Util.java | Util.getArgs | public static String[] getArgs(final String patternString, final String sourceString, final String[] keywordPrecedence) {
log.debug("Util getArgs String[] with pattern: " + patternString + " and sourceStr: "
+ sourceString);
String[] rtn = null;
ArrayList<String> argsList = null;
String patternCopy = new String(patternString);
if (keywordPrecedence != null && StringUtils.startsWithAny(patternString, keywordPrecedence)){
//
for (String s : keywordPrecedence){
patternCopy = StringUtils.removeStart(patternCopy, s);
}
patternCopy = "(?:" + StringUtils.join(keywordPrecedence, "|") + ")" + patternCopy;
}
final Pattern pattern = Pattern.compile(patternCopy);
final Matcher matcher = pattern.matcher(sourceString);
final int groupCount = matcher.groupCount();
// TODO - this doesn't work if we're not doing strict matching
if (matcher.find()) {
for (int i = 1; i <= groupCount; i++) {
final String arg = matcher.group(i);
if (arg != null) {
if (argsList == null) {
argsList = new ArrayList<String>();
}
argsList.add(arg);
}
}
}
if (argsList != null) {
rtn = argsList.toArray(new String[argsList.size()]);
if (log.isDebugEnabled()) {
final StringBuilder buf = new StringBuilder();
buf.append("returning args: ");
for (final String s : argsList) {
buf.append("[").append(s).append("] ");
}
log.debug(buf.toString());
}
}
return rtn;
} | java | public static String[] getArgs(final String patternString, final String sourceString, final String[] keywordPrecedence) {
log.debug("Util getArgs String[] with pattern: " + patternString + " and sourceStr: "
+ sourceString);
String[] rtn = null;
ArrayList<String> argsList = null;
String patternCopy = new String(patternString);
if (keywordPrecedence != null && StringUtils.startsWithAny(patternString, keywordPrecedence)){
//
for (String s : keywordPrecedence){
patternCopy = StringUtils.removeStart(patternCopy, s);
}
patternCopy = "(?:" + StringUtils.join(keywordPrecedence, "|") + ")" + patternCopy;
}
final Pattern pattern = Pattern.compile(patternCopy);
final Matcher matcher = pattern.matcher(sourceString);
final int groupCount = matcher.groupCount();
// TODO - this doesn't work if we're not doing strict matching
if (matcher.find()) {
for (int i = 1; i <= groupCount; i++) {
final String arg = matcher.group(i);
if (arg != null) {
if (argsList == null) {
argsList = new ArrayList<String>();
}
argsList.add(arg);
}
}
}
if (argsList != null) {
rtn = argsList.toArray(new String[argsList.size()]);
if (log.isDebugEnabled()) {
final StringBuilder buf = new StringBuilder();
buf.append("returning args: ");
for (final String s : argsList) {
buf.append("[").append(s).append("] ");
}
log.debug(buf.toString());
}
}
return rtn;
} | [
"public",
"static",
"String",
"[",
"]",
"getArgs",
"(",
"final",
"String",
"patternString",
",",
"final",
"String",
"sourceString",
",",
"final",
"String",
"[",
"]",
"keywordPrecedence",
")",
"{",
"log",
".",
"debug",
"(",
"\"Util getArgs String[] with pattern: \"... | - could they be combined ?? | [
"-",
"could",
"they",
"be",
"combined",
"??"
] | c1ec6487e1673a7dae54b5e7b62a96f602cd280a | https://github.com/G2G3Digital/substeps-framework/blob/c1ec6487e1673a7dae54b5e7b62a96f602cd280a/core/src/main/java/com/technophobia/substeps/model/Util.java#L48-L109 |
156,032 | morimekta/utils | io-util/src/main/java/net/morimekta/util/Strings.java | Strings.escape | public static String escape(CharSequence string) {
StringBuilder builder = new StringBuilder();
for (int i = 0; i < string.length(); ++i) {
char c = string.charAt(i);
switch (c) {
case '\b':
builder.append('\\').append('b');
break;
case '\t':
builder.append('\\').append('t');
break;
case '\n':
builder.append('\\').append('n');
break;
case '\f':
builder.append('\\').append('f');
break;
case '\r':
builder.append('\\').append('r');
break;
case '"':
case '\'':
builder.append('\\').append(c);
break;
case '\\':
builder.append('\\').append('\\');
break;
default:
if (c < 32 || c == 127) {
builder.append(String.format("\\%03o", (int) c));
} else if (!isConsolePrintable(c) ||
Character.isHighSurrogate(c) ||
Character.isLowSurrogate(c)) {
builder.append(String.format("\\u%04x", (int) c));
} else {
builder.append(c);
}
break;
}
}
return builder.toString();
} | java | public static String escape(CharSequence string) {
StringBuilder builder = new StringBuilder();
for (int i = 0; i < string.length(); ++i) {
char c = string.charAt(i);
switch (c) {
case '\b':
builder.append('\\').append('b');
break;
case '\t':
builder.append('\\').append('t');
break;
case '\n':
builder.append('\\').append('n');
break;
case '\f':
builder.append('\\').append('f');
break;
case '\r':
builder.append('\\').append('r');
break;
case '"':
case '\'':
builder.append('\\').append(c);
break;
case '\\':
builder.append('\\').append('\\');
break;
default:
if (c < 32 || c == 127) {
builder.append(String.format("\\%03o", (int) c));
} else if (!isConsolePrintable(c) ||
Character.isHighSurrogate(c) ||
Character.isLowSurrogate(c)) {
builder.append(String.format("\\u%04x", (int) c));
} else {
builder.append(c);
}
break;
}
}
return builder.toString();
} | [
"public",
"static",
"String",
"escape",
"(",
"CharSequence",
"string",
")",
"{",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"string",
".",
"length",
"(",
")",
";",
"++",
"i... | Properly java-escape the string for printing to console.
@param string The string to escape.
@return The escaped string. | [
"Properly",
"java",
"-",
"escape",
"the",
"string",
"for",
"printing",
"to",
"console",
"."
] | dc987485902f1a7d58169c89c61db97425a6226d | https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/Strings.java#L50-L91 |
156,033 | morimekta/utils | io-util/src/main/java/net/morimekta/util/Strings.java | Strings.escape | public static String escape(char c) {
switch (c) {
case '\b':
return "\\b";
case '\t':
return "\\t";
case '\n':
return "\\n";
case '\f':
return "\\f";
case '\r':
return "\\r";
case '"':
return "\\\"";
case '\'':
return "\\'";
case '\\':
return "\\\\";
default:
if (c < 32 || c == 127) {
return String.format("\\%03o", (int) c);
} else if (!isConsolePrintable(c) ||
isHighSurrogate(c) ||
isLowSurrogate(c)) {
return String.format("\\u%04x", (int) c);
}
return String.valueOf(c);
}
} | java | public static String escape(char c) {
switch (c) {
case '\b':
return "\\b";
case '\t':
return "\\t";
case '\n':
return "\\n";
case '\f':
return "\\f";
case '\r':
return "\\r";
case '"':
return "\\\"";
case '\'':
return "\\'";
case '\\':
return "\\\\";
default:
if (c < 32 || c == 127) {
return String.format("\\%03o", (int) c);
} else if (!isConsolePrintable(c) ||
isHighSurrogate(c) ||
isLowSurrogate(c)) {
return String.format("\\u%04x", (int) c);
}
return String.valueOf(c);
}
} | [
"public",
"static",
"String",
"escape",
"(",
"char",
"c",
")",
"{",
"switch",
"(",
"c",
")",
"{",
"case",
"'",
"'",
":",
"return",
"\"\\\\b\"",
";",
"case",
"'",
"'",
":",
"return",
"\"\\\\t\"",
";",
"case",
"'",
"'",
":",
"return",
"\"\\\\n\"",
";... | Escape a single character. It is escaped into a string, as it may become
more than one char when escaped.
@param c The char to escape.
@return The escaped char string. | [
"Escape",
"a",
"single",
"character",
".",
"It",
"is",
"escaped",
"into",
"a",
"string",
"as",
"it",
"may",
"become",
"more",
"than",
"one",
"char",
"when",
"escaped",
"."
] | dc987485902f1a7d58169c89c61db97425a6226d | https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/Strings.java#L100-L128 |
156,034 | morimekta/utils | io-util/src/main/java/net/morimekta/util/Strings.java | Strings.join | public static String join(String delimiter, Object... values) {
// Since primitive arrays does not pass as a values array, but as it's
// single first element.
if (values.length == 1) {
Class<?> type = values[0].getClass();
if (char[].class.equals(type)) {
return joinP(delimiter, (char[]) values[0]);
} else if (int[].class.equals(type)) {
return joinP(delimiter, (int[]) values[0]);
} else if (long[].class.equals(type)) {
return joinP(delimiter, (long[]) values[0]);
} else if (double[].class.equals(type)) {
return joinP(delimiter, (double[]) values[0]);
} else if (boolean[].class.equals(type)) {
return joinP(delimiter, (boolean[]) values[0]);
}
}
StringBuilder builder = new StringBuilder();
boolean first = true;
for (Object value : values) {
if (first) {
first = false;
} else {
builder.append(delimiter);
}
builder.append(Objects.toString(value));
}
return builder.toString();
} | java | public static String join(String delimiter, Object... values) {
// Since primitive arrays does not pass as a values array, but as it's
// single first element.
if (values.length == 1) {
Class<?> type = values[0].getClass();
if (char[].class.equals(type)) {
return joinP(delimiter, (char[]) values[0]);
} else if (int[].class.equals(type)) {
return joinP(delimiter, (int[]) values[0]);
} else if (long[].class.equals(type)) {
return joinP(delimiter, (long[]) values[0]);
} else if (double[].class.equals(type)) {
return joinP(delimiter, (double[]) values[0]);
} else if (boolean[].class.equals(type)) {
return joinP(delimiter, (boolean[]) values[0]);
}
}
StringBuilder builder = new StringBuilder();
boolean first = true;
for (Object value : values) {
if (first) {
first = false;
} else {
builder.append(delimiter);
}
builder.append(Objects.toString(value));
}
return builder.toString();
} | [
"public",
"static",
"String",
"join",
"(",
"String",
"delimiter",
",",
"Object",
"...",
"values",
")",
"{",
"// Since primitive arrays does not pass as a values array, but as it's",
"// single first element.",
"if",
"(",
"values",
".",
"length",
"==",
"1",
")",
"{",
"... | Join set of arbitrary values with delimiter.
@param delimiter The delimiter.
@param values The values to join.
@return The joined string. | [
"Join",
"set",
"of",
"arbitrary",
"values",
"with",
"delimiter",
"."
] | dc987485902f1a7d58169c89c61db97425a6226d | https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/Strings.java#L244-L274 |
156,035 | morimekta/utils | io-util/src/main/java/net/morimekta/util/Strings.java | Strings.join | public static <T> String join(String delimiter, Collection<T> strings) {
StringBuilder builder = new StringBuilder();
boolean first = true;
for (T o : strings) {
if (first) {
first = false;
} else {
builder.append(delimiter);
}
builder.append(Objects.toString(o));
}
return builder.toString();
} | java | public static <T> String join(String delimiter, Collection<T> strings) {
StringBuilder builder = new StringBuilder();
boolean first = true;
for (T o : strings) {
if (first) {
first = false;
} else {
builder.append(delimiter);
}
builder.append(Objects.toString(o));
}
return builder.toString();
} | [
"public",
"static",
"<",
"T",
">",
"String",
"join",
"(",
"String",
"delimiter",
",",
"Collection",
"<",
"T",
">",
"strings",
")",
"{",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"boolean",
"first",
"=",
"true",
";",
"for",
... | Join collection with delimiter.
@param <T> Collection item type.
@param delimiter The delimiter.
@param strings The string collection to join.
@return The joined string. | [
"Join",
"collection",
"with",
"delimiter",
"."
] | dc987485902f1a7d58169c89c61db97425a6226d | https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/Strings.java#L389-L401 |
156,036 | morimekta/utils | io-util/src/main/java/net/morimekta/util/Strings.java | Strings.times | public static String times(String s, int num) {
StringBuilder builder = new StringBuilder();
for (int i = 0; i < num; ++i) {
builder.append(s);
}
return builder.toString();
} | java | public static String times(String s, int num) {
StringBuilder builder = new StringBuilder();
for (int i = 0; i < num; ++i) {
builder.append(s);
}
return builder.toString();
} | [
"public",
"static",
"String",
"times",
"(",
"String",
"s",
",",
"int",
"num",
")",
"{",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"num",
";",
"++",
"i",
")",
"{",
"bui... | Multiply a string N times.
@param s The string to multiply.
@param num N
@return The result. | [
"Multiply",
"a",
"string",
"N",
"times",
"."
] | dc987485902f1a7d58169c89c61db97425a6226d | https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/Strings.java#L442-L448 |
156,037 | morimekta/utils | io-util/src/main/java/net/morimekta/util/Strings.java | Strings.camelCase | public static String camelCase(String name) {
StringBuilder builder = new StringBuilder();
String[] parts = CAMEL_CASE_DELIMITER.split(name);
for (String part : parts) {
if (part.isEmpty()) {
continue;
}
builder.append(capitalize(part));
}
return builder.toString();
} | java | public static String camelCase(String name) {
StringBuilder builder = new StringBuilder();
String[] parts = CAMEL_CASE_DELIMITER.split(name);
for (String part : parts) {
if (part.isEmpty()) {
continue;
}
builder.append(capitalize(part));
}
return builder.toString();
} | [
"public",
"static",
"String",
"camelCase",
"(",
"String",
"name",
")",
"{",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"String",
"[",
"]",
"parts",
"=",
"CAMEL_CASE_DELIMITER",
".",
"split",
"(",
"name",
")",
";",
"for",
"(",
... | Format a name as CamelCase. The name is split on non-alphabet non-numeric
chars, and joined with each part capitalized. This is also called
PascalCase. There is in this instance no assumptions on the name itself,
other than it contains some alphabet characters. Any uppercase letters
in the name will be kept as uppercase, so that a CamelCase name will
stay CamelCase through this call.
@param name The name to camel-case.
@return TheCamelCasedName | [
"Format",
"a",
"name",
"as",
"CamelCase",
".",
"The",
"name",
"is",
"split",
"on",
"non",
"-",
"alphabet",
"non",
"-",
"numeric",
"chars",
"and",
"joined",
"with",
"each",
"part",
"capitalized",
".",
"This",
"is",
"also",
"called",
"PascalCase",
".",
"Th... | dc987485902f1a7d58169c89c61db97425a6226d | https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/Strings.java#L473-L483 |
156,038 | morimekta/utils | io-util/src/main/java/net/morimekta/util/Strings.java | Strings.c_case | public static String c_case(String prefix, String name, String suffix) {
// Assume we insert at most 4 '_' chars for a majority of names.
StringBuilder builder = new StringBuilder(prefix.length() + name.length() + 5);
builder.append(prefix);
boolean lastUpper = true;
for (char c : name.toCharArray()) {
if (Character.isUpperCase(c)) {
if (!lastUpper) {
builder.append('_');
}
lastUpper = true;
} else if (c == '_' || c == '.' || c == '-') {
builder.append('_');
lastUpper = true;
continue;
} else if (!Character.isDigit(c)) {
lastUpper = false;
}
builder.append(Character.toLowerCase(c));
}
builder.append(suffix);
return builder.toString();
} | java | public static String c_case(String prefix, String name, String suffix) {
// Assume we insert at most 4 '_' chars for a majority of names.
StringBuilder builder = new StringBuilder(prefix.length() + name.length() + 5);
builder.append(prefix);
boolean lastUpper = true;
for (char c : name.toCharArray()) {
if (Character.isUpperCase(c)) {
if (!lastUpper) {
builder.append('_');
}
lastUpper = true;
} else if (c == '_' || c == '.' || c == '-') {
builder.append('_');
lastUpper = true;
continue;
} else if (!Character.isDigit(c)) {
lastUpper = false;
}
builder.append(Character.toLowerCase(c));
}
builder.append(suffix);
return builder.toString();
} | [
"public",
"static",
"String",
"c_case",
"(",
"String",
"prefix",
",",
"String",
"name",
",",
"String",
"suffix",
")",
"{",
"// Assume we insert at most 4 '_' chars for a majority of names.",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
"prefix",
".",
... | Format a prefixed name as c_case. The prefix is kept verbatim, while the
name has a '_' character inserted before each upper-case letter, not
including the first character. Then the whole thing is lower-cased.
@param prefix The prefix.
@param name The name to c-case.
@param suffix The suffix.
@return the_c_cased_name | [
"Format",
"a",
"prefixed",
"name",
"as",
"c_case",
".",
"The",
"prefix",
"is",
"kept",
"verbatim",
"while",
"the",
"name",
"has",
"a",
"_",
"character",
"inserted",
"before",
"each",
"upper",
"-",
"case",
"letter",
"not",
"including",
"the",
"first",
"char... | dc987485902f1a7d58169c89c61db97425a6226d | https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/Strings.java#L495-L519 |
156,039 | morimekta/utils | io-util/src/main/java/net/morimekta/util/Strings.java | Strings.asString | public static String asString(Collection<?> collection) {
if (collection == null) {
return NULL;
}
StringBuilder builder = new StringBuilder();
builder.append('[');
boolean first = true;
for (Object item : collection) {
if (first) {
first = false;
} else {
builder.append(',');
}
builder.append(asString(item));
}
builder.append(']');
return builder.toString();
} | java | public static String asString(Collection<?> collection) {
if (collection == null) {
return NULL;
}
StringBuilder builder = new StringBuilder();
builder.append('[');
boolean first = true;
for (Object item : collection) {
if (first) {
first = false;
} else {
builder.append(',');
}
builder.append(asString(item));
}
builder.append(']');
return builder.toString();
} | [
"public",
"static",
"String",
"asString",
"(",
"Collection",
"<",
"?",
">",
"collection",
")",
"{",
"if",
"(",
"collection",
"==",
"null",
")",
"{",
"return",
"NULL",
";",
"}",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"buil... | Make a printable string from a collection using the tools here.
@param collection The collection to stringify.
@return The collection string value. | [
"Make",
"a",
"printable",
"string",
"from",
"a",
"collection",
"using",
"the",
"tools",
"here",
"."
] | dc987485902f1a7d58169c89c61db97425a6226d | https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/Strings.java#L583-L600 |
156,040 | morimekta/utils | io-util/src/main/java/net/morimekta/util/Strings.java | Strings.asString | public static String asString(Map<?, ?> map) {
if (map == null) {
return NULL;
}
StringBuilder builder = new StringBuilder();
builder.append('{');
boolean first = true;
for (Map.Entry<?, ?> entry : map.entrySet()) {
if (first) {
first = false;
} else {
builder.append(',');
}
builder.append(asString(entry.getKey()))
.append(':')
.append(asString(entry.getValue()));
}
builder.append('}');
return builder.toString();
} | java | public static String asString(Map<?, ?> map) {
if (map == null) {
return NULL;
}
StringBuilder builder = new StringBuilder();
builder.append('{');
boolean first = true;
for (Map.Entry<?, ?> entry : map.entrySet()) {
if (first) {
first = false;
} else {
builder.append(',');
}
builder.append(asString(entry.getKey()))
.append(':')
.append(asString(entry.getValue()));
}
builder.append('}');
return builder.toString();
} | [
"public",
"static",
"String",
"asString",
"(",
"Map",
"<",
"?",
",",
"?",
">",
"map",
")",
"{",
"if",
"(",
"map",
"==",
"null",
")",
"{",
"return",
"NULL",
";",
"}",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"builder",
... | Make a minimal printable string value from a typed map.
@param map The map to stringify.
@return The resulting string. | [
"Make",
"a",
"minimal",
"printable",
"string",
"value",
"from",
"a",
"typed",
"map",
"."
] | dc987485902f1a7d58169c89c61db97425a6226d | https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/Strings.java#L608-L627 |
156,041 | morimekta/utils | io-util/src/main/java/net/morimekta/util/Strings.java | Strings.asString | public static String asString(Object o) {
if (o == null) {
return NULL;
} else if (o instanceof Stringable) {
return ((Stringable) o).asString();
} else if (o instanceof Numeric) {
return String.format("%d", ((Numeric) o).asInteger());
} else if (o instanceof CharSequence) {
return String.format("\"%s\"", escape((CharSequence) o));
} else if (o instanceof Double) {
return asString(((Double) o).doubleValue());
} else if (o instanceof Collection) {
return asString((Collection<?>) o);
} else if (o instanceof Map) {
return asString((Map<?, ?>) o);
} else {
return o.toString();
}
} | java | public static String asString(Object o) {
if (o == null) {
return NULL;
} else if (o instanceof Stringable) {
return ((Stringable) o).asString();
} else if (o instanceof Numeric) {
return String.format("%d", ((Numeric) o).asInteger());
} else if (o instanceof CharSequence) {
return String.format("\"%s\"", escape((CharSequence) o));
} else if (o instanceof Double) {
return asString(((Double) o).doubleValue());
} else if (o instanceof Collection) {
return asString((Collection<?>) o);
} else if (o instanceof Map) {
return asString((Map<?, ?>) o);
} else {
return o.toString();
}
} | [
"public",
"static",
"String",
"asString",
"(",
"Object",
"o",
")",
"{",
"if",
"(",
"o",
"==",
"null",
")",
"{",
"return",
"NULL",
";",
"}",
"else",
"if",
"(",
"o",
"instanceof",
"Stringable",
")",
"{",
"return",
"(",
"(",
"Stringable",
")",
"o",
")... | Make an object into a string using the typed tools here.
@param o The object to stringify.
@return The resulting string. | [
"Make",
"an",
"object",
"into",
"a",
"string",
"using",
"the",
"typed",
"tools",
"here",
"."
] | dc987485902f1a7d58169c89c61db97425a6226d | https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/Strings.java#L635-L653 |
156,042 | morimekta/utils | io-util/src/main/java/net/morimekta/util/Strings.java | Strings.commonPrefix | public static int commonPrefix(String text1, String text2) {
// Performance analysis: http://neil.fraser.name/news/2007/10/09/
int n = Math.min(text1.length(), text2.length());
for (int i = 0; i < n; i++) {
if (text1.charAt(i) != text2.charAt(i)) {
return i;
}
}
return n;
} | java | public static int commonPrefix(String text1, String text2) {
// Performance analysis: http://neil.fraser.name/news/2007/10/09/
int n = Math.min(text1.length(), text2.length());
for (int i = 0; i < n; i++) {
if (text1.charAt(i) != text2.charAt(i)) {
return i;
}
}
return n;
} | [
"public",
"static",
"int",
"commonPrefix",
"(",
"String",
"text1",
",",
"String",
"text2",
")",
"{",
"// Performance analysis: http://neil.fraser.name/news/2007/10/09/",
"int",
"n",
"=",
"Math",
".",
"min",
"(",
"text1",
".",
"length",
"(",
")",
",",
"text2",
".... | Determine the common prefix of two strings
@param text1 First string.
@param text2 Second string.
@return The number of characters common to the start of each string. | [
"Determine",
"the",
"common",
"prefix",
"of",
"two",
"strings"
] | dc987485902f1a7d58169c89c61db97425a6226d | https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/Strings.java#L680-L689 |
156,043 | morimekta/utils | io-util/src/main/java/net/morimekta/util/Strings.java | Strings.commonSuffix | public static int commonSuffix(String text1, String text2) {
// Performance analysis: http://neil.fraser.name/news/2007/10/09/
int text1_length = text1.length();
int text2_length = text2.length();
int n = Math.min(text1_length, text2_length);
for (int i = 1; i <= n; i++) {
if (text1.charAt(text1_length - i) != text2.charAt(text2_length - i)) {
return i - 1;
}
}
return n;
} | java | public static int commonSuffix(String text1, String text2) {
// Performance analysis: http://neil.fraser.name/news/2007/10/09/
int text1_length = text1.length();
int text2_length = text2.length();
int n = Math.min(text1_length, text2_length);
for (int i = 1; i <= n; i++) {
if (text1.charAt(text1_length - i) != text2.charAt(text2_length - i)) {
return i - 1;
}
}
return n;
} | [
"public",
"static",
"int",
"commonSuffix",
"(",
"String",
"text1",
",",
"String",
"text2",
")",
"{",
"// Performance analysis: http://neil.fraser.name/news/2007/10/09/",
"int",
"text1_length",
"=",
"text1",
".",
"length",
"(",
")",
";",
"int",
"text2_length",
"=",
"... | Determine the common suffix of two strings
@param text1 First string.
@param text2 Second string.
@return The number of characters common to the end of each string. | [
"Determine",
"the",
"common",
"suffix",
"of",
"two",
"strings"
] | dc987485902f1a7d58169c89c61db97425a6226d | https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/Strings.java#L697-L708 |
156,044 | morimekta/utils | io-util/src/main/java/net/morimekta/util/Strings.java | Strings.commonOverlap | public static int commonOverlap(String text1, String text2) {
// Cache the text lengths to prevent multiple calls.
int text1_length = text1.length();
int text2_length = text2.length();
// Eliminate the null case.
if (text1_length == 0 || text2_length == 0) {
return 0;
}
// Truncate the longer string.
if (text1_length > text2_length) {
text1 = text1.substring(text1_length - text2_length);
} else if (text1_length < text2_length) {
text2 = text2.substring(0, text1_length);
}
int text_length = Math.min(text1_length, text2_length);
// Quick check for the worst case.
if (text1.equals(text2)) {
return text_length;
}
// Start by looking for a single character match
// and increase length until no match is found.
// Performance analysis: http://neil.fraser.name/news/2010/11/04/
int best = 0;
int length = 1;
while (true) {
String pattern = text1.substring(text_length - length);
int found = text2.indexOf(pattern);
if (found == -1) {
return best;
}
length += found;
if (found == 0 || text1.substring(text_length - length).equals(
text2.substring(0, length))) {
best = length;
length++;
}
}
} | java | public static int commonOverlap(String text1, String text2) {
// Cache the text lengths to prevent multiple calls.
int text1_length = text1.length();
int text2_length = text2.length();
// Eliminate the null case.
if (text1_length == 0 || text2_length == 0) {
return 0;
}
// Truncate the longer string.
if (text1_length > text2_length) {
text1 = text1.substring(text1_length - text2_length);
} else if (text1_length < text2_length) {
text2 = text2.substring(0, text1_length);
}
int text_length = Math.min(text1_length, text2_length);
// Quick check for the worst case.
if (text1.equals(text2)) {
return text_length;
}
// Start by looking for a single character match
// and increase length until no match is found.
// Performance analysis: http://neil.fraser.name/news/2010/11/04/
int best = 0;
int length = 1;
while (true) {
String pattern = text1.substring(text_length - length);
int found = text2.indexOf(pattern);
if (found == -1) {
return best;
}
length += found;
if (found == 0 || text1.substring(text_length - length).equals(
text2.substring(0, length))) {
best = length;
length++;
}
}
} | [
"public",
"static",
"int",
"commonOverlap",
"(",
"String",
"text1",
",",
"String",
"text2",
")",
"{",
"// Cache the text lengths to prevent multiple calls.",
"int",
"text1_length",
"=",
"text1",
".",
"length",
"(",
")",
";",
"int",
"text2_length",
"=",
"text2",
".... | Determine if the suffix of one string is the prefix of another.
@param text1 First string.
@param text2 Second string.
@return The number of characters common to the end of the first
string and the start of the second string. | [
"Determine",
"if",
"the",
"suffix",
"of",
"one",
"string",
"is",
"the",
"prefix",
"of",
"another",
"."
] | dc987485902f1a7d58169c89c61db97425a6226d | https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/Strings.java#L717-L755 |
156,045 | foundation-runtime/service-directory | 2.0/sd-core/src/main/java/com/cisco/oss/foundation/directory/ServiceDirectoryThread.java | ServiceDirectoryThread.getThreadName | public static String getThreadName(String name){
if(name==null || name.isEmpty()){
return SD_THREAD_PREFIX + nextIndex();
}
return SD_THREAD_PREFIX + name + "_" + nextIndex();
} | java | public static String getThreadName(String name){
if(name==null || name.isEmpty()){
return SD_THREAD_PREFIX + nextIndex();
}
return SD_THREAD_PREFIX + name + "_" + nextIndex();
} | [
"public",
"static",
"String",
"getThreadName",
"(",
"String",
"name",
")",
"{",
"if",
"(",
"name",
"==",
"null",
"||",
"name",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"SD_THREAD_PREFIX",
"+",
"nextIndex",
"(",
")",
";",
"}",
"return",
"SD_THREAD_PR... | Get the SD prefixed thread name.
@param name
the thread name.
@return
the prefixed thread name. | [
"Get",
"the",
"SD",
"prefixed",
"thread",
"name",
"."
] | a7bdefe173dc99e75eff4a24e07e6407e62f2ed4 | https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-core/src/main/java/com/cisco/oss/foundation/directory/ServiceDirectoryThread.java#L92-L97 |
156,046 | foundation-runtime/service-directory | 2.0/sd-core/src/main/java/com/cisco/oss/foundation/directory/ServiceDirectoryThread.java | ServiceDirectoryThread.doThread | private static Thread doThread(Runnable runnable, String name, boolean deamon){
String realname = getThreadName(name);
Thread t = new Thread(runnable);
t.setName(realname);
t.setDaemon(deamon);
return t;
} | java | private static Thread doThread(Runnable runnable, String name, boolean deamon){
String realname = getThreadName(name);
Thread t = new Thread(runnable);
t.setName(realname);
t.setDaemon(deamon);
return t;
} | [
"private",
"static",
"Thread",
"doThread",
"(",
"Runnable",
"runnable",
",",
"String",
"name",
",",
"boolean",
"deamon",
")",
"{",
"String",
"realname",
"=",
"getThreadName",
"(",
"name",
")",
";",
"Thread",
"t",
"=",
"new",
"Thread",
"(",
"runnable",
")",... | Generate the Thread.
@param runnable
the runnable task.
@param name
the thread name.
@param deamon
the deamon flag.
@return
the Thread. | [
"Generate",
"the",
"Thread",
"."
] | a7bdefe173dc99e75eff4a24e07e6407e62f2ed4 | https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-core/src/main/java/com/cisco/oss/foundation/directory/ServiceDirectoryThread.java#L121-L127 |
156,047 | opencb/datastore | datastore-hbase/src/main/java/org/opencb/datastore/hbase/HBaseNativeQuery.java | HBaseNativeQuery.find | public Result find(String rowKey, List<String> returnFields, QueryOptions options) throws IOException {
Get get = new Get(rowKey.getBytes());
if (returnFields != null) {
for (String field : returnFields) {
String[] parts = field.split(":");
get.addColumn(parts[0].getBytes(), parts[1].getBytes());
}
} else {
getReturnFields(get, options);
}
int maxVersions = (options != null) ? options.getInt("maxVersions", 0) : 0;
if (maxVersions > 0) {
get.setMaxVersions(maxVersions);
}
return table.get(get);
} | java | public Result find(String rowKey, List<String> returnFields, QueryOptions options) throws IOException {
Get get = new Get(rowKey.getBytes());
if (returnFields != null) {
for (String field : returnFields) {
String[] parts = field.split(":");
get.addColumn(parts[0].getBytes(), parts[1].getBytes());
}
} else {
getReturnFields(get, options);
}
int maxVersions = (options != null) ? options.getInt("maxVersions", 0) : 0;
if (maxVersions > 0) {
get.setMaxVersions(maxVersions);
}
return table.get(get);
} | [
"public",
"Result",
"find",
"(",
"String",
"rowKey",
",",
"List",
"<",
"String",
">",
"returnFields",
",",
"QueryOptions",
"options",
")",
"throws",
"IOException",
"{",
"Get",
"get",
"=",
"new",
"Get",
"(",
"rowKey",
".",
"getBytes",
"(",
")",
")",
";",
... | Returns the result from a query to a single row, performed using a Get
object from HBase API.
@param rowKey Row key to query
@param returnFields List of fields to return, in pairs of format cf:col
@param options
@return
@throws IOException | [
"Returns",
"the",
"result",
"from",
"a",
"query",
"to",
"a",
"single",
"row",
"performed",
"using",
"a",
"Get",
"object",
"from",
"HBase",
"API",
"."
] | c6b92b30385d5fc5cc191e2db96c46b0389a88c7 | https://github.com/opencb/datastore/blob/c6b92b30385d5fc5cc191e2db96c46b0389a88c7/datastore-hbase/src/main/java/org/opencb/datastore/hbase/HBaseNativeQuery.java#L69-L87 |
156,048 | opencb/datastore | datastore-hbase/src/main/java/org/opencb/datastore/hbase/HBaseNativeQuery.java | HBaseNativeQuery.find | public Iterator<Result> find(String startRow, String endRow, List<String> returnFields, QueryOptions options) throws IOException {
Scan scan = new Scan(startRow.getBytes(), endRow.getBytes());
if (returnFields != null) {
for (String field : returnFields) {
String[] parts = field.split(":");
scan.addColumn(parts[0].getBytes(), parts[1].getBytes());
}
} else {
getReturnFields(scan, options);
}
int maxVersions = (options != null) ? options.getInt("maxVersions", 0) : 0;
if (maxVersions > 0) {
scan.setMaxVersions(maxVersions);
}
int limit = (options != null) ? options.getInt("limit", 0) : 0;
if (limit > 0) {
scan.setFilter(new PageFilter(limit));
}
String sort = (options != null) ? options.getString("sort") : null;
if (sort != null) {
if (sort.equalsIgnoreCase("asc")) {
scan.setReversed(false);
} else if (sort.equalsIgnoreCase("desc")) {
scan.setReversed(true);
}
}
ResultScanner scanres = table.getScanner(scan);
return scanres.iterator();
} | java | public Iterator<Result> find(String startRow, String endRow, List<String> returnFields, QueryOptions options) throws IOException {
Scan scan = new Scan(startRow.getBytes(), endRow.getBytes());
if (returnFields != null) {
for (String field : returnFields) {
String[] parts = field.split(":");
scan.addColumn(parts[0].getBytes(), parts[1].getBytes());
}
} else {
getReturnFields(scan, options);
}
int maxVersions = (options != null) ? options.getInt("maxVersions", 0) : 0;
if (maxVersions > 0) {
scan.setMaxVersions(maxVersions);
}
int limit = (options != null) ? options.getInt("limit", 0) : 0;
if (limit > 0) {
scan.setFilter(new PageFilter(limit));
}
String sort = (options != null) ? options.getString("sort") : null;
if (sort != null) {
if (sort.equalsIgnoreCase("asc")) {
scan.setReversed(false);
} else if (sort.equalsIgnoreCase("desc")) {
scan.setReversed(true);
}
}
ResultScanner scanres = table.getScanner(scan);
return scanres.iterator();
} | [
"public",
"Iterator",
"<",
"Result",
">",
"find",
"(",
"String",
"startRow",
",",
"String",
"endRow",
",",
"List",
"<",
"String",
">",
"returnFields",
",",
"QueryOptions",
"options",
")",
"throws",
"IOException",
"{",
"Scan",
"scan",
"=",
"new",
"Scan",
"(... | Returns the results from a query to multiple rows, performed using a Scan
object from HBase API.
@param startRow First row key to query
@param endRow Last row key to query
@param returnFields List of fields to return, in pairs of format cf:col
@param options
@return
@throws IOException
@see <a href="https://stackoverflow.com/questions/17981450/row-pagination-with-hbase">Instructions on how to perform pagination in HBase</a> | [
"Returns",
"the",
"results",
"from",
"a",
"query",
"to",
"multiple",
"rows",
"performed",
"using",
"a",
"Scan",
"object",
"from",
"HBase",
"API",
"."
] | c6b92b30385d5fc5cc191e2db96c46b0389a88c7 | https://github.com/opencb/datastore/blob/c6b92b30385d5fc5cc191e2db96c46b0389a88c7/datastore-hbase/src/main/java/org/opencb/datastore/hbase/HBaseNativeQuery.java#L101-L134 |
156,049 | hudson3-plugins/warnings-plugin | src/main/java/hudson/plugins/warnings/WarningsDescriptor.java | WarningsDescriptor.getResultUrl | public static String getResultUrl(final String group) {
if (group == null) { // prior 4.0
return RESULT_URL;
}
else {
return PLUGIN_ID + ParserRegistry.getUrl(group) + RESULT_URL_SUFFIX;
}
} | java | public static String getResultUrl(final String group) {
if (group == null) { // prior 4.0
return RESULT_URL;
}
else {
return PLUGIN_ID + ParserRegistry.getUrl(group) + RESULT_URL_SUFFIX;
}
} | [
"public",
"static",
"String",
"getResultUrl",
"(",
"final",
"String",
"group",
")",
"{",
"if",
"(",
"group",
"==",
"null",
")",
"{",
"// prior 4.0",
"return",
"RESULT_URL",
";",
"}",
"else",
"{",
"return",
"PLUGIN_ID",
"+",
"ParserRegistry",
".",
"getUrl",
... | Returns the URL of the warning results for the specified parser.
@param group
the parser group
@return a unique URL | [
"Returns",
"the",
"URL",
"of",
"the",
"warning",
"results",
"for",
"the",
"specified",
"parser",
"."
] | 462c9f3dffede9120173935567392b22520b0966 | https://github.com/hudson3-plugins/warnings-plugin/blob/462c9f3dffede9120173935567392b22520b0966/src/main/java/hudson/plugins/warnings/WarningsDescriptor.java#L53-L60 |
156,050 | hudson3-plugins/warnings-plugin | src/main/java/hudson/plugins/warnings/WarningsDescriptor.java | WarningsDescriptor.getProjectUrl | public static String getProjectUrl(final String group) {
if (group == null) { // prior 4.0
return PLUGIN_ID;
}
else {
return PLUGIN_ID + ParserRegistry.getUrl(group);
}
} | java | public static String getProjectUrl(final String group) {
if (group == null) { // prior 4.0
return PLUGIN_ID;
}
else {
return PLUGIN_ID + ParserRegistry.getUrl(group);
}
} | [
"public",
"static",
"String",
"getProjectUrl",
"(",
"final",
"String",
"group",
")",
"{",
"if",
"(",
"group",
"==",
"null",
")",
"{",
"// prior 4.0",
"return",
"PLUGIN_ID",
";",
"}",
"else",
"{",
"return",
"PLUGIN_ID",
"+",
"ParserRegistry",
".",
"getUrl",
... | Returns the URL of the warning project for the specified parser.
@param group
the parser group
@return a unique URL | [
"Returns",
"the",
"URL",
"of",
"the",
"warning",
"project",
"for",
"the",
"specified",
"parser",
"."
] | 462c9f3dffede9120173935567392b22520b0966 | https://github.com/hudson3-plugins/warnings-plugin/blob/462c9f3dffede9120173935567392b22520b0966/src/main/java/hudson/plugins/warnings/WarningsDescriptor.java#L69-L76 |
156,051 | hudson3-plugins/warnings-plugin | src/main/java/hudson/plugins/warnings/WarningsDescriptor.java | WarningsDescriptor.getDynamic | public Object getDynamic(final String link, final StaplerRequest request, final StaplerResponse response) {
if ("configureDefaults".equals(link)) {
Ancestor ancestor = request.findAncestor(AbstractProject.class);
if (ancestor.getObject() instanceof AbstractProject) {
AbstractProject<?, ?> project = (AbstractProject<?, ?>)ancestor.getObject();
return new DefaultGraphConfigurationView(
new GraphConfiguration(WarningsProjectAction.getAllGraphs()), project, "warnings",
new NullBuildHistory(),
project.getAbsoluteUrl() + "/descriptorByName/WarningsPublisher/configureDefaults/");
}
}
return null;
} | java | public Object getDynamic(final String link, final StaplerRequest request, final StaplerResponse response) {
if ("configureDefaults".equals(link)) {
Ancestor ancestor = request.findAncestor(AbstractProject.class);
if (ancestor.getObject() instanceof AbstractProject) {
AbstractProject<?, ?> project = (AbstractProject<?, ?>)ancestor.getObject();
return new DefaultGraphConfigurationView(
new GraphConfiguration(WarningsProjectAction.getAllGraphs()), project, "warnings",
new NullBuildHistory(),
project.getAbsoluteUrl() + "/descriptorByName/WarningsPublisher/configureDefaults/");
}
}
return null;
} | [
"public",
"Object",
"getDynamic",
"(",
"final",
"String",
"link",
",",
"final",
"StaplerRequest",
"request",
",",
"final",
"StaplerResponse",
"response",
")",
"{",
"if",
"(",
"\"configureDefaults\"",
".",
"equals",
"(",
"link",
")",
")",
"{",
"Ancestor",
"ance... | Returns the graph configuration screen.
@param link
the link to check
@param request
stapler request
@param response
stapler response
@return the graph configuration or <code>null</code> | [
"Returns",
"the",
"graph",
"configuration",
"screen",
"."
] | 462c9f3dffede9120173935567392b22520b0966 | https://github.com/hudson3-plugins/warnings-plugin/blob/462c9f3dffede9120173935567392b22520b0966/src/main/java/hudson/plugins/warnings/WarningsDescriptor.java#L89-L101 |
156,052 | RogerParkinson/madura-objects-parent | madura-objects/src/main/java/org/springframework/context/support/JdbcMessageSource.java | JdbcMessageSource.resolveCodeInternal | protected MessageFormat resolveCodeInternal(String code, Locale locale) {
String result;
lastQuery = System.currentTimeMillis();
try {
result = (String) jdbcTemplate.queryForObject(sqlStatement,
new Object[] { code, locale.toString() }, String.class);
} catch (IncorrectResultSizeDataAccessException e) {
if (locale != null) {
// Retry without a locale if we checked with one before
try {
result = (String) jdbcTemplate.queryForObject(sqlStatement,
new Object[] { code, null }, String.class);
} catch (IncorrectResultSizeDataAccessException ex) {
return null;
}
} else {
return null;
}
}
return new MessageFormat(result, locale);
} | java | protected MessageFormat resolveCodeInternal(String code, Locale locale) {
String result;
lastQuery = System.currentTimeMillis();
try {
result = (String) jdbcTemplate.queryForObject(sqlStatement,
new Object[] { code, locale.toString() }, String.class);
} catch (IncorrectResultSizeDataAccessException e) {
if (locale != null) {
// Retry without a locale if we checked with one before
try {
result = (String) jdbcTemplate.queryForObject(sqlStatement,
new Object[] { code, null }, String.class);
} catch (IncorrectResultSizeDataAccessException ex) {
return null;
}
} else {
return null;
}
}
return new MessageFormat(result, locale);
} | [
"protected",
"MessageFormat",
"resolveCodeInternal",
"(",
"String",
"code",
",",
"Locale",
"locale",
")",
"{",
"String",
"result",
";",
"lastQuery",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"try",
"{",
"result",
"=",
"(",
"String",
")",
"jdbcT... | Check in base the message associated with the given code and locale
@param code
the code of the message to solve
@param locale
the locale to check against
@return a MessageFormat if one were found, either for the given locale or
for the default on, or null if nothing could be found | [
"Check",
"in",
"base",
"the",
"message",
"associated",
"with",
"the",
"given",
"code",
"and",
"locale"
] | 9b5385dd0437611f0ce8506f63646e018d06fb8e | https://github.com/RogerParkinson/madura-objects-parent/blob/9b5385dd0437611f0ce8506f63646e018d06fb8e/madura-objects/src/main/java/org/springframework/context/support/JdbcMessageSource.java#L100-L123 |
156,053 | SimiaCryptus/utilities | java-util/src/main/java/com/simiacryptus/text/TextGenerator.java | TextGenerator.generateMarkov | public String generateMarkov(int length, int context, String seed) {
String str = seed;
while (str.length() < length) {
String prefix = str.substring(Math.max(str.length() - context, 0), str.length());
TrieNode node = inner.matchPredictor(prefix);
long cursorCount = node.getCursorCount();
long fate = CompressionUtil.random.nextLong() % cursorCount;
String next = null;
Stream<TrieNode> stream = node.getChildren().map(x -> x);
List<TrieNode> children = stream.collect(Collectors.toList());
for (TrieNode child : children) {
fate -= child.getCursorCount();
if (fate <= 0) {
if (child.getChar() != NodewalkerCodec.END_OF_STRING) {
next = child.getToken();
}
break;
}
}
if (null != next) {
str += next;
}
else {
break;
}
}
return str;
} | java | public String generateMarkov(int length, int context, String seed) {
String str = seed;
while (str.length() < length) {
String prefix = str.substring(Math.max(str.length() - context, 0), str.length());
TrieNode node = inner.matchPredictor(prefix);
long cursorCount = node.getCursorCount();
long fate = CompressionUtil.random.nextLong() % cursorCount;
String next = null;
Stream<TrieNode> stream = node.getChildren().map(x -> x);
List<TrieNode> children = stream.collect(Collectors.toList());
for (TrieNode child : children) {
fate -= child.getCursorCount();
if (fate <= 0) {
if (child.getChar() != NodewalkerCodec.END_OF_STRING) {
next = child.getToken();
}
break;
}
}
if (null != next) {
str += next;
}
else {
break;
}
}
return str;
} | [
"public",
"String",
"generateMarkov",
"(",
"int",
"length",
",",
"int",
"context",
",",
"String",
"seed",
")",
"{",
"String",
"str",
"=",
"seed",
";",
"while",
"(",
"str",
".",
"length",
"(",
")",
"<",
"length",
")",
"{",
"String",
"prefix",
"=",
"st... | Generate markov string.
@param length the length
@param context the context
@param seed the seed
@return the string | [
"Generate",
"markov",
"string",
"."
] | b5a5e73449aae57de7dbfca2ed7a074432c5b17e | https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/text/TextGenerator.java#L53-L80 |
156,054 | RogerParkinson/madura-objects-parent | madura-rules/src/main/java/nz/co/senanque/rules/RuleSessionImpl.java | RuleSessionImpl.alreadyResettingRule | protected boolean alreadyResettingRule(final RuleContext rc)
{
if (m_resettingRules.contains(rc))
{
return true;
}
m_resettingRules.add(rc);
return false;
} | java | protected boolean alreadyResettingRule(final RuleContext rc)
{
if (m_resettingRules.contains(rc))
{
return true;
}
m_resettingRules.add(rc);
return false;
} | [
"protected",
"boolean",
"alreadyResettingRule",
"(",
"final",
"RuleContext",
"rc",
")",
"{",
"if",
"(",
"m_resettingRules",
".",
"contains",
"(",
"rc",
")",
")",
"{",
"return",
"true",
";",
"}",
"m_resettingRules",
".",
"add",
"(",
"rc",
")",
";",
"return"... | Method alreadyResettingRule.
Sometimes a rule attempts to reset twice and gets into a loop
This checks for that situation. Rules only need to be reset once.
@param rc
@return boolean | [
"Method",
"alreadyResettingRule",
".",
"Sometimes",
"a",
"rule",
"attempts",
"to",
"reset",
"twice",
"and",
"gets",
"into",
"a",
"loop",
"This",
"checks",
"for",
"that",
"situation",
".",
"Rules",
"only",
"need",
"to",
"be",
"reset",
"once",
"."
] | 9b5385dd0437611f0ce8506f63646e018d06fb8e | https://github.com/RogerParkinson/madura-objects-parent/blob/9b5385dd0437611f0ce8506f63646e018d06fb8e/madura-rules/src/main/java/nz/co/senanque/rules/RuleSessionImpl.java#L252-L260 |
156,055 | foundation-runtime/service-directory | 2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryConnection.java | DirectoryConnection.blockUtilConnected | public void blockUtilConnected(){
if(getStatus().isConnected()){
return;
}
int to = getConnectTimeOut();
final Object o = new Object();
long now = System.currentTimeMillis();
synchronized(o){
ServiceDirectoryListener listener = new ServiceDirectoryListener(){
@Override
public void notify(ServiceDirectoryEvent event) {
synchronized(o){
o.notifyAll();
}
}
};
registerClientChangeListener(listener);
try{
while(to > 0){
if (getStatus().isConnected()) {
return;
}
try {
o.wait(to);
} catch (InterruptedException e) {
LOGGER.warn("Block Util Connected interrupted.");
}
to -= (System.currentTimeMillis() - now);
}
}finally{
unregisterClientChangeListener(listener);
}
}
} | java | public void blockUtilConnected(){
if(getStatus().isConnected()){
return;
}
int to = getConnectTimeOut();
final Object o = new Object();
long now = System.currentTimeMillis();
synchronized(o){
ServiceDirectoryListener listener = new ServiceDirectoryListener(){
@Override
public void notify(ServiceDirectoryEvent event) {
synchronized(o){
o.notifyAll();
}
}
};
registerClientChangeListener(listener);
try{
while(to > 0){
if (getStatus().isConnected()) {
return;
}
try {
o.wait(to);
} catch (InterruptedException e) {
LOGGER.warn("Block Util Connected interrupted.");
}
to -= (System.currentTimeMillis() - now);
}
}finally{
unregisterClientChangeListener(listener);
}
}
} | [
"public",
"void",
"blockUtilConnected",
"(",
")",
"{",
"if",
"(",
"getStatus",
"(",
")",
".",
"isConnected",
"(",
")",
")",
"{",
"return",
";",
"}",
"int",
"to",
"=",
"getConnectTimeOut",
"(",
")",
";",
"final",
"Object",
"o",
"=",
"new",
"Object",
"... | Block util the connect complete.
It just make sure the connect finished, it doesn't mean the DirectoryConnection
CONNECTED. Because DirectoryConnection will keep polling remote Directory Server,
if it is NOT_CONNECTED.
And it doesn't block the Thread interruption. | [
"Block",
"util",
"the",
"connect",
"complete",
"."
] | a7bdefe173dc99e75eff4a24e07e6407e62f2ed4 | https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryConnection.java#L234-L278 |
156,056 | foundation-runtime/service-directory | 2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryConnection.java | DirectoryConnection.start | public void start() {
setStatus(ConnectionStatus.NOT_CONNECTED);
InetSocketAddress address = directoryServer;
clientSocket.connect(address);
eventThread.start();
connectionThread = new Thread(new ConnectTask());
connectionThread.setDaemon(true);
connectionThread.setName(ServiceDirectoryThread.getThreadName("Client_Connect_Thread"));
connectionThread.start();
} | java | public void start() {
setStatus(ConnectionStatus.NOT_CONNECTED);
InetSocketAddress address = directoryServer;
clientSocket.connect(address);
eventThread.start();
connectionThread = new Thread(new ConnectTask());
connectionThread.setDaemon(true);
connectionThread.setName(ServiceDirectoryThread.getThreadName("Client_Connect_Thread"));
connectionThread.start();
} | [
"public",
"void",
"start",
"(",
")",
"{",
"setStatus",
"(",
"ConnectionStatus",
".",
"NOT_CONNECTED",
")",
";",
"InetSocketAddress",
"address",
"=",
"directoryServer",
";",
"clientSocket",
".",
"connect",
"(",
"address",
")",
";",
"eventThread",
".",
"start",
... | Start the DirectoryConnection.
It is not thread safe. | [
"Start",
"the",
"DirectoryConnection",
"."
] | a7bdefe173dc99e75eff4a24e07e6407e62f2ed4 | https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryConnection.java#L285-L294 |
156,057 | foundation-runtime/service-directory | 2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryConnection.java | DirectoryConnection.close | public synchronized void close() throws IOException {
if(getStatus().equals(ConnectionStatus.CLOSED)){
return ;
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Closing client for session: 0x"
+ getSessionId());
}
connectRun.set(false);
try{
clientSocket.cleanup();
}catch(Exception e){
LOGGER.warn("Close the WSDirectorySocket get error.", e);
}
try {
setStatus(ConnectionStatus.CLOSED);
sendCloseSession();
closeSession();
eventThread.queueEventOfDeath();
} catch (ServiceException e) {
LOGGER.warn("Execute the CloseSession Protocol failed when close", e);
}
} | java | public synchronized void close() throws IOException {
if(getStatus().equals(ConnectionStatus.CLOSED)){
return ;
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Closing client for session: 0x"
+ getSessionId());
}
connectRun.set(false);
try{
clientSocket.cleanup();
}catch(Exception e){
LOGGER.warn("Close the WSDirectorySocket get error.", e);
}
try {
setStatus(ConnectionStatus.CLOSED);
sendCloseSession();
closeSession();
eventThread.queueEventOfDeath();
} catch (ServiceException e) {
LOGGER.warn("Execute the CloseSession Protocol failed when close", e);
}
} | [
"public",
"synchronized",
"void",
"close",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"getStatus",
"(",
")",
".",
"equals",
"(",
"ConnectionStatus",
".",
"CLOSED",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"LOGGER",
".",
"isDebugEnabled",
"("... | Close the Directory Connection.
It is thread safe.
@throws IOException
the IOException in closing. | [
"Close",
"the",
"Directory",
"Connection",
"."
] | a7bdefe173dc99e75eff4a24e07e6407e62f2ed4 | https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryConnection.java#L311-L335 |
156,058 | foundation-runtime/service-directory | 2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryConnection.java | DirectoryConnection.submitRequest | public Response submitRequest(ProtocolHeader h, Protocol request,
WatcherRegistration wr){
Packet packet = queuePacket(h, request, null, null, null, wr);
synchronized (packet) {
while (!packet.finished) {
try {
packet.wait();
} catch (InterruptedException e) {
ServiceDirectoryError sde = new ServiceDirectoryError(ErrorCode.REQUEST_INTERUPTED);
throw new ServiceException(sde, e);
}
}
}
if(! packet.respHeader.getErr().equals(ErrorCode.OK)){
ServiceDirectoryError sde = new ServiceDirectoryError(packet.respHeader.getErr());
throw new ServiceException(sde);
}
return packet.response;
} | java | public Response submitRequest(ProtocolHeader h, Protocol request,
WatcherRegistration wr){
Packet packet = queuePacket(h, request, null, null, null, wr);
synchronized (packet) {
while (!packet.finished) {
try {
packet.wait();
} catch (InterruptedException e) {
ServiceDirectoryError sde = new ServiceDirectoryError(ErrorCode.REQUEST_INTERUPTED);
throw new ServiceException(sde, e);
}
}
}
if(! packet.respHeader.getErr().equals(ErrorCode.OK)){
ServiceDirectoryError sde = new ServiceDirectoryError(packet.respHeader.getErr());
throw new ServiceException(sde);
}
return packet.response;
} | [
"public",
"Response",
"submitRequest",
"(",
"ProtocolHeader",
"h",
",",
"Protocol",
"request",
",",
"WatcherRegistration",
"wr",
")",
"{",
"Packet",
"packet",
"=",
"queuePacket",
"(",
"h",
",",
"request",
",",
"null",
",",
"null",
",",
"null",
",",
"wr",
"... | Submit a Request.
@param h
the ProtocolHeader.
@param request
the Protocol.
@param wr
the WatcherRegistration
@return
the Response of the Request. | [
"Submit",
"a",
"Request",
"."
] | a7bdefe173dc99e75eff4a24e07e6407e62f2ed4 | https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryConnection.java#L349-L367 |
156,059 | foundation-runtime/service-directory | 2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryConnection.java | DirectoryConnection.submitCallbackRequest | public void submitCallbackRequest(ProtocolHeader h, Protocol request, ProtocolCallback callBack, Object context){
queuePacket(h, request, callBack, context, null, null);
} | java | public void submitCallbackRequest(ProtocolHeader h, Protocol request, ProtocolCallback callBack, Object context){
queuePacket(h, request, callBack, context, null, null);
} | [
"public",
"void",
"submitCallbackRequest",
"(",
"ProtocolHeader",
"h",
",",
"Protocol",
"request",
",",
"ProtocolCallback",
"callBack",
",",
"Object",
"context",
")",
"{",
"queuePacket",
"(",
"h",
",",
"request",
",",
"callBack",
",",
"context",
",",
"null",
"... | Submit a Request with Callback.
It is a asynchronized method, it returns on until Request complete.
When the Request complete, SD API will invoke the Callback.
@param h
the ProtocolHeader.
@param request
the Protocol.
@param callBack
the Callback.
@param context
the Context object of the Callback. | [
"Submit",
"a",
"Request",
"with",
"Callback",
"."
] | a7bdefe173dc99e75eff4a24e07e6407e62f2ed4 | https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryConnection.java#L384-L386 |
156,060 | foundation-runtime/service-directory | 2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryConnection.java | DirectoryConnection.submitAsyncRequest | public ServiceDirectoryFuture submitAsyncRequest(ProtocolHeader h, Protocol request, WatcherRegistration wr){
ServiceDirectoryFuture future = new ServiceDirectoryFuture();
queuePacket(h, request, null, null, future, wr);
return future;
} | java | public ServiceDirectoryFuture submitAsyncRequest(ProtocolHeader h, Protocol request, WatcherRegistration wr){
ServiceDirectoryFuture future = new ServiceDirectoryFuture();
queuePacket(h, request, null, null, future, wr);
return future;
} | [
"public",
"ServiceDirectoryFuture",
"submitAsyncRequest",
"(",
"ProtocolHeader",
"h",
",",
"Protocol",
"request",
",",
"WatcherRegistration",
"wr",
")",
"{",
"ServiceDirectoryFuture",
"future",
"=",
"new",
"ServiceDirectoryFuture",
"(",
")",
";",
"queuePacket",
"(",
"... | Submit a Request in asynchronizing, it return a Future for the
Request Response.
@param h
the ProtocolHeader.
@param request
the Protocol.
@param wr
the WatcherRegistration of the Service.
@return
the Future. | [
"Submit",
"a",
"Request",
"in",
"asynchronizing",
"it",
"return",
"a",
"Future",
"for",
"the",
"Request",
"Response",
"."
] | a7bdefe173dc99e75eff4a24e07e6407e62f2ed4 | https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryConnection.java#L401-L405 |
156,061 | foundation-runtime/service-directory | 2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryConnection.java | DirectoryConnection.queuePacket | private Packet queuePacket(ProtocolHeader header, Protocol protocol,
ProtocolCallback cb, Object context, ServiceDirectoryFuture future, WatcherRegistration wr)
{
Packet packet = new Packet(header, protocol, wr);
PacketLatency.initPacket(packet);
header.createTime = packet.createTime;
packet.cb = cb;
packet.context = context;
packet.future = future;
if (! clientSocket.isConnected() || closing) {
onLossPacket(packet);
} else {
synchronized (pendingQueue) {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Add the packet in queuePacket, type=" + header.getType());
}
header.setXid(xid.incrementAndGet());
try{
PacketLatency.queuePacket(packet);
clientSocket.sendPacket(header, protocol);
pendingQueue.add(packet);
PacketLatency.sendPacket(packet);
} catch(IOException e){
LOGGER.error("ClientSocket send packet failed.");
if(LOGGER.isTraceEnabled()){
LOGGER.trace("ClientSocket send packet failed.", e);
}
if(packet != null){
onLossPacket(packet);
}
}
}
}
return packet;
} | java | private Packet queuePacket(ProtocolHeader header, Protocol protocol,
ProtocolCallback cb, Object context, ServiceDirectoryFuture future, WatcherRegistration wr)
{
Packet packet = new Packet(header, protocol, wr);
PacketLatency.initPacket(packet);
header.createTime = packet.createTime;
packet.cb = cb;
packet.context = context;
packet.future = future;
if (! clientSocket.isConnected() || closing) {
onLossPacket(packet);
} else {
synchronized (pendingQueue) {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Add the packet in queuePacket, type=" + header.getType());
}
header.setXid(xid.incrementAndGet());
try{
PacketLatency.queuePacket(packet);
clientSocket.sendPacket(header, protocol);
pendingQueue.add(packet);
PacketLatency.sendPacket(packet);
} catch(IOException e){
LOGGER.error("ClientSocket send packet failed.");
if(LOGGER.isTraceEnabled()){
LOGGER.trace("ClientSocket send packet failed.", e);
}
if(packet != null){
onLossPacket(packet);
}
}
}
}
return packet;
} | [
"private",
"Packet",
"queuePacket",
"(",
"ProtocolHeader",
"header",
",",
"Protocol",
"protocol",
",",
"ProtocolCallback",
"cb",
",",
"Object",
"context",
",",
"ServiceDirectoryFuture",
"future",
",",
"WatcherRegistration",
"wr",
")",
"{",
"Packet",
"packet",
"=",
... | Queue the Packet to Connection.
The DirectoryConnect Queue the Packet to the internal Queue and send it to remote
Directory Server.
@param header
the ProtocolHeader.
@param protocol
the Protocol.
@param cb
the Callback.
@param context
the context Object of the Callback.
@param future
the Future.
@param wr
WatcherRegistration
@return
the queued Packet. | [
"Queue",
"the",
"Packet",
"to",
"Connection",
"."
] | a7bdefe173dc99e75eff4a24e07e6407e62f2ed4 | https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryConnection.java#L428-L466 |
156,062 | foundation-runtime/service-directory | 2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryConnection.java | DirectoryConnection.setDirectoryUser | public void setDirectoryUser(String userName, String password){
this.authData = generateDirectoryAuthData(userName, password);
if(getStatus().isConnected()){
ErrorCode ec = sendConnectProtocol(this.getConnectTimeOut());
if(ErrorCode.SESSION_EXPIRED.equals(ec)){
LOGGER.info("Session Expired, cleanup the client session.");
closeSession();
} else if(! ErrorCode.OK.equals(ec)){
reopenSession();
}
}
} | java | public void setDirectoryUser(String userName, String password){
this.authData = generateDirectoryAuthData(userName, password);
if(getStatus().isConnected()){
ErrorCode ec = sendConnectProtocol(this.getConnectTimeOut());
if(ErrorCode.SESSION_EXPIRED.equals(ec)){
LOGGER.info("Session Expired, cleanup the client session.");
closeSession();
} else if(! ErrorCode.OK.equals(ec)){
reopenSession();
}
}
} | [
"public",
"void",
"setDirectoryUser",
"(",
"String",
"userName",
",",
"String",
"password",
")",
"{",
"this",
".",
"authData",
"=",
"generateDirectoryAuthData",
"(",
"userName",
",",
"password",
")",
";",
"if",
"(",
"getStatus",
"(",
")",
".",
"isConnected",
... | Change the Directory Authentication.
It will reopen session use the new authentication.
If failed, need to close the session.
@param userName
@param password | [
"Change",
"the",
"Directory",
"Authentication",
"."
] | a7bdefe173dc99e75eff4a24e07e6407e62f2ed4 | https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryConnection.java#L598-L609 |
156,063 | foundation-runtime/service-directory | 2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryConnection.java | DirectoryConnection.setStatus | private void setStatus(ConnectionStatus status){
if(LOGGER.isDebugEnabled()){
LOGGER.debug("Set status to - " + status);
}
if(! this.status.equals(status)){
ConnectionStatus pre = this.status;
this.status = status;
eventThread.queueClientEvent(new ClientStatusEvent(pre, status));
}
} | java | private void setStatus(ConnectionStatus status){
if(LOGGER.isDebugEnabled()){
LOGGER.debug("Set status to - " + status);
}
if(! this.status.equals(status)){
ConnectionStatus pre = this.status;
this.status = status;
eventThread.queueClientEvent(new ClientStatusEvent(pre, status));
}
} | [
"private",
"void",
"setStatus",
"(",
"ConnectionStatus",
"status",
")",
"{",
"if",
"(",
"LOGGER",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"\"Set status to - \"",
"+",
"status",
")",
";",
"}",
"if",
"(",
"!",
"this",
".",
... | Set the DirectoryConnection ConenctionStatus.
@param status
the ConenctionStatus. | [
"Set",
"the",
"DirectoryConnection",
"ConenctionStatus",
"."
] | a7bdefe173dc99e75eff4a24e07e6407e62f2ed4 | https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryConnection.java#L626-L635 |
156,064 | foundation-runtime/service-directory | 2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryConnection.java | DirectoryConnection.onConnected | public void onConnected(int serverSessionTimeout, String sessionId, byte[] sessionPassword, int serverId) {
if (serverSessionTimeout <= 0) {
closeSession();
LOGGER.error("Unable to reconnect to Directory Server, session 0x" + sessionId + " has expired");
return;
}
boolean reopen = session.id == null || session.id.equals("") ? false : true;
session.timeOut = serverSessionTimeout;
session.id = sessionId;
session.password = sessionPassword;
session.serverId = serverId;
if(getStatus().isAlive()){
setStatus(ConnectionStatus.CONNECTED);
}
if(reopen){
eventThread.queueClientEvent(new ClientSessionEvent(SessionEvent.REOPEN));
} else {
eventThread.queueClientEvent(new ClientSessionEvent(SessionEvent.CREATED));
}
LOGGER.info("Session establishment complete on server " + this.clientSocket.getRemoteSocketAddress()
+ ", sessionid = 0x" + sessionId + ", session timeout = " + session.timeOut
+ ", serverId=" + session.serverId);
} | java | public void onConnected(int serverSessionTimeout, String sessionId, byte[] sessionPassword, int serverId) {
if (serverSessionTimeout <= 0) {
closeSession();
LOGGER.error("Unable to reconnect to Directory Server, session 0x" + sessionId + " has expired");
return;
}
boolean reopen = session.id == null || session.id.equals("") ? false : true;
session.timeOut = serverSessionTimeout;
session.id = sessionId;
session.password = sessionPassword;
session.serverId = serverId;
if(getStatus().isAlive()){
setStatus(ConnectionStatus.CONNECTED);
}
if(reopen){
eventThread.queueClientEvent(new ClientSessionEvent(SessionEvent.REOPEN));
} else {
eventThread.queueClientEvent(new ClientSessionEvent(SessionEvent.CREATED));
}
LOGGER.info("Session establishment complete on server " + this.clientSocket.getRemoteSocketAddress()
+ ", sessionid = 0x" + sessionId + ", session timeout = " + session.timeOut
+ ", serverId=" + session.serverId);
} | [
"public",
"void",
"onConnected",
"(",
"int",
"serverSessionTimeout",
",",
"String",
"sessionId",
",",
"byte",
"[",
"]",
"sessionPassword",
",",
"int",
"serverId",
")",
"{",
"if",
"(",
"serverSessionTimeout",
"<=",
"0",
")",
"{",
"closeSession",
"(",
")",
";"... | On the DirectoryConnection setup connection to DirectoryServer.
@param serverSessionTimeout
the session timeout.
@param sessionId
the session id.
@param sessionPassword
the session password.
@param serverId
the remote server id. | [
"On",
"the",
"DirectoryConnection",
"setup",
"connection",
"to",
"DirectoryServer",
"."
] | a7bdefe173dc99e75eff4a24e07e6407e62f2ed4 | https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryConnection.java#L673-L699 |
156,065 | foundation-runtime/service-directory | 2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryConnection.java | DirectoryConnection.sendCloseSession | private void sendCloseSession() throws IOException{
ProtocolHeader h = new ProtocolHeader();
h.setType(ProtocolType.CloseSession);
sendAdminPacket(h, null);
} | java | private void sendCloseSession() throws IOException{
ProtocolHeader h = new ProtocolHeader();
h.setType(ProtocolType.CloseSession);
sendAdminPacket(h, null);
} | [
"private",
"void",
"sendCloseSession",
"(",
")",
"throws",
"IOException",
"{",
"ProtocolHeader",
"h",
"=",
"new",
"ProtocolHeader",
"(",
")",
";",
"h",
".",
"setType",
"(",
"ProtocolType",
".",
"CloseSession",
")",
";",
"sendAdminPacket",
"(",
"h",
",",
"nul... | Send the CloseSession packet.
@throws IOException
the IOException. | [
"Send",
"the",
"CloseSession",
"packet",
"."
] | a7bdefe173dc99e75eff4a24e07e6407e62f2ed4 | https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryConnection.java#L714-L719 |
156,066 | foundation-runtime/service-directory | 2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryConnection.java | DirectoryConnection.doConnect | private void doConnect() throws SessionTimeOutException{
long to = getConnectTimeOut();
if(clientSocket.isConnected()){
ErrorCode ec = sendConnectProtocol(to);
// CONNECTION_LOSS means client data is inconsistence with server. now we check the last dxid of client.
// if dxid of the client is bigger than server actual dxid, return CONNECTION_LOSS.
if(ErrorCode.SESSION_EXPIRED.equals(ec) || ErrorCode.CONNECTION_LOSS.equals(equals(ec))){
LOGGER.info("Session Expired, cleanup the client session.");
cleanupSession();
}
}
} | java | private void doConnect() throws SessionTimeOutException{
long to = getConnectTimeOut();
if(clientSocket.isConnected()){
ErrorCode ec = sendConnectProtocol(to);
// CONNECTION_LOSS means client data is inconsistence with server. now we check the last dxid of client.
// if dxid of the client is bigger than server actual dxid, return CONNECTION_LOSS.
if(ErrorCode.SESSION_EXPIRED.equals(ec) || ErrorCode.CONNECTION_LOSS.equals(equals(ec))){
LOGGER.info("Session Expired, cleanup the client session.");
cleanupSession();
}
}
} | [
"private",
"void",
"doConnect",
"(",
")",
"throws",
"SessionTimeOutException",
"{",
"long",
"to",
"=",
"getConnectTimeOut",
"(",
")",
";",
"if",
"(",
"clientSocket",
".",
"isConnected",
"(",
")",
")",
"{",
"ErrorCode",
"ec",
"=",
"sendConnectProtocol",
"(",
... | Connect to the remote DirectoryServer.
@throws IOException | [
"Connect",
"to",
"the",
"remote",
"DirectoryServer",
"."
] | a7bdefe173dc99e75eff4a24e07e6407e62f2ed4 | https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryConnection.java#L726-L738 |
156,067 | foundation-runtime/service-directory | 2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryConnection.java | DirectoryConnection.sendConnectProtocol | private ErrorCode sendConnectProtocol(long to) {
String sessId = session.id;
ErrorCode ec = ErrorCode.OK;
ConnectProtocol conReq = new ConnectProtocol(0, lastDxid,
session.timeOut, sessId, session.password, authData.userName, authData.secret, authData.obfuscated);
ServiceDirectoryFuture future = submitAsyncRequest(new ProtocolHeader(0, ProtocolType.CreateSession), conReq, null);
try {
ConnectResponse resp = null;
if (future.isDone()) {
resp = (ConnectResponse) future.get();
} else {
resp = (ConnectResponse) future.get(to, TimeUnit.MILLISECONDS);
}
onConnected(resp.getTimeOut(), resp.getSessionId(), resp.getPasswd(), resp.getServerId());
return ec;
} catch (ExecutionException e) {
// ConnectResponse failed, renew session.
ServiceException se = (ServiceException) e.getCause();
ec = se.getServiceDirectoryError().getExceptionCode();
} catch (Exception e) {
ec = ErrorCode.GENERAL_ERROR;
}
future.cancel(false);
return ec;
} | java | private ErrorCode sendConnectProtocol(long to) {
String sessId = session.id;
ErrorCode ec = ErrorCode.OK;
ConnectProtocol conReq = new ConnectProtocol(0, lastDxid,
session.timeOut, sessId, session.password, authData.userName, authData.secret, authData.obfuscated);
ServiceDirectoryFuture future = submitAsyncRequest(new ProtocolHeader(0, ProtocolType.CreateSession), conReq, null);
try {
ConnectResponse resp = null;
if (future.isDone()) {
resp = (ConnectResponse) future.get();
} else {
resp = (ConnectResponse) future.get(to, TimeUnit.MILLISECONDS);
}
onConnected(resp.getTimeOut(), resp.getSessionId(), resp.getPasswd(), resp.getServerId());
return ec;
} catch (ExecutionException e) {
// ConnectResponse failed, renew session.
ServiceException se = (ServiceException) e.getCause();
ec = se.getServiceDirectoryError().getExceptionCode();
} catch (Exception e) {
ec = ErrorCode.GENERAL_ERROR;
}
future.cancel(false);
return ec;
} | [
"private",
"ErrorCode",
"sendConnectProtocol",
"(",
"long",
"to",
")",
"{",
"String",
"sessId",
"=",
"session",
".",
"id",
";",
"ErrorCode",
"ec",
"=",
"ErrorCode",
".",
"OK",
";",
"ConnectProtocol",
"conReq",
"=",
"new",
"ConnectProtocol",
"(",
"0",
",",
... | Send the Connect Protocol to the remote Directory Server.
@param to
the connection timeout.
@return
the ErrorCode of the request, OK for success. | [
"Send",
"the",
"Connect",
"Protocol",
"to",
"the",
"remote",
"Directory",
"Server",
"."
] | a7bdefe173dc99e75eff4a24e07e6407e62f2ed4 | https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryConnection.java#L748-L775 |
156,068 | foundation-runtime/service-directory | 2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryConnection.java | DirectoryConnection.sendAdminPacket | private void sendAdminPacket(ProtocolHeader header, Protocol protocol) throws IOException{
clientSocket.sendPacket(header, protocol);
} | java | private void sendAdminPacket(ProtocolHeader header, Protocol protocol) throws IOException{
clientSocket.sendPacket(header, protocol);
} | [
"private",
"void",
"sendAdminPacket",
"(",
"ProtocolHeader",
"header",
",",
"Protocol",
"protocol",
")",
"throws",
"IOException",
"{",
"clientSocket",
".",
"sendPacket",
"(",
"header",
",",
"protocol",
")",
";",
"}"
] | Send the packet to Directory Server directory.
It doesn't queue the packet in the pendingQueue. It used internally to send
administration Protocol.
@param header
@param protocol
@throws IOException | [
"Send",
"the",
"packet",
"to",
"Directory",
"Server",
"directory",
"."
] | a7bdefe173dc99e75eff4a24e07e6407e62f2ed4 | https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryConnection.java#L786-L788 |
156,069 | foundation-runtime/service-directory | 2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryConnection.java | DirectoryConnection.finishPacket | private void finishPacket(Packet p) {
if (p.watcherRegistration != null) {
if(ErrorCode.OK.equals(p.respHeader.getErr())){
this.watcherManager.register(p.watcherRegistration);
}
}
synchronized (p) {
p.finished = true;
PacketLatency.finishPacket(p);
if (p.cb == null && p.future == null) {
p.notifyAll();
}
}
eventThread.queuePacket(p);
} | java | private void finishPacket(Packet p) {
if (p.watcherRegistration != null) {
if(ErrorCode.OK.equals(p.respHeader.getErr())){
this.watcherManager.register(p.watcherRegistration);
}
}
synchronized (p) {
p.finished = true;
PacketLatency.finishPacket(p);
if (p.cb == null && p.future == null) {
p.notifyAll();
}
}
eventThread.queuePacket(p);
} | [
"private",
"void",
"finishPacket",
"(",
"Packet",
"p",
")",
"{",
"if",
"(",
"p",
".",
"watcherRegistration",
"!=",
"null",
")",
"{",
"if",
"(",
"ErrorCode",
".",
"OK",
".",
"equals",
"(",
"p",
".",
"respHeader",
".",
"getErr",
"(",
")",
")",
")",
"... | The Packet finished.
@param p
the Packet. | [
"The",
"Packet",
"finished",
"."
] | a7bdefe173dc99e75eff4a24e07e6407e62f2ed4 | https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryConnection.java#L796-L814 |
156,070 | foundation-runtime/service-directory | 2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryConnection.java | DirectoryConnection.onLossPacket | private void onLossPacket(Packet p) {
if (p.respHeader == null) {
p.respHeader = new ResponseHeader(-1, -1, ErrorCode.OK);
}
switch (getStatus()) {
case AUTH_FAILED:
p.respHeader.setErr(ErrorCode.AUTHENT_FAILED);
break;
case CLOSED:
p.respHeader.setErr(ErrorCode.CLIENT_CLOSED);
break;
default:
p.respHeader.setErr(ErrorCode.CONNECTION_LOSS);
}
finishPacket(p);
} | java | private void onLossPacket(Packet p) {
if (p.respHeader == null) {
p.respHeader = new ResponseHeader(-1, -1, ErrorCode.OK);
}
switch (getStatus()) {
case AUTH_FAILED:
p.respHeader.setErr(ErrorCode.AUTHENT_FAILED);
break;
case CLOSED:
p.respHeader.setErr(ErrorCode.CLIENT_CLOSED);
break;
default:
p.respHeader.setErr(ErrorCode.CONNECTION_LOSS);
}
finishPacket(p);
} | [
"private",
"void",
"onLossPacket",
"(",
"Packet",
"p",
")",
"{",
"if",
"(",
"p",
".",
"respHeader",
"==",
"null",
")",
"{",
"p",
".",
"respHeader",
"=",
"new",
"ResponseHeader",
"(",
"-",
"1",
",",
"-",
"1",
",",
"ErrorCode",
".",
"OK",
")",
";",
... | On the Packet lost in the DirectoryConnection.
@param p
the Packet. | [
"On",
"the",
"Packet",
"lost",
"in",
"the",
"DirectoryConnection",
"."
] | a7bdefe173dc99e75eff4a24e07e6407e62f2ed4 | https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryConnection.java#L822-L837 |
156,071 | foundation-runtime/service-directory | 2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryConnection.java | DirectoryConnection.onSessionClose | private void onSessionClose(){
synchronized(pendingQueue){
while(! pendingQueue.isEmpty()){
Packet p = pendingQueue.remove();
onLossPacket(p);
}
}
} | java | private void onSessionClose(){
synchronized(pendingQueue){
while(! pendingQueue.isEmpty()){
Packet p = pendingQueue.remove();
onLossPacket(p);
}
}
} | [
"private",
"void",
"onSessionClose",
"(",
")",
"{",
"synchronized",
"(",
"pendingQueue",
")",
"{",
"while",
"(",
"!",
"pendingQueue",
".",
"isEmpty",
"(",
")",
")",
"{",
"Packet",
"p",
"=",
"pendingQueue",
".",
"remove",
"(",
")",
";",
"onLossPacket",
"(... | On the session close. | [
"On",
"the",
"session",
"close",
"."
] | a7bdefe173dc99e75eff4a24e07e6407e62f2ed4 | https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryConnection.java#L842-L849 |
156,072 | foundation-runtime/service-directory | 2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryConnection.java | DirectoryConnection.closeSession | private void closeSession(){
if(LOGGER.isDebugEnabled()){
LOGGER.debug("Close the session, sessionId=" + session.id + ", timeOut=" + session.timeOut);
}
if(! closing && getStatus().isConnected()){
closing = true;
if(getStatus().isAlive()){
setStatus(ConnectionStatus.NOT_CONNECTED);
}
cleanupSession();
closing = false;
}
} | java | private void closeSession(){
if(LOGGER.isDebugEnabled()){
LOGGER.debug("Close the session, sessionId=" + session.id + ", timeOut=" + session.timeOut);
}
if(! closing && getStatus().isConnected()){
closing = true;
if(getStatus().isAlive()){
setStatus(ConnectionStatus.NOT_CONNECTED);
}
cleanupSession();
closing = false;
}
} | [
"private",
"void",
"closeSession",
"(",
")",
"{",
"if",
"(",
"LOGGER",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"\"Close the session, sessionId=\"",
"+",
"session",
".",
"id",
"+",
"\", timeOut=\"",
"+",
"session",
".",
"timeOu... | It cleans the session, including the sessionId, sessionPassword.
Close session doesn't close the whole connection, the ConnectionThread will
try to do connect soon. | [
"It",
"cleans",
"the",
"session",
"including",
"the",
"sessionId",
"sessionPassword",
"."
] | a7bdefe173dc99e75eff4a24e07e6407e62f2ed4 | https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryConnection.java#L857-L869 |
156,073 | foundation-runtime/service-directory | 2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryConnection.java | DirectoryConnection.cleanupSession | private void cleanupSession(){
eventThread.queueClientEvent(new ClientSessionEvent(SessionEvent.CLOSED));
watcherManager.cleanup();
session.id = "";
session.password = null;
session.serverId = -1;
onSessionClose();
} | java | private void cleanupSession(){
eventThread.queueClientEvent(new ClientSessionEvent(SessionEvent.CLOSED));
watcherManager.cleanup();
session.id = "";
session.password = null;
session.serverId = -1;
onSessionClose();
} | [
"private",
"void",
"cleanupSession",
"(",
")",
"{",
"eventThread",
".",
"queueClientEvent",
"(",
"new",
"ClientSessionEvent",
"(",
"SessionEvent",
".",
"CLOSED",
")",
")",
";",
"watcherManager",
".",
"cleanup",
"(",
")",
";",
"session",
".",
"id",
"=",
"\"\"... | Cleanup the session in the DirectoryConnection. | [
"Cleanup",
"the",
"session",
"in",
"the",
"DirectoryConnection",
"."
] | a7bdefe173dc99e75eff4a24e07e6407e62f2ed4 | https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryConnection.java#L874-L881 |
156,074 | foundation-runtime/service-directory | 2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryConnection.java | DirectoryConnection.reopenSession | private void reopenSession(){
if(! closing && getStatus().isConnected()){
closing = true;
if(getStatus().isAlive()){
setStatus(ConnectionStatus.NOT_CONNECTED);
}
closing = false;
}
} | java | private void reopenSession(){
if(! closing && getStatus().isConnected()){
closing = true;
if(getStatus().isAlive()){
setStatus(ConnectionStatus.NOT_CONNECTED);
}
closing = false;
}
} | [
"private",
"void",
"reopenSession",
"(",
")",
"{",
"if",
"(",
"!",
"closing",
"&&",
"getStatus",
"(",
")",
".",
"isConnected",
"(",
")",
")",
"{",
"closing",
"=",
"true",
";",
"if",
"(",
"getStatus",
"(",
")",
".",
"isAlive",
"(",
")",
")",
"{",
... | When connect has exception and the session still not out of time.
Reopen the session to server.
It doesn't clean the sessionId, sessionPassword, authdata and serverId. the ConnectionThread can
reopen the session use them.
When send ping failed or ClientSocket detects fail, reopen the session again.
Send packet failed donot reopen the session. | [
"When",
"connect",
"has",
"exception",
"and",
"the",
"session",
"still",
"not",
"out",
"of",
"time",
".",
"Reopen",
"the",
"session",
"to",
"server",
"."
] | a7bdefe173dc99e75eff4a24e07e6407e62f2ed4 | https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryConnection.java#L893-L901 |
156,075 | foundation-runtime/service-directory | 2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryConnection.java | DirectoryConnection.sendPing | private ErrorCode sendPing() throws IOException {
if(LOGGER.isTraceEnabled()){
LOGGER.trace("......................send Ping");
}
lastPingSentNs = System.currentTimeMillis();
ProtocolHeader h = new ProtocolHeader(-2, ProtocolType.Ping);
sendAdminPacket(h, null);
int waitTime = session.pingWaitTimeOut;
synchronized(pingResponse){
while(waitTime > 0){
try {
pingResponse.wait(waitTime);
} catch (InterruptedException e) {
// Do nothing.
}
ResponseHeader header = pingResponse.get();
if (header != null) {
pingResponse.set(null);
return header.getErr();
}
waitTime -= (System.currentTimeMillis() - lastPingSentNs);
}
}
return ErrorCode.PING_TIMEOUT;
} | java | private ErrorCode sendPing() throws IOException {
if(LOGGER.isTraceEnabled()){
LOGGER.trace("......................send Ping");
}
lastPingSentNs = System.currentTimeMillis();
ProtocolHeader h = new ProtocolHeader(-2, ProtocolType.Ping);
sendAdminPacket(h, null);
int waitTime = session.pingWaitTimeOut;
synchronized(pingResponse){
while(waitTime > 0){
try {
pingResponse.wait(waitTime);
} catch (InterruptedException e) {
// Do nothing.
}
ResponseHeader header = pingResponse.get();
if (header != null) {
pingResponse.set(null);
return header.getErr();
}
waitTime -= (System.currentTimeMillis() - lastPingSentNs);
}
}
return ErrorCode.PING_TIMEOUT;
} | [
"private",
"ErrorCode",
"sendPing",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"LOGGER",
".",
"isTraceEnabled",
"(",
")",
")",
"{",
"LOGGER",
".",
"trace",
"(",
"\"......................send Ping\"",
")",
";",
"}",
"lastPingSentNs",
"=",
"System",
".",... | Send the Ping Request.
@return
the ErrorCode, OK for success.
@throws IOException
the IOException. | [
"Send",
"the",
"Ping",
"Request",
"."
] | a7bdefe173dc99e75eff4a24e07e6407e62f2ed4 | https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryConnection.java#L911-L938 |
156,076 | foundation-runtime/service-directory | 2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryConnection.java | DirectoryConnection.generateDirectoryAuthData | private AuthData generateDirectoryAuthData(String userName, String password) {
if(password != null && ! password.isEmpty()){
byte[] secret = ObfuscatUtil.base64Encode(password.getBytes());
return new AuthData(AuthScheme.DIRECTORY, userName, secret, true);
} else {
return new AuthData(AuthScheme.DIRECTORY, userName, null, false);
}
} | java | private AuthData generateDirectoryAuthData(String userName, String password) {
if(password != null && ! password.isEmpty()){
byte[] secret = ObfuscatUtil.base64Encode(password.getBytes());
return new AuthData(AuthScheme.DIRECTORY, userName, secret, true);
} else {
return new AuthData(AuthScheme.DIRECTORY, userName, null, false);
}
} | [
"private",
"AuthData",
"generateDirectoryAuthData",
"(",
"String",
"userName",
",",
"String",
"password",
")",
"{",
"if",
"(",
"password",
"!=",
"null",
"&&",
"!",
"password",
".",
"isEmpty",
"(",
")",
")",
"{",
"byte",
"[",
"]",
"secret",
"=",
"ObfuscatUt... | Generate the obfuscated auth data.
@param userName
the user name.
@param password
the password.
@return
the AuthData. | [
"Generate",
"the",
"obfuscated",
"auth",
"data",
"."
] | a7bdefe173dc99e75eff4a24e07e6407e62f2ed4 | https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryConnection.java#L960-L968 |
156,077 | RogerParkinson/madura-objects-parent | madura-rules/src/main/java/nz/co/senanque/rules/RuleProxyField.java | RuleProxyField.backChain | public RuleProxyField backChain() {
ObjectMetadata objectMetadata = m_proxyField.getObjectMetadata();
// loop through the rules that output this field
for (RuleContext rc: getOutputRules())
{
// loop through the fields needed by this rule to fire
for (FieldReference fr :rc.getRule().listeners())
{
RuleProxyField rpf = m_ruleSession.getRuleProxyField(objectMetadata.getProxyField(fr.getFieldName()));
// if this rpf has no value yet then look for an rpf that can deliver it.
// if none is found then return this rpf, else return the one we found.
if (rpf.askFor())
{
RuleProxyField rpf1 = rpf.backChain();
if (rpf1 == null)
{
return rpf;
}
else
{
return rpf1;
}
}
}
}
return null;
} | java | public RuleProxyField backChain() {
ObjectMetadata objectMetadata = m_proxyField.getObjectMetadata();
// loop through the rules that output this field
for (RuleContext rc: getOutputRules())
{
// loop through the fields needed by this rule to fire
for (FieldReference fr :rc.getRule().listeners())
{
RuleProxyField rpf = m_ruleSession.getRuleProxyField(objectMetadata.getProxyField(fr.getFieldName()));
// if this rpf has no value yet then look for an rpf that can deliver it.
// if none is found then return this rpf, else return the one we found.
if (rpf.askFor())
{
RuleProxyField rpf1 = rpf.backChain();
if (rpf1 == null)
{
return rpf;
}
else
{
return rpf1;
}
}
}
}
return null;
} | [
"public",
"RuleProxyField",
"backChain",
"(",
")",
"{",
"ObjectMetadata",
"objectMetadata",
"=",
"m_proxyField",
".",
"getObjectMetadata",
"(",
")",
";",
"// loop through the rules that output this field",
"for",
"(",
"RuleContext",
"rc",
":",
"getOutputRules",
"(",
")"... | Find the first unfilled field needed to supply this field and return it.
@return proxyfield describing the unfilled field | [
"Find",
"the",
"first",
"unfilled",
"field",
"needed",
"to",
"supply",
"this",
"field",
"and",
"return",
"it",
"."
] | 9b5385dd0437611f0ce8506f63646e018d06fb8e | https://github.com/RogerParkinson/madura-objects-parent/blob/9b5385dd0437611f0ce8506f63646e018d06fb8e/madura-rules/src/main/java/nz/co/senanque/rules/RuleProxyField.java#L199-L225 |
156,078 | morimekta/utils | io-util/src/main/java/net/morimekta/util/BinaryUtil.java | BinaryUtil.fromBinaryCollection | public static byte[] fromBinaryCollection(Collection<Binary> binaryList) throws IOException {
try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
BigEndianBinaryWriter writer = new BigEndianBinaryWriter(baos)) {
writer.writeInt(binaryList.size());
for (Binary binary : binaryList) {
writer.writeInt(binary.length());
writer.writeBinary(binary);
}
return baos.toByteArray();
}
} | java | public static byte[] fromBinaryCollection(Collection<Binary> binaryList) throws IOException {
try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
BigEndianBinaryWriter writer = new BigEndianBinaryWriter(baos)) {
writer.writeInt(binaryList.size());
for (Binary binary : binaryList) {
writer.writeInt(binary.length());
writer.writeBinary(binary);
}
return baos.toByteArray();
}
} | [
"public",
"static",
"byte",
"[",
"]",
"fromBinaryCollection",
"(",
"Collection",
"<",
"Binary",
">",
"binaryList",
")",
"throws",
"IOException",
"{",
"try",
"(",
"ByteArrayOutputStream",
"baos",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"BigEndianBinaryW... | Method to convert a Collection of Binary to a byte array.
@param binaryList Collection containing Binary elements.
@throws IOException If unable to write binary to bytes, e.g. on buffer overflow.
@return Array of bytes. | [
"Method",
"to",
"convert",
"a",
"Collection",
"of",
"Binary",
"to",
"a",
"byte",
"array",
"."
] | dc987485902f1a7d58169c89c61db97425a6226d | https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/BinaryUtil.java#L23-L33 |
156,079 | morimekta/utils | io-util/src/main/java/net/morimekta/util/BinaryUtil.java | BinaryUtil.toBinaryCollection | public static Collection<Binary> toBinaryCollection(byte[] bytes) throws IOException {
try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
BigEndianBinaryReader reader = new BigEndianBinaryReader(bais) ) {
final int size = reader.expectInt();
Collection<Binary> result = new ArrayList<>();
for( int i = 0; i < size; i++ ) {
int length = reader.expectInt();
result.add(reader.expectBinary(length));
}
return result;
}
} | java | public static Collection<Binary> toBinaryCollection(byte[] bytes) throws IOException {
try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
BigEndianBinaryReader reader = new BigEndianBinaryReader(bais) ) {
final int size = reader.expectInt();
Collection<Binary> result = new ArrayList<>();
for( int i = 0; i < size; i++ ) {
int length = reader.expectInt();
result.add(reader.expectBinary(length));
}
return result;
}
} | [
"public",
"static",
"Collection",
"<",
"Binary",
">",
"toBinaryCollection",
"(",
"byte",
"[",
"]",
"bytes",
")",
"throws",
"IOException",
"{",
"try",
"(",
"ByteArrayInputStream",
"bais",
"=",
"new",
"ByteArrayInputStream",
"(",
"bytes",
")",
";",
"BigEndianBinar... | Method to convert a byte array to a Collection of Binary.
@param bytes Array of bytes.
@throws IOException If unable to read the binary collection.
@return Collection of Binary. | [
"Method",
"to",
"convert",
"a",
"byte",
"array",
"to",
"a",
"Collection",
"of",
"Binary",
"."
] | dc987485902f1a7d58169c89c61db97425a6226d | https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/BinaryUtil.java#L42-L53 |
156,080 | morimekta/utils | config-util/src/main/java/net/morimekta/config/format/PropertiesConfigFormatter.java | PropertiesConfigFormatter.format | public static Properties format(Config config) {
Properties properties = new Properties();
writeConfig("", config, properties);
return properties;
} | java | public static Properties format(Config config) {
Properties properties = new Properties();
writeConfig("", config, properties);
return properties;
} | [
"public",
"static",
"Properties",
"format",
"(",
"Config",
"config",
")",
"{",
"Properties",
"properties",
"=",
"new",
"Properties",
"(",
")",
";",
"writeConfig",
"(",
"\"\"",
",",
"config",
",",
"properties",
")",
";",
"return",
"properties",
";",
"}"
] | Format a config into a properties instance.
@param config The config to put into the properties instance.
@return The properties instance. | [
"Format",
"a",
"config",
"into",
"a",
"properties",
"instance",
"."
] | dc987485902f1a7d58169c89c61db97425a6226d | https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/config-util/src/main/java/net/morimekta/config/format/PropertiesConfigFormatter.java#L55-L59 |
156,081 | app55/app55-java | src/support/java/org/apache/harmony/beans/internal/nls/Messages.java | Messages.getString | static public String getString(String msg)
{
if (bundle == null)
return msg;
try
{
return bundle.getString(msg);
}
catch (MissingResourceException e)
{
return "Missing message: " + msg; //$NON-NLS-1$
}
} | java | static public String getString(String msg)
{
if (bundle == null)
return msg;
try
{
return bundle.getString(msg);
}
catch (MissingResourceException e)
{
return "Missing message: " + msg; //$NON-NLS-1$
}
} | [
"static",
"public",
"String",
"getString",
"(",
"String",
"msg",
")",
"{",
"if",
"(",
"bundle",
"==",
"null",
")",
"return",
"msg",
";",
"try",
"{",
"return",
"bundle",
".",
"getString",
"(",
"msg",
")",
";",
"}",
"catch",
"(",
"MissingResourceException"... | Retrieves a message which has no arguments.
@param msg
String the key to look up.
@return String the message for that key in the system message bundle. | [
"Retrieves",
"a",
"message",
"which",
"has",
"no",
"arguments",
"."
] | 73e51d0f3141a859dfbd37ca9becef98477e553e | https://github.com/app55/app55-java/blob/73e51d0f3141a859dfbd37ca9becef98477e553e/src/support/java/org/apache/harmony/beans/internal/nls/Messages.java#L52-L64 |
156,082 | app55/app55-java | src/support/java/org/apache/harmony/beans/internal/nls/Messages.java | Messages.getString | static public String getString(String msg, int arg)
{
return getString(msg, new Object[] { Integer.toString(arg) });
} | java | static public String getString(String msg, int arg)
{
return getString(msg, new Object[] { Integer.toString(arg) });
} | [
"static",
"public",
"String",
"getString",
"(",
"String",
"msg",
",",
"int",
"arg",
")",
"{",
"return",
"getString",
"(",
"msg",
",",
"new",
"Object",
"[",
"]",
"{",
"Integer",
".",
"toString",
"(",
"arg",
")",
"}",
")",
";",
"}"
] | Retrieves a message which takes 1 integer argument.
@param msg
String the key to look up.
@param arg
int the integer to insert in the formatted output.
@return String the message for that key in the system message bundle. | [
"Retrieves",
"a",
"message",
"which",
"takes",
"1",
"integer",
"argument",
"."
] | 73e51d0f3141a859dfbd37ca9becef98477e553e | https://github.com/app55/app55-java/blob/73e51d0f3141a859dfbd37ca9becef98477e553e/src/support/java/org/apache/harmony/beans/internal/nls/Messages.java#L89-L92 |
156,083 | app55/app55-java | src/support/java/org/apache/harmony/beans/internal/nls/Messages.java | Messages.getString | static public String getString(String msg, char arg)
{
return getString(msg, new Object[] { String.valueOf(arg) });
} | java | static public String getString(String msg, char arg)
{
return getString(msg, new Object[] { String.valueOf(arg) });
} | [
"static",
"public",
"String",
"getString",
"(",
"String",
"msg",
",",
"char",
"arg",
")",
"{",
"return",
"getString",
"(",
"msg",
",",
"new",
"Object",
"[",
"]",
"{",
"String",
".",
"valueOf",
"(",
"arg",
")",
"}",
")",
";",
"}"
] | Retrieves a message which takes 1 character argument.
@param msg
String the key to look up.
@param arg
char the character to insert in the formatted output.
@return String the message for that key in the system message bundle. | [
"Retrieves",
"a",
"message",
"which",
"takes",
"1",
"character",
"argument",
"."
] | 73e51d0f3141a859dfbd37ca9becef98477e553e | https://github.com/app55/app55-java/blob/73e51d0f3141a859dfbd37ca9becef98477e553e/src/support/java/org/apache/harmony/beans/internal/nls/Messages.java#L103-L106 |
156,084 | app55/app55-java | src/support/java/org/apache/harmony/beans/internal/nls/Messages.java | Messages.getString | static public String getString(String msg, Object arg1, Object arg2)
{
return getString(msg, new Object[] { arg1, arg2 });
} | java | static public String getString(String msg, Object arg1, Object arg2)
{
return getString(msg, new Object[] { arg1, arg2 });
} | [
"static",
"public",
"String",
"getString",
"(",
"String",
"msg",
",",
"Object",
"arg1",
",",
"Object",
"arg2",
")",
"{",
"return",
"getString",
"(",
"msg",
",",
"new",
"Object",
"[",
"]",
"{",
"arg1",
",",
"arg2",
"}",
")",
";",
"}"
] | Retrieves a message which takes 2 arguments.
@param msg
String the key to look up.
@param arg1
Object an object to insert in the formatted output.
@param arg2
Object another object to insert in the formatted output.
@return String the message for that key in the system message bundle. | [
"Retrieves",
"a",
"message",
"which",
"takes",
"2",
"arguments",
"."
] | 73e51d0f3141a859dfbd37ca9becef98477e553e | https://github.com/app55/app55-java/blob/73e51d0f3141a859dfbd37ca9becef98477e553e/src/support/java/org/apache/harmony/beans/internal/nls/Messages.java#L119-L122 |
156,085 | app55/app55-java | src/support/java/org/apache/harmony/beans/internal/nls/Messages.java | Messages.getString | static public String getString(String msg, Object[] args)
{
String format = msg;
if (bundle != null)
{
try
{
format = bundle.getString(msg);
}
catch (MissingResourceException e)
{
}
}
return format(format, args);
} | java | static public String getString(String msg, Object[] args)
{
String format = msg;
if (bundle != null)
{
try
{
format = bundle.getString(msg);
}
catch (MissingResourceException e)
{
}
}
return format(format, args);
} | [
"static",
"public",
"String",
"getString",
"(",
"String",
"msg",
",",
"Object",
"[",
"]",
"args",
")",
"{",
"String",
"format",
"=",
"msg",
";",
"if",
"(",
"bundle",
"!=",
"null",
")",
"{",
"try",
"{",
"format",
"=",
"bundle",
".",
"getString",
"(",
... | Retrieves a message which takes several arguments.
@param msg
String the key to look up.
@param args
Object[] the objects to insert in the formatted output.
@return String the message for that key in the system message bundle. | [
"Retrieves",
"a",
"message",
"which",
"takes",
"several",
"arguments",
"."
] | 73e51d0f3141a859dfbd37ca9becef98477e553e | https://github.com/app55/app55-java/blob/73e51d0f3141a859dfbd37ca9becef98477e553e/src/support/java/org/apache/harmony/beans/internal/nls/Messages.java#L133-L149 |
156,086 | RogerParkinson/madura-objects-parent | madura-objects/src/main/java/nz/co/senanque/validationengine/ValidationSession.java | ValidationSession.invokeListeners | public void invokeListeners(final ValidationObject object, final String fieldName, final Object newValue, final Object currentValue) {
m_validationEngine.invokeListeners(object, fieldName, newValue, currentValue, this);
} | java | public void invokeListeners(final ValidationObject object, final String fieldName, final Object newValue, final Object currentValue) {
m_validationEngine.invokeListeners(object, fieldName, newValue, currentValue, this);
} | [
"public",
"void",
"invokeListeners",
"(",
"final",
"ValidationObject",
"object",
",",
"final",
"String",
"fieldName",
",",
"final",
"Object",
"newValue",
",",
"final",
"Object",
"currentValue",
")",
"{",
"m_validationEngine",
".",
"invokeListeners",
"(",
"object",
... | This is called after a successful setter call on one of the fields. If any listeners are attached to the field they are invoked
from here.
@param object
@param fieldName
@param newValue
@param currentValue | [
"This",
"is",
"called",
"after",
"a",
"successful",
"setter",
"call",
"on",
"one",
"of",
"the",
"fields",
".",
"If",
"any",
"listeners",
"are",
"attached",
"to",
"the",
"field",
"they",
"are",
"invoked",
"from",
"here",
"."
] | 9b5385dd0437611f0ce8506f63646e018d06fb8e | https://github.com/RogerParkinson/madura-objects-parent/blob/9b5385dd0437611f0ce8506f63646e018d06fb8e/madura-objects/src/main/java/nz/co/senanque/validationengine/ValidationSession.java#L104-L106 |
156,087 | RogerParkinson/madura-objects-parent | madura-objects/src/main/java/nz/co/senanque/validationengine/ValidationSession.java | ValidationSession.addListener | public void addListener(ValidationObject object, String name, SetterListener listener) {
m_validationEngine.addListener(object, name, this, listener);
} | java | public void addListener(ValidationObject object, String name, SetterListener listener) {
m_validationEngine.addListener(object, name, this, listener);
} | [
"public",
"void",
"addListener",
"(",
"ValidationObject",
"object",
",",
"String",
"name",
",",
"SetterListener",
"listener",
")",
"{",
"m_validationEngine",
".",
"addListener",
"(",
"object",
",",
"name",
",",
"this",
",",
"listener",
")",
";",
"}"
] | Add a setter listener to a field.
@param object
@param name
@param listener | [
"Add",
"a",
"setter",
"listener",
"to",
"a",
"field",
"."
] | 9b5385dd0437611f0ce8506f63646e018d06fb8e | https://github.com/RogerParkinson/madura-objects-parent/blob/9b5385dd0437611f0ce8506f63646e018d06fb8e/madura-objects/src/main/java/nz/co/senanque/validationengine/ValidationSession.java#L115-L117 |
156,088 | RogerParkinson/madura-objects-parent | madura-objects/src/main/java/nz/co/senanque/validationengine/ValidationSession.java | ValidationSession.clean | public void clean(final ValidationObject object)
{
if (m_enabled)
{
m_validationEngine.clean(object);
for (ProxyField proxyField:m_history) {
proxyField.expire();
}
}
} | java | public void clean(final ValidationObject object)
{
if (m_enabled)
{
m_validationEngine.clean(object);
for (ProxyField proxyField:m_history) {
proxyField.expire();
}
}
} | [
"public",
"void",
"clean",
"(",
"final",
"ValidationObject",
"object",
")",
"{",
"if",
"(",
"m_enabled",
")",
"{",
"m_validationEngine",
".",
"clean",
"(",
"object",
")",
";",
"for",
"(",
"ProxyField",
"proxyField",
":",
"m_history",
")",
"{",
"proxyField",
... | The clean method ensures that the object and its attached objects are up to date
ie that any mapping is updated. This means the getters on the object are safe to use
@param object | [
"The",
"clean",
"method",
"ensures",
"that",
"the",
"object",
"and",
"its",
"attached",
"objects",
"are",
"up",
"to",
"date",
"ie",
"that",
"any",
"mapping",
"is",
"updated",
".",
"This",
"means",
"the",
"getters",
"on",
"the",
"object",
"are",
"safe",
"... | 9b5385dd0437611f0ce8506f63646e018d06fb8e | https://github.com/RogerParkinson/madura-objects-parent/blob/9b5385dd0437611f0ce8506f63646e018d06fb8e/madura-objects/src/main/java/nz/co/senanque/validationengine/ValidationSession.java#L125-L134 |
156,089 | RogerParkinson/madura-objects-parent | madura-objects/src/main/java/nz/co/senanque/validationengine/ValidationSession.java | ValidationSession.getMetadata | public ObjectMetadata getMetadata(final ValidationObject object)
{
if (m_enabled)
{
m_validationEngine.clean(object);
}
return object.getMetadata();
} | java | public ObjectMetadata getMetadata(final ValidationObject object)
{
if (m_enabled)
{
m_validationEngine.clean(object);
}
return object.getMetadata();
} | [
"public",
"ObjectMetadata",
"getMetadata",
"(",
"final",
"ValidationObject",
"object",
")",
"{",
"if",
"(",
"m_enabled",
")",
"{",
"m_validationEngine",
".",
"clean",
"(",
"object",
")",
";",
"}",
"return",
"object",
".",
"getMetadata",
"(",
")",
";",
"}"
] | Locate the metadata for the given object
The object is cleaned first and then a wrapper for the metadata is returned
@param object
@return the metadata for the object | [
"Locate",
"the",
"metadata",
"for",
"the",
"given",
"object",
"The",
"object",
"is",
"cleaned",
"first",
"and",
"then",
"a",
"wrapper",
"for",
"the",
"metadata",
"is",
"returned"
] | 9b5385dd0437611f0ce8506f63646e018d06fb8e | https://github.com/RogerParkinson/madura-objects-parent/blob/9b5385dd0437611f0ce8506f63646e018d06fb8e/madura-objects/src/main/java/nz/co/senanque/validationengine/ValidationSession.java#L142-L149 |
156,090 | RogerParkinson/madura-objects-parent | madura-objects/src/main/java/nz/co/senanque/validationengine/ValidationSession.java | ValidationSession.removedFrom | protected void removedFrom(final ListeningArray<?> array, final ValidationObject o)
{
if (m_enabled)
{
m_validationEngine.removedFrom(array, o,this);
}
} | java | protected void removedFrom(final ListeningArray<?> array, final ValidationObject o)
{
if (m_enabled)
{
m_validationEngine.removedFrom(array, o,this);
}
} | [
"protected",
"void",
"removedFrom",
"(",
"final",
"ListeningArray",
"<",
"?",
">",
"array",
",",
"final",
"ValidationObject",
"o",
")",
"{",
"if",
"(",
"m_enabled",
")",
"{",
"m_validationEngine",
".",
"removedFrom",
"(",
"array",
",",
"o",
",",
"this",
")... | Remove an object from an array
@param array
@param o | [
"Remove",
"an",
"object",
"from",
"an",
"array"
] | 9b5385dd0437611f0ce8506f63646e018d06fb8e | https://github.com/RogerParkinson/madura-objects-parent/blob/9b5385dd0437611f0ce8506f63646e018d06fb8e/madura-objects/src/main/java/nz/co/senanque/validationengine/ValidationSession.java#L175-L181 |
156,091 | xmlet/XsdAsmFaster | src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmVisitor.java | XsdAsmVisitor.generateVisitors | static void generateVisitors(Set<String> elementNames, List<XsdAttribute> attributes, String apiName){
generateVisitorInterface(elementNames, filterAttributes(attributes), apiName);
} | java | static void generateVisitors(Set<String> elementNames, List<XsdAttribute> attributes, String apiName){
generateVisitorInterface(elementNames, filterAttributes(attributes), apiName);
} | [
"static",
"void",
"generateVisitors",
"(",
"Set",
"<",
"String",
">",
"elementNames",
",",
"List",
"<",
"XsdAttribute",
">",
"attributes",
",",
"String",
"apiName",
")",
"{",
"generateVisitorInterface",
"(",
"elementNames",
",",
"filterAttributes",
"(",
"attribute... | Generates both the abstract visitor class with methods for each element from the list.
@param elementNames The elements names list.
@param apiName The name of the generated fluent interface. | [
"Generates",
"both",
"the",
"abstract",
"visitor",
"class",
"with",
"methods",
"for",
"each",
"element",
"from",
"the",
"list",
"."
] | ccb78f9dd4b957ad5ac1ca349eaf24338c421e94 | https://github.com/xmlet/XsdAsmFaster/blob/ccb78f9dd4b957ad5ac1ca349eaf24338c421e94/src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmVisitor.java#L34-L36 |
156,092 | xmlet/XsdAsmFaster | src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmVisitor.java | XsdAsmVisitor.generateVisitorInterface | private static void generateVisitorInterface(Set<String> elementNames, List<XsdAttribute> attributes, String apiName) {
ClassWriter classWriter = generateClass(ELEMENT_VISITOR, JAVA_OBJECT, null, null, ACC_PUBLIC + ACC_ABSTRACT + ACC_SUPER, apiName);
MethodVisitor mVisitor = classWriter.visitMethod(ACC_PUBLIC, CONSTRUCTOR, "()V", null, null);
mVisitor.visitCode();
mVisitor.visitVarInsn(ALOAD, 0);
mVisitor.visitMethodInsn(INVOKESPECIAL, JAVA_OBJECT, CONSTRUCTOR, "()V", false);
mVisitor.visitInsn(RETURN);
mVisitor.visitMaxs(1, 1);
mVisitor.visitEnd();
mVisitor = classWriter.visitMethod(ACC_PUBLIC + ACC_ABSTRACT, VISIT_ELEMENT_NAME, "(" + elementTypeDesc + ")V", null, null);
mVisitor.visitEnd();
mVisitor = classWriter.visitMethod(ACC_PUBLIC + ACC_ABSTRACT, VISIT_ATTRIBUTE_NAME, "(" + JAVA_STRING_DESC + JAVA_STRING_DESC + ")V", null, null);
mVisitor.visitEnd();
mVisitor = classWriter.visitMethod(ACC_PUBLIC + ACC_ABSTRACT, VISIT_PARENT_NAME, "(" + elementTypeDesc + ")V", null, null);
mVisitor.visitEnd();
mVisitor = classWriter.visitMethod(ACC_PUBLIC + ACC_ABSTRACT, "visitText", "(" + textTypeDesc + ")V", "<R:" + JAVA_OBJECT_DESC + ">(L" + textType + "<+" + elementTypeDesc + "TR;>;)V", null);
mVisitor.visitEnd();
mVisitor = classWriter.visitMethod(ACC_PUBLIC + ACC_ABSTRACT, "visitComment", "(" + textTypeDesc + ")V", "<R:" + JAVA_OBJECT_DESC + ">(L" + textType + "<+" + elementTypeDesc + "TR;>;)V", null);
mVisitor.visitEnd();
mVisitor = classWriter.visitMethod(ACC_PUBLIC, "visitOpenDynamic", "()V", null, null);
mVisitor.visitCode();
mVisitor.visitInsn(RETURN);
mVisitor.visitMaxs(0, 1);
mVisitor.visitEnd();
mVisitor = classWriter.visitMethod(ACC_PUBLIC, "visitCloseDynamic", "()V", null, null);
mVisitor.visitCode();
mVisitor.visitInsn(RETURN);
mVisitor.visitMaxs(0, 1);
mVisitor.visitEnd();
elementNames.forEach(elementName -> addVisitorParentMethod(classWriter, elementName, apiName));
elementNames.forEach(elementName -> addVisitorElementMethod(classWriter, elementName, apiName));
attributes.forEach(attribute -> addVisitorAttributeMethod(classWriter, attribute));
writeClassToFile(ELEMENT_VISITOR, classWriter, apiName);
} | java | private static void generateVisitorInterface(Set<String> elementNames, List<XsdAttribute> attributes, String apiName) {
ClassWriter classWriter = generateClass(ELEMENT_VISITOR, JAVA_OBJECT, null, null, ACC_PUBLIC + ACC_ABSTRACT + ACC_SUPER, apiName);
MethodVisitor mVisitor = classWriter.visitMethod(ACC_PUBLIC, CONSTRUCTOR, "()V", null, null);
mVisitor.visitCode();
mVisitor.visitVarInsn(ALOAD, 0);
mVisitor.visitMethodInsn(INVOKESPECIAL, JAVA_OBJECT, CONSTRUCTOR, "()V", false);
mVisitor.visitInsn(RETURN);
mVisitor.visitMaxs(1, 1);
mVisitor.visitEnd();
mVisitor = classWriter.visitMethod(ACC_PUBLIC + ACC_ABSTRACT, VISIT_ELEMENT_NAME, "(" + elementTypeDesc + ")V", null, null);
mVisitor.visitEnd();
mVisitor = classWriter.visitMethod(ACC_PUBLIC + ACC_ABSTRACT, VISIT_ATTRIBUTE_NAME, "(" + JAVA_STRING_DESC + JAVA_STRING_DESC + ")V", null, null);
mVisitor.visitEnd();
mVisitor = classWriter.visitMethod(ACC_PUBLIC + ACC_ABSTRACT, VISIT_PARENT_NAME, "(" + elementTypeDesc + ")V", null, null);
mVisitor.visitEnd();
mVisitor = classWriter.visitMethod(ACC_PUBLIC + ACC_ABSTRACT, "visitText", "(" + textTypeDesc + ")V", "<R:" + JAVA_OBJECT_DESC + ">(L" + textType + "<+" + elementTypeDesc + "TR;>;)V", null);
mVisitor.visitEnd();
mVisitor = classWriter.visitMethod(ACC_PUBLIC + ACC_ABSTRACT, "visitComment", "(" + textTypeDesc + ")V", "<R:" + JAVA_OBJECT_DESC + ">(L" + textType + "<+" + elementTypeDesc + "TR;>;)V", null);
mVisitor.visitEnd();
mVisitor = classWriter.visitMethod(ACC_PUBLIC, "visitOpenDynamic", "()V", null, null);
mVisitor.visitCode();
mVisitor.visitInsn(RETURN);
mVisitor.visitMaxs(0, 1);
mVisitor.visitEnd();
mVisitor = classWriter.visitMethod(ACC_PUBLIC, "visitCloseDynamic", "()V", null, null);
mVisitor.visitCode();
mVisitor.visitInsn(RETURN);
mVisitor.visitMaxs(0, 1);
mVisitor.visitEnd();
elementNames.forEach(elementName -> addVisitorParentMethod(classWriter, elementName, apiName));
elementNames.forEach(elementName -> addVisitorElementMethod(classWriter, elementName, apiName));
attributes.forEach(attribute -> addVisitorAttributeMethod(classWriter, attribute));
writeClassToFile(ELEMENT_VISITOR, classWriter, apiName);
} | [
"private",
"static",
"void",
"generateVisitorInterface",
"(",
"Set",
"<",
"String",
">",
"elementNames",
",",
"List",
"<",
"XsdAttribute",
">",
"attributes",
",",
"String",
"apiName",
")",
"{",
"ClassWriter",
"classWriter",
"=",
"generateClass",
"(",
"ELEMENT_VISI... | Generates the visitor class for this fluent interface with methods for all elements in the element list.
Main methods:
void visitElement(Element element);
void visitAttribute(String attributeName, String attributeValue);
void visitParent(Element elementName);
<R> void visitText(Text<? extends Element, R> text);
<R> void visitComment(Text<? extends Element, R> comment);
@param elementNames The elements names list.
@param attributes The list of attributes to be generated.
@param apiName The name of the generated fluent interface. | [
"Generates",
"the",
"visitor",
"class",
"for",
"this",
"fluent",
"interface",
"with",
"methods",
"for",
"all",
"elements",
"in",
"the",
"element",
"list",
"."
] | ccb78f9dd4b957ad5ac1ca349eaf24338c421e94 | https://github.com/xmlet/XsdAsmFaster/blob/ccb78f9dd4b957ad5ac1ca349eaf24338c421e94/src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmVisitor.java#L51-L96 |
156,093 | xmlet/XsdAsmFaster | src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmVisitor.java | XsdAsmVisitor.filterAttributes | private static List<XsdAttribute> filterAttributes(List<XsdAttribute> attributes) {
List<String> attributeNames = attributes.stream()
.map(XsdNamedElements::getName)
.distinct()
.collect(Collectors.toList());
List<XsdAttribute> filteredAttributes = new ArrayList<>();
attributeNames.forEach(attributeName -> {
for (XsdAttribute attribute : attributes) {
if (attribute.getName().equals(attributeName)){
filteredAttributes.add(attribute);
break;
}
}
});
return filteredAttributes;
} | java | private static List<XsdAttribute> filterAttributes(List<XsdAttribute> attributes) {
List<String> attributeNames = attributes.stream()
.map(XsdNamedElements::getName)
.distinct()
.collect(Collectors.toList());
List<XsdAttribute> filteredAttributes = new ArrayList<>();
attributeNames.forEach(attributeName -> {
for (XsdAttribute attribute : attributes) {
if (attribute.getName().equals(attributeName)){
filteredAttributes.add(attribute);
break;
}
}
});
return filteredAttributes;
} | [
"private",
"static",
"List",
"<",
"XsdAttribute",
">",
"filterAttributes",
"(",
"List",
"<",
"XsdAttribute",
">",
"attributes",
")",
"{",
"List",
"<",
"String",
">",
"attributeNames",
"=",
"attributes",
".",
"stream",
"(",
")",
".",
"map",
"(",
"XsdNamedElem... | Removes duplicate attribute names.
@param attributes The {@link List} of {@link XsdAttribute} objects.
@return The distinct {@link List} of {@link XsdAttribute}. | [
"Removes",
"duplicate",
"attribute",
"names",
"."
] | ccb78f9dd4b957ad5ac1ca349eaf24338c421e94 | https://github.com/xmlet/XsdAsmFaster/blob/ccb78f9dd4b957ad5ac1ca349eaf24338c421e94/src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmVisitor.java#L177-L195 |
156,094 | foundation-runtime/service-directory | 2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryServers.java | DirectoryServers.getNextDirectoryServer | public InetSocketAddress getNextDirectoryServer(){
index = index + 1;
if(index == servers.size()){
index = 0;
}
InetSocketAddress unresolved = servers.get(index);
// List<InetSocketAddress> resolved = null;
// try {
// InetAddress[] addresses = InetAddress.getAllByName(unresolved.getHostName());
// for(InetAddress address : addresses){
// if(resolved == null){
// resolved = new ArrayList<InetSocketAddress>();
// }
// resolved.add(new InetSocketAddress(address.getHostAddress(), unresolved.getPort()));
// }
// } catch (UnknownHostException e) {
// LOGGER.error("Resolve the Directory Server failed, host=" + unresolved.getAddress().toString() + " - " + e.getMessage());
// }
//
// if(resolved == null){
// return Collections.emptyList();
// }
return new InetSocketAddress(unresolved.getHostName(), unresolved.getPort());
} | java | public InetSocketAddress getNextDirectoryServer(){
index = index + 1;
if(index == servers.size()){
index = 0;
}
InetSocketAddress unresolved = servers.get(index);
// List<InetSocketAddress> resolved = null;
// try {
// InetAddress[] addresses = InetAddress.getAllByName(unresolved.getHostName());
// for(InetAddress address : addresses){
// if(resolved == null){
// resolved = new ArrayList<InetSocketAddress>();
// }
// resolved.add(new InetSocketAddress(address.getHostAddress(), unresolved.getPort()));
// }
// } catch (UnknownHostException e) {
// LOGGER.error("Resolve the Directory Server failed, host=" + unresolved.getAddress().toString() + " - " + e.getMessage());
// }
//
// if(resolved == null){
// return Collections.emptyList();
// }
return new InetSocketAddress(unresolved.getHostName(), unresolved.getPort());
} | [
"public",
"InetSocketAddress",
"getNextDirectoryServer",
"(",
")",
"{",
"index",
"=",
"index",
"+",
"1",
";",
"if",
"(",
"index",
"==",
"servers",
".",
"size",
"(",
")",
")",
"{",
"index",
"=",
"0",
";",
"}",
"InetSocketAddress",
"unresolved",
"=",
"serv... | Get the next directory server.
@return
the Directory Server InetSocketAddress. | [
"Get",
"the",
"next",
"directory",
"server",
"."
] | a7bdefe173dc99e75eff4a24e07e6407e62f2ed4 | https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryServers.java#L83-L108 |
156,095 | foundation-runtime/service-directory | 2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryServers.java | DirectoryServers.parseServers | private void parseServers(List<String> servers){
if(servers != null && servers.size() > 0){
this.servers = new ArrayList<InetSocketAddress>();
for(String server : servers){
String[] ss = server.split(":");
if(ss.length == 2){
String host = ss[0];
int port = 0;
try{
port = Integer.valueOf(ss[1]);
} catch(NumberFormatException e){
// do nothing.
}
if(validateServer(host, port)){
this.servers.add(InetSocketAddress.createUnresolved(host, port));
}
}
}
}
} | java | private void parseServers(List<String> servers){
if(servers != null && servers.size() > 0){
this.servers = new ArrayList<InetSocketAddress>();
for(String server : servers){
String[] ss = server.split(":");
if(ss.length == 2){
String host = ss[0];
int port = 0;
try{
port = Integer.valueOf(ss[1]);
} catch(NumberFormatException e){
// do nothing.
}
if(validateServer(host, port)){
this.servers.add(InetSocketAddress.createUnresolved(host, port));
}
}
}
}
} | [
"private",
"void",
"parseServers",
"(",
"List",
"<",
"String",
">",
"servers",
")",
"{",
"if",
"(",
"servers",
"!=",
"null",
"&&",
"servers",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"this",
".",
"servers",
"=",
"new",
"ArrayList",
"<",
"InetSocket... | Parser the server list.
@param servers
the server list. | [
"Parser",
"the",
"server",
"list",
"."
] | a7bdefe173dc99e75eff4a24e07e6407e62f2ed4 | https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryServers.java#L116-L135 |
156,096 | foundation-runtime/service-directory | 2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryServers.java | DirectoryServers.validateServer | private boolean validateServer(String host, int port){
if(host==null || host.isEmpty()){
return false;
}
if(port <=0 || port > 65535){
return false;
}
return true;
} | java | private boolean validateServer(String host, int port){
if(host==null || host.isEmpty()){
return false;
}
if(port <=0 || port > 65535){
return false;
}
return true;
} | [
"private",
"boolean",
"validateServer",
"(",
"String",
"host",
",",
"int",
"port",
")",
"{",
"if",
"(",
"host",
"==",
"null",
"||",
"host",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"port",
"<=",
"0",
"||",
"port",... | Validate the host and port.
@param host
the host string.
@param port
the port number.
@return
true for success. | [
"Validate",
"the",
"host",
"and",
"port",
"."
] | a7bdefe173dc99e75eff4a24e07e6407e62f2ed4 | https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/DirectoryServers.java#L147-L155 |
156,097 | morimekta/utils | android-util/src/main/java/android/os/Parcel.java | Parcel.recycle | public void recycle() {
size = 0;
position = 0;
// clear data so it won't leak.
fill(buffer, 0, buffer.length, (byte) 0);
synchronized (pool) {
// If the pool is already full, cycle back in new parcels to enable
// refreshing memory.
if (pool.size() == kMaxPoolSize) {
pool.poll();
}
pool.offer(this);
}
} | java | public void recycle() {
size = 0;
position = 0;
// clear data so it won't leak.
fill(buffer, 0, buffer.length, (byte) 0);
synchronized (pool) {
// If the pool is already full, cycle back in new parcels to enable
// refreshing memory.
if (pool.size() == kMaxPoolSize) {
pool.poll();
}
pool.offer(this);
}
} | [
"public",
"void",
"recycle",
"(",
")",
"{",
"size",
"=",
"0",
";",
"position",
"=",
"0",
";",
"// clear data so it won't leak.",
"fill",
"(",
"buffer",
",",
"0",
",",
"buffer",
".",
"length",
",",
"(",
"byte",
")",
"0",
")",
";",
"synchronized",
"(",
... | Put a Parcel object back into the pool. | [
"Put",
"a",
"Parcel",
"object",
"back",
"into",
"the",
"pool",
"."
] | dc987485902f1a7d58169c89c61db97425a6226d | https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/android-util/src/main/java/android/os/Parcel.java#L75-L89 |
156,098 | hudson3-plugins/warnings-plugin | src/main/java/hudson/plugins/warnings/ParserConfiguration.java | ParserConfiguration.filterExisting | public static ParserConfiguration[] filterExisting(final List<? extends ParserConfiguration> parsers) {
List<ParserConfiguration> existing = Lists.newArrayList();
for (ParserConfiguration parser : parsers) {
if (ParserRegistry.exists(parser.getParserName())) {
existing.add(parser);
}
}
return existing.toArray(new ParserConfiguration[existing.size()]);
} | java | public static ParserConfiguration[] filterExisting(final List<? extends ParserConfiguration> parsers) {
List<ParserConfiguration> existing = Lists.newArrayList();
for (ParserConfiguration parser : parsers) {
if (ParserRegistry.exists(parser.getParserName())) {
existing.add(parser);
}
}
return existing.toArray(new ParserConfiguration[existing.size()]);
} | [
"public",
"static",
"ParserConfiguration",
"[",
"]",
"filterExisting",
"(",
"final",
"List",
"<",
"?",
"extends",
"ParserConfiguration",
">",
"parsers",
")",
"{",
"List",
"<",
"ParserConfiguration",
">",
"existing",
"=",
"Lists",
".",
"newArrayList",
"(",
")",
... | Removes non-existing parsers from the specified collection of parsers.
@param parsers
the parsers
@return a new list containing the filtered parsers | [
"Removes",
"non",
"-",
"existing",
"parsers",
"from",
"the",
"specified",
"collection",
"of",
"parsers",
"."
] | 462c9f3dffede9120173935567392b22520b0966 | https://github.com/hudson3-plugins/warnings-plugin/blob/462c9f3dffede9120173935567392b22520b0966/src/main/java/hudson/plugins/warnings/ParserConfiguration.java#L77-L85 |
156,099 | G2G3Digital/substeps-framework | core/src/main/java/com/technophobia/substeps/runner/syntax/ClassAnalyser.java | ClassAnalyser.analyseAdditionalStepImplementations | private void analyseAdditionalStepImplementations(final Class<?> loadedClass, final Syntax syntax,
final Class<?>[] additionalStepImplementationClasses) {
for (final Class<?> stepImplClass : additionalStepImplementationClasses) {
analyseClass(stepImplClass, syntax);
}
} | java | private void analyseAdditionalStepImplementations(final Class<?> loadedClass, final Syntax syntax,
final Class<?>[] additionalStepImplementationClasses) {
for (final Class<?> stepImplClass : additionalStepImplementationClasses) {
analyseClass(stepImplClass, syntax);
}
} | [
"private",
"void",
"analyseAdditionalStepImplementations",
"(",
"final",
"Class",
"<",
"?",
">",
"loadedClass",
",",
"final",
"Syntax",
"syntax",
",",
"final",
"Class",
"<",
"?",
">",
"[",
"]",
"additionalStepImplementationClasses",
")",
"{",
"for",
"(",
"final"... | Analyses all deferred step implementation classes of the loading class
@param loadedClass
@param syntax
@param syntaxErrorReporter | [
"Analyses",
"all",
"deferred",
"step",
"implementation",
"classes",
"of",
"the",
"loading",
"class"
] | c1ec6487e1673a7dae54b5e7b62a96f602cd280a | https://github.com/G2G3Digital/substeps-framework/blob/c1ec6487e1673a7dae54b5e7b62a96f602cd280a/core/src/main/java/com/technophobia/substeps/runner/syntax/ClassAnalyser.java#L117-L122 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.