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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
148,200
|
torakiki/event-studio
|
src/main/java/org/sejda/eventstudio/util/ReflectionUtils.java
|
ReflectionUtils.inferParameterClass
|
@SuppressWarnings("rawtypes")
public static Class inferParameterClass(Class clazz, String methodName) {
Method[] methods = clazz.getMethods();
for (Method method : methods) {
if (method.getName().equals(methodName) && !method.isBridge()) {
Type[] types = method.getGenericParameterTypes();
for (Type type : types) {
if (type instanceof Class && !((Class) type).isInterface()) {
return ((Class) type);
}
}
}
}
return null;
}
|
java
|
@SuppressWarnings("rawtypes")
public static Class inferParameterClass(Class clazz, String methodName) {
Method[] methods = clazz.getMethods();
for (Method method : methods) {
if (method.getName().equals(methodName) && !method.isBridge()) {
Type[] types = method.getGenericParameterTypes();
for (Type type : types) {
if (type instanceof Class && !((Class) type).isInterface()) {
return ((Class) type);
}
}
}
}
return null;
}
|
[
"@",
"SuppressWarnings",
"(",
"\"rawtypes\"",
")",
"public",
"static",
"Class",
"inferParameterClass",
"(",
"Class",
"clazz",
",",
"String",
"methodName",
")",
"{",
"Method",
"[",
"]",
"methods",
"=",
"clazz",
".",
"getMethods",
"(",
")",
";",
"for",
"(",
"Method",
"method",
":",
"methods",
")",
"{",
"if",
"(",
"method",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"methodName",
")",
"&&",
"!",
"method",
".",
"isBridge",
"(",
")",
")",
"{",
"Type",
"[",
"]",
"types",
"=",
"method",
".",
"getGenericParameterTypes",
"(",
")",
";",
"for",
"(",
"Type",
"type",
":",
"types",
")",
"{",
"if",
"(",
"type",
"instanceof",
"Class",
"&&",
"!",
"(",
"(",
"Class",
")",
"type",
")",
".",
"isInterface",
"(",
")",
")",
"{",
"return",
"(",
"(",
"Class",
")",
"type",
")",
";",
"}",
"}",
"}",
"}",
"return",
"null",
";",
"}"
] |
Given a concrete class and a method name, it tries to infer the Class of the first parameter of the method
@param clazz
@param methodName
@return the class or null if nothing found
|
[
"Given",
"a",
"concrete",
"class",
"and",
"a",
"method",
"name",
"it",
"tries",
"to",
"infer",
"the",
"Class",
"of",
"the",
"first",
"parameter",
"of",
"the",
"method"
] |
2937b7ed28bb185a79b9cfb98c4de2eb37690a4a
|
https://github.com/torakiki/event-studio/blob/2937b7ed28bb185a79b9cfb98c4de2eb37690a4a/src/main/java/org/sejda/eventstudio/util/ReflectionUtils.java#L42-L56
|
148,201
|
lisicnu/droidUtil
|
src/main/java/com/github/lisicnu/libDroid/helper/FlashPluginHelper.java
|
FlashPluginHelper.check
|
public static boolean check(Context context, WebView mWebView, boolean showInstall) {
if (context == null) return false;
boolean flashPluginExist = isPluginExist(context);
if (mWebView != null) {
if (!flashPluginExist && showInstall) {
mWebView.addJavascriptInterface(new AndroidBridge(context), "android");
String content = "<html>\n" +
"<head></head>\n" +
"<body>\n" +
"<br/><br/>\n" +
"\n" +
"<h3>Sorry, We have found that you haven't installed adobe flash player's plugin!</h3>\n" +
"\n" +
"<p>\n" +
"<h4>\n" +
" You can click <a href=\"#\" onclick=\"window.android.goMarket()\"> <b> here</b></a> to\n" +
" install it.</h4>\n" +
"</p>\n" +
"</body>\n" +
"</html>\n";
mWebView.loadData(content, "text/html", "UTF-8");
}
}
return flashPluginExist;
}
|
java
|
public static boolean check(Context context, WebView mWebView, boolean showInstall) {
if (context == null) return false;
boolean flashPluginExist = isPluginExist(context);
if (mWebView != null) {
if (!flashPluginExist && showInstall) {
mWebView.addJavascriptInterface(new AndroidBridge(context), "android");
String content = "<html>\n" +
"<head></head>\n" +
"<body>\n" +
"<br/><br/>\n" +
"\n" +
"<h3>Sorry, We have found that you haven't installed adobe flash player's plugin!</h3>\n" +
"\n" +
"<p>\n" +
"<h4>\n" +
" You can click <a href=\"#\" onclick=\"window.android.goMarket()\"> <b> here</b></a> to\n" +
" install it.</h4>\n" +
"</p>\n" +
"</body>\n" +
"</html>\n";
mWebView.loadData(content, "text/html", "UTF-8");
}
}
return flashPluginExist;
}
|
[
"public",
"static",
"boolean",
"check",
"(",
"Context",
"context",
",",
"WebView",
"mWebView",
",",
"boolean",
"showInstall",
")",
"{",
"if",
"(",
"context",
"==",
"null",
")",
"return",
"false",
";",
"boolean",
"flashPluginExist",
"=",
"isPluginExist",
"(",
"context",
")",
";",
"if",
"(",
"mWebView",
"!=",
"null",
")",
"{",
"if",
"(",
"!",
"flashPluginExist",
"&&",
"showInstall",
")",
"{",
"mWebView",
".",
"addJavascriptInterface",
"(",
"new",
"AndroidBridge",
"(",
"context",
")",
",",
"\"android\"",
")",
";",
"String",
"content",
"=",
"\"<html>\\n\"",
"+",
"\"<head></head>\\n\"",
"+",
"\"<body>\\n\"",
"+",
"\"<br/><br/>\\n\"",
"+",
"\"\\n\"",
"+",
"\"<h3>Sorry, We have found that you haven't installed adobe flash player's plugin!</h3>\\n\"",
"+",
"\"\\n\"",
"+",
"\"<p>\\n\"",
"+",
"\"<h4>\\n\"",
"+",
"\" You can click <a href=\\\"#\\\" onclick=\\\"window.android.goMarket()\\\"> <b> here</b></a> to\\n\"",
"+",
"\" install it.</h4>\\n\"",
"+",
"\"</p>\\n\"",
"+",
"\"</body>\\n\"",
"+",
"\"</html>\\n\"",
";",
"mWebView",
".",
"loadData",
"(",
"content",
",",
"\"text/html\"",
",",
"\"UTF-8\"",
")",
";",
"}",
"}",
"return",
"flashPluginExist",
";",
"}"
] |
check whether the flash can play or not.
@param context
@param mWebView
@param showInstall show install page or not.
@return return the plugin exist or not.
|
[
"check",
"whether",
"the",
"flash",
"can",
"play",
"or",
"not",
"."
] |
e4d6cf3e3f60e5efb5a75672607ded94d1725519
|
https://github.com/lisicnu/droidUtil/blob/e4d6cf3e3f60e5efb5a75672607ded94d1725519/src/main/java/com/github/lisicnu/libDroid/helper/FlashPluginHelper.java#L46-L73
|
148,202
|
fuinorg/objects4j
|
src/main/java/org/fuin/objects4j/vo/SecurityToken.java
|
SecurityToken.encodeBase64
|
private static String encodeBase64(final byte[] buffer) {
final int l = buffer.length;
final char[] out = new char[l << 1];
int j = 0;
for (int i = 0; i < l; i++) {
out[j++] = DIGITS[(0xF0 & buffer[i]) >>> 4];
out[j++] = DIGITS[0x0F & buffer[i]];
}
return String.copyValueOf(out);
}
|
java
|
private static String encodeBase64(final byte[] buffer) {
final int l = buffer.length;
final char[] out = new char[l << 1];
int j = 0;
for (int i = 0; i < l; i++) {
out[j++] = DIGITS[(0xF0 & buffer[i]) >>> 4];
out[j++] = DIGITS[0x0F & buffer[i]];
}
return String.copyValueOf(out);
}
|
[
"private",
"static",
"String",
"encodeBase64",
"(",
"final",
"byte",
"[",
"]",
"buffer",
")",
"{",
"final",
"int",
"l",
"=",
"buffer",
".",
"length",
";",
"final",
"char",
"[",
"]",
"out",
"=",
"new",
"char",
"[",
"l",
"<<",
"1",
"]",
";",
"int",
"j",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"out",
"[",
"j",
"++",
"]",
"=",
"DIGITS",
"[",
"(",
"0xF0",
"&",
"buffer",
"[",
"i",
"]",
")",
">>>",
"4",
"]",
";",
"out",
"[",
"j",
"++",
"]",
"=",
"DIGITS",
"[",
"0x0F",
"&",
"buffer",
"[",
"i",
"]",
"]",
";",
"}",
"return",
"String",
".",
"copyValueOf",
"(",
"out",
")",
";",
"}"
] |
Encodes a byte array base64.
@param buffer
Bytes to encode.
@return Base64 encoded string.
|
[
"Encodes",
"a",
"byte",
"array",
"base64",
"."
] |
e7f278b5bae073ebb6a76053650571c718f36246
|
https://github.com/fuinorg/objects4j/blob/e7f278b5bae073ebb6a76053650571c718f36246/src/main/java/org/fuin/objects4j/vo/SecurityToken.java#L77-L86
|
148,203
|
fuinorg/objects4j
|
src/main/java/org/fuin/objects4j/vo/SecurityToken.java
|
SecurityToken.createSecureRandom
|
private static String createSecureRandom() {
try {
final String no = "" + SECURE_RANDOM.nextInt();
final MessageDigest md = MessageDigest.getInstance("SHA-1");
final byte[] digest = md.digest(no.getBytes());
return encodeBase64(digest);
} catch (final NoSuchAlgorithmException ex) {
throw new RuntimeException(ex);
}
}
|
java
|
private static String createSecureRandom() {
try {
final String no = "" + SECURE_RANDOM.nextInt();
final MessageDigest md = MessageDigest.getInstance("SHA-1");
final byte[] digest = md.digest(no.getBytes());
return encodeBase64(digest);
} catch (final NoSuchAlgorithmException ex) {
throw new RuntimeException(ex);
}
}
|
[
"private",
"static",
"String",
"createSecureRandom",
"(",
")",
"{",
"try",
"{",
"final",
"String",
"no",
"=",
"\"\"",
"+",
"SECURE_RANDOM",
".",
"nextInt",
"(",
")",
";",
"final",
"MessageDigest",
"md",
"=",
"MessageDigest",
".",
"getInstance",
"(",
"\"SHA-1\"",
")",
";",
"final",
"byte",
"[",
"]",
"digest",
"=",
"md",
".",
"digest",
"(",
"no",
".",
"getBytes",
"(",
")",
")",
";",
"return",
"encodeBase64",
"(",
"digest",
")",
";",
"}",
"catch",
"(",
"final",
"NoSuchAlgorithmException",
"ex",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"ex",
")",
";",
"}",
"}"
] |
Creates a encoded secure random string.
@return Base64 encoded string.
|
[
"Creates",
"a",
"encoded",
"secure",
"random",
"string",
"."
] |
e7f278b5bae073ebb6a76053650571c718f36246
|
https://github.com/fuinorg/objects4j/blob/e7f278b5bae073ebb6a76053650571c718f36246/src/main/java/org/fuin/objects4j/vo/SecurityToken.java#L93-L102
|
148,204
|
DDTH/ddth-dao
|
ddth-dao-core/src/main/java/com/github/ddth/dao/nosql/lucene/BaseLuceneStorage.java
|
BaseLuceneStorage.buildQuery
|
protected Query buildQuery(String spaceId, String key) {
BooleanQuery.Builder builder = new BooleanQuery.Builder();
if (!StringUtils.isBlank(spaceId)) {
builder.add(new TermQuery(new Term(FIELD_SPACE_ID, spaceId.trim())), Occur.MUST);
}
if (!StringUtils.isBlank(key)) {
builder.add(new TermQuery(new Term(FIELD_KEY, key.trim())), Occur.MUST);
}
return builder.build();
}
|
java
|
protected Query buildQuery(String spaceId, String key) {
BooleanQuery.Builder builder = new BooleanQuery.Builder();
if (!StringUtils.isBlank(spaceId)) {
builder.add(new TermQuery(new Term(FIELD_SPACE_ID, spaceId.trim())), Occur.MUST);
}
if (!StringUtils.isBlank(key)) {
builder.add(new TermQuery(new Term(FIELD_KEY, key.trim())), Occur.MUST);
}
return builder.build();
}
|
[
"protected",
"Query",
"buildQuery",
"(",
"String",
"spaceId",
",",
"String",
"key",
")",
"{",
"BooleanQuery",
".",
"Builder",
"builder",
"=",
"new",
"BooleanQuery",
".",
"Builder",
"(",
")",
";",
"if",
"(",
"!",
"StringUtils",
".",
"isBlank",
"(",
"spaceId",
")",
")",
"{",
"builder",
".",
"add",
"(",
"new",
"TermQuery",
"(",
"new",
"Term",
"(",
"FIELD_SPACE_ID",
",",
"spaceId",
".",
"trim",
"(",
")",
")",
")",
",",
"Occur",
".",
"MUST",
")",
";",
"}",
"if",
"(",
"!",
"StringUtils",
".",
"isBlank",
"(",
"key",
")",
")",
"{",
"builder",
".",
"add",
"(",
"new",
"TermQuery",
"(",
"new",
"Term",
"(",
"FIELD_KEY",
",",
"key",
".",
"trim",
"(",
")",
")",
")",
",",
"Occur",
".",
"MUST",
")",
";",
"}",
"return",
"builder",
".",
"build",
"(",
")",
";",
"}"
] |
Build query to match entry's space-id and key.
@param spaceId
@param key
@return
|
[
"Build",
"query",
"to",
"match",
"entry",
"s",
"space",
"-",
"id",
"and",
"key",
"."
] |
8d059ddf641a1629aa53851f9d1b41abf175a180
|
https://github.com/DDTH/ddth-dao/blob/8d059ddf641a1629aa53851f9d1b41abf175a180/ddth-dao-core/src/main/java/com/github/ddth/dao/nosql/lucene/BaseLuceneStorage.java#L232-L241
|
148,205
|
DDTH/ddth-dao
|
ddth-dao-core/src/main/java/com/github/ddth/dao/nosql/lucene/BaseLuceneStorage.java
|
BaseLuceneStorage.doCount
|
protected long doCount(String spaceId) throws IOException {
TopDocs result = getIndexSearcher().search(buildQuery(spaceId, null), 1);
return result != null ? result.totalHits : -1;
}
|
java
|
protected long doCount(String spaceId) throws IOException {
TopDocs result = getIndexSearcher().search(buildQuery(spaceId, null), 1);
return result != null ? result.totalHits : -1;
}
|
[
"protected",
"long",
"doCount",
"(",
"String",
"spaceId",
")",
"throws",
"IOException",
"{",
"TopDocs",
"result",
"=",
"getIndexSearcher",
"(",
")",
".",
"search",
"(",
"buildQuery",
"(",
"spaceId",
",",
"null",
")",
",",
"1",
")",
";",
"return",
"result",
"!=",
"null",
"?",
"result",
".",
"totalHits",
":",
"-",
"1",
";",
"}"
] |
Count number of documents within a space.
@param spaceId
@return
@throws IOException
|
[
"Count",
"number",
"of",
"documents",
"within",
"a",
"space",
"."
] |
8d059ddf641a1629aa53851f9d1b41abf175a180
|
https://github.com/DDTH/ddth-dao/blob/8d059ddf641a1629aa53851f9d1b41abf175a180/ddth-dao-core/src/main/java/com/github/ddth/dao/nosql/lucene/BaseLuceneStorage.java#L312-L315
|
148,206
|
fuinorg/objects4j
|
src/main/java/org/fuin/objects4j/vo/CurrencyAmountStrValidator.java
|
CurrencyAmountStrValidator.isValid
|
public static boolean isValid(final String value) {
if (value == null) {
return true;
}
if (value.length() == 0) {
return false;
}
final int space = value.indexOf(' ');
if (space == -1) {
return false;
}
// Try converting amount
final String amount = value.substring(0, space);
if (!(amount.matches(DECIMAL) || amount.matches(INTEGER))) {
return false;
}
// Try to convert code into a currency
final String currencyCode = value.substring(space + 1);
try {
Currency.getInstance(currencyCode);
} catch (RuntimeException ex) {
return false;
}
return true;
}
|
java
|
public static boolean isValid(final String value) {
if (value == null) {
return true;
}
if (value.length() == 0) {
return false;
}
final int space = value.indexOf(' ');
if (space == -1) {
return false;
}
// Try converting amount
final String amount = value.substring(0, space);
if (!(amount.matches(DECIMAL) || amount.matches(INTEGER))) {
return false;
}
// Try to convert code into a currency
final String currencyCode = value.substring(space + 1);
try {
Currency.getInstance(currencyCode);
} catch (RuntimeException ex) {
return false;
}
return true;
}
|
[
"public",
"static",
"boolean",
"isValid",
"(",
"final",
"String",
"value",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"value",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"return",
"false",
";",
"}",
"final",
"int",
"space",
"=",
"value",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"space",
"==",
"-",
"1",
")",
"{",
"return",
"false",
";",
"}",
"// Try converting amount\r",
"final",
"String",
"amount",
"=",
"value",
".",
"substring",
"(",
"0",
",",
"space",
")",
";",
"if",
"(",
"!",
"(",
"amount",
".",
"matches",
"(",
"DECIMAL",
")",
"||",
"amount",
".",
"matches",
"(",
"INTEGER",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"// Try to convert code into a currency\r",
"final",
"String",
"currencyCode",
"=",
"value",
".",
"substring",
"(",
"space",
"+",
"1",
")",
";",
"try",
"{",
"Currency",
".",
"getInstance",
"(",
"currencyCode",
")",
";",
"}",
"catch",
"(",
"RuntimeException",
"ex",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Check that a given string is a well-formed currency amount.
@param value
Value to check.
@return Returns <code>true</code> if it's a valid currency amount else <code>false</code> is returned.
|
[
"Check",
"that",
"a",
"given",
"string",
"is",
"a",
"well",
"-",
"formed",
"currency",
"amount",
"."
] |
e7f278b5bae073ebb6a76053650571c718f36246
|
https://github.com/fuinorg/objects4j/blob/e7f278b5bae073ebb6a76053650571c718f36246/src/main/java/org/fuin/objects4j/vo/CurrencyAmountStrValidator.java#L56-L83
|
148,207
|
fuinorg/objects4j
|
src/main/java/org/fuin/objects4j/vo/HourRanges.java
|
HourRanges.diff
|
public final List<Change> diff(final HourRanges toOther) {
ensureSingleDayOnly("from", this);
ensureSingleDayOnly("to", toOther);
final BitSet thisMinutes = this.toMinutes();
final BitSet otherMinutes = toOther.toMinutes();
final BitSet addedMinutes = new BitSet(1440);
final BitSet removedMinutes = new BitSet(1440);
for (int i = 0; i < 1440; i++) {
if (thisMinutes.get(i) && !otherMinutes.get(i)) {
removedMinutes.set(i);
}
if (!thisMinutes.get(i) && otherMinutes.get(i)) {
addedMinutes.set(i);
}
}
final List<Change> changes = new ArrayList<>();
if (!removedMinutes.isEmpty()) {
final HourRanges removed = HourRanges.valueOf(removedMinutes);
for (final HourRange hr : removed) {
changes.add(new Change(ChangeType.REMOVED, hr));
}
}
if (!addedMinutes.isEmpty()) {
final HourRanges added = HourRanges.valueOf(addedMinutes);
for (final HourRange hr : added) {
changes.add(new Change(ChangeType.ADDED, hr));
}
}
return changes;
}
|
java
|
public final List<Change> diff(final HourRanges toOther) {
ensureSingleDayOnly("from", this);
ensureSingleDayOnly("to", toOther);
final BitSet thisMinutes = this.toMinutes();
final BitSet otherMinutes = toOther.toMinutes();
final BitSet addedMinutes = new BitSet(1440);
final BitSet removedMinutes = new BitSet(1440);
for (int i = 0; i < 1440; i++) {
if (thisMinutes.get(i) && !otherMinutes.get(i)) {
removedMinutes.set(i);
}
if (!thisMinutes.get(i) && otherMinutes.get(i)) {
addedMinutes.set(i);
}
}
final List<Change> changes = new ArrayList<>();
if (!removedMinutes.isEmpty()) {
final HourRanges removed = HourRanges.valueOf(removedMinutes);
for (final HourRange hr : removed) {
changes.add(new Change(ChangeType.REMOVED, hr));
}
}
if (!addedMinutes.isEmpty()) {
final HourRanges added = HourRanges.valueOf(addedMinutes);
for (final HourRange hr : added) {
changes.add(new Change(ChangeType.ADDED, hr));
}
}
return changes;
}
|
[
"public",
"final",
"List",
"<",
"Change",
">",
"diff",
"(",
"final",
"HourRanges",
"toOther",
")",
"{",
"ensureSingleDayOnly",
"(",
"\"from\"",
",",
"this",
")",
";",
"ensureSingleDayOnly",
"(",
"\"to\"",
",",
"toOther",
")",
";",
"final",
"BitSet",
"thisMinutes",
"=",
"this",
".",
"toMinutes",
"(",
")",
";",
"final",
"BitSet",
"otherMinutes",
"=",
"toOther",
".",
"toMinutes",
"(",
")",
";",
"final",
"BitSet",
"addedMinutes",
"=",
"new",
"BitSet",
"(",
"1440",
")",
";",
"final",
"BitSet",
"removedMinutes",
"=",
"new",
"BitSet",
"(",
"1440",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"1440",
";",
"i",
"++",
")",
"{",
"if",
"(",
"thisMinutes",
".",
"get",
"(",
"i",
")",
"&&",
"!",
"otherMinutes",
".",
"get",
"(",
"i",
")",
")",
"{",
"removedMinutes",
".",
"set",
"(",
"i",
")",
";",
"}",
"if",
"(",
"!",
"thisMinutes",
".",
"get",
"(",
"i",
")",
"&&",
"otherMinutes",
".",
"get",
"(",
"i",
")",
")",
"{",
"addedMinutes",
".",
"set",
"(",
"i",
")",
";",
"}",
"}",
"final",
"List",
"<",
"Change",
">",
"changes",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"if",
"(",
"!",
"removedMinutes",
".",
"isEmpty",
"(",
")",
")",
"{",
"final",
"HourRanges",
"removed",
"=",
"HourRanges",
".",
"valueOf",
"(",
"removedMinutes",
")",
";",
"for",
"(",
"final",
"HourRange",
"hr",
":",
"removed",
")",
"{",
"changes",
".",
"add",
"(",
"new",
"Change",
"(",
"ChangeType",
".",
"REMOVED",
",",
"hr",
")",
")",
";",
"}",
"}",
"if",
"(",
"!",
"addedMinutes",
".",
"isEmpty",
"(",
")",
")",
"{",
"final",
"HourRanges",
"added",
"=",
"HourRanges",
".",
"valueOf",
"(",
"addedMinutes",
")",
";",
"for",
"(",
"final",
"HourRange",
"hr",
":",
"added",
")",
"{",
"changes",
".",
"add",
"(",
"new",
"Change",
"(",
"ChangeType",
".",
"ADDED",
",",
"hr",
")",
")",
";",
"}",
"}",
"return",
"changes",
";",
"}"
] |
Returns the difference when changing this opening hours to the other one.
@param toOther
Opening hours to compare with.
@return List of changes or an empty list if both are equal.
|
[
"Returns",
"the",
"difference",
"when",
"changing",
"this",
"opening",
"hours",
"to",
"the",
"other",
"one",
"."
] |
e7f278b5bae073ebb6a76053650571c718f36246
|
https://github.com/fuinorg/objects4j/blob/e7f278b5bae073ebb6a76053650571c718f36246/src/main/java/org/fuin/objects4j/vo/HourRanges.java#L167-L203
|
148,208
|
fuinorg/objects4j
|
src/main/java/org/fuin/objects4j/vo/HourRanges.java
|
HourRanges.compress
|
public final HourRanges compress() {
final List<HourRanges> normalized = normalize();
if (normalized.size() == 1) {
return valueOf(normalized.get(0).toMinutes());
} else if (normalized.size() == 2) {
final HourRanges firstDay = valueOf(normalized.get(0).toMinutes());
final HourRanges secondDay = normalized.get(1);
if (secondDay.ranges.size() != 1) {
throw new IllegalStateException(
"Expected exactly 1 hour range for the seond day, but was " + secondDay.ranges.size() + ": " + secondDay);
}
final HourRange seondDayHR = secondDay.ranges.get(0);
final List<HourRange> newRanges = new ArrayList<>();
int lastIdx = 0;
if (firstDay.ranges.size() > 1) {
lastIdx = firstDay.ranges.size() - 1;
newRanges.addAll(firstDay.ranges.subList(0, lastIdx));
}
final HourRange firstDayHR = firstDay.ranges.get(lastIdx);
newRanges.add(firstDayHR.joinWithNextDay(seondDayHR));
return new HourRanges(newRanges.toArray(new HourRange[newRanges.size()]));
} else {
throw new IllegalStateException(
"Normalized hour ranges returned an unexpected number of elements (" + normalized.size() + "): " + normalized);
}
}
|
java
|
public final HourRanges compress() {
final List<HourRanges> normalized = normalize();
if (normalized.size() == 1) {
return valueOf(normalized.get(0).toMinutes());
} else if (normalized.size() == 2) {
final HourRanges firstDay = valueOf(normalized.get(0).toMinutes());
final HourRanges secondDay = normalized.get(1);
if (secondDay.ranges.size() != 1) {
throw new IllegalStateException(
"Expected exactly 1 hour range for the seond day, but was " + secondDay.ranges.size() + ": " + secondDay);
}
final HourRange seondDayHR = secondDay.ranges.get(0);
final List<HourRange> newRanges = new ArrayList<>();
int lastIdx = 0;
if (firstDay.ranges.size() > 1) {
lastIdx = firstDay.ranges.size() - 1;
newRanges.addAll(firstDay.ranges.subList(0, lastIdx));
}
final HourRange firstDayHR = firstDay.ranges.get(lastIdx);
newRanges.add(firstDayHR.joinWithNextDay(seondDayHR));
return new HourRanges(newRanges.toArray(new HourRange[newRanges.size()]));
} else {
throw new IllegalStateException(
"Normalized hour ranges returned an unexpected number of elements (" + normalized.size() + "): " + normalized);
}
}
|
[
"public",
"final",
"HourRanges",
"compress",
"(",
")",
"{",
"final",
"List",
"<",
"HourRanges",
">",
"normalized",
"=",
"normalize",
"(",
")",
";",
"if",
"(",
"normalized",
".",
"size",
"(",
")",
"==",
"1",
")",
"{",
"return",
"valueOf",
"(",
"normalized",
".",
"get",
"(",
"0",
")",
".",
"toMinutes",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"normalized",
".",
"size",
"(",
")",
"==",
"2",
")",
"{",
"final",
"HourRanges",
"firstDay",
"=",
"valueOf",
"(",
"normalized",
".",
"get",
"(",
"0",
")",
".",
"toMinutes",
"(",
")",
")",
";",
"final",
"HourRanges",
"secondDay",
"=",
"normalized",
".",
"get",
"(",
"1",
")",
";",
"if",
"(",
"secondDay",
".",
"ranges",
".",
"size",
"(",
")",
"!=",
"1",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Expected exactly 1 hour range for the seond day, but was \"",
"+",
"secondDay",
".",
"ranges",
".",
"size",
"(",
")",
"+",
"\": \"",
"+",
"secondDay",
")",
";",
"}",
"final",
"HourRange",
"seondDayHR",
"=",
"secondDay",
".",
"ranges",
".",
"get",
"(",
"0",
")",
";",
"final",
"List",
"<",
"HourRange",
">",
"newRanges",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"int",
"lastIdx",
"=",
"0",
";",
"if",
"(",
"firstDay",
".",
"ranges",
".",
"size",
"(",
")",
">",
"1",
")",
"{",
"lastIdx",
"=",
"firstDay",
".",
"ranges",
".",
"size",
"(",
")",
"-",
"1",
";",
"newRanges",
".",
"addAll",
"(",
"firstDay",
".",
"ranges",
".",
"subList",
"(",
"0",
",",
"lastIdx",
")",
")",
";",
"}",
"final",
"HourRange",
"firstDayHR",
"=",
"firstDay",
".",
"ranges",
".",
"get",
"(",
"lastIdx",
")",
";",
"newRanges",
".",
"add",
"(",
"firstDayHR",
".",
"joinWithNextDay",
"(",
"seondDayHR",
")",
")",
";",
"return",
"new",
"HourRanges",
"(",
"newRanges",
".",
"toArray",
"(",
"new",
"HourRange",
"[",
"newRanges",
".",
"size",
"(",
")",
"]",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Normalized hour ranges returned an unexpected number of elements (\"",
"+",
"normalized",
".",
"size",
"(",
")",
"+",
"\"): \"",
"+",
"normalized",
")",
";",
"}",
"}"
] |
Returns a compressed version of the
@return
|
[
"Returns",
"a",
"compressed",
"version",
"of",
"the"
] |
e7f278b5bae073ebb6a76053650571c718f36246
|
https://github.com/fuinorg/objects4j/blob/e7f278b5bae073ebb6a76053650571c718f36246/src/main/java/org/fuin/objects4j/vo/HourRanges.java#L338-L368
|
148,209
|
acromusashi/acromusashi-stream
|
src/main/java/acromusashi/stream/resource/ResourceResolver.java
|
ResourceResolver.resolve
|
public static File resolve(Class<?> clazz, String path)
{
URL url = clazz.getResource(path);
if (url == null)
{
return null;
}
File result;
try
{
result = Paths.get(url.toURI()).toFile();
}
catch (URISyntaxException ex)
{
return null;
}
return result;
}
|
java
|
public static File resolve(Class<?> clazz, String path)
{
URL url = clazz.getResource(path);
if (url == null)
{
return null;
}
File result;
try
{
result = Paths.get(url.toURI()).toFile();
}
catch (URISyntaxException ex)
{
return null;
}
return result;
}
|
[
"public",
"static",
"File",
"resolve",
"(",
"Class",
"<",
"?",
">",
"clazz",
",",
"String",
"path",
")",
"{",
"URL",
"url",
"=",
"clazz",
".",
"getResource",
"(",
"path",
")",
";",
"if",
"(",
"url",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"File",
"result",
";",
"try",
"{",
"result",
"=",
"Paths",
".",
"get",
"(",
"url",
".",
"toURI",
"(",
")",
")",
".",
"toFile",
"(",
")",
";",
"}",
"catch",
"(",
"URISyntaxException",
"ex",
")",
"{",
"return",
"null",
";",
"}",
"return",
"result",
";",
"}"
] |
Return target file path from class and resource's path.
@param clazz Target class
@param path resource's path
@return File object
|
[
"Return",
"target",
"file",
"path",
"from",
"class",
"and",
"resource",
"s",
"path",
"."
] |
65b1f335d771d657c5640a2056ab5c8546eddec9
|
https://github.com/acromusashi/acromusashi-stream/blob/65b1f335d771d657c5640a2056ab5c8546eddec9/src/main/java/acromusashi/stream/resource/ResourceResolver.java#L45-L64
|
148,210
|
acromusashi/acromusashi-stream
|
src/main/java/acromusashi/stream/resource/ResourceResolver.java
|
ResourceResolver.resolveCaller
|
public static Class<?> resolveCaller()
{
Class<?> callerClass = null;
StackTraceElement[] stackTraces = Thread.currentThread().getStackTrace();
int stackSize = stackTraces.length;
// StackTrace is below. So check from 3rd element.
// 1st:java.lang.Thread
// 2nd:ResourceResolver#resolveCaller(this method)
for (int stackIndex = 2; stackIndex < stackSize; stackIndex++)
{
StackTraceElement stackTrace = stackTraces[stackIndex];
String callerClassName = stackTrace.getClassName();
if (StringUtils.equals(ResourceResolver.class.getName(), callerClassName) == false)
{
try
{
callerClass = Class.forName(callerClassName);
break;
}
catch (ClassNotFoundException ex)
{
return null;
}
}
}
return callerClass;
}
|
java
|
public static Class<?> resolveCaller()
{
Class<?> callerClass = null;
StackTraceElement[] stackTraces = Thread.currentThread().getStackTrace();
int stackSize = stackTraces.length;
// StackTrace is below. So check from 3rd element.
// 1st:java.lang.Thread
// 2nd:ResourceResolver#resolveCaller(this method)
for (int stackIndex = 2; stackIndex < stackSize; stackIndex++)
{
StackTraceElement stackTrace = stackTraces[stackIndex];
String callerClassName = stackTrace.getClassName();
if (StringUtils.equals(ResourceResolver.class.getName(), callerClassName) == false)
{
try
{
callerClass = Class.forName(callerClassName);
break;
}
catch (ClassNotFoundException ex)
{
return null;
}
}
}
return callerClass;
}
|
[
"public",
"static",
"Class",
"<",
"?",
">",
"resolveCaller",
"(",
")",
"{",
"Class",
"<",
"?",
">",
"callerClass",
"=",
"null",
";",
"StackTraceElement",
"[",
"]",
"stackTraces",
"=",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getStackTrace",
"(",
")",
";",
"int",
"stackSize",
"=",
"stackTraces",
".",
"length",
";",
"// StackTrace is below. So check from 3rd element.",
"// 1st:java.lang.Thread",
"// 2nd:ResourceResolver#resolveCaller(this method)",
"for",
"(",
"int",
"stackIndex",
"=",
"2",
";",
"stackIndex",
"<",
"stackSize",
";",
"stackIndex",
"++",
")",
"{",
"StackTraceElement",
"stackTrace",
"=",
"stackTraces",
"[",
"stackIndex",
"]",
";",
"String",
"callerClassName",
"=",
"stackTrace",
".",
"getClassName",
"(",
")",
";",
"if",
"(",
"StringUtils",
".",
"equals",
"(",
"ResourceResolver",
".",
"class",
".",
"getName",
"(",
")",
",",
"callerClassName",
")",
"==",
"false",
")",
"{",
"try",
"{",
"callerClass",
"=",
"Class",
".",
"forName",
"(",
"callerClassName",
")",
";",
"break",
";",
"}",
"catch",
"(",
"ClassNotFoundException",
"ex",
")",
"{",
"return",
"null",
";",
"}",
"}",
"}",
"return",
"callerClass",
";",
"}"
] |
Return caller class calling this class's method.
@return Caller class
|
[
"Return",
"caller",
"class",
"calling",
"this",
"class",
"s",
"method",
"."
] |
65b1f335d771d657c5640a2056ab5c8546eddec9
|
https://github.com/acromusashi/acromusashi-stream/blob/65b1f335d771d657c5640a2056ab5c8546eddec9/src/main/java/acromusashi/stream/resource/ResourceResolver.java#L192-L221
|
148,211
|
Commonjava/webdav-handler
|
common/src/main/java/net/sf/webdav/methods/DoGet.java
|
DoGet.getCSS
|
protected String getCSS()
{
// The default styles to use
String retVal =
"body {\n" + " font-family: Arial, Helvetica, sans-serif;\n" + "}\n" + "h1 {\n" + " font-size: 1.5em;\n" + "}\n" + "th {\n"
+ " background-color: #9DACBF;\n" + "}\n" + "table {\n" + " border-top-style: solid;\n" + " border-right-style: solid;\n"
+ " border-bottom-style: solid;\n" + " border-left-style: solid;\n" + "}\n" + "td {\n" + " margin: 0px;\n" + " padding-top: 2px;\n"
+ " padding-right: 5px;\n" + " padding-bottom: 2px;\n" + " padding-left: 5px;\n" + "}\n" + "tr.even {\n"
+ " background-color: #CCCCCC;\n" + "}\n" + "tr.odd {\n" + " background-color: #FFFFFF;\n" + "}\n" + "";
try
{
// Try loading one via class loader and use that one instead
final ClassLoader cl = getClass().getClassLoader();
final InputStream iStream = cl.getResourceAsStream( "webdav.css" );
if ( iStream != null )
{
// Found css via class loader, use that one
final StringBuilder out = new StringBuilder();
final byte[] b = new byte[4096];
for ( int n; ( n = iStream.read( b ) ) != -1; )
{
out.append( new String( b, 0, n ) );
}
retVal = out.toString();
}
}
catch ( final Exception ex )
{
LOG.error( "Error in reading webdav.css", ex );
}
return retVal;
}
|
java
|
protected String getCSS()
{
// The default styles to use
String retVal =
"body {\n" + " font-family: Arial, Helvetica, sans-serif;\n" + "}\n" + "h1 {\n" + " font-size: 1.5em;\n" + "}\n" + "th {\n"
+ " background-color: #9DACBF;\n" + "}\n" + "table {\n" + " border-top-style: solid;\n" + " border-right-style: solid;\n"
+ " border-bottom-style: solid;\n" + " border-left-style: solid;\n" + "}\n" + "td {\n" + " margin: 0px;\n" + " padding-top: 2px;\n"
+ " padding-right: 5px;\n" + " padding-bottom: 2px;\n" + " padding-left: 5px;\n" + "}\n" + "tr.even {\n"
+ " background-color: #CCCCCC;\n" + "}\n" + "tr.odd {\n" + " background-color: #FFFFFF;\n" + "}\n" + "";
try
{
// Try loading one via class loader and use that one instead
final ClassLoader cl = getClass().getClassLoader();
final InputStream iStream = cl.getResourceAsStream( "webdav.css" );
if ( iStream != null )
{
// Found css via class loader, use that one
final StringBuilder out = new StringBuilder();
final byte[] b = new byte[4096];
for ( int n; ( n = iStream.read( b ) ) != -1; )
{
out.append( new String( b, 0, n ) );
}
retVal = out.toString();
}
}
catch ( final Exception ex )
{
LOG.error( "Error in reading webdav.css", ex );
}
return retVal;
}
|
[
"protected",
"String",
"getCSS",
"(",
")",
"{",
"// The default styles to use",
"String",
"retVal",
"=",
"\"body {\\n\"",
"+",
"\"\tfont-family: Arial, Helvetica, sans-serif;\\n\"",
"+",
"\"}\\n\"",
"+",
"\"h1 {\\n\"",
"+",
"\"\tfont-size: 1.5em;\\n\"",
"+",
"\"}\\n\"",
"+",
"\"th {\\n\"",
"+",
"\"\tbackground-color: #9DACBF;\\n\"",
"+",
"\"}\\n\"",
"+",
"\"table {\\n\"",
"+",
"\"\tborder-top-style: solid;\\n\"",
"+",
"\"\tborder-right-style: solid;\\n\"",
"+",
"\"\tborder-bottom-style: solid;\\n\"",
"+",
"\"\tborder-left-style: solid;\\n\"",
"+",
"\"}\\n\"",
"+",
"\"td {\\n\"",
"+",
"\"\tmargin: 0px;\\n\"",
"+",
"\"\tpadding-top: 2px;\\n\"",
"+",
"\"\tpadding-right: 5px;\\n\"",
"+",
"\"\tpadding-bottom: 2px;\\n\"",
"+",
"\"\tpadding-left: 5px;\\n\"",
"+",
"\"}\\n\"",
"+",
"\"tr.even {\\n\"",
"+",
"\"\tbackground-color: #CCCCCC;\\n\"",
"+",
"\"}\\n\"",
"+",
"\"tr.odd {\\n\"",
"+",
"\"\tbackground-color: #FFFFFF;\\n\"",
"+",
"\"}\\n\"",
"+",
"\"\"",
";",
"try",
"{",
"// Try loading one via class loader and use that one instead",
"final",
"ClassLoader",
"cl",
"=",
"getClass",
"(",
")",
".",
"getClassLoader",
"(",
")",
";",
"final",
"InputStream",
"iStream",
"=",
"cl",
".",
"getResourceAsStream",
"(",
"\"webdav.css\"",
")",
";",
"if",
"(",
"iStream",
"!=",
"null",
")",
"{",
"// Found css via class loader, use that one",
"final",
"StringBuilder",
"out",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"final",
"byte",
"[",
"]",
"b",
"=",
"new",
"byte",
"[",
"4096",
"]",
";",
"for",
"(",
"int",
"n",
";",
"(",
"n",
"=",
"iStream",
".",
"read",
"(",
"b",
")",
")",
"!=",
"-",
"1",
";",
")",
"{",
"out",
".",
"append",
"(",
"new",
"String",
"(",
"b",
",",
"0",
",",
"n",
")",
")",
";",
"}",
"retVal",
"=",
"out",
".",
"toString",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"final",
"Exception",
"ex",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Error in reading webdav.css\"",
",",
"ex",
")",
";",
"}",
"return",
"retVal",
";",
"}"
] |
Return the CSS styles used to display the HTML representation
of the webdav content.
@return String returning the CSS style sheet used to display result in html format
|
[
"Return",
"the",
"CSS",
"styles",
"used",
"to",
"display",
"the",
"HTML",
"representation",
"of",
"the",
"webdav",
"content",
"."
] |
39bb7032fc75c1b67d3f2440dd1c234ead96cb9d
|
https://github.com/Commonjava/webdav-handler/blob/39bb7032fc75c1b67d3f2440dd1c234ead96cb9d/common/src/main/java/net/sf/webdav/methods/DoGet.java#L215-L247
|
148,212
|
fuinorg/objects4j
|
src/main/java/org/fuin/objects4j/vo/DayOfTheWeek.java
|
DayOfTheWeek.next
|
public DayOfTheWeek next() {
if (this == PH) {
return null;
}
final int nextId = id + 1;
if (nextId == PH.id) {
return MON;
}
for (final DayOfTheWeek dow : ALL) {
if (dow.id == nextId) {
return dow;
}
}
throw new IllegalStateException("Wasn't able to find next day for: " + this);
}
|
java
|
public DayOfTheWeek next() {
if (this == PH) {
return null;
}
final int nextId = id + 1;
if (nextId == PH.id) {
return MON;
}
for (final DayOfTheWeek dow : ALL) {
if (dow.id == nextId) {
return dow;
}
}
throw new IllegalStateException("Wasn't able to find next day for: " + this);
}
|
[
"public",
"DayOfTheWeek",
"next",
"(",
")",
"{",
"if",
"(",
"this",
"==",
"PH",
")",
"{",
"return",
"null",
";",
"}",
"final",
"int",
"nextId",
"=",
"id",
"+",
"1",
";",
"if",
"(",
"nextId",
"==",
"PH",
".",
"id",
")",
"{",
"return",
"MON",
";",
"}",
"for",
"(",
"final",
"DayOfTheWeek",
"dow",
":",
"ALL",
")",
"{",
"if",
"(",
"dow",
".",
"id",
"==",
"nextId",
")",
"{",
"return",
"dow",
";",
"}",
"}",
"throw",
"new",
"IllegalStateException",
"(",
"\"Wasn't able to find next day for: \"",
"+",
"this",
")",
";",
"}"
] |
Returns the next day.
@return Day that follows this one. In case of {@link #PH} {@literal null} is returned.
|
[
"Returns",
"the",
"next",
"day",
"."
] |
e7f278b5bae073ebb6a76053650571c718f36246
|
https://github.com/fuinorg/objects4j/blob/e7f278b5bae073ebb6a76053650571c718f36246/src/main/java/org/fuin/objects4j/vo/DayOfTheWeek.java#L136-L150
|
148,213
|
fuinorg/objects4j
|
src/main/java/org/fuin/objects4j/vo/DayOfTheWeek.java
|
DayOfTheWeek.previous
|
public DayOfTheWeek previous() {
if (this == PH) {
return null;
}
final int nextId = id - 1;
for (final DayOfTheWeek dow : ALL) {
if (dow.id == nextId) {
return dow;
}
}
return SUN;
}
|
java
|
public DayOfTheWeek previous() {
if (this == PH) {
return null;
}
final int nextId = id - 1;
for (final DayOfTheWeek dow : ALL) {
if (dow.id == nextId) {
return dow;
}
}
return SUN;
}
|
[
"public",
"DayOfTheWeek",
"previous",
"(",
")",
"{",
"if",
"(",
"this",
"==",
"PH",
")",
"{",
"return",
"null",
";",
"}",
"final",
"int",
"nextId",
"=",
"id",
"-",
"1",
";",
"for",
"(",
"final",
"DayOfTheWeek",
"dow",
":",
"ALL",
")",
"{",
"if",
"(",
"dow",
".",
"id",
"==",
"nextId",
")",
"{",
"return",
"dow",
";",
"}",
"}",
"return",
"SUN",
";",
"}"
] |
Returns the previous day.
@return Day before this one. In case of {@link #PH} {@literal null} is returned.
|
[
"Returns",
"the",
"previous",
"day",
"."
] |
e7f278b5bae073ebb6a76053650571c718f36246
|
https://github.com/fuinorg/objects4j/blob/e7f278b5bae073ebb6a76053650571c718f36246/src/main/java/org/fuin/objects4j/vo/DayOfTheWeek.java#L157-L168
|
148,214
|
fuinorg/objects4j
|
src/main/java/org/fuin/objects4j/vo/DayOfTheWeek.java
|
DayOfTheWeek.isValid
|
public static boolean isValid(@Nullable final String dayOfTheWeek) {
if (dayOfTheWeek == null) {
return true;
}
for (final DayOfTheWeek dow : ALL) {
if (dow.value.equalsIgnoreCase(dayOfTheWeek)) {
return true;
}
}
return false;
}
|
java
|
public static boolean isValid(@Nullable final String dayOfTheWeek) {
if (dayOfTheWeek == null) {
return true;
}
for (final DayOfTheWeek dow : ALL) {
if (dow.value.equalsIgnoreCase(dayOfTheWeek)) {
return true;
}
}
return false;
}
|
[
"public",
"static",
"boolean",
"isValid",
"(",
"@",
"Nullable",
"final",
"String",
"dayOfTheWeek",
")",
"{",
"if",
"(",
"dayOfTheWeek",
"==",
"null",
")",
"{",
"return",
"true",
";",
"}",
"for",
"(",
"final",
"DayOfTheWeek",
"dow",
":",
"ALL",
")",
"{",
"if",
"(",
"dow",
".",
"value",
".",
"equalsIgnoreCase",
"(",
"dayOfTheWeek",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Verifies if the string is a valid dayOfTheWeek.
@param dayOfTheWeek
Weekday string to test.
@return {@literal true} if the string is a valid number, else {@literal false}.
|
[
"Verifies",
"if",
"the",
"string",
"is",
"a",
"valid",
"dayOfTheWeek",
"."
] |
e7f278b5bae073ebb6a76053650571c718f36246
|
https://github.com/fuinorg/objects4j/blob/e7f278b5bae073ebb6a76053650571c718f36246/src/main/java/org/fuin/objects4j/vo/DayOfTheWeek.java#L251-L261
|
148,215
|
fuinorg/objects4j
|
src/main/java/org/fuin/objects4j/vo/DayOfTheWeek.java
|
DayOfTheWeek.valueOf
|
@Nullable
public static DayOfTheWeek valueOf(@Nullable final DayOfWeek dayOfWeek) {
if (dayOfWeek == null) {
return null;
}
final int value = dayOfWeek.getValue();
for (final DayOfTheWeek dow : ALL) {
if (value == dow.id) {
return dow;
}
}
throw new IllegalArgumentException("Unknown day week: " + dayOfWeek);
}
|
java
|
@Nullable
public static DayOfTheWeek valueOf(@Nullable final DayOfWeek dayOfWeek) {
if (dayOfWeek == null) {
return null;
}
final int value = dayOfWeek.getValue();
for (final DayOfTheWeek dow : ALL) {
if (value == dow.id) {
return dow;
}
}
throw new IllegalArgumentException("Unknown day week: " + dayOfWeek);
}
|
[
"@",
"Nullable",
"public",
"static",
"DayOfTheWeek",
"valueOf",
"(",
"@",
"Nullable",
"final",
"DayOfWeek",
"dayOfWeek",
")",
"{",
"if",
"(",
"dayOfWeek",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"final",
"int",
"value",
"=",
"dayOfWeek",
".",
"getValue",
"(",
")",
";",
"for",
"(",
"final",
"DayOfTheWeek",
"dow",
":",
"ALL",
")",
"{",
"if",
"(",
"value",
"==",
"dow",
".",
"id",
")",
"{",
"return",
"dow",
";",
"}",
"}",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unknown day week: \"",
"+",
"dayOfWeek",
")",
";",
"}"
] |
Converts the instance into java time instance.
@return Day of week.
|
[
"Converts",
"the",
"instance",
"into",
"java",
"time",
"instance",
"."
] |
e7f278b5bae073ebb6a76053650571c718f36246
|
https://github.com/fuinorg/objects4j/blob/e7f278b5bae073ebb6a76053650571c718f36246/src/main/java/org/fuin/objects4j/vo/DayOfTheWeek.java#L289-L301
|
148,216
|
groundupworks/wings
|
wings/src/main/java/com/groundupworks/wings/Wings.java
|
Wings.getEndpoint
|
public static final WingsEndpoint getEndpoint(Class<? extends WingsEndpoint> endpointClazz) throws IllegalStateException {
if (!sIsInitialized) {
throw new IllegalStateException("Wings must be initialized. See Wings#init().");
}
WingsEndpoint selectedEndpoint = null;
for (WingsEndpoint endpoint : sEndpoints) {
if (endpointClazz.isInstance(endpoint)) {
selectedEndpoint = endpoint;
break;
}
}
return selectedEndpoint;
}
|
java
|
public static final WingsEndpoint getEndpoint(Class<? extends WingsEndpoint> endpointClazz) throws IllegalStateException {
if (!sIsInitialized) {
throw new IllegalStateException("Wings must be initialized. See Wings#init().");
}
WingsEndpoint selectedEndpoint = null;
for (WingsEndpoint endpoint : sEndpoints) {
if (endpointClazz.isInstance(endpoint)) {
selectedEndpoint = endpoint;
break;
}
}
return selectedEndpoint;
}
|
[
"public",
"static",
"final",
"WingsEndpoint",
"getEndpoint",
"(",
"Class",
"<",
"?",
"extends",
"WingsEndpoint",
">",
"endpointClazz",
")",
"throws",
"IllegalStateException",
"{",
"if",
"(",
"!",
"sIsInitialized",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Wings must be initialized. See Wings#init().\"",
")",
";",
"}",
"WingsEndpoint",
"selectedEndpoint",
"=",
"null",
";",
"for",
"(",
"WingsEndpoint",
"endpoint",
":",
"sEndpoints",
")",
"{",
"if",
"(",
"endpointClazz",
".",
"isInstance",
"(",
"endpoint",
")",
")",
"{",
"selectedEndpoint",
"=",
"endpoint",
";",
"break",
";",
"}",
"}",
"return",
"selectedEndpoint",
";",
"}"
] |
Gets the instance of a specific endpoint that Wings can share to.
@param endpointClazz the endpoint {@link java.lang.Class}.
@return the endpoint instance; or {@code null} if unavailable.
@throws IllegalStateException Wings must be initialized. See {@link Wings#init(IWingsModule, Class[])}.
|
[
"Gets",
"the",
"instance",
"of",
"a",
"specific",
"endpoint",
"that",
"Wings",
"can",
"share",
"to",
"."
] |
03d2827c30ef55f2db4e23f7500e016c7771fa39
|
https://github.com/groundupworks/wings/blob/03d2827c30ef55f2db4e23f7500e016c7771fa39/wings/src/main/java/com/groundupworks/wings/Wings.java#L123-L136
|
148,217
|
groundupworks/wings
|
wings/src/main/java/com/groundupworks/wings/Wings.java
|
Wings.unsubscribe
|
public static void unsubscribe(Object object) throws IllegalStateException {
if (!sIsInitialized) {
throw new IllegalStateException("Wings must be initialized. See Wings#init().");
}
WingsInjector.getBus().unregister(object);
}
|
java
|
public static void unsubscribe(Object object) throws IllegalStateException {
if (!sIsInitialized) {
throw new IllegalStateException("Wings must be initialized. See Wings#init().");
}
WingsInjector.getBus().unregister(object);
}
|
[
"public",
"static",
"void",
"unsubscribe",
"(",
"Object",
"object",
")",
"throws",
"IllegalStateException",
"{",
"if",
"(",
"!",
"sIsInitialized",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Wings must be initialized. See Wings#init().\"",
")",
";",
"}",
"WingsInjector",
".",
"getBus",
"(",
")",
".",
"unregister",
"(",
"object",
")",
";",
"}"
] |
Unsubscribes to link state changes of the endpoints.
@param object the {@link java.lang.Object} you wish to unsubscribe.
@throws IllegalStateException Wings must be initialized. See {@link Wings#init(IWingsModule, Class[])}.
|
[
"Unsubscribes",
"to",
"link",
"state",
"changes",
"of",
"the",
"endpoints",
"."
] |
03d2827c30ef55f2db4e23f7500e016c7771fa39
|
https://github.com/groundupworks/wings/blob/03d2827c30ef55f2db4e23f7500e016c7771fa39/wings/src/main/java/com/groundupworks/wings/Wings.java#L164-L169
|
148,218
|
groundupworks/wings
|
wings/src/main/java/com/groundupworks/wings/Wings.java
|
Wings.share
|
public static boolean share(String filePath, Class<? extends WingsEndpoint> endpointClazz) throws IllegalStateException {
if (!sIsInitialized) {
throw new IllegalStateException("Wings must be initialized. See Wings#init().");
}
WingsEndpoint endpoint = Wings.getEndpoint(endpointClazz);
if (endpoint != null) {
WingsEndpoint.LinkInfo linkInfo = endpoint.getLinkInfo();
if (linkInfo != null
&& WingsInjector.getDatabase().createShareRequest(filePath, new Destination(linkInfo.mDestinationId, endpoint.getEndpointId()))) {
WingsService.startWakefulService(WingsInjector.getApplicationContext());
return true;
}
}
return false;
}
|
java
|
public static boolean share(String filePath, Class<? extends WingsEndpoint> endpointClazz) throws IllegalStateException {
if (!sIsInitialized) {
throw new IllegalStateException("Wings must be initialized. See Wings#init().");
}
WingsEndpoint endpoint = Wings.getEndpoint(endpointClazz);
if (endpoint != null) {
WingsEndpoint.LinkInfo linkInfo = endpoint.getLinkInfo();
if (linkInfo != null
&& WingsInjector.getDatabase().createShareRequest(filePath, new Destination(linkInfo.mDestinationId, endpoint.getEndpointId()))) {
WingsService.startWakefulService(WingsInjector.getApplicationContext());
return true;
}
}
return false;
}
|
[
"public",
"static",
"boolean",
"share",
"(",
"String",
"filePath",
",",
"Class",
"<",
"?",
"extends",
"WingsEndpoint",
">",
"endpointClazz",
")",
"throws",
"IllegalStateException",
"{",
"if",
"(",
"!",
"sIsInitialized",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Wings must be initialized. See Wings#init().\"",
")",
";",
"}",
"WingsEndpoint",
"endpoint",
"=",
"Wings",
".",
"getEndpoint",
"(",
"endpointClazz",
")",
";",
"if",
"(",
"endpoint",
"!=",
"null",
")",
"{",
"WingsEndpoint",
".",
"LinkInfo",
"linkInfo",
"=",
"endpoint",
".",
"getLinkInfo",
"(",
")",
";",
"if",
"(",
"linkInfo",
"!=",
"null",
"&&",
"WingsInjector",
".",
"getDatabase",
"(",
")",
".",
"createShareRequest",
"(",
"filePath",
",",
"new",
"Destination",
"(",
"linkInfo",
".",
"mDestinationId",
",",
"endpoint",
".",
"getEndpointId",
"(",
")",
")",
")",
")",
"{",
"WingsService",
".",
"startWakefulService",
"(",
"WingsInjector",
".",
"getApplicationContext",
"(",
")",
")",
";",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Shares an image to the specified endpoint. The client is responsible for ensuring that the file
exists and the endpoint is linked.
@param filePath the local path to the file to share.
@param endpointClazz the {@link java.lang.Class} of the endpoint to share to.
@return {@code true} if successful; {@code false} otherwise.
@throws IllegalStateException Wings must be initialized. See {@link Wings#init(IWingsModule, Class[])}.
|
[
"Shares",
"an",
"image",
"to",
"the",
"specified",
"endpoint",
".",
"The",
"client",
"is",
"responsible",
"for",
"ensuring",
"that",
"the",
"file",
"exists",
"and",
"the",
"endpoint",
"is",
"linked",
"."
] |
03d2827c30ef55f2db4e23f7500e016c7771fa39
|
https://github.com/groundupworks/wings/blob/03d2827c30ef55f2db4e23f7500e016c7771fa39/wings/src/main/java/com/groundupworks/wings/Wings.java#L180-L195
|
148,219
|
torakiki/sejda-io
|
src/main/java/org/sejda/io/util/IOUtils.java
|
IOUtils.unmapper
|
private static Consumer<ByteBuffer> unmapper() {
final Lookup lookup = lookup();
try {
// *** sun.misc.Unsafe unmapping (Java 9+) ***
final Class<?> unsafeClass = Class.forName("sun.misc.Unsafe");
// first check if Unsafe has the right method, otherwise we can give up
// without doing any security critical stuff:
final MethodHandle unmapper = lookup.findVirtual(unsafeClass, "invokeCleaner",
methodType(void.class, ByteBuffer.class));
// fetch the unsafe instance and bind it to the virtual MH:
final Field f = unsafeClass.getDeclaredField("theUnsafe");
f.setAccessible(true);
final Object theUnsafe = f.get(null);
return newBufferCleaner(ByteBuffer.class, unmapper.bindTo(theUnsafe));
} catch (SecurityException se) {
LOG.error(
"Unmapping is not supported because of missing permissions. Please grant at least the following permissions: RuntimePermission(\"accessClassInPackage.sun.misc\") "
+ " and ReflectPermission(\"suppressAccessChecks\")",
se);
} catch (ReflectiveOperationException | RuntimeException e) {
LOG.error("Unmapping is not supported.", e);
}
return null;
}
|
java
|
private static Consumer<ByteBuffer> unmapper() {
final Lookup lookup = lookup();
try {
// *** sun.misc.Unsafe unmapping (Java 9+) ***
final Class<?> unsafeClass = Class.forName("sun.misc.Unsafe");
// first check if Unsafe has the right method, otherwise we can give up
// without doing any security critical stuff:
final MethodHandle unmapper = lookup.findVirtual(unsafeClass, "invokeCleaner",
methodType(void.class, ByteBuffer.class));
// fetch the unsafe instance and bind it to the virtual MH:
final Field f = unsafeClass.getDeclaredField("theUnsafe");
f.setAccessible(true);
final Object theUnsafe = f.get(null);
return newBufferCleaner(ByteBuffer.class, unmapper.bindTo(theUnsafe));
} catch (SecurityException se) {
LOG.error(
"Unmapping is not supported because of missing permissions. Please grant at least the following permissions: RuntimePermission(\"accessClassInPackage.sun.misc\") "
+ " and ReflectPermission(\"suppressAccessChecks\")",
se);
} catch (ReflectiveOperationException | RuntimeException e) {
LOG.error("Unmapping is not supported.", e);
}
return null;
}
|
[
"private",
"static",
"Consumer",
"<",
"ByteBuffer",
">",
"unmapper",
"(",
")",
"{",
"final",
"Lookup",
"lookup",
"=",
"lookup",
"(",
")",
";",
"try",
"{",
"// *** sun.misc.Unsafe unmapping (Java 9+) ***",
"final",
"Class",
"<",
"?",
">",
"unsafeClass",
"=",
"Class",
".",
"forName",
"(",
"\"sun.misc.Unsafe\"",
")",
";",
"// first check if Unsafe has the right method, otherwise we can give up",
"// without doing any security critical stuff:",
"final",
"MethodHandle",
"unmapper",
"=",
"lookup",
".",
"findVirtual",
"(",
"unsafeClass",
",",
"\"invokeCleaner\"",
",",
"methodType",
"(",
"void",
".",
"class",
",",
"ByteBuffer",
".",
"class",
")",
")",
";",
"// fetch the unsafe instance and bind it to the virtual MH:",
"final",
"Field",
"f",
"=",
"unsafeClass",
".",
"getDeclaredField",
"(",
"\"theUnsafe\"",
")",
";",
"f",
".",
"setAccessible",
"(",
"true",
")",
";",
"final",
"Object",
"theUnsafe",
"=",
"f",
".",
"get",
"(",
"null",
")",
";",
"return",
"newBufferCleaner",
"(",
"ByteBuffer",
".",
"class",
",",
"unmapper",
".",
"bindTo",
"(",
"theUnsafe",
")",
")",
";",
"}",
"catch",
"(",
"SecurityException",
"se",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Unmapping is not supported because of missing permissions. Please grant at least the following permissions: RuntimePermission(\\\"accessClassInPackage.sun.misc\\\") \"",
"+",
"\" and ReflectPermission(\\\"suppressAccessChecks\\\")\"",
",",
"se",
")",
";",
"}",
"catch",
"(",
"ReflectiveOperationException",
"|",
"RuntimeException",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Unmapping is not supported.\"",
",",
"e",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
This is adapted from org.apache.lucene.store.MMapDirectory
@return
|
[
"This",
"is",
"adapted",
"from",
"org",
".",
"apache",
".",
"lucene",
".",
"store",
".",
"MMapDirectory"
] |
93840416c49a9c540979545c1264055406737d75
|
https://github.com/torakiki/sejda-io/blob/93840416c49a9c540979545c1264055406737d75/src/main/java/org/sejda/io/util/IOUtils.java#L72-L96
|
148,220
|
zamrokk/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/Chain.java
|
Chain.addPeer
|
public Peer addPeer(String url, String pem) {
Peer peer = new Peer(url, pem, this);
this.peers.add(peer);
return peer;
}
|
java
|
public Peer addPeer(String url, String pem) {
Peer peer = new Peer(url, pem, this);
this.peers.add(peer);
return peer;
}
|
[
"public",
"Peer",
"addPeer",
"(",
"String",
"url",
",",
"String",
"pem",
")",
"{",
"Peer",
"peer",
"=",
"new",
"Peer",
"(",
"url",
",",
"pem",
",",
"this",
")",
";",
"this",
".",
"peers",
".",
"add",
"(",
"peer",
")",
";",
"return",
"peer",
";",
"}"
] |
Add a peer given an endpoint specification.
@param url URL of the peer
@param pem permission
@return a new peer.
|
[
"Add",
"a",
"peer",
"given",
"an",
"endpoint",
"specification",
"."
] |
d4993ca602f72d412cd682e1b92e805e48b27afa
|
https://github.com/zamrokk/fabric-sdk-java/blob/d4993ca602f72d412cd682e1b92e805e48b27afa/src/main/java/org/hyperledger/fabric/sdk/Chain.java#L99-L103
|
148,221
|
zamrokk/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/Chain.java
|
Chain.setMemberServicesUrl
|
public void setMemberServicesUrl(String url, String pem) throws CertificateException {
this.setMemberServices(new MemberServicesImpl(url,pem));
}
|
java
|
public void setMemberServicesUrl(String url, String pem) throws CertificateException {
this.setMemberServices(new MemberServicesImpl(url,pem));
}
|
[
"public",
"void",
"setMemberServicesUrl",
"(",
"String",
"url",
",",
"String",
"pem",
")",
"throws",
"CertificateException",
"{",
"this",
".",
"setMemberServices",
"(",
"new",
"MemberServicesImpl",
"(",
"url",
",",
"pem",
")",
")",
";",
"}"
] |
Set the member services URL
@param url Member services URL of the form: "grpc://host:port" or "grpcs://host:port"
@param pem permission
@throws CertificateException exception
|
[
"Set",
"the",
"member",
"services",
"URL"
] |
d4993ca602f72d412cd682e1b92e805e48b27afa
|
https://github.com/zamrokk/fabric-sdk-java/blob/d4993ca602f72d412cd682e1b92e805e48b27afa/src/main/java/org/hyperledger/fabric/sdk/Chain.java#L135-L137
|
148,222
|
zamrokk/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/Chain.java
|
Chain.setMemberServices
|
public void setMemberServices(MemberServices memberServices) {
this.memberServices = memberServices;
if (memberServices instanceof MemberServicesImpl) {
this.cryptoPrimitives = ((MemberServicesImpl) memberServices).getCrypto();
}
}
|
java
|
public void setMemberServices(MemberServices memberServices) {
this.memberServices = memberServices;
if (memberServices instanceof MemberServicesImpl) {
this.cryptoPrimitives = ((MemberServicesImpl) memberServices).getCrypto();
}
}
|
[
"public",
"void",
"setMemberServices",
"(",
"MemberServices",
"memberServices",
")",
"{",
"this",
".",
"memberServices",
"=",
"memberServices",
";",
"if",
"(",
"memberServices",
"instanceof",
"MemberServicesImpl",
")",
"{",
"this",
".",
"cryptoPrimitives",
"=",
"(",
"(",
"MemberServicesImpl",
")",
"memberServices",
")",
".",
"getCrypto",
"(",
")",
";",
"}",
"}"
] |
Set the member service
@param memberServices The MemberServices instance
|
[
"Set",
"the",
"member",
"service"
] |
d4993ca602f72d412cd682e1b92e805e48b27afa
|
https://github.com/zamrokk/fabric-sdk-java/blob/d4993ca602f72d412cd682e1b92e805e48b27afa/src/main/java/org/hyperledger/fabric/sdk/Chain.java#L151-L156
|
148,223
|
zamrokk/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/Chain.java
|
Chain.eventHubConnect
|
public void eventHubConnect(String peerUrl, String pem) {
this.eventHub.setPeerAddr(peerUrl, pem);
this.eventHub.connect();
}
|
java
|
public void eventHubConnect(String peerUrl, String pem) {
this.eventHub.setPeerAddr(peerUrl, pem);
this.eventHub.connect();
}
|
[
"public",
"void",
"eventHubConnect",
"(",
"String",
"peerUrl",
",",
"String",
"pem",
")",
"{",
"this",
".",
"eventHub",
".",
"setPeerAddr",
"(",
"peerUrl",
",",
"pem",
")",
";",
"this",
".",
"eventHub",
".",
"connect",
"(",
")",
";",
"}"
] |
Set and connect to the peer to be used as the event source.
@param peerUrl peerUrl
@param pem permission
|
[
"Set",
"and",
"connect",
"to",
"the",
"peer",
"to",
"be",
"used",
"as",
"the",
"event",
"source",
"."
] |
d4993ca602f72d412cd682e1b92e805e48b27afa
|
https://github.com/zamrokk/fabric-sdk-java/blob/d4993ca602f72d412cd682e1b92e805e48b27afa/src/main/java/org/hyperledger/fabric/sdk/Chain.java#L275-L278
|
148,224
|
zamrokk/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/Chain.java
|
Chain.getMember
|
public Member getMember(String name) {
if (null == keyValStore) throw new RuntimeException("No key value store was found. You must first call Chain.setKeyValStore");
if (null == memberServices) throw new RuntimeException("No member services was found. You must first call Chain.setMemberServices or Chain.setMemberServicesUrl");
// Try to get the member state from the cache
Member member = (Member) members.get(name);
if (null != member) return member;
// Create the member and try to restore it's state from the key value store (if found).
member = new Member(name, this);
member.restoreState();
return member;
}
|
java
|
public Member getMember(String name) {
if (null == keyValStore) throw new RuntimeException("No key value store was found. You must first call Chain.setKeyValStore");
if (null == memberServices) throw new RuntimeException("No member services was found. You must first call Chain.setMemberServices or Chain.setMemberServicesUrl");
// Try to get the member state from the cache
Member member = (Member) members.get(name);
if (null != member) return member;
// Create the member and try to restore it's state from the key value store (if found).
member = new Member(name, this);
member.restoreState();
return member;
}
|
[
"public",
"Member",
"getMember",
"(",
"String",
"name",
")",
"{",
"if",
"(",
"null",
"==",
"keyValStore",
")",
"throw",
"new",
"RuntimeException",
"(",
"\"No key value store was found. You must first call Chain.setKeyValStore\"",
")",
";",
"if",
"(",
"null",
"==",
"memberServices",
")",
"throw",
"new",
"RuntimeException",
"(",
"\"No member services was found. You must first call Chain.setMemberServices or Chain.setMemberServicesUrl\"",
")",
";",
"// Try to get the member state from the cache",
"Member",
"member",
"=",
"(",
"Member",
")",
"members",
".",
"get",
"(",
"name",
")",
";",
"if",
"(",
"null",
"!=",
"member",
")",
"return",
"member",
";",
"// Create the member and try to restore it's state from the key value store (if found).",
"member",
"=",
"new",
"Member",
"(",
"name",
",",
"this",
")",
";",
"member",
".",
"restoreState",
"(",
")",
";",
"return",
"member",
";",
"}"
] |
Get the member with a given name
@param name name of the member
@return member
|
[
"Get",
"the",
"member",
"with",
"a",
"given",
"name"
] |
d4993ca602f72d412cd682e1b92e805e48b27afa
|
https://github.com/zamrokk/fabric-sdk-java/blob/d4993ca602f72d412cd682e1b92e805e48b27afa/src/main/java/org/hyperledger/fabric/sdk/Chain.java#L292-L305
|
148,225
|
zamrokk/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/Chain.java
|
Chain.register
|
public Member register(RegistrationRequest registrationRequest) throws RegistrationException {
Member member = getMember(registrationRequest.getEnrollmentID());
member.register(registrationRequest);
return member;
}
|
java
|
public Member register(RegistrationRequest registrationRequest) throws RegistrationException {
Member member = getMember(registrationRequest.getEnrollmentID());
member.register(registrationRequest);
return member;
}
|
[
"public",
"Member",
"register",
"(",
"RegistrationRequest",
"registrationRequest",
")",
"throws",
"RegistrationException",
"{",
"Member",
"member",
"=",
"getMember",
"(",
"registrationRequest",
".",
"getEnrollmentID",
"(",
")",
")",
";",
"member",
".",
"register",
"(",
"registrationRequest",
")",
";",
"return",
"member",
";",
"}"
] |
Register a user or other member type with the chain.
@param registrationRequest Registration information.
@throws RegistrationException if the registration fails
@return
|
[
"Register",
"a",
"user",
"or",
"other",
"member",
"type",
"with",
"the",
"chain",
"."
] |
d4993ca602f72d412cd682e1b92e805e48b27afa
|
https://github.com/zamrokk/fabric-sdk-java/blob/d4993ca602f72d412cd682e1b92e805e48b27afa/src/main/java/org/hyperledger/fabric/sdk/Chain.java#L325-L329
|
148,226
|
zamrokk/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/Chain.java
|
Chain.enroll
|
public Member enroll(String name, String secret) throws EnrollmentException {
Member member = getMember(name);
member.enroll(secret);
members.put(name, member);
return member;
}
|
java
|
public Member enroll(String name, String secret) throws EnrollmentException {
Member member = getMember(name);
member.enroll(secret);
members.put(name, member);
return member;
}
|
[
"public",
"Member",
"enroll",
"(",
"String",
"name",
",",
"String",
"secret",
")",
"throws",
"EnrollmentException",
"{",
"Member",
"member",
"=",
"getMember",
"(",
"name",
")",
";",
"member",
".",
"enroll",
"(",
"secret",
")",
";",
"members",
".",
"put",
"(",
"name",
",",
"member",
")",
";",
"return",
"member",
";",
"}"
] |
Enroll a user or other identity which has already been registered.
@param name The name of the user or other member to enroll.
@param secret The enrollment secret of the user or other member to enroll.
@throws EnrollmentException
|
[
"Enroll",
"a",
"user",
"or",
"other",
"identity",
"which",
"has",
"already",
"been",
"registered",
"."
] |
d4993ca602f72d412cd682e1b92e805e48b27afa
|
https://github.com/zamrokk/fabric-sdk-java/blob/d4993ca602f72d412cd682e1b92e805e48b27afa/src/main/java/org/hyperledger/fabric/sdk/Chain.java#L338-L344
|
148,227
|
zamrokk/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/Chain.java
|
Chain.registerAndEnroll
|
public Member registerAndEnroll(RegistrationRequest registrationRequest) throws RegistrationException, EnrollmentException {
Member member = getMember(registrationRequest.getEnrollmentID());
member.registerAndEnroll(registrationRequest);
return member;
}
|
java
|
public Member registerAndEnroll(RegistrationRequest registrationRequest) throws RegistrationException, EnrollmentException {
Member member = getMember(registrationRequest.getEnrollmentID());
member.registerAndEnroll(registrationRequest);
return member;
}
|
[
"public",
"Member",
"registerAndEnroll",
"(",
"RegistrationRequest",
"registrationRequest",
")",
"throws",
"RegistrationException",
",",
"EnrollmentException",
"{",
"Member",
"member",
"=",
"getMember",
"(",
"registrationRequest",
".",
"getEnrollmentID",
"(",
")",
")",
";",
"member",
".",
"registerAndEnroll",
"(",
"registrationRequest",
")",
";",
"return",
"member",
";",
"}"
] |
Register and enroll a user or other member type.
This assumes that a registrar with sufficient privileges has been set.
@param registrationRequest Registration information.
@throws RegistrationException
@throws EnrollmentException
|
[
"Register",
"and",
"enroll",
"a",
"user",
"or",
"other",
"member",
"type",
".",
"This",
"assumes",
"that",
"a",
"registrar",
"with",
"sufficient",
"privileges",
"has",
"been",
"set",
"."
] |
d4993ca602f72d412cd682e1b92e805e48b27afa
|
https://github.com/zamrokk/fabric-sdk-java/blob/d4993ca602f72d412cd682e1b92e805e48b27afa/src/main/java/org/hyperledger/fabric/sdk/Chain.java#L353-L357
|
148,228
|
zamrokk/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/Chain.java
|
Chain.sendTransaction
|
public Response sendTransaction(Transaction tx) {
if (this.peers.isEmpty()) {
throw new NoValidPeerException(String.format("chain %s has no peers", getName()));
}
for(Peer peer : peers) {
try {
return peer.sendTransaction(tx);
} catch (PeerException exp) {
logger.info(String.format("Failed sending transaction to peer:%s", exp.getMessage()));
}
}
throw new RuntimeException("No peer available to respond");
}
|
java
|
public Response sendTransaction(Transaction tx) {
if (this.peers.isEmpty()) {
throw new NoValidPeerException(String.format("chain %s has no peers", getName()));
}
for(Peer peer : peers) {
try {
return peer.sendTransaction(tx);
} catch (PeerException exp) {
logger.info(String.format("Failed sending transaction to peer:%s", exp.getMessage()));
}
}
throw new RuntimeException("No peer available to respond");
}
|
[
"public",
"Response",
"sendTransaction",
"(",
"Transaction",
"tx",
")",
"{",
"if",
"(",
"this",
".",
"peers",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"NoValidPeerException",
"(",
"String",
".",
"format",
"(",
"\"chain %s has no peers\"",
",",
"getName",
"(",
")",
")",
")",
";",
"}",
"for",
"(",
"Peer",
"peer",
":",
"peers",
")",
"{",
"try",
"{",
"return",
"peer",
".",
"sendTransaction",
"(",
"tx",
")",
";",
"}",
"catch",
"(",
"PeerException",
"exp",
")",
"{",
"logger",
".",
"info",
"(",
"String",
".",
"format",
"(",
"\"Failed sending transaction to peer:%s\"",
",",
"exp",
".",
"getMessage",
"(",
")",
")",
")",
";",
"}",
"}",
"throw",
"new",
"RuntimeException",
"(",
"\"No peer available to respond\"",
")",
";",
"}"
] |
Send a transaction to a peer.
@param tx The transaction
|
[
"Send",
"a",
"transaction",
"to",
"a",
"peer",
"."
] |
d4993ca602f72d412cd682e1b92e805e48b27afa
|
https://github.com/zamrokk/fabric-sdk-java/blob/d4993ca602f72d412cd682e1b92e805e48b27afa/src/main/java/org/hyperledger/fabric/sdk/Chain.java#L363-L377
|
148,229
|
soarcn/COCOQuery
|
query/src/main/java/com/cocosw/query/CocoQuery.java
|
CocoQuery.getContext
|
protected Context getContext() {
if (act != null) {
return act;
}
if (root != null) {
return root.getContext();
}
return context;
}
|
java
|
protected Context getContext() {
if (act != null) {
return act;
}
if (root != null) {
return root.getContext();
}
return context;
}
|
[
"protected",
"Context",
"getContext",
"(",
")",
"{",
"if",
"(",
"act",
"!=",
"null",
")",
"{",
"return",
"act",
";",
"}",
"if",
"(",
"root",
"!=",
"null",
")",
"{",
"return",
"root",
".",
"getContext",
"(",
")",
";",
"}",
"return",
"context",
";",
"}"
] |
Return the context of activity or view.
@return Context
|
[
"Return",
"the",
"context",
"of",
"activity",
"or",
"view",
"."
] |
712eac37ab65ef3dbdf55dbfae28750edfc36608
|
https://github.com/soarcn/COCOQuery/blob/712eac37ab65ef3dbdf55dbfae28750edfc36608/query/src/main/java/com/cocosw/query/CocoQuery.java#L83-L91
|
148,230
|
soarcn/COCOQuery
|
query/src/main/java/com/cocosw/query/CocoQuery.java
|
CocoQuery.confirm
|
public void confirm(final int title, final int message,
final DialogInterface.OnClickListener onClickListener) {
final AlertDialog.Builder builder = new AlertDialog.Builder(
getContext());
builder.setTitle(title).setIcon(android.R.drawable.ic_dialog_info).setMessage(message);
builder.setPositiveButton(android.R.string.ok,
new DialogInterface.OnClickListener() {
@Override
public void onClick(final DialogInterface dialog,
final int which) {
if (onClickListener != null) {
onClickListener.onClick(dialog, which);
}
}
});
builder.setNegativeButton(android.R.string.cancel,
new DialogInterface.OnClickListener() {
@Override
public void onClick(final DialogInterface dialog,
final int which) {
if (onClickListener != null) {
onClickListener.onClick(dialog, which);
}
}
});
builder.show();
}
|
java
|
public void confirm(final int title, final int message,
final DialogInterface.OnClickListener onClickListener) {
final AlertDialog.Builder builder = new AlertDialog.Builder(
getContext());
builder.setTitle(title).setIcon(android.R.drawable.ic_dialog_info).setMessage(message);
builder.setPositiveButton(android.R.string.ok,
new DialogInterface.OnClickListener() {
@Override
public void onClick(final DialogInterface dialog,
final int which) {
if (onClickListener != null) {
onClickListener.onClick(dialog, which);
}
}
});
builder.setNegativeButton(android.R.string.cancel,
new DialogInterface.OnClickListener() {
@Override
public void onClick(final DialogInterface dialog,
final int which) {
if (onClickListener != null) {
onClickListener.onClick(dialog, which);
}
}
});
builder.show();
}
|
[
"public",
"void",
"confirm",
"(",
"final",
"int",
"title",
",",
"final",
"int",
"message",
",",
"final",
"DialogInterface",
".",
"OnClickListener",
"onClickListener",
")",
"{",
"final",
"AlertDialog",
".",
"Builder",
"builder",
"=",
"new",
"AlertDialog",
".",
"Builder",
"(",
"getContext",
"(",
")",
")",
";",
"builder",
".",
"setTitle",
"(",
"title",
")",
".",
"setIcon",
"(",
"android",
".",
"R",
".",
"drawable",
".",
"ic_dialog_info",
")",
".",
"setMessage",
"(",
"message",
")",
";",
"builder",
".",
"setPositiveButton",
"(",
"android",
".",
"R",
".",
"string",
".",
"ok",
",",
"new",
"DialogInterface",
".",
"OnClickListener",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onClick",
"(",
"final",
"DialogInterface",
"dialog",
",",
"final",
"int",
"which",
")",
"{",
"if",
"(",
"onClickListener",
"!=",
"null",
")",
"{",
"onClickListener",
".",
"onClick",
"(",
"dialog",
",",
"which",
")",
";",
"}",
"}",
"}",
")",
";",
"builder",
".",
"setNegativeButton",
"(",
"android",
".",
"R",
".",
"string",
".",
"cancel",
",",
"new",
"DialogInterface",
".",
"OnClickListener",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onClick",
"(",
"final",
"DialogInterface",
"dialog",
",",
"final",
"int",
"which",
")",
"{",
"if",
"(",
"onClickListener",
"!=",
"null",
")",
"{",
"onClickListener",
".",
"onClick",
"(",
"dialog",
",",
"which",
")",
";",
"}",
"}",
"}",
")",
";",
"builder",
".",
"show",
"(",
")",
";",
"}"
] |
Open a confirm dialog with title and message
@param title
@param message
|
[
"Open",
"a",
"confirm",
"dialog",
"with",
"title",
"and",
"message"
] |
712eac37ab65ef3dbdf55dbfae28750edfc36608
|
https://github.com/soarcn/COCOQuery/blob/712eac37ab65ef3dbdf55dbfae28750edfc36608/query/src/main/java/com/cocosw/query/CocoQuery.java#L283-L312
|
148,231
|
soarcn/COCOQuery
|
query/src/main/java/com/cocosw/query/CocoQuery.java
|
CocoQuery.dialog
|
public void dialog(final int title, int list, DialogInterface.OnClickListener listener) {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder.setTitle(title)
.setItems(list, listener);
builder.create().show();
}
|
java
|
public void dialog(final int title, int list, DialogInterface.OnClickListener listener) {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder.setTitle(title)
.setItems(list, listener);
builder.create().show();
}
|
[
"public",
"void",
"dialog",
"(",
"final",
"int",
"title",
",",
"int",
"list",
",",
"DialogInterface",
".",
"OnClickListener",
"listener",
")",
"{",
"AlertDialog",
".",
"Builder",
"builder",
"=",
"new",
"AlertDialog",
".",
"Builder",
"(",
"getContext",
"(",
")",
")",
";",
"builder",
".",
"setTitle",
"(",
"title",
")",
".",
"setItems",
"(",
"list",
",",
"listener",
")",
";",
"builder",
".",
"create",
"(",
")",
".",
"show",
"(",
")",
";",
"}"
] |
Open a dialog with single choice list
@param title
@param list
@param listener
|
[
"Open",
"a",
"dialog",
"with",
"single",
"choice",
"list"
] |
712eac37ab65ef3dbdf55dbfae28750edfc36608
|
https://github.com/soarcn/COCOQuery/blob/712eac37ab65ef3dbdf55dbfae28750edfc36608/query/src/main/java/com/cocosw/query/CocoQuery.java#L351-L356
|
148,232
|
soarcn/COCOQuery
|
query/src/main/java/com/cocosw/query/CocoQuery.java
|
CocoQuery.CleanAllTask
|
private CocoQuery CleanAllTask() {
for (final CocoTask<?> reference : taskpool.values()) {
if (reference != null) {
reference.cancel();
}
}
return this;
}
|
java
|
private CocoQuery CleanAllTask() {
for (final CocoTask<?> reference : taskpool.values()) {
if (reference != null) {
reference.cancel();
}
}
return this;
}
|
[
"private",
"CocoQuery",
"CleanAllTask",
"(",
")",
"{",
"for",
"(",
"final",
"CocoTask",
"<",
"?",
">",
"reference",
":",
"taskpool",
".",
"values",
"(",
")",
")",
"{",
"if",
"(",
"reference",
"!=",
"null",
")",
"{",
"reference",
".",
"cancel",
"(",
")",
";",
"}",
"}",
"return",
"this",
";",
"}"
] |
Cancle all the task in pool
@return
|
[
"Cancle",
"all",
"the",
"task",
"in",
"pool"
] |
712eac37ab65ef3dbdf55dbfae28750edfc36608
|
https://github.com/soarcn/COCOQuery/blob/712eac37ab65ef3dbdf55dbfae28750edfc36608/query/src/main/java/com/cocosw/query/CocoQuery.java#L388-L395
|
148,233
|
soarcn/COCOQuery
|
query/src/main/java/com/cocosw/query/CocoQuery.java
|
CocoQuery.startActivityForResult
|
public void startActivityForResult(Class clz,int requestCode) {
act.startActivityForResult(new Intent(getContext(),clz),requestCode);
}
|
java
|
public void startActivityForResult(Class clz,int requestCode) {
act.startActivityForResult(new Intent(getContext(),clz),requestCode);
}
|
[
"public",
"void",
"startActivityForResult",
"(",
"Class",
"clz",
",",
"int",
"requestCode",
")",
"{",
"act",
".",
"startActivityForResult",
"(",
"new",
"Intent",
"(",
"getContext",
"(",
")",
",",
"clz",
")",
",",
"requestCode",
")",
";",
"}"
] |
Launch an activity for which you would like a result when it finished
@param clz
@param requestCode
|
[
"Launch",
"an",
"activity",
"for",
"which",
"you",
"would",
"like",
"a",
"result",
"when",
"it",
"finished"
] |
712eac37ab65ef3dbdf55dbfae28750edfc36608
|
https://github.com/soarcn/COCOQuery/blob/712eac37ab65ef3dbdf55dbfae28750edfc36608/query/src/main/java/com/cocosw/query/CocoQuery.java#L417-L419
|
148,234
|
luuuis/jcalendar
|
src/main/java/com/toedter/calendar/JMonthChooser.java
|
JMonthChooser.initNames
|
public void initNames() {
localInitialize = true;
DateFormatSymbols dateFormatSymbols = new DateFormatSymbols(locale);
String[] monthNames = dateFormatSymbols.getMonths();
if (comboBox.getItemCount() == 12) {
comboBox.removeAllItems();
}
for (int i = 0; i < 12; i++) {
comboBox.addItem(monthNames[i]);
}
localInitialize = false;
comboBox.setSelectedIndex(month);
}
|
java
|
public void initNames() {
localInitialize = true;
DateFormatSymbols dateFormatSymbols = new DateFormatSymbols(locale);
String[] monthNames = dateFormatSymbols.getMonths();
if (comboBox.getItemCount() == 12) {
comboBox.removeAllItems();
}
for (int i = 0; i < 12; i++) {
comboBox.addItem(monthNames[i]);
}
localInitialize = false;
comboBox.setSelectedIndex(month);
}
|
[
"public",
"void",
"initNames",
"(",
")",
"{",
"localInitialize",
"=",
"true",
";",
"DateFormatSymbols",
"dateFormatSymbols",
"=",
"new",
"DateFormatSymbols",
"(",
"locale",
")",
";",
"String",
"[",
"]",
"monthNames",
"=",
"dateFormatSymbols",
".",
"getMonths",
"(",
")",
";",
"if",
"(",
"comboBox",
".",
"getItemCount",
"(",
")",
"==",
"12",
")",
"{",
"comboBox",
".",
"removeAllItems",
"(",
")",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"12",
";",
"i",
"++",
")",
"{",
"comboBox",
".",
"addItem",
"(",
"monthNames",
"[",
"i",
"]",
")",
";",
"}",
"localInitialize",
"=",
"false",
";",
"comboBox",
".",
"setSelectedIndex",
"(",
"month",
")",
";",
"}"
] |
Initializes the locale specific month names.
|
[
"Initializes",
"the",
"locale",
"specific",
"month",
"names",
"."
] |
442e5bc319d92dee93400e6180ca74a5b6bd7775
|
https://github.com/luuuis/jcalendar/blob/442e5bc319d92dee93400e6180ca74a5b6bd7775/src/main/java/com/toedter/calendar/JMonthChooser.java#L133-L149
|
148,235
|
luuuis/jcalendar
|
src/main/java/com/toedter/calendar/JMonthChooser.java
|
JMonthChooser.stateChanged
|
public void stateChanged(ChangeEvent e) {
SpinnerNumberModel model = (SpinnerNumberModel) ((JSpinner) e
.getSource()).getModel();
int value = model.getNumber().intValue();
boolean increase = (value > oldSpinnerValue) ? true : false;
oldSpinnerValue = value;
int month = getMonth();
if (increase) {
month += 1;
if (month == 12) {
month = 0;
if (yearChooser != null) {
int year = yearChooser.getYear();
year += 1;
yearChooser.setYear(year);
}
}
} else {
month -= 1;
if (month == -1) {
month = 11;
if (yearChooser != null) {
int year = yearChooser.getYear();
year -= 1;
yearChooser.setYear(year);
}
}
}
setMonth(month);
}
|
java
|
public void stateChanged(ChangeEvent e) {
SpinnerNumberModel model = (SpinnerNumberModel) ((JSpinner) e
.getSource()).getModel();
int value = model.getNumber().intValue();
boolean increase = (value > oldSpinnerValue) ? true : false;
oldSpinnerValue = value;
int month = getMonth();
if (increase) {
month += 1;
if (month == 12) {
month = 0;
if (yearChooser != null) {
int year = yearChooser.getYear();
year += 1;
yearChooser.setYear(year);
}
}
} else {
month -= 1;
if (month == -1) {
month = 11;
if (yearChooser != null) {
int year = yearChooser.getYear();
year -= 1;
yearChooser.setYear(year);
}
}
}
setMonth(month);
}
|
[
"public",
"void",
"stateChanged",
"(",
"ChangeEvent",
"e",
")",
"{",
"SpinnerNumberModel",
"model",
"=",
"(",
"SpinnerNumberModel",
")",
"(",
"(",
"JSpinner",
")",
"e",
".",
"getSource",
"(",
")",
")",
".",
"getModel",
"(",
")",
";",
"int",
"value",
"=",
"model",
".",
"getNumber",
"(",
")",
".",
"intValue",
"(",
")",
";",
"boolean",
"increase",
"=",
"(",
"value",
">",
"oldSpinnerValue",
")",
"?",
"true",
":",
"false",
";",
"oldSpinnerValue",
"=",
"value",
";",
"int",
"month",
"=",
"getMonth",
"(",
")",
";",
"if",
"(",
"increase",
")",
"{",
"month",
"+=",
"1",
";",
"if",
"(",
"month",
"==",
"12",
")",
"{",
"month",
"=",
"0",
";",
"if",
"(",
"yearChooser",
"!=",
"null",
")",
"{",
"int",
"year",
"=",
"yearChooser",
".",
"getYear",
"(",
")",
";",
"year",
"+=",
"1",
";",
"yearChooser",
".",
"setYear",
"(",
"year",
")",
";",
"}",
"}",
"}",
"else",
"{",
"month",
"-=",
"1",
";",
"if",
"(",
"month",
"==",
"-",
"1",
")",
"{",
"month",
"=",
"11",
";",
"if",
"(",
"yearChooser",
"!=",
"null",
")",
"{",
"int",
"year",
"=",
"yearChooser",
".",
"getYear",
"(",
")",
";",
"year",
"-=",
"1",
";",
"yearChooser",
".",
"setYear",
"(",
"year",
")",
";",
"}",
"}",
"}",
"setMonth",
"(",
"month",
")",
";",
"}"
] |
Is invoked if the state of the spnner changes.
@param e
the change event.
|
[
"Is",
"invoked",
"if",
"the",
"state",
"of",
"the",
"spnner",
"changes",
"."
] |
442e5bc319d92dee93400e6180ca74a5b6bd7775
|
https://github.com/luuuis/jcalendar/blob/442e5bc319d92dee93400e6180ca74a5b6bd7775/src/main/java/com/toedter/calendar/JMonthChooser.java#L157-L193
|
148,236
|
luuuis/jcalendar
|
src/main/java/com/toedter/calendar/JMonthChooser.java
|
JMonthChooser.itemStateChanged
|
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
int index = comboBox.getSelectedIndex();
if ((index >= 0) && (index != month)) {
setMonth(index, false);
}
}
}
|
java
|
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
int index = comboBox.getSelectedIndex();
if ((index >= 0) && (index != month)) {
setMonth(index, false);
}
}
}
|
[
"public",
"void",
"itemStateChanged",
"(",
"ItemEvent",
"e",
")",
"{",
"if",
"(",
"e",
".",
"getStateChange",
"(",
")",
"==",
"ItemEvent",
".",
"SELECTED",
")",
"{",
"int",
"index",
"=",
"comboBox",
".",
"getSelectedIndex",
"(",
")",
";",
"if",
"(",
"(",
"index",
">=",
"0",
")",
"&&",
"(",
"index",
"!=",
"month",
")",
")",
"{",
"setMonth",
"(",
"index",
",",
"false",
")",
";",
"}",
"}",
"}"
] |
The ItemListener for the months.
@param e
the item event
|
[
"The",
"ItemListener",
"for",
"the",
"months",
"."
] |
442e5bc319d92dee93400e6180ca74a5b6bd7775
|
https://github.com/luuuis/jcalendar/blob/442e5bc319d92dee93400e6180ca74a5b6bd7775/src/main/java/com/toedter/calendar/JMonthChooser.java#L201-L209
|
148,237
|
luuuis/jcalendar
|
src/main/java/com/toedter/calendar/JMonthChooser.java
|
JMonthChooser.setMonth
|
private void setMonth(int newMonth, boolean select) {
if (!initialized || localInitialize) {
return;
}
int oldMonth = month;
month = newMonth;
if (select) {
comboBox.setSelectedIndex(month);
}
if (dayChooser != null) {
dayChooser.setMonth(month);
}
firePropertyChange("month", oldMonth, month);
}
|
java
|
private void setMonth(int newMonth, boolean select) {
if (!initialized || localInitialize) {
return;
}
int oldMonth = month;
month = newMonth;
if (select) {
comboBox.setSelectedIndex(month);
}
if (dayChooser != null) {
dayChooser.setMonth(month);
}
firePropertyChange("month", oldMonth, month);
}
|
[
"private",
"void",
"setMonth",
"(",
"int",
"newMonth",
",",
"boolean",
"select",
")",
"{",
"if",
"(",
"!",
"initialized",
"||",
"localInitialize",
")",
"{",
"return",
";",
"}",
"int",
"oldMonth",
"=",
"month",
";",
"month",
"=",
"newMonth",
";",
"if",
"(",
"select",
")",
"{",
"comboBox",
".",
"setSelectedIndex",
"(",
"month",
")",
";",
"}",
"if",
"(",
"dayChooser",
"!=",
"null",
")",
"{",
"dayChooser",
".",
"setMonth",
"(",
"month",
")",
";",
"}",
"firePropertyChange",
"(",
"\"month\"",
",",
"oldMonth",
",",
"month",
")",
";",
"}"
] |
Sets the month attribute of the JMonthChooser object. Fires a property
change "month".
@param newMonth
the new month value
@param select
true, if the month should be selcted in the combo box.
|
[
"Sets",
"the",
"month",
"attribute",
"of",
"the",
"JMonthChooser",
"object",
".",
"Fires",
"a",
"property",
"change",
"month",
"."
] |
442e5bc319d92dee93400e6180ca74a5b6bd7775
|
https://github.com/luuuis/jcalendar/blob/442e5bc319d92dee93400e6180ca74a5b6bd7775/src/main/java/com/toedter/calendar/JMonthChooser.java#L220-L237
|
148,238
|
luuuis/jcalendar
|
src/main/java/com/toedter/calendar/JMonthChooser.java
|
JMonthChooser.setEnabled
|
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
comboBox.setEnabled(enabled);
if (spinner != null) {
spinner.setEnabled(enabled);
}
}
|
java
|
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
comboBox.setEnabled(enabled);
if (spinner != null) {
spinner.setEnabled(enabled);
}
}
|
[
"public",
"void",
"setEnabled",
"(",
"boolean",
"enabled",
")",
"{",
"super",
".",
"setEnabled",
"(",
"enabled",
")",
";",
"comboBox",
".",
"setEnabled",
"(",
"enabled",
")",
";",
"if",
"(",
"spinner",
"!=",
"null",
")",
"{",
"spinner",
".",
"setEnabled",
"(",
"enabled",
")",
";",
"}",
"}"
] |
Enable or disable the JMonthChooser.
@param enabled
the new enabled value
|
[
"Enable",
"or",
"disable",
"the",
"JMonthChooser",
"."
] |
442e5bc319d92dee93400e6180ca74a5b6bd7775
|
https://github.com/luuuis/jcalendar/blob/442e5bc319d92dee93400e6180ca74a5b6bd7775/src/main/java/com/toedter/calendar/JMonthChooser.java#L323-L330
|
148,239
|
luuuis/jcalendar
|
src/main/java/com/toedter/calendar/JMonthChooser.java
|
JMonthChooser.setFont
|
public void setFont(Font font) {
if (comboBox != null) {
comboBox.setFont(font);
}
super.setFont(font);
}
|
java
|
public void setFont(Font font) {
if (comboBox != null) {
comboBox.setFont(font);
}
super.setFont(font);
}
|
[
"public",
"void",
"setFont",
"(",
"Font",
"font",
")",
"{",
"if",
"(",
"comboBox",
"!=",
"null",
")",
"{",
"comboBox",
".",
"setFont",
"(",
"font",
")",
";",
"}",
"super",
".",
"setFont",
"(",
"font",
")",
";",
"}"
] |
Sets the font for this component.
@param font the desired <code>Font</code> for this component
|
[
"Sets",
"the",
"font",
"for",
"this",
"component",
"."
] |
442e5bc319d92dee93400e6180ca74a5b6bd7775
|
https://github.com/luuuis/jcalendar/blob/442e5bc319d92dee93400e6180ca74a5b6bd7775/src/main/java/com/toedter/calendar/JMonthChooser.java#L368-L373
|
148,240
|
luuuis/jcalendar
|
src/main/java/com/toedter/calendar/JMonthChooser.java
|
JMonthChooser.updateUI
|
public void updateUI() {
final JSpinner testSpinner = new JSpinner();
if (spinner != null) {
if ("Windows".equals(UIManager.getLookAndFeel().getID())) {
spinner.setBorder(testSpinner.getBorder());
} else {
spinner.setBorder(new EmptyBorder(0, 0, 0, 0));
}
}
}
|
java
|
public void updateUI() {
final JSpinner testSpinner = new JSpinner();
if (spinner != null) {
if ("Windows".equals(UIManager.getLookAndFeel().getID())) {
spinner.setBorder(testSpinner.getBorder());
} else {
spinner.setBorder(new EmptyBorder(0, 0, 0, 0));
}
}
}
|
[
"public",
"void",
"updateUI",
"(",
")",
"{",
"final",
"JSpinner",
"testSpinner",
"=",
"new",
"JSpinner",
"(",
")",
";",
"if",
"(",
"spinner",
"!=",
"null",
")",
"{",
"if",
"(",
"\"Windows\"",
".",
"equals",
"(",
"UIManager",
".",
"getLookAndFeel",
"(",
")",
".",
"getID",
"(",
")",
")",
")",
"{",
"spinner",
".",
"setBorder",
"(",
"testSpinner",
".",
"getBorder",
"(",
")",
")",
";",
"}",
"else",
"{",
"spinner",
".",
"setBorder",
"(",
"new",
"EmptyBorder",
"(",
"0",
",",
"0",
",",
"0",
",",
"0",
")",
")",
";",
"}",
"}",
"}"
] |
Updates the UI.
@see javax.swing.JPanel#updateUI()
|
[
"Updates",
"the",
"UI",
"."
] |
442e5bc319d92dee93400e6180ca74a5b6bd7775
|
https://github.com/luuuis/jcalendar/blob/442e5bc319d92dee93400e6180ca74a5b6bd7775/src/main/java/com/toedter/calendar/JMonthChooser.java#L380-L389
|
148,241
|
brunocvcunha/ghostme4j
|
src/main/java/org/brunocvcunha/ghostme4j/GhostMe.java
|
GhostMe.getProxy
|
public static Proxy getProxy(final boolean test) throws IOException {
int providerIndex = MyNumberUtils.randomIntBetween(0, PROVIDERS.length - 1);
IProxyProvider randomProvider = PROVIDERS[providerIndex];
return getProxy(randomProvider, test);
}
|
java
|
public static Proxy getProxy(final boolean test) throws IOException {
int providerIndex = MyNumberUtils.randomIntBetween(0, PROVIDERS.length - 1);
IProxyProvider randomProvider = PROVIDERS[providerIndex];
return getProxy(randomProvider, test);
}
|
[
"public",
"static",
"Proxy",
"getProxy",
"(",
"final",
"boolean",
"test",
")",
"throws",
"IOException",
"{",
"int",
"providerIndex",
"=",
"MyNumberUtils",
".",
"randomIntBetween",
"(",
"0",
",",
"PROVIDERS",
".",
"length",
"-",
"1",
")",
";",
"IProxyProvider",
"randomProvider",
"=",
"PROVIDERS",
"[",
"providerIndex",
"]",
";",
"return",
"getProxy",
"(",
"randomProvider",
",",
"test",
")",
";",
"}"
] |
Get a Proxy
@param test whether to test the proxy
@return used proxy
@throws IOException I/O Error
|
[
"Get",
"a",
"Proxy"
] |
c763a0d5f78ed0860e63d27afa0330b92eb0400c
|
https://github.com/brunocvcunha/ghostme4j/blob/c763a0d5f78ed0860e63d27afa0330b92eb0400c/src/main/java/org/brunocvcunha/ghostme4j/GhostMe.java#L63-L69
|
148,242
|
brunocvcunha/ghostme4j
|
src/main/java/org/brunocvcunha/ghostme4j/GhostMe.java
|
GhostMe.getProxy
|
public static Proxy getProxy(final IProxyProvider provider, final boolean test) throws IOException {
LOGGER.info("Getting proxy...");
List<Proxy> proxies = provider.getProxies(-1, false, true);
LOGGER.info("Total Proxies: " + proxies.size());
final CountDownLatch countDown = new CountDownLatch(proxies.size());
final AtomicReference<Proxy> useProxy = new AtomicReference<>();
int threadCount = proxies.size() > 10 ? 10 : proxies.size();
if (threadCount <= 0) {
threadCount = 1;
}
final ExecutorService testService = Executors.newFixedThreadPool(threadCount);
for (final Proxy proxy : proxies) {
Thread validate = new Thread() {
@Override
public void run() {
try {
if (test) {
if (proxy.isBlackListed()) {
return;
}
proxy.updateStatus();
if (!proxy.isOnline()) {
return;
}
proxy.updateAnonymity();
if (!proxy.isAnonymous()) {
return;
}
}
if (useProxy.get() == null) {
LOGGER.info("Using Proxy: " + proxy.toString());
useProxy.set(proxy);
// count to 0
while (countDown.getCount() > 0) {
countDown.countDown();
}
}
} catch (Exception e) {
LOGGER.info("Proxy validation returned error: " + e.getClass().getName() + " - " + e.getMessage());
} finally {
countDown.countDown();
}
}
};
testService.submit(validate);
}
try {
countDown.await();
} catch (InterruptedException e) {
e.printStackTrace();
}
testService.shutdownNow();
if (useProxy.get() == null) {
//if null, use another provider
return getProxy(test);
}
return useProxy.get();
}
|
java
|
public static Proxy getProxy(final IProxyProvider provider, final boolean test) throws IOException {
LOGGER.info("Getting proxy...");
List<Proxy> proxies = provider.getProxies(-1, false, true);
LOGGER.info("Total Proxies: " + proxies.size());
final CountDownLatch countDown = new CountDownLatch(proxies.size());
final AtomicReference<Proxy> useProxy = new AtomicReference<>();
int threadCount = proxies.size() > 10 ? 10 : proxies.size();
if (threadCount <= 0) {
threadCount = 1;
}
final ExecutorService testService = Executors.newFixedThreadPool(threadCount);
for (final Proxy proxy : proxies) {
Thread validate = new Thread() {
@Override
public void run() {
try {
if (test) {
if (proxy.isBlackListed()) {
return;
}
proxy.updateStatus();
if (!proxy.isOnline()) {
return;
}
proxy.updateAnonymity();
if (!proxy.isAnonymous()) {
return;
}
}
if (useProxy.get() == null) {
LOGGER.info("Using Proxy: " + proxy.toString());
useProxy.set(proxy);
// count to 0
while (countDown.getCount() > 0) {
countDown.countDown();
}
}
} catch (Exception e) {
LOGGER.info("Proxy validation returned error: " + e.getClass().getName() + " - " + e.getMessage());
} finally {
countDown.countDown();
}
}
};
testService.submit(validate);
}
try {
countDown.await();
} catch (InterruptedException e) {
e.printStackTrace();
}
testService.shutdownNow();
if (useProxy.get() == null) {
//if null, use another provider
return getProxy(test);
}
return useProxy.get();
}
|
[
"public",
"static",
"Proxy",
"getProxy",
"(",
"final",
"IProxyProvider",
"provider",
",",
"final",
"boolean",
"test",
")",
"throws",
"IOException",
"{",
"LOGGER",
".",
"info",
"(",
"\"Getting proxy...\"",
")",
";",
"List",
"<",
"Proxy",
">",
"proxies",
"=",
"provider",
".",
"getProxies",
"(",
"-",
"1",
",",
"false",
",",
"true",
")",
";",
"LOGGER",
".",
"info",
"(",
"\"Total Proxies: \"",
"+",
"proxies",
".",
"size",
"(",
")",
")",
";",
"final",
"CountDownLatch",
"countDown",
"=",
"new",
"CountDownLatch",
"(",
"proxies",
".",
"size",
"(",
")",
")",
";",
"final",
"AtomicReference",
"<",
"Proxy",
">",
"useProxy",
"=",
"new",
"AtomicReference",
"<>",
"(",
")",
";",
"int",
"threadCount",
"=",
"proxies",
".",
"size",
"(",
")",
">",
"10",
"?",
"10",
":",
"proxies",
".",
"size",
"(",
")",
";",
"if",
"(",
"threadCount",
"<=",
"0",
")",
"{",
"threadCount",
"=",
"1",
";",
"}",
"final",
"ExecutorService",
"testService",
"=",
"Executors",
".",
"newFixedThreadPool",
"(",
"threadCount",
")",
";",
"for",
"(",
"final",
"Proxy",
"proxy",
":",
"proxies",
")",
"{",
"Thread",
"validate",
"=",
"new",
"Thread",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"try",
"{",
"if",
"(",
"test",
")",
"{",
"if",
"(",
"proxy",
".",
"isBlackListed",
"(",
")",
")",
"{",
"return",
";",
"}",
"proxy",
".",
"updateStatus",
"(",
")",
";",
"if",
"(",
"!",
"proxy",
".",
"isOnline",
"(",
")",
")",
"{",
"return",
";",
"}",
"proxy",
".",
"updateAnonymity",
"(",
")",
";",
"if",
"(",
"!",
"proxy",
".",
"isAnonymous",
"(",
")",
")",
"{",
"return",
";",
"}",
"}",
"if",
"(",
"useProxy",
".",
"get",
"(",
")",
"==",
"null",
")",
"{",
"LOGGER",
".",
"info",
"(",
"\"Using Proxy: \"",
"+",
"proxy",
".",
"toString",
"(",
")",
")",
";",
"useProxy",
".",
"set",
"(",
"proxy",
")",
";",
"// count to 0",
"while",
"(",
"countDown",
".",
"getCount",
"(",
")",
">",
"0",
")",
"{",
"countDown",
".",
"countDown",
"(",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOGGER",
".",
"info",
"(",
"\"Proxy validation returned error: \"",
"+",
"e",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\" - \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"finally",
"{",
"countDown",
".",
"countDown",
"(",
")",
";",
"}",
"}",
"}",
";",
"testService",
".",
"submit",
"(",
"validate",
")",
";",
"}",
"try",
"{",
"countDown",
".",
"await",
"(",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"testService",
".",
"shutdownNow",
"(",
")",
";",
"if",
"(",
"useProxy",
".",
"get",
"(",
")",
"==",
"null",
")",
"{",
"//if null, use another provider",
"return",
"getProxy",
"(",
"test",
")",
";",
"}",
"return",
"useProxy",
".",
"get",
"(",
")",
";",
"}"
] |
Get a Proxy, using the given provider
@param provider provider to use
@param test whether to test the proxy
@return used proxy
@throws IOException I/O Error
|
[
"Get",
"a",
"Proxy",
"using",
"the",
"given",
"provider"
] |
c763a0d5f78ed0860e63d27afa0330b92eb0400c
|
https://github.com/brunocvcunha/ghostme4j/blob/c763a0d5f78ed0860e63d27afa0330b92eb0400c/src/main/java/org/brunocvcunha/ghostme4j/GhostMe.java#L79-L156
|
148,243
|
brunocvcunha/ghostme4j
|
src/main/java/org/brunocvcunha/ghostme4j/GhostMe.java
|
GhostMe.ghostMySystemProperties
|
public static Proxy ghostMySystemProperties(boolean test) throws IOException {
LOGGER.info("Ghosting System Properties...");
Proxy use = getProxy(test);
if (use != null) {
applyProxy(use);
}
return use;
}
|
java
|
public static Proxy ghostMySystemProperties(boolean test) throws IOException {
LOGGER.info("Ghosting System Properties...");
Proxy use = getProxy(test);
if (use != null) {
applyProxy(use);
}
return use;
}
|
[
"public",
"static",
"Proxy",
"ghostMySystemProperties",
"(",
"boolean",
"test",
")",
"throws",
"IOException",
"{",
"LOGGER",
".",
"info",
"(",
"\"Ghosting System Properties...\"",
")",
";",
"Proxy",
"use",
"=",
"getProxy",
"(",
"test",
")",
";",
"if",
"(",
"use",
"!=",
"null",
")",
"{",
"applyProxy",
"(",
"use",
")",
";",
"}",
"return",
"use",
";",
"}"
] |
Ghost the HTTP in the system properties
@param test whether to test the proxy
@return used proxy
@throws IOException I/O Exception
|
[
"Ghost",
"the",
"HTTP",
"in",
"the",
"system",
"properties"
] |
c763a0d5f78ed0860e63d27afa0330b92eb0400c
|
https://github.com/brunocvcunha/ghostme4j/blob/c763a0d5f78ed0860e63d27afa0330b92eb0400c/src/main/java/org/brunocvcunha/ghostme4j/GhostMe.java#L165-L175
|
148,244
|
brunocvcunha/ghostme4j
|
src/main/java/org/brunocvcunha/ghostme4j/GhostMe.java
|
GhostMe.applyUserAgent
|
public static void applyUserAgent(String agent) {
LOGGER.info("Applying agent: " + agent);
System.setProperty("http.agent", agent);
System.setProperty("https.agent", agent);
}
|
java
|
public static void applyUserAgent(String agent) {
LOGGER.info("Applying agent: " + agent);
System.setProperty("http.agent", agent);
System.setProperty("https.agent", agent);
}
|
[
"public",
"static",
"void",
"applyUserAgent",
"(",
"String",
"agent",
")",
"{",
"LOGGER",
".",
"info",
"(",
"\"Applying agent: \"",
"+",
"agent",
")",
";",
"System",
".",
"setProperty",
"(",
"\"http.agent\"",
",",
"agent",
")",
";",
"System",
".",
"setProperty",
"(",
"\"https.agent\"",
",",
"agent",
")",
";",
"}"
] |
Apply User Agent
@param agent Agent to apply
|
[
"Apply",
"User",
"Agent"
] |
c763a0d5f78ed0860e63d27afa0330b92eb0400c
|
https://github.com/brunocvcunha/ghostme4j/blob/c763a0d5f78ed0860e63d27afa0330b92eb0400c/src/main/java/org/brunocvcunha/ghostme4j/GhostMe.java#L203-L207
|
148,245
|
brunocvcunha/ghostme4j
|
src/main/java/org/brunocvcunha/ghostme4j/GhostMe.java
|
GhostMe.isBlacklisted
|
public synchronized static boolean isBlacklisted(String ip) {
if (blacklistCache == null || blacklistCache.isEmpty()) {
blacklistCache = new HashSet<>();
for (IBlackListProvider provider : BLACKLIST_PROVIDERS) {
try {
blacklistCache.addAll(provider.getIPs());
} catch (IOException e) {
LOGGER.warn("Error fetching blacklist records", e);
}
}
}
return blacklistCache.contains(ip);
}
|
java
|
public synchronized static boolean isBlacklisted(String ip) {
if (blacklistCache == null || blacklistCache.isEmpty()) {
blacklistCache = new HashSet<>();
for (IBlackListProvider provider : BLACKLIST_PROVIDERS) {
try {
blacklistCache.addAll(provider.getIPs());
} catch (IOException e) {
LOGGER.warn("Error fetching blacklist records", e);
}
}
}
return blacklistCache.contains(ip);
}
|
[
"public",
"synchronized",
"static",
"boolean",
"isBlacklisted",
"(",
"String",
"ip",
")",
"{",
"if",
"(",
"blacklistCache",
"==",
"null",
"||",
"blacklistCache",
".",
"isEmpty",
"(",
")",
")",
"{",
"blacklistCache",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"for",
"(",
"IBlackListProvider",
"provider",
":",
"BLACKLIST_PROVIDERS",
")",
"{",
"try",
"{",
"blacklistCache",
".",
"addAll",
"(",
"provider",
".",
"getIPs",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"LOGGER",
".",
"warn",
"(",
"\"Error fetching blacklist records\"",
",",
"e",
")",
";",
"}",
"}",
"}",
"return",
"blacklistCache",
".",
"contains",
"(",
"ip",
")",
";",
"}"
] |
Check if the IP is in a blacklist
@param ip IP to check
@return whether the ip is blacklisted or not
|
[
"Check",
"if",
"the",
"IP",
"is",
"in",
"a",
"blacklist"
] |
c763a0d5f78ed0860e63d27afa0330b92eb0400c
|
https://github.com/brunocvcunha/ghostme4j/blob/c763a0d5f78ed0860e63d27afa0330b92eb0400c/src/main/java/org/brunocvcunha/ghostme4j/GhostMe.java#L231-L246
|
148,246
|
iipc/openwayback-access-control
|
oracle/src/main/java/org/archive/accesscontrol/model/HibernateRuleDao.java
|
HibernateRuleDao.getRuleTree
|
public RuleSet getRuleTree(String surt) {
RuleSet rules = new RuleSet();
// add the root SURT
rules.addAll(getRulesWithExactSurt("("));
boolean first = true;
for (String search: new NewSurtTokenizer(surt).getSearchList()) {
if (first) {
first = false;
rules.addAll(getRulesWithSurtPrefix(search));
} else {
rules.addAll(getRulesWithExactSurt(search));
}
}
return rules;
}
|
java
|
public RuleSet getRuleTree(String surt) {
RuleSet rules = new RuleSet();
// add the root SURT
rules.addAll(getRulesWithExactSurt("("));
boolean first = true;
for (String search: new NewSurtTokenizer(surt).getSearchList()) {
if (first) {
first = false;
rules.addAll(getRulesWithSurtPrefix(search));
} else {
rules.addAll(getRulesWithExactSurt(search));
}
}
return rules;
}
|
[
"public",
"RuleSet",
"getRuleTree",
"(",
"String",
"surt",
")",
"{",
"RuleSet",
"rules",
"=",
"new",
"RuleSet",
"(",
")",
";",
"// add the root SURT",
"rules",
".",
"addAll",
"(",
"getRulesWithExactSurt",
"(",
"\"(\"",
")",
")",
";",
"boolean",
"first",
"=",
"true",
";",
"for",
"(",
"String",
"search",
":",
"new",
"NewSurtTokenizer",
"(",
"surt",
")",
".",
"getSearchList",
"(",
")",
")",
"{",
"if",
"(",
"first",
")",
"{",
"first",
"=",
"false",
";",
"rules",
".",
"addAll",
"(",
"getRulesWithSurtPrefix",
"(",
"search",
")",
")",
";",
"}",
"else",
"{",
"rules",
".",
"addAll",
"(",
"getRulesWithExactSurt",
"(",
"search",
")",
")",
";",
"}",
"}",
"return",
"rules",
";",
"}"
] |
Returns the "rule tree" for a given SURT. This is a sorted set of all
rules equal or lower in specificity than the given SURT plus all rules on
the path from this SURT to the root SURT "(".
The intention is to call this function with a domain or public suffix,
then queries within that domain can be made very fast by searching the
resulting list.
@param surt
@return
|
[
"Returns",
"the",
"rule",
"tree",
"for",
"a",
"given",
"SURT",
".",
"This",
"is",
"a",
"sorted",
"set",
"of",
"all",
"rules",
"equal",
"or",
"lower",
"in",
"specificity",
"than",
"the",
"given",
"SURT",
"plus",
"all",
"rules",
"on",
"the",
"path",
"from",
"this",
"SURT",
"to",
"the",
"root",
"SURT",
"(",
"."
] |
4a0f70f200fd8d7b6e313624b7628656d834bf31
|
https://github.com/iipc/openwayback-access-control/blob/4a0f70f200fd8d7b6e313624b7628656d834bf31/oracle/src/main/java/org/archive/accesscontrol/model/HibernateRuleDao.java#L79-L96
|
148,247
|
lecousin/java-compression
|
deflate/src/main/java/net/lecousin/compression/deflate/DeflateCompressor.java
|
DeflateCompressor.compress
|
public ISynchronizationPoint<Exception> compress(Readable input, Writable output, int bufferSize, int maxBuffers, byte priority) {
Deflater deflater = new Deflater(level, nowrap);
LimitWriteOperationsReuseBuffers limit = new LimitWriteOperationsReuseBuffers(output, bufferSize, maxBuffers);
byte[] bufRead = new byte[bufferSize];
ByteBuffer buffer = ByteBuffer.wrap(bufRead);
AsyncWork<Integer,IOException> task = input.readAsync(buffer);
SynchronizationPoint<Exception> end = new SynchronizationPoint<>();
task.listenAsync(new Compress(input, output, task, bufRead, deflater, limit, priority, end), true);
return end;
}
|
java
|
public ISynchronizationPoint<Exception> compress(Readable input, Writable output, int bufferSize, int maxBuffers, byte priority) {
Deflater deflater = new Deflater(level, nowrap);
LimitWriteOperationsReuseBuffers limit = new LimitWriteOperationsReuseBuffers(output, bufferSize, maxBuffers);
byte[] bufRead = new byte[bufferSize];
ByteBuffer buffer = ByteBuffer.wrap(bufRead);
AsyncWork<Integer,IOException> task = input.readAsync(buffer);
SynchronizationPoint<Exception> end = new SynchronizationPoint<>();
task.listenAsync(new Compress(input, output, task, bufRead, deflater, limit, priority, end), true);
return end;
}
|
[
"public",
"ISynchronizationPoint",
"<",
"Exception",
">",
"compress",
"(",
"Readable",
"input",
",",
"Writable",
"output",
",",
"int",
"bufferSize",
",",
"int",
"maxBuffers",
",",
"byte",
"priority",
")",
"{",
"Deflater",
"deflater",
"=",
"new",
"Deflater",
"(",
"level",
",",
"nowrap",
")",
";",
"LimitWriteOperationsReuseBuffers",
"limit",
"=",
"new",
"LimitWriteOperationsReuseBuffers",
"(",
"output",
",",
"bufferSize",
",",
"maxBuffers",
")",
";",
"byte",
"[",
"]",
"bufRead",
"=",
"new",
"byte",
"[",
"bufferSize",
"]",
";",
"ByteBuffer",
"buffer",
"=",
"ByteBuffer",
".",
"wrap",
"(",
"bufRead",
")",
";",
"AsyncWork",
"<",
"Integer",
",",
"IOException",
">",
"task",
"=",
"input",
".",
"readAsync",
"(",
"buffer",
")",
";",
"SynchronizationPoint",
"<",
"Exception",
">",
"end",
"=",
"new",
"SynchronizationPoint",
"<>",
"(",
")",
";",
"task",
".",
"listenAsync",
"(",
"new",
"Compress",
"(",
"input",
",",
"output",
",",
"task",
",",
"bufRead",
",",
"deflater",
",",
"limit",
",",
"priority",
",",
"end",
")",
",",
"true",
")",
";",
"return",
"end",
";",
"}"
] |
Compress from a Readable to a Writable.
|
[
"Compress",
"from",
"a",
"Readable",
"to",
"a",
"Writable",
"."
] |
19c8001fb3655817a52a3b8ab69501e3df7a2b4a
|
https://github.com/lecousin/java-compression/blob/19c8001fb3655817a52a3b8ab69501e3df7a2b4a/deflate/src/main/java/net/lecousin/compression/deflate/DeflateCompressor.java#L49-L58
|
148,248
|
luuuis/jcalendar
|
src/main/java/com/toedter/calendar/demo/JCalendarDemo.java
|
JCalendarDemo.initializeLookAndFeels
|
public final void initializeLookAndFeels() {
// if in classpath thry to load JGoodies Plastic Look & Feel
try {
LookAndFeelInfo[] lnfs = UIManager.getInstalledLookAndFeels();
boolean found = false;
for (int i = 0; i < lnfs.length; i++) {
if (lnfs[i].getName().equals("JGoodies Plastic 3D")) {
found = true;
}
}
if (!found) {
UIManager.installLookAndFeel("JGoodies Plastic 3D",
"com.jgoodies.looks.plastic.Plastic3DLookAndFeel");
}
UIManager.setLookAndFeel("com.jgoodies.looks.plastic.Plastic3DLookAndFeel");
} catch (Throwable t) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
e.printStackTrace();
}
}
}
|
java
|
public final void initializeLookAndFeels() {
// if in classpath thry to load JGoodies Plastic Look & Feel
try {
LookAndFeelInfo[] lnfs = UIManager.getInstalledLookAndFeels();
boolean found = false;
for (int i = 0; i < lnfs.length; i++) {
if (lnfs[i].getName().equals("JGoodies Plastic 3D")) {
found = true;
}
}
if (!found) {
UIManager.installLookAndFeel("JGoodies Plastic 3D",
"com.jgoodies.looks.plastic.Plastic3DLookAndFeel");
}
UIManager.setLookAndFeel("com.jgoodies.looks.plastic.Plastic3DLookAndFeel");
} catch (Throwable t) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
e.printStackTrace();
}
}
}
|
[
"public",
"final",
"void",
"initializeLookAndFeels",
"(",
")",
"{",
"// if in classpath thry to load JGoodies Plastic Look & Feel",
"try",
"{",
"LookAndFeelInfo",
"[",
"]",
"lnfs",
"=",
"UIManager",
".",
"getInstalledLookAndFeels",
"(",
")",
";",
"boolean",
"found",
"=",
"false",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"lnfs",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"lnfs",
"[",
"i",
"]",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"\"JGoodies Plastic 3D\"",
")",
")",
"{",
"found",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"!",
"found",
")",
"{",
"UIManager",
".",
"installLookAndFeel",
"(",
"\"JGoodies Plastic 3D\"",
",",
"\"com.jgoodies.looks.plastic.Plastic3DLookAndFeel\"",
")",
";",
"}",
"UIManager",
".",
"setLookAndFeel",
"(",
"\"com.jgoodies.looks.plastic.Plastic3DLookAndFeel\"",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"try",
"{",
"UIManager",
".",
"setLookAndFeel",
"(",
"UIManager",
".",
"getSystemLookAndFeelClassName",
"(",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}",
"}"
] |
Installs the JGoodies Look & Feels, if available, in classpath.
|
[
"Installs",
"the",
"JGoodies",
"Look",
"&",
"Feels",
"if",
"available",
"in",
"classpath",
"."
] |
442e5bc319d92dee93400e6180ca74a5b6bd7775
|
https://github.com/luuuis/jcalendar/blob/442e5bc319d92dee93400e6180ca74a5b6bd7775/src/main/java/com/toedter/calendar/demo/JCalendarDemo.java#L162-L184
|
148,249
|
luuuis/jcalendar
|
src/main/java/com/toedter/calendar/demo/JCalendarDemo.java
|
JCalendarDemo.main
|
public static void main(String[] s) {
WindowListener l = new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
};
JFrame frame = new JFrame("JCalendar Demo");
frame.addWindowListener(l);
JCalendarDemo demo = new JCalendarDemo();
demo.init();
frame.getContentPane().add(demo);
frame.pack();
frame.setBounds(200, 200, (int) frame.getPreferredSize().getWidth() + 20, (int) frame
.getPreferredSize().getHeight() + 180);
frame.setVisible(true);
}
|
java
|
public static void main(String[] s) {
WindowListener l = new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
};
JFrame frame = new JFrame("JCalendar Demo");
frame.addWindowListener(l);
JCalendarDemo demo = new JCalendarDemo();
demo.init();
frame.getContentPane().add(demo);
frame.pack();
frame.setBounds(200, 200, (int) frame.getPreferredSize().getWidth() + 20, (int) frame
.getPreferredSize().getHeight() + 180);
frame.setVisible(true);
}
|
[
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"s",
")",
"{",
"WindowListener",
"l",
"=",
"new",
"WindowAdapter",
"(",
")",
"{",
"public",
"void",
"windowClosing",
"(",
"WindowEvent",
"e",
")",
"{",
"System",
".",
"exit",
"(",
"0",
")",
";",
"}",
"}",
";",
"JFrame",
"frame",
"=",
"new",
"JFrame",
"(",
"\"JCalendar Demo\"",
")",
";",
"frame",
".",
"addWindowListener",
"(",
"l",
")",
";",
"JCalendarDemo",
"demo",
"=",
"new",
"JCalendarDemo",
"(",
")",
";",
"demo",
".",
"init",
"(",
")",
";",
"frame",
".",
"getContentPane",
"(",
")",
".",
"add",
"(",
"demo",
")",
";",
"frame",
".",
"pack",
"(",
")",
";",
"frame",
".",
"setBounds",
"(",
"200",
",",
"200",
",",
"(",
"int",
")",
"frame",
".",
"getPreferredSize",
"(",
")",
".",
"getWidth",
"(",
")",
"+",
"20",
",",
"(",
"int",
")",
"frame",
".",
"getPreferredSize",
"(",
")",
".",
"getHeight",
"(",
")",
"+",
"180",
")",
";",
"frame",
".",
"setVisible",
"(",
"true",
")",
";",
"}"
] |
Creates a JFrame with a JCalendarDemo inside and can be used for testing.
@param s
The command line arguments
|
[
"Creates",
"a",
"JFrame",
"with",
"a",
"JCalendarDemo",
"inside",
"and",
"can",
"be",
"used",
"for",
"testing",
"."
] |
442e5bc319d92dee93400e6180ca74a5b6bd7775
|
https://github.com/luuuis/jcalendar/blob/442e5bc319d92dee93400e6180ca74a5b6bd7775/src/main/java/com/toedter/calendar/demo/JCalendarDemo.java#L369-L386
|
148,250
|
zamrokk/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/TCertGetter.java
|
TCertGetter.getTCerts
|
private void getTCerts() {
GetTCertBatchRequest req = new GetTCertBatchRequest(this.member.getName(), this.member.getEnrollment(),
this.member.getTCertBatchSize(), attrs);
try {
List<TCert> tcerts = this.memberServices.getTCertBatch(req);
// Add to member's tcert list
for (TCert tcert : tcerts) {
this.tcerts.push(tcert);
}
} catch (GetTCertBatchException e) {
// ignore the exception for now
}
}
|
java
|
private void getTCerts() {
GetTCertBatchRequest req = new GetTCertBatchRequest(this.member.getName(), this.member.getEnrollment(),
this.member.getTCertBatchSize(), attrs);
try {
List<TCert> tcerts = this.memberServices.getTCertBatch(req);
// Add to member's tcert list
for (TCert tcert : tcerts) {
this.tcerts.push(tcert);
}
} catch (GetTCertBatchException e) {
// ignore the exception for now
}
}
|
[
"private",
"void",
"getTCerts",
"(",
")",
"{",
"GetTCertBatchRequest",
"req",
"=",
"new",
"GetTCertBatchRequest",
"(",
"this",
".",
"member",
".",
"getName",
"(",
")",
",",
"this",
".",
"member",
".",
"getEnrollment",
"(",
")",
",",
"this",
".",
"member",
".",
"getTCertBatchSize",
"(",
")",
",",
"attrs",
")",
";",
"try",
"{",
"List",
"<",
"TCert",
">",
"tcerts",
"=",
"this",
".",
"memberServices",
".",
"getTCertBatch",
"(",
"req",
")",
";",
"// Add to member's tcert list",
"for",
"(",
"TCert",
"tcert",
":",
"tcerts",
")",
"{",
"this",
".",
"tcerts",
".",
"push",
"(",
"tcert",
")",
";",
"}",
"}",
"catch",
"(",
"GetTCertBatchException",
"e",
")",
"{",
"// ignore the exception for now",
"}",
"}"
] |
Call member services to get more tcerts
|
[
"Call",
"member",
"services",
"to",
"get",
"more",
"tcerts"
] |
d4993ca602f72d412cd682e1b92e805e48b27afa
|
https://github.com/zamrokk/fabric-sdk-java/blob/d4993ca602f72d412cd682e1b92e805e48b27afa/src/main/java/org/hyperledger/fabric/sdk/TCertGetter.java#L130-L142
|
148,251
|
craterdog/java-security-framework
|
java-property-encryptor/src/main/java/craterdog/security/PropertyEncryptor.java
|
PropertyEncryptor.main
|
static public void main(String[] args) {
String propertyValue = args[0];
logger.info("Property Value: " + propertyValue);
String encryptedValue = encryptor.encryptPropertyValue(propertyValue);
logger.info("Encrypted Value: " + encryptedValue);
}
|
java
|
static public void main(String[] args) {
String propertyValue = args[0];
logger.info("Property Value: " + propertyValue);
String encryptedValue = encryptor.encryptPropertyValue(propertyValue);
logger.info("Encrypted Value: " + encryptedValue);
}
|
[
"static",
"public",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"String",
"propertyValue",
"=",
"args",
"[",
"0",
"]",
";",
"logger",
".",
"info",
"(",
"\"Property Value: \"",
"+",
"propertyValue",
")",
";",
"String",
"encryptedValue",
"=",
"encryptor",
".",
"encryptPropertyValue",
"(",
"propertyValue",
")",
";",
"logger",
".",
"info",
"(",
"\"Encrypted Value: \"",
"+",
"encryptedValue",
")",
";",
"}"
] |
The main method for this application.
@param args The arguments that were passed into this program. There should only be one
argument, the property value to be encrypted.
|
[
"The",
"main",
"method",
"for",
"this",
"application",
"."
] |
a5634c19812d473b608bc11060f5cbb4b4b0b5da
|
https://github.com/craterdog/java-security-framework/blob/a5634c19812d473b608bc11060f5cbb4b4b0b5da/java-property-encryptor/src/main/java/craterdog/security/PropertyEncryptor.java#L47-L52
|
148,252
|
JM-Lab/utils-elasticsearch
|
src/main/java/kr/jm/utils/elasticsearch/JMEmbeddedElasticsearch.java
|
JMEmbeddedElasticsearch.getNodeConfig
|
public static Builder getNodeConfig(String clusterName, String nodeName,
String networkHost, String homePath, boolean nodeIngest) {
return Settings.builder()
// .put("path.metric", dataPath).put("http.port", httpRange)
// .put("transport.tcp.port", transportRange)
.put("node.name", nodeName).put("cluster.name", clusterName)
.put("network.host", networkHost).put("path.home", homePath)
.put("transport.type", "netty4")
// .put("discovery.type", "none")
.put("http.type", "netty4").put("node.ingest", nodeIngest);
}
|
java
|
public static Builder getNodeConfig(String clusterName, String nodeName,
String networkHost, String homePath, boolean nodeIngest) {
return Settings.builder()
// .put("path.metric", dataPath).put("http.port", httpRange)
// .put("transport.tcp.port", transportRange)
.put("node.name", nodeName).put("cluster.name", clusterName)
.put("network.host", networkHost).put("path.home", homePath)
.put("transport.type", "netty4")
// .put("discovery.type", "none")
.put("http.type", "netty4").put("node.ingest", nodeIngest);
}
|
[
"public",
"static",
"Builder",
"getNodeConfig",
"(",
"String",
"clusterName",
",",
"String",
"nodeName",
",",
"String",
"networkHost",
",",
"String",
"homePath",
",",
"boolean",
"nodeIngest",
")",
"{",
"return",
"Settings",
".",
"builder",
"(",
")",
"// .put(\"path.metric\", dataPath).put(\"http.port\", httpRange)",
"// .put(\"transport.tcp.port\", transportRange)",
".",
"put",
"(",
"\"node.name\"",
",",
"nodeName",
")",
".",
"put",
"(",
"\"cluster.name\"",
",",
"clusterName",
")",
".",
"put",
"(",
"\"network.host\"",
",",
"networkHost",
")",
".",
"put",
"(",
"\"path.home\"",
",",
"homePath",
")",
".",
"put",
"(",
"\"transport.type\"",
",",
"\"netty4\"",
")",
"// .put(\"discovery.type\", \"none\")",
".",
"put",
"(",
"\"http.type\"",
",",
"\"netty4\"",
")",
".",
"put",
"(",
"\"node.ingest\"",
",",
"nodeIngest",
")",
";",
"}"
] |
Gets node config.
@param clusterName the cluster name
@param nodeName the node name
@param networkHost the network host
@param homePath the home path
@param nodeIngest the node ingest
@return the node config
|
[
"Gets",
"node",
"config",
"."
] |
6ccec90e1e51d65d2af5efbb6d7b9f9bad90e638
|
https://github.com/JM-Lab/utils-elasticsearch/blob/6ccec90e1e51d65d2af5efbb6d7b9f9bad90e638/src/main/java/kr/jm/utils/elasticsearch/JMEmbeddedElasticsearch.java#L74-L84
|
148,253
|
luuuis/jcalendar
|
src/main/java/com/toedter/calendar/JDayChooser.java
|
JDayChooser.init
|
protected void init() {
JButton testButton = new JButton();
oldDayBackgroundColor = testButton.getBackground();
selectedColor = new Color(160, 160, 160);
Date date = calendar.getTime();
calendar = Calendar.getInstance(locale);
calendar.setTime(date);
drawDayNames();
drawDays();
}
|
java
|
protected void init() {
JButton testButton = new JButton();
oldDayBackgroundColor = testButton.getBackground();
selectedColor = new Color(160, 160, 160);
Date date = calendar.getTime();
calendar = Calendar.getInstance(locale);
calendar.setTime(date);
drawDayNames();
drawDays();
}
|
[
"protected",
"void",
"init",
"(",
")",
"{",
"JButton",
"testButton",
"=",
"new",
"JButton",
"(",
")",
";",
"oldDayBackgroundColor",
"=",
"testButton",
".",
"getBackground",
"(",
")",
";",
"selectedColor",
"=",
"new",
"Color",
"(",
"160",
",",
"160",
",",
"160",
")",
";",
"Date",
"date",
"=",
"calendar",
".",
"getTime",
"(",
")",
";",
"calendar",
"=",
"Calendar",
".",
"getInstance",
"(",
"locale",
")",
";",
"calendar",
".",
"setTime",
"(",
"date",
")",
";",
"drawDayNames",
"(",
")",
";",
"drawDays",
"(",
")",
";",
"}"
] |
Initilizes the locale specific names for the days of the week.
|
[
"Initilizes",
"the",
"locale",
"specific",
"names",
"for",
"the",
"days",
"of",
"the",
"week",
"."
] |
442e5bc319d92dee93400e6180ca74a5b6bd7775
|
https://github.com/luuuis/jcalendar/blob/442e5bc319d92dee93400e6180ca74a5b6bd7775/src/main/java/com/toedter/calendar/JDayChooser.java#L224-L235
|
148,254
|
luuuis/jcalendar
|
src/main/java/com/toedter/calendar/JDayChooser.java
|
JDayChooser.drawDayNames
|
private void drawDayNames() {
int firstDayOfWeek = calendar.getFirstDayOfWeek();
DateFormatSymbols dateFormatSymbols = new DateFormatSymbols(locale);
dayNames = dateFormatSymbols.getShortWeekdays();
int day = firstDayOfWeek;
for (int i = 0; i < 7; i++) {
if (maxDayCharacters > 0 && maxDayCharacters < 5) {
if (dayNames[day].length() >= maxDayCharacters) {
dayNames[day] = dayNames[day]
.substring(0, maxDayCharacters);
}
}
days[i].setText(dayNames[day]);
if (day == 1) {
days[i].setForeground(sundayForeground);
} else {
days[i].setForeground(weekdayForeground);
}
if (day < 7) {
day++;
} else {
day -= 6;
}
}
}
|
java
|
private void drawDayNames() {
int firstDayOfWeek = calendar.getFirstDayOfWeek();
DateFormatSymbols dateFormatSymbols = new DateFormatSymbols(locale);
dayNames = dateFormatSymbols.getShortWeekdays();
int day = firstDayOfWeek;
for (int i = 0; i < 7; i++) {
if (maxDayCharacters > 0 && maxDayCharacters < 5) {
if (dayNames[day].length() >= maxDayCharacters) {
dayNames[day] = dayNames[day]
.substring(0, maxDayCharacters);
}
}
days[i].setText(dayNames[day]);
if (day == 1) {
days[i].setForeground(sundayForeground);
} else {
days[i].setForeground(weekdayForeground);
}
if (day < 7) {
day++;
} else {
day -= 6;
}
}
}
|
[
"private",
"void",
"drawDayNames",
"(",
")",
"{",
"int",
"firstDayOfWeek",
"=",
"calendar",
".",
"getFirstDayOfWeek",
"(",
")",
";",
"DateFormatSymbols",
"dateFormatSymbols",
"=",
"new",
"DateFormatSymbols",
"(",
"locale",
")",
";",
"dayNames",
"=",
"dateFormatSymbols",
".",
"getShortWeekdays",
"(",
")",
";",
"int",
"day",
"=",
"firstDayOfWeek",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"7",
";",
"i",
"++",
")",
"{",
"if",
"(",
"maxDayCharacters",
">",
"0",
"&&",
"maxDayCharacters",
"<",
"5",
")",
"{",
"if",
"(",
"dayNames",
"[",
"day",
"]",
".",
"length",
"(",
")",
">=",
"maxDayCharacters",
")",
"{",
"dayNames",
"[",
"day",
"]",
"=",
"dayNames",
"[",
"day",
"]",
".",
"substring",
"(",
"0",
",",
"maxDayCharacters",
")",
";",
"}",
"}",
"days",
"[",
"i",
"]",
".",
"setText",
"(",
"dayNames",
"[",
"day",
"]",
")",
";",
"if",
"(",
"day",
"==",
"1",
")",
"{",
"days",
"[",
"i",
"]",
".",
"setForeground",
"(",
"sundayForeground",
")",
";",
"}",
"else",
"{",
"days",
"[",
"i",
"]",
".",
"setForeground",
"(",
"weekdayForeground",
")",
";",
"}",
"if",
"(",
"day",
"<",
"7",
")",
"{",
"day",
"++",
";",
"}",
"else",
"{",
"day",
"-=",
"6",
";",
"}",
"}",
"}"
] |
Draws the day names of the day columnes.
|
[
"Draws",
"the",
"day",
"names",
"of",
"the",
"day",
"columnes",
"."
] |
442e5bc319d92dee93400e6180ca74a5b6bd7775
|
https://github.com/luuuis/jcalendar/blob/442e5bc319d92dee93400e6180ca74a5b6bd7775/src/main/java/com/toedter/calendar/JDayChooser.java#L240-L269
|
148,255
|
luuuis/jcalendar
|
src/main/java/com/toedter/calendar/JDayChooser.java
|
JDayChooser.initDecorations
|
protected void initDecorations() {
for (int x = 0; x < 7; x++) {
days[x].setContentAreaFilled(decorationBackgroundVisible);
days[x].setBorderPainted(decorationBordersVisible);
days[x].invalidate();
days[x].repaint();
weeks[x].setContentAreaFilled(decorationBackgroundVisible);
weeks[x].setBorderPainted(decorationBordersVisible);
weeks[x].invalidate();
weeks[x].repaint();
}
}
|
java
|
protected void initDecorations() {
for (int x = 0; x < 7; x++) {
days[x].setContentAreaFilled(decorationBackgroundVisible);
days[x].setBorderPainted(decorationBordersVisible);
days[x].invalidate();
days[x].repaint();
weeks[x].setContentAreaFilled(decorationBackgroundVisible);
weeks[x].setBorderPainted(decorationBordersVisible);
weeks[x].invalidate();
weeks[x].repaint();
}
}
|
[
"protected",
"void",
"initDecorations",
"(",
")",
"{",
"for",
"(",
"int",
"x",
"=",
"0",
";",
"x",
"<",
"7",
";",
"x",
"++",
")",
"{",
"days",
"[",
"x",
"]",
".",
"setContentAreaFilled",
"(",
"decorationBackgroundVisible",
")",
";",
"days",
"[",
"x",
"]",
".",
"setBorderPainted",
"(",
"decorationBordersVisible",
")",
";",
"days",
"[",
"x",
"]",
".",
"invalidate",
"(",
")",
";",
"days",
"[",
"x",
"]",
".",
"repaint",
"(",
")",
";",
"weeks",
"[",
"x",
"]",
".",
"setContentAreaFilled",
"(",
"decorationBackgroundVisible",
")",
";",
"weeks",
"[",
"x",
"]",
".",
"setBorderPainted",
"(",
"decorationBordersVisible",
")",
";",
"weeks",
"[",
"x",
"]",
".",
"invalidate",
"(",
")",
";",
"weeks",
"[",
"x",
"]",
".",
"repaint",
"(",
")",
";",
"}",
"}"
] |
Initializes both day names and weeks of the year.
|
[
"Initializes",
"both",
"day",
"names",
"and",
"weeks",
"of",
"the",
"year",
"."
] |
442e5bc319d92dee93400e6180ca74a5b6bd7775
|
https://github.com/luuuis/jcalendar/blob/442e5bc319d92dee93400e6180ca74a5b6bd7775/src/main/java/com/toedter/calendar/JDayChooser.java#L274-L285
|
148,256
|
luuuis/jcalendar
|
src/main/java/com/toedter/calendar/JDayChooser.java
|
JDayChooser.drawWeeks
|
protected void drawWeeks() {
Calendar tmpCalendar = (Calendar) calendar.clone();
for (int i = 1; i < 7; i++) {
tmpCalendar.set(Calendar.DAY_OF_MONTH, (i * 7) - 6);
int week = tmpCalendar.get(Calendar.WEEK_OF_YEAR);
String buttonText = Integer.toString(week);
if (week < 10) {
buttonText = "0" + buttonText;
}
weeks[i].setText(buttonText);
if ((i == 5) || (i == 6)) {
weeks[i].setVisible(days[i * 7].isVisible());
}
}
}
|
java
|
protected void drawWeeks() {
Calendar tmpCalendar = (Calendar) calendar.clone();
for (int i = 1; i < 7; i++) {
tmpCalendar.set(Calendar.DAY_OF_MONTH, (i * 7) - 6);
int week = tmpCalendar.get(Calendar.WEEK_OF_YEAR);
String buttonText = Integer.toString(week);
if (week < 10) {
buttonText = "0" + buttonText;
}
weeks[i].setText(buttonText);
if ((i == 5) || (i == 6)) {
weeks[i].setVisible(days[i * 7].isVisible());
}
}
}
|
[
"protected",
"void",
"drawWeeks",
"(",
")",
"{",
"Calendar",
"tmpCalendar",
"=",
"(",
"Calendar",
")",
"calendar",
".",
"clone",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"7",
";",
"i",
"++",
")",
"{",
"tmpCalendar",
".",
"set",
"(",
"Calendar",
".",
"DAY_OF_MONTH",
",",
"(",
"i",
"*",
"7",
")",
"-",
"6",
")",
";",
"int",
"week",
"=",
"tmpCalendar",
".",
"get",
"(",
"Calendar",
".",
"WEEK_OF_YEAR",
")",
";",
"String",
"buttonText",
"=",
"Integer",
".",
"toString",
"(",
"week",
")",
";",
"if",
"(",
"week",
"<",
"10",
")",
"{",
"buttonText",
"=",
"\"0\"",
"+",
"buttonText",
";",
"}",
"weeks",
"[",
"i",
"]",
".",
"setText",
"(",
"buttonText",
")",
";",
"if",
"(",
"(",
"i",
"==",
"5",
")",
"||",
"(",
"i",
"==",
"6",
")",
")",
"{",
"weeks",
"[",
"i",
"]",
".",
"setVisible",
"(",
"days",
"[",
"i",
"*",
"7",
"]",
".",
"isVisible",
"(",
")",
")",
";",
"}",
"}",
"}"
] |
Hides and shows the week buttons.
|
[
"Hides",
"and",
"shows",
"the",
"week",
"buttons",
"."
] |
442e5bc319d92dee93400e6180ca74a5b6bd7775
|
https://github.com/luuuis/jcalendar/blob/442e5bc319d92dee93400e6180ca74a5b6bd7775/src/main/java/com/toedter/calendar/JDayChooser.java#L290-L309
|
148,257
|
luuuis/jcalendar
|
src/main/java/com/toedter/calendar/JDayChooser.java
|
JDayChooser.setDay
|
public void setDay(int d) {
if (d < 1) {
d = 1;
}
Calendar tmpCalendar = (Calendar) calendar.clone();
tmpCalendar.set(Calendar.DAY_OF_MONTH, 1);
tmpCalendar.add(Calendar.MONTH, 1);
tmpCalendar.add(Calendar.DATE, -1);
int maxDaysInMonth = tmpCalendar.get(Calendar.DATE);
if (d > maxDaysInMonth) {
d = maxDaysInMonth;
}
int oldDay = day;
day = d;
if (selectedDay != null) {
selectedDay.setBackground(oldDayBackgroundColor);
selectedDay.repaint();
}
for (int i = 7; i < 49; i++) {
if (days[i].getText().equals(Integer.toString(day))) {
selectedDay = days[i];
selectedDay.setBackground(selectedColor);
break;
}
}
if (alwaysFireDayProperty) {
firePropertyChange("day", 0, day);
} else {
firePropertyChange("day", oldDay, day);
}
}
|
java
|
public void setDay(int d) {
if (d < 1) {
d = 1;
}
Calendar tmpCalendar = (Calendar) calendar.clone();
tmpCalendar.set(Calendar.DAY_OF_MONTH, 1);
tmpCalendar.add(Calendar.MONTH, 1);
tmpCalendar.add(Calendar.DATE, -1);
int maxDaysInMonth = tmpCalendar.get(Calendar.DATE);
if (d > maxDaysInMonth) {
d = maxDaysInMonth;
}
int oldDay = day;
day = d;
if (selectedDay != null) {
selectedDay.setBackground(oldDayBackgroundColor);
selectedDay.repaint();
}
for (int i = 7; i < 49; i++) {
if (days[i].getText().equals(Integer.toString(day))) {
selectedDay = days[i];
selectedDay.setBackground(selectedColor);
break;
}
}
if (alwaysFireDayProperty) {
firePropertyChange("day", 0, day);
} else {
firePropertyChange("day", oldDay, day);
}
}
|
[
"public",
"void",
"setDay",
"(",
"int",
"d",
")",
"{",
"if",
"(",
"d",
"<",
"1",
")",
"{",
"d",
"=",
"1",
";",
"}",
"Calendar",
"tmpCalendar",
"=",
"(",
"Calendar",
")",
"calendar",
".",
"clone",
"(",
")",
";",
"tmpCalendar",
".",
"set",
"(",
"Calendar",
".",
"DAY_OF_MONTH",
",",
"1",
")",
";",
"tmpCalendar",
".",
"add",
"(",
"Calendar",
".",
"MONTH",
",",
"1",
")",
";",
"tmpCalendar",
".",
"add",
"(",
"Calendar",
".",
"DATE",
",",
"-",
"1",
")",
";",
"int",
"maxDaysInMonth",
"=",
"tmpCalendar",
".",
"get",
"(",
"Calendar",
".",
"DATE",
")",
";",
"if",
"(",
"d",
">",
"maxDaysInMonth",
")",
"{",
"d",
"=",
"maxDaysInMonth",
";",
"}",
"int",
"oldDay",
"=",
"day",
";",
"day",
"=",
"d",
";",
"if",
"(",
"selectedDay",
"!=",
"null",
")",
"{",
"selectedDay",
".",
"setBackground",
"(",
"oldDayBackgroundColor",
")",
";",
"selectedDay",
".",
"repaint",
"(",
")",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"7",
";",
"i",
"<",
"49",
";",
"i",
"++",
")",
"{",
"if",
"(",
"days",
"[",
"i",
"]",
".",
"getText",
"(",
")",
".",
"equals",
"(",
"Integer",
".",
"toString",
"(",
"day",
")",
")",
")",
"{",
"selectedDay",
"=",
"days",
"[",
"i",
"]",
";",
"selectedDay",
".",
"setBackground",
"(",
"selectedColor",
")",
";",
"break",
";",
"}",
"}",
"if",
"(",
"alwaysFireDayProperty",
")",
"{",
"firePropertyChange",
"(",
"\"day\"",
",",
"0",
",",
"day",
")",
";",
"}",
"else",
"{",
"firePropertyChange",
"(",
"\"day\"",
",",
"oldDay",
",",
"day",
")",
";",
"}",
"}"
] |
Sets the day. This is a bound property.
@param d
the day
@see #getDay
|
[
"Sets",
"the",
"day",
".",
"This",
"is",
"a",
"bound",
"property",
"."
] |
442e5bc319d92dee93400e6180ca74a5b6bd7775
|
https://github.com/luuuis/jcalendar/blob/442e5bc319d92dee93400e6180ca74a5b6bd7775/src/main/java/com/toedter/calendar/JDayChooser.java#L436-L472
|
148,258
|
luuuis/jcalendar
|
src/main/java/com/toedter/calendar/JDayChooser.java
|
JDayChooser.setMonth
|
public void setMonth(int month) {
calendar.set(Calendar.MONTH, month);
int maxDays = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
int adjustedDay = day;
if (day > maxDays) {
adjustedDay = maxDays;
setDay(adjustedDay);
}
drawDays();
}
|
java
|
public void setMonth(int month) {
calendar.set(Calendar.MONTH, month);
int maxDays = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
int adjustedDay = day;
if (day > maxDays) {
adjustedDay = maxDays;
setDay(adjustedDay);
}
drawDays();
}
|
[
"public",
"void",
"setMonth",
"(",
"int",
"month",
")",
"{",
"calendar",
".",
"set",
"(",
"Calendar",
".",
"MONTH",
",",
"month",
")",
";",
"int",
"maxDays",
"=",
"calendar",
".",
"getActualMaximum",
"(",
"Calendar",
".",
"DAY_OF_MONTH",
")",
";",
"int",
"adjustedDay",
"=",
"day",
";",
"if",
"(",
"day",
">",
"maxDays",
")",
"{",
"adjustedDay",
"=",
"maxDays",
";",
"setDay",
"(",
"adjustedDay",
")",
";",
"}",
"drawDays",
"(",
")",
";",
"}"
] |
Sets a specific month. This is needed for correct graphical
representation of the days.
@param month
the new month
|
[
"Sets",
"a",
"specific",
"month",
".",
"This",
"is",
"needed",
"for",
"correct",
"graphical",
"representation",
"of",
"the",
"days",
"."
] |
442e5bc319d92dee93400e6180ca74a5b6bd7775
|
https://github.com/luuuis/jcalendar/blob/442e5bc319d92dee93400e6180ca74a5b6bd7775/src/main/java/com/toedter/calendar/JDayChooser.java#L503-L514
|
148,259
|
luuuis/jcalendar
|
src/main/java/com/toedter/calendar/JDayChooser.java
|
JDayChooser.setForeground
|
public void setForeground(Color foreground) {
super.setForeground(foreground);
if (days != null) {
for (int i = 7; i < 49; i++) {
days[i].setForeground(foreground);
}
drawDays();
}
}
|
java
|
public void setForeground(Color foreground) {
super.setForeground(foreground);
if (days != null) {
for (int i = 7; i < 49; i++) {
days[i].setForeground(foreground);
}
drawDays();
}
}
|
[
"public",
"void",
"setForeground",
"(",
"Color",
"foreground",
")",
"{",
"super",
".",
"setForeground",
"(",
"foreground",
")",
";",
"if",
"(",
"days",
"!=",
"null",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"7",
";",
"i",
"<",
"49",
";",
"i",
"++",
")",
"{",
"days",
"[",
"i",
"]",
".",
"setForeground",
"(",
"foreground",
")",
";",
"}",
"drawDays",
"(",
")",
";",
"}",
"}"
] |
Sets the foregroundColor color.
@param foreground
the new foregroundColor
|
[
"Sets",
"the",
"foregroundColor",
"color",
"."
] |
442e5bc319d92dee93400e6180ca74a5b6bd7775
|
https://github.com/luuuis/jcalendar/blob/442e5bc319d92dee93400e6180ca74a5b6bd7775/src/main/java/com/toedter/calendar/JDayChooser.java#L565-L575
|
148,260
|
luuuis/jcalendar
|
src/main/java/com/toedter/calendar/JDayChooser.java
|
JDayChooser.actionPerformed
|
public void actionPerformed(ActionEvent e) {
JButton button = (JButton) e.getSource();
String buttonText = button.getText();
int day = new Integer(buttonText).intValue();
setDay(day);
}
|
java
|
public void actionPerformed(ActionEvent e) {
JButton button = (JButton) e.getSource();
String buttonText = button.getText();
int day = new Integer(buttonText).intValue();
setDay(day);
}
|
[
"public",
"void",
"actionPerformed",
"(",
"ActionEvent",
"e",
")",
"{",
"JButton",
"button",
"=",
"(",
"JButton",
")",
"e",
".",
"getSource",
"(",
")",
";",
"String",
"buttonText",
"=",
"button",
".",
"getText",
"(",
")",
";",
"int",
"day",
"=",
"new",
"Integer",
"(",
"buttonText",
")",
".",
"intValue",
"(",
")",
";",
"setDay",
"(",
"day",
")",
";",
"}"
] |
JDayChooser is the ActionListener for all day buttons.
@param e
the ActionEvent
|
[
"JDayChooser",
"is",
"the",
"ActionListener",
"for",
"all",
"day",
"buttons",
"."
] |
442e5bc319d92dee93400e6180ca74a5b6bd7775
|
https://github.com/luuuis/jcalendar/blob/442e5bc319d92dee93400e6180ca74a5b6bd7775/src/main/java/com/toedter/calendar/JDayChooser.java#L583-L588
|
148,261
|
luuuis/jcalendar
|
src/main/java/com/toedter/calendar/JDayChooser.java
|
JDayChooser.setEnabled
|
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
for (short i = 0; i < days.length; i++) {
if (days[i] != null) {
days[i].setEnabled(enabled);
}
}
for (short i = 0; i < weeks.length; i++) {
if (weeks[i] != null) {
weeks[i].setEnabled(enabled);
}
}
}
|
java
|
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
for (short i = 0; i < days.length; i++) {
if (days[i] != null) {
days[i].setEnabled(enabled);
}
}
for (short i = 0; i < weeks.length; i++) {
if (weeks[i] != null) {
weeks[i].setEnabled(enabled);
}
}
}
|
[
"public",
"void",
"setEnabled",
"(",
"boolean",
"enabled",
")",
"{",
"super",
".",
"setEnabled",
"(",
"enabled",
")",
";",
"for",
"(",
"short",
"i",
"=",
"0",
";",
"i",
"<",
"days",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"days",
"[",
"i",
"]",
"!=",
"null",
")",
"{",
"days",
"[",
"i",
"]",
".",
"setEnabled",
"(",
"enabled",
")",
";",
"}",
"}",
"for",
"(",
"short",
"i",
"=",
"0",
";",
"i",
"<",
"weeks",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"weeks",
"[",
"i",
"]",
"!=",
"null",
")",
"{",
"weeks",
"[",
"i",
"]",
".",
"setEnabled",
"(",
"enabled",
")",
";",
"}",
"}",
"}"
] |
Enable or disable the JDayChooser.
@param enabled
The new enabled value
|
[
"Enable",
"or",
"disable",
"the",
"JDayChooser",
"."
] |
442e5bc319d92dee93400e6180ca74a5b6bd7775
|
https://github.com/luuuis/jcalendar/blob/442e5bc319d92dee93400e6180ca74a5b6bd7775/src/main/java/com/toedter/calendar/JDayChooser.java#L667-L681
|
148,262
|
luuuis/jcalendar
|
src/main/java/com/toedter/calendar/JDayChooser.java
|
JDayChooser.setWeekOfYearVisible
|
public void setWeekOfYearVisible(boolean weekOfYearVisible) {
if (weekOfYearVisible == this.weekOfYearVisible) {
return;
} else if (weekOfYearVisible) {
add(weekPanel, BorderLayout.WEST);
} else {
remove(weekPanel);
}
this.weekOfYearVisible = weekOfYearVisible;
validate();
dayPanel.validate();
}
|
java
|
public void setWeekOfYearVisible(boolean weekOfYearVisible) {
if (weekOfYearVisible == this.weekOfYearVisible) {
return;
} else if (weekOfYearVisible) {
add(weekPanel, BorderLayout.WEST);
} else {
remove(weekPanel);
}
this.weekOfYearVisible = weekOfYearVisible;
validate();
dayPanel.validate();
}
|
[
"public",
"void",
"setWeekOfYearVisible",
"(",
"boolean",
"weekOfYearVisible",
")",
"{",
"if",
"(",
"weekOfYearVisible",
"==",
"this",
".",
"weekOfYearVisible",
")",
"{",
"return",
";",
"}",
"else",
"if",
"(",
"weekOfYearVisible",
")",
"{",
"add",
"(",
"weekPanel",
",",
"BorderLayout",
".",
"WEST",
")",
";",
"}",
"else",
"{",
"remove",
"(",
"weekPanel",
")",
";",
"}",
"this",
".",
"weekOfYearVisible",
"=",
"weekOfYearVisible",
";",
"validate",
"(",
")",
";",
"dayPanel",
".",
"validate",
"(",
")",
";",
"}"
] |
In some Countries it is often usefull to know in which week of the year a
date is.
@param weekOfYearVisible
true, if the weeks of the year shall be shown
|
[
"In",
"some",
"Countries",
"it",
"is",
"often",
"usefull",
"to",
"know",
"in",
"which",
"week",
"of",
"the",
"year",
"a",
"date",
"is",
"."
] |
442e5bc319d92dee93400e6180ca74a5b6bd7775
|
https://github.com/luuuis/jcalendar/blob/442e5bc319d92dee93400e6180ca74a5b6bd7775/src/main/java/com/toedter/calendar/JDayChooser.java#L700-L712
|
148,263
|
luuuis/jcalendar
|
src/main/java/com/toedter/calendar/JDayChooser.java
|
JDayChooser.setDecorationBackgroundColor
|
public void setDecorationBackgroundColor(Color decorationBackgroundColor) {
this.decorationBackgroundColor = decorationBackgroundColor;
if (days != null) {
for (int i = 0; i < 7; i++) {
days[i].setBackground(decorationBackgroundColor);
}
}
if (weeks != null) {
for (int i = 0; i < 7; i++) {
weeks[i].setBackground(decorationBackgroundColor);
}
}
}
|
java
|
public void setDecorationBackgroundColor(Color decorationBackgroundColor) {
this.decorationBackgroundColor = decorationBackgroundColor;
if (days != null) {
for (int i = 0; i < 7; i++) {
days[i].setBackground(decorationBackgroundColor);
}
}
if (weeks != null) {
for (int i = 0; i < 7; i++) {
weeks[i].setBackground(decorationBackgroundColor);
}
}
}
|
[
"public",
"void",
"setDecorationBackgroundColor",
"(",
"Color",
"decorationBackgroundColor",
")",
"{",
"this",
".",
"decorationBackgroundColor",
"=",
"decorationBackgroundColor",
";",
"if",
"(",
"days",
"!=",
"null",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"7",
";",
"i",
"++",
")",
"{",
"days",
"[",
"i",
"]",
".",
"setBackground",
"(",
"decorationBackgroundColor",
")",
";",
"}",
"}",
"if",
"(",
"weeks",
"!=",
"null",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"7",
";",
"i",
"++",
")",
"{",
"weeks",
"[",
"i",
"]",
".",
"setBackground",
"(",
"decorationBackgroundColor",
")",
";",
"}",
"}",
"}"
] |
Sets the background of days and weeks of year buttons.
@param decorationBackgroundColor
The background to set
|
[
"Sets",
"the",
"background",
"of",
"days",
"and",
"weeks",
"of",
"year",
"buttons",
"."
] |
442e5bc319d92dee93400e6180ca74a5b6bd7775
|
https://github.com/luuuis/jcalendar/blob/442e5bc319d92dee93400e6180ca74a5b6bd7775/src/main/java/com/toedter/calendar/JDayChooser.java#L738-L752
|
148,264
|
luuuis/jcalendar
|
src/main/java/com/toedter/calendar/JDayChooser.java
|
JDayChooser.updateUI
|
public void updateUI() {
super.updateUI();
setFont(Font.decode("Dialog Plain 11"));
if (weekPanel != null) {
weekPanel.updateUI();
}
if (initialized) {
if ("Windows".equals(UIManager.getLookAndFeel().getID())) {
setDayBordersVisible(false);
setDecorationBackgroundVisible(true);
setDecorationBordersVisible(false);
} else {
setDayBordersVisible(true);
setDecorationBackgroundVisible(decorationBackgroundVisible);
setDecorationBordersVisible(decorationBordersVisible);
}
}
}
|
java
|
public void updateUI() {
super.updateUI();
setFont(Font.decode("Dialog Plain 11"));
if (weekPanel != null) {
weekPanel.updateUI();
}
if (initialized) {
if ("Windows".equals(UIManager.getLookAndFeel().getID())) {
setDayBordersVisible(false);
setDecorationBackgroundVisible(true);
setDecorationBordersVisible(false);
} else {
setDayBordersVisible(true);
setDecorationBackgroundVisible(decorationBackgroundVisible);
setDecorationBordersVisible(decorationBordersVisible);
}
}
}
|
[
"public",
"void",
"updateUI",
"(",
")",
"{",
"super",
".",
"updateUI",
"(",
")",
";",
"setFont",
"(",
"Font",
".",
"decode",
"(",
"\"Dialog Plain 11\"",
")",
")",
";",
"if",
"(",
"weekPanel",
"!=",
"null",
")",
"{",
"weekPanel",
".",
"updateUI",
"(",
")",
";",
"}",
"if",
"(",
"initialized",
")",
"{",
"if",
"(",
"\"Windows\"",
".",
"equals",
"(",
"UIManager",
".",
"getLookAndFeel",
"(",
")",
".",
"getID",
"(",
")",
")",
")",
"{",
"setDayBordersVisible",
"(",
"false",
")",
";",
"setDecorationBackgroundVisible",
"(",
"true",
")",
";",
"setDecorationBordersVisible",
"(",
"false",
")",
";",
"}",
"else",
"{",
"setDayBordersVisible",
"(",
"true",
")",
";",
"setDecorationBackgroundVisible",
"(",
"decorationBackgroundVisible",
")",
";",
"setDecorationBordersVisible",
"(",
"decorationBordersVisible",
")",
";",
"}",
"}",
"}"
] |
Updates the UI and sets the day button preferences.
|
[
"Updates",
"the",
"UI",
"and",
"sets",
"the",
"day",
"button",
"preferences",
"."
] |
442e5bc319d92dee93400e6180ca74a5b6bd7775
|
https://github.com/luuuis/jcalendar/blob/442e5bc319d92dee93400e6180ca74a5b6bd7775/src/main/java/com/toedter/calendar/JDayChooser.java#L871-L889
|
148,265
|
jledit/jledit
|
core/src/main/java/org/jledit/jline/InputStreamReader.java
|
InputStreamReader.close
|
@Override
public void close() throws IOException {
synchronized (lock) {
decoder = null;
if (in != null) {
in.close();
in = null;
}
}
}
|
java
|
@Override
public void close() throws IOException {
synchronized (lock) {
decoder = null;
if (in != null) {
in.close();
in = null;
}
}
}
|
[
"@",
"Override",
"public",
"void",
"close",
"(",
")",
"throws",
"IOException",
"{",
"synchronized",
"(",
"lock",
")",
"{",
"decoder",
"=",
"null",
";",
"if",
"(",
"in",
"!=",
"null",
")",
"{",
"in",
".",
"close",
"(",
")",
";",
"in",
"=",
"null",
";",
"}",
"}",
"}"
] |
Closes this reader. This implementation closes the source InputStream and
releases all local storage.
@throws java.io.IOException
if an error occurs attempting to close this reader.
|
[
"Closes",
"this",
"reader",
".",
"This",
"implementation",
"closes",
"the",
"source",
"InputStream",
"and",
"releases",
"all",
"local",
"storage",
"."
] |
ced2c4b44330664adb65f8be4c8fff780ccaa6fd
|
https://github.com/jledit/jledit/blob/ced2c4b44330664adb65f8be4c8fff780ccaa6fd/core/src/main/java/org/jledit/jline/InputStreamReader.java#L141-L150
|
148,266
|
jledit/jledit
|
core/src/main/java/org/jledit/jline/InputStreamReader.java
|
InputStreamReader.read
|
@Override
public int read() throws IOException {
synchronized (lock) {
if (!isOpen()) {
throw new IOException("InputStreamReader is closed.");
}
char buf[] = new char[1];
return read(buf, 0, 1) != -1 ? buf[0] : -1;
}
}
|
java
|
@Override
public int read() throws IOException {
synchronized (lock) {
if (!isOpen()) {
throw new IOException("InputStreamReader is closed.");
}
char buf[] = new char[1];
return read(buf, 0, 1) != -1 ? buf[0] : -1;
}
}
|
[
"@",
"Override",
"public",
"int",
"read",
"(",
")",
"throws",
"IOException",
"{",
"synchronized",
"(",
"lock",
")",
"{",
"if",
"(",
"!",
"isOpen",
"(",
")",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"InputStreamReader is closed.\"",
")",
";",
"}",
"char",
"buf",
"[",
"]",
"=",
"new",
"char",
"[",
"1",
"]",
";",
"return",
"read",
"(",
"buf",
",",
"0",
",",
"1",
")",
"!=",
"-",
"1",
"?",
"buf",
"[",
"0",
"]",
":",
"-",
"1",
";",
"}",
"}"
] |
Reads a single character from this reader and returns it as an integer
with the two higher-order bytes set to 0. Returns -1 if the end of the
reader has been reached. The byte value is either obtained from
converting bytes in this reader's buffer or by first filling the buffer
from the source InputStream and then reading from the buffer.
@return the character read or -1 if the end of the reader has been
reached.
@throws IOException
if this reader is closed or some other I/O error occurs.
|
[
"Reads",
"a",
"single",
"character",
"from",
"this",
"reader",
"and",
"returns",
"it",
"as",
"an",
"integer",
"with",
"the",
"two",
"higher",
"-",
"order",
"bytes",
"set",
"to",
"0",
".",
"Returns",
"-",
"1",
"if",
"the",
"end",
"of",
"the",
"reader",
"has",
"been",
"reached",
".",
"The",
"byte",
"value",
"is",
"either",
"obtained",
"from",
"converting",
"bytes",
"in",
"this",
"reader",
"s",
"buffer",
"or",
"by",
"first",
"filling",
"the",
"buffer",
"from",
"the",
"source",
"InputStream",
"and",
"then",
"reading",
"from",
"the",
"buffer",
"."
] |
ced2c4b44330664adb65f8be4c8fff780ccaa6fd
|
https://github.com/jledit/jledit/blob/ced2c4b44330664adb65f8be4c8fff780ccaa6fd/core/src/main/java/org/jledit/jline/InputStreamReader.java#L178-L188
|
148,267
|
OpenHFT/Stage-Compiler
|
src/main/java/net/openhft/sg/DependencyNode.java
|
DependencyNode.dependsOn
|
public boolean dependsOn(DependencyNode dependency) {
boolean dependsDirectly = dependenciesVia.contains(dependency);
if (dependsDirectly)
return true;
for (DependencyNode reqDependency : dependency.dependantsVia) {
if (dependsOn(reqDependency))
return true;
}
return false;
}
|
java
|
public boolean dependsOn(DependencyNode dependency) {
boolean dependsDirectly = dependenciesVia.contains(dependency);
if (dependsDirectly)
return true;
for (DependencyNode reqDependency : dependency.dependantsVia) {
if (dependsOn(reqDependency))
return true;
}
return false;
}
|
[
"public",
"boolean",
"dependsOn",
"(",
"DependencyNode",
"dependency",
")",
"{",
"boolean",
"dependsDirectly",
"=",
"dependenciesVia",
".",
"contains",
"(",
"dependency",
")",
";",
"if",
"(",
"dependsDirectly",
")",
"return",
"true",
";",
"for",
"(",
"DependencyNode",
"reqDependency",
":",
"dependency",
".",
"dependantsVia",
")",
"{",
"if",
"(",
"dependsOn",
"(",
"reqDependency",
")",
")",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Directly or indirectly
|
[
"Directly",
"or",
"indirectly"
] |
d5dd982a429f9f528f3d2d19e48f704aa8d796b9
|
https://github.com/OpenHFT/Stage-Compiler/blob/d5dd982a429f9f528f3d2d19e48f704aa8d796b9/src/main/java/net/openhft/sg/DependencyNode.java#L73-L82
|
148,268
|
jledit/jledit
|
core/src/main/java/org/jledit/utils/Strings.java
|
Strings.tryToTrimToSize
|
public static String tryToTrimToSize(String s, int length, boolean trimSuffix) {
if (s == null || s.isEmpty()) {
return s;
} else if (s.length() <= length) {
return s;
} else if (s.contains(File.separator)) {
String before = s.substring(0, s.lastIndexOf(File.separator));
String after = s.substring(s.lastIndexOf(File.separator));
if (!trimSuffix && length - after.length() > 4) {
return Strings.tryToTrimToSize(before, length - after.length(), true) + after;
} else {
return Strings.tryToTrimToSize(before, length - 3, true) + File.separator + "..";
}
} else {
return "..";
}
}
|
java
|
public static String tryToTrimToSize(String s, int length, boolean trimSuffix) {
if (s == null || s.isEmpty()) {
return s;
} else if (s.length() <= length) {
return s;
} else if (s.contains(File.separator)) {
String before = s.substring(0, s.lastIndexOf(File.separator));
String after = s.substring(s.lastIndexOf(File.separator));
if (!trimSuffix && length - after.length() > 4) {
return Strings.tryToTrimToSize(before, length - after.length(), true) + after;
} else {
return Strings.tryToTrimToSize(before, length - 3, true) + File.separator + "..";
}
} else {
return "..";
}
}
|
[
"public",
"static",
"String",
"tryToTrimToSize",
"(",
"String",
"s",
",",
"int",
"length",
",",
"boolean",
"trimSuffix",
")",
"{",
"if",
"(",
"s",
"==",
"null",
"||",
"s",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"s",
";",
"}",
"else",
"if",
"(",
"s",
".",
"length",
"(",
")",
"<=",
"length",
")",
"{",
"return",
"s",
";",
"}",
"else",
"if",
"(",
"s",
".",
"contains",
"(",
"File",
".",
"separator",
")",
")",
"{",
"String",
"before",
"=",
"s",
".",
"substring",
"(",
"0",
",",
"s",
".",
"lastIndexOf",
"(",
"File",
".",
"separator",
")",
")",
";",
"String",
"after",
"=",
"s",
".",
"substring",
"(",
"s",
".",
"lastIndexOf",
"(",
"File",
".",
"separator",
")",
")",
";",
"if",
"(",
"!",
"trimSuffix",
"&&",
"length",
"-",
"after",
".",
"length",
"(",
")",
">",
"4",
")",
"{",
"return",
"Strings",
".",
"tryToTrimToSize",
"(",
"before",
",",
"length",
"-",
"after",
".",
"length",
"(",
")",
",",
"true",
")",
"+",
"after",
";",
"}",
"else",
"{",
"return",
"Strings",
".",
"tryToTrimToSize",
"(",
"before",
",",
"length",
"-",
"3",
",",
"true",
")",
"+",
"File",
".",
"separator",
"+",
"\"..\"",
";",
"}",
"}",
"else",
"{",
"return",
"\"..\"",
";",
"}",
"}"
] |
Try to trim a String to the given size.
@param s The String to trim.
@param length The trim length.
@param trimSuffix Flag the specifies if trimming should be applied to the suffix of the String.
@return
|
[
"Try",
"to",
"trim",
"a",
"String",
"to",
"the",
"given",
"size",
"."
] |
ced2c4b44330664adb65f8be4c8fff780ccaa6fd
|
https://github.com/jledit/jledit/blob/ced2c4b44330664adb65f8be4c8fff780ccaa6fd/core/src/main/java/org/jledit/utils/Strings.java#L44-L60
|
148,269
|
chocotan/datepicker4j
|
src/main/java/io/loli/datepicker/DatePicker.java
|
DatePicker.getShowYear
|
public int getShowYear() {
Calendar cal = Calendar.getInstance();
cal.setTime(getDate());
return cal.get(Calendar.YEAR);
}
|
java
|
public int getShowYear() {
Calendar cal = Calendar.getInstance();
cal.setTime(getDate());
return cal.get(Calendar.YEAR);
}
|
[
"public",
"int",
"getShowYear",
"(",
")",
"{",
"Calendar",
"cal",
"=",
"Calendar",
".",
"getInstance",
"(",
")",
";",
"cal",
".",
"setTime",
"(",
"getDate",
"(",
")",
")",
";",
"return",
"cal",
".",
"get",
"(",
"Calendar",
".",
"YEAR",
")",
";",
"}"
] |
Get year val from text field
@return year val
|
[
"Get",
"year",
"val",
"from",
"text",
"field"
] |
d65d7a6b29f9efe77aeec2024dc31a38a7852676
|
https://github.com/chocotan/datepicker4j/blob/d65d7a6b29f9efe77aeec2024dc31a38a7852676/src/main/java/io/loli/datepicker/DatePicker.java#L82-L86
|
148,270
|
chocotan/datepicker4j
|
src/main/java/io/loli/datepicker/DatePicker.java
|
DatePicker.getShowMonth
|
public int getShowMonth() {
Calendar cal = Calendar.getInstance();
cal.setTime(getDate());
return cal.get(Calendar.MONDAY);
}
|
java
|
public int getShowMonth() {
Calendar cal = Calendar.getInstance();
cal.setTime(getDate());
return cal.get(Calendar.MONDAY);
}
|
[
"public",
"int",
"getShowMonth",
"(",
")",
"{",
"Calendar",
"cal",
"=",
"Calendar",
".",
"getInstance",
"(",
")",
";",
"cal",
".",
"setTime",
"(",
"getDate",
"(",
")",
")",
";",
"return",
"cal",
".",
"get",
"(",
"Calendar",
".",
"MONDAY",
")",
";",
"}"
] |
Get month val from text field
@return month val
|
[
"Get",
"month",
"val",
"from",
"text",
"field"
] |
d65d7a6b29f9efe77aeec2024dc31a38a7852676
|
https://github.com/chocotan/datepicker4j/blob/d65d7a6b29f9efe77aeec2024dc31a38a7852676/src/main/java/io/loli/datepicker/DatePicker.java#L93-L97
|
148,271
|
chocotan/datepicker4j
|
src/main/java/io/loli/datepicker/DatePicker.java
|
DatePicker.selectDay
|
void selectDay(int year, int month, int day) {
Calendar cal = Calendar.getInstance();
cal.set(year, month, day);
Date date = cal.getTime();
this.field.setText(simpleDateFormat.format(date));
if (popup != null) {
popup.hide();
popup = null;
}
}
|
java
|
void selectDay(int year, int month, int day) {
Calendar cal = Calendar.getInstance();
cal.set(year, month, day);
Date date = cal.getTime();
this.field.setText(simpleDateFormat.format(date));
if (popup != null) {
popup.hide();
popup = null;
}
}
|
[
"void",
"selectDay",
"(",
"int",
"year",
",",
"int",
"month",
",",
"int",
"day",
")",
"{",
"Calendar",
"cal",
"=",
"Calendar",
".",
"getInstance",
"(",
")",
";",
"cal",
".",
"set",
"(",
"year",
",",
"month",
",",
"day",
")",
";",
"Date",
"date",
"=",
"cal",
".",
"getTime",
"(",
")",
";",
"this",
".",
"field",
".",
"setText",
"(",
"simpleDateFormat",
".",
"format",
"(",
"date",
")",
")",
";",
"if",
"(",
"popup",
"!=",
"null",
")",
"{",
"popup",
".",
"hide",
"(",
")",
";",
"popup",
"=",
"null",
";",
"}",
"}"
] |
Set date to text field
@param year
year to set
@param month
month to set
@param day
day to set
|
[
"Set",
"date",
"to",
"text",
"field"
] |
d65d7a6b29f9efe77aeec2024dc31a38a7852676
|
https://github.com/chocotan/datepicker4j/blob/d65d7a6b29f9efe77aeec2024dc31a38a7852676/src/main/java/io/loli/datepicker/DatePicker.java#L109-L118
|
148,272
|
chocotan/datepicker4j
|
src/main/java/io/loli/datepicker/DatePicker.java
|
DatePicker.datePicker
|
public static void datePicker(JTextField field, String format,
DateFilter filter) {
new DatePicker(field, format, filter);
}
|
java
|
public static void datePicker(JTextField field, String format,
DateFilter filter) {
new DatePicker(field, format, filter);
}
|
[
"public",
"static",
"void",
"datePicker",
"(",
"JTextField",
"field",
",",
"String",
"format",
",",
"DateFilter",
"filter",
")",
"{",
"new",
"DatePicker",
"(",
"field",
",",
"format",
",",
"filter",
")",
";",
"}"
] |
Add a date picker to a text field with date format
@param field
the text field you want to add to
@param format
date format string
@param filter
filter
|
[
"Add",
"a",
"date",
"picker",
"to",
"a",
"text",
"field",
"with",
"date",
"format"
] |
d65d7a6b29f9efe77aeec2024dc31a38a7852676
|
https://github.com/chocotan/datepicker4j/blob/d65d7a6b29f9efe77aeec2024dc31a38a7852676/src/main/java/io/loli/datepicker/DatePicker.java#L152-L155
|
148,273
|
chocotan/datepicker4j
|
src/main/java/io/loli/datepicker/DatePicker.java
|
DatePicker.dateTimePicker
|
public static void dateTimePicker(JTextField field, String format,
DateFilter filter) {
new DateTimePicker(field, format, filter);
}
|
java
|
public static void dateTimePicker(JTextField field, String format,
DateFilter filter) {
new DateTimePicker(field, format, filter);
}
|
[
"public",
"static",
"void",
"dateTimePicker",
"(",
"JTextField",
"field",
",",
"String",
"format",
",",
"DateFilter",
"filter",
")",
"{",
"new",
"DateTimePicker",
"(",
"field",
",",
"format",
",",
"filter",
")",
";",
"}"
] |
Add a time picker to a text field with time format
@param field
the text field you want to add to
@param format
time format string
@param filter
to make some days unclickable
|
[
"Add",
"a",
"time",
"picker",
"to",
"a",
"text",
"field",
"with",
"time",
"format"
] |
d65d7a6b29f9efe77aeec2024dc31a38a7852676
|
https://github.com/chocotan/datepicker4j/blob/d65d7a6b29f9efe77aeec2024dc31a38a7852676/src/main/java/io/loli/datepicker/DatePicker.java#L211-L214
|
148,274
|
lecousin/java-compression
|
lzma/src/main/java/net/lecousin/compression/lzma/LZEncoder.java
|
LZEncoder.fillWindow
|
public int fillWindow(ByteBuffer buffer) {
assert !finishing;
// Move the sliding window if needed.
if (readPos >= bufSize - keepSizeAfter)
moveWindow();
// Try to fill the dictionary buffer. If it becomes full,
// some of the input bytes may be left unused.
int len = buffer.remaining();
if (len > bufSize - writePos)
len = bufSize - writePos;
buffer.get(buf, writePos, len);
writePos += len;
// Set the new readLimit but only if there's enough data to allow
// encoding of at least one more byte.
if (writePos >= keepSizeAfter)
readLimit = writePos - keepSizeAfter;
processPendingBytes();
// Tell the caller how much input we actually copied into
// the dictionary.
return len;
}
|
java
|
public int fillWindow(ByteBuffer buffer) {
assert !finishing;
// Move the sliding window if needed.
if (readPos >= bufSize - keepSizeAfter)
moveWindow();
// Try to fill the dictionary buffer. If it becomes full,
// some of the input bytes may be left unused.
int len = buffer.remaining();
if (len > bufSize - writePos)
len = bufSize - writePos;
buffer.get(buf, writePos, len);
writePos += len;
// Set the new readLimit but only if there's enough data to allow
// encoding of at least one more byte.
if (writePos >= keepSizeAfter)
readLimit = writePos - keepSizeAfter;
processPendingBytes();
// Tell the caller how much input we actually copied into
// the dictionary.
return len;
}
|
[
"public",
"int",
"fillWindow",
"(",
"ByteBuffer",
"buffer",
")",
"{",
"assert",
"!",
"finishing",
";",
"// Move the sliding window if needed.",
"if",
"(",
"readPos",
">=",
"bufSize",
"-",
"keepSizeAfter",
")",
"moveWindow",
"(",
")",
";",
"// Try to fill the dictionary buffer. If it becomes full,",
"// some of the input bytes may be left unused.",
"int",
"len",
"=",
"buffer",
".",
"remaining",
"(",
")",
";",
"if",
"(",
"len",
">",
"bufSize",
"-",
"writePos",
")",
"len",
"=",
"bufSize",
"-",
"writePos",
";",
"buffer",
".",
"get",
"(",
"buf",
",",
"writePos",
",",
"len",
")",
";",
"writePos",
"+=",
"len",
";",
"// Set the new readLimit but only if there's enough data to allow",
"// encoding of at least one more byte.",
"if",
"(",
"writePos",
">=",
"keepSizeAfter",
")",
"readLimit",
"=",
"writePos",
"-",
"keepSizeAfter",
";",
"processPendingBytes",
"(",
")",
";",
"// Tell the caller how much input we actually copied into",
"// the dictionary.",
"return",
"len",
";",
"}"
] |
Copies new data into the LZEncoder's buffer.
|
[
"Copies",
"new",
"data",
"into",
"the",
"LZEncoder",
"s",
"buffer",
"."
] |
19c8001fb3655817a52a3b8ab69501e3df7a2b4a
|
https://github.com/lecousin/java-compression/blob/19c8001fb3655817a52a3b8ab69501e3df7a2b4a/lzma/src/main/java/net/lecousin/compression/lzma/LZEncoder.java#L191-L217
|
148,275
|
groundupworks/wings
|
wings-facebook/src/main/java/com/groundupworks/wings/facebook/FacebookPrivacyDialogFragment.java
|
FacebookPrivacyDialogFragment.handlePhotoPrivacySelection
|
private void handlePhotoPrivacySelection(int photoPrivacyIndex, String albumName, String albumGraphPath) {
FacebookSettingsActivity activity = (FacebookSettingsActivity) getActivity();
if (activity != null && !activity.isFinishing()) {
// Convert privacy index to privacy setting to store.
String[] privacyArray = getResources().getStringArray(R.array.wings_facebook_privacy__privacies);
String privacyString = privacyArray[photoPrivacyIndex];
String photoPrivacy = null;
if (getString(R.string.wings_facebook__privacy__photo_privacy_self).equals(privacyString)) {
photoPrivacy = FacebookEndpoint.PHOTO_PRIVACY_SELF;
} else if (getString(R.string.wings_facebook__privacy__photo_privacy_friends).equals(privacyString)) {
photoPrivacy = FacebookEndpoint.PHOTO_PRIVACY_FRIENDS;
} else if (getString(R.string.wings_facebook__privacy__photo_privacy_friends_of_friends).equals(privacyString)) {
photoPrivacy = FacebookEndpoint.PHOTO_PRIVACY_FRIENDS_OF_FRIENDS;
} else if (getString(R.string.wings_facebook__privacy__photo_privacy_everyone).equals(privacyString)) {
photoPrivacy = FacebookEndpoint.PHOTO_PRIVACY_EVERYONE;
}
// Set Facebook settings.
if (photoPrivacy != null && photoPrivacy.length() > 0 && albumName != null && albumName.length() > 0
&& albumGraphPath != null && albumGraphPath.length() > 0) {
activity.mDestinationId = FacebookEndpoint.DestinationId.PROFILE;
activity.mPhotoPrivacy = photoPrivacy;
activity.mAlbumName = albumName;
activity.mAlbumGraphPath = albumGraphPath;
} else {
activity.mHasErrorOccurred = true;
}
// Finish activity.
activity.tryFinish();
}
}
|
java
|
private void handlePhotoPrivacySelection(int photoPrivacyIndex, String albumName, String albumGraphPath) {
FacebookSettingsActivity activity = (FacebookSettingsActivity) getActivity();
if (activity != null && !activity.isFinishing()) {
// Convert privacy index to privacy setting to store.
String[] privacyArray = getResources().getStringArray(R.array.wings_facebook_privacy__privacies);
String privacyString = privacyArray[photoPrivacyIndex];
String photoPrivacy = null;
if (getString(R.string.wings_facebook__privacy__photo_privacy_self).equals(privacyString)) {
photoPrivacy = FacebookEndpoint.PHOTO_PRIVACY_SELF;
} else if (getString(R.string.wings_facebook__privacy__photo_privacy_friends).equals(privacyString)) {
photoPrivacy = FacebookEndpoint.PHOTO_PRIVACY_FRIENDS;
} else if (getString(R.string.wings_facebook__privacy__photo_privacy_friends_of_friends).equals(privacyString)) {
photoPrivacy = FacebookEndpoint.PHOTO_PRIVACY_FRIENDS_OF_FRIENDS;
} else if (getString(R.string.wings_facebook__privacy__photo_privacy_everyone).equals(privacyString)) {
photoPrivacy = FacebookEndpoint.PHOTO_PRIVACY_EVERYONE;
}
// Set Facebook settings.
if (photoPrivacy != null && photoPrivacy.length() > 0 && albumName != null && albumName.length() > 0
&& albumGraphPath != null && albumGraphPath.length() > 0) {
activity.mDestinationId = FacebookEndpoint.DestinationId.PROFILE;
activity.mPhotoPrivacy = photoPrivacy;
activity.mAlbumName = albumName;
activity.mAlbumGraphPath = albumGraphPath;
} else {
activity.mHasErrorOccurred = true;
}
// Finish activity.
activity.tryFinish();
}
}
|
[
"private",
"void",
"handlePhotoPrivacySelection",
"(",
"int",
"photoPrivacyIndex",
",",
"String",
"albumName",
",",
"String",
"albumGraphPath",
")",
"{",
"FacebookSettingsActivity",
"activity",
"=",
"(",
"FacebookSettingsActivity",
")",
"getActivity",
"(",
")",
";",
"if",
"(",
"activity",
"!=",
"null",
"&&",
"!",
"activity",
".",
"isFinishing",
"(",
")",
")",
"{",
"// Convert privacy index to privacy setting to store.",
"String",
"[",
"]",
"privacyArray",
"=",
"getResources",
"(",
")",
".",
"getStringArray",
"(",
"R",
".",
"array",
".",
"wings_facebook_privacy__privacies",
")",
";",
"String",
"privacyString",
"=",
"privacyArray",
"[",
"photoPrivacyIndex",
"]",
";",
"String",
"photoPrivacy",
"=",
"null",
";",
"if",
"(",
"getString",
"(",
"R",
".",
"string",
".",
"wings_facebook__privacy__photo_privacy_self",
")",
".",
"equals",
"(",
"privacyString",
")",
")",
"{",
"photoPrivacy",
"=",
"FacebookEndpoint",
".",
"PHOTO_PRIVACY_SELF",
";",
"}",
"else",
"if",
"(",
"getString",
"(",
"R",
".",
"string",
".",
"wings_facebook__privacy__photo_privacy_friends",
")",
".",
"equals",
"(",
"privacyString",
")",
")",
"{",
"photoPrivacy",
"=",
"FacebookEndpoint",
".",
"PHOTO_PRIVACY_FRIENDS",
";",
"}",
"else",
"if",
"(",
"getString",
"(",
"R",
".",
"string",
".",
"wings_facebook__privacy__photo_privacy_friends_of_friends",
")",
".",
"equals",
"(",
"privacyString",
")",
")",
"{",
"photoPrivacy",
"=",
"FacebookEndpoint",
".",
"PHOTO_PRIVACY_FRIENDS_OF_FRIENDS",
";",
"}",
"else",
"if",
"(",
"getString",
"(",
"R",
".",
"string",
".",
"wings_facebook__privacy__photo_privacy_everyone",
")",
".",
"equals",
"(",
"privacyString",
")",
")",
"{",
"photoPrivacy",
"=",
"FacebookEndpoint",
".",
"PHOTO_PRIVACY_EVERYONE",
";",
"}",
"// Set Facebook settings.",
"if",
"(",
"photoPrivacy",
"!=",
"null",
"&&",
"photoPrivacy",
".",
"length",
"(",
")",
">",
"0",
"&&",
"albumName",
"!=",
"null",
"&&",
"albumName",
".",
"length",
"(",
")",
">",
"0",
"&&",
"albumGraphPath",
"!=",
"null",
"&&",
"albumGraphPath",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"activity",
".",
"mDestinationId",
"=",
"FacebookEndpoint",
".",
"DestinationId",
".",
"PROFILE",
";",
"activity",
".",
"mPhotoPrivacy",
"=",
"photoPrivacy",
";",
"activity",
".",
"mAlbumName",
"=",
"albumName",
";",
"activity",
".",
"mAlbumGraphPath",
"=",
"albumGraphPath",
";",
"}",
"else",
"{",
"activity",
".",
"mHasErrorOccurred",
"=",
"true",
";",
"}",
"// Finish activity.",
"activity",
".",
"tryFinish",
"(",
")",
";",
"}",
"}"
] |
Handles the photo privacy selection.
@param photoPrivacyIndex the index of the selected photo privacy level.
@param albumName the name of the album to share to.
@param albumGraphPath the graph path of the album to share to.
|
[
"Handles",
"the",
"photo",
"privacy",
"selection",
"."
] |
03d2827c30ef55f2db4e23f7500e016c7771fa39
|
https://github.com/groundupworks/wings/blob/03d2827c30ef55f2db4e23f7500e016c7771fa39/wings-facebook/src/main/java/com/groundupworks/wings/facebook/FacebookPrivacyDialogFragment.java#L79-L111
|
148,276
|
encircled/Joiner
|
joiner-core/src/main/java/cz/encircled/joiner/core/Joiner.java
|
Joiner.applyPredicates
|
private <T, R> void applyPredicates(JoinerQuery<T, R> request, JPAQuery query, Set<Path<?>> usedAliases, List<JoinDescription> joins) {
if (request.getWhere() != null) {
Predicate where = predicateAliasResolver.resolvePredicate(request.getWhere(), joins, usedAliases);
checkAliasesArePresent(where, usedAliases);
query.where(where);
}
if (request.getGroupBy() != null) {
Map<AnnotatedElement, List<JoinDescription>> grouped = joins.stream()
.collect(Collectors.groupingBy(j -> j.getOriginalAlias().getAnnotatedElement()));
Path<?> grouping = predicateAliasResolver.resolvePath(request.getGroupBy(), grouped, usedAliases);
checkAliasesArePresent(grouping, usedAliases);
query.groupBy(grouping);
}
if (request.getHaving() != null) {
Predicate having = predicateAliasResolver.resolvePredicate(request.getHaving(), joins, usedAliases);
checkAliasesArePresent(having, usedAliases);
query.having(having);
}
}
|
java
|
private <T, R> void applyPredicates(JoinerQuery<T, R> request, JPAQuery query, Set<Path<?>> usedAliases, List<JoinDescription> joins) {
if (request.getWhere() != null) {
Predicate where = predicateAliasResolver.resolvePredicate(request.getWhere(), joins, usedAliases);
checkAliasesArePresent(where, usedAliases);
query.where(where);
}
if (request.getGroupBy() != null) {
Map<AnnotatedElement, List<JoinDescription>> grouped = joins.stream()
.collect(Collectors.groupingBy(j -> j.getOriginalAlias().getAnnotatedElement()));
Path<?> grouping = predicateAliasResolver.resolvePath(request.getGroupBy(), grouped, usedAliases);
checkAliasesArePresent(grouping, usedAliases);
query.groupBy(grouping);
}
if (request.getHaving() != null) {
Predicate having = predicateAliasResolver.resolvePredicate(request.getHaving(), joins, usedAliases);
checkAliasesArePresent(having, usedAliases);
query.having(having);
}
}
|
[
"private",
"<",
"T",
",",
"R",
">",
"void",
"applyPredicates",
"(",
"JoinerQuery",
"<",
"T",
",",
"R",
">",
"request",
",",
"JPAQuery",
"query",
",",
"Set",
"<",
"Path",
"<",
"?",
">",
">",
"usedAliases",
",",
"List",
"<",
"JoinDescription",
">",
"joins",
")",
"{",
"if",
"(",
"request",
".",
"getWhere",
"(",
")",
"!=",
"null",
")",
"{",
"Predicate",
"where",
"=",
"predicateAliasResolver",
".",
"resolvePredicate",
"(",
"request",
".",
"getWhere",
"(",
")",
",",
"joins",
",",
"usedAliases",
")",
";",
"checkAliasesArePresent",
"(",
"where",
",",
"usedAliases",
")",
";",
"query",
".",
"where",
"(",
"where",
")",
";",
"}",
"if",
"(",
"request",
".",
"getGroupBy",
"(",
")",
"!=",
"null",
")",
"{",
"Map",
"<",
"AnnotatedElement",
",",
"List",
"<",
"JoinDescription",
">",
">",
"grouped",
"=",
"joins",
".",
"stream",
"(",
")",
".",
"collect",
"(",
"Collectors",
".",
"groupingBy",
"(",
"j",
"->",
"j",
".",
"getOriginalAlias",
"(",
")",
".",
"getAnnotatedElement",
"(",
")",
")",
")",
";",
"Path",
"<",
"?",
">",
"grouping",
"=",
"predicateAliasResolver",
".",
"resolvePath",
"(",
"request",
".",
"getGroupBy",
"(",
")",
",",
"grouped",
",",
"usedAliases",
")",
";",
"checkAliasesArePresent",
"(",
"grouping",
",",
"usedAliases",
")",
";",
"query",
".",
"groupBy",
"(",
"grouping",
")",
";",
"}",
"if",
"(",
"request",
".",
"getHaving",
"(",
")",
"!=",
"null",
")",
"{",
"Predicate",
"having",
"=",
"predicateAliasResolver",
".",
"resolvePredicate",
"(",
"request",
".",
"getHaving",
"(",
")",
",",
"joins",
",",
"usedAliases",
")",
";",
"checkAliasesArePresent",
"(",
"having",
",",
"usedAliases",
")",
";",
"query",
".",
"having",
"(",
"having",
")",
";",
"}",
"}"
] |
Apply "where", "groupBy" and "having"
@param request
@param query
@param usedAliases
@param joins
@param <T>
@param <R>
|
[
"Apply",
"where",
"groupBy",
"and",
"having"
] |
7b9117db05d8b89feeeb9ef7ce944256330d405c
|
https://github.com/encircled/Joiner/blob/7b9117db05d8b89feeeb9ef7ce944256330d405c/joiner-core/src/main/java/cz/encircled/joiner/core/Joiner.java#L164-L182
|
148,277
|
scaleset/scaleset-geo
|
src/main/java/com/scaleset/geo/math/GoogleMapsTileMath.java
|
GoogleMapsTileMath.metersToTilePixelsTransform
|
public AffineTransform metersToTilePixelsTransform(int tx, int ty, int zoomLevel) {
AffineTransform result = new AffineTransform();
double scale = 1.0 / resolution(zoomLevel);
int nTiles = 2 << (zoomLevel - 1);
int px = tx * -256;
int py = (nTiles - ty) * -256;
// flip y for upper-left origin
result.scale(1, -1);
result.translate(px, py);
result.scale(scale, scale);
result.translate(originShift, originShift);
return result;
}
|
java
|
public AffineTransform metersToTilePixelsTransform(int tx, int ty, int zoomLevel) {
AffineTransform result = new AffineTransform();
double scale = 1.0 / resolution(zoomLevel);
int nTiles = 2 << (zoomLevel - 1);
int px = tx * -256;
int py = (nTiles - ty) * -256;
// flip y for upper-left origin
result.scale(1, -1);
result.translate(px, py);
result.scale(scale, scale);
result.translate(originShift, originShift);
return result;
}
|
[
"public",
"AffineTransform",
"metersToTilePixelsTransform",
"(",
"int",
"tx",
",",
"int",
"ty",
",",
"int",
"zoomLevel",
")",
"{",
"AffineTransform",
"result",
"=",
"new",
"AffineTransform",
"(",
")",
";",
"double",
"scale",
"=",
"1.0",
"/",
"resolution",
"(",
"zoomLevel",
")",
";",
"int",
"nTiles",
"=",
"2",
"<<",
"(",
"zoomLevel",
"-",
"1",
")",
";",
"int",
"px",
"=",
"tx",
"*",
"-",
"256",
";",
"int",
"py",
"=",
"(",
"nTiles",
"-",
"ty",
")",
"*",
"-",
"256",
";",
"// flip y for upper-left origin",
"result",
".",
"scale",
"(",
"1",
",",
"-",
"1",
")",
";",
"result",
".",
"translate",
"(",
"px",
",",
"py",
")",
";",
"result",
".",
"scale",
"(",
"scale",
",",
"scale",
")",
";",
"result",
".",
"translate",
"(",
"originShift",
",",
"originShift",
")",
";",
"return",
"result",
";",
"}"
] |
Create a transform that converts meters to tile-relative pixels
@param tx The x coordinate of the tile
@param ty The y coordinate of the tile
@param zoomLevel the zoom level
@return AffineTransform with meters to pixels transformation
|
[
"Create",
"a",
"transform",
"that",
"converts",
"meters",
"to",
"tile",
"-",
"relative",
"pixels"
] |
5cff2349668037dc287928a6c1a1f67c76d96b02
|
https://github.com/scaleset/scaleset-geo/blob/5cff2349668037dc287928a6c1a1f67c76d96b02/src/main/java/com/scaleset/geo/math/GoogleMapsTileMath.java#L216-L228
|
148,278
|
scaleset/scaleset-geo
|
src/main/java/com/scaleset/geo/math/GoogleMapsTileMath.java
|
GoogleMapsTileMath.metersToTile
|
public Coordinate metersToTile(Coordinate coord, int zoomLevel) {
Coordinate pixels = metersToPixels(coord.x, coord.y, zoomLevel);
int tx = (int) pixels.x / 256;
int ty = (int) pixels.y / 256;
return new Coordinate(tx, ty, zoomLevel);
}
|
java
|
public Coordinate metersToTile(Coordinate coord, int zoomLevel) {
Coordinate pixels = metersToPixels(coord.x, coord.y, zoomLevel);
int tx = (int) pixels.x / 256;
int ty = (int) pixels.y / 256;
return new Coordinate(tx, ty, zoomLevel);
}
|
[
"public",
"Coordinate",
"metersToTile",
"(",
"Coordinate",
"coord",
",",
"int",
"zoomLevel",
")",
"{",
"Coordinate",
"pixels",
"=",
"metersToPixels",
"(",
"coord",
".",
"x",
",",
"coord",
".",
"y",
",",
"zoomLevel",
")",
";",
"int",
"tx",
"=",
"(",
"int",
")",
"pixels",
".",
"x",
"/",
"256",
";",
"int",
"ty",
"=",
"(",
"int",
")",
"pixels",
".",
"y",
"/",
"256",
";",
"return",
"new",
"Coordinate",
"(",
"tx",
",",
"ty",
",",
"zoomLevel",
")",
";",
"}"
] |
Returns the tile coordinate of the meters coordinate
|
[
"Returns",
"the",
"tile",
"coordinate",
"of",
"the",
"meters",
"coordinate"
] |
5cff2349668037dc287928a6c1a1f67c76d96b02
|
https://github.com/scaleset/scaleset-geo/blob/5cff2349668037dc287928a6c1a1f67c76d96b02/src/main/java/com/scaleset/geo/math/GoogleMapsTileMath.java#L234-L239
|
148,279
|
scaleset/scaleset-geo
|
src/main/java/com/scaleset/geo/math/GoogleMapsTileMath.java
|
GoogleMapsTileMath.tileTopLeft
|
public Coordinate tileTopLeft(int tx, int ty, int zoomLevel) {
int px = tx * tileSize;
int py = ty * tileSize;
Coordinate result = pixelsToMeters(px, py, zoomLevel);
return result;
}
|
java
|
public Coordinate tileTopLeft(int tx, int ty, int zoomLevel) {
int px = tx * tileSize;
int py = ty * tileSize;
Coordinate result = pixelsToMeters(px, py, zoomLevel);
return result;
}
|
[
"public",
"Coordinate",
"tileTopLeft",
"(",
"int",
"tx",
",",
"int",
"ty",
",",
"int",
"zoomLevel",
")",
"{",
"int",
"px",
"=",
"tx",
"*",
"tileSize",
";",
"int",
"py",
"=",
"ty",
"*",
"tileSize",
";",
"Coordinate",
"result",
"=",
"pixelsToMeters",
"(",
"px",
",",
"py",
",",
"zoomLevel",
")",
";",
"return",
"result",
";",
"}"
] |
Returns the top-left corner of the specific tile coordinate
@param tx The tile x coordinate
@param ty The tile y coordinate
@param zoomLevel The tile zoom level
@return The EPSG:3857 coordinate of the top-left corner
|
[
"Returns",
"the",
"top",
"-",
"left",
"corner",
"of",
"the",
"specific",
"tile",
"coordinate"
] |
5cff2349668037dc287928a6c1a1f67c76d96b02
|
https://github.com/scaleset/scaleset-geo/blob/5cff2349668037dc287928a6c1a1f67c76d96b02/src/main/java/com/scaleset/geo/math/GoogleMapsTileMath.java#L316-L321
|
148,280
|
diirt/util
|
src/main/java/org/epics/util/time/TimeParser.java
|
TimeParser.getTimeStamp
|
public static Timestamp getTimeStamp(String time) {
if (time.equalsIgnoreCase("now")) {
return Timestamp.now();
} else {
int quantity = 0;
String unit = "";
Pattern lastNUnitsPattern = Pattern
.compile(
"last\\s*(\\d*)\\s*(min|mins|hour|hours|day|days|week|weeks).*",
Pattern.CASE_INSENSITIVE);
Matcher lastNUnitsMatcher = lastNUnitsPattern.matcher(time);
while (lastNUnitsMatcher.find()) {
quantity = "".equals(lastNUnitsMatcher.group(1)) ? 1 : Integer
.valueOf(lastNUnitsMatcher.group(1));
unit = lastNUnitsMatcher.group(2).toLowerCase();
switch (unit) {
case "min":
case "mins":
return Timestamp.now().minus(
TimeDuration.ofMinutes(quantity));
case "hour":
case "hours":
return Timestamp.now()
.minus(TimeDuration.ofHours(quantity));
case "day":
case "days":
return Timestamp.now().minus(
TimeDuration.ofHours(quantity * 24));
case "week":
case "weeks":
return Timestamp.now().minus(
TimeDuration.ofHours(quantity * 24 * 7));
default:
break;
}
}
Pattern nUnitsAgoPattern = Pattern
.compile(
"(\\d*)\\s*(min|mins|hour|hours|day|days|week|weeks)\\s*ago",
Pattern.CASE_INSENSITIVE);
Matcher nUnitsAgoMatcher = nUnitsAgoPattern.matcher(time);
while (nUnitsAgoMatcher.find()) {
quantity = "".equals(nUnitsAgoMatcher.group(1)) ? 1 : Integer
.valueOf(nUnitsAgoMatcher.group(1));
unit = nUnitsAgoMatcher.group(2).toLowerCase();
switch (unit) {
case "min":
case "mins":
return Timestamp.now().minus(
TimeDuration.ofMinutes(quantity));
case "hour":
case "hours":
return Timestamp.now()
.minus(TimeDuration.ofHours(quantity));
case "day":
case "days":
return Timestamp.now().minus(
TimeDuration.ofHours(quantity * 24));
case "week":
case "weeks":
return Timestamp.now().minus(
TimeDuration.ofHours(quantity * 24 * 7));
default:
break;
}
}
TimestampFormat format = new TimestampFormat(
"yyyy-MM-dd'T'HH:mm:ss");
try {
return format.parse(time);
} catch (ParseException e) {
return null;
}
}
}
|
java
|
public static Timestamp getTimeStamp(String time) {
if (time.equalsIgnoreCase("now")) {
return Timestamp.now();
} else {
int quantity = 0;
String unit = "";
Pattern lastNUnitsPattern = Pattern
.compile(
"last\\s*(\\d*)\\s*(min|mins|hour|hours|day|days|week|weeks).*",
Pattern.CASE_INSENSITIVE);
Matcher lastNUnitsMatcher = lastNUnitsPattern.matcher(time);
while (lastNUnitsMatcher.find()) {
quantity = "".equals(lastNUnitsMatcher.group(1)) ? 1 : Integer
.valueOf(lastNUnitsMatcher.group(1));
unit = lastNUnitsMatcher.group(2).toLowerCase();
switch (unit) {
case "min":
case "mins":
return Timestamp.now().minus(
TimeDuration.ofMinutes(quantity));
case "hour":
case "hours":
return Timestamp.now()
.minus(TimeDuration.ofHours(quantity));
case "day":
case "days":
return Timestamp.now().minus(
TimeDuration.ofHours(quantity * 24));
case "week":
case "weeks":
return Timestamp.now().minus(
TimeDuration.ofHours(quantity * 24 * 7));
default:
break;
}
}
Pattern nUnitsAgoPattern = Pattern
.compile(
"(\\d*)\\s*(min|mins|hour|hours|day|days|week|weeks)\\s*ago",
Pattern.CASE_INSENSITIVE);
Matcher nUnitsAgoMatcher = nUnitsAgoPattern.matcher(time);
while (nUnitsAgoMatcher.find()) {
quantity = "".equals(nUnitsAgoMatcher.group(1)) ? 1 : Integer
.valueOf(nUnitsAgoMatcher.group(1));
unit = nUnitsAgoMatcher.group(2).toLowerCase();
switch (unit) {
case "min":
case "mins":
return Timestamp.now().minus(
TimeDuration.ofMinutes(quantity));
case "hour":
case "hours":
return Timestamp.now()
.minus(TimeDuration.ofHours(quantity));
case "day":
case "days":
return Timestamp.now().minus(
TimeDuration.ofHours(quantity * 24));
case "week":
case "weeks":
return Timestamp.now().minus(
TimeDuration.ofHours(quantity * 24 * 7));
default:
break;
}
}
TimestampFormat format = new TimestampFormat(
"yyyy-MM-dd'T'HH:mm:ss");
try {
return format.parse(time);
} catch (ParseException e) {
return null;
}
}
}
|
[
"public",
"static",
"Timestamp",
"getTimeStamp",
"(",
"String",
"time",
")",
"{",
"if",
"(",
"time",
".",
"equalsIgnoreCase",
"(",
"\"now\"",
")",
")",
"{",
"return",
"Timestamp",
".",
"now",
"(",
")",
";",
"}",
"else",
"{",
"int",
"quantity",
"=",
"0",
";",
"String",
"unit",
"=",
"\"\"",
";",
"Pattern",
"lastNUnitsPattern",
"=",
"Pattern",
".",
"compile",
"(",
"\"last\\\\s*(\\\\d*)\\\\s*(min|mins|hour|hours|day|days|week|weeks).*\"",
",",
"Pattern",
".",
"CASE_INSENSITIVE",
")",
";",
"Matcher",
"lastNUnitsMatcher",
"=",
"lastNUnitsPattern",
".",
"matcher",
"(",
"time",
")",
";",
"while",
"(",
"lastNUnitsMatcher",
".",
"find",
"(",
")",
")",
"{",
"quantity",
"=",
"\"\"",
".",
"equals",
"(",
"lastNUnitsMatcher",
".",
"group",
"(",
"1",
")",
")",
"?",
"1",
":",
"Integer",
".",
"valueOf",
"(",
"lastNUnitsMatcher",
".",
"group",
"(",
"1",
")",
")",
";",
"unit",
"=",
"lastNUnitsMatcher",
".",
"group",
"(",
"2",
")",
".",
"toLowerCase",
"(",
")",
";",
"switch",
"(",
"unit",
")",
"{",
"case",
"\"min\"",
":",
"case",
"\"mins\"",
":",
"return",
"Timestamp",
".",
"now",
"(",
")",
".",
"minus",
"(",
"TimeDuration",
".",
"ofMinutes",
"(",
"quantity",
")",
")",
";",
"case",
"\"hour\"",
":",
"case",
"\"hours\"",
":",
"return",
"Timestamp",
".",
"now",
"(",
")",
".",
"minus",
"(",
"TimeDuration",
".",
"ofHours",
"(",
"quantity",
")",
")",
";",
"case",
"\"day\"",
":",
"case",
"\"days\"",
":",
"return",
"Timestamp",
".",
"now",
"(",
")",
".",
"minus",
"(",
"TimeDuration",
".",
"ofHours",
"(",
"quantity",
"*",
"24",
")",
")",
";",
"case",
"\"week\"",
":",
"case",
"\"weeks\"",
":",
"return",
"Timestamp",
".",
"now",
"(",
")",
".",
"minus",
"(",
"TimeDuration",
".",
"ofHours",
"(",
"quantity",
"*",
"24",
"*",
"7",
")",
")",
";",
"default",
":",
"break",
";",
"}",
"}",
"Pattern",
"nUnitsAgoPattern",
"=",
"Pattern",
".",
"compile",
"(",
"\"(\\\\d*)\\\\s*(min|mins|hour|hours|day|days|week|weeks)\\\\s*ago\"",
",",
"Pattern",
".",
"CASE_INSENSITIVE",
")",
";",
"Matcher",
"nUnitsAgoMatcher",
"=",
"nUnitsAgoPattern",
".",
"matcher",
"(",
"time",
")",
";",
"while",
"(",
"nUnitsAgoMatcher",
".",
"find",
"(",
")",
")",
"{",
"quantity",
"=",
"\"\"",
".",
"equals",
"(",
"nUnitsAgoMatcher",
".",
"group",
"(",
"1",
")",
")",
"?",
"1",
":",
"Integer",
".",
"valueOf",
"(",
"nUnitsAgoMatcher",
".",
"group",
"(",
"1",
")",
")",
";",
"unit",
"=",
"nUnitsAgoMatcher",
".",
"group",
"(",
"2",
")",
".",
"toLowerCase",
"(",
")",
";",
"switch",
"(",
"unit",
")",
"{",
"case",
"\"min\"",
":",
"case",
"\"mins\"",
":",
"return",
"Timestamp",
".",
"now",
"(",
")",
".",
"minus",
"(",
"TimeDuration",
".",
"ofMinutes",
"(",
"quantity",
")",
")",
";",
"case",
"\"hour\"",
":",
"case",
"\"hours\"",
":",
"return",
"Timestamp",
".",
"now",
"(",
")",
".",
"minus",
"(",
"TimeDuration",
".",
"ofHours",
"(",
"quantity",
")",
")",
";",
"case",
"\"day\"",
":",
"case",
"\"days\"",
":",
"return",
"Timestamp",
".",
"now",
"(",
")",
".",
"minus",
"(",
"TimeDuration",
".",
"ofHours",
"(",
"quantity",
"*",
"24",
")",
")",
";",
"case",
"\"week\"",
":",
"case",
"\"weeks\"",
":",
"return",
"Timestamp",
".",
"now",
"(",
")",
".",
"minus",
"(",
"TimeDuration",
".",
"ofHours",
"(",
"quantity",
"*",
"24",
"*",
"7",
")",
")",
";",
"default",
":",
"break",
";",
"}",
"}",
"TimestampFormat",
"format",
"=",
"new",
"TimestampFormat",
"(",
"\"yyyy-MM-dd'T'HH:mm:ss\"",
")",
";",
"try",
"{",
"return",
"format",
".",
"parse",
"(",
"time",
")",
";",
"}",
"catch",
"(",
"ParseException",
"e",
")",
"{",
"return",
"null",
";",
"}",
"}",
"}"
] |
A Helper function to help you convert various string represented time
definition to an absolute Timestamp.
@param time a string represent the time
@return the parsed timestamp or null
|
[
"A",
"Helper",
"function",
"to",
"help",
"you",
"convert",
"various",
"string",
"represented",
"time",
"definition",
"to",
"an",
"absolute",
"Timestamp",
"."
] |
24aca0a173a635aaf0b78d213a3fee8d4f91c077
|
https://github.com/diirt/util/blob/24aca0a173a635aaf0b78d213a3fee8d4f91c077/src/main/java/org/epics/util/time/TimeParser.java#L99-L175
|
148,281
|
torakiki/sejda-io
|
src/main/java/org/sejda/io/BufferedCountingChannelWriter.java
|
BufferedCountingChannelWriter.write
|
public void write(byte[] bytes) throws IOException {
for (int i = 0; i < bytes.length; i++) {
write(bytes[i]);
}
}
|
java
|
public void write(byte[] bytes) throws IOException {
for (int i = 0; i < bytes.length; i++) {
write(bytes[i]);
}
}
|
[
"public",
"void",
"write",
"(",
"byte",
"[",
"]",
"bytes",
")",
"throws",
"IOException",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"bytes",
".",
"length",
";",
"i",
"++",
")",
"{",
"write",
"(",
"bytes",
"[",
"i",
"]",
")",
";",
"}",
"}"
] |
Writes the given bytes to the destination
@param bytes
@throws IOException
|
[
"Writes",
"the",
"given",
"bytes",
"to",
"the",
"destination"
] |
93840416c49a9c540979545c1264055406737d75
|
https://github.com/torakiki/sejda-io/blob/93840416c49a9c540979545c1264055406737d75/src/main/java/org/sejda/io/BufferedCountingChannelWriter.java#L81-L85
|
148,282
|
torakiki/sejda-io
|
src/main/java/org/sejda/io/BufferedCountingChannelWriter.java
|
BufferedCountingChannelWriter.write
|
public void write(byte myByte) throws IOException {
onNewLine = false;
buffer.put(myByte);
if (!buffer.hasRemaining()) {
flush();
}
}
|
java
|
public void write(byte myByte) throws IOException {
onNewLine = false;
buffer.put(myByte);
if (!buffer.hasRemaining()) {
flush();
}
}
|
[
"public",
"void",
"write",
"(",
"byte",
"myByte",
")",
"throws",
"IOException",
"{",
"onNewLine",
"=",
"false",
";",
"buffer",
".",
"put",
"(",
"myByte",
")",
";",
"if",
"(",
"!",
"buffer",
".",
"hasRemaining",
"(",
")",
")",
"{",
"flush",
"(",
")",
";",
"}",
"}"
] |
Writes the single byte to the destination
@param myByte
@throws IOException
|
[
"Writes",
"the",
"single",
"byte",
"to",
"the",
"destination"
] |
93840416c49a9c540979545c1264055406737d75
|
https://github.com/torakiki/sejda-io/blob/93840416c49a9c540979545c1264055406737d75/src/main/java/org/sejda/io/BufferedCountingChannelWriter.java#L93-L99
|
148,283
|
versionone/VersionOne.SDK.Java.ObjectModel
|
src/main/java/com/versionone/om/BuildRun.java
|
BuildRun.getCompletedPrimaryWorkitems
|
public Collection<PrimaryWorkitem> getCompletedPrimaryWorkitems(
PrimaryWorkitemFilter filter) {
filter = (filter != null) ? filter : new PrimaryWorkitemFilter();
filter.completedIn.clear();
filter.completedIn.add(this);
return getInstance().get().primaryWorkitems(filter);
}
|
java
|
public Collection<PrimaryWorkitem> getCompletedPrimaryWorkitems(
PrimaryWorkitemFilter filter) {
filter = (filter != null) ? filter : new PrimaryWorkitemFilter();
filter.completedIn.clear();
filter.completedIn.add(this);
return getInstance().get().primaryWorkitems(filter);
}
|
[
"public",
"Collection",
"<",
"PrimaryWorkitem",
">",
"getCompletedPrimaryWorkitems",
"(",
"PrimaryWorkitemFilter",
"filter",
")",
"{",
"filter",
"=",
"(",
"filter",
"!=",
"null",
")",
"?",
"filter",
":",
"new",
"PrimaryWorkitemFilter",
"(",
")",
";",
"filter",
".",
"completedIn",
".",
"clear",
"(",
")",
";",
"filter",
".",
"completedIn",
".",
"add",
"(",
"this",
")",
";",
"return",
"getInstance",
"(",
")",
".",
"get",
"(",
")",
".",
"primaryWorkitems",
"(",
"filter",
")",
";",
"}"
] |
Stories and Defects completed in this Build Run.
@param filter Filter for PrimaryWorkitems.
@return completed Stories and Defects completed in this Build Run.
|
[
"Stories",
"and",
"Defects",
"completed",
"in",
"this",
"Build",
"Run",
"."
] |
59d35b67c849299631bca45ee94143237eb2ae1a
|
https://github.com/versionone/VersionOne.SDK.Java.ObjectModel/blob/59d35b67c849299631bca45ee94143237eb2ae1a/src/main/java/com/versionone/om/BuildRun.java#L122-L129
|
148,284
|
versionone/VersionOne.SDK.Java.ObjectModel
|
src/main/java/com/versionone/om/BuildRun.java
|
BuildRun.getFoundDefects
|
public Collection<Defect> getFoundDefects(DefectFilter filter) {
filter = (filter != null) ? filter : new DefectFilter();
filter.foundIn.clear();
filter.foundIn.add(this);
return getInstance().get().defects(filter);
}
|
java
|
public Collection<Defect> getFoundDefects(DefectFilter filter) {
filter = (filter != null) ? filter : new DefectFilter();
filter.foundIn.clear();
filter.foundIn.add(this);
return getInstance().get().defects(filter);
}
|
[
"public",
"Collection",
"<",
"Defect",
">",
"getFoundDefects",
"(",
"DefectFilter",
"filter",
")",
"{",
"filter",
"=",
"(",
"filter",
"!=",
"null",
")",
"?",
"filter",
":",
"new",
"DefectFilter",
"(",
")",
";",
"filter",
".",
"foundIn",
".",
"clear",
"(",
")",
";",
"filter",
".",
"foundIn",
".",
"add",
"(",
"this",
")",
";",
"return",
"getInstance",
"(",
")",
".",
"get",
"(",
")",
".",
"defects",
"(",
"filter",
")",
";",
"}"
] |
Defects found in this Build Run.
@param filter Limit the defect returned (If null, then all items
returned).
@return collection of defects.
|
[
"Defects",
"found",
"in",
"this",
"Build",
"Run",
"."
] |
59d35b67c849299631bca45ee94143237eb2ae1a
|
https://github.com/versionone/VersionOne.SDK.Java.ObjectModel/blob/59d35b67c849299631bca45ee94143237eb2ae1a/src/main/java/com/versionone/om/BuildRun.java#L159-L165
|
148,285
|
jledit/jledit
|
core/src/main/java/org/jledit/command/editor/AbstractUndoableCommand.java
|
AbstractUndoableCommand.execute
|
@Override
public final void execute() {
beforeLine = editor.getLine();
beforeColumn = editor.getColumn();
doExecute();
afterLine = editor.getLine();
afterColumn = editor.getColumn();
}
|
java
|
@Override
public final void execute() {
beforeLine = editor.getLine();
beforeColumn = editor.getColumn();
doExecute();
afterLine = editor.getLine();
afterColumn = editor.getColumn();
}
|
[
"@",
"Override",
"public",
"final",
"void",
"execute",
"(",
")",
"{",
"beforeLine",
"=",
"editor",
".",
"getLine",
"(",
")",
";",
"beforeColumn",
"=",
"editor",
".",
"getColumn",
"(",
")",
";",
"doExecute",
"(",
")",
";",
"afterLine",
"=",
"editor",
".",
"getLine",
"(",
")",
";",
"afterColumn",
"=",
"editor",
".",
"getColumn",
"(",
")",
";",
"}"
] |
Stores cursor coordinates.
|
[
"Stores",
"cursor",
"coordinates",
"."
] |
ced2c4b44330664adb65f8be4c8fff780ccaa6fd
|
https://github.com/jledit/jledit/blob/ced2c4b44330664adb65f8be4c8fff780ccaa6fd/core/src/main/java/org/jledit/command/editor/AbstractUndoableCommand.java#L39-L46
|
148,286
|
luuuis/jcalendar
|
src/main/java/com/toedter/calendar/DateUtil.java
|
DateUtil.setMaxSelectableDate
|
public Date setMaxSelectableDate(Date max) {
if (max == null) {
maxSelectableDate = defaultMaxSelectableDate;
} else {
maxSelectableDate = max;
}
return maxSelectableDate;
}
|
java
|
public Date setMaxSelectableDate(Date max) {
if (max == null) {
maxSelectableDate = defaultMaxSelectableDate;
} else {
maxSelectableDate = max;
}
return maxSelectableDate;
}
|
[
"public",
"Date",
"setMaxSelectableDate",
"(",
"Date",
"max",
")",
"{",
"if",
"(",
"max",
"==",
"null",
")",
"{",
"maxSelectableDate",
"=",
"defaultMaxSelectableDate",
";",
"}",
"else",
"{",
"maxSelectableDate",
"=",
"max",
";",
"}",
"return",
"maxSelectableDate",
";",
"}"
] |
Sets the maximum selectable date. If null, the date 01\01\9999 will be set instead.
@param max the maximum selectable date
@return the maximum selectable date
|
[
"Sets",
"the",
"maximum",
"selectable",
"date",
".",
"If",
"null",
"the",
"date",
"01",
"\\",
"01",
"\\",
"9999",
"will",
"be",
"set",
"instead",
"."
] |
442e5bc319d92dee93400e6180ca74a5b6bd7775
|
https://github.com/luuuis/jcalendar/blob/442e5bc319d92dee93400e6180ca74a5b6bd7775/src/main/java/com/toedter/calendar/DateUtil.java#L88-L95
|
148,287
|
luuuis/jcalendar
|
src/main/java/com/toedter/calendar/DateUtil.java
|
DateUtil.setMinSelectableDate
|
public Date setMinSelectableDate(Date min) {
if (min == null) {
minSelectableDate = defaultMinSelectableDate;
} else {
minSelectableDate = min;
}
return minSelectableDate;
}
|
java
|
public Date setMinSelectableDate(Date min) {
if (min == null) {
minSelectableDate = defaultMinSelectableDate;
} else {
minSelectableDate = min;
}
return minSelectableDate;
}
|
[
"public",
"Date",
"setMinSelectableDate",
"(",
"Date",
"min",
")",
"{",
"if",
"(",
"min",
"==",
"null",
")",
"{",
"minSelectableDate",
"=",
"defaultMinSelectableDate",
";",
"}",
"else",
"{",
"minSelectableDate",
"=",
"min",
";",
"}",
"return",
"minSelectableDate",
";",
"}"
] |
Sets the minimum selectable date. If null, the date 01\01\0001 will be set instead.
@param min the minimum selectable date
@return the minimum selectable date
|
[
"Sets",
"the",
"minimum",
"selectable",
"date",
".",
"If",
"null",
"the",
"date",
"01",
"\\",
"01",
"\\",
"0001",
"will",
"be",
"set",
"instead",
"."
] |
442e5bc319d92dee93400e6180ca74a5b6bd7775
|
https://github.com/luuuis/jcalendar/blob/442e5bc319d92dee93400e6180ca74a5b6bd7775/src/main/java/com/toedter/calendar/DateUtil.java#L104-L111
|
148,288
|
luuuis/jcalendar
|
src/main/java/com/toedter/calendar/DateUtil.java
|
DateUtil.checkDate
|
public boolean checkDate(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
Calendar minCal = Calendar.getInstance();
minCal.setTime(minSelectableDate);
minCal.set(Calendar.HOUR_OF_DAY, 0);
minCal.set(Calendar.MINUTE, 0);
minCal.set(Calendar.SECOND, 0);
minCal.set(Calendar.MILLISECOND, 0);
Calendar maxCal = Calendar.getInstance();
maxCal.setTime(maxSelectableDate);
maxCal.set(Calendar.HOUR_OF_DAY, 0);
maxCal.set(Calendar.MINUTE, 0);
maxCal.set(Calendar.SECOND, 0);
maxCal.set(Calendar.MILLISECOND, 0);
return !(calendar.before(minCal) || calendar.after(maxCal));
}
|
java
|
public boolean checkDate(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
Calendar minCal = Calendar.getInstance();
minCal.setTime(minSelectableDate);
minCal.set(Calendar.HOUR_OF_DAY, 0);
minCal.set(Calendar.MINUTE, 0);
minCal.set(Calendar.SECOND, 0);
minCal.set(Calendar.MILLISECOND, 0);
Calendar maxCal = Calendar.getInstance();
maxCal.setTime(maxSelectableDate);
maxCal.set(Calendar.HOUR_OF_DAY, 0);
maxCal.set(Calendar.MINUTE, 0);
maxCal.set(Calendar.SECOND, 0);
maxCal.set(Calendar.MILLISECOND, 0);
return !(calendar.before(minCal) || calendar.after(maxCal));
}
|
[
"public",
"boolean",
"checkDate",
"(",
"Date",
"date",
")",
"{",
"Calendar",
"calendar",
"=",
"Calendar",
".",
"getInstance",
"(",
")",
";",
"calendar",
".",
"setTime",
"(",
"date",
")",
";",
"calendar",
".",
"set",
"(",
"Calendar",
".",
"HOUR_OF_DAY",
",",
"0",
")",
";",
"calendar",
".",
"set",
"(",
"Calendar",
".",
"MINUTE",
",",
"0",
")",
";",
"calendar",
".",
"set",
"(",
"Calendar",
".",
"SECOND",
",",
"0",
")",
";",
"calendar",
".",
"set",
"(",
"Calendar",
".",
"MILLISECOND",
",",
"0",
")",
";",
"Calendar",
"minCal",
"=",
"Calendar",
".",
"getInstance",
"(",
")",
";",
"minCal",
".",
"setTime",
"(",
"minSelectableDate",
")",
";",
"minCal",
".",
"set",
"(",
"Calendar",
".",
"HOUR_OF_DAY",
",",
"0",
")",
";",
"minCal",
".",
"set",
"(",
"Calendar",
".",
"MINUTE",
",",
"0",
")",
";",
"minCal",
".",
"set",
"(",
"Calendar",
".",
"SECOND",
",",
"0",
")",
";",
"minCal",
".",
"set",
"(",
"Calendar",
".",
"MILLISECOND",
",",
"0",
")",
";",
"Calendar",
"maxCal",
"=",
"Calendar",
".",
"getInstance",
"(",
")",
";",
"maxCal",
".",
"setTime",
"(",
"maxSelectableDate",
")",
";",
"maxCal",
".",
"set",
"(",
"Calendar",
".",
"HOUR_OF_DAY",
",",
"0",
")",
";",
"maxCal",
".",
"set",
"(",
"Calendar",
".",
"MINUTE",
",",
"0",
")",
";",
"maxCal",
".",
"set",
"(",
"Calendar",
".",
"SECOND",
",",
"0",
")",
";",
"maxCal",
".",
"set",
"(",
"Calendar",
".",
"MILLISECOND",
",",
"0",
")",
";",
"return",
"!",
"(",
"calendar",
".",
"before",
"(",
"minCal",
")",
"||",
"calendar",
".",
"after",
"(",
"maxCal",
")",
")",
";",
"}"
] |
Checks a given date if it is in the formally specified date range.
@param date
the date to check
@return true, if the date is within minSelectableDate and
maxSelectableDate
|
[
"Checks",
"a",
"given",
"date",
"if",
"it",
"is",
"in",
"the",
"formally",
"specified",
"date",
"range",
"."
] |
442e5bc319d92dee93400e6180ca74a5b6bd7775
|
https://github.com/luuuis/jcalendar/blob/442e5bc319d92dee93400e6180ca74a5b6bd7775/src/main/java/com/toedter/calendar/DateUtil.java#L139-L162
|
148,289
|
JM-Lab/utils-elasticsearch
|
src/main/java/kr/jm/utils/elasticsearch/JMElasticsearchClient.java
|
JMElasticsearchClient.getSettingsBuilder
|
public static Builder getSettingsBuilder(String nodeName,
boolean clientTransportSniff, String clusterName) {
boolean isNullClusterName = Objects.isNull(clusterName);
Builder builder = Settings.builder().put(NODE_NAME, nodeName)
.put(CLIENT_TRANSPORT_SNIFF, clientTransportSniff)
.put(CLIENT_TRANSPORT_IGNORE_CLUSTER_NAME,
isNullClusterName);
if (!isNullClusterName)
builder.put(CLUSTER_NAME, clusterName);
return builder;
}
|
java
|
public static Builder getSettingsBuilder(String nodeName,
boolean clientTransportSniff, String clusterName) {
boolean isNullClusterName = Objects.isNull(clusterName);
Builder builder = Settings.builder().put(NODE_NAME, nodeName)
.put(CLIENT_TRANSPORT_SNIFF, clientTransportSniff)
.put(CLIENT_TRANSPORT_IGNORE_CLUSTER_NAME,
isNullClusterName);
if (!isNullClusterName)
builder.put(CLUSTER_NAME, clusterName);
return builder;
}
|
[
"public",
"static",
"Builder",
"getSettingsBuilder",
"(",
"String",
"nodeName",
",",
"boolean",
"clientTransportSniff",
",",
"String",
"clusterName",
")",
"{",
"boolean",
"isNullClusterName",
"=",
"Objects",
".",
"isNull",
"(",
"clusterName",
")",
";",
"Builder",
"builder",
"=",
"Settings",
".",
"builder",
"(",
")",
".",
"put",
"(",
"NODE_NAME",
",",
"nodeName",
")",
".",
"put",
"(",
"CLIENT_TRANSPORT_SNIFF",
",",
"clientTransportSniff",
")",
".",
"put",
"(",
"CLIENT_TRANSPORT_IGNORE_CLUSTER_NAME",
",",
"isNullClusterName",
")",
";",
"if",
"(",
"!",
"isNullClusterName",
")",
"builder",
".",
"put",
"(",
"CLUSTER_NAME",
",",
"clusterName",
")",
";",
"return",
"builder",
";",
"}"
] |
Gets settings builder.
@param nodeName the node name
@param clientTransportSniff the client transport sniff
@param clusterName the cluster name
@return the settings builder
|
[
"Gets",
"settings",
"builder",
"."
] |
6ccec90e1e51d65d2af5efbb6d7b9f9bad90e638
|
https://github.com/JM-Lab/utils-elasticsearch/blob/6ccec90e1e51d65d2af5efbb6d7b9f9bad90e638/src/main/java/kr/jm/utils/elasticsearch/JMElasticsearchClient.java#L173-L183
|
148,290
|
JM-Lab/utils-elasticsearch
|
src/main/java/kr/jm/utils/elasticsearch/JMElasticsearchClient.java
|
JMElasticsearchClient.isExists
|
public boolean isExists(String index) {
IndicesExistsRequestBuilder indicesExistsRequestBuilder =
admin().indices().prepareExists(index);
return JMElasticsearchUtil
.logRequestQueryAndReturn("isExists",
indicesExistsRequestBuilder,
indicesExistsRequestBuilder.execute())
.isExists();
}
|
java
|
public boolean isExists(String index) {
IndicesExistsRequestBuilder indicesExistsRequestBuilder =
admin().indices().prepareExists(index);
return JMElasticsearchUtil
.logRequestQueryAndReturn("isExists",
indicesExistsRequestBuilder,
indicesExistsRequestBuilder.execute())
.isExists();
}
|
[
"public",
"boolean",
"isExists",
"(",
"String",
"index",
")",
"{",
"IndicesExistsRequestBuilder",
"indicesExistsRequestBuilder",
"=",
"admin",
"(",
")",
".",
"indices",
"(",
")",
".",
"prepareExists",
"(",
"index",
")",
";",
"return",
"JMElasticsearchUtil",
".",
"logRequestQueryAndReturn",
"(",
"\"isExists\"",
",",
"indicesExistsRequestBuilder",
",",
"indicesExistsRequestBuilder",
".",
"execute",
"(",
")",
")",
".",
"isExists",
"(",
")",
";",
"}"
] |
Is exists boolean.
@param index the index
@return the boolean
|
[
"Is",
"exists",
"boolean",
"."
] |
6ccec90e1e51d65d2af5efbb6d7b9f9bad90e638
|
https://github.com/JM-Lab/utils-elasticsearch/blob/6ccec90e1e51d65d2af5efbb6d7b9f9bad90e638/src/main/java/kr/jm/utils/elasticsearch/JMElasticsearchClient.java#L191-L199
|
148,291
|
JM-Lab/utils-elasticsearch
|
src/main/java/kr/jm/utils/elasticsearch/JMElasticsearchClient.java
|
JMElasticsearchClient.create
|
public boolean create(String index) {
CreateIndexRequestBuilder createIndexRequestBuilder =
admin().indices().prepareCreate(index);
return JMElasticsearchUtil.logRequestQueryAndReturn("create",
createIndexRequestBuilder,
createIndexRequestBuilder.execute())
.isAcknowledged();
}
|
java
|
public boolean create(String index) {
CreateIndexRequestBuilder createIndexRequestBuilder =
admin().indices().prepareCreate(index);
return JMElasticsearchUtil.logRequestQueryAndReturn("create",
createIndexRequestBuilder,
createIndexRequestBuilder.execute())
.isAcknowledged();
}
|
[
"public",
"boolean",
"create",
"(",
"String",
"index",
")",
"{",
"CreateIndexRequestBuilder",
"createIndexRequestBuilder",
"=",
"admin",
"(",
")",
".",
"indices",
"(",
")",
".",
"prepareCreate",
"(",
"index",
")",
";",
"return",
"JMElasticsearchUtil",
".",
"logRequestQueryAndReturn",
"(",
"\"create\"",
",",
"createIndexRequestBuilder",
",",
"createIndexRequestBuilder",
".",
"execute",
"(",
")",
")",
".",
"isAcknowledged",
"(",
")",
";",
"}"
] |
Create boolean.
@param index the index
@return the boolean
|
[
"Create",
"boolean",
"."
] |
6ccec90e1e51d65d2af5efbb6d7b9f9bad90e638
|
https://github.com/JM-Lab/utils-elasticsearch/blob/6ccec90e1e51d65d2af5efbb6d7b9f9bad90e638/src/main/java/kr/jm/utils/elasticsearch/JMElasticsearchClient.java#L207-L214
|
148,292
|
JM-Lab/utils-elasticsearch
|
src/main/java/kr/jm/utils/elasticsearch/JMElasticsearchClient.java
|
JMElasticsearchClient.getAllIdList
|
public List<String> getAllIdList(String index, String type) {
return extractIdList(searchAll(index, type));
}
|
java
|
public List<String> getAllIdList(String index, String type) {
return extractIdList(searchAll(index, type));
}
|
[
"public",
"List",
"<",
"String",
">",
"getAllIdList",
"(",
"String",
"index",
",",
"String",
"type",
")",
"{",
"return",
"extractIdList",
"(",
"searchAll",
"(",
"index",
",",
"type",
")",
")",
";",
"}"
] |
Gets all id list.
@param index the index
@param type the type
@return the all id list
|
[
"Gets",
"all",
"id",
"list",
"."
] |
6ccec90e1e51d65d2af5efbb6d7b9f9bad90e638
|
https://github.com/JM-Lab/utils-elasticsearch/blob/6ccec90e1e51d65d2af5efbb6d7b9f9bad90e638/src/main/java/kr/jm/utils/elasticsearch/JMElasticsearchClient.java#L234-L236
|
148,293
|
JM-Lab/utils-elasticsearch
|
src/main/java/kr/jm/utils/elasticsearch/JMElasticsearchClient.java
|
JMElasticsearchClient.getMappingsResponse
|
public ImmutableOpenMap<String, ImmutableOpenMap<String, MappingMetaData>>
getMappingsResponse(String... indices) {
GetMappingsRequestBuilder getMappingsRequestBuilder =
admin().indices().prepareGetMappings(indices);
return JMElasticsearchUtil
.logRequestQueryAndReturn("getMappingsResponse",
getMappingsRequestBuilder,
getMappingsRequestBuilder.execute
()).getMappings();
}
|
java
|
public ImmutableOpenMap<String, ImmutableOpenMap<String, MappingMetaData>>
getMappingsResponse(String... indices) {
GetMappingsRequestBuilder getMappingsRequestBuilder =
admin().indices().prepareGetMappings(indices);
return JMElasticsearchUtil
.logRequestQueryAndReturn("getMappingsResponse",
getMappingsRequestBuilder,
getMappingsRequestBuilder.execute
()).getMappings();
}
|
[
"public",
"ImmutableOpenMap",
"<",
"String",
",",
"ImmutableOpenMap",
"<",
"String",
",",
"MappingMetaData",
">",
">",
"getMappingsResponse",
"(",
"String",
"...",
"indices",
")",
"{",
"GetMappingsRequestBuilder",
"getMappingsRequestBuilder",
"=",
"admin",
"(",
")",
".",
"indices",
"(",
")",
".",
"prepareGetMappings",
"(",
"indices",
")",
";",
"return",
"JMElasticsearchUtil",
".",
"logRequestQueryAndReturn",
"(",
"\"getMappingsResponse\"",
",",
"getMappingsRequestBuilder",
",",
"getMappingsRequestBuilder",
".",
"execute",
"(",
")",
")",
".",
"getMappings",
"(",
")",
";",
"}"
] |
Gets mappings response.
@param indices the indices
@return the mappings response
|
[
"Gets",
"mappings",
"response",
"."
] |
6ccec90e1e51d65d2af5efbb6d7b9f9bad90e638
|
https://github.com/JM-Lab/utils-elasticsearch/blob/6ccec90e1e51d65d2af5efbb6d7b9f9bad90e638/src/main/java/kr/jm/utils/elasticsearch/JMElasticsearchClient.java#L258-L267
|
148,294
|
JM-Lab/utils-elasticsearch
|
src/main/java/kr/jm/utils/elasticsearch/JMElasticsearchClient.java
|
JMElasticsearchClient.getAllIndicesStats
|
public Map<String, IndexStats> getAllIndicesStats() {
IndicesStatsRequestBuilder indicesStatsRequestBuilder =
admin().indices().prepareStats().all();
return JMElasticsearchUtil
.logRequestQueryAndReturn("getAllIndicesStats",
indicesStatsRequestBuilder,
indicesStatsRequestBuilder.execute()).getIndices();
}
|
java
|
public Map<String, IndexStats> getAllIndicesStats() {
IndicesStatsRequestBuilder indicesStatsRequestBuilder =
admin().indices().prepareStats().all();
return JMElasticsearchUtil
.logRequestQueryAndReturn("getAllIndicesStats",
indicesStatsRequestBuilder,
indicesStatsRequestBuilder.execute()).getIndices();
}
|
[
"public",
"Map",
"<",
"String",
",",
"IndexStats",
">",
"getAllIndicesStats",
"(",
")",
"{",
"IndicesStatsRequestBuilder",
"indicesStatsRequestBuilder",
"=",
"admin",
"(",
")",
".",
"indices",
"(",
")",
".",
"prepareStats",
"(",
")",
".",
"all",
"(",
")",
";",
"return",
"JMElasticsearchUtil",
".",
"logRequestQueryAndReturn",
"(",
"\"getAllIndicesStats\"",
",",
"indicesStatsRequestBuilder",
",",
"indicesStatsRequestBuilder",
".",
"execute",
"(",
")",
")",
".",
"getIndices",
"(",
")",
";",
"}"
] |
Gets all indices stats.
@return the all indices stats
|
[
"Gets",
"all",
"indices",
"stats",
"."
] |
6ccec90e1e51d65d2af5efbb6d7b9f9bad90e638
|
https://github.com/JM-Lab/utils-elasticsearch/blob/6ccec90e1e51d65d2af5efbb6d7b9f9bad90e638/src/main/java/kr/jm/utils/elasticsearch/JMElasticsearchClient.java#L274-L281
|
148,295
|
JM-Lab/utils-elasticsearch
|
src/main/java/kr/jm/utils/elasticsearch/JMElasticsearchClient.java
|
JMElasticsearchClient.getFilteredIndexList
|
public List<String> getFilteredIndexList(String containedString) {
return getAllIndices().stream()
.filter(index -> index.contains(containedString))
.collect(toList());
}
|
java
|
public List<String> getFilteredIndexList(String containedString) {
return getAllIndices().stream()
.filter(index -> index.contains(containedString))
.collect(toList());
}
|
[
"public",
"List",
"<",
"String",
">",
"getFilteredIndexList",
"(",
"String",
"containedString",
")",
"{",
"return",
"getAllIndices",
"(",
")",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"index",
"->",
"index",
".",
"contains",
"(",
"containedString",
")",
")",
".",
"collect",
"(",
"toList",
"(",
")",
")",
";",
"}"
] |
Gets filtered index list.
@param containedString the contained string
@return the filtered index list
|
[
"Gets",
"filtered",
"index",
"list",
"."
] |
6ccec90e1e51d65d2af5efbb6d7b9f9bad90e638
|
https://github.com/JM-Lab/utils-elasticsearch/blob/6ccec90e1e51d65d2af5efbb6d7b9f9bad90e638/src/main/java/kr/jm/utils/elasticsearch/JMElasticsearchClient.java#L298-L302
|
148,296
|
JM-Lab/utils-elasticsearch
|
src/main/java/kr/jm/utils/elasticsearch/JMElasticsearchClient.java
|
JMElasticsearchClient.getMappings
|
public Optional<Map<String, ?>> getMappings(String index, String
type) {
try {
return Optional
.of(getMappingsResponse(index).get(index).get(type)
.getSourceAsMap());
} catch (Exception e) {
return JMExceptionManager.handleExceptionAndReturnEmptyOptional
(log, e, "getMappings", index, type);
}
}
|
java
|
public Optional<Map<String, ?>> getMappings(String index, String
type) {
try {
return Optional
.of(getMappingsResponse(index).get(index).get(type)
.getSourceAsMap());
} catch (Exception e) {
return JMExceptionManager.handleExceptionAndReturnEmptyOptional
(log, e, "getMappings", index, type);
}
}
|
[
"public",
"Optional",
"<",
"Map",
"<",
"String",
",",
"?",
">",
">",
"getMappings",
"(",
"String",
"index",
",",
"String",
"type",
")",
"{",
"try",
"{",
"return",
"Optional",
".",
"of",
"(",
"getMappingsResponse",
"(",
"index",
")",
".",
"get",
"(",
"index",
")",
".",
"get",
"(",
"type",
")",
".",
"getSourceAsMap",
"(",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"return",
"JMExceptionManager",
".",
"handleExceptionAndReturnEmptyOptional",
"(",
"log",
",",
"e",
",",
"\"getMappings\"",
",",
"index",
",",
"type",
")",
";",
"}",
"}"
] |
Gets mappings.
@param index the index
@param type the type
@return the mappings
|
[
"Gets",
"mappings",
"."
] |
6ccec90e1e51d65d2af5efbb6d7b9f9bad90e638
|
https://github.com/JM-Lab/utils-elasticsearch/blob/6ccec90e1e51d65d2af5efbb6d7b9f9bad90e638/src/main/java/kr/jm/utils/elasticsearch/JMElasticsearchClient.java#L334-L344
|
148,297
|
jledit/jledit
|
core/src/main/java/org/jledit/AbstractConsoleEditor.java
|
AbstractConsoleEditor.readBoolean
|
@Override
public boolean readBoolean(String message, Boolean defaultValue) throws IOException {
saveCursorPosition();
Ansi style = ansi();
if (getTheme().getPromptBackground() != null) {
style.bg(getTheme().getPromptBackground());
}
if (getTheme().getPromptForeground() != null) {
style.fg(getTheme().getPromptForeground());
}
for (int i = 1; i <= getFooterSize(); i++) {
console.out().print(ansi().cursor(terminal.getHeight() - getFooterSize() + i, 1));
console.out().print(style.eraseLine(Ansi.Erase.FORWARD));
}
console.out().print(ansi().cursor(terminal.getHeight(), 1));
console.out().print(style.a(message).bold().eraseLine(Ansi.Erase.FORWARD));
restoreCursorPosition();
flush();
try {
EditorOperation operation;
while (true) {
operation = readOperation();
switch (operation.getType()) {
case NEWLINE:
return defaultValue;
case TYPE:
if ("y".equals(operation.getInput()) || "Y".equals(operation.getInput())) {
return true;
} else if ("n".equals(operation.getInput()) || "N".equals(operation.getInput())) {
return false;
}
}
}
} finally {
redrawFooter();
}
}
|
java
|
@Override
public boolean readBoolean(String message, Boolean defaultValue) throws IOException {
saveCursorPosition();
Ansi style = ansi();
if (getTheme().getPromptBackground() != null) {
style.bg(getTheme().getPromptBackground());
}
if (getTheme().getPromptForeground() != null) {
style.fg(getTheme().getPromptForeground());
}
for (int i = 1; i <= getFooterSize(); i++) {
console.out().print(ansi().cursor(terminal.getHeight() - getFooterSize() + i, 1));
console.out().print(style.eraseLine(Ansi.Erase.FORWARD));
}
console.out().print(ansi().cursor(terminal.getHeight(), 1));
console.out().print(style.a(message).bold().eraseLine(Ansi.Erase.FORWARD));
restoreCursorPosition();
flush();
try {
EditorOperation operation;
while (true) {
operation = readOperation();
switch (operation.getType()) {
case NEWLINE:
return defaultValue;
case TYPE:
if ("y".equals(operation.getInput()) || "Y".equals(operation.getInput())) {
return true;
} else if ("n".equals(operation.getInput()) || "N".equals(operation.getInput())) {
return false;
}
}
}
} finally {
redrawFooter();
}
}
|
[
"@",
"Override",
"public",
"boolean",
"readBoolean",
"(",
"String",
"message",
",",
"Boolean",
"defaultValue",
")",
"throws",
"IOException",
"{",
"saveCursorPosition",
"(",
")",
";",
"Ansi",
"style",
"=",
"ansi",
"(",
")",
";",
"if",
"(",
"getTheme",
"(",
")",
".",
"getPromptBackground",
"(",
")",
"!=",
"null",
")",
"{",
"style",
".",
"bg",
"(",
"getTheme",
"(",
")",
".",
"getPromptBackground",
"(",
")",
")",
";",
"}",
"if",
"(",
"getTheme",
"(",
")",
".",
"getPromptForeground",
"(",
")",
"!=",
"null",
")",
"{",
"style",
".",
"fg",
"(",
"getTheme",
"(",
")",
".",
"getPromptForeground",
"(",
")",
")",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<=",
"getFooterSize",
"(",
")",
";",
"i",
"++",
")",
"{",
"console",
".",
"out",
"(",
")",
".",
"print",
"(",
"ansi",
"(",
")",
".",
"cursor",
"(",
"terminal",
".",
"getHeight",
"(",
")",
"-",
"getFooterSize",
"(",
")",
"+",
"i",
",",
"1",
")",
")",
";",
"console",
".",
"out",
"(",
")",
".",
"print",
"(",
"style",
".",
"eraseLine",
"(",
"Ansi",
".",
"Erase",
".",
"FORWARD",
")",
")",
";",
"}",
"console",
".",
"out",
"(",
")",
".",
"print",
"(",
"ansi",
"(",
")",
".",
"cursor",
"(",
"terminal",
".",
"getHeight",
"(",
")",
",",
"1",
")",
")",
";",
"console",
".",
"out",
"(",
")",
".",
"print",
"(",
"style",
".",
"a",
"(",
"message",
")",
".",
"bold",
"(",
")",
".",
"eraseLine",
"(",
"Ansi",
".",
"Erase",
".",
"FORWARD",
")",
")",
";",
"restoreCursorPosition",
"(",
")",
";",
"flush",
"(",
")",
";",
"try",
"{",
"EditorOperation",
"operation",
";",
"while",
"(",
"true",
")",
"{",
"operation",
"=",
"readOperation",
"(",
")",
";",
"switch",
"(",
"operation",
".",
"getType",
"(",
")",
")",
"{",
"case",
"NEWLINE",
":",
"return",
"defaultValue",
";",
"case",
"TYPE",
":",
"if",
"(",
"\"y\"",
".",
"equals",
"(",
"operation",
".",
"getInput",
"(",
")",
")",
"||",
"\"Y\"",
".",
"equals",
"(",
"operation",
".",
"getInput",
"(",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"if",
"(",
"\"n\"",
".",
"equals",
"(",
"operation",
".",
"getInput",
"(",
")",
")",
"||",
"\"N\"",
".",
"equals",
"(",
"operation",
".",
"getInput",
"(",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"}",
"}",
"finally",
"{",
"redrawFooter",
"(",
")",
";",
"}",
"}"
] |
Displays a message and reads a boolean from the user input.
The mapping of the user input to a boolean value is specified by the implementation.
@param message
@param defaultValue
@return
|
[
"Displays",
"a",
"message",
"and",
"reads",
"a",
"boolean",
"from",
"the",
"user",
"input",
".",
"The",
"mapping",
"of",
"the",
"user",
"input",
"to",
"a",
"boolean",
"value",
"is",
"specified",
"by",
"the",
"implementation",
"."
] |
ced2c4b44330664adb65f8be4c8fff780ccaa6fd
|
https://github.com/jledit/jledit/blob/ced2c4b44330664adb65f8be4c8fff780ccaa6fd/core/src/main/java/org/jledit/AbstractConsoleEditor.java#L209-L245
|
148,298
|
jledit/jledit
|
core/src/main/java/org/jledit/AbstractConsoleEditor.java
|
AbstractConsoleEditor.readLine
|
@Override
public String readLine() throws IOException {
StringBuilder lineBuilder = new StringBuilder();
EditorOperation operation;
while (true) {
operation = readOperation();
switch (operation.getType()) {
case BACKSAPCE:
case DELETE:
if (lineBuilder.length() > 0) {
lineBuilder.delete(lineBuilder.length() - 1, lineBuilder.length());
console.out().print(Ansi.ansi().cursorLeft(1));
console.out().print(" ");
console.out().print(Ansi.ansi().cursorLeft(1));
}
break;
case NEWLINE:
return lineBuilder.toString();
case TYPE:
console.out().print(operation.getInput());
lineBuilder.append(operation.getInput());
break;
}
flush();
}
}
|
java
|
@Override
public String readLine() throws IOException {
StringBuilder lineBuilder = new StringBuilder();
EditorOperation operation;
while (true) {
operation = readOperation();
switch (operation.getType()) {
case BACKSAPCE:
case DELETE:
if (lineBuilder.length() > 0) {
lineBuilder.delete(lineBuilder.length() - 1, lineBuilder.length());
console.out().print(Ansi.ansi().cursorLeft(1));
console.out().print(" ");
console.out().print(Ansi.ansi().cursorLeft(1));
}
break;
case NEWLINE:
return lineBuilder.toString();
case TYPE:
console.out().print(operation.getInput());
lineBuilder.append(operation.getInput());
break;
}
flush();
}
}
|
[
"@",
"Override",
"public",
"String",
"readLine",
"(",
")",
"throws",
"IOException",
"{",
"StringBuilder",
"lineBuilder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"EditorOperation",
"operation",
";",
"while",
"(",
"true",
")",
"{",
"operation",
"=",
"readOperation",
"(",
")",
";",
"switch",
"(",
"operation",
".",
"getType",
"(",
")",
")",
"{",
"case",
"BACKSAPCE",
":",
"case",
"DELETE",
":",
"if",
"(",
"lineBuilder",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"lineBuilder",
".",
"delete",
"(",
"lineBuilder",
".",
"length",
"(",
")",
"-",
"1",
",",
"lineBuilder",
".",
"length",
"(",
")",
")",
";",
"console",
".",
"out",
"(",
")",
".",
"print",
"(",
"Ansi",
".",
"ansi",
"(",
")",
".",
"cursorLeft",
"(",
"1",
")",
")",
";",
"console",
".",
"out",
"(",
")",
".",
"print",
"(",
"\" \"",
")",
";",
"console",
".",
"out",
"(",
")",
".",
"print",
"(",
"Ansi",
".",
"ansi",
"(",
")",
".",
"cursorLeft",
"(",
"1",
")",
")",
";",
"}",
"break",
";",
"case",
"NEWLINE",
":",
"return",
"lineBuilder",
".",
"toString",
"(",
")",
";",
"case",
"TYPE",
":",
"console",
".",
"out",
"(",
")",
".",
"print",
"(",
"operation",
".",
"getInput",
"(",
")",
")",
";",
"lineBuilder",
".",
"append",
"(",
"operation",
".",
"getInput",
"(",
")",
")",
";",
"break",
";",
"}",
"flush",
"(",
")",
";",
"}",
"}"
] |
Reads a line from the user input.
@return
@throws java.io.IOException
|
[
"Reads",
"a",
"line",
"from",
"the",
"user",
"input",
"."
] |
ced2c4b44330664adb65f8be4c8fff780ccaa6fd
|
https://github.com/jledit/jledit/blob/ced2c4b44330664adb65f8be4c8fff780ccaa6fd/core/src/main/java/org/jledit/AbstractConsoleEditor.java#L253-L278
|
148,299
|
jledit/jledit
|
core/src/main/java/org/jledit/AbstractConsoleEditor.java
|
AbstractConsoleEditor.repaintScreen
|
void repaintScreen() {
int repaintLine = 1;
console.out().print(ansi().eraseScreen(Erase.ALL));
console.out().print(ansi().cursor(1, 1));
console.out().print("\33[" + (getHeaderSize() + 1) + ";" + (terminal.getHeight() - getFooterSize()) + ";r");
redrawHeader();
redrawFooter();
LinkedList<String> linesToDisplay = new LinkedList<String>();
int l = 1;
while (linesToDisplay.size() < terminal.getHeight() - getFooterSize()) {
String currentLine = getContent(l++);
linesToDisplay.addAll(toDisplayLines(currentLine));
}
for (int i = 0; i < terminal.getHeight() - getHeaderSize() - getFooterSize(); i++) {
console.out().print(ansi().cursor(repaintLine + getHeaderSize(), 1));
displayText(linesToDisplay.get(i));
repaintLine++;
}
console.out().print(ansi().cursor(2, 1));
}
|
java
|
void repaintScreen() {
int repaintLine = 1;
console.out().print(ansi().eraseScreen(Erase.ALL));
console.out().print(ansi().cursor(1, 1));
console.out().print("\33[" + (getHeaderSize() + 1) + ";" + (terminal.getHeight() - getFooterSize()) + ";r");
redrawHeader();
redrawFooter();
LinkedList<String> linesToDisplay = new LinkedList<String>();
int l = 1;
while (linesToDisplay.size() < terminal.getHeight() - getFooterSize()) {
String currentLine = getContent(l++);
linesToDisplay.addAll(toDisplayLines(currentLine));
}
for (int i = 0; i < terminal.getHeight() - getHeaderSize() - getFooterSize(); i++) {
console.out().print(ansi().cursor(repaintLine + getHeaderSize(), 1));
displayText(linesToDisplay.get(i));
repaintLine++;
}
console.out().print(ansi().cursor(2, 1));
}
|
[
"void",
"repaintScreen",
"(",
")",
"{",
"int",
"repaintLine",
"=",
"1",
";",
"console",
".",
"out",
"(",
")",
".",
"print",
"(",
"ansi",
"(",
")",
".",
"eraseScreen",
"(",
"Erase",
".",
"ALL",
")",
")",
";",
"console",
".",
"out",
"(",
")",
".",
"print",
"(",
"ansi",
"(",
")",
".",
"cursor",
"(",
"1",
",",
"1",
")",
")",
";",
"console",
".",
"out",
"(",
")",
".",
"print",
"(",
"\"\\33[\"",
"+",
"(",
"getHeaderSize",
"(",
")",
"+",
"1",
")",
"+",
"\";\"",
"+",
"(",
"terminal",
".",
"getHeight",
"(",
")",
"-",
"getFooterSize",
"(",
")",
")",
"+",
"\";r\"",
")",
";",
"redrawHeader",
"(",
")",
";",
"redrawFooter",
"(",
")",
";",
"LinkedList",
"<",
"String",
">",
"linesToDisplay",
"=",
"new",
"LinkedList",
"<",
"String",
">",
"(",
")",
";",
"int",
"l",
"=",
"1",
";",
"while",
"(",
"linesToDisplay",
".",
"size",
"(",
")",
"<",
"terminal",
".",
"getHeight",
"(",
")",
"-",
"getFooterSize",
"(",
")",
")",
"{",
"String",
"currentLine",
"=",
"getContent",
"(",
"l",
"++",
")",
";",
"linesToDisplay",
".",
"addAll",
"(",
"toDisplayLines",
"(",
"currentLine",
")",
")",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"terminal",
".",
"getHeight",
"(",
")",
"-",
"getHeaderSize",
"(",
")",
"-",
"getFooterSize",
"(",
")",
";",
"i",
"++",
")",
"{",
"console",
".",
"out",
"(",
")",
".",
"print",
"(",
"ansi",
"(",
")",
".",
"cursor",
"(",
"repaintLine",
"+",
"getHeaderSize",
"(",
")",
",",
"1",
")",
")",
";",
"displayText",
"(",
"linesToDisplay",
".",
"get",
"(",
"i",
")",
")",
";",
"repaintLine",
"++",
";",
"}",
"console",
".",
"out",
"(",
")",
".",
"print",
"(",
"ansi",
"(",
")",
".",
"cursor",
"(",
"2",
",",
"1",
")",
")",
";",
"}"
] |
Repaints the whole screen.
|
[
"Repaints",
"the",
"whole",
"screen",
"."
] |
ced2c4b44330664adb65f8be4c8fff780ccaa6fd
|
https://github.com/jledit/jledit/blob/ced2c4b44330664adb65f8be4c8fff780ccaa6fd/core/src/main/java/org/jledit/AbstractConsoleEditor.java#L384-L404
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.