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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
143,300 | galan/commons | src/main/java/de/galan/commons/net/flux/Flux.java | Flux.addDefaultHeader | public static void addDefaultHeader(String key, String value) {
if (isNotBlank(key) && isNotBlank(value)) {
if (defaultHeader == null) {
defaultHeader = new HashMap<String, String>();
}
defaultHeader.put(key, value);
}
} | java | public static void addDefaultHeader(String key, String value) {
if (isNotBlank(key) && isNotBlank(value)) {
if (defaultHeader == null) {
defaultHeader = new HashMap<String, String>();
}
defaultHeader.put(key, value);
}
} | [
"public",
"static",
"void",
"addDefaultHeader",
"(",
"String",
"key",
",",
"String",
"value",
")",
"{",
"if",
"(",
"isNotBlank",
"(",
"key",
")",
"&&",
"isNotBlank",
"(",
"value",
")",
")",
"{",
"if",
"(",
"defaultHeader",
"==",
"null",
")",
"{",
"defaultHeader",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"}",
"defaultHeader",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"}",
"}"
] | Added default headers will always be send, can still be overriden using the builder. | [
"Added",
"default",
"headers",
"will",
"always",
"be",
"send",
"can",
"still",
"be",
"overriden",
"using",
"the",
"builder",
"."
] | 45d2f36c69958d3f847e5fed66603ea629471822 | https://github.com/galan/commons/blob/45d2f36c69958d3f847e5fed66603ea629471822/src/main/java/de/galan/commons/net/flux/Flux.java#L103-L110 |
143,301 | galan/commons | src/main/java/de/galan/commons/net/flux/Flux.java | Flux.request | public static HttpBuilder request(String protocol, String host, Integer port, String path) {
return defaults(createClient().request(protocol, host, port, path));
} | java | public static HttpBuilder request(String protocol, String host, Integer port, String path) {
return defaults(createClient().request(protocol, host, port, path));
} | [
"public",
"static",
"HttpBuilder",
"request",
"(",
"String",
"protocol",
",",
"String",
"host",
",",
"Integer",
"port",
",",
"String",
"path",
")",
"{",
"return",
"defaults",
"(",
"createClient",
"(",
")",
".",
"request",
"(",
"protocol",
",",
"host",
",",
"port",
",",
"path",
")",
")",
";",
"}"
] | Specifies the resource to be requested.
@param protocol Protocol of the resource
@param host Host of the resource
@param port Port the host is listening on
@param path Path for the resource
@return The HttpBuilder | [
"Specifies",
"the",
"resource",
"to",
"be",
"requested",
"."
] | 45d2f36c69958d3f847e5fed66603ea629471822 | https://github.com/galan/commons/blob/45d2f36c69958d3f847e5fed66603ea629471822/src/main/java/de/galan/commons/net/flux/Flux.java#L150-L152 |
143,302 | galan/commons | src/main/java/de/galan/commons/net/flux/Flux.java | Flux.defaults | private static HttpBuilder defaults(HttpBuilder builder) {
if (defaultTimeout != null) {
builder.timeout(defaultTimeout);
}
if (defaultTimeoutConnection != null) {
builder.timeoutConnection(defaultTimeoutConnection);
}
if (defaultTimeoutRead != null) {
builder.timeoutRead(defaultTimeoutRead);
}
if (defaultHeader != null) {
builder.headers(defaultHeader);
}
return builder;
} | java | private static HttpBuilder defaults(HttpBuilder builder) {
if (defaultTimeout != null) {
builder.timeout(defaultTimeout);
}
if (defaultTimeoutConnection != null) {
builder.timeoutConnection(defaultTimeoutConnection);
}
if (defaultTimeoutRead != null) {
builder.timeoutRead(defaultTimeoutRead);
}
if (defaultHeader != null) {
builder.headers(defaultHeader);
}
return builder;
} | [
"private",
"static",
"HttpBuilder",
"defaults",
"(",
"HttpBuilder",
"builder",
")",
"{",
"if",
"(",
"defaultTimeout",
"!=",
"null",
")",
"{",
"builder",
".",
"timeout",
"(",
"defaultTimeout",
")",
";",
"}",
"if",
"(",
"defaultTimeoutConnection",
"!=",
"null",
")",
"{",
"builder",
".",
"timeoutConnection",
"(",
"defaultTimeoutConnection",
")",
";",
"}",
"if",
"(",
"defaultTimeoutRead",
"!=",
"null",
")",
"{",
"builder",
".",
"timeoutRead",
"(",
"defaultTimeoutRead",
")",
";",
"}",
"if",
"(",
"defaultHeader",
"!=",
"null",
")",
"{",
"builder",
".",
"headers",
"(",
"defaultHeader",
")",
";",
"}",
"return",
"builder",
";",
"}"
] | Setting the static defaults before returning the builder | [
"Setting",
"the",
"static",
"defaults",
"before",
"returning",
"the",
"builder"
] | 45d2f36c69958d3f847e5fed66603ea629471822 | https://github.com/galan/commons/blob/45d2f36c69958d3f847e5fed66603ea629471822/src/main/java/de/galan/commons/net/flux/Flux.java#L161-L175 |
143,303 | galan/commons | src/main/java/de/galan/commons/util/MessageBox.java | MessageBox.printBox | public static void printBox(String title, String message) {
printBox(title, Splitter.on(LINEBREAK).splitToList(message));
} | java | public static void printBox(String title, String message) {
printBox(title, Splitter.on(LINEBREAK).splitToList(message));
} | [
"public",
"static",
"void",
"printBox",
"(",
"String",
"title",
",",
"String",
"message",
")",
"{",
"printBox",
"(",
"title",
",",
"Splitter",
".",
"on",
"(",
"LINEBREAK",
")",
".",
"splitToList",
"(",
"message",
")",
")",
";",
"}"
] | Prints a box with the given title and message to the logger, the title can be omitted. | [
"Prints",
"a",
"box",
"with",
"the",
"given",
"title",
"and",
"message",
"to",
"the",
"logger",
"the",
"title",
"can",
"be",
"omitted",
"."
] | 45d2f36c69958d3f847e5fed66603ea629471822 | https://github.com/galan/commons/blob/45d2f36c69958d3f847e5fed66603ea629471822/src/main/java/de/galan/commons/util/MessageBox.java#L26-L28 |
143,304 | galan/commons | src/main/java/de/galan/commons/util/MessageBox.java | MessageBox.printBox | public static void printBox(String title, List<String> messageLines) {
Say.info("{message}", generateBox(title, messageLines));
} | java | public static void printBox(String title, List<String> messageLines) {
Say.info("{message}", generateBox(title, messageLines));
} | [
"public",
"static",
"void",
"printBox",
"(",
"String",
"title",
",",
"List",
"<",
"String",
">",
"messageLines",
")",
"{",
"Say",
".",
"info",
"(",
"\"{message}\"",
",",
"generateBox",
"(",
"title",
",",
"messageLines",
")",
")",
";",
"}"
] | Prints a box with the given title and message lines to the logger, the title can be omitted. | [
"Prints",
"a",
"box",
"with",
"the",
"given",
"title",
"and",
"message",
"lines",
"to",
"the",
"logger",
"the",
"title",
"can",
"be",
"omitted",
"."
] | 45d2f36c69958d3f847e5fed66603ea629471822 | https://github.com/galan/commons/blob/45d2f36c69958d3f847e5fed66603ea629471822/src/main/java/de/galan/commons/util/MessageBox.java#L32-L34 |
143,305 | galan/commons | src/main/java/de/galan/commons/time/ApplicationClock.java | ApplicationClock.setUtc | public static void setUtc(Date time) {
setClock(Clock.fixed(time.toInstant(), ZoneId.of("UTC")));
} | java | public static void setUtc(Date time) {
setClock(Clock.fixed(time.toInstant(), ZoneId.of("UTC")));
} | [
"public",
"static",
"void",
"setUtc",
"(",
"Date",
"time",
")",
"{",
"setClock",
"(",
"Clock",
".",
"fixed",
"(",
"time",
".",
"toInstant",
"(",
")",
",",
"ZoneId",
".",
"of",
"(",
"\"UTC\"",
")",
")",
")",
";",
"}"
] | Creates a fixed Clock. | [
"Creates",
"a",
"fixed",
"Clock",
"."
] | 45d2f36c69958d3f847e5fed66603ea629471822 | https://github.com/galan/commons/blob/45d2f36c69958d3f847e5fed66603ea629471822/src/main/java/de/galan/commons/time/ApplicationClock.java#L45-L47 |
143,306 | galan/commons | src/main/java/de/galan/commons/util/JvmUtil.java | JvmUtil.addShutdownHook | public synchronized static void addShutdownHook(Runnable task) {
if (task != null) {
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
try {
task.run();
}
catch (RuntimeException rex) {
Say.warn("Exception while processing shutdown-hook", rex);
}
}));
}
} | java | public synchronized static void addShutdownHook(Runnable task) {
if (task != null) {
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
try {
task.run();
}
catch (RuntimeException rex) {
Say.warn("Exception while processing shutdown-hook", rex);
}
}));
}
} | [
"public",
"synchronized",
"static",
"void",
"addShutdownHook",
"(",
"Runnable",
"task",
")",
"{",
"if",
"(",
"task",
"!=",
"null",
")",
"{",
"Runtime",
".",
"getRuntime",
"(",
")",
".",
"addShutdownHook",
"(",
"new",
"Thread",
"(",
"(",
")",
"->",
"{",
"try",
"{",
"task",
".",
"run",
"(",
")",
";",
"}",
"catch",
"(",
"RuntimeException",
"rex",
")",
"{",
"Say",
".",
"warn",
"(",
"\"Exception while processing shutdown-hook\"",
",",
"rex",
")",
";",
"}",
"}",
")",
")",
";",
"}",
"}"
] | Null-safe shortcut to Runtime method, catching RuntimeExceptions. | [
"Null",
"-",
"safe",
"shortcut",
"to",
"Runtime",
"method",
"catching",
"RuntimeExceptions",
"."
] | 45d2f36c69958d3f847e5fed66603ea629471822 | https://github.com/galan/commons/blob/45d2f36c69958d3f847e5fed66603ea629471822/src/main/java/de/galan/commons/util/JvmUtil.java#L110-L121 |
143,307 | galan/commons | src/main/java/de/galan/commons/util/Measure.java | Measure.finish | public void finish() {
if (startMeasure == null) {
Say.info("No invokations are measured");
}
else {
long total = System.currentTimeMillis() - startMeasure;
double average = 1d * total / counter;
logFinished(total, average);
}
} | java | public void finish() {
if (startMeasure == null) {
Say.info("No invokations are measured");
}
else {
long total = System.currentTimeMillis() - startMeasure;
double average = 1d * total / counter;
logFinished(total, average);
}
} | [
"public",
"void",
"finish",
"(",
")",
"{",
"if",
"(",
"startMeasure",
"==",
"null",
")",
"{",
"Say",
".",
"info",
"(",
"\"No invokations are measured\"",
")",
";",
"}",
"else",
"{",
"long",
"total",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"startMeasure",
";",
"double",
"average",
"=",
"1d",
"*",
"total",
"/",
"counter",
";",
"logFinished",
"(",
"total",
",",
"average",
")",
";",
"}",
"}"
] | This method can be called to print the total amount of time taken until that point in time. | [
"This",
"method",
"can",
"be",
"called",
"to",
"print",
"the",
"total",
"amount",
"of",
"time",
"taken",
"until",
"that",
"point",
"in",
"time",
"."
] | 45d2f36c69958d3f847e5fed66603ea629471822 | https://github.com/galan/commons/blob/45d2f36c69958d3f847e5fed66603ea629471822/src/main/java/de/galan/commons/util/Measure.java#L55-L64 |
143,308 | galan/commons | src/main/java/de/galan/commons/util/Measure.java | Measure.run | public void run(ExceptionalRunnable runnable) throws Exception {
initStartTotal();
long startInvokation = System.currentTimeMillis();
runnable.run();
invoked(System.currentTimeMillis() - startInvokation);
} | java | public void run(ExceptionalRunnable runnable) throws Exception {
initStartTotal();
long startInvokation = System.currentTimeMillis();
runnable.run();
invoked(System.currentTimeMillis() - startInvokation);
} | [
"public",
"void",
"run",
"(",
"ExceptionalRunnable",
"runnable",
")",
"throws",
"Exception",
"{",
"initStartTotal",
"(",
")",
";",
"long",
"startInvokation",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"runnable",
".",
"run",
"(",
")",
";",
"invoked",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"startInvokation",
")",
";",
"}"
] | Measure the invokation time of the given ExceptionalRunnable. | [
"Measure",
"the",
"invokation",
"time",
"of",
"the",
"given",
"ExceptionalRunnable",
"."
] | 45d2f36c69958d3f847e5fed66603ea629471822 | https://github.com/galan/commons/blob/45d2f36c69958d3f847e5fed66603ea629471822/src/main/java/de/galan/commons/util/Measure.java#L82-L87 |
143,309 | galan/commons | src/main/java/de/galan/commons/util/Measure.java | Measure.call | public <V> V call(Callable<V> callable) throws Exception {
initStartTotal();
long startInvokation = System.currentTimeMillis();
V result = callable.call();
invoked(System.currentTimeMillis() - startInvokation);
return result;
} | java | public <V> V call(Callable<V> callable) throws Exception {
initStartTotal();
long startInvokation = System.currentTimeMillis();
V result = callable.call();
invoked(System.currentTimeMillis() - startInvokation);
return result;
} | [
"public",
"<",
"V",
">",
"V",
"call",
"(",
"Callable",
"<",
"V",
">",
"callable",
")",
"throws",
"Exception",
"{",
"initStartTotal",
"(",
")",
";",
"long",
"startInvokation",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"V",
"result",
"=",
"callable",
".",
"call",
"(",
")",
";",
"invoked",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"startInvokation",
")",
";",
"return",
"result",
";",
"}"
] | Measure the invokation time of the given Callable. | [
"Measure",
"the",
"invokation",
"time",
"of",
"the",
"given",
"Callable",
"."
] | 45d2f36c69958d3f847e5fed66603ea629471822 | https://github.com/galan/commons/blob/45d2f36c69958d3f847e5fed66603ea629471822/src/main/java/de/galan/commons/util/Measure.java#L91-L97 |
143,310 | galan/commons | src/main/java/de/galan/commons/time/Sleeper.java | Sleeper.sleep | public static void sleep(long millis) {
try {
Thread.sleep(millis);
}
catch (InterruptedException ex) {
Thread.currentThread().interrupt();
}
} | java | public static void sleep(long millis) {
try {
Thread.sleep(millis);
}
catch (InterruptedException ex) {
Thread.currentThread().interrupt();
}
} | [
"public",
"static",
"void",
"sleep",
"(",
"long",
"millis",
")",
"{",
"try",
"{",
"Thread",
".",
"sleep",
"(",
"millis",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"ex",
")",
"{",
"Thread",
".",
"currentThread",
"(",
")",
".",
"interrupt",
"(",
")",
";",
"}",
"}"
] | Sleep the given milliseconds, swallowing the exception
@param millis time in milliseconds | [
"Sleep",
"the",
"given",
"milliseconds",
"swallowing",
"the",
"exception"
] | 45d2f36c69958d3f847e5fed66603ea629471822 | https://github.com/galan/commons/blob/45d2f36c69958d3f847e5fed66603ea629471822/src/main/java/de/galan/commons/time/Sleeper.java#L23-L30 |
143,311 | galan/commons | src/main/java/de/galan/commons/util/Sugar.java | Sugar.fallback | public <T> T fallback(T val, T fallback) {
return val != null ? val : fallback;
} | java | public <T> T fallback(T val, T fallback) {
return val != null ? val : fallback;
} | [
"public",
"<",
"T",
">",
"T",
"fallback",
"(",
"T",
"val",
",",
"T",
"fallback",
")",
"{",
"return",
"val",
"!=",
"null",
"?",
"val",
":",
"fallback",
";",
"}"
] | Returns the given value, or the fallback if the value is null. | [
"Returns",
"the",
"given",
"value",
"or",
"the",
"fallback",
"if",
"the",
"value",
"is",
"null",
"."
] | 45d2f36c69958d3f847e5fed66603ea629471822 | https://github.com/galan/commons/blob/45d2f36c69958d3f847e5fed66603ea629471822/src/main/java/de/galan/commons/util/Sugar.java#L19-L21 |
143,312 | centic9/commons-test | src/main/java/org/dstadler/commons/email/MockSMTPServer.java | MockSMTPServer.getMessages | public Iterator<String> getMessages() {
Iterator<SmtpMessage> it = server.getReceivedEmail();
List<String> msgs = new ArrayList<>();
while(it.hasNext()) {
SmtpMessage msg = it.next();
msgs.add(msg.toString());
}
return msgs.iterator();
} | java | public Iterator<String> getMessages() {
Iterator<SmtpMessage> it = server.getReceivedEmail();
List<String> msgs = new ArrayList<>();
while(it.hasNext()) {
SmtpMessage msg = it.next();
msgs.add(msg.toString());
}
return msgs.iterator();
} | [
"public",
"Iterator",
"<",
"String",
">",
"getMessages",
"(",
")",
"{",
"Iterator",
"<",
"SmtpMessage",
">",
"it",
"=",
"server",
".",
"getReceivedEmail",
"(",
")",
";",
"List",
"<",
"String",
">",
"msgs",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"while",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"SmtpMessage",
"msg",
"=",
"it",
".",
"next",
"(",
")",
";",
"msgs",
".",
"add",
"(",
"msg",
".",
"toString",
"(",
")",
")",
";",
"}",
"return",
"msgs",
".",
"iterator",
"(",
")",
";",
"}"
] | Returns an iterator of messages that were received by this server.
The iterator is of type SmtpMessage from the dumbster-jar file.
Note: calling start() again on this instance resets this list.
@return An iterator of the messages that were received. | [
"Returns",
"an",
"iterator",
"of",
"messages",
"that",
"were",
"received",
"by",
"this",
"server",
"."
] | 562047c198133ecb116f2472e9aeb15e866579f5 | https://github.com/centic9/commons-test/blob/562047c198133ecb116f2472e9aeb15e866579f5/src/main/java/org/dstadler/commons/email/MockSMTPServer.java#L109-L119 |
143,313 | galan/commons | src/main/java/de/galan/commons/util/JmxUtil.java | JmxUtil.registerMBean | public static void registerMBean(String packageName, String type, String name, Object mbean) {
try {
String pkg = defaultString(packageName, mbean.getClass().getPackage().getName());
MBeanServer server = ManagementFactory.getPlatformMBeanServer();
ObjectName on = new ObjectName(pkg + ":type=" + type + ",name=" + name);
if (server.isRegistered(on)) {
Say.debug("MBean with type {type} and name {name} for {package} has already been defined, ignoring", type, name, pkg);
}
else {
server.registerMBean(mbean, on);
}
}
catch (Exception ex) {
Say.warn("MBean could not be registered", ex);
}
} | java | public static void registerMBean(String packageName, String type, String name, Object mbean) {
try {
String pkg = defaultString(packageName, mbean.getClass().getPackage().getName());
MBeanServer server = ManagementFactory.getPlatformMBeanServer();
ObjectName on = new ObjectName(pkg + ":type=" + type + ",name=" + name);
if (server.isRegistered(on)) {
Say.debug("MBean with type {type} and name {name} for {package} has already been defined, ignoring", type, name, pkg);
}
else {
server.registerMBean(mbean, on);
}
}
catch (Exception ex) {
Say.warn("MBean could not be registered", ex);
}
} | [
"public",
"static",
"void",
"registerMBean",
"(",
"String",
"packageName",
",",
"String",
"type",
",",
"String",
"name",
",",
"Object",
"mbean",
")",
"{",
"try",
"{",
"String",
"pkg",
"=",
"defaultString",
"(",
"packageName",
",",
"mbean",
".",
"getClass",
"(",
")",
".",
"getPackage",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"MBeanServer",
"server",
"=",
"ManagementFactory",
".",
"getPlatformMBeanServer",
"(",
")",
";",
"ObjectName",
"on",
"=",
"new",
"ObjectName",
"(",
"pkg",
"+",
"\":type=\"",
"+",
"type",
"+",
"\",name=\"",
"+",
"name",
")",
";",
"if",
"(",
"server",
".",
"isRegistered",
"(",
"on",
")",
")",
"{",
"Say",
".",
"debug",
"(",
"\"MBean with type {type} and name {name} for {package} has already been defined, ignoring\"",
",",
"type",
",",
"name",
",",
"pkg",
")",
";",
"}",
"else",
"{",
"server",
".",
"registerMBean",
"(",
"mbean",
",",
"on",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"Say",
".",
"warn",
"(",
"\"MBean could not be registered\"",
",",
"ex",
")",
";",
"}",
"}"
] | Will register the given mbean using the given packageName, type and name. If no packageName has been given, the
package of the mbean will be used. | [
"Will",
"register",
"the",
"given",
"mbean",
"using",
"the",
"given",
"packageName",
"type",
"and",
"name",
".",
"If",
"no",
"packageName",
"has",
"been",
"given",
"the",
"package",
"of",
"the",
"mbean",
"will",
"be",
"used",
"."
] | 45d2f36c69958d3f847e5fed66603ea629471822 | https://github.com/galan/commons/blob/45d2f36c69958d3f847e5fed66603ea629471822/src/main/java/de/galan/commons/util/JmxUtil.java#L22-L37 |
143,314 | galan/commons | src/main/java/de/galan/commons/time/Durations.java | Durations.dehumanize | public static Long dehumanize(String time) {
Long result = getHumantimeCache().get(time);
if (result == null) {
if (isNotBlank(time)) {
String input = time.trim();
if (NumberUtils.isDigits(input)) {
result = NumberUtils.toLong(input);
}
else {
Matcher matcher = PATTERN_HUMAN_TIME.matcher(input);
if (matcher.matches()) {
long sum = 0L;
sum += dehumanizeUnit(matcher.group(1), MS_WEEK);
sum += dehumanizeUnit(matcher.group(2), MS_DAY);
sum += dehumanizeUnit(matcher.group(3), MS_HOUR);
sum += dehumanizeUnit(matcher.group(4), MS_MINUTE);
sum += dehumanizeUnit(matcher.group(5), MS_SECOND);
sum += dehumanizeUnit(matcher.group(6), MS_MILLISECOND);
result = sum;
}
}
getHumantimeCache().put(time, result);
}
}
return result;
} | java | public static Long dehumanize(String time) {
Long result = getHumantimeCache().get(time);
if (result == null) {
if (isNotBlank(time)) {
String input = time.trim();
if (NumberUtils.isDigits(input)) {
result = NumberUtils.toLong(input);
}
else {
Matcher matcher = PATTERN_HUMAN_TIME.matcher(input);
if (matcher.matches()) {
long sum = 0L;
sum += dehumanizeUnit(matcher.group(1), MS_WEEK);
sum += dehumanizeUnit(matcher.group(2), MS_DAY);
sum += dehumanizeUnit(matcher.group(3), MS_HOUR);
sum += dehumanizeUnit(matcher.group(4), MS_MINUTE);
sum += dehumanizeUnit(matcher.group(5), MS_SECOND);
sum += dehumanizeUnit(matcher.group(6), MS_MILLISECOND);
result = sum;
}
}
getHumantimeCache().put(time, result);
}
}
return result;
} | [
"public",
"static",
"Long",
"dehumanize",
"(",
"String",
"time",
")",
"{",
"Long",
"result",
"=",
"getHumantimeCache",
"(",
")",
".",
"get",
"(",
"time",
")",
";",
"if",
"(",
"result",
"==",
"null",
")",
"{",
"if",
"(",
"isNotBlank",
"(",
"time",
")",
")",
"{",
"String",
"input",
"=",
"time",
".",
"trim",
"(",
")",
";",
"if",
"(",
"NumberUtils",
".",
"isDigits",
"(",
"input",
")",
")",
"{",
"result",
"=",
"NumberUtils",
".",
"toLong",
"(",
"input",
")",
";",
"}",
"else",
"{",
"Matcher",
"matcher",
"=",
"PATTERN_HUMAN_TIME",
".",
"matcher",
"(",
"input",
")",
";",
"if",
"(",
"matcher",
".",
"matches",
"(",
")",
")",
"{",
"long",
"sum",
"=",
"0L",
";",
"sum",
"+=",
"dehumanizeUnit",
"(",
"matcher",
".",
"group",
"(",
"1",
")",
",",
"MS_WEEK",
")",
";",
"sum",
"+=",
"dehumanizeUnit",
"(",
"matcher",
".",
"group",
"(",
"2",
")",
",",
"MS_DAY",
")",
";",
"sum",
"+=",
"dehumanizeUnit",
"(",
"matcher",
".",
"group",
"(",
"3",
")",
",",
"MS_HOUR",
")",
";",
"sum",
"+=",
"dehumanizeUnit",
"(",
"matcher",
".",
"group",
"(",
"4",
")",
",",
"MS_MINUTE",
")",
";",
"sum",
"+=",
"dehumanizeUnit",
"(",
"matcher",
".",
"group",
"(",
"5",
")",
",",
"MS_SECOND",
")",
";",
"sum",
"+=",
"dehumanizeUnit",
"(",
"matcher",
".",
"group",
"(",
"6",
")",
",",
"MS_MILLISECOND",
")",
";",
"result",
"=",
"sum",
";",
"}",
"}",
"getHumantimeCache",
"(",
")",
".",
"put",
"(",
"time",
",",
"result",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
] | Converts a human readable duration in the format "Xd Xh Xm Xs Xms" to miliseconds. | [
"Converts",
"a",
"human",
"readable",
"duration",
"in",
"the",
"format",
"Xd",
"Xh",
"Xm",
"Xs",
"Xms",
"to",
"miliseconds",
"."
] | 45d2f36c69958d3f847e5fed66603ea629471822 | https://github.com/galan/commons/blob/45d2f36c69958d3f847e5fed66603ea629471822/src/main/java/de/galan/commons/time/Durations.java#L116-L141 |
143,315 | TimeAndSpaceIO/SmoothieMap | src/main/java/net/openhft/smoothie/SmoothieMap.java | SmoothieMap.computeIfPresent | @Override
public final V computeIfPresent(
K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
if (remappingFunction == null)
throw new NullPointerException();
long hash;
return segment(segmentIndex(hash = keyHashCode(key)))
.computeIfPresent(this, hash, key, remappingFunction);
} | java | @Override
public final V computeIfPresent(
K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
if (remappingFunction == null)
throw new NullPointerException();
long hash;
return segment(segmentIndex(hash = keyHashCode(key)))
.computeIfPresent(this, hash, key, remappingFunction);
} | [
"@",
"Override",
"public",
"final",
"V",
"computeIfPresent",
"(",
"K",
"key",
",",
"BiFunction",
"<",
"?",
"super",
"K",
",",
"?",
"super",
"V",
",",
"?",
"extends",
"V",
">",
"remappingFunction",
")",
"{",
"if",
"(",
"remappingFunction",
"==",
"null",
")",
"throw",
"new",
"NullPointerException",
"(",
")",
";",
"long",
"hash",
";",
"return",
"segment",
"(",
"segmentIndex",
"(",
"hash",
"=",
"keyHashCode",
"(",
"key",
")",
")",
")",
".",
"computeIfPresent",
"(",
"this",
",",
"hash",
",",
"key",
",",
"remappingFunction",
")",
";",
"}"
] | If the value for the specified key is present and non-null, attempts to compute a new mapping
given the key and its current mapped value.
<p>If the function returns {@code null}, the mapping is removed. If the function itself
throws an (unchecked) exception, the exception is rethrown, and the current mapping is left
unchanged.
@param key key with which the specified value is to be associated
@param remappingFunction the function to compute a value
@return the new value associated with the specified key, or null if none
@throws NullPointerException if the remappingFunction is null | [
"If",
"the",
"value",
"for",
"the",
"specified",
"key",
"is",
"present",
"and",
"non",
"-",
"null",
"attempts",
"to",
"compute",
"a",
"new",
"mapping",
"given",
"the",
"key",
"and",
"its",
"current",
"mapped",
"value",
"."
] | c798f6cae1d377f6913e8821a1fcf5bf45ee0412 | https://github.com/TimeAndSpaceIO/SmoothieMap/blob/c798f6cae1d377f6913e8821a1fcf5bf45ee0412/src/main/java/net/openhft/smoothie/SmoothieMap.java#L927-L935 |
143,316 | TimeAndSpaceIO/SmoothieMap | src/main/java/net/openhft/smoothie/SmoothieMap.java | SmoothieMap.nextSegmentIndex | private long nextSegmentIndex(long segmentIndex, Segment segment) {
long segmentsTier = this.segmentsTier;
segmentIndex <<= -segmentsTier;
segmentIndex = Long.reverse(segmentIndex);
int numberOfArrayIndexesWithThisSegment = 1 << (segmentsTier - segment.tier);
segmentIndex += numberOfArrayIndexesWithThisSegment;
if (segmentIndex > segmentsMask)
return -1;
segmentIndex = Long.reverse(segmentIndex);
segmentIndex >>>= -segmentsTier;
return segmentIndex;
} | java | private long nextSegmentIndex(long segmentIndex, Segment segment) {
long segmentsTier = this.segmentsTier;
segmentIndex <<= -segmentsTier;
segmentIndex = Long.reverse(segmentIndex);
int numberOfArrayIndexesWithThisSegment = 1 << (segmentsTier - segment.tier);
segmentIndex += numberOfArrayIndexesWithThisSegment;
if (segmentIndex > segmentsMask)
return -1;
segmentIndex = Long.reverse(segmentIndex);
segmentIndex >>>= -segmentsTier;
return segmentIndex;
} | [
"private",
"long",
"nextSegmentIndex",
"(",
"long",
"segmentIndex",
",",
"Segment",
"segment",
")",
"{",
"long",
"segmentsTier",
"=",
"this",
".",
"segmentsTier",
";",
"segmentIndex",
"<<=",
"-",
"segmentsTier",
";",
"segmentIndex",
"=",
"Long",
".",
"reverse",
"(",
"segmentIndex",
")",
";",
"int",
"numberOfArrayIndexesWithThisSegment",
"=",
"1",
"<<",
"(",
"segmentsTier",
"-",
"segment",
".",
"tier",
")",
";",
"segmentIndex",
"+=",
"numberOfArrayIndexesWithThisSegment",
";",
"if",
"(",
"segmentIndex",
">",
"segmentsMask",
")",
"return",
"-",
"1",
";",
"segmentIndex",
"=",
"Long",
".",
"reverse",
"(",
"segmentIndex",
")",
";",
"segmentIndex",
">>>=",
"-",
"segmentsTier",
";",
"return",
"segmentIndex",
";",
"}"
] | Extension rules make order of iteration of segments a little weird, avoiding visiting
the same segment twice
<p>Geven segmentsMask = 0b1111, iterates segments in order:
0000
1000
0100
1100
0010
.. etc, i. e. grows "from left to right"
<p>In all lines above - +1 increment, that might be +2, +4 or higher, depending on how much
segment's tier is smaller than current map tier. | [
"Extension",
"rules",
"make",
"order",
"of",
"iteration",
"of",
"segments",
"a",
"little",
"weird",
"avoiding",
"visiting",
"the",
"same",
"segment",
"twice"
] | c798f6cae1d377f6913e8821a1fcf5bf45ee0412 | https://github.com/TimeAndSpaceIO/SmoothieMap/blob/c798f6cae1d377f6913e8821a1fcf5bf45ee0412/src/main/java/net/openhft/smoothie/SmoothieMap.java#L1015-L1026 |
143,317 | TimeAndSpaceIO/SmoothieMap | src/main/java/net/openhft/smoothie/SmoothieMap.java | SmoothieMap.replaceAll | @Override
public final void replaceAll(BiFunction<? super K, ? super V, ? extends V> function) {
Objects.requireNonNull(function);
int mc = this.modCount;
Segment<K, V> segment;
for (long segmentIndex = 0; segmentIndex >= 0;
segmentIndex = nextSegmentIndex(segmentIndex, segment)) {
(segment = segment(segmentIndex)).replaceAll(function);
}
if (mc != modCount)
throw new ConcurrentModificationException();
} | java | @Override
public final void replaceAll(BiFunction<? super K, ? super V, ? extends V> function) {
Objects.requireNonNull(function);
int mc = this.modCount;
Segment<K, V> segment;
for (long segmentIndex = 0; segmentIndex >= 0;
segmentIndex = nextSegmentIndex(segmentIndex, segment)) {
(segment = segment(segmentIndex)).replaceAll(function);
}
if (mc != modCount)
throw new ConcurrentModificationException();
} | [
"@",
"Override",
"public",
"final",
"void",
"replaceAll",
"(",
"BiFunction",
"<",
"?",
"super",
"K",
",",
"?",
"super",
"V",
",",
"?",
"extends",
"V",
">",
"function",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"function",
")",
";",
"int",
"mc",
"=",
"this",
".",
"modCount",
";",
"Segment",
"<",
"K",
",",
"V",
">",
"segment",
";",
"for",
"(",
"long",
"segmentIndex",
"=",
"0",
";",
"segmentIndex",
">=",
"0",
";",
"segmentIndex",
"=",
"nextSegmentIndex",
"(",
"segmentIndex",
",",
"segment",
")",
")",
"{",
"(",
"segment",
"=",
"segment",
"(",
"segmentIndex",
")",
")",
".",
"replaceAll",
"(",
"function",
")",
";",
"}",
"if",
"(",
"mc",
"!=",
"modCount",
")",
"throw",
"new",
"ConcurrentModificationException",
"(",
")",
";",
"}"
] | Replaces each entry's value with the result of invoking the given function on that entry
until all entries have been processed or the function throws an exception. Exceptions thrown
by the function are relayed to the caller.
@param function the function to apply to each entry
@throws NullPointerException if the specified function is null
@throws ConcurrentModificationException if any structural modification of the map (new entry
insertion or an entry removal) is detected during iteration | [
"Replaces",
"each",
"entry",
"s",
"value",
"with",
"the",
"result",
"of",
"invoking",
"the",
"given",
"function",
"on",
"that",
"entry",
"until",
"all",
"entries",
"have",
"been",
"processed",
"or",
"the",
"function",
"throws",
"an",
"exception",
".",
"Exceptions",
"thrown",
"by",
"the",
"function",
"are",
"relayed",
"to",
"the",
"caller",
"."
] | c798f6cae1d377f6913e8821a1fcf5bf45ee0412 | https://github.com/TimeAndSpaceIO/SmoothieMap/blob/c798f6cae1d377f6913e8821a1fcf5bf45ee0412/src/main/java/net/openhft/smoothie/SmoothieMap.java#L1107-L1118 |
143,318 | TimeAndSpaceIO/SmoothieMap | src/main/java/net/openhft/smoothie/SmoothieMap.java | SmoothieMap.removeIf | public final boolean removeIf(BiPredicate<? super K, ? super V> filter) {
Objects.requireNonNull(filter);
if (isEmpty())
return false;
Segment<K, V> segment;
int mc = this.modCount;
int initialModCount = mc;
for (long segmentIndex = 0; segmentIndex >= 0;
segmentIndex = nextSegmentIndex(segmentIndex, segment)) {
mc = (segment = segment(segmentIndex)).removeIf(this, filter, mc);
}
if (mc != modCount)
throw new ConcurrentModificationException();
return mc != initialModCount;
} | java | public final boolean removeIf(BiPredicate<? super K, ? super V> filter) {
Objects.requireNonNull(filter);
if (isEmpty())
return false;
Segment<K, V> segment;
int mc = this.modCount;
int initialModCount = mc;
for (long segmentIndex = 0; segmentIndex >= 0;
segmentIndex = nextSegmentIndex(segmentIndex, segment)) {
mc = (segment = segment(segmentIndex)).removeIf(this, filter, mc);
}
if (mc != modCount)
throw new ConcurrentModificationException();
return mc != initialModCount;
} | [
"public",
"final",
"boolean",
"removeIf",
"(",
"BiPredicate",
"<",
"?",
"super",
"K",
",",
"?",
"super",
"V",
">",
"filter",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"filter",
")",
";",
"if",
"(",
"isEmpty",
"(",
")",
")",
"return",
"false",
";",
"Segment",
"<",
"K",
",",
"V",
">",
"segment",
";",
"int",
"mc",
"=",
"this",
".",
"modCount",
";",
"int",
"initialModCount",
"=",
"mc",
";",
"for",
"(",
"long",
"segmentIndex",
"=",
"0",
";",
"segmentIndex",
">=",
"0",
";",
"segmentIndex",
"=",
"nextSegmentIndex",
"(",
"segmentIndex",
",",
"segment",
")",
")",
"{",
"mc",
"=",
"(",
"segment",
"=",
"segment",
"(",
"segmentIndex",
")",
")",
".",
"removeIf",
"(",
"this",
",",
"filter",
",",
"mc",
")",
";",
"}",
"if",
"(",
"mc",
"!=",
"modCount",
")",
"throw",
"new",
"ConcurrentModificationException",
"(",
")",
";",
"return",
"mc",
"!=",
"initialModCount",
";",
"}"
] | Removes all of the entries of this map that satisfy the given predicate. Errors or runtime
exceptions thrown during iteration or by the predicate are relayed to the caller.
<p>Note the order in which this method visits entries is <i>different</i> from the iteration
and {@link #forEach(BiConsumer)} order.
@param filter a predicate which returns {@code true} for entries to be removed
@return {@code true} if any entries were removed
@throws NullPointerException if the specified {@code filter} is {@code null}
@throws ConcurrentModificationException if any structural modification of the map (new entry
insertion or an entry removal) is detected during iteration | [
"Removes",
"all",
"of",
"the",
"entries",
"of",
"this",
"map",
"that",
"satisfy",
"the",
"given",
"predicate",
".",
"Errors",
"or",
"runtime",
"exceptions",
"thrown",
"during",
"iteration",
"or",
"by",
"the",
"predicate",
"are",
"relayed",
"to",
"the",
"caller",
"."
] | c798f6cae1d377f6913e8821a1fcf5bf45ee0412 | https://github.com/TimeAndSpaceIO/SmoothieMap/blob/c798f6cae1d377f6913e8821a1fcf5bf45ee0412/src/main/java/net/openhft/smoothie/SmoothieMap.java#L1274-L1288 |
143,319 | amilcar-sr/JustifiedTextView | library/src/main/java/com/codesgood/views/JustifiedTextView.java | JustifiedTextView.getJustifiedText | private String getJustifiedText(String text) {
String[] words = text.split(NORMAL_SPACE);
for (String word : words) {
boolean containsNewLine = (word.contains("\n") || word.contains("\r"));
if (fitsInSentence(word, currentSentence, true)) {
addWord(word, containsNewLine);
} else {
sentences.add(fillSentenceWithSpaces(currentSentence));
currentSentence.clear();
addWord(word, containsNewLine);
}
}
//Making sure we add the last sentence if needed.
if (currentSentence.size() > 0) {
sentences.add(getSentenceFromList(currentSentence, true));
}
//Returns the justified text.
return getSentenceFromList(sentences, false);
} | java | private String getJustifiedText(String text) {
String[] words = text.split(NORMAL_SPACE);
for (String word : words) {
boolean containsNewLine = (word.contains("\n") || word.contains("\r"));
if (fitsInSentence(word, currentSentence, true)) {
addWord(word, containsNewLine);
} else {
sentences.add(fillSentenceWithSpaces(currentSentence));
currentSentence.clear();
addWord(word, containsNewLine);
}
}
//Making sure we add the last sentence if needed.
if (currentSentence.size() > 0) {
sentences.add(getSentenceFromList(currentSentence, true));
}
//Returns the justified text.
return getSentenceFromList(sentences, false);
} | [
"private",
"String",
"getJustifiedText",
"(",
"String",
"text",
")",
"{",
"String",
"[",
"]",
"words",
"=",
"text",
".",
"split",
"(",
"NORMAL_SPACE",
")",
";",
"for",
"(",
"String",
"word",
":",
"words",
")",
"{",
"boolean",
"containsNewLine",
"=",
"(",
"word",
".",
"contains",
"(",
"\"\\n\"",
")",
"||",
"word",
".",
"contains",
"(",
"\"\\r\"",
")",
")",
";",
"if",
"(",
"fitsInSentence",
"(",
"word",
",",
"currentSentence",
",",
"true",
")",
")",
"{",
"addWord",
"(",
"word",
",",
"containsNewLine",
")",
";",
"}",
"else",
"{",
"sentences",
".",
"add",
"(",
"fillSentenceWithSpaces",
"(",
"currentSentence",
")",
")",
";",
"currentSentence",
".",
"clear",
"(",
")",
";",
"addWord",
"(",
"word",
",",
"containsNewLine",
")",
";",
"}",
"}",
"//Making sure we add the last sentence if needed.",
"if",
"(",
"currentSentence",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"sentences",
".",
"add",
"(",
"getSentenceFromList",
"(",
"currentSentence",
",",
"true",
")",
")",
";",
"}",
"//Returns the justified text.",
"return",
"getSentenceFromList",
"(",
"sentences",
",",
"false",
")",
";",
"}"
] | Retrieves a String with appropriate spaces to justify the text in the TextView.
@param text Text to be justified
@return Justified text | [
"Retrieves",
"a",
"String",
"with",
"appropriate",
"spaces",
"to",
"justify",
"the",
"text",
"in",
"the",
"TextView",
"."
] | 8fd91b4cfb225f973096519eae8295c3d7e8d49f | https://github.com/amilcar-sr/JustifiedTextView/blob/8fd91b4cfb225f973096519eae8295c3d7e8d49f/library/src/main/java/com/codesgood/views/JustifiedTextView.java#L106-L128 |
143,320 | amilcar-sr/JustifiedTextView | library/src/main/java/com/codesgood/views/JustifiedTextView.java | JustifiedTextView.addWord | private void addWord(String word, boolean containsNewLine) {
currentSentence.add(word);
if (containsNewLine) {
sentences.add(getSentenceFromListCheckingNewLines(currentSentence));
currentSentence.clear();
}
} | java | private void addWord(String word, boolean containsNewLine) {
currentSentence.add(word);
if (containsNewLine) {
sentences.add(getSentenceFromListCheckingNewLines(currentSentence));
currentSentence.clear();
}
} | [
"private",
"void",
"addWord",
"(",
"String",
"word",
",",
"boolean",
"containsNewLine",
")",
"{",
"currentSentence",
".",
"add",
"(",
"word",
")",
";",
"if",
"(",
"containsNewLine",
")",
"{",
"sentences",
".",
"add",
"(",
"getSentenceFromListCheckingNewLines",
"(",
"currentSentence",
")",
")",
";",
"currentSentence",
".",
"clear",
"(",
")",
";",
"}",
"}"
] | Adds a word into sentence and starts a new one if "new line" is part of the string.
@param word Word to be added
@param containsNewLine Specifies if the string contains a new line | [
"Adds",
"a",
"word",
"into",
"sentence",
"and",
"starts",
"a",
"new",
"one",
"if",
"new",
"line",
"is",
"part",
"of",
"the",
"string",
"."
] | 8fd91b4cfb225f973096519eae8295c3d7e8d49f | https://github.com/amilcar-sr/JustifiedTextView/blob/8fd91b4cfb225f973096519eae8295c3d7e8d49f/library/src/main/java/com/codesgood/views/JustifiedTextView.java#L136-L142 |
143,321 | amilcar-sr/JustifiedTextView | library/src/main/java/com/codesgood/views/JustifiedTextView.java | JustifiedTextView.getSentenceFromList | private String getSentenceFromList(List<String> strings, boolean addSpaces) {
StringBuilder stringBuilder = new StringBuilder();
for (String string : strings) {
stringBuilder.append(string);
if (addSpaces) {
stringBuilder.append(NORMAL_SPACE);
}
}
return stringBuilder.toString();
} | java | private String getSentenceFromList(List<String> strings, boolean addSpaces) {
StringBuilder stringBuilder = new StringBuilder();
for (String string : strings) {
stringBuilder.append(string);
if (addSpaces) {
stringBuilder.append(NORMAL_SPACE);
}
}
return stringBuilder.toString();
} | [
"private",
"String",
"getSentenceFromList",
"(",
"List",
"<",
"String",
">",
"strings",
",",
"boolean",
"addSpaces",
")",
"{",
"StringBuilder",
"stringBuilder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"String",
"string",
":",
"strings",
")",
"{",
"stringBuilder",
".",
"append",
"(",
"string",
")",
";",
"if",
"(",
"addSpaces",
")",
"{",
"stringBuilder",
".",
"append",
"(",
"NORMAL_SPACE",
")",
";",
"}",
"}",
"return",
"stringBuilder",
".",
"toString",
"(",
")",
";",
"}"
] | Creates a string using the words in the list and adds spaces between words if required.
@param strings Strings to be merged into one
@param addSpaces Specifies if the method should add spaces between words.
@return Returns a sentence using the words in the list. | [
"Creates",
"a",
"string",
"using",
"the",
"words",
"in",
"the",
"list",
"and",
"adds",
"spaces",
"between",
"words",
"if",
"required",
"."
] | 8fd91b4cfb225f973096519eae8295c3d7e8d49f | https://github.com/amilcar-sr/JustifiedTextView/blob/8fd91b4cfb225f973096519eae8295c3d7e8d49f/library/src/main/java/com/codesgood/views/JustifiedTextView.java#L151-L163 |
143,322 | amilcar-sr/JustifiedTextView | library/src/main/java/com/codesgood/views/JustifiedTextView.java | JustifiedTextView.getSentenceFromListCheckingNewLines | private String getSentenceFromListCheckingNewLines(List<String> strings) {
StringBuilder stringBuilder = new StringBuilder();
for (String string : strings) {
stringBuilder.append(string);
//We don't want to add a space next to the word if this one contains a new line character
if (!string.contains("\n") && !string.contains("\r")) {
stringBuilder.append(NORMAL_SPACE);
}
}
return stringBuilder.toString();
} | java | private String getSentenceFromListCheckingNewLines(List<String> strings) {
StringBuilder stringBuilder = new StringBuilder();
for (String string : strings) {
stringBuilder.append(string);
//We don't want to add a space next to the word if this one contains a new line character
if (!string.contains("\n") && !string.contains("\r")) {
stringBuilder.append(NORMAL_SPACE);
}
}
return stringBuilder.toString();
} | [
"private",
"String",
"getSentenceFromListCheckingNewLines",
"(",
"List",
"<",
"String",
">",
"strings",
")",
"{",
"StringBuilder",
"stringBuilder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"String",
"string",
":",
"strings",
")",
"{",
"stringBuilder",
".",
"append",
"(",
"string",
")",
";",
"//We don't want to add a space next to the word if this one contains a new line character",
"if",
"(",
"!",
"string",
".",
"contains",
"(",
"\"\\n\"",
")",
"&&",
"!",
"string",
".",
"contains",
"(",
"\"\\r\"",
")",
")",
"{",
"stringBuilder",
".",
"append",
"(",
"NORMAL_SPACE",
")",
";",
"}",
"}",
"return",
"stringBuilder",
".",
"toString",
"(",
")",
";",
"}"
] | Creates a string using the words in the list and adds spaces between words taking new lines
in consideration.
@param strings Strings to be merged into one
@return Returns a sentence using the words in the list. | [
"Creates",
"a",
"string",
"using",
"the",
"words",
"in",
"the",
"list",
"and",
"adds",
"spaces",
"between",
"words",
"taking",
"new",
"lines",
"in",
"consideration",
"."
] | 8fd91b4cfb225f973096519eae8295c3d7e8d49f | https://github.com/amilcar-sr/JustifiedTextView/blob/8fd91b4cfb225f973096519eae8295c3d7e8d49f/library/src/main/java/com/codesgood/views/JustifiedTextView.java#L172-L185 |
143,323 | amilcar-sr/JustifiedTextView | library/src/main/java/com/codesgood/views/JustifiedTextView.java | JustifiedTextView.fillSentenceWithSpaces | private String fillSentenceWithSpaces(List<String> sentence) {
sentenceWithSpaces.clear();
//We don't need to do this process if the sentence received is a single word.
if (sentence.size() > 1) {
//We fill with normal spaces first, we can do this with confidence because "fitsInSentence"
//already takes these spaces into account.
for (String word : sentence) {
sentenceWithSpaces.add(word);
sentenceWithSpaces.add(NORMAL_SPACE);
}
//Filling sentence with thin spaces.
while (fitsInSentence(HAIR_SPACE, sentenceWithSpaces, false)) {
//We remove 2 from the sentence size because we need to make sure we are not adding
//spaces to the end of the line.
sentenceWithSpaces.add(getRandomNumber(sentenceWithSpaces.size() - 2), HAIR_SPACE);
}
}
return getSentenceFromList(sentenceWithSpaces, false);
} | java | private String fillSentenceWithSpaces(List<String> sentence) {
sentenceWithSpaces.clear();
//We don't need to do this process if the sentence received is a single word.
if (sentence.size() > 1) {
//We fill with normal spaces first, we can do this with confidence because "fitsInSentence"
//already takes these spaces into account.
for (String word : sentence) {
sentenceWithSpaces.add(word);
sentenceWithSpaces.add(NORMAL_SPACE);
}
//Filling sentence with thin spaces.
while (fitsInSentence(HAIR_SPACE, sentenceWithSpaces, false)) {
//We remove 2 from the sentence size because we need to make sure we are not adding
//spaces to the end of the line.
sentenceWithSpaces.add(getRandomNumber(sentenceWithSpaces.size() - 2), HAIR_SPACE);
}
}
return getSentenceFromList(sentenceWithSpaces, false);
} | [
"private",
"String",
"fillSentenceWithSpaces",
"(",
"List",
"<",
"String",
">",
"sentence",
")",
"{",
"sentenceWithSpaces",
".",
"clear",
"(",
")",
";",
"//We don't need to do this process if the sentence received is a single word.",
"if",
"(",
"sentence",
".",
"size",
"(",
")",
">",
"1",
")",
"{",
"//We fill with normal spaces first, we can do this with confidence because \"fitsInSentence\"",
"//already takes these spaces into account.",
"for",
"(",
"String",
"word",
":",
"sentence",
")",
"{",
"sentenceWithSpaces",
".",
"add",
"(",
"word",
")",
";",
"sentenceWithSpaces",
".",
"add",
"(",
"NORMAL_SPACE",
")",
";",
"}",
"//Filling sentence with thin spaces.",
"while",
"(",
"fitsInSentence",
"(",
"HAIR_SPACE",
",",
"sentenceWithSpaces",
",",
"false",
")",
")",
"{",
"//We remove 2 from the sentence size because we need to make sure we are not adding",
"//spaces to the end of the line.",
"sentenceWithSpaces",
".",
"add",
"(",
"getRandomNumber",
"(",
"sentenceWithSpaces",
".",
"size",
"(",
")",
"-",
"2",
")",
",",
"HAIR_SPACE",
")",
";",
"}",
"}",
"return",
"getSentenceFromList",
"(",
"sentenceWithSpaces",
",",
"false",
")",
";",
"}"
] | Fills sentence with appropriate amount of spaces.
@param sentence Sentence we'll use to build the sentence with additional spaces
@return String with spaces. | [
"Fills",
"sentence",
"with",
"appropriate",
"amount",
"of",
"spaces",
"."
] | 8fd91b4cfb225f973096519eae8295c3d7e8d49f | https://github.com/amilcar-sr/JustifiedTextView/blob/8fd91b4cfb225f973096519eae8295c3d7e8d49f/library/src/main/java/com/codesgood/views/JustifiedTextView.java#L193-L214 |
143,324 | amilcar-sr/JustifiedTextView | library/src/main/java/com/codesgood/views/JustifiedTextView.java | JustifiedTextView.fitsInSentence | private boolean fitsInSentence(String word, List<String> sentence, boolean addSpaces) {
String stringSentence = getSentenceFromList(sentence, addSpaces);
stringSentence += word;
float sentenceWidth = getPaint().measureText(stringSentence);
return sentenceWidth < viewWidth;
} | java | private boolean fitsInSentence(String word, List<String> sentence, boolean addSpaces) {
String stringSentence = getSentenceFromList(sentence, addSpaces);
stringSentence += word;
float sentenceWidth = getPaint().measureText(stringSentence);
return sentenceWidth < viewWidth;
} | [
"private",
"boolean",
"fitsInSentence",
"(",
"String",
"word",
",",
"List",
"<",
"String",
">",
"sentence",
",",
"boolean",
"addSpaces",
")",
"{",
"String",
"stringSentence",
"=",
"getSentenceFromList",
"(",
"sentence",
",",
"addSpaces",
")",
";",
"stringSentence",
"+=",
"word",
";",
"float",
"sentenceWidth",
"=",
"getPaint",
"(",
")",
".",
"measureText",
"(",
"stringSentence",
")",
";",
"return",
"sentenceWidth",
"<",
"viewWidth",
";",
"}"
] | Verifies if word to be added will fit into the sentence
@param word Word to be added
@param sentence Sentence that will receive the new word
@param addSpaces Specifies weather we should add spaces to validation or not
@return True if word fits, false otherwise. | [
"Verifies",
"if",
"word",
"to",
"be",
"added",
"will",
"fit",
"into",
"the",
"sentence"
] | 8fd91b4cfb225f973096519eae8295c3d7e8d49f | https://github.com/amilcar-sr/JustifiedTextView/blob/8fd91b4cfb225f973096519eae8295c3d7e8d49f/library/src/main/java/com/codesgood/views/JustifiedTextView.java#L224-L231 |
143,325 | realityforge/gwt-appcache | linker/src/main/java/org/realityforge/gwt/appcache/linker/AppcacheLinker.java | AppcacheLinker.writeManifest | @Nonnull
final String writeManifest( @Nonnull final TreeLogger logger,
@Nonnull final Set<String> staticResources,
@Nonnull final Map<String, String> fallbackResources,
@Nonnull final Set<String> cacheResources )
throws UnableToCompleteException
{
final ManifestDescriptor descriptor = new ManifestDescriptor();
final List<String> cachedResources =
Stream
.concat( staticResources.stream(), cacheResources.stream() )
.sorted()
.distinct()
.collect( Collectors.toList() );
descriptor.getCachedResources().addAll( cachedResources );
descriptor.getFallbackResources().putAll( fallbackResources );
descriptor.getNetworkResources().add( "*" );
try
{
return descriptor.toString();
}
catch ( final Exception e )
{
logger.log( Type.ERROR, "Error generating manifest: " + e, e );
throw new UnableToCompleteException();
}
} | java | @Nonnull
final String writeManifest( @Nonnull final TreeLogger logger,
@Nonnull final Set<String> staticResources,
@Nonnull final Map<String, String> fallbackResources,
@Nonnull final Set<String> cacheResources )
throws UnableToCompleteException
{
final ManifestDescriptor descriptor = new ManifestDescriptor();
final List<String> cachedResources =
Stream
.concat( staticResources.stream(), cacheResources.stream() )
.sorted()
.distinct()
.collect( Collectors.toList() );
descriptor.getCachedResources().addAll( cachedResources );
descriptor.getFallbackResources().putAll( fallbackResources );
descriptor.getNetworkResources().add( "*" );
try
{
return descriptor.toString();
}
catch ( final Exception e )
{
logger.log( Type.ERROR, "Error generating manifest: " + e, e );
throw new UnableToCompleteException();
}
} | [
"@",
"Nonnull",
"final",
"String",
"writeManifest",
"(",
"@",
"Nonnull",
"final",
"TreeLogger",
"logger",
",",
"@",
"Nonnull",
"final",
"Set",
"<",
"String",
">",
"staticResources",
",",
"@",
"Nonnull",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"fallbackResources",
",",
"@",
"Nonnull",
"final",
"Set",
"<",
"String",
">",
"cacheResources",
")",
"throws",
"UnableToCompleteException",
"{",
"final",
"ManifestDescriptor",
"descriptor",
"=",
"new",
"ManifestDescriptor",
"(",
")",
";",
"final",
"List",
"<",
"String",
">",
"cachedResources",
"=",
"Stream",
".",
"concat",
"(",
"staticResources",
".",
"stream",
"(",
")",
",",
"cacheResources",
".",
"stream",
"(",
")",
")",
".",
"sorted",
"(",
")",
".",
"distinct",
"(",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"descriptor",
".",
"getCachedResources",
"(",
")",
".",
"addAll",
"(",
"cachedResources",
")",
";",
"descriptor",
".",
"getFallbackResources",
"(",
")",
".",
"putAll",
"(",
"fallbackResources",
")",
";",
"descriptor",
".",
"getNetworkResources",
"(",
")",
".",
"add",
"(",
"\"*\"",
")",
";",
"try",
"{",
"return",
"descriptor",
".",
"toString",
"(",
")",
";",
"}",
"catch",
"(",
"final",
"Exception",
"e",
")",
"{",
"logger",
".",
"log",
"(",
"Type",
".",
"ERROR",
",",
"\"Error generating manifest: \"",
"+",
"e",
",",
"e",
")",
";",
"throw",
"new",
"UnableToCompleteException",
"(",
")",
";",
"}",
"}"
] | Write a manifest file for the given set of artifacts and return it as a
string
@param staticResources - the static resources of the app, such as
index.html file
@param fallbackResources the fall back files to add to the manifest.
@param cacheResources the gwt output artifacts like cache.html files
@return the manifest as a string | [
"Write",
"a",
"manifest",
"file",
"for",
"the",
"given",
"set",
"of",
"artifacts",
"and",
"return",
"it",
"as",
"a",
"string"
] | e22a5ae20b6fd4b5d0d6cfb5fdfd7b68b03a5519 | https://github.com/realityforge/gwt-appcache/blob/e22a5ae20b6fd4b5d0d6cfb5fdfd7b68b03a5519/linker/src/main/java/org/realityforge/gwt/appcache/linker/AppcacheLinker.java#L197-L223 |
143,326 | realityforge/gwt-appcache | linker/src/main/java/org/realityforge/gwt/appcache/linker/AppcacheLinker.java | AppcacheLinker.calculatePermutation | @Nullable
final Permutation calculatePermutation( @Nonnull final TreeLogger logger,
@Nonnull final LinkerContext context,
@Nonnull final ArtifactSet artifacts )
throws UnableToCompleteException
{
Permutation permutation = null;
for ( final SelectionInformation result : artifacts.find( SelectionInformation.class ) )
{
final String strongName = result.getStrongName();
if ( null != permutation && !permutation.getPermutationName().equals( strongName ) )
{
throw new UnableToCompleteException();
}
if ( null == permutation )
{
permutation = new Permutation( strongName );
final Set<String> artifactsForCompilation = getArtifactsForCompilation( context, artifacts );
permutation.getPermutationFiles().addAll( artifactsForCompilation );
}
final List<BindingProperty> list = new ArrayList<>();
for ( final SelectionProperty property : context.getProperties() )
{
if ( !property.isDerived() )
{
final String name = property.getName();
final String value = result.getPropMap().get( name );
if ( null != value )
{
list.add( new BindingProperty( name, value ) );
}
}
}
final SelectionDescriptor selection = new SelectionDescriptor( strongName, list );
final List<SelectionDescriptor> selectors = permutation.getSelectors();
if ( !selectors.contains( selection ) )
{
selectors.add( selection );
}
}
if ( null != permutation )
{
logger.log( Type.DEBUG, "Calculated Permutation: " + permutation.getPermutationName() +
" Selectors: " + permutation.getSelectors() );
}
return permutation;
} | java | @Nullable
final Permutation calculatePermutation( @Nonnull final TreeLogger logger,
@Nonnull final LinkerContext context,
@Nonnull final ArtifactSet artifacts )
throws UnableToCompleteException
{
Permutation permutation = null;
for ( final SelectionInformation result : artifacts.find( SelectionInformation.class ) )
{
final String strongName = result.getStrongName();
if ( null != permutation && !permutation.getPermutationName().equals( strongName ) )
{
throw new UnableToCompleteException();
}
if ( null == permutation )
{
permutation = new Permutation( strongName );
final Set<String> artifactsForCompilation = getArtifactsForCompilation( context, artifacts );
permutation.getPermutationFiles().addAll( artifactsForCompilation );
}
final List<BindingProperty> list = new ArrayList<>();
for ( final SelectionProperty property : context.getProperties() )
{
if ( !property.isDerived() )
{
final String name = property.getName();
final String value = result.getPropMap().get( name );
if ( null != value )
{
list.add( new BindingProperty( name, value ) );
}
}
}
final SelectionDescriptor selection = new SelectionDescriptor( strongName, list );
final List<SelectionDescriptor> selectors = permutation.getSelectors();
if ( !selectors.contains( selection ) )
{
selectors.add( selection );
}
}
if ( null != permutation )
{
logger.log( Type.DEBUG, "Calculated Permutation: " + permutation.getPermutationName() +
" Selectors: " + permutation.getSelectors() );
}
return permutation;
} | [
"@",
"Nullable",
"final",
"Permutation",
"calculatePermutation",
"(",
"@",
"Nonnull",
"final",
"TreeLogger",
"logger",
",",
"@",
"Nonnull",
"final",
"LinkerContext",
"context",
",",
"@",
"Nonnull",
"final",
"ArtifactSet",
"artifacts",
")",
"throws",
"UnableToCompleteException",
"{",
"Permutation",
"permutation",
"=",
"null",
";",
"for",
"(",
"final",
"SelectionInformation",
"result",
":",
"artifacts",
".",
"find",
"(",
"SelectionInformation",
".",
"class",
")",
")",
"{",
"final",
"String",
"strongName",
"=",
"result",
".",
"getStrongName",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"permutation",
"&&",
"!",
"permutation",
".",
"getPermutationName",
"(",
")",
".",
"equals",
"(",
"strongName",
")",
")",
"{",
"throw",
"new",
"UnableToCompleteException",
"(",
")",
";",
"}",
"if",
"(",
"null",
"==",
"permutation",
")",
"{",
"permutation",
"=",
"new",
"Permutation",
"(",
"strongName",
")",
";",
"final",
"Set",
"<",
"String",
">",
"artifactsForCompilation",
"=",
"getArtifactsForCompilation",
"(",
"context",
",",
"artifacts",
")",
";",
"permutation",
".",
"getPermutationFiles",
"(",
")",
".",
"addAll",
"(",
"artifactsForCompilation",
")",
";",
"}",
"final",
"List",
"<",
"BindingProperty",
">",
"list",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"final",
"SelectionProperty",
"property",
":",
"context",
".",
"getProperties",
"(",
")",
")",
"{",
"if",
"(",
"!",
"property",
".",
"isDerived",
"(",
")",
")",
"{",
"final",
"String",
"name",
"=",
"property",
".",
"getName",
"(",
")",
";",
"final",
"String",
"value",
"=",
"result",
".",
"getPropMap",
"(",
")",
".",
"get",
"(",
"name",
")",
";",
"if",
"(",
"null",
"!=",
"value",
")",
"{",
"list",
".",
"add",
"(",
"new",
"BindingProperty",
"(",
"name",
",",
"value",
")",
")",
";",
"}",
"}",
"}",
"final",
"SelectionDescriptor",
"selection",
"=",
"new",
"SelectionDescriptor",
"(",
"strongName",
",",
"list",
")",
";",
"final",
"List",
"<",
"SelectionDescriptor",
">",
"selectors",
"=",
"permutation",
".",
"getSelectors",
"(",
")",
";",
"if",
"(",
"!",
"selectors",
".",
"contains",
"(",
"selection",
")",
")",
"{",
"selectors",
".",
"add",
"(",
"selection",
")",
";",
"}",
"}",
"if",
"(",
"null",
"!=",
"permutation",
")",
"{",
"logger",
".",
"log",
"(",
"Type",
".",
"DEBUG",
",",
"\"Calculated Permutation: \"",
"+",
"permutation",
".",
"getPermutationName",
"(",
")",
"+",
"\" Selectors: \"",
"+",
"permutation",
".",
"getSelectors",
"(",
")",
")",
";",
"}",
"return",
"permutation",
";",
"}"
] | Return the permutation for a single link step. | [
"Return",
"the",
"permutation",
"for",
"a",
"single",
"link",
"step",
"."
] | e22a5ae20b6fd4b5d0d6cfb5fdfd7b68b03a5519 | https://github.com/realityforge/gwt-appcache/blob/e22a5ae20b6fd4b5d0d6cfb5fdfd7b68b03a5519/linker/src/main/java/org/realityforge/gwt/appcache/linker/AppcacheLinker.java#L327-L374 |
143,327 | realityforge/gwt-appcache | server/src/main/java/org/realityforge/gwt/appcache/server/AbstractManifestServlet.java | AbstractManifestServlet.handleUnmatchedRequest | protected boolean handleUnmatchedRequest( final HttpServletRequest request,
final HttpServletResponse response,
final String moduleName,
final String baseUrl,
final List<BindingProperty> computedBindings )
throws ServletException, IOException
{
return false;
} | java | protected boolean handleUnmatchedRequest( final HttpServletRequest request,
final HttpServletResponse response,
final String moduleName,
final String baseUrl,
final List<BindingProperty> computedBindings )
throws ServletException, IOException
{
return false;
} | [
"protected",
"boolean",
"handleUnmatchedRequest",
"(",
"final",
"HttpServletRequest",
"request",
",",
"final",
"HttpServletResponse",
"response",
",",
"final",
"String",
"moduleName",
",",
"final",
"String",
"baseUrl",
",",
"final",
"List",
"<",
"BindingProperty",
">",
"computedBindings",
")",
"throws",
"ServletException",
",",
"IOException",
"{",
"return",
"false",
";",
"}"
] | Sub-classes can override this method to perform handle the inability to find a matching permutation. In which
case the method should return true if the response has been handled. | [
"Sub",
"-",
"classes",
"can",
"override",
"this",
"method",
"to",
"perform",
"handle",
"the",
"inability",
"to",
"find",
"a",
"matching",
"permutation",
".",
"In",
"which",
"case",
"the",
"method",
"should",
"return",
"true",
"if",
"the",
"response",
"has",
"been",
"handled",
"."
] | e22a5ae20b6fd4b5d0d6cfb5fdfd7b68b03a5519 | https://github.com/realityforge/gwt-appcache/blob/e22a5ae20b6fd4b5d0d6cfb5fdfd7b68b03a5519/server/src/main/java/org/realityforge/gwt/appcache/server/AbstractManifestServlet.java#L141-L149 |
143,328 | realityforge/gwt-appcache | server/src/main/java/org/realityforge/gwt/appcache/server/AbstractManifestServlet.java | AbstractManifestServlet.loadAndMergeManifests | protected final String loadAndMergeManifests( final String baseUrl,
final String moduleName,
final String... permutationNames )
throws ServletException
{
final String cacheKey = toCacheKey( baseUrl, moduleName, permutationNames );
if ( isCacheEnabled() )
{
final String manifest = _cache.get( cacheKey );
if ( null != manifest )
{
return manifest;
}
}
final ManifestDescriptor descriptor = new ManifestDescriptor();
for ( final String permutationName : permutationNames )
{
final String manifest = loadManifest( baseUrl, moduleName, permutationName );
final ManifestDescriptor other = ManifestDescriptor.parse( manifest );
descriptor.merge( other );
}
Collections.sort( descriptor.getCachedResources() );
Collections.sort( descriptor.getNetworkResources() );
final String manifest = descriptor.toString();
if ( isCacheEnabled() )
{
_cache.put( cacheKey, manifest );
}
return manifest;
} | java | protected final String loadAndMergeManifests( final String baseUrl,
final String moduleName,
final String... permutationNames )
throws ServletException
{
final String cacheKey = toCacheKey( baseUrl, moduleName, permutationNames );
if ( isCacheEnabled() )
{
final String manifest = _cache.get( cacheKey );
if ( null != manifest )
{
return manifest;
}
}
final ManifestDescriptor descriptor = new ManifestDescriptor();
for ( final String permutationName : permutationNames )
{
final String manifest = loadManifest( baseUrl, moduleName, permutationName );
final ManifestDescriptor other = ManifestDescriptor.parse( manifest );
descriptor.merge( other );
}
Collections.sort( descriptor.getCachedResources() );
Collections.sort( descriptor.getNetworkResources() );
final String manifest = descriptor.toString();
if ( isCacheEnabled() )
{
_cache.put( cacheKey, manifest );
}
return manifest;
} | [
"protected",
"final",
"String",
"loadAndMergeManifests",
"(",
"final",
"String",
"baseUrl",
",",
"final",
"String",
"moduleName",
",",
"final",
"String",
"...",
"permutationNames",
")",
"throws",
"ServletException",
"{",
"final",
"String",
"cacheKey",
"=",
"toCacheKey",
"(",
"baseUrl",
",",
"moduleName",
",",
"permutationNames",
")",
";",
"if",
"(",
"isCacheEnabled",
"(",
")",
")",
"{",
"final",
"String",
"manifest",
"=",
"_cache",
".",
"get",
"(",
"cacheKey",
")",
";",
"if",
"(",
"null",
"!=",
"manifest",
")",
"{",
"return",
"manifest",
";",
"}",
"}",
"final",
"ManifestDescriptor",
"descriptor",
"=",
"new",
"ManifestDescriptor",
"(",
")",
";",
"for",
"(",
"final",
"String",
"permutationName",
":",
"permutationNames",
")",
"{",
"final",
"String",
"manifest",
"=",
"loadManifest",
"(",
"baseUrl",
",",
"moduleName",
",",
"permutationName",
")",
";",
"final",
"ManifestDescriptor",
"other",
"=",
"ManifestDescriptor",
".",
"parse",
"(",
"manifest",
")",
";",
"descriptor",
".",
"merge",
"(",
"other",
")",
";",
"}",
"Collections",
".",
"sort",
"(",
"descriptor",
".",
"getCachedResources",
"(",
")",
")",
";",
"Collections",
".",
"sort",
"(",
"descriptor",
".",
"getNetworkResources",
"(",
")",
")",
";",
"final",
"String",
"manifest",
"=",
"descriptor",
".",
"toString",
"(",
")",
";",
"if",
"(",
"isCacheEnabled",
"(",
")",
")",
"{",
"_cache",
".",
"put",
"(",
"cacheKey",
",",
"manifest",
")",
";",
"}",
"return",
"manifest",
";",
"}"
] | Utility method that loads and merges the cache files for multiple permutations.
This is useful when it is not possible to determine the exact permutation required
for a client on the server. This defers the decision to the client but may result in
extra files being downloaded. | [
"Utility",
"method",
"that",
"loads",
"and",
"merges",
"the",
"cache",
"files",
"for",
"multiple",
"permutations",
".",
"This",
"is",
"useful",
"when",
"it",
"is",
"not",
"possible",
"to",
"determine",
"the",
"exact",
"permutation",
"required",
"for",
"a",
"client",
"on",
"the",
"server",
".",
"This",
"defers",
"the",
"decision",
"to",
"the",
"client",
"but",
"may",
"result",
"in",
"extra",
"files",
"being",
"downloaded",
"."
] | e22a5ae20b6fd4b5d0d6cfb5fdfd7b68b03a5519 | https://github.com/realityforge/gwt-appcache/blob/e22a5ae20b6fd4b5d0d6cfb5fdfd7b68b03a5519/server/src/main/java/org/realityforge/gwt/appcache/server/AbstractManifestServlet.java#L174-L204 |
143,329 | realityforge/gwt-appcache | server/src/main/java/org/realityforge/gwt/appcache/server/AbstractManifestServlet.java | AbstractManifestServlet.reduceToMatchingDescriptors | protected final void reduceToMatchingDescriptors( @Nonnull final List<BindingProperty> bindings,
@Nonnull final List<SelectionDescriptor> descriptors )
{
final Iterator<BindingProperty> iterator = bindings.iterator();
while ( iterator.hasNext() )
{
final BindingProperty property = iterator.next();
// Do any selectors match?
boolean matched = false;
for ( final SelectionDescriptor selection : descriptors )
{
final BindingProperty candidate =
findMatchingBindingProperty( selection.getBindingProperties(), property );
if ( null != candidate )
{
matched = true;
break;
}
}
if ( matched )
{
// if so we can remove binding property from candidates list
iterator.remove();
// and now remove any selections that don't match
final Iterator<SelectionDescriptor> selections = descriptors.iterator();
while ( selections.hasNext() )
{
final SelectionDescriptor selection = selections.next();
if ( null == findSatisfiesBindingProperty( selection.getBindingProperties(), property ) )
{
selections.remove();
}
}
}
}
} | java | protected final void reduceToMatchingDescriptors( @Nonnull final List<BindingProperty> bindings,
@Nonnull final List<SelectionDescriptor> descriptors )
{
final Iterator<BindingProperty> iterator = bindings.iterator();
while ( iterator.hasNext() )
{
final BindingProperty property = iterator.next();
// Do any selectors match?
boolean matched = false;
for ( final SelectionDescriptor selection : descriptors )
{
final BindingProperty candidate =
findMatchingBindingProperty( selection.getBindingProperties(), property );
if ( null != candidate )
{
matched = true;
break;
}
}
if ( matched )
{
// if so we can remove binding property from candidates list
iterator.remove();
// and now remove any selections that don't match
final Iterator<SelectionDescriptor> selections = descriptors.iterator();
while ( selections.hasNext() )
{
final SelectionDescriptor selection = selections.next();
if ( null == findSatisfiesBindingProperty( selection.getBindingProperties(), property ) )
{
selections.remove();
}
}
}
}
} | [
"protected",
"final",
"void",
"reduceToMatchingDescriptors",
"(",
"@",
"Nonnull",
"final",
"List",
"<",
"BindingProperty",
">",
"bindings",
",",
"@",
"Nonnull",
"final",
"List",
"<",
"SelectionDescriptor",
">",
"descriptors",
")",
"{",
"final",
"Iterator",
"<",
"BindingProperty",
">",
"iterator",
"=",
"bindings",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"iterator",
".",
"hasNext",
"(",
")",
")",
"{",
"final",
"BindingProperty",
"property",
"=",
"iterator",
".",
"next",
"(",
")",
";",
"// Do any selectors match?",
"boolean",
"matched",
"=",
"false",
";",
"for",
"(",
"final",
"SelectionDescriptor",
"selection",
":",
"descriptors",
")",
"{",
"final",
"BindingProperty",
"candidate",
"=",
"findMatchingBindingProperty",
"(",
"selection",
".",
"getBindingProperties",
"(",
")",
",",
"property",
")",
";",
"if",
"(",
"null",
"!=",
"candidate",
")",
"{",
"matched",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"matched",
")",
"{",
"// if so we can remove binding property from candidates list",
"iterator",
".",
"remove",
"(",
")",
";",
"// and now remove any selections that don't match",
"final",
"Iterator",
"<",
"SelectionDescriptor",
">",
"selections",
"=",
"descriptors",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"selections",
".",
"hasNext",
"(",
")",
")",
"{",
"final",
"SelectionDescriptor",
"selection",
"=",
"selections",
".",
"next",
"(",
")",
";",
"if",
"(",
"null",
"==",
"findSatisfiesBindingProperty",
"(",
"selection",
".",
"getBindingProperties",
"(",
")",
",",
"property",
")",
")",
"{",
"selections",
".",
"remove",
"(",
")",
";",
"}",
"}",
"}",
"}",
"}"
] | This method will restrict the list of descriptors so that it only contains selections valid for specified
bindings. Bindings will be removed from the list as they are matched. Unmatched bindings will remain in the
bindings list after the method completes. | [
"This",
"method",
"will",
"restrict",
"the",
"list",
"of",
"descriptors",
"so",
"that",
"it",
"only",
"contains",
"selections",
"valid",
"for",
"specified",
"bindings",
".",
"Bindings",
"will",
"be",
"removed",
"from",
"the",
"list",
"as",
"they",
"are",
"matched",
".",
"Unmatched",
"bindings",
"will",
"remain",
"in",
"the",
"bindings",
"list",
"after",
"the",
"method",
"completes",
"."
] | e22a5ae20b6fd4b5d0d6cfb5fdfd7b68b03a5519 | https://github.com/realityforge/gwt-appcache/blob/e22a5ae20b6fd4b5d0d6cfb5fdfd7b68b03a5519/server/src/main/java/org/realityforge/gwt/appcache/server/AbstractManifestServlet.java#L349-L386 |
143,330 | realityforge/gwt-appcache | server/src/main/java/org/realityforge/gwt/appcache/server/AbstractManifestServlet.java | AbstractManifestServlet.findMatchingBindingProperty | private BindingProperty findMatchingBindingProperty( final List<BindingProperty> bindings,
final BindingProperty requirement )
{
for ( final BindingProperty candidate : bindings )
{
if ( requirement.getName().equals( candidate.getName() ) )
{
return candidate;
}
}
return null;
} | java | private BindingProperty findMatchingBindingProperty( final List<BindingProperty> bindings,
final BindingProperty requirement )
{
for ( final BindingProperty candidate : bindings )
{
if ( requirement.getName().equals( candidate.getName() ) )
{
return candidate;
}
}
return null;
} | [
"private",
"BindingProperty",
"findMatchingBindingProperty",
"(",
"final",
"List",
"<",
"BindingProperty",
">",
"bindings",
",",
"final",
"BindingProperty",
"requirement",
")",
"{",
"for",
"(",
"final",
"BindingProperty",
"candidate",
":",
"bindings",
")",
"{",
"if",
"(",
"requirement",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"candidate",
".",
"getName",
"(",
")",
")",
")",
"{",
"return",
"candidate",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Return the binding property in the bindings list that matches specified requirement. | [
"Return",
"the",
"binding",
"property",
"in",
"the",
"bindings",
"list",
"that",
"matches",
"specified",
"requirement",
"."
] | e22a5ae20b6fd4b5d0d6cfb5fdfd7b68b03a5519 | https://github.com/realityforge/gwt-appcache/blob/e22a5ae20b6fd4b5d0d6cfb5fdfd7b68b03a5519/server/src/main/java/org/realityforge/gwt/appcache/server/AbstractManifestServlet.java#L391-L402 |
143,331 | realityforge/gwt-appcache | server/src/main/java/org/realityforge/gwt/appcache/server/AbstractManifestServlet.java | AbstractManifestServlet.findSatisfiesBindingProperty | private BindingProperty findSatisfiesBindingProperty( final List<BindingProperty> bindings,
final BindingProperty requirement )
{
final BindingProperty property = findMatchingBindingProperty( bindings, requirement );
if ( null != property && property.matches( requirement.getValue() ) )
{
return property;
}
return null;
} | java | private BindingProperty findSatisfiesBindingProperty( final List<BindingProperty> bindings,
final BindingProperty requirement )
{
final BindingProperty property = findMatchingBindingProperty( bindings, requirement );
if ( null != property && property.matches( requirement.getValue() ) )
{
return property;
}
return null;
} | [
"private",
"BindingProperty",
"findSatisfiesBindingProperty",
"(",
"final",
"List",
"<",
"BindingProperty",
">",
"bindings",
",",
"final",
"BindingProperty",
"requirement",
")",
"{",
"final",
"BindingProperty",
"property",
"=",
"findMatchingBindingProperty",
"(",
"bindings",
",",
"requirement",
")",
";",
"if",
"(",
"null",
"!=",
"property",
"&&",
"property",
".",
"matches",
"(",
"requirement",
".",
"getValue",
"(",
")",
")",
")",
"{",
"return",
"property",
";",
"}",
"return",
"null",
";",
"}"
] | Return the binding property in the bindings list that satisfies specified requirement. Satisfies means that
the property name matches and the value matches. | [
"Return",
"the",
"binding",
"property",
"in",
"the",
"bindings",
"list",
"that",
"satisfies",
"specified",
"requirement",
".",
"Satisfies",
"means",
"that",
"the",
"property",
"name",
"matches",
"and",
"the",
"value",
"matches",
"."
] | e22a5ae20b6fd4b5d0d6cfb5fdfd7b68b03a5519 | https://github.com/realityforge/gwt-appcache/blob/e22a5ae20b6fd4b5d0d6cfb5fdfd7b68b03a5519/server/src/main/java/org/realityforge/gwt/appcache/server/AbstractManifestServlet.java#L408-L417 |
143,332 | realityforge/gwt-appcache | server/src/main/java/org/realityforge/gwt/appcache/server/AbstractManifestServlet.java | AbstractManifestServlet.selectPermutations | protected final String[] selectPermutations( @Nonnull final String baseUrl,
@Nonnull final String moduleName,
@Nonnull final List<BindingProperty> computedBindings )
throws ServletException
{
try
{
final List<SelectionDescriptor> descriptors = new ArrayList<>();
descriptors.addAll( getPermutationDescriptors( baseUrl, moduleName ) );
final List<BindingProperty> bindings = new ArrayList<>();
bindings.addAll( computedBindings );
reduceToMatchingDescriptors( bindings, descriptors );
if ( 0 == bindings.size() )
{
if ( 1 == descriptors.size() )
{
return new String[]{ descriptors.get( 0 ).getPermutationName() };
}
else
{
final ArrayList<String> permutations = new ArrayList<>();
for ( final SelectionDescriptor descriptor : descriptors )
{
if ( descriptor.getBindingProperties().size() == computedBindings.size() )
{
permutations.add( descriptor.getPermutationName() );
}
else
{
for ( final BindingProperty property : descriptor.getBindingProperties() )
{
// This is one of the bindings that we could not reduce on
if ( null == findMatchingBindingProperty( computedBindings, property ) )
{
if ( canMergeManifestForSelectionProperty( property.getName() ) )
{
permutations.add( descriptor.getPermutationName() );
}
}
}
}
}
if ( 0 == permutations.size() )
{
return null;
}
else
{
return permutations.toArray( new String[ permutations.size() ] );
}
}
}
return null;
}
catch ( final Exception e )
{
throw new ServletException( "can not read permutation information", e );
}
} | java | protected final String[] selectPermutations( @Nonnull final String baseUrl,
@Nonnull final String moduleName,
@Nonnull final List<BindingProperty> computedBindings )
throws ServletException
{
try
{
final List<SelectionDescriptor> descriptors = new ArrayList<>();
descriptors.addAll( getPermutationDescriptors( baseUrl, moduleName ) );
final List<BindingProperty> bindings = new ArrayList<>();
bindings.addAll( computedBindings );
reduceToMatchingDescriptors( bindings, descriptors );
if ( 0 == bindings.size() )
{
if ( 1 == descriptors.size() )
{
return new String[]{ descriptors.get( 0 ).getPermutationName() };
}
else
{
final ArrayList<String> permutations = new ArrayList<>();
for ( final SelectionDescriptor descriptor : descriptors )
{
if ( descriptor.getBindingProperties().size() == computedBindings.size() )
{
permutations.add( descriptor.getPermutationName() );
}
else
{
for ( final BindingProperty property : descriptor.getBindingProperties() )
{
// This is one of the bindings that we could not reduce on
if ( null == findMatchingBindingProperty( computedBindings, property ) )
{
if ( canMergeManifestForSelectionProperty( property.getName() ) )
{
permutations.add( descriptor.getPermutationName() );
}
}
}
}
}
if ( 0 == permutations.size() )
{
return null;
}
else
{
return permutations.toArray( new String[ permutations.size() ] );
}
}
}
return null;
}
catch ( final Exception e )
{
throw new ServletException( "can not read permutation information", e );
}
} | [
"protected",
"final",
"String",
"[",
"]",
"selectPermutations",
"(",
"@",
"Nonnull",
"final",
"String",
"baseUrl",
",",
"@",
"Nonnull",
"final",
"String",
"moduleName",
",",
"@",
"Nonnull",
"final",
"List",
"<",
"BindingProperty",
">",
"computedBindings",
")",
"throws",
"ServletException",
"{",
"try",
"{",
"final",
"List",
"<",
"SelectionDescriptor",
">",
"descriptors",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"descriptors",
".",
"addAll",
"(",
"getPermutationDescriptors",
"(",
"baseUrl",
",",
"moduleName",
")",
")",
";",
"final",
"List",
"<",
"BindingProperty",
">",
"bindings",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"bindings",
".",
"addAll",
"(",
"computedBindings",
")",
";",
"reduceToMatchingDescriptors",
"(",
"bindings",
",",
"descriptors",
")",
";",
"if",
"(",
"0",
"==",
"bindings",
".",
"size",
"(",
")",
")",
"{",
"if",
"(",
"1",
"==",
"descriptors",
".",
"size",
"(",
")",
")",
"{",
"return",
"new",
"String",
"[",
"]",
"{",
"descriptors",
".",
"get",
"(",
"0",
")",
".",
"getPermutationName",
"(",
")",
"}",
";",
"}",
"else",
"{",
"final",
"ArrayList",
"<",
"String",
">",
"permutations",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"final",
"SelectionDescriptor",
"descriptor",
":",
"descriptors",
")",
"{",
"if",
"(",
"descriptor",
".",
"getBindingProperties",
"(",
")",
".",
"size",
"(",
")",
"==",
"computedBindings",
".",
"size",
"(",
")",
")",
"{",
"permutations",
".",
"add",
"(",
"descriptor",
".",
"getPermutationName",
"(",
")",
")",
";",
"}",
"else",
"{",
"for",
"(",
"final",
"BindingProperty",
"property",
":",
"descriptor",
".",
"getBindingProperties",
"(",
")",
")",
"{",
"// This is one of the bindings that we could not reduce on",
"if",
"(",
"null",
"==",
"findMatchingBindingProperty",
"(",
"computedBindings",
",",
"property",
")",
")",
"{",
"if",
"(",
"canMergeManifestForSelectionProperty",
"(",
"property",
".",
"getName",
"(",
")",
")",
")",
"{",
"permutations",
".",
"add",
"(",
"descriptor",
".",
"getPermutationName",
"(",
")",
")",
";",
"}",
"}",
"}",
"}",
"}",
"if",
"(",
"0",
"==",
"permutations",
".",
"size",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"else",
"{",
"return",
"permutations",
".",
"toArray",
"(",
"new",
"String",
"[",
"permutations",
".",
"size",
"(",
")",
"]",
")",
";",
"}",
"}",
"}",
"return",
"null",
";",
"}",
"catch",
"(",
"final",
"Exception",
"e",
")",
"{",
"throw",
"new",
"ServletException",
"(",
"\"can not read permutation information\"",
",",
"e",
")",
";",
"}",
"}"
] | Return an array of permutation names that are selected based on supplied properties.
The array may be null if no permutation could be found. It may be a single value if
the bindings uniquely identify a permutation or it may be multiple values if client side
properties are not specified and the server side properties do not uniquely identify a
permutation. | [
"Return",
"an",
"array",
"of",
"permutation",
"names",
"that",
"are",
"selected",
"based",
"on",
"supplied",
"properties",
"."
] | e22a5ae20b6fd4b5d0d6cfb5fdfd7b68b03a5519 | https://github.com/realityforge/gwt-appcache/blob/e22a5ae20b6fd4b5d0d6cfb5fdfd7b68b03a5519/server/src/main/java/org/realityforge/gwt/appcache/server/AbstractManifestServlet.java#L427-L485 |
143,333 | cloudiator/common | util/src/main/java/de/uniulm/omi/cloudiator/util/StreamUtil.java | StreamUtil.getOnly | public static <E> Collector<E, ?, Optional<E>> getOnly() {
return Collector.of(
AtomicReference<E>::new,
(ref, e) -> {
if (!ref.compareAndSet(null, e)) {
throw new IllegalArgumentException("Multiple values");
}
},
(ref1, ref2) -> {
if (ref1.get() == null) {
return ref2;
} else if (ref2.get() != null) {
throw new IllegalArgumentException("Multiple values");
} else {
return ref1;
}
},
ref -> Optional.ofNullable(ref.get()),
Collector.Characteristics.UNORDERED);
} | java | public static <E> Collector<E, ?, Optional<E>> getOnly() {
return Collector.of(
AtomicReference<E>::new,
(ref, e) -> {
if (!ref.compareAndSet(null, e)) {
throw new IllegalArgumentException("Multiple values");
}
},
(ref1, ref2) -> {
if (ref1.get() == null) {
return ref2;
} else if (ref2.get() != null) {
throw new IllegalArgumentException("Multiple values");
} else {
return ref1;
}
},
ref -> Optional.ofNullable(ref.get()),
Collector.Characteristics.UNORDERED);
} | [
"public",
"static",
"<",
"E",
">",
"Collector",
"<",
"E",
",",
"?",
",",
"Optional",
"<",
"E",
">",
">",
"getOnly",
"(",
")",
"{",
"return",
"Collector",
".",
"of",
"(",
"AtomicReference",
"<",
"E",
">",
"::",
"new",
",",
"(",
"ref",
",",
"e",
")",
"->",
"{",
"if",
"(",
"!",
"ref",
".",
"compareAndSet",
"(",
"null",
",",
"e",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Multiple values\"",
")",
";",
"}",
"}",
",",
"(",
"ref1",
",",
"ref2",
")",
"->",
"{",
"if",
"(",
"ref1",
".",
"get",
"(",
")",
"==",
"null",
")",
"{",
"return",
"ref2",
";",
"}",
"else",
"if",
"(",
"ref2",
".",
"get",
"(",
")",
"!=",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Multiple values\"",
")",
";",
"}",
"else",
"{",
"return",
"ref1",
";",
"}",
"}",
",",
"ref",
"->",
"Optional",
".",
"ofNullable",
"(",
"ref",
".",
"get",
"(",
")",
")",
",",
"Collector",
".",
"Characteristics",
".",
"UNORDERED",
")",
";",
"}"
] | Can be replaced with MoreCollectors.onlyElement as soon as we can upgrade to the newest Guava
version.
@param <E> type of the element.
@return only one element.
@see <a href="https://stackoverflow.com/questions/22694884/filter-java-stream-to-1-and-only-1-element"/> | [
"Can",
"be",
"replaced",
"with",
"MoreCollectors",
".",
"onlyElement",
"as",
"soon",
"as",
"we",
"can",
"upgrade",
"to",
"the",
"newest",
"Guava",
"version",
"."
] | 18841a64f0a5fc4e7554c214df4ab0547bc408dc | https://github.com/cloudiator/common/blob/18841a64f0a5fc4e7554c214df4ab0547bc408dc/util/src/main/java/de/uniulm/omi/cloudiator/util/StreamUtil.java#L38-L57 |
143,334 | cloudiator/common | persistence/src/main/java/io/github/cloudiator/util/JpaResultHelper.java | JpaResultHelper.getSingleResultOrNull | public static Object getSingleResultOrNull(Query query) {
List results = query.getResultList();
if (results.isEmpty()) {
return null;
} else if (results.size() == 1) {
return results.get(0);
}
throw new NonUniqueResultException();
} | java | public static Object getSingleResultOrNull(Query query) {
List results = query.getResultList();
if (results.isEmpty()) {
return null;
} else if (results.size() == 1) {
return results.get(0);
}
throw new NonUniqueResultException();
} | [
"public",
"static",
"Object",
"getSingleResultOrNull",
"(",
"Query",
"query",
")",
"{",
"List",
"results",
"=",
"query",
".",
"getResultList",
"(",
")",
";",
"if",
"(",
"results",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"else",
"if",
"(",
"results",
".",
"size",
"(",
")",
"==",
"1",
")",
"{",
"return",
"results",
".",
"get",
"(",
"0",
")",
";",
"}",
"throw",
"new",
"NonUniqueResultException",
"(",
")",
";",
"}"
] | Executes the query and ensures that either a single result is returned or null.
@param query the query to be executed.
@return a single result of any, otherwise null.
@throws javax.persistence.NonUniqueResultException if more than one result is returned by the
query. | [
"Executes",
"the",
"query",
"and",
"ensures",
"that",
"either",
"a",
"single",
"result",
"is",
"returned",
"or",
"null",
"."
] | 18841a64f0a5fc4e7554c214df4ab0547bc408dc | https://github.com/cloudiator/common/blob/18841a64f0a5fc4e7554c214df4ab0547bc408dc/persistence/src/main/java/io/github/cloudiator/util/JpaResultHelper.java#L47-L55 |
143,335 | cloudiator/common | util/src/main/java/de/uniulm/omi/cloudiator/util/Password.java | Password.hash | public char[] hash(char[] password, byte[] salt) {
checkNotNull(password);
checkArgument(password.length != 0);
checkNotNull(salt);
checkArgument(salt.length != 0);
try {
SecretKeyFactory f = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
SecretKey key =
f.generateSecret(new PBEKeySpec(password, salt, ITERATIONS, DESIRED_KEY_LENGTH));
return Base64.encodeBase64String(key.getEncoded()).toCharArray();
} catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
throw new IllegalStateException("Could not hash the password of the user.", e);
}
} | java | public char[] hash(char[] password, byte[] salt) {
checkNotNull(password);
checkArgument(password.length != 0);
checkNotNull(salt);
checkArgument(salt.length != 0);
try {
SecretKeyFactory f = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
SecretKey key =
f.generateSecret(new PBEKeySpec(password, salt, ITERATIONS, DESIRED_KEY_LENGTH));
return Base64.encodeBase64String(key.getEncoded()).toCharArray();
} catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
throw new IllegalStateException("Could not hash the password of the user.", e);
}
} | [
"public",
"char",
"[",
"]",
"hash",
"(",
"char",
"[",
"]",
"password",
",",
"byte",
"[",
"]",
"salt",
")",
"{",
"checkNotNull",
"(",
"password",
")",
";",
"checkArgument",
"(",
"password",
".",
"length",
"!=",
"0",
")",
";",
"checkNotNull",
"(",
"salt",
")",
";",
"checkArgument",
"(",
"salt",
".",
"length",
"!=",
"0",
")",
";",
"try",
"{",
"SecretKeyFactory",
"f",
"=",
"SecretKeyFactory",
".",
"getInstance",
"(",
"\"PBKDF2WithHmacSHA1\"",
")",
";",
"SecretKey",
"key",
"=",
"f",
".",
"generateSecret",
"(",
"new",
"PBEKeySpec",
"(",
"password",
",",
"salt",
",",
"ITERATIONS",
",",
"DESIRED_KEY_LENGTH",
")",
")",
";",
"return",
"Base64",
".",
"encodeBase64String",
"(",
"key",
".",
"getEncoded",
"(",
")",
")",
".",
"toCharArray",
"(",
")",
";",
"}",
"catch",
"(",
"NoSuchAlgorithmException",
"|",
"InvalidKeySpecException",
"e",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Could not hash the password of the user.\"",
",",
"e",
")",
";",
"}",
"}"
] | Hashes the password using pbkdf2 and the given salt.
@param password the plain text password to hash.
@param salt the salt for the password
@return the hashed password | [
"Hashes",
"the",
"password",
"using",
"pbkdf2",
"and",
"the",
"given",
"salt",
"."
] | 18841a64f0a5fc4e7554c214df4ab0547bc408dc | https://github.com/cloudiator/common/blob/18841a64f0a5fc4e7554c214df4ab0547bc408dc/util/src/main/java/de/uniulm/omi/cloudiator/util/Password.java#L111-L125 |
143,336 | cloudiator/common | util/src/main/java/de/uniulm/omi/cloudiator/util/Password.java | Password.check | public boolean check(char[] plain, char[] database, byte[] salt) {
checkNotNull(plain);
checkArgument(plain.length != 0, "Plain must not be empty.");
checkNotNull(database);
checkArgument(database.length != 0, "Database must not be empty.");
checkNotNull(salt);
checkArgument(salt.length != 0, "Salt must not be empty.");
char[] hashedPlain = this.hash(plain, salt);
return Arrays.equals(hashedPlain, database);
} | java | public boolean check(char[] plain, char[] database, byte[] salt) {
checkNotNull(plain);
checkArgument(plain.length != 0, "Plain must not be empty.");
checkNotNull(database);
checkArgument(database.length != 0, "Database must not be empty.");
checkNotNull(salt);
checkArgument(salt.length != 0, "Salt must not be empty.");
char[] hashedPlain = this.hash(plain, salt);
return Arrays.equals(hashedPlain, database);
} | [
"public",
"boolean",
"check",
"(",
"char",
"[",
"]",
"plain",
",",
"char",
"[",
"]",
"database",
",",
"byte",
"[",
"]",
"salt",
")",
"{",
"checkNotNull",
"(",
"plain",
")",
";",
"checkArgument",
"(",
"plain",
".",
"length",
"!=",
"0",
",",
"\"Plain must not be empty.\"",
")",
";",
"checkNotNull",
"(",
"database",
")",
";",
"checkArgument",
"(",
"database",
".",
"length",
"!=",
"0",
",",
"\"Database must not be empty.\"",
")",
";",
"checkNotNull",
"(",
"salt",
")",
";",
"checkArgument",
"(",
"salt",
".",
"length",
"!=",
"0",
",",
"\"Salt must not be empty.\"",
")",
";",
"char",
"[",
"]",
"hashedPlain",
"=",
"this",
".",
"hash",
"(",
"plain",
",",
"salt",
")",
";",
"return",
"Arrays",
".",
"equals",
"(",
"hashedPlain",
",",
"database",
")",
";",
"}"
] | Checks if the given plain password matches the given password hash
@param plain the plain text password.
@param database the hashed password from the database.
@param salt the salt used for the hashed password.
@return true if the passwords match, false if not. | [
"Checks",
"if",
"the",
"given",
"plain",
"password",
"matches",
"the",
"given",
"password",
"hash"
] | 18841a64f0a5fc4e7554c214df4ab0547bc408dc | https://github.com/cloudiator/common/blob/18841a64f0a5fc4e7554c214df4ab0547bc408dc/util/src/main/java/de/uniulm/omi/cloudiator/util/Password.java#L135-L146 |
143,337 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/util/stats/Mathematics.java | Mathematics.mean | public static double mean(double[] a) {
if (a.length == 0) return Double.NaN;
double sum = sum(a);
return sum / a.length;
} | java | public static double mean(double[] a) {
if (a.length == 0) return Double.NaN;
double sum = sum(a);
return sum / a.length;
} | [
"public",
"static",
"double",
"mean",
"(",
"double",
"[",
"]",
"a",
")",
"{",
"if",
"(",
"a",
".",
"length",
"==",
"0",
")",
"return",
"Double",
".",
"NaN",
";",
"double",
"sum",
"=",
"sum",
"(",
"a",
")",
";",
"return",
"sum",
"/",
"a",
".",
"length",
";",
"}"
] | Returns the average value in the specified array.
@param a the array
@return the average value in the array {@code a[]};
{@code Double.NaN} if no such value | [
"Returns",
"the",
"average",
"value",
"in",
"the",
"specified",
"array",
"."
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/stats/Mathematics.java#L31-L36 |
143,338 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/util/stats/Mathematics.java | Mathematics.stdDev | public static double stdDev(double[] a) {
if(a == null || a.length == 0)
return -1;
return Math.sqrt(varp(a));
} | java | public static double stdDev(double[] a) {
if(a == null || a.length == 0)
return -1;
return Math.sqrt(varp(a));
} | [
"public",
"static",
"double",
"stdDev",
"(",
"double",
"[",
"]",
"a",
")",
"{",
"if",
"(",
"a",
"==",
"null",
"||",
"a",
".",
"length",
"==",
"0",
")",
"return",
"-",
"1",
";",
"return",
"Math",
".",
"sqrt",
"(",
"varp",
"(",
"a",
")",
")",
";",
"}"
] | Returns the population standard deviation in the specified array.
@param a the array
@return the population standard deviation in the array;
{@code Double.NaN} if no such value | [
"Returns",
"the",
"population",
"standard",
"deviation",
"in",
"the",
"specified",
"array",
"."
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/stats/Mathematics.java#L63-L69 |
143,339 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/io/SynchronizedIO.java | SynchronizedIO.writeFile | public void writeFile(String aFileName, String aData) throws IOException
{
Object lock = retrieveLock(aFileName);
synchronized (lock)
{
IO.writeFile(aFileName, aData,IO.CHARSET);
}
} | java | public void writeFile(String aFileName, String aData) throws IOException
{
Object lock = retrieveLock(aFileName);
synchronized (lock)
{
IO.writeFile(aFileName, aData,IO.CHARSET);
}
} | [
"public",
"void",
"writeFile",
"(",
"String",
"aFileName",
",",
"String",
"aData",
")",
"throws",
"IOException",
"{",
"Object",
"lock",
"=",
"retrieveLock",
"(",
"aFileName",
")",
";",
"synchronized",
"(",
"lock",
")",
"{",
"IO",
".",
"writeFile",
"(",
"aFileName",
",",
"aData",
",",
"IO",
".",
"CHARSET",
")",
";",
"}",
"}"
] | Write string file data
@param aFileName the file name
@param aData the data to write
@throws IOException when an IO error occurs | [
"Write",
"string",
"file",
"data"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/io/SynchronizedIO.java#L118-L126 |
143,340 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/io/SynchronizedIO.java | SynchronizedIO.retrieveLock | private Object retrieveLock(String key)
{
Object lock = this.lockMap.get(key);
if(lock == null)
{
lock = key;
this.lockMap.put(key, lock);
}
return lock;
} | java | private Object retrieveLock(String key)
{
Object lock = this.lockMap.get(key);
if(lock == null)
{
lock = key;
this.lockMap.put(key, lock);
}
return lock;
} | [
"private",
"Object",
"retrieveLock",
"(",
"String",
"key",
")",
"{",
"Object",
"lock",
"=",
"this",
".",
"lockMap",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"lock",
"==",
"null",
")",
"{",
"lock",
"=",
"key",
";",
"this",
".",
"lockMap",
".",
"put",
"(",
"key",
",",
"lock",
")",
";",
"}",
"return",
"lock",
";",
"}"
] | Retrieve the lock object for a given key
@param key the key for the lock
@return the object that will be used as a lock | [
"Retrieve",
"the",
"lock",
"object",
"for",
"a",
"given",
"key"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/io/SynchronizedIO.java#L170-L179 |
143,341 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/exception/fault/FaultException.java | FaultException.formatMessage | protected void formatMessage(String aID, Map<Object,Object> aBindValues)
{
Presenter presenter = Presenter.getPresenter(this.getClass());
message = presenter.getText(aID,aBindValues);
} | java | protected void formatMessage(String aID, Map<Object,Object> aBindValues)
{
Presenter presenter = Presenter.getPresenter(this.getClass());
message = presenter.getText(aID,aBindValues);
} | [
"protected",
"void",
"formatMessage",
"(",
"String",
"aID",
",",
"Map",
"<",
"Object",
",",
"Object",
">",
"aBindValues",
")",
"{",
"Presenter",
"presenter",
"=",
"Presenter",
".",
"getPresenter",
"(",
"this",
".",
"getClass",
"(",
")",
")",
";",
"message",
"=",
"presenter",
".",
"getText",
"(",
"aID",
",",
"aBindValues",
")",
";",
"}"
] | Format the exception message using the presenter getText method
@param aID the key of the message
@param aBindValues the values to plug into the message. | [
"Format",
"the",
"exception",
"message",
"using",
"the",
"presenter",
"getText",
"method"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/exception/fault/FaultException.java#L215-L220 |
143,342 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/ds/LDAP.java | LDAP.setupKerberosContext | @SuppressWarnings({ "rawtypes", "unchecked" })
protected DirContext setupKerberosContext(Hashtable<String,Object> env)
throws NamingException
{
LoginContext lc = null;
try
{
lc = new LoginContext(getClass().getName(), new JXCallbackHandler());
lc.login();
}
catch (LoginException ex)
{
throw new NamingException("login problem: " + ex);
}
DirContext ctx = (DirContext) Subject.doAs(lc.getSubject(), new JndiAction(env));
if (ctx == null)
throw new NamingException("another problem with GSSAPI");
else
return ctx;
} | java | @SuppressWarnings({ "rawtypes", "unchecked" })
protected DirContext setupKerberosContext(Hashtable<String,Object> env)
throws NamingException
{
LoginContext lc = null;
try
{
lc = new LoginContext(getClass().getName(), new JXCallbackHandler());
lc.login();
}
catch (LoginException ex)
{
throw new NamingException("login problem: " + ex);
}
DirContext ctx = (DirContext) Subject.doAs(lc.getSubject(), new JndiAction(env));
if (ctx == null)
throw new NamingException("another problem with GSSAPI");
else
return ctx;
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"rawtypes\"",
",",
"\"unchecked\"",
"}",
")",
"protected",
"DirContext",
"setupKerberosContext",
"(",
"Hashtable",
"<",
"String",
",",
"Object",
">",
"env",
")",
"throws",
"NamingException",
"{",
"LoginContext",
"lc",
"=",
"null",
";",
"try",
"{",
"lc",
"=",
"new",
"LoginContext",
"(",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
",",
"new",
"JXCallbackHandler",
"(",
")",
")",
";",
"lc",
".",
"login",
"(",
")",
";",
"}",
"catch",
"(",
"LoginException",
"ex",
")",
"{",
"throw",
"new",
"NamingException",
"(",
"\"login problem: \"",
"+",
"ex",
")",
";",
"}",
"DirContext",
"ctx",
"=",
"(",
"DirContext",
")",
"Subject",
".",
"doAs",
"(",
"lc",
".",
"getSubject",
"(",
")",
",",
"new",
"JndiAction",
"(",
"env",
")",
")",
";",
"if",
"(",
"ctx",
"==",
"null",
")",
"throw",
"new",
"NamingException",
"(",
"\"another problem with GSSAPI\"",
")",
";",
"else",
"return",
"ctx",
";",
"}"
] | Initial LDAP for kerberos support
@param env
@throws NamingException | [
"Initial",
"LDAP",
"for",
"kerberos",
"support"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/ds/LDAP.java#L156-L181 |
143,343 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/ds/LDAP.java | LDAP.authenicate | public Principal authenicate(String uid, char[] password)
throws SecurityException
{
String rootDN = Config.getProperty(ROOT_DN_PROP);
int timeout = Config.getPropertyInteger(TIMEOUT_SECS_PROP).intValue();
Debugger.println(LDAP.class,"timeout="+timeout);
String uidAttributeName = Config.getProperty(UID_ATTRIB_NM_PROP);
String groupAttributeName = Config.getProperty(GROUP_ATTRIB_NM_PROP,"");
String memberOfAttributeName = Config.getProperty(MEMBEROF_ATTRIB_NM_PROP,"");
return authenicate(uid, password,rootDN,uidAttributeName,memberOfAttributeName,groupAttributeName,timeout);
} | java | public Principal authenicate(String uid, char[] password)
throws SecurityException
{
String rootDN = Config.getProperty(ROOT_DN_PROP);
int timeout = Config.getPropertyInteger(TIMEOUT_SECS_PROP).intValue();
Debugger.println(LDAP.class,"timeout="+timeout);
String uidAttributeName = Config.getProperty(UID_ATTRIB_NM_PROP);
String groupAttributeName = Config.getProperty(GROUP_ATTRIB_NM_PROP,"");
String memberOfAttributeName = Config.getProperty(MEMBEROF_ATTRIB_NM_PROP,"");
return authenicate(uid, password,rootDN,uidAttributeName,memberOfAttributeName,groupAttributeName,timeout);
} | [
"public",
"Principal",
"authenicate",
"(",
"String",
"uid",
",",
"char",
"[",
"]",
"password",
")",
"throws",
"SecurityException",
"{",
"String",
"rootDN",
"=",
"Config",
".",
"getProperty",
"(",
"ROOT_DN_PROP",
")",
";",
"int",
"timeout",
"=",
"Config",
".",
"getPropertyInteger",
"(",
"TIMEOUT_SECS_PROP",
")",
".",
"intValue",
"(",
")",
";",
"Debugger",
".",
"println",
"(",
"LDAP",
".",
"class",
",",
"\"timeout=\"",
"+",
"timeout",
")",
";",
"String",
"uidAttributeName",
"=",
"Config",
".",
"getProperty",
"(",
"UID_ATTRIB_NM_PROP",
")",
";",
"String",
"groupAttributeName",
"=",
"Config",
".",
"getProperty",
"(",
"GROUP_ATTRIB_NM_PROP",
",",
"\"\"",
")",
";",
"String",
"memberOfAttributeName",
"=",
"Config",
".",
"getProperty",
"(",
"MEMBEROF_ATTRIB_NM_PROP",
",",
"\"\"",
")",
";",
"return",
"authenicate",
"(",
"uid",
",",
"password",
",",
"rootDN",
",",
"uidAttributeName",
",",
"memberOfAttributeName",
",",
"groupAttributeName",
",",
"timeout",
")",
";",
"}"
] | Authenticate user ID and password against the LDAP server
@param uid i.e. greeng
@param password the user password
@return the user principal details
@throws SecurityException when security error occurs | [
"Authenticate",
"user",
"ID",
"and",
"password",
"against",
"the",
"LDAP",
"server"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/ds/LDAP.java#L270-L284 |
143,344 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/reflection/GenericObject.java | GenericObject.getFields | public GenericField[] getFields()
{
Collection<GenericField> values = fieldMap.values();
if(values == null || values.isEmpty())
return null;
GenericField[] fieldMirrors = new GenericField[values.size()];
values.toArray(fieldMirrors);
return fieldMirrors;
} | java | public GenericField[] getFields()
{
Collection<GenericField> values = fieldMap.values();
if(values == null || values.isEmpty())
return null;
GenericField[] fieldMirrors = new GenericField[values.size()];
values.toArray(fieldMirrors);
return fieldMirrors;
} | [
"public",
"GenericField",
"[",
"]",
"getFields",
"(",
")",
"{",
"Collection",
"<",
"GenericField",
">",
"values",
"=",
"fieldMap",
".",
"values",
"(",
")",
";",
"if",
"(",
"values",
"==",
"null",
"||",
"values",
".",
"isEmpty",
"(",
")",
")",
"return",
"null",
";",
"GenericField",
"[",
"]",
"fieldMirrors",
"=",
"new",
"GenericField",
"[",
"values",
".",
"size",
"(",
")",
"]",
";",
"values",
".",
"toArray",
"(",
"fieldMirrors",
")",
";",
"return",
"fieldMirrors",
";",
"}"
] | List all fields
@return the array of generic fields | [
"List",
"all",
"fields"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/reflection/GenericObject.java#L57-L69 |
143,345 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/io/csv/CsvReader.java | CsvReader.sortRows | public void sortRows(Comparator<List<String>> comparator)
{
if(data.isEmpty())
return;
Collections.sort(data, comparator);
} | java | public void sortRows(Comparator<List<String>> comparator)
{
if(data.isEmpty())
return;
Collections.sort(data, comparator);
} | [
"public",
"void",
"sortRows",
"(",
"Comparator",
"<",
"List",
"<",
"String",
">",
">",
"comparator",
")",
"{",
"if",
"(",
"data",
".",
"isEmpty",
"(",
")",
")",
"return",
";",
"Collections",
".",
"sort",
"(",
"data",
",",
"comparator",
")",
";",
"}"
] | Sort the rows by comparator
@param comparator the comparator used for sorting | [
"Sort",
"the",
"rows",
"by",
"comparator"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/io/csv/CsvReader.java#L236-L242 |
143,346 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/creational/generator/JavaBeanGeneratorCreator.java | JavaBeanGeneratorCreator.randomizeProperty | public JavaBeanGeneratorCreator<T> randomizeProperty(String property)
{
if(property ==null || property.length() == 0)
return this;
this.randomizeProperties.add(property);
return this;
} | java | public JavaBeanGeneratorCreator<T> randomizeProperty(String property)
{
if(property ==null || property.length() == 0)
return this;
this.randomizeProperties.add(property);
return this;
} | [
"public",
"JavaBeanGeneratorCreator",
"<",
"T",
">",
"randomizeProperty",
"(",
"String",
"property",
")",
"{",
"if",
"(",
"property",
"==",
"null",
"||",
"property",
".",
"length",
"(",
")",
"==",
"0",
")",
"return",
"this",
";",
"this",
".",
"randomizeProperties",
".",
"add",
"(",
"property",
")",
";",
"return",
"this",
";",
"}"
] | Setup property to generate a random value
@param property the property randomize
@return the creator instance | [
"Setup",
"property",
"to",
"generate",
"a",
"random",
"value"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/creational/generator/JavaBeanGeneratorCreator.java#L221-L229 |
143,347 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/creational/generator/JavaBeanGeneratorCreator.java | JavaBeanGeneratorCreator.fixedProperties | public JavaBeanGeneratorCreator<T> fixedProperties(String... fixedPropertyNames)
{
if(fixedPropertyNames == null || fixedPropertyNames.length == 0)
{
return this;
}
HashSet<String> fixSet = new HashSet<>(Arrays.asList(fixedPropertyNames));
Map<Object,Object> map = null;
if(this.prototype != null)
{
map =JavaBean.toMap(this.prototype);
}
else
map = JavaBean.toMap(ClassPath.newInstance(this.creationClass));
if(map == null || map.isEmpty())
return this;
String propertyName = null;
for(Object propertyNameObject : map.keySet())
{
propertyName = String.valueOf(propertyNameObject);
if(!fixSet.contains(propertyName))
{
this.randomizeProperty(propertyName);
}
}
return this;
} | java | public JavaBeanGeneratorCreator<T> fixedProperties(String... fixedPropertyNames)
{
if(fixedPropertyNames == null || fixedPropertyNames.length == 0)
{
return this;
}
HashSet<String> fixSet = new HashSet<>(Arrays.asList(fixedPropertyNames));
Map<Object,Object> map = null;
if(this.prototype != null)
{
map =JavaBean.toMap(this.prototype);
}
else
map = JavaBean.toMap(ClassPath.newInstance(this.creationClass));
if(map == null || map.isEmpty())
return this;
String propertyName = null;
for(Object propertyNameObject : map.keySet())
{
propertyName = String.valueOf(propertyNameObject);
if(!fixSet.contains(propertyName))
{
this.randomizeProperty(propertyName);
}
}
return this;
} | [
"public",
"JavaBeanGeneratorCreator",
"<",
"T",
">",
"fixedProperties",
"(",
"String",
"...",
"fixedPropertyNames",
")",
"{",
"if",
"(",
"fixedPropertyNames",
"==",
"null",
"||",
"fixedPropertyNames",
".",
"length",
"==",
"0",
")",
"{",
"return",
"this",
";",
"}",
"HashSet",
"<",
"String",
">",
"fixSet",
"=",
"new",
"HashSet",
"<>",
"(",
"Arrays",
".",
"asList",
"(",
"fixedPropertyNames",
")",
")",
";",
"Map",
"<",
"Object",
",",
"Object",
">",
"map",
"=",
"null",
";",
"if",
"(",
"this",
".",
"prototype",
"!=",
"null",
")",
"{",
"map",
"=",
"JavaBean",
".",
"toMap",
"(",
"this",
".",
"prototype",
")",
";",
"}",
"else",
"map",
"=",
"JavaBean",
".",
"toMap",
"(",
"ClassPath",
".",
"newInstance",
"(",
"this",
".",
"creationClass",
")",
")",
";",
"if",
"(",
"map",
"==",
"null",
"||",
"map",
".",
"isEmpty",
"(",
")",
")",
"return",
"this",
";",
"String",
"propertyName",
"=",
"null",
";",
"for",
"(",
"Object",
"propertyNameObject",
":",
"map",
".",
"keySet",
"(",
")",
")",
"{",
"propertyName",
"=",
"String",
".",
"valueOf",
"(",
"propertyNameObject",
")",
";",
"if",
"(",
"!",
"fixSet",
".",
"contains",
"(",
"propertyName",
")",
")",
"{",
"this",
".",
"randomizeProperty",
"(",
"propertyName",
")",
";",
"}",
"}",
"return",
"this",
";",
"}"
] | Randomized to records that are not in fixed list
@param fixedPropertyNames the fixed list of property names
@return the creator factory | [
"Randomized",
"to",
"records",
"that",
"are",
"not",
"in",
"fixed",
"list"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/creational/generator/JavaBeanGeneratorCreator.java#L240-L272 |
143,348 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/data/Criteria.java | Criteria.setPrimaryKey | public void setPrimaryKey(int primaryKey)
throws IllegalArgumentException
{
if (primaryKey <= NULL)
{
this.primaryKey = Data.NULL;
}
else
{
this.primaryKey = primaryKey;
//resetNew();
return;
}
} | java | public void setPrimaryKey(int primaryKey)
throws IllegalArgumentException
{
if (primaryKey <= NULL)
{
this.primaryKey = Data.NULL;
}
else
{
this.primaryKey = primaryKey;
//resetNew();
return;
}
} | [
"public",
"void",
"setPrimaryKey",
"(",
"int",
"primaryKey",
")",
"throws",
"IllegalArgumentException",
"{",
"if",
"(",
"primaryKey",
"<=",
"NULL",
")",
"{",
"this",
".",
"primaryKey",
"=",
"Data",
".",
"NULL",
";",
"}",
"else",
"{",
"this",
".",
"primaryKey",
"=",
"primaryKey",
";",
"//resetNew();\r",
"return",
";",
"}",
"}"
] | Set primary key
@param primaryKey the primary key to set
@throws IllegalArgumentException primary key is < 1 | [
"Set",
"primary",
"key"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/data/Criteria.java#L112-L129 |
143,349 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/search/ReLookup.java | ReLookup.lookup | public T lookup(String text)
{
if (text == null)
return null;
for (Entry<String,T> entry :lookupMap.entrySet())
{
if (Text.matches(text, entry.getKey()))
return lookupMap.get(entry.getKey());
}
return null;
} | java | public T lookup(String text)
{
if (text == null)
return null;
for (Entry<String,T> entry :lookupMap.entrySet())
{
if (Text.matches(text, entry.getKey()))
return lookupMap.get(entry.getKey());
}
return null;
} | [
"public",
"T",
"lookup",
"(",
"String",
"text",
")",
"{",
"if",
"(",
"text",
"==",
"null",
")",
"return",
"null",
";",
"for",
"(",
"Entry",
"<",
"String",
",",
"T",
">",
"entry",
":",
"lookupMap",
".",
"entrySet",
"(",
")",
")",
"{",
"if",
"(",
"Text",
".",
"matches",
"(",
"text",
",",
"entry",
".",
"getKey",
"(",
")",
")",
")",
"return",
"lookupMap",
".",
"get",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Lookup a value of the dictionary
@param text the value to compare the keys
@return the match value for the key | [
"Lookup",
"a",
"value",
"of",
"the",
"dictionary"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/search/ReLookup.java#L121-L135 |
143,350 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/search/queryService/QuestDirector.java | QuestDirector.constructDataRows | @SuppressWarnings({ "unchecked", "rawtypes" })
public static final <T> Collection<DataRow> constructDataRows(Iterator<T> iterator, QuestCriteria questCriteria, DataRowCreator visitor)
{
if(iterator == null )
return null;
ArrayList<DataRow> dataRows = new ArrayList<DataRow>(BATCH_SIZE);
boolean usePaging = false;
boolean savePagination = false;
int pageSize = 0;
PageCriteria pageCriteria = questCriteria.getPageCriteria();
Pagination pagination = null;
if(pageCriteria != null)
{
pageSize = pageCriteria.getSize();
if(pageSize > 0)
{
usePaging = true;
savePagination = pageCriteria.isSavePagination();
if(savePagination)
pagination = Pagination.getPagination(pageCriteria);
}
}
if(usePaging)
{
//Process results with paging being used
//int index = 0;
T item;
DataRow dataRow;
while (iterator.hasNext())
{
item = iterator.next();
JavaBean.acceptVisitor(item, visitor);
dataRow = visitor.getDataRow();
dataRows.add(dataRow);
if(savePagination)
pagination.store(dataRow, pageCriteria);
visitor.clear();
//if datarows greater than page size
if(dataRows.size() >= pageSize)
{
//then check if has more results and continue to gather results in break ground
if(savePagination && iterator.hasNext())
{
pagination.constructPaging(iterator, pageCriteria, (RowObjectCreator)visitor);
}
break; //break look since page is filled
}
}
}
else
{
//no paging used
Object item;
while (iterator.hasNext())
{
item = iterator.next();
JavaBean.acceptVisitor(item, visitor);
dataRows.add(visitor.getDataRow());
visitor.clear();
}
}
dataRows.trimToSize();
//data rows to paging collection
PagingCollection<DataRow> pagingCollection = new PagingCollection<DataRow>(dataRows,questCriteria.getPageCriteria());
return pagingCollection;
} | java | @SuppressWarnings({ "unchecked", "rawtypes" })
public static final <T> Collection<DataRow> constructDataRows(Iterator<T> iterator, QuestCriteria questCriteria, DataRowCreator visitor)
{
if(iterator == null )
return null;
ArrayList<DataRow> dataRows = new ArrayList<DataRow>(BATCH_SIZE);
boolean usePaging = false;
boolean savePagination = false;
int pageSize = 0;
PageCriteria pageCriteria = questCriteria.getPageCriteria();
Pagination pagination = null;
if(pageCriteria != null)
{
pageSize = pageCriteria.getSize();
if(pageSize > 0)
{
usePaging = true;
savePagination = pageCriteria.isSavePagination();
if(savePagination)
pagination = Pagination.getPagination(pageCriteria);
}
}
if(usePaging)
{
//Process results with paging being used
//int index = 0;
T item;
DataRow dataRow;
while (iterator.hasNext())
{
item = iterator.next();
JavaBean.acceptVisitor(item, visitor);
dataRow = visitor.getDataRow();
dataRows.add(dataRow);
if(savePagination)
pagination.store(dataRow, pageCriteria);
visitor.clear();
//if datarows greater than page size
if(dataRows.size() >= pageSize)
{
//then check if has more results and continue to gather results in break ground
if(savePagination && iterator.hasNext())
{
pagination.constructPaging(iterator, pageCriteria, (RowObjectCreator)visitor);
}
break; //break look since page is filled
}
}
}
else
{
//no paging used
Object item;
while (iterator.hasNext())
{
item = iterator.next();
JavaBean.acceptVisitor(item, visitor);
dataRows.add(visitor.getDataRow());
visitor.clear();
}
}
dataRows.trimToSize();
//data rows to paging collection
PagingCollection<DataRow> pagingCollection = new PagingCollection<DataRow>(dataRows,questCriteria.getPageCriteria());
return pagingCollection;
} | [
"@",
"SuppressWarnings",
"(",
"{",
"\"unchecked\"",
",",
"\"rawtypes\"",
"}",
")",
"public",
"static",
"final",
"<",
"T",
">",
"Collection",
"<",
"DataRow",
">",
"constructDataRows",
"(",
"Iterator",
"<",
"T",
">",
"iterator",
",",
"QuestCriteria",
"questCriteria",
",",
"DataRowCreator",
"visitor",
")",
"{",
"if",
"(",
"iterator",
"==",
"null",
")",
"return",
"null",
";",
"ArrayList",
"<",
"DataRow",
">",
"dataRows",
"=",
"new",
"ArrayList",
"<",
"DataRow",
">",
"(",
"BATCH_SIZE",
")",
";",
"boolean",
"usePaging",
"=",
"false",
";",
"boolean",
"savePagination",
"=",
"false",
";",
"int",
"pageSize",
"=",
"0",
";",
"PageCriteria",
"pageCriteria",
"=",
"questCriteria",
".",
"getPageCriteria",
"(",
")",
";",
"Pagination",
"pagination",
"=",
"null",
";",
"if",
"(",
"pageCriteria",
"!=",
"null",
")",
"{",
"pageSize",
"=",
"pageCriteria",
".",
"getSize",
"(",
")",
";",
"if",
"(",
"pageSize",
">",
"0",
")",
"{",
"usePaging",
"=",
"true",
";",
"savePagination",
"=",
"pageCriteria",
".",
"isSavePagination",
"(",
")",
";",
"if",
"(",
"savePagination",
")",
"pagination",
"=",
"Pagination",
".",
"getPagination",
"(",
"pageCriteria",
")",
";",
"}",
"}",
"if",
"(",
"usePaging",
")",
"{",
"//Process results with paging being used",
"//int index = 0;",
"T",
"item",
";",
"DataRow",
"dataRow",
";",
"while",
"(",
"iterator",
".",
"hasNext",
"(",
")",
")",
"{",
"item",
"=",
"iterator",
".",
"next",
"(",
")",
";",
"JavaBean",
".",
"acceptVisitor",
"(",
"item",
",",
"visitor",
")",
";",
"dataRow",
"=",
"visitor",
".",
"getDataRow",
"(",
")",
";",
"dataRows",
".",
"add",
"(",
"dataRow",
")",
";",
"if",
"(",
"savePagination",
")",
"pagination",
".",
"store",
"(",
"dataRow",
",",
"pageCriteria",
")",
";",
"visitor",
".",
"clear",
"(",
")",
";",
"//if datarows greater than page size",
"if",
"(",
"dataRows",
".",
"size",
"(",
")",
">=",
"pageSize",
")",
"{",
"//then check if has more results and continue to gather results in break ground",
"if",
"(",
"savePagination",
"&&",
"iterator",
".",
"hasNext",
"(",
")",
")",
"{",
"pagination",
".",
"constructPaging",
"(",
"iterator",
",",
"pageCriteria",
",",
"(",
"RowObjectCreator",
")",
"visitor",
")",
";",
"}",
"break",
";",
"//break look since page is filled",
"}",
"}",
"}",
"else",
"{",
"//no paging used",
"Object",
"item",
";",
"while",
"(",
"iterator",
".",
"hasNext",
"(",
")",
")",
"{",
"item",
"=",
"iterator",
".",
"next",
"(",
")",
";",
"JavaBean",
".",
"acceptVisitor",
"(",
"item",
",",
"visitor",
")",
";",
"dataRows",
".",
"add",
"(",
"visitor",
".",
"getDataRow",
"(",
")",
")",
";",
"visitor",
".",
"clear",
"(",
")",
";",
"}",
"}",
"dataRows",
".",
"trimToSize",
"(",
")",
";",
"//data rows to paging collection",
"PagingCollection",
"<",
"DataRow",
">",
"pagingCollection",
"=",
"new",
"PagingCollection",
"<",
"DataRow",
">",
"(",
"dataRows",
",",
"questCriteria",
".",
"getPageCriteria",
"(",
")",
")",
";",
"return",
"pagingCollection",
";",
"}"
] | Process results with support for paging
@param <T> the type
@param iterator the results to be converted to data rows
@param questCriteria the input query search criteria
@param visitor the visitor to convert results to the data rows
@return the collection of data rows | [
"Process",
"results",
"with",
"support",
"for",
"paging"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/search/queryService/QuestDirector.java#L32-L121 |
143,351 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/net/rmi/RMI.java | RMI.rebind | public void rebind(Remote[] remotes)
{
String rmiUrl = null;
//loop thru remote objects
for (int i = 0; i < remotes.length; i++)
{
//use is if instance of Identifier
if(remotes[i] instanceof Identifier
&& !Text.isNull(((Identifier)remotes[i]).getId()))
{
rmiUrl = ((Identifier)remotes[i]).getId();
}
else
{
//get rmiUrl
rmiUrl = Config.getProperty(remotes[i].getClass(), "bind.rmi.url");
}
//rebind
rebind(rmiUrl,remotes[i]);
}
} | java | public void rebind(Remote[] remotes)
{
String rmiUrl = null;
//loop thru remote objects
for (int i = 0; i < remotes.length; i++)
{
//use is if instance of Identifier
if(remotes[i] instanceof Identifier
&& !Text.isNull(((Identifier)remotes[i]).getId()))
{
rmiUrl = ((Identifier)remotes[i]).getId();
}
else
{
//get rmiUrl
rmiUrl = Config.getProperty(remotes[i].getClass(), "bind.rmi.url");
}
//rebind
rebind(rmiUrl,remotes[i]);
}
} | [
"public",
"void",
"rebind",
"(",
"Remote",
"[",
"]",
"remotes",
")",
"{",
"String",
"rmiUrl",
"=",
"null",
";",
"//loop thru remote objects\r",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"remotes",
".",
"length",
";",
"i",
"++",
")",
"{",
"//use is if instance of Identifier\r",
"if",
"(",
"remotes",
"[",
"i",
"]",
"instanceof",
"Identifier",
"&&",
"!",
"Text",
".",
"isNull",
"(",
"(",
"(",
"Identifier",
")",
"remotes",
"[",
"i",
"]",
")",
".",
"getId",
"(",
")",
")",
")",
"{",
"rmiUrl",
"=",
"(",
"(",
"Identifier",
")",
"remotes",
"[",
"i",
"]",
")",
".",
"getId",
"(",
")",
";",
"}",
"else",
"{",
"//get rmiUrl\r",
"rmiUrl",
"=",
"Config",
".",
"getProperty",
"(",
"remotes",
"[",
"i",
"]",
".",
"getClass",
"(",
")",
",",
"\"bind.rmi.url\"",
")",
";",
"}",
"//rebind\r",
"rebind",
"(",
"rmiUrl",
",",
"remotes",
"[",
"i",
"]",
")",
";",
"}",
"}"
] | Bind all object.
Note that the rmiUrl in located in the config.properties
${class}.rmiUrl
Example: solutions.test.RemoteObjectText.bind.rmi.url=rmi://localhost:port/serviceName
Note that is the remote object is an instance of Identifier,
the object will be binded based on its "id" property if the value is provided
@param remotes the object to rebind | [
"Bind",
"all",
"object",
".",
"Note",
"that",
"the",
"rmiUrl",
"in",
"located",
"in",
"the",
"config",
".",
"properties"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/net/rmi/RMI.java#L158-L183 |
143,352 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/net/rmi/RMI.java | RMI.getRegistry | public static Registry getRegistry()
throws RemoteException
{
return LocateRegistry.getRegistry(Config.getProperty(RMI.class,"host"),
Config.getPropertyInteger(RMI.class,"port").intValue());
} | java | public static Registry getRegistry()
throws RemoteException
{
return LocateRegistry.getRegistry(Config.getProperty(RMI.class,"host"),
Config.getPropertyInteger(RMI.class,"port").intValue());
} | [
"public",
"static",
"Registry",
"getRegistry",
"(",
")",
"throws",
"RemoteException",
"{",
"return",
"LocateRegistry",
".",
"getRegistry",
"(",
"Config",
".",
"getProperty",
"(",
"RMI",
".",
"class",
",",
"\"host\"",
")",
",",
"Config",
".",
"getPropertyInteger",
"(",
"RMI",
".",
"class",
",",
"\"port\"",
")",
".",
"intValue",
"(",
")",
")",
";",
"}"
] | Create a new local registry on a local port
@return registry using configuration properties nyla.solutions.core.net.rmi.RMI.host nyla.solutions.core.net.rmi.RMI.port
@throws RemoteException unknown occurs RMI. | [
"Create",
"a",
"new",
"local",
"registry",
"on",
"a",
"local",
"port"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/net/rmi/RMI.java#L190-L195 |
143,353 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/memento/FileMemento.java | FileMemento.restore | public Object restore(String savePoint, Class<?> objClass)
{
String location = whereIs(savePoint, objClass);
Object cacheObject = CacheFarm.getCache().get(location);
if(cacheObject != null)
return cacheObject;
cacheObject = IO.deserialize(new File(location));
CacheFarm.getCache().put(location, cacheObject);
return cacheObject;
} | java | public Object restore(String savePoint, Class<?> objClass)
{
String location = whereIs(savePoint, objClass);
Object cacheObject = CacheFarm.getCache().get(location);
if(cacheObject != null)
return cacheObject;
cacheObject = IO.deserialize(new File(location));
CacheFarm.getCache().put(location, cacheObject);
return cacheObject;
} | [
"public",
"Object",
"restore",
"(",
"String",
"savePoint",
",",
"Class",
"<",
"?",
">",
"objClass",
")",
"{",
"String",
"location",
"=",
"whereIs",
"(",
"savePoint",
",",
"objClass",
")",
";",
"Object",
"cacheObject",
"=",
"CacheFarm",
".",
"getCache",
"(",
")",
".",
"get",
"(",
"location",
")",
";",
"if",
"(",
"cacheObject",
"!=",
"null",
")",
"return",
"cacheObject",
";",
"cacheObject",
"=",
"IO",
".",
"deserialize",
"(",
"new",
"File",
"(",
"location",
")",
")",
";",
"CacheFarm",
".",
"getCache",
"(",
")",
".",
"put",
"(",
"location",
",",
"cacheObject",
")",
";",
"return",
"cacheObject",
";",
"}"
] | Retrieve the de-serialized object
@param savePoint the save point
@param objClass the object class
@return the object the object | [
"Retrieve",
"the",
"de",
"-",
"serialized",
"object"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/memento/FileMemento.java#L33-L45 |
143,354 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/memento/FileMemento.java | FileMemento.store | public void store(String savePoint, Object obj)
{
if (savePoint == null)
throw new RequiredException("savePoint");
if (obj == null)
throw new RequiredException("obj");
String location = whereIs(savePoint, obj.getClass());
Debugger.println(this,"Storing in "+location);
IO.serializeToFile(obj, new File(location));
} | java | public void store(String savePoint, Object obj)
{
if (savePoint == null)
throw new RequiredException("savePoint");
if (obj == null)
throw new RequiredException("obj");
String location = whereIs(savePoint, obj.getClass());
Debugger.println(this,"Storing in "+location);
IO.serializeToFile(obj, new File(location));
} | [
"public",
"void",
"store",
"(",
"String",
"savePoint",
",",
"Object",
"obj",
")",
"{",
"if",
"(",
"savePoint",
"==",
"null",
")",
"throw",
"new",
"RequiredException",
"(",
"\"savePoint\"",
")",
";",
"if",
"(",
"obj",
"==",
"null",
")",
"throw",
"new",
"RequiredException",
"(",
"\"obj\"",
")",
";",
"String",
"location",
"=",
"whereIs",
"(",
"savePoint",
",",
"obj",
".",
"getClass",
"(",
")",
")",
";",
"Debugger",
".",
"println",
"(",
"this",
",",
"\"Storing in \"",
"+",
"location",
")",
";",
"IO",
".",
"serializeToFile",
"(",
"obj",
",",
"new",
"File",
"(",
"location",
")",
")",
";",
"}"
] | Store the serialized object
@param savePoint the save point
@param obj the object to save | [
"Store",
"the",
"serialized",
"object"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/memento/FileMemento.java#L52-L65 |
143,355 | jinahya/bit-io | src/main/java/com/github/jinahya/bit/io/BitIoConstraints.java | BitIoConstraints.requireValidExponent | static int requireValidExponent(final int exponent) {
if (exponent < MIN_EXPONENT) {
throw new IllegalArgumentException("exponent(" + exponent + ") < " + MIN_EXPONENT);
}
if (exponent > MAX_EXPONENT) {
throw new IllegalArgumentException("exponent(" + exponent + ") > " + MAX_EXPONENT);
}
return exponent;
} | java | static int requireValidExponent(final int exponent) {
if (exponent < MIN_EXPONENT) {
throw new IllegalArgumentException("exponent(" + exponent + ") < " + MIN_EXPONENT);
}
if (exponent > MAX_EXPONENT) {
throw new IllegalArgumentException("exponent(" + exponent + ") > " + MAX_EXPONENT);
}
return exponent;
} | [
"static",
"int",
"requireValidExponent",
"(",
"final",
"int",
"exponent",
")",
"{",
"if",
"(",
"exponent",
"<",
"MIN_EXPONENT",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"exponent(\"",
"+",
"exponent",
"+",
"\") < \"",
"+",
"MIN_EXPONENT",
")",
";",
"}",
"if",
"(",
"exponent",
">",
"MAX_EXPONENT",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"exponent(\"",
"+",
"exponent",
"+",
"\") > \"",
"+",
"MAX_EXPONENT",
")",
";",
"}",
"return",
"exponent",
";",
"}"
] | Validates given exponent.
@param exponent the exponent to validate.
@return given exponent. | [
"Validates",
"given",
"exponent",
"."
] | f3b49bbec80047c0cc3ea2424def98eb2d08352a | https://github.com/jinahya/bit-io/blob/f3b49bbec80047c0cc3ea2424def98eb2d08352a/src/main/java/com/github/jinahya/bit/io/BitIoConstraints.java#L79-L87 |
143,356 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/creational/builder/mapped/ReLookupTextMapFactory.java | ReLookupTextMapFactory.setLookupTable | public void setLookupTable(Map<String,Map<K,V>> lookupTable)
{
this.lookupTable = new TreeMap<String,Map<K,V>> (lookupTable);
} | java | public void setLookupTable(Map<String,Map<K,V>> lookupTable)
{
this.lookupTable = new TreeMap<String,Map<K,V>> (lookupTable);
} | [
"public",
"void",
"setLookupTable",
"(",
"Map",
"<",
"String",
",",
"Map",
"<",
"K",
",",
"V",
">",
">",
"lookupTable",
")",
"{",
"this",
".",
"lookupTable",
"=",
"new",
"TreeMap",
"<",
"String",
",",
"Map",
"<",
"K",
",",
"V",
">",
">",
"(",
"lookupTable",
")",
";",
"}"
] | The key of the lookup table is a regular expression
@param lookupTable the lookupTable to set | [
"The",
"key",
"of",
"the",
"lookup",
"table",
"is",
"a",
"regular",
"expression"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/creational/builder/mapped/ReLookupTextMapFactory.java#L62-L65 |
143,357 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/util/JavaBean.java | JavaBean.getProperty | @SuppressWarnings("unchecked")
public static <T> T getProperty(Object bean, String name)
throws SystemException
{
try
{
return (T)getNestedProperty(bean, name);
}
catch (Exception e)
{
throw new SystemException("Get property \""+name+"\" ERROR:"+e.getMessage(),e);
}
} | java | @SuppressWarnings("unchecked")
public static <T> T getProperty(Object bean, String name)
throws SystemException
{
try
{
return (T)getNestedProperty(bean, name);
}
catch (Exception e)
{
throw new SystemException("Get property \""+name+"\" ERROR:"+e.getMessage(),e);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"<",
"T",
">",
"T",
"getProperty",
"(",
"Object",
"bean",
",",
"String",
"name",
")",
"throws",
"SystemException",
"{",
"try",
"{",
"return",
"(",
"T",
")",
"getNestedProperty",
"(",
"bean",
",",
"name",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"SystemException",
"(",
"\"Get property \\\"\"",
"+",
"name",
"+",
"\"\\\" ERROR:\"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}"
] | Retrieve the bean property
@param bean the bean
@param name the property name
@param <T> the type class of the property for casting
@return the property
@throws SystemException the an unknown error occurs | [
"Retrieve",
"the",
"bean",
"property"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/JavaBean.java#L463-L475 |
143,358 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/util/JavaBean.java | JavaBean.getCollectionProperties | public static Collection<Object> getCollectionProperties(Collection<?> collection,String name)
throws Exception
{
if(collection == null)
throw new IllegalArgumentException("collection, name");
ArrayList<Object> list = new ArrayList<Object>(collection.size());
for (Object bean : collection)
{
list.add(getNestedProperty(bean, name));
}
return list;
} | java | public static Collection<Object> getCollectionProperties(Collection<?> collection,String name)
throws Exception
{
if(collection == null)
throw new IllegalArgumentException("collection, name");
ArrayList<Object> list = new ArrayList<Object>(collection.size());
for (Object bean : collection)
{
list.add(getNestedProperty(bean, name));
}
return list;
} | [
"public",
"static",
"Collection",
"<",
"Object",
">",
"getCollectionProperties",
"(",
"Collection",
"<",
"?",
">",
"collection",
",",
"String",
"name",
")",
"throws",
"Exception",
"{",
"if",
"(",
"collection",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"collection, name\"",
")",
";",
"ArrayList",
"<",
"Object",
">",
"list",
"=",
"new",
"ArrayList",
"<",
"Object",
">",
"(",
"collection",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"Object",
"bean",
":",
"collection",
")",
"{",
"list",
".",
"add",
"(",
"getNestedProperty",
"(",
"bean",
",",
"name",
")",
")",
";",
"}",
"return",
"list",
";",
"}"
] | Retrieve the list of properties that exists in a given collection
@param collection the collection of object
@param name the name of property
@return collection of objects
@throws Exception when an unknown error occurs | [
"Retrieve",
"the",
"list",
"of",
"properties",
"that",
"exists",
"in",
"a",
"given",
"collection"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/JavaBean.java#L565-L579 |
143,359 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/decorator/MacroTextDecorator.java | MacroTextDecorator.getText | public String getText()
{
//loop thru text
StringText stringText = new StringText();
stringText.setText(this.target.getText());
TextDecorator<Textable> textDecorator = null;
//loop thru decorator and get results from each
for(Iterator<TextDecorator<Textable>> i = textables.iterator();i.hasNext();)
{
textDecorator = i.next();
textDecorator.setTarget(stringText);
stringText.setText(textDecorator.getText());
}
return stringText.getText();
} | java | public String getText()
{
//loop thru text
StringText stringText = new StringText();
stringText.setText(this.target.getText());
TextDecorator<Textable> textDecorator = null;
//loop thru decorator and get results from each
for(Iterator<TextDecorator<Textable>> i = textables.iterator();i.hasNext();)
{
textDecorator = i.next();
textDecorator.setTarget(stringText);
stringText.setText(textDecorator.getText());
}
return stringText.getText();
} | [
"public",
"String",
"getText",
"(",
")",
"{",
"//loop thru text\r",
"StringText",
"stringText",
"=",
"new",
"StringText",
"(",
")",
";",
"stringText",
".",
"setText",
"(",
"this",
".",
"target",
".",
"getText",
"(",
")",
")",
";",
"TextDecorator",
"<",
"Textable",
">",
"textDecorator",
"=",
"null",
";",
"//loop thru decorator and get results from each\r",
"for",
"(",
"Iterator",
"<",
"TextDecorator",
"<",
"Textable",
">",
">",
"i",
"=",
"textables",
".",
"iterator",
"(",
")",
";",
"i",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"textDecorator",
"=",
"i",
".",
"next",
"(",
")",
";",
"textDecorator",
".",
"setTarget",
"(",
"stringText",
")",
";",
"stringText",
".",
"setText",
"(",
"textDecorator",
".",
"getText",
"(",
")",
")",
";",
"}",
"return",
"stringText",
".",
"getText",
"(",
")",
";",
"}"
] | Get the target text and execute each text decorator on its results
@return the text results | [
"Get",
"the",
"target",
"text",
"and",
"execute",
"each",
"text",
"decorator",
"on",
"its",
"results"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/decorator/MacroTextDecorator.java#L22-L41 |
143,360 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/data/Data.java | Data.sortByCriteria | public static <T> Collection<T> sortByCriteria(Collection<T> aVOs)
{
final List<T> list;
if (aVOs instanceof List)
list = (List<T>) aVOs;
else
list = new ArrayList<T>(aVOs);
Collections.sort(list, new CriteriaComparator());
return list;
} | java | public static <T> Collection<T> sortByCriteria(Collection<T> aVOs)
{
final List<T> list;
if (aVOs instanceof List)
list = (List<T>) aVOs;
else
list = new ArrayList<T>(aVOs);
Collections.sort(list, new CriteriaComparator());
return list;
} | [
"public",
"static",
"<",
"T",
">",
"Collection",
"<",
"T",
">",
"sortByCriteria",
"(",
"Collection",
"<",
"T",
">",
"aVOs",
")",
"{",
"final",
"List",
"<",
"T",
">",
"list",
";",
"if",
"(",
"aVOs",
"instanceof",
"List",
")",
"list",
"=",
"(",
"List",
"<",
"T",
">",
")",
"aVOs",
";",
"else",
"list",
"=",
"new",
"ArrayList",
"<",
"T",
">",
"(",
"aVOs",
")",
";",
"Collections",
".",
"sort",
"(",
"list",
",",
"new",
"CriteriaComparator",
"(",
")",
")",
";",
"return",
"list",
";",
"}"
] | Sort a list
@param <T> the type
@param aVOs the value objects
@return collection the sorted criteria | [
"Sort",
"a",
"list"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/data/Data.java#L103-L117 |
143,361 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/data/conversation/DateBag.java | DateBag.bag | @Override
public void bag(Date unBaggedObject)
{
if(unBaggedObject == null)
this.time = 0;
else
this.time = unBaggedObject.getTime();
} | java | @Override
public void bag(Date unBaggedObject)
{
if(unBaggedObject == null)
this.time = 0;
else
this.time = unBaggedObject.getTime();
} | [
"@",
"Override",
"public",
"void",
"bag",
"(",
"Date",
"unBaggedObject",
")",
"{",
"if",
"(",
"unBaggedObject",
"==",
"null",
")",
"this",
".",
"time",
"=",
"0",
";",
"else",
"this",
".",
"time",
"=",
"unBaggedObject",
".",
"getTime",
"(",
")",
";",
"}"
] | Wraps a given date in a format that can be easily unbagged | [
"Wraps",
"a",
"given",
"date",
"in",
"a",
"format",
"that",
"can",
"be",
"easily",
"unbagged"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/data/conversation/DateBag.java#L50-L58 |
143,362 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/util/PROXY.java | PROXY.findMethod | public static Method findMethod(Class<?> objClass, String methodName,
Class<?>[] parameterTypes) throws NoSuchMethodException
{
try
{
return objClass.getDeclaredMethod(methodName, parameterTypes);
}
catch (NoSuchMethodException e)
{
if (Object.class.equals(objClass))
throw e;
try
{
// try super
return findMethod(objClass.getSuperclass(), methodName,
parameterTypes);
}
catch(NoSuchMethodException parentException)
{
throw e;
}
}
} | java | public static Method findMethod(Class<?> objClass, String methodName,
Class<?>[] parameterTypes) throws NoSuchMethodException
{
try
{
return objClass.getDeclaredMethod(methodName, parameterTypes);
}
catch (NoSuchMethodException e)
{
if (Object.class.equals(objClass))
throw e;
try
{
// try super
return findMethod(objClass.getSuperclass(), methodName,
parameterTypes);
}
catch(NoSuchMethodException parentException)
{
throw e;
}
}
} | [
"public",
"static",
"Method",
"findMethod",
"(",
"Class",
"<",
"?",
">",
"objClass",
",",
"String",
"methodName",
",",
"Class",
"<",
"?",
">",
"[",
"]",
"parameterTypes",
")",
"throws",
"NoSuchMethodException",
"{",
"try",
"{",
"return",
"objClass",
".",
"getDeclaredMethod",
"(",
"methodName",
",",
"parameterTypes",
")",
";",
"}",
"catch",
"(",
"NoSuchMethodException",
"e",
")",
"{",
"if",
"(",
"Object",
".",
"class",
".",
"equals",
"(",
"objClass",
")",
")",
"throw",
"e",
";",
"try",
"{",
"// try super\r",
"return",
"findMethod",
"(",
"objClass",
".",
"getSuperclass",
"(",
")",
",",
"methodName",
",",
"parameterTypes",
")",
";",
"}",
"catch",
"(",
"NoSuchMethodException",
"parentException",
")",
"{",
"throw",
"e",
";",
"}",
"}",
"}"
] | Find the method for a target of its parent
@param objClass the object class
@param methodName the method name
@param parameterTypes the method parameter types
@return the method
@throws NoSuchMethodException | [
"Find",
"the",
"method",
"for",
"a",
"target",
"of",
"its",
"parent"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/PROXY.java#L60-L85 |
143,363 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/exception/fault/FaultFormatTextDecorator.java | FaultFormatTextDecorator.getText | @Override
public String getText()
{
if(this.target == null)
return null;
try
{
//Check if load of template needed
if((this.template == null || this.template.length() == 0) && this.templateName != null)
{
try
{
this.template = Text.loadTemplate(templateName);
}
catch(Exception e)
{
throw new SetupException("Cannot load template:"+templateName,e);
}
}
Map<Object,Object> faultMap = JavaBean.toMap(this.target);
if(this.argumentTextDecorator != null)
{
this.argumentTextDecorator.setTarget(this.target.getArgument());
faultMap.put(this.argumentKeyName, this.argumentTextDecorator.getText());
}
return Text.format(this.template, faultMap);
}
catch (FormatException e)
{
throw new FormatFaultException(this.template, e);
}
} | java | @Override
public String getText()
{
if(this.target == null)
return null;
try
{
//Check if load of template needed
if((this.template == null || this.template.length() == 0) && this.templateName != null)
{
try
{
this.template = Text.loadTemplate(templateName);
}
catch(Exception e)
{
throw new SetupException("Cannot load template:"+templateName,e);
}
}
Map<Object,Object> faultMap = JavaBean.toMap(this.target);
if(this.argumentTextDecorator != null)
{
this.argumentTextDecorator.setTarget(this.target.getArgument());
faultMap.put(this.argumentKeyName, this.argumentTextDecorator.getText());
}
return Text.format(this.template, faultMap);
}
catch (FormatException e)
{
throw new FormatFaultException(this.template, e);
}
} | [
"@",
"Override",
"public",
"String",
"getText",
"(",
")",
"{",
"if",
"(",
"this",
".",
"target",
"==",
"null",
")",
"return",
"null",
";",
"try",
"{",
"//Check if load of template needed",
"if",
"(",
"(",
"this",
".",
"template",
"==",
"null",
"||",
"this",
".",
"template",
".",
"length",
"(",
")",
"==",
"0",
")",
"&&",
"this",
".",
"templateName",
"!=",
"null",
")",
"{",
"try",
"{",
"this",
".",
"template",
"=",
"Text",
".",
"loadTemplate",
"(",
"templateName",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"SetupException",
"(",
"\"Cannot load template:\"",
"+",
"templateName",
",",
"e",
")",
";",
"}",
"}",
"Map",
"<",
"Object",
",",
"Object",
">",
"faultMap",
"=",
"JavaBean",
".",
"toMap",
"(",
"this",
".",
"target",
")",
";",
"if",
"(",
"this",
".",
"argumentTextDecorator",
"!=",
"null",
")",
"{",
"this",
".",
"argumentTextDecorator",
".",
"setTarget",
"(",
"this",
".",
"target",
".",
"getArgument",
"(",
")",
")",
";",
"faultMap",
".",
"put",
"(",
"this",
".",
"argumentKeyName",
",",
"this",
".",
"argumentTextDecorator",
".",
"getText",
"(",
")",
")",
";",
"}",
"return",
"Text",
".",
"format",
"(",
"this",
".",
"template",
",",
"faultMap",
")",
";",
"}",
"catch",
"(",
"FormatException",
"e",
")",
"{",
"throw",
"new",
"FormatFaultException",
"(",
"this",
".",
"template",
",",
"e",
")",
";",
"}",
"}"
] | Converts the target fault into a formatted text.
@see nyla.solutions.core.data.Textable#getText() | [
"Converts",
"the",
"target",
"fault",
"into",
"a",
"formatted",
"text",
"."
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/exception/fault/FaultFormatTextDecorator.java#L40-L80 |
143,364 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/io/csv/CsvWriter.java | CsvWriter.addCells | public static void addCells(StringBuilder builder, String... cells)
{
if(builder == null || cells == null || cells.length == 0)
return;
for (String cell : cells)
{
addCell(builder,cell);
}
} | java | public static void addCells(StringBuilder builder, String... cells)
{
if(builder == null || cells == null || cells.length == 0)
return;
for (String cell : cells)
{
addCell(builder,cell);
}
} | [
"public",
"static",
"void",
"addCells",
"(",
"StringBuilder",
"builder",
",",
"String",
"...",
"cells",
")",
"{",
"if",
"(",
"builder",
"==",
"null",
"||",
"cells",
"==",
"null",
"||",
"cells",
".",
"length",
"==",
"0",
")",
"return",
";",
"for",
"(",
"String",
"cell",
":",
"cells",
")",
"{",
"addCell",
"(",
"builder",
",",
"cell",
")",
";",
"}",
"}"
] | Add formatted CSV cells to a builder
@param builder the string builder
@param cells the cells to format as CSV cells in a row | [
"Add",
"formatted",
"CSV",
"cells",
"to",
"a",
"builder"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/io/csv/CsvWriter.java#L183-L192 |
143,365 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/io/csv/CsvWriter.java | CsvWriter.toCSV | public static String toCSV(String... cells)
{
if(cells == null || cells.length == 0)
return null;
StringBuilder builder = new StringBuilder();
addCells(builder, cells);
return builder.toString();
} | java | public static String toCSV(String... cells)
{
if(cells == null || cells.length == 0)
return null;
StringBuilder builder = new StringBuilder();
addCells(builder, cells);
return builder.toString();
} | [
"public",
"static",
"String",
"toCSV",
"(",
"String",
"...",
"cells",
")",
"{",
"if",
"(",
"cells",
"==",
"null",
"||",
"cells",
".",
"length",
"==",
"0",
")",
"return",
"null",
";",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"addCells",
"(",
"builder",
",",
"cells",
")",
";",
"return",
"builder",
".",
"toString",
"(",
")",
";",
"}"
] | Create a CSV line
@param cells the cells for format
@return the CSF formatted line | [
"Create",
"a",
"CSV",
"line"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/io/csv/CsvWriter.java#L198-L206 |
143,366 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/util/Cryption.java | Cryption.encryptText | public String encryptText(String text)
throws Exception
{
return toByteText(this.encrypt(text.getBytes(IO.CHARSET)));
} | java | public String encryptText(String text)
throws Exception
{
return toByteText(this.encrypt(text.getBytes(IO.CHARSET)));
} | [
"public",
"String",
"encryptText",
"(",
"String",
"text",
")",
"throws",
"Exception",
"{",
"return",
"toByteText",
"(",
"this",
".",
"encrypt",
"(",
"text",
".",
"getBytes",
"(",
"IO",
".",
"CHARSET",
")",
")",
")",
";",
"}"
] | The text to encrypt
@param text
the original text
@return the encrypted version of the text
@throws Exception | [
"The",
"text",
"to",
"encrypt"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/Cryption.java#L195-L200 |
143,367 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/util/Cryption.java | Cryption.main | public static void main(String[] args)
{
try
{
if (args.length == 0)
{
System.err.println("Usage java " + Cryption.class.getName()
+ " <text>");
return;
}
final String decryptedPassword;
if (args[0].equals("-d"))
{
if (args.length > 2)
{
StringBuilder p = new StringBuilder();
for (int i = 1; i < args.length; i++)
{
if (i > 1)
p.append(' ');
p.append(args[i]);
}
decryptedPassword = p.toString();
}
else
{
decryptedPassword = args[1];
}
System.out.println(getCanonical().decryptText(decryptedPassword));
}
else
System.out.println(CRYPTION_PREFIX
+ getCanonical().encryptText(args[0]));
}
catch (Exception e)
{
e.printStackTrace();
}
} | java | public static void main(String[] args)
{
try
{
if (args.length == 0)
{
System.err.println("Usage java " + Cryption.class.getName()
+ " <text>");
return;
}
final String decryptedPassword;
if (args[0].equals("-d"))
{
if (args.length > 2)
{
StringBuilder p = new StringBuilder();
for (int i = 1; i < args.length; i++)
{
if (i > 1)
p.append(' ');
p.append(args[i]);
}
decryptedPassword = p.toString();
}
else
{
decryptedPassword = args[1];
}
System.out.println(getCanonical().decryptText(decryptedPassword));
}
else
System.out.println(CRYPTION_PREFIX
+ getCanonical().encryptText(args[0]));
}
catch (Exception e)
{
e.printStackTrace();
}
} | [
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"try",
"{",
"if",
"(",
"args",
".",
"length",
"==",
"0",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"Usage java \"",
"+",
"Cryption",
".",
"class",
".",
"getName",
"(",
")",
"+",
"\" <text>\"",
")",
";",
"return",
";",
"}",
"final",
"String",
"decryptedPassword",
";",
"if",
"(",
"args",
"[",
"0",
"]",
".",
"equals",
"(",
"\"-d\"",
")",
")",
"{",
"if",
"(",
"args",
".",
"length",
">",
"2",
")",
"{",
"StringBuilder",
"p",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"args",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"i",
">",
"1",
")",
"p",
".",
"append",
"(",
"'",
"'",
")",
";",
"p",
".",
"append",
"(",
"args",
"[",
"i",
"]",
")",
";",
"}",
"decryptedPassword",
"=",
"p",
".",
"toString",
"(",
")",
";",
"}",
"else",
"{",
"decryptedPassword",
"=",
"args",
"[",
"1",
"]",
";",
"}",
"System",
".",
"out",
".",
"println",
"(",
"getCanonical",
"(",
")",
".",
"decryptText",
"(",
"decryptedPassword",
")",
")",
";",
"}",
"else",
"System",
".",
"out",
".",
"println",
"(",
"CRYPTION_PREFIX",
"+",
"getCanonical",
"(",
")",
".",
"encryptText",
"(",
"args",
"[",
"0",
"]",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}"
] | Encrypt a given values
@param args args[0] contains the value to encrypt | [
"Encrypt",
"a",
"given",
"values"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/Cryption.java#L336-L384 |
143,368 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/security/user/data/UserProfile.java | UserProfile.compareTo | @Override
public int compareTo(Object object)
{
if(!(object instanceof User))
{
return -1;
}
User user = (User)object;
return getLastName().compareTo(user.getLastName());
} | java | @Override
public int compareTo(Object object)
{
if(!(object instanceof User))
{
return -1;
}
User user = (User)object;
return getLastName().compareTo(user.getLastName());
} | [
"@",
"Override",
"public",
"int",
"compareTo",
"(",
"Object",
"object",
")",
"{",
"if",
"(",
"!",
"(",
"object",
"instanceof",
"User",
")",
")",
"{",
"return",
"-",
"1",
";",
"}",
"User",
"user",
"=",
"(",
"User",
")",
"object",
";",
"return",
"getLastName",
"(",
")",
".",
"compareTo",
"(",
"user",
".",
"getLastName",
"(",
")",
")",
";",
"}"
] | Compare user's by last name
@see java.lang.Comparable#compareTo(java.lang.Object) | [
"Compare",
"user",
"s",
"by",
"last",
"name"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/security/user/data/UserProfile.java#L116-L128 |
143,369 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/creational/proxy/ObjectProxy.java | ObjectProxy.executeMethod | public static Object executeMethod(Object object, MethodCallFact methodCallFact)
throws Exception
{
if (object == null)
throw new RequiredException("object");
if (methodCallFact == null)
throw new RequiredException("methodCallFact");
return executeMethod(object, methodCallFact.getMethodName(),methodCallFact.getArguments());
} | java | public static Object executeMethod(Object object, MethodCallFact methodCallFact)
throws Exception
{
if (object == null)
throw new RequiredException("object");
if (methodCallFact == null)
throw new RequiredException("methodCallFact");
return executeMethod(object, methodCallFact.getMethodName(),methodCallFact.getArguments());
} | [
"public",
"static",
"Object",
"executeMethod",
"(",
"Object",
"object",
",",
"MethodCallFact",
"methodCallFact",
")",
"throws",
"Exception",
"{",
"if",
"(",
"object",
"==",
"null",
")",
"throw",
"new",
"RequiredException",
"(",
"\"object\"",
")",
";",
"if",
"(",
"methodCallFact",
"==",
"null",
")",
"throw",
"new",
"RequiredException",
"(",
"\"methodCallFact\"",
")",
";",
"return",
"executeMethod",
"(",
"object",
",",
"methodCallFact",
".",
"getMethodName",
"(",
")",
",",
"methodCallFact",
".",
"getArguments",
"(",
")",
")",
";",
"}"
] | Execute the method call on a object
@param object the target object that contains the method
@param methodCallFact the method call information
@return the return object of the method call
@throws Exception | [
"Execute",
"the",
"method",
"call",
"on",
"a",
"object"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/creational/proxy/ObjectProxy.java#L23-L33 |
143,370 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/servicefactory/ConfigServiceFactory.java | ConfigServiceFactory.setUp | public synchronized void setUp()
{
if(initialized)
return;
String className = null;
//Load
Map<Object,Object> properties = settings.getProperties();
String key = null;
Object serviceObject = null;
for(Map.Entry<Object,Object> entry : properties.entrySet())
{
key = String.valueOf(entry.getKey());
if(key.startsWith(PROP_PREFIX))
{
try
{
className = (String)entry.getValue();
serviceObject = ClassPath.newInstance(className);
factoryMap.put(key, serviceObject);
}
catch (Throwable e)
{
throw new SetupException("CLASS:"+className+" ERROR:"+e.getMessage(),e);
}
}
}
initialized = true;
} | java | public synchronized void setUp()
{
if(initialized)
return;
String className = null;
//Load
Map<Object,Object> properties = settings.getProperties();
String key = null;
Object serviceObject = null;
for(Map.Entry<Object,Object> entry : properties.entrySet())
{
key = String.valueOf(entry.getKey());
if(key.startsWith(PROP_PREFIX))
{
try
{
className = (String)entry.getValue();
serviceObject = ClassPath.newInstance(className);
factoryMap.put(key, serviceObject);
}
catch (Throwable e)
{
throw new SetupException("CLASS:"+className+" ERROR:"+e.getMessage(),e);
}
}
}
initialized = true;
} | [
"public",
"synchronized",
"void",
"setUp",
"(",
")",
"{",
"if",
"(",
"initialized",
")",
"return",
";",
"String",
"className",
"=",
"null",
";",
"//Load\r",
"Map",
"<",
"Object",
",",
"Object",
">",
"properties",
"=",
"settings",
".",
"getProperties",
"(",
")",
";",
"String",
"key",
"=",
"null",
";",
"Object",
"serviceObject",
"=",
"null",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"Object",
",",
"Object",
">",
"entry",
":",
"properties",
".",
"entrySet",
"(",
")",
")",
"{",
"key",
"=",
"String",
".",
"valueOf",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
";",
"if",
"(",
"key",
".",
"startsWith",
"(",
"PROP_PREFIX",
")",
")",
"{",
"try",
"{",
"className",
"=",
"(",
"String",
")",
"entry",
".",
"getValue",
"(",
")",
";",
"serviceObject",
"=",
"ClassPath",
".",
"newInstance",
"(",
"className",
")",
";",
"factoryMap",
".",
"put",
"(",
"key",
",",
"serviceObject",
")",
";",
"}",
"catch",
"(",
"Throwable",
"e",
")",
"{",
"throw",
"new",
"SetupException",
"(",
"\"CLASS:\"",
"+",
"className",
"+",
"\" ERROR:\"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}",
"}",
"initialized",
"=",
"true",
";",
"}"
] | Setup the factory beans | [
"Setup",
"the",
"factory",
"beans"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/servicefactory/ConfigServiceFactory.java#L63-L98 |
143,371 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/ds/ActiveDirectory.java | ActiveDirectory.getValidURL | private String getValidURL(String url)
{
if (url != null && url.length() > 0)
{
// XXX really important that this one happens first!!
return url.replaceAll("[%]", "%25")
.replaceAll(" ", "%20")
.replaceAll("[<]", "%3c")
.replaceAll("[>]", "%3e")
.replaceAll("[\"]", "%3f")
.replaceAll("[#]", "%23")
.replaceAll("[{]", "%7b")
.replaceAll("[}]", "%7d")
.replaceAll("[|]", "%7c")
.replaceAll("[\\\\]", "%5c") // double check this
// one :-)
.replaceAll("[\\^]", "%5e")
.replaceAll("[~]", "%7e")
.replaceAll("[\\[]", "%5b")
.replaceAll("[\\]]", "%5d")
.replaceAll("[']", "%27")
.replaceAll("[?]", "%3f");
}
return url;
} | java | private String getValidURL(String url)
{
if (url != null && url.length() > 0)
{
// XXX really important that this one happens first!!
return url.replaceAll("[%]", "%25")
.replaceAll(" ", "%20")
.replaceAll("[<]", "%3c")
.replaceAll("[>]", "%3e")
.replaceAll("[\"]", "%3f")
.replaceAll("[#]", "%23")
.replaceAll("[{]", "%7b")
.replaceAll("[}]", "%7d")
.replaceAll("[|]", "%7c")
.replaceAll("[\\\\]", "%5c") // double check this
// one :-)
.replaceAll("[\\^]", "%5e")
.replaceAll("[~]", "%7e")
.replaceAll("[\\[]", "%5b")
.replaceAll("[\\]]", "%5d")
.replaceAll("[']", "%27")
.replaceAll("[?]", "%3f");
}
return url;
} | [
"private",
"String",
"getValidURL",
"(",
"String",
"url",
")",
"{",
"if",
"(",
"url",
"!=",
"null",
"&&",
"url",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"// XXX really important that this one happens first!!\r",
"return",
"url",
".",
"replaceAll",
"(",
"\"[%]\"",
",",
"\"%25\"",
")",
".",
"replaceAll",
"(",
"\" \"",
",",
"\"%20\"",
")",
".",
"replaceAll",
"(",
"\"[<]\"",
",",
"\"%3c\"",
")",
".",
"replaceAll",
"(",
"\"[>]\"",
",",
"\"%3e\"",
")",
".",
"replaceAll",
"(",
"\"[\\\"]\"",
",",
"\"%3f\"",
")",
".",
"replaceAll",
"(",
"\"[#]\"",
",",
"\"%23\"",
")",
".",
"replaceAll",
"(",
"\"[{]\"",
",",
"\"%7b\"",
")",
".",
"replaceAll",
"(",
"\"[}]\"",
",",
"\"%7d\"",
")",
".",
"replaceAll",
"(",
"\"[|]\"",
",",
"\"%7c\"",
")",
".",
"replaceAll",
"(",
"\"[\\\\\\\\]\"",
",",
"\"%5c\"",
")",
"// double check this\r",
"// one :-)\r",
".",
"replaceAll",
"(",
"\"[\\\\^]\"",
",",
"\"%5e\"",
")",
".",
"replaceAll",
"(",
"\"[~]\"",
",",
"\"%7e\"",
")",
".",
"replaceAll",
"(",
"\"[\\\\[]\"",
",",
"\"%5b\"",
")",
".",
"replaceAll",
"(",
"\"[\\\\]]\"",
",",
"\"%5d\"",
")",
".",
"replaceAll",
"(",
"\"[']\"",
",",
"\"%27\"",
")",
".",
"replaceAll",
"(",
"\"[?]\"",
",",
"\"%3f\"",
")",
";",
"}",
"return",
"url",
";",
"}"
] | Returns valid LDAP URL for the specified URL.
@param url
the URL to convert to the valid URL | [
"Returns",
"valid",
"LDAP",
"URL",
"for",
"the",
"specified",
"URL",
"."
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/ds/ActiveDirectory.java#L132-L158 |
143,372 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/ds/ActiveDirectory.java | ActiveDirectory.setupSimpleSecurityProperties | private static void setupSimpleSecurityProperties(Hashtable<String,Object> env,
String userDn, char[] pwd)
{
// 'simple' = username + password
env.put(Context.SECURITY_AUTHENTICATION, "simple");
// add the full user dn
env.put(Context.SECURITY_PRINCIPAL, userDn);
// set password
env.put(Context.SECURITY_CREDENTIALS, new String(pwd));
} | java | private static void setupSimpleSecurityProperties(Hashtable<String,Object> env,
String userDn, char[] pwd)
{
// 'simple' = username + password
env.put(Context.SECURITY_AUTHENTICATION, "simple");
// add the full user dn
env.put(Context.SECURITY_PRINCIPAL, userDn);
// set password
env.put(Context.SECURITY_CREDENTIALS, new String(pwd));
} | [
"private",
"static",
"void",
"setupSimpleSecurityProperties",
"(",
"Hashtable",
"<",
"String",
",",
"Object",
">",
"env",
",",
"String",
"userDn",
",",
"char",
"[",
"]",
"pwd",
")",
"{",
"// 'simple' = username + password\r",
"env",
".",
"put",
"(",
"Context",
".",
"SECURITY_AUTHENTICATION",
",",
"\"simple\"",
")",
";",
"// add the full user dn\r",
"env",
".",
"put",
"(",
"Context",
".",
"SECURITY_PRINCIPAL",
",",
"userDn",
")",
";",
"// set password\r",
"env",
".",
"put",
"(",
"Context",
".",
"SECURITY_CREDENTIALS",
",",
"new",
"String",
"(",
"pwd",
")",
")",
";",
"}"
] | Sets the environment properties needed for a simple username + password
authenticated jndi connection.
@param env
The LDAP security environment
@param userDn
The user distinguished name
@param pwd
The user password | [
"Sets",
"the",
"environment",
"properties",
"needed",
"for",
"a",
"simple",
"username",
"+",
"password",
"authenticated",
"jndi",
"connection",
"."
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/ds/ActiveDirectory.java#L171-L182 |
143,373 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/ds/ActiveDirectory.java | ActiveDirectory.setupBasicProperties | private Hashtable<?,?> setupBasicProperties(Hashtable<String,Object> env)
throws NamingException
{
return setupBasicProperties(env,this.fullUrl);
} | java | private Hashtable<?,?> setupBasicProperties(Hashtable<String,Object> env)
throws NamingException
{
return setupBasicProperties(env,this.fullUrl);
} | [
"private",
"Hashtable",
"<",
"?",
",",
"?",
">",
"setupBasicProperties",
"(",
"Hashtable",
"<",
"String",
",",
"Object",
">",
"env",
")",
"throws",
"NamingException",
"{",
"return",
"setupBasicProperties",
"(",
"env",
",",
"this",
".",
"fullUrl",
")",
";",
"}"
] | Sets basic LDAP connection properties in env.
@param env
The LDAP security environment
@param url
The LDAP URL
@param tracing
LDAP tracing level. Output to System.err
@param referralType
Referral type: follow, ignore, or throw
@param aliasType
Alias type: finding, searching, etc.
@throws NamingException
Thrown if the passed in values are invalid | [
"Sets",
"basic",
"LDAP",
"connection",
"properties",
"in",
"env",
"."
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/ds/ActiveDirectory.java#L200-L204 |
143,374 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/util/Config.java | Config.getProperty | public static String getProperty(Class<?> aClass,String key,ResourceBundle resourceBundle)
{
return getSettings().getProperty(aClass, key, resourceBundle);
} | java | public static String getProperty(Class<?> aClass,String key,ResourceBundle resourceBundle)
{
return getSettings().getProperty(aClass, key, resourceBundle);
} | [
"public",
"static",
"String",
"getProperty",
"(",
"Class",
"<",
"?",
">",
"aClass",
",",
"String",
"key",
",",
"ResourceBundle",
"resourceBundle",
")",
"{",
"return",
"getSettings",
"(",
")",
".",
"getProperty",
"(",
"aClass",
",",
"key",
",",
"resourceBundle",
")",
";",
"}"
] | Get the property
@param aClass the class associate with property
@param key the property key
@param resourceBundle the resource bundle default used if property not found
@return the property key | [
"Get",
"the",
"property"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/Config.java#L172-L175 |
143,375 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/util/Config.java | Config.getProperty | public static String getProperty(String key, String aDefault)
{
return getSettings().getProperty(key, aDefault);
} | java | public static String getProperty(String key, String aDefault)
{
return getSettings().getProperty(key, aDefault);
} | [
"public",
"static",
"String",
"getProperty",
"(",
"String",
"key",
",",
"String",
"aDefault",
")",
"{",
"return",
"getSettings",
"(",
")",
".",
"getProperty",
"(",
"key",
",",
"aDefault",
")",
";",
"}"
] | Retrieves a configuration property as a String object.
Loads the file if not already initialized.
@param key Key Name of the property to be returned.
@param aDefault the default value
@return Value of the property as a string or null if no property found. | [
"Retrieves",
"a",
"configuration",
"property",
"as",
"a",
"String",
"object",
"."
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/Config.java#L251-L255 |
143,376 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/util/Config.java | Config.getPropertyInteger | public static Integer getPropertyInteger(Class<?> aClass, String key,
int defaultValue)
{
return getSettings().getPropertyInteger(key, defaultValue);
} | java | public static Integer getPropertyInteger(Class<?> aClass, String key,
int defaultValue)
{
return getSettings().getPropertyInteger(key, defaultValue);
} | [
"public",
"static",
"Integer",
"getPropertyInteger",
"(",
"Class",
"<",
"?",
">",
"aClass",
",",
"String",
"key",
",",
"int",
"defaultValue",
")",
"{",
"return",
"getSettings",
"(",
")",
".",
"getPropertyInteger",
"(",
"key",
",",
"defaultValue",
")",
";",
"}"
] | Get a configuration property as an Integer object.
@param aClass calling class
@param key the Key Name of the numeric property to be returned.
@param defaultValue the default value
@return Value of the property as an Integer or null if no property found. | [
"Get",
"a",
"configuration",
"property",
"as",
"an",
"Integer",
"object",
"."
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/Config.java#L266-L270 |
143,377 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/util/Config.java | Config.getPropertyCharacter | public static Character getPropertyCharacter(Class<?> aClass, String key,
char defaultValue)
{
return getSettings().getPropertyCharacter(aClass, key, defaultValue);
} | java | public static Character getPropertyCharacter(Class<?> aClass, String key,
char defaultValue)
{
return getSettings().getPropertyCharacter(aClass, key, defaultValue);
} | [
"public",
"static",
"Character",
"getPropertyCharacter",
"(",
"Class",
"<",
"?",
">",
"aClass",
",",
"String",
"key",
",",
"char",
"defaultValue",
")",
"{",
"return",
"getSettings",
"(",
")",
".",
"getPropertyCharacter",
"(",
"aClass",
",",
"key",
",",
"defaultValue",
")",
";",
"}"
] | Get a configuration property as an c object.
@param aClass the class the property is related to
@param key the configuration name
@param defaultValue the default value to return if the property does not
exist
@return the configuration character | [
"Get",
"a",
"configuration",
"property",
"as",
"an",
"c",
"object",
"."
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/Config.java#L283-L288 |
143,378 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/util/Config.java | Config.getPropertyPassword | public static char[] getPropertyPassword(Class<?> aClass, String key,
char[] defaultPassword)
{
return getSettings().getPropertyPassword(aClass, key, defaultPassword);
} | java | public static char[] getPropertyPassword(Class<?> aClass, String key,
char[] defaultPassword)
{
return getSettings().getPropertyPassword(aClass, key, defaultPassword);
} | [
"public",
"static",
"char",
"[",
"]",
"getPropertyPassword",
"(",
"Class",
"<",
"?",
">",
"aClass",
",",
"String",
"key",
",",
"char",
"[",
"]",
"defaultPassword",
")",
"{",
"return",
"getSettings",
"(",
")",
".",
"getPropertyPassword",
"(",
"aClass",
",",
"key",
",",
"defaultPassword",
")",
";",
"}"
] | Retrieve the password
@param aClass the class name
@param key the configuration key
@param defaultPassword default value
@return defaultPassword if the configuration value for the key is blank | [
"Retrieve",
"the",
"password"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/Config.java#L511-L515 |
143,379 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/util/Organizer.java | Organizer.addAll | public static <T> void addAll(Collection<T> pagingResults, Collection<T> paging, BooleanExpression<T> filter)
{
if (pagingResults == null || paging == null)
return;
if (filter != null)
{
for (T obj : paging)
{
if (filter.apply(obj))
pagingResults.add(obj);
}
}
else
{
// add independent of a filter
for (T obj : paging)
{
pagingResults.add(obj);
}
}
} | java | public static <T> void addAll(Collection<T> pagingResults, Collection<T> paging, BooleanExpression<T> filter)
{
if (pagingResults == null || paging == null)
return;
if (filter != null)
{
for (T obj : paging)
{
if (filter.apply(obj))
pagingResults.add(obj);
}
}
else
{
// add independent of a filter
for (T obj : paging)
{
pagingResults.add(obj);
}
}
} | [
"public",
"static",
"<",
"T",
">",
"void",
"addAll",
"(",
"Collection",
"<",
"T",
">",
"pagingResults",
",",
"Collection",
"<",
"T",
">",
"paging",
",",
"BooleanExpression",
"<",
"T",
">",
"filter",
")",
"{",
"if",
"(",
"pagingResults",
"==",
"null",
"||",
"paging",
"==",
"null",
")",
"return",
";",
"if",
"(",
"filter",
"!=",
"null",
")",
"{",
"for",
"(",
"T",
"obj",
":",
"paging",
")",
"{",
"if",
"(",
"filter",
".",
"apply",
"(",
"obj",
")",
")",
"pagingResults",
".",
"add",
"(",
"obj",
")",
";",
"}",
"}",
"else",
"{",
"// add independent of a filter\r",
"for",
"(",
"T",
"obj",
":",
"paging",
")",
"{",
"pagingResults",
".",
"add",
"(",
"obj",
")",
";",
"}",
"}",
"}"
] | Add all collections
@param <T>
the type class
@param paging
the paging output
@param pagingResults
the results to add to
@param filter
remove object where filter.getBoolean() == true | [
"Add",
"all",
"collections"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/Organizer.java#L295-L316 |
143,380 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/util/Organizer.java | Organizer.findMapValueByKey | public static Object findMapValueByKey(Object key, Map<?, ?> map,
Object defaultValue)
{
if (key == null || map == null)
return defaultValue;
Object value = map.get(key);
if (value == null)
return defaultValue;
return value;
} | java | public static Object findMapValueByKey(Object key, Map<?, ?> map,
Object defaultValue)
{
if (key == null || map == null)
return defaultValue;
Object value = map.get(key);
if (value == null)
return defaultValue;
return value;
} | [
"public",
"static",
"Object",
"findMapValueByKey",
"(",
"Object",
"key",
",",
"Map",
"<",
"?",
",",
"?",
">",
"map",
",",
"Object",
"defaultValue",
")",
"{",
"if",
"(",
"key",
"==",
"null",
"||",
"map",
"==",
"null",
")",
"return",
"defaultValue",
";",
"Object",
"value",
"=",
"map",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"value",
"==",
"null",
")",
"return",
"defaultValue",
";",
"return",
"value",
";",
"}"
] | Find the value with a given key in the map.
@param key
the map key
@param map
the map with key/value pairs
@param defaultValue
this is returned if the value is now found
@return the single value found | [
"Find",
"the",
"value",
"with",
"a",
"given",
"key",
"in",
"the",
"map",
"."
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/Organizer.java#L455-L467 |
143,381 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/util/Organizer.java | Organizer.addAll | public static void addAll(Collection<Object> list, Object[] objects)
{
list.addAll(Arrays.asList(objects));
} | java | public static void addAll(Collection<Object> list, Object[] objects)
{
list.addAll(Arrays.asList(objects));
} | [
"public",
"static",
"void",
"addAll",
"(",
"Collection",
"<",
"Object",
">",
"list",
",",
"Object",
"[",
"]",
"objects",
")",
"{",
"list",
".",
"addAll",
"(",
"Arrays",
".",
"asList",
"(",
"objects",
")",
")",
";",
"}"
] | Add object to a list
@param list
where objects will be added
@param objects
the object add | [
"Add",
"object",
"to",
"a",
"list"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/Organizer.java#L525-L528 |
143,382 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/util/Organizer.java | Organizer.copyToArray | public static void copyToArray(Collection<Object> collection, Object[] objects)
{
System.arraycopy(collection.toArray(), 0, objects, 0, objects.length);
} | java | public static void copyToArray(Collection<Object> collection, Object[] objects)
{
System.arraycopy(collection.toArray(), 0, objects, 0, objects.length);
} | [
"public",
"static",
"void",
"copyToArray",
"(",
"Collection",
"<",
"Object",
">",
"collection",
",",
"Object",
"[",
"]",
"objects",
")",
"{",
"System",
".",
"arraycopy",
"(",
"collection",
".",
"toArray",
"(",
")",
",",
"0",
",",
"objects",
",",
"0",
",",
"objects",
".",
"length",
")",
";",
"}"
] | Copy collection objects to a given array
@param collection
the collection source
@param objects
array destination | [
"Copy",
"collection",
"objects",
"to",
"a",
"given",
"array"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/Organizer.java#L608-L611 |
143,383 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/util/Organizer.java | Organizer.addMappableCopiesToMap | public static <K, V> void addMappableCopiesToMap(Collection<Mappable<K, V>> aMappables, Map<K, V> aMap)
{
if (aMappables == null || aMap == null)
return;
Mappable<K, V> mappable = null;
Copier previous = null;
for (Iterator<Mappable<K, V>> i = aMappables.iterator(); i.hasNext();)
{
mappable = i.next();
previous = (Copier) aMap.get(mappable.getKey());
if (previous != null)
{
// copy data
previous.copy((Copier) mappable);
}
else
{
// add to map
aMap.put((K) mappable.getKey(), (V) mappable.getValue());
}
}
} | java | public static <K, V> void addMappableCopiesToMap(Collection<Mappable<K, V>> aMappables, Map<K, V> aMap)
{
if (aMappables == null || aMap == null)
return;
Mappable<K, V> mappable = null;
Copier previous = null;
for (Iterator<Mappable<K, V>> i = aMappables.iterator(); i.hasNext();)
{
mappable = i.next();
previous = (Copier) aMap.get(mappable.getKey());
if (previous != null)
{
// copy data
previous.copy((Copier) mappable);
}
else
{
// add to map
aMap.put((K) mappable.getKey(), (V) mappable.getValue());
}
}
} | [
"public",
"static",
"<",
"K",
",",
"V",
">",
"void",
"addMappableCopiesToMap",
"(",
"Collection",
"<",
"Mappable",
"<",
"K",
",",
"V",
">",
">",
"aMappables",
",",
"Map",
"<",
"K",
",",
"V",
">",
"aMap",
")",
"{",
"if",
"(",
"aMappables",
"==",
"null",
"||",
"aMap",
"==",
"null",
")",
"return",
";",
"Mappable",
"<",
"K",
",",
"V",
">",
"mappable",
"=",
"null",
";",
"Copier",
"previous",
"=",
"null",
";",
"for",
"(",
"Iterator",
"<",
"Mappable",
"<",
"K",
",",
"V",
">",
">",
"i",
"=",
"aMappables",
".",
"iterator",
"(",
")",
";",
"i",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"mappable",
"=",
"i",
".",
"next",
"(",
")",
";",
"previous",
"=",
"(",
"Copier",
")",
"aMap",
".",
"get",
"(",
"mappable",
".",
"getKey",
"(",
")",
")",
";",
"if",
"(",
"previous",
"!=",
"null",
")",
"{",
"// copy data\r",
"previous",
".",
"copy",
"(",
"(",
"Copier",
")",
"mappable",
")",
";",
"}",
"else",
"{",
"// add to map\r",
"aMap",
".",
"put",
"(",
"(",
"K",
")",
"mappable",
".",
"getKey",
"(",
")",
",",
"(",
"V",
")",
"mappable",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"}"
] | Add mappable to map
@param <K>
the key
@param <V>
the value
@param aMappables
the collection of Mappables that must implement the Copier
interface
@param aMap
the map to add to | [
"Add",
"mappable",
"to",
"map"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/Organizer.java#L626-L650 |
143,384 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/util/Organizer.java | Organizer.findMapValuesByKey | public static <T, K> Collection<T> findMapValuesByKey(Collection<K> aKeys,
Map<K, T> aMap)
{
if (aKeys == null || aMap == null)
return null;
Object key = null;
ArrayList<T> results = new ArrayList<T>(aMap.size());
for (Iterator<K> i = aKeys.iterator(); i.hasNext();)
{
key = i.next();
results.add(aMap.get(key));
}
results.trimToSize();
return results;
} | java | public static <T, K> Collection<T> findMapValuesByKey(Collection<K> aKeys,
Map<K, T> aMap)
{
if (aKeys == null || aMap == null)
return null;
Object key = null;
ArrayList<T> results = new ArrayList<T>(aMap.size());
for (Iterator<K> i = aKeys.iterator(); i.hasNext();)
{
key = i.next();
results.add(aMap.get(key));
}
results.trimToSize();
return results;
} | [
"public",
"static",
"<",
"T",
",",
"K",
">",
"Collection",
"<",
"T",
">",
"findMapValuesByKey",
"(",
"Collection",
"<",
"K",
">",
"aKeys",
",",
"Map",
"<",
"K",
",",
"T",
">",
"aMap",
")",
"{",
"if",
"(",
"aKeys",
"==",
"null",
"||",
"aMap",
"==",
"null",
")",
"return",
"null",
";",
"Object",
"key",
"=",
"null",
";",
"ArrayList",
"<",
"T",
">",
"results",
"=",
"new",
"ArrayList",
"<",
"T",
">",
"(",
"aMap",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"Iterator",
"<",
"K",
">",
"i",
"=",
"aKeys",
".",
"iterator",
"(",
")",
";",
"i",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"key",
"=",
"i",
".",
"next",
"(",
")",
";",
"results",
".",
"add",
"(",
"aMap",
".",
"get",
"(",
"key",
")",
")",
";",
"}",
"results",
".",
"trimToSize",
"(",
")",
";",
"return",
"results",
";",
"}"
] | Find values in map that match a given key
@param <K>
the key type
@param <T>
the map value type
@param aKeys
the keys
@param aMap
the map containing the data
@return Collection of values | [
"Find",
"values",
"in",
"map",
"that",
"match",
"a",
"given",
"key"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/Organizer.java#L665-L682 |
143,385 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/util/Organizer.java | Organizer.addAll | public static <T> void addAll(Collection<T> aFrom, Collection<T> aTo)
{
if (aFrom == null || aTo == null)
return; // do nothing
T object = null;
for (Iterator<T> i = aFrom.iterator(); i.hasNext();)
{
object = i.next();
if (object != null)
{
aTo.add(object);
}
}
} | java | public static <T> void addAll(Collection<T> aFrom, Collection<T> aTo)
{
if (aFrom == null || aTo == null)
return; // do nothing
T object = null;
for (Iterator<T> i = aFrom.iterator(); i.hasNext();)
{
object = i.next();
if (object != null)
{
aTo.add(object);
}
}
} | [
"public",
"static",
"<",
"T",
">",
"void",
"addAll",
"(",
"Collection",
"<",
"T",
">",
"aFrom",
",",
"Collection",
"<",
"T",
">",
"aTo",
")",
"{",
"if",
"(",
"aFrom",
"==",
"null",
"||",
"aTo",
"==",
"null",
")",
"return",
";",
"// do nothing\r",
"T",
"object",
"=",
"null",
";",
"for",
"(",
"Iterator",
"<",
"T",
">",
"i",
"=",
"aFrom",
".",
"iterator",
"(",
")",
";",
"i",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"object",
"=",
"i",
".",
"next",
"(",
")",
";",
"if",
"(",
"object",
"!=",
"null",
")",
"{",
"aTo",
".",
"add",
"(",
"object",
")",
";",
"}",
"}",
"}"
] | All object to a given collection
@param <T>
the type class
@param aFrom
the collection to add from
@param aTo
the collection to add to. | [
"All",
"object",
"to",
"a",
"given",
"collection"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/Organizer.java#L694-L708 |
143,386 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/util/Organizer.java | Organizer.constructCriteriaMap | public static Map<String, Criteria> constructCriteriaMap(Collection<Criteria> aCriterias)
{
if (aCriterias == null)
return null;
Map<String, Criteria> map = new HashMap<String, Criteria>(aCriterias.size());
Criteria criteria = null;
for (Iterator<Criteria> i = aCriterias.iterator(); i.hasNext();)
{
criteria = (Criteria) i.next();
map.put(criteria.getId(), criteria);
}
return map;
} | java | public static Map<String, Criteria> constructCriteriaMap(Collection<Criteria> aCriterias)
{
if (aCriterias == null)
return null;
Map<String, Criteria> map = new HashMap<String, Criteria>(aCriterias.size());
Criteria criteria = null;
for (Iterator<Criteria> i = aCriterias.iterator(); i.hasNext();)
{
criteria = (Criteria) i.next();
map.put(criteria.getId(), criteria);
}
return map;
} | [
"public",
"static",
"Map",
"<",
"String",
",",
"Criteria",
">",
"constructCriteriaMap",
"(",
"Collection",
"<",
"Criteria",
">",
"aCriterias",
")",
"{",
"if",
"(",
"aCriterias",
"==",
"null",
")",
"return",
"null",
";",
"Map",
"<",
"String",
",",
"Criteria",
">",
"map",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Criteria",
">",
"(",
"aCriterias",
".",
"size",
"(",
")",
")",
";",
"Criteria",
"criteria",
"=",
"null",
";",
"for",
"(",
"Iterator",
"<",
"Criteria",
">",
"i",
"=",
"aCriterias",
".",
"iterator",
"(",
")",
";",
"i",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"criteria",
"=",
"(",
"Criteria",
")",
"i",
".",
"next",
"(",
")",
";",
"map",
".",
"put",
"(",
"criteria",
".",
"getId",
"(",
")",
",",
"criteria",
")",
";",
"}",
"return",
"map",
";",
"}"
] | construct map for collection of criteria object wher the key is
Criteria.getId
@param aCriterias
@return the map Criteria is the value and Criteria.getId is the key | [
"construct",
"map",
"for",
"collection",
"of",
"criteria",
"object",
"wher",
"the",
"key",
"is",
"Criteria",
".",
"getId"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/Organizer.java#L755-L768 |
143,387 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/util/Organizer.java | Organizer.constructPrimaryKeyMap | public static Map<Integer, PrimaryKey> constructPrimaryKeyMap(Collection<PrimaryKey> aPrimaryKeys)
{
if (aPrimaryKeys == null)
return null;
Map<Integer, PrimaryKey> map = new HashMap<Integer, PrimaryKey>(aPrimaryKeys.size());
PrimaryKey primaryKey = null;
for (Iterator<PrimaryKey> i = aPrimaryKeys.iterator(); i.hasNext();)
{
primaryKey = (PrimaryKey) i.next();
map.put(Integer.valueOf(primaryKey.getPrimaryKey()), primaryKey);
}
return map;
} | java | public static Map<Integer, PrimaryKey> constructPrimaryKeyMap(Collection<PrimaryKey> aPrimaryKeys)
{
if (aPrimaryKeys == null)
return null;
Map<Integer, PrimaryKey> map = new HashMap<Integer, PrimaryKey>(aPrimaryKeys.size());
PrimaryKey primaryKey = null;
for (Iterator<PrimaryKey> i = aPrimaryKeys.iterator(); i.hasNext();)
{
primaryKey = (PrimaryKey) i.next();
map.put(Integer.valueOf(primaryKey.getPrimaryKey()), primaryKey);
}
return map;
} | [
"public",
"static",
"Map",
"<",
"Integer",
",",
"PrimaryKey",
">",
"constructPrimaryKeyMap",
"(",
"Collection",
"<",
"PrimaryKey",
">",
"aPrimaryKeys",
")",
"{",
"if",
"(",
"aPrimaryKeys",
"==",
"null",
")",
"return",
"null",
";",
"Map",
"<",
"Integer",
",",
"PrimaryKey",
">",
"map",
"=",
"new",
"HashMap",
"<",
"Integer",
",",
"PrimaryKey",
">",
"(",
"aPrimaryKeys",
".",
"size",
"(",
")",
")",
";",
"PrimaryKey",
"primaryKey",
"=",
"null",
";",
"for",
"(",
"Iterator",
"<",
"PrimaryKey",
">",
"i",
"=",
"aPrimaryKeys",
".",
"iterator",
"(",
")",
";",
"i",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"primaryKey",
"=",
"(",
"PrimaryKey",
")",
"i",
".",
"next",
"(",
")",
";",
"map",
".",
"put",
"(",
"Integer",
".",
"valueOf",
"(",
"primaryKey",
".",
"getPrimaryKey",
"(",
")",
")",
",",
"primaryKey",
")",
";",
"}",
"return",
"map",
";",
"}"
] | construct map for collection of criteria object where the key is
Criteria.getId
@param aPrimaryKeys
the primary keys
@return the map Criteria is the value and Criteria.getId is the key | [
"construct",
"map",
"for",
"collection",
"of",
"criteria",
"object",
"where",
"the",
"key",
"is",
"Criteria",
".",
"getId"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/Organizer.java#L778-L791 |
143,388 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/util/Organizer.java | Organizer.makeAuditableCopies | public static <K> void makeAuditableCopies(Map<K, Copier> aFormMap, Map<K, Copier> aToMap,
Auditable aAuditable)
{
if (aFormMap == null || aToMap == null)
return;
// for thru froms
K fromKey = null;
Copier to = null;
Copier from = null;
for (Map.Entry<K, Copier> entry : aFormMap.entrySet())
{
fromKey = entry.getKey();
if (aToMap.keySet().contains(fromKey))
{
// copy existening data
to = (Copier) aToMap.get(fromKey);
to.copy((Copier) entry.getValue());
// copy auditing info
if (aAuditable != null && to instanceof Auditable)
{
AbstractAuditable.copy(aAuditable, (Auditable) to);
}
}
else
{
from = (Copier) aFormMap.get(fromKey);
// copy auditing info
if (aAuditable != null && from instanceof Auditable)
{
AbstractAuditable.copy(aAuditable, (Auditable) from);
}
// add to
aToMap.put(fromKey, from);
}
}
} | java | public static <K> void makeAuditableCopies(Map<K, Copier> aFormMap, Map<K, Copier> aToMap,
Auditable aAuditable)
{
if (aFormMap == null || aToMap == null)
return;
// for thru froms
K fromKey = null;
Copier to = null;
Copier from = null;
for (Map.Entry<K, Copier> entry : aFormMap.entrySet())
{
fromKey = entry.getKey();
if (aToMap.keySet().contains(fromKey))
{
// copy existening data
to = (Copier) aToMap.get(fromKey);
to.copy((Copier) entry.getValue());
// copy auditing info
if (aAuditable != null && to instanceof Auditable)
{
AbstractAuditable.copy(aAuditable, (Auditable) to);
}
}
else
{
from = (Copier) aFormMap.get(fromKey);
// copy auditing info
if (aAuditable != null && from instanceof Auditable)
{
AbstractAuditable.copy(aAuditable, (Auditable) from);
}
// add to
aToMap.put(fromKey, from);
}
}
} | [
"public",
"static",
"<",
"K",
">",
"void",
"makeAuditableCopies",
"(",
"Map",
"<",
"K",
",",
"Copier",
">",
"aFormMap",
",",
"Map",
"<",
"K",
",",
"Copier",
">",
"aToMap",
",",
"Auditable",
"aAuditable",
")",
"{",
"if",
"(",
"aFormMap",
"==",
"null",
"||",
"aToMap",
"==",
"null",
")",
"return",
";",
"// for thru froms\r",
"K",
"fromKey",
"=",
"null",
";",
"Copier",
"to",
"=",
"null",
";",
"Copier",
"from",
"=",
"null",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"K",
",",
"Copier",
">",
"entry",
":",
"aFormMap",
".",
"entrySet",
"(",
")",
")",
"{",
"fromKey",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"if",
"(",
"aToMap",
".",
"keySet",
"(",
")",
".",
"contains",
"(",
"fromKey",
")",
")",
"{",
"// copy existening data\r",
"to",
"=",
"(",
"Copier",
")",
"aToMap",
".",
"get",
"(",
"fromKey",
")",
";",
"to",
".",
"copy",
"(",
"(",
"Copier",
")",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"// copy auditing info\r",
"if",
"(",
"aAuditable",
"!=",
"null",
"&&",
"to",
"instanceof",
"Auditable",
")",
"{",
"AbstractAuditable",
".",
"copy",
"(",
"aAuditable",
",",
"(",
"Auditable",
")",
"to",
")",
";",
"}",
"}",
"else",
"{",
"from",
"=",
"(",
"Copier",
")",
"aFormMap",
".",
"get",
"(",
"fromKey",
")",
";",
"// copy auditing info\r",
"if",
"(",
"aAuditable",
"!=",
"null",
"&&",
"from",
"instanceof",
"Auditable",
")",
"{",
"AbstractAuditable",
".",
"copy",
"(",
"aAuditable",
",",
"(",
"Auditable",
")",
"from",
")",
";",
"}",
"// add to\r",
"aToMap",
".",
"put",
"(",
"fromKey",
",",
"from",
")",
";",
"}",
"}",
"}"
] | Copy value form one map to another
@param aAuditable
the auditable to copy
@param aFormMap
the input map of copiers
@param <K>
the key name
@param aToMap
the output map of copiers | [
"Copy",
"value",
"form",
"one",
"map",
"to",
"another"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/Organizer.java#L882-L923 |
143,389 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/util/Organizer.java | Organizer.toArray | public static Object[] toArray(Object obj)
{
if (obj instanceof Object[])
return (Object[]) obj;
else
{
Object[] returnArray =
{ obj };
return returnArray;
}
} | java | public static Object[] toArray(Object obj)
{
if (obj instanceof Object[])
return (Object[]) obj;
else
{
Object[] returnArray =
{ obj };
return returnArray;
}
} | [
"public",
"static",
"Object",
"[",
"]",
"toArray",
"(",
"Object",
"obj",
")",
"{",
"if",
"(",
"obj",
"instanceof",
"Object",
"[",
"]",
")",
"return",
"(",
"Object",
"[",
"]",
")",
"obj",
";",
"else",
"{",
"Object",
"[",
"]",
"returnArray",
"=",
"{",
"obj",
"}",
";",
"return",
"returnArray",
";",
"}",
"}"
] | Cast into an array of objects or create a array with a single entry
@param obj
the Object[] or single object
@return converted Object[] | [
"Cast",
"into",
"an",
"array",
"of",
"objects",
"or",
"create",
"a",
"array",
"with",
"a",
"single",
"entry"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/util/Organizer.java#L1274-L1285 |
143,390 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/iteration/Pagination.java | Pagination.createPagination | public static <StoredObjectType, ResultSetType> Pagination createPagination(PageCriteria pageCriteria)
{
String id = pageCriteria.getId();
if(id == null || id.length() == 0)
{
return null;
}
Pagination pagination = ClassPath.newInstance(paginationClassName,String.class,pageCriteria.getId());
paginationMap.put(id, pagination);
return pagination;
} | java | public static <StoredObjectType, ResultSetType> Pagination createPagination(PageCriteria pageCriteria)
{
String id = pageCriteria.getId();
if(id == null || id.length() == 0)
{
return null;
}
Pagination pagination = ClassPath.newInstance(paginationClassName,String.class,pageCriteria.getId());
paginationMap.put(id, pagination);
return pagination;
} | [
"public",
"static",
"<",
"StoredObjectType",
",",
"ResultSetType",
">",
"Pagination",
"createPagination",
"(",
"PageCriteria",
"pageCriteria",
")",
"{",
"String",
"id",
"=",
"pageCriteria",
".",
"getId",
"(",
")",
";",
"if",
"(",
"id",
"==",
"null",
"||",
"id",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"return",
"null",
";",
"}",
"Pagination",
"pagination",
"=",
"ClassPath",
".",
"newInstance",
"(",
"paginationClassName",
",",
"String",
".",
"class",
",",
"pageCriteria",
".",
"getId",
"(",
")",
")",
";",
"paginationMap",
".",
"put",
"(",
"id",
",",
"pagination",
")",
";",
"return",
"pagination",
";",
"}"
] | Create a pagination instance
@param <StoredObjectType> the stored object type
@param <ResultSetType> the results set type
@param pageCriteria the page criteria
@return pagination instance | [
"Create",
"a",
"pagination",
"instance"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/iteration/Pagination.java#L55-L70 |
143,391 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/operations/ClassPath.java | ClassPath.loadJar | public void loadJar(File fileJar)
throws IOException
{
JarFile jar = null;
try
{
jar = new JarFile(fileJar);
Enumeration<JarEntry> enumerations = jar.entries();
JarEntry entry = null;
byte[] classByte = null;
ByteArrayOutputStream byteStream = null;
String fileName = null;
String className = null;
Class<?> jarClass = null;
while(enumerations.hasMoreElements())
{
entry = (JarEntry)enumerations.nextElement();
if(entry.isDirectory())
continue; //skip directories
fileName = entry.getName();
if(!fileName.endsWith(".class"))
continue; //skip non classes
InputStream is = jar.getInputStream(entry);
byteStream = new ByteArrayOutputStream();
IO.write(byteStream, is);
classByte = byteStream.toByteArray();
className = formatClassName(fileName);
Debugger.println(this,"className="+className);
jarClass = defineClass(className, classByte, 0, classByte.length,null);
classes.put(className, jarClass);
classByte = null;
byteStream = null;
}//end while
}
finally
{
if(jar !=null)
{ try{ jar.close(); } catch(Exception e){e.printStackTrace();} }
}
} | java | public void loadJar(File fileJar)
throws IOException
{
JarFile jar = null;
try
{
jar = new JarFile(fileJar);
Enumeration<JarEntry> enumerations = jar.entries();
JarEntry entry = null;
byte[] classByte = null;
ByteArrayOutputStream byteStream = null;
String fileName = null;
String className = null;
Class<?> jarClass = null;
while(enumerations.hasMoreElements())
{
entry = (JarEntry)enumerations.nextElement();
if(entry.isDirectory())
continue; //skip directories
fileName = entry.getName();
if(!fileName.endsWith(".class"))
continue; //skip non classes
InputStream is = jar.getInputStream(entry);
byteStream = new ByteArrayOutputStream();
IO.write(byteStream, is);
classByte = byteStream.toByteArray();
className = formatClassName(fileName);
Debugger.println(this,"className="+className);
jarClass = defineClass(className, classByte, 0, classByte.length,null);
classes.put(className, jarClass);
classByte = null;
byteStream = null;
}//end while
}
finally
{
if(jar !=null)
{ try{ jar.close(); } catch(Exception e){e.printStackTrace();} }
}
} | [
"public",
"void",
"loadJar",
"(",
"File",
"fileJar",
")",
"throws",
"IOException",
"{",
"JarFile",
"jar",
"=",
"null",
";",
"try",
"{",
"jar",
"=",
"new",
"JarFile",
"(",
"fileJar",
")",
";",
"Enumeration",
"<",
"JarEntry",
">",
"enumerations",
"=",
"jar",
".",
"entries",
"(",
")",
";",
"JarEntry",
"entry",
"=",
"null",
";",
"byte",
"[",
"]",
"classByte",
"=",
"null",
";",
"ByteArrayOutputStream",
"byteStream",
"=",
"null",
";",
"String",
"fileName",
"=",
"null",
";",
"String",
"className",
"=",
"null",
";",
"Class",
"<",
"?",
">",
"jarClass",
"=",
"null",
";",
"while",
"(",
"enumerations",
".",
"hasMoreElements",
"(",
")",
")",
"{",
"entry",
"=",
"(",
"JarEntry",
")",
"enumerations",
".",
"nextElement",
"(",
")",
";",
"if",
"(",
"entry",
".",
"isDirectory",
"(",
")",
")",
"continue",
";",
"//skip directories\r",
"fileName",
"=",
"entry",
".",
"getName",
"(",
")",
";",
"if",
"(",
"!",
"fileName",
".",
"endsWith",
"(",
"\".class\"",
")",
")",
"continue",
";",
"//skip non classes\r",
"InputStream",
"is",
"=",
"jar",
".",
"getInputStream",
"(",
"entry",
")",
";",
"byteStream",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"IO",
".",
"write",
"(",
"byteStream",
",",
"is",
")",
";",
"classByte",
"=",
"byteStream",
".",
"toByteArray",
"(",
")",
";",
"className",
"=",
"formatClassName",
"(",
"fileName",
")",
";",
"Debugger",
".",
"println",
"(",
"this",
",",
"\"className=\"",
"+",
"className",
")",
";",
"jarClass",
"=",
"defineClass",
"(",
"className",
",",
"classByte",
",",
"0",
",",
"classByte",
".",
"length",
",",
"null",
")",
";",
"classes",
".",
"put",
"(",
"className",
",",
"jarClass",
")",
";",
"classByte",
"=",
"null",
";",
"byteStream",
"=",
"null",
";",
"}",
"//end while\r",
"}",
"finally",
"{",
"if",
"(",
"jar",
"!=",
"null",
")",
"{",
"try",
"{",
"jar",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}",
"}",
"}"
] | Load all classes in the fileJar
@param fileJar
@throws IOException | [
"Load",
"all",
"classes",
"in",
"the",
"fileJar"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/operations/ClassPath.java#L346-L396 |
143,392 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/operations/ClassPath.java | ClassPath.findClass | public Class<?> findClass(String className)
{
Class<?> result = null;
// look in hash map
result = (Class<?>) classes.get(className);
if (result != null)
{
return result;
}
try
{
return findSystemClass(className);
}
catch (Exception e)
{
Debugger.printWarn(e);
}
try
{
URL resourceURL = ClassLoader.getSystemResource(className.replace(
'.', File.separatorChar) + ".class");
if (resourceURL == null)
return null;
String classPath = resourceURL.getFile();
classPath = classPath.substring(1);
return loadClass(className, new File(classPath));
}
catch (Exception e)
{
Debugger.printError(e);
return null;
}
} | java | public Class<?> findClass(String className)
{
Class<?> result = null;
// look in hash map
result = (Class<?>) classes.get(className);
if (result != null)
{
return result;
}
try
{
return findSystemClass(className);
}
catch (Exception e)
{
Debugger.printWarn(e);
}
try
{
URL resourceURL = ClassLoader.getSystemResource(className.replace(
'.', File.separatorChar) + ".class");
if (resourceURL == null)
return null;
String classPath = resourceURL.getFile();
classPath = classPath.substring(1);
return loadClass(className, new File(classPath));
}
catch (Exception e)
{
Debugger.printError(e);
return null;
}
} | [
"public",
"Class",
"<",
"?",
">",
"findClass",
"(",
"String",
"className",
")",
"{",
"Class",
"<",
"?",
">",
"result",
"=",
"null",
";",
"// look in hash map\r",
"result",
"=",
"(",
"Class",
"<",
"?",
">",
")",
"classes",
".",
"get",
"(",
"className",
")",
";",
"if",
"(",
"result",
"!=",
"null",
")",
"{",
"return",
"result",
";",
"}",
"try",
"{",
"return",
"findSystemClass",
"(",
"className",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"Debugger",
".",
"printWarn",
"(",
"e",
")",
";",
"}",
"try",
"{",
"URL",
"resourceURL",
"=",
"ClassLoader",
".",
"getSystemResource",
"(",
"className",
".",
"replace",
"(",
"'",
"'",
",",
"File",
".",
"separatorChar",
")",
"+",
"\".class\"",
")",
";",
"if",
"(",
"resourceURL",
"==",
"null",
")",
"return",
"null",
";",
"String",
"classPath",
"=",
"resourceURL",
".",
"getFile",
"(",
")",
";",
"classPath",
"=",
"classPath",
".",
"substring",
"(",
"1",
")",
";",
"return",
"loadClass",
"(",
"className",
",",
"new",
"File",
"(",
"classPath",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"Debugger",
".",
"printError",
"(",
"e",
")",
";",
"return",
"null",
";",
"}",
"}"
] | Find the class by it name
@param className the class name
@return the existing of loaded class | [
"Find",
"the",
"class",
"by",
"it",
"name"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/operations/ClassPath.java#L417-L457 |
143,393 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/operations/ClassPath.java | ClassPath.loadClassBytes | private byte[] loadClassBytes(File classFile) throws IOException
{
int size = (int) classFile.length();
byte buff[] = new byte[size];
FileInputStream fis = new FileInputStream(classFile);
DataInputStream dis = null;
try
{
dis = new DataInputStream(fis);
dis.readFully(buff);
}
finally
{
if(dis != null)
dis.close();
}
return buff;
} | java | private byte[] loadClassBytes(File classFile) throws IOException
{
int size = (int) classFile.length();
byte buff[] = new byte[size];
FileInputStream fis = new FileInputStream(classFile);
DataInputStream dis = null;
try
{
dis = new DataInputStream(fis);
dis.readFully(buff);
}
finally
{
if(dis != null)
dis.close();
}
return buff;
} | [
"private",
"byte",
"[",
"]",
"loadClassBytes",
"(",
"File",
"classFile",
")",
"throws",
"IOException",
"{",
"int",
"size",
"=",
"(",
"int",
")",
"classFile",
".",
"length",
"(",
")",
";",
"byte",
"buff",
"[",
"]",
"=",
"new",
"byte",
"[",
"size",
"]",
";",
"FileInputStream",
"fis",
"=",
"new",
"FileInputStream",
"(",
"classFile",
")",
";",
"DataInputStream",
"dis",
"=",
"null",
";",
"try",
"{",
"dis",
"=",
"new",
"DataInputStream",
"(",
"fis",
")",
";",
"dis",
".",
"readFully",
"(",
"buff",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"dis",
"!=",
"null",
")",
"dis",
".",
"close",
"(",
")",
";",
"}",
"return",
"buff",
";",
"}"
] | Load the class name
@param classPath
the path of the class
@return the byte of the class
@throws IOException | [
"Load",
"the",
"class",
"name"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/operations/ClassPath.java#L479-L500 |
143,394 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/data/clock/Day.java | Day.compareTo | public int compareTo(Day object)
{
if (object == null)
throw new IllegalArgumentException("day cannot be null");
Day day = (Day)object;
return localDate.compareTo(day.localDate);
} | java | public int compareTo(Day object)
{
if (object == null)
throw new IllegalArgumentException("day cannot be null");
Day day = (Day)object;
return localDate.compareTo(day.localDate);
} | [
"public",
"int",
"compareTo",
"(",
"Day",
"object",
")",
"{",
"if",
"(",
"object",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"day cannot be null\"",
")",
";",
"Day",
"day",
"=",
"(",
"Day",
")",
"object",
";",
"return",
"localDate",
".",
"compareTo",
"(",
"day",
".",
"localDate",
")",
";",
"}"
] | Compare this day to the specified day. If object is
not of type Day a ClassCastException is thrown.
@param object Day object to compare to.
@return @see Comparable#compareTo(Object)
@throws IllegalArgumentException If day is null. | [
"Compare",
"this",
"day",
"to",
"the",
"specified",
"day",
".",
"If",
"object",
"is",
"not",
"of",
"type",
"Day",
"a",
"ClassCastException",
"is",
"thrown",
"."
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/data/clock/Day.java#L199-L207 |
143,395 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/data/clock/Day.java | Day.isAfter | public boolean isAfter(Day day)
{
if (day == null)
throw new IllegalArgumentException("day cannot be null");
return localDate.isAfter(day.localDate);
} | java | public boolean isAfter(Day day)
{
if (day == null)
throw new IllegalArgumentException("day cannot be null");
return localDate.isAfter(day.localDate);
} | [
"public",
"boolean",
"isAfter",
"(",
"Day",
"day",
")",
"{",
"if",
"(",
"day",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"day cannot be null\"",
")",
";",
"return",
"localDate",
".",
"isAfter",
"(",
"day",
".",
"localDate",
")",
";",
"}"
] | Return true if this day is after the specified day.
@param day Day to compare to.
@return True if this is after day, false otherwise.
@throws IllegalArgumentException If day is null. | [
"Return",
"true",
"if",
"this",
"day",
"is",
"after",
"the",
"specified",
"day",
"."
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/data/clock/Day.java#L219-L225 |
143,396 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/data/clock/Day.java | Day.isBefore | public boolean isBefore(Day day)
{
if (day == null)
throw new IllegalArgumentException("day cannot be null");
return localDate.isBefore(day.localDate);
} | java | public boolean isBefore(Day day)
{
if (day == null)
throw new IllegalArgumentException("day cannot be null");
return localDate.isBefore(day.localDate);
} | [
"public",
"boolean",
"isBefore",
"(",
"Day",
"day",
")",
"{",
"if",
"(",
"day",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"day cannot be null\"",
")",
";",
"return",
"localDate",
".",
"isBefore",
"(",
"day",
".",
"localDate",
")",
";",
"}"
] | Return true if this day is before the specified day.
@param day Day to compare to.
@return True if this is before day, false otherwise.
@throws IllegalArgumentException If day is null. | [
"Return",
"true",
"if",
"this",
"day",
"is",
"before",
"the",
"specified",
"day",
"."
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/data/clock/Day.java#L236-L242 |
143,397 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/data/clock/Day.java | Day.isSameDay | public boolean isSameDay(Day compared)
{
if(compared == null)
return false;
return this.getMonth() == compared.getMonth()
&& this.getDayOfMonth() == compared.getDayOfMonth()
&& this.getYear() == compared.getYear();
} | java | public boolean isSameDay(Day compared)
{
if(compared == null)
return false;
return this.getMonth() == compared.getMonth()
&& this.getDayOfMonth() == compared.getDayOfMonth()
&& this.getYear() == compared.getYear();
} | [
"public",
"boolean",
"isSameDay",
"(",
"Day",
"compared",
")",
"{",
"if",
"(",
"compared",
"==",
"null",
")",
"return",
"false",
";",
"return",
"this",
".",
"getMonth",
"(",
")",
"==",
"compared",
".",
"getMonth",
"(",
")",
"&&",
"this",
".",
"getDayOfMonth",
"(",
")",
"==",
"compared",
".",
"getDayOfMonth",
"(",
")",
"&&",
"this",
".",
"getYear",
"(",
")",
"==",
"compared",
".",
"getYear",
"(",
")",
";",
"}"
] | Compare based on month day year
@param compared the day to compare
@return if compared is the same day | [
"Compare",
"based",
"on",
"month",
"day",
"year"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/data/clock/Day.java#L645-L653 |
143,398 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/loadbalancer/PropertiesLoadBalanceRegistry.java | PropertiesLoadBalanceRegistry.lookup | @Override
public synchronized String lookup(String id)
{
if(this.properties == null)
this.setUp();
String associated = this.properties.getProperty(id);
if(associated == null)
{
associated = this.next();
//Est. new association
register(id,associated);
}
return associated;
} | java | @Override
public synchronized String lookup(String id)
{
if(this.properties == null)
this.setUp();
String associated = this.properties.getProperty(id);
if(associated == null)
{
associated = this.next();
//Est. new association
register(id,associated);
}
return associated;
} | [
"@",
"Override",
"public",
"synchronized",
"String",
"lookup",
"(",
"String",
"id",
")",
"{",
"if",
"(",
"this",
".",
"properties",
"==",
"null",
")",
"this",
".",
"setUp",
"(",
")",
";",
"String",
"associated",
"=",
"this",
".",
"properties",
".",
"getProperty",
"(",
"id",
")",
";",
"if",
"(",
"associated",
"==",
"null",
")",
"{",
"associated",
"=",
"this",
".",
"next",
"(",
")",
";",
"//Est. new association",
"register",
"(",
"id",
",",
"associated",
")",
";",
"}",
"return",
"associated",
";",
"}"
] | Lookup the location of a key
@see nyla.solutions.core.patterns.loadbalancer.LoadBalanceRegistry#lookup(java.lang.Object) | [
"Lookup",
"the",
"location",
"of",
"a",
"key"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/loadbalancer/PropertiesLoadBalanceRegistry.java#L71-L89 |
143,399 | nyla-solutions/nyla | nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/workthread/Boss.java | Boss.manage | public void manage(int workersCount)
{
this.workers.clear();
WorkerThread worker = null;
for (int i = 0; i <workersCount; i++)
{
worker = new WorkerThread(this); //TODO expensive use thread pool
this.manage(worker);
}
} | java | public void manage(int workersCount)
{
this.workers.clear();
WorkerThread worker = null;
for (int i = 0; i <workersCount; i++)
{
worker = new WorkerThread(this); //TODO expensive use thread pool
this.manage(worker);
}
} | [
"public",
"void",
"manage",
"(",
"int",
"workersCount",
")",
"{",
"this",
".",
"workers",
".",
"clear",
"(",
")",
";",
"WorkerThread",
"worker",
"=",
"null",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"workersCount",
";",
"i",
"++",
")",
"{",
"worker",
"=",
"new",
"WorkerThread",
"(",
"this",
")",
";",
"//TODO expensive use thread pool\r",
"this",
".",
"manage",
"(",
"worker",
")",
";",
"}",
"}"
] | Manage a number of default worker threads
@param workersCount the worker count | [
"Manage",
"a",
"number",
"of",
"default",
"worker",
"threads"
] | 38d5b843c76eae9762bbca20453ed0f0ad8412a9 | https://github.com/nyla-solutions/nyla/blob/38d5b843c76eae9762bbca20453ed0f0ad8412a9/nyla.solutions.core/src/main/java/nyla/solutions/core/patterns/workthread/Boss.java#L99-L110 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.