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 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
marklogic/marklogic-contentpump | mapreduce/src/main/java/com/marklogic/mapreduce/utilities/URIUtil.java | URIUtil.applyUriReplace | public static String applyUriReplace(String uriSource, Configuration conf) {
if (uriSource == null) return null;
String[] uriReplace = conf.getStrings(OUTPUT_URI_REPLACE);
if (uriReplace == null) return uriSource;
for (int i = 0; i < uriReplace.length - 1; i += 2) {
String replacement = uriReplace[i+1].trim();
replacement = replacement.substring(1, replacement.length()-1);
uriSource = uriSource.replaceAll(uriReplace[i], replacement);
}
return uriSource;
} | java | public static String applyUriReplace(String uriSource, Configuration conf) {
if (uriSource == null) return null;
String[] uriReplace = conf.getStrings(OUTPUT_URI_REPLACE);
if (uriReplace == null) return uriSource;
for (int i = 0; i < uriReplace.length - 1; i += 2) {
String replacement = uriReplace[i+1].trim();
replacement = replacement.substring(1, replacement.length()-1);
uriSource = uriSource.replaceAll(uriReplace[i], replacement);
}
return uriSource;
} | [
"public",
"static",
"String",
"applyUriReplace",
"(",
"String",
"uriSource",
",",
"Configuration",
"conf",
")",
"{",
"if",
"(",
"uriSource",
"==",
"null",
")",
"return",
"null",
";",
"String",
"[",
"]",
"uriReplace",
"=",
"conf",
".",
"getStrings",
"(",
"O... | Apply URI replacement configuration option to a URI source string. The
configuration option is a list of comma separated pairs of regex
patterns and replacements. Validation of the configuration is done at
command parsing time.
@param uriSource
@param conf
@return result URI string | [
"Apply",
"URI",
"replacement",
"configuration",
"option",
"to",
"a",
"URI",
"source",
"string",
".",
"The",
"configuration",
"option",
"is",
"a",
"list",
"of",
"comma",
"separated",
"pairs",
"of",
"regex",
"patterns",
"and",
"replacements",
".",
"Validation",
... | 4c41e4a953301f81a4c655efb2a847603dee8afc | https://github.com/marklogic/marklogic-contentpump/blob/4c41e4a953301f81a4c655efb2a847603dee8afc/mapreduce/src/main/java/com/marklogic/mapreduce/utilities/URIUtil.java#L45-L55 | train |
marklogic/marklogic-contentpump | mapreduce/src/main/java/com/marklogic/mapreduce/utilities/URIUtil.java | URIUtil.applyPrefixSuffix | public static String applyPrefixSuffix(String uriSource,
Configuration conf) {
if (uriSource == null) return null;
String prefix = conf.get(OUTPUT_URI_PREFIX);
String suffix = conf.get(OUTPUT_URI_SUFFIX);
if (prefix == null && suffix == null) {
return uriSource;
}
int len = uriSource.length() +
(prefix != null ? prefix.length() : 0) +
(suffix != null ? suffix.length() : 0);
StringBuilder uriBuf = new StringBuilder(len);
if (prefix != null) {
uriBuf.append(prefix);
}
uriBuf.append(uriSource);
if (suffix != null) {
uriBuf.append(suffix);
}
return uriBuf.toString();
} | java | public static String applyPrefixSuffix(String uriSource,
Configuration conf) {
if (uriSource == null) return null;
String prefix = conf.get(OUTPUT_URI_PREFIX);
String suffix = conf.get(OUTPUT_URI_SUFFIX);
if (prefix == null && suffix == null) {
return uriSource;
}
int len = uriSource.length() +
(prefix != null ? prefix.length() : 0) +
(suffix != null ? suffix.length() : 0);
StringBuilder uriBuf = new StringBuilder(len);
if (prefix != null) {
uriBuf.append(prefix);
}
uriBuf.append(uriSource);
if (suffix != null) {
uriBuf.append(suffix);
}
return uriBuf.toString();
} | [
"public",
"static",
"String",
"applyPrefixSuffix",
"(",
"String",
"uriSource",
",",
"Configuration",
"conf",
")",
"{",
"if",
"(",
"uriSource",
"==",
"null",
")",
"return",
"null",
";",
"String",
"prefix",
"=",
"conf",
".",
"get",
"(",
"OUTPUT_URI_PREFIX",
")... | Apply URI prefix and suffix configuration option to a URI source string.
@param uriSource
@param conf
@return result URI string | [
"Apply",
"URI",
"prefix",
"and",
"suffix",
"configuration",
"option",
"to",
"a",
"URI",
"source",
"string",
"."
] | 4c41e4a953301f81a4c655efb2a847603dee8afc | https://github.com/marklogic/marklogic-contentpump/blob/4c41e4a953301f81a4c655efb2a847603dee8afc/mapreduce/src/main/java/com/marklogic/mapreduce/utilities/URIUtil.java#L64-L84 | train |
marklogic/marklogic-contentpump | mlcp/src/main/java/com/marklogic/contentpump/utilities/OptionsFileUtil.java | OptionsFileUtil.expandArguments | public static String[] expandArguments(String[] args) throws Exception {
List<String> options = new ArrayList<String>();
for (int i = 0; i < args.length; i++) {
if (args[i].equals(OPTIONS_FILE)) {
if (i == args.length - 1) {
throw new Exception("Missing options file");
}
String fileName = args[++i];
File optionsFile = new File(fileName);
BufferedReader reader = null;
StringBuilder buffer = new StringBuilder();
try {
reader = new BufferedReader(new FileReader(optionsFile));
String nextLine = null;
while ((nextLine = reader.readLine()) != null) {
nextLine = nextLine.trim();
if (nextLine.length() == 0 || nextLine.startsWith("#")) {
// empty line or comment
continue;
}
buffer.append(nextLine);
if (nextLine.endsWith("\\")) {
if (buffer.charAt(0) == '\'' || buffer.charAt(0) == '"') {
throw new Exception(
"Multiline quoted strings not supported in file("
+ fileName + "): " + buffer.toString());
}
// Remove the trailing back-slash and continue
buffer.deleteCharAt(buffer.length() - 1);
} else {
// The buffer contains a full option
options.add(
removeQuotesEncolosingOption(fileName, buffer.toString()));
buffer.delete(0, buffer.length());
}
}
// Assert that the buffer is empty
if (buffer.length() != 0) {
throw new Exception("Malformed option in options file("
+ fileName + "): " + buffer.toString());
}
} catch (IOException ex) {
throw new Exception("Unable to read options file: " + fileName, ex);
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException ex) {
LOG.info("Exception while closing reader", ex);
}
}
}
} else {
// Regular option. Parse it and put it on the appropriate list
options.add(args[i]);
}
}
return options.toArray(new String[options.size()]);
} | java | public static String[] expandArguments(String[] args) throws Exception {
List<String> options = new ArrayList<String>();
for (int i = 0; i < args.length; i++) {
if (args[i].equals(OPTIONS_FILE)) {
if (i == args.length - 1) {
throw new Exception("Missing options file");
}
String fileName = args[++i];
File optionsFile = new File(fileName);
BufferedReader reader = null;
StringBuilder buffer = new StringBuilder();
try {
reader = new BufferedReader(new FileReader(optionsFile));
String nextLine = null;
while ((nextLine = reader.readLine()) != null) {
nextLine = nextLine.trim();
if (nextLine.length() == 0 || nextLine.startsWith("#")) {
// empty line or comment
continue;
}
buffer.append(nextLine);
if (nextLine.endsWith("\\")) {
if (buffer.charAt(0) == '\'' || buffer.charAt(0) == '"') {
throw new Exception(
"Multiline quoted strings not supported in file("
+ fileName + "): " + buffer.toString());
}
// Remove the trailing back-slash and continue
buffer.deleteCharAt(buffer.length() - 1);
} else {
// The buffer contains a full option
options.add(
removeQuotesEncolosingOption(fileName, buffer.toString()));
buffer.delete(0, buffer.length());
}
}
// Assert that the buffer is empty
if (buffer.length() != 0) {
throw new Exception("Malformed option in options file("
+ fileName + "): " + buffer.toString());
}
} catch (IOException ex) {
throw new Exception("Unable to read options file: " + fileName, ex);
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException ex) {
LOG.info("Exception while closing reader", ex);
}
}
}
} else {
// Regular option. Parse it and put it on the appropriate list
options.add(args[i]);
}
}
return options.toArray(new String[options.size()]);
} | [
"public",
"static",
"String",
"[",
"]",
"expandArguments",
"(",
"String",
"[",
"]",
"args",
")",
"throws",
"Exception",
"{",
"List",
"<",
"String",
">",
"options",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=... | Expands any options file that may be present in the given set of arguments.
@param args the given arguments
@return a new string array that contains the expanded arguments.
@throws Exception | [
"Expands",
"any",
"options",
"file",
"that",
"may",
"be",
"present",
"in",
"the",
"given",
"set",
"of",
"arguments",
"."
] | 4c41e4a953301f81a4c655efb2a847603dee8afc | https://github.com/marklogic/marklogic-contentpump/blob/4c41e4a953301f81a4c655efb2a847603dee8afc/mlcp/src/main/java/com/marklogic/contentpump/utilities/OptionsFileUtil.java#L53-L116 | train |
marklogic/marklogic-contentpump | mlcp/src/main/java/com/marklogic/contentpump/utilities/OptionsFileUtil.java | OptionsFileUtil.removeQuotesEncolosingOption | private static String removeQuotesEncolosingOption(
String fileName, String option) throws Exception {
// Attempt to remove double quotes. If successful, return.
String option1 = removeQuoteCharactersIfNecessary(fileName, option, '"');
if (!option1.equals(option)) {
// Quotes were successfully removed
return option1;
}
// Attempt to remove single quotes.
return removeQuoteCharactersIfNecessary(fileName, option, '\'');
} | java | private static String removeQuotesEncolosingOption(
String fileName, String option) throws Exception {
// Attempt to remove double quotes. If successful, return.
String option1 = removeQuoteCharactersIfNecessary(fileName, option, '"');
if (!option1.equals(option)) {
// Quotes were successfully removed
return option1;
}
// Attempt to remove single quotes.
return removeQuoteCharactersIfNecessary(fileName, option, '\'');
} | [
"private",
"static",
"String",
"removeQuotesEncolosingOption",
"(",
"String",
"fileName",
",",
"String",
"option",
")",
"throws",
"Exception",
"{",
"// Attempt to remove double quotes. If successful, return.",
"String",
"option1",
"=",
"removeQuoteCharactersIfNecessary",
"(",
... | Removes the surrounding quote characters as needed. It first attempts to
remove surrounding double quotes. If successful, the resultant string is
returned. If no surrounding double quotes are found, it attempts to remove
surrounding single quote characters. If successful, the resultant string
is returned. If not the original string is returnred.
@param fileName
@param option
@return
@throws Exception | [
"Removes",
"the",
"surrounding",
"quote",
"characters",
"as",
"needed",
".",
"It",
"first",
"attempts",
"to",
"remove",
"surrounding",
"double",
"quotes",
".",
"If",
"successful",
"the",
"resultant",
"string",
"is",
"returned",
".",
"If",
"no",
"surrounding",
... | 4c41e4a953301f81a4c655efb2a847603dee8afc | https://github.com/marklogic/marklogic-contentpump/blob/4c41e4a953301f81a4c655efb2a847603dee8afc/mlcp/src/main/java/com/marklogic/contentpump/utilities/OptionsFileUtil.java#L129-L141 | train |
marklogic/marklogic-contentpump | mlcp/src/main/java/com/marklogic/contentpump/utilities/OptionsFileUtil.java | OptionsFileUtil.removeQuoteCharactersIfNecessary | private static String removeQuoteCharactersIfNecessary(String fileName,
String option, char quote) throws Exception {
boolean startingQuote = (option.charAt(0) == quote);
boolean endingQuote = (option.charAt(option.length() - 1) == quote);
if (startingQuote && endingQuote) {
if (option.length() == 1) {
throw new Exception("Malformed option in options file("
+ fileName + "): " + option);
}
return option.substring(1, option.length() - 1);
}
if (startingQuote || endingQuote) {
throw new Exception("Malformed option in options file("
+ fileName + "): " + option);
}
return option;
} | java | private static String removeQuoteCharactersIfNecessary(String fileName,
String option, char quote) throws Exception {
boolean startingQuote = (option.charAt(0) == quote);
boolean endingQuote = (option.charAt(option.length() - 1) == quote);
if (startingQuote && endingQuote) {
if (option.length() == 1) {
throw new Exception("Malformed option in options file("
+ fileName + "): " + option);
}
return option.substring(1, option.length() - 1);
}
if (startingQuote || endingQuote) {
throw new Exception("Malformed option in options file("
+ fileName + "): " + option);
}
return option;
} | [
"private",
"static",
"String",
"removeQuoteCharactersIfNecessary",
"(",
"String",
"fileName",
",",
"String",
"option",
",",
"char",
"quote",
")",
"throws",
"Exception",
"{",
"boolean",
"startingQuote",
"=",
"(",
"option",
".",
"charAt",
"(",
"0",
")",
"==",
"q... | Removes the surrounding quote characters from the given string. The quotes
are identified by the quote parameter, the given string by option. The
fileName parameter is used for raising exceptions with relevant message.
@param fileName
@param option
@param quote
@return
@throws Exception | [
"Removes",
"the",
"surrounding",
"quote",
"characters",
"from",
"the",
"given",
"string",
".",
"The",
"quotes",
"are",
"identified",
"by",
"the",
"quote",
"parameter",
"the",
"given",
"string",
"by",
"option",
".",
"The",
"fileName",
"parameter",
"is",
"used",... | 4c41e4a953301f81a4c655efb2a847603dee8afc | https://github.com/marklogic/marklogic-contentpump/blob/4c41e4a953301f81a4c655efb2a847603dee8afc/mlcp/src/main/java/com/marklogic/contentpump/utilities/OptionsFileUtil.java#L153-L172 | train |
marklogic/marklogic-contentpump | mlcp/src/main/java/com/marklogic/contentpump/LocalJobRunner.java | LocalJobRunner.assignThreads | private int assignThreads(int splitIndex, int splitCount) {
if (threadsPerSplit > 0) {
return threadsPerSplit;
}
if (splitCount == 1) {
return threadCount;
}
if (splitCount * minThreads > threadCount) {
return minThreads;
}
if (splitIndex % threadCount < threadCount % splitCount) {
return threadCount / splitCount + 1;
} else {
return threadCount / splitCount;
}
} | java | private int assignThreads(int splitIndex, int splitCount) {
if (threadsPerSplit > 0) {
return threadsPerSplit;
}
if (splitCount == 1) {
return threadCount;
}
if (splitCount * minThreads > threadCount) {
return minThreads;
}
if (splitIndex % threadCount < threadCount % splitCount) {
return threadCount / splitCount + 1;
} else {
return threadCount / splitCount;
}
} | [
"private",
"int",
"assignThreads",
"(",
"int",
"splitIndex",
",",
"int",
"splitCount",
")",
"{",
"if",
"(",
"threadsPerSplit",
">",
"0",
")",
"{",
"return",
"threadsPerSplit",
";",
"}",
"if",
"(",
"splitCount",
"==",
"1",
")",
"{",
"return",
"threadCount",... | Assign thread count for a given split
@param splitIndex split index
@param splitCount
@return | [
"Assign",
"thread",
"count",
"for",
"a",
"given",
"split"
] | 4c41e4a953301f81a4c655efb2a847603dee8afc | https://github.com/marklogic/marklogic-contentpump/blob/4c41e4a953301f81a4c655efb2a847603dee8afc/mlcp/src/main/java/com/marklogic/contentpump/LocalJobRunner.java#L306-L321 | train |
marklogic/marklogic-contentpump | mlcp/src/main/java/com/marklogic/contentpump/utilities/DocBuilder.java | DocBuilder.configFields | public void configFields(Configuration conf, String[] fields)
throws IllegalArgumentException, IOException {
for (int i = 0; i < fields.length; i++) {
fields[i] = fields[i].trim();
if ("".equals(fields[i])) {
LOG.warn("Column " + (i+1) + " has no header and will be skipped");
}
}
} | java | public void configFields(Configuration conf, String[] fields)
throws IllegalArgumentException, IOException {
for (int i = 0; i < fields.length; i++) {
fields[i] = fields[i].trim();
if ("".equals(fields[i])) {
LOG.warn("Column " + (i+1) + " has no header and will be skipped");
}
}
} | [
"public",
"void",
"configFields",
"(",
"Configuration",
"conf",
",",
"String",
"[",
"]",
"fields",
")",
"throws",
"IllegalArgumentException",
",",
"IOException",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"fields",
".",
"length",
";",
"i",
"++... | Check document header fields.
@param fields
@throws IOException | [
"Check",
"document",
"header",
"fields",
"."
] | 4c41e4a953301f81a4c655efb2a847603dee8afc | https://github.com/marklogic/marklogic-contentpump/blob/4c41e4a953301f81a4c655efb2a847603dee8afc/mlcp/src/main/java/com/marklogic/contentpump/utilities/DocBuilder.java#L68-L76 | train |
aerospike/aerospike-helper | java/src/main/java/com/aerospike/helper/query/QueryEngine.java | QueryEngine.setClient | public void setClient(AerospikeClient client) {
this.client = client;
this.updatePolicy = new WritePolicy(this.client.writePolicyDefault);
this.updatePolicy.recordExistsAction = RecordExistsAction.UPDATE_ONLY;
this.insertPolicy = new WritePolicy(this.client.writePolicyDefault);
this.insertPolicy.recordExistsAction = RecordExistsAction.CREATE_ONLY;
this.queryPolicy = client.queryPolicyDefault;
refreshCluster();
registerUDF();
} | java | public void setClient(AerospikeClient client) {
this.client = client;
this.updatePolicy = new WritePolicy(this.client.writePolicyDefault);
this.updatePolicy.recordExistsAction = RecordExistsAction.UPDATE_ONLY;
this.insertPolicy = new WritePolicy(this.client.writePolicyDefault);
this.insertPolicy.recordExistsAction = RecordExistsAction.CREATE_ONLY;
this.queryPolicy = client.queryPolicyDefault;
refreshCluster();
registerUDF();
} | [
"public",
"void",
"setClient",
"(",
"AerospikeClient",
"client",
")",
"{",
"this",
".",
"client",
"=",
"client",
";",
"this",
".",
"updatePolicy",
"=",
"new",
"WritePolicy",
"(",
"this",
".",
"client",
".",
"writePolicyDefault",
")",
";",
"this",
".",
"upd... | Sets the AerospikeClient
@param client An instance of AerospikeClient | [
"Sets",
"the",
"AerospikeClient"
] | eeb4a1464bc8d9c6716c014d250c8166b5caa82d | https://github.com/aerospike/aerospike-helper/blob/eeb4a1464bc8d9c6716c014d250c8166b5caa82d/java/src/main/java/com/aerospike/helper/query/QueryEngine.java#L121-L130 | train |
aerospike/aerospike-helper | java/src/main/java/com/aerospike/helper/query/QueryEngine.java | QueryEngine.select | public KeyRecordIterator select(String namespace, String set, Filter filter, Qualifier... qualifiers) {
Statement stmt = new Statement();
stmt.setNamespace(namespace);
stmt.setSetName(set);
if (filter != null)
stmt.setFilters(filter);
return select(stmt, qualifiers);
} | java | public KeyRecordIterator select(String namespace, String set, Filter filter, Qualifier... qualifiers) {
Statement stmt = new Statement();
stmt.setNamespace(namespace);
stmt.setSetName(set);
if (filter != null)
stmt.setFilters(filter);
return select(stmt, qualifiers);
} | [
"public",
"KeyRecordIterator",
"select",
"(",
"String",
"namespace",
",",
"String",
"set",
",",
"Filter",
"filter",
",",
"Qualifier",
"...",
"qualifiers",
")",
"{",
"Statement",
"stmt",
"=",
"new",
"Statement",
"(",
")",
";",
"stmt",
".",
"setNamespace",
"("... | Select records filtered by a Filter and Qualifiers
@param namespace Namespace to storing the data
@param set Set storing the data
@param filter Aerospike Filter to be used
@param qualifiers Zero or more Qualifiers for the update query
@return A KeyRecordIterator to iterate over the results | [
"Select",
"records",
"filtered",
"by",
"a",
"Filter",
"and",
"Qualifiers"
] | eeb4a1464bc8d9c6716c014d250c8166b5caa82d | https://github.com/aerospike/aerospike-helper/blob/eeb4a1464bc8d9c6716c014d250c8166b5caa82d/java/src/main/java/com/aerospike/helper/query/QueryEngine.java#L197-L204 | train |
aerospike/aerospike-helper | java/src/main/java/com/aerospike/helper/query/QueryEngine.java | QueryEngine.insert | public void insert(String namespace, String set, Key key, List<Bin> bins) {
insert(namespace, set, key, bins, 0);
} | java | public void insert(String namespace, String set, Key key, List<Bin> bins) {
insert(namespace, set, key, bins, 0);
} | [
"public",
"void",
"insert",
"(",
"String",
"namespace",
",",
"String",
"set",
",",
"Key",
"key",
",",
"List",
"<",
"Bin",
">",
"bins",
")",
"{",
"insert",
"(",
"namespace",
",",
"set",
",",
"key",
",",
"bins",
",",
"0",
")",
";",
"}"
] | inserts a record. If the record exists, and exception will be thrown.
@param namespace Namespace to store the record
@param set Set to store the record
@param key Key of the record
@param bins A list of Bins to insert | [
"inserts",
"a",
"record",
".",
"If",
"the",
"record",
"exists",
"and",
"exception",
"will",
"be",
"thrown",
"."
] | eeb4a1464bc8d9c6716c014d250c8166b5caa82d | https://github.com/aerospike/aerospike-helper/blob/eeb4a1464bc8d9c6716c014d250c8166b5caa82d/java/src/main/java/com/aerospike/helper/query/QueryEngine.java#L353-L355 | train |
aerospike/aerospike-helper | java/src/main/java/com/aerospike/helper/query/QueryEngine.java | QueryEngine.insert | public void insert(String namespace, String set, Key key, List<Bin> bins, int ttl) {
this.client.put(this.insertPolicy, key, bins.toArray(new Bin[0]));
} | java | public void insert(String namespace, String set, Key key, List<Bin> bins, int ttl) {
this.client.put(this.insertPolicy, key, bins.toArray(new Bin[0]));
} | [
"public",
"void",
"insert",
"(",
"String",
"namespace",
",",
"String",
"set",
",",
"Key",
"key",
",",
"List",
"<",
"Bin",
">",
"bins",
",",
"int",
"ttl",
")",
"{",
"this",
".",
"client",
".",
"put",
"(",
"this",
".",
"insertPolicy",
",",
"key",
","... | inserts a record with a time to live. If the record exists, and exception will be thrown.
@param namespace Namespace to store the record
@param set Set to store the record
@param key Key of the record
@param bins A list of Bins to insert
@param ttl The record time to live in seconds | [
"inserts",
"a",
"record",
"with",
"a",
"time",
"to",
"live",
".",
"If",
"the",
"record",
"exists",
"and",
"exception",
"will",
"be",
"thrown",
"."
] | eeb4a1464bc8d9c6716c014d250c8166b5caa82d | https://github.com/aerospike/aerospike-helper/blob/eeb4a1464bc8d9c6716c014d250c8166b5caa82d/java/src/main/java/com/aerospike/helper/query/QueryEngine.java#L366-L368 | train |
aerospike/aerospike-helper | java/src/main/java/com/aerospike/helper/query/QueryEngine.java | QueryEngine.insert | public void insert(Statement stmt, KeyQualifier keyQualifier, List<Bin> bins) {
insert(stmt, keyQualifier, bins, 0);
} | java | public void insert(Statement stmt, KeyQualifier keyQualifier, List<Bin> bins) {
insert(stmt, keyQualifier, bins, 0);
} | [
"public",
"void",
"insert",
"(",
"Statement",
"stmt",
",",
"KeyQualifier",
"keyQualifier",
",",
"List",
"<",
"Bin",
">",
"bins",
")",
"{",
"insert",
"(",
"stmt",
",",
"keyQualifier",
",",
"bins",
",",
"0",
")",
";",
"}"
] | inserts a record using a Statement and KeyQualifier. If the record exists, and exception will be thrown.
@param stmt A Statement object containing Namespace and Set
@param keyQualifier KeyQualifier containin the primary key
@param bins A list of Bins to insert | [
"inserts",
"a",
"record",
"using",
"a",
"Statement",
"and",
"KeyQualifier",
".",
"If",
"the",
"record",
"exists",
"and",
"exception",
"will",
"be",
"thrown",
"."
] | eeb4a1464bc8d9c6716c014d250c8166b5caa82d | https://github.com/aerospike/aerospike-helper/blob/eeb4a1464bc8d9c6716c014d250c8166b5caa82d/java/src/main/java/com/aerospike/helper/query/QueryEngine.java#L377-L379 | train |
aerospike/aerospike-helper | java/src/main/java/com/aerospike/helper/query/QueryEngine.java | QueryEngine.insert | public void insert(Statement stmt, KeyQualifier keyQualifier, List<Bin> bins, int ttl) {
Key key = keyQualifier.makeKey(stmt.getNamespace(), stmt.getSetName());
// Key key = new Key(stmt.getNamespace(), stmt.getSetName(), keyQualifier.getValue1());
this.client.put(this.insertPolicy, key, bins.toArray(new Bin[0]));
} | java | public void insert(Statement stmt, KeyQualifier keyQualifier, List<Bin> bins, int ttl) {
Key key = keyQualifier.makeKey(stmt.getNamespace(), stmt.getSetName());
// Key key = new Key(stmt.getNamespace(), stmt.getSetName(), keyQualifier.getValue1());
this.client.put(this.insertPolicy, key, bins.toArray(new Bin[0]));
} | [
"public",
"void",
"insert",
"(",
"Statement",
"stmt",
",",
"KeyQualifier",
"keyQualifier",
",",
"List",
"<",
"Bin",
">",
"bins",
",",
"int",
"ttl",
")",
"{",
"Key",
"key",
"=",
"keyQualifier",
".",
"makeKey",
"(",
"stmt",
".",
"getNamespace",
"(",
")",
... | inserts a record, with a time to live, using a Statement and KeyQualifier. If the record exists, and exception will be thrown.
@param stmt A Statement object containing Namespace and Set
@param keyQualifier KeyQualifier containin the primary key
@param bins A list of Bins to insert
@param ttl The record time to live in seconds | [
"inserts",
"a",
"record",
"with",
"a",
"time",
"to",
"live",
"using",
"a",
"Statement",
"and",
"KeyQualifier",
".",
"If",
"the",
"record",
"exists",
"and",
"exception",
"will",
"be",
"thrown",
"."
] | eeb4a1464bc8d9c6716c014d250c8166b5caa82d | https://github.com/aerospike/aerospike-helper/blob/eeb4a1464bc8d9c6716c014d250c8166b5caa82d/java/src/main/java/com/aerospike/helper/query/QueryEngine.java#L389-L393 | train |
aerospike/aerospike-helper | java/src/main/java/com/aerospike/helper/query/QueryEngine.java | QueryEngine.update | public Map<String, Long> update(Statement stmt, List<Bin> bins, Qualifier... qualifiers) {
if (qualifiers != null && qualifiers.length == 1 && qualifiers[0] instanceof KeyQualifier) {
KeyQualifier keyQualifier = (KeyQualifier) qualifiers[0];
Key key = keyQualifier.makeKey(stmt.getNamespace(), stmt.getSetName());
this.client.put(this.updatePolicy, key, bins.toArray(new Bin[0]));
Map<String, Long> result = new HashMap<String, Long>();
result.put("read", 1L);
result.put("write", 1L);
return result;
} else {
KeyRecordIterator results = select(stmt, true, null, qualifiers);
return update(results, bins);
}
} | java | public Map<String, Long> update(Statement stmt, List<Bin> bins, Qualifier... qualifiers) {
if (qualifiers != null && qualifiers.length == 1 && qualifiers[0] instanceof KeyQualifier) {
KeyQualifier keyQualifier = (KeyQualifier) qualifiers[0];
Key key = keyQualifier.makeKey(stmt.getNamespace(), stmt.getSetName());
this.client.put(this.updatePolicy, key, bins.toArray(new Bin[0]));
Map<String, Long> result = new HashMap<String, Long>();
result.put("read", 1L);
result.put("write", 1L);
return result;
} else {
KeyRecordIterator results = select(stmt, true, null, qualifiers);
return update(results, bins);
}
} | [
"public",
"Map",
"<",
"String",
",",
"Long",
">",
"update",
"(",
"Statement",
"stmt",
",",
"List",
"<",
"Bin",
">",
"bins",
",",
"Qualifier",
"...",
"qualifiers",
")",
"{",
"if",
"(",
"qualifiers",
"!=",
"null",
"&&",
"qualifiers",
".",
"length",
"==",... | The list of Bins will update each record that match the Qualifiers supplied.
@param stmt A Statement object containing Namespace and Set
@param bins A list of Bin objects with the values to updated
@param qualifiers Zero or more Qualifiers for the update query
@return returns a Map containing a number of successful updates. The Map will contain 2 keys "read" and "write", the values will be the count of successful operations | [
"The",
"list",
"of",
"Bins",
"will",
"update",
"each",
"record",
"that",
"match",
"the",
"Qualifiers",
"supplied",
"."
] | eeb4a1464bc8d9c6716c014d250c8166b5caa82d | https://github.com/aerospike/aerospike-helper/blob/eeb4a1464bc8d9c6716c014d250c8166b5caa82d/java/src/main/java/com/aerospike/helper/query/QueryEngine.java#L412-L425 | train |
aerospike/aerospike-helper | java/src/main/java/com/aerospike/helper/query/QueryEngine.java | QueryEngine.delete | public Map<String, Long> delete(Statement stmt, Qualifier... qualifiers) {
if (qualifiers == null || qualifiers.length == 0) {
/*
* There are no qualifiers, so delete every record in the set
* using Scan UDF delete
*/
ExecuteTask task = client.execute(null, stmt, QUERY_MODULE, "delete_record");
task.waitTillComplete();
return null;
}
if (qualifiers.length == 1 && qualifiers[0] instanceof KeyQualifier) {
KeyQualifier keyQualifier = (KeyQualifier) qualifiers[0];
Key key = keyQualifier.makeKey(stmt.getNamespace(), stmt.getSetName());
this.client.delete(null, key);
Map<String, Long> map = new HashMap<String, Long>();
map.put("read", 1L);
map.put("write", 1L);
return map;
}
KeyRecordIterator results = select(stmt, true, null, qualifiers);
return delete(results);
} | java | public Map<String, Long> delete(Statement stmt, Qualifier... qualifiers) {
if (qualifiers == null || qualifiers.length == 0) {
/*
* There are no qualifiers, so delete every record in the set
* using Scan UDF delete
*/
ExecuteTask task = client.execute(null, stmt, QUERY_MODULE, "delete_record");
task.waitTillComplete();
return null;
}
if (qualifiers.length == 1 && qualifiers[0] instanceof KeyQualifier) {
KeyQualifier keyQualifier = (KeyQualifier) qualifiers[0];
Key key = keyQualifier.makeKey(stmt.getNamespace(), stmt.getSetName());
this.client.delete(null, key);
Map<String, Long> map = new HashMap<String, Long>();
map.put("read", 1L);
map.put("write", 1L);
return map;
}
KeyRecordIterator results = select(stmt, true, null, qualifiers);
return delete(results);
} | [
"public",
"Map",
"<",
"String",
",",
"Long",
">",
"delete",
"(",
"Statement",
"stmt",
",",
"Qualifier",
"...",
"qualifiers",
")",
"{",
"if",
"(",
"qualifiers",
"==",
"null",
"||",
"qualifiers",
".",
"length",
"==",
"0",
")",
"{",
"/*\n\t\t\t * There are no... | Deletes the records specified by the Statement and Qualifiers
@param stmt A Statement object containing Namespace and Set
@param qualifiers Zero or more Qualifiers for the update query
@return returns a Map containing a number of successful updates. The Map will contain 2 keys "read" and "write", the values will be the count of successful operations | [
"Deletes",
"the",
"records",
"specified",
"by",
"the",
"Statement",
"and",
"Qualifiers"
] | eeb4a1464bc8d9c6716c014d250c8166b5caa82d | https://github.com/aerospike/aerospike-helper/blob/eeb4a1464bc8d9c6716c014d250c8166b5caa82d/java/src/main/java/com/aerospike/helper/query/QueryEngine.java#L463-L485 | train |
aerospike/aerospike-helper | java/src/main/java/com/aerospike/helper/query/QueryEngine.java | QueryEngine.refreshNamespaces | public synchronized void refreshNamespaces() {
/*
* cache namespaces
*/
if (this.namespaceCache == null) {
this.namespaceCache = new TreeMap<String, Namespace>();
Node[] nodes = client.getNodes();
for (Node node : nodes) {
try {
String namespaceString = Info.request(getInfoPolicy(), node, "namespaces");
if (!namespaceString.isEmpty()) {
String[] namespaceList = namespaceString.split(";");
for (String namespace : namespaceList) {
Namespace ns = this.namespaceCache.get(namespace);
if (ns == null) {
ns = new Namespace(namespace);
this.namespaceCache.put(namespace, ns);
}
refreshNamespaceData(node, ns);
}
}
} catch (AerospikeException e) {
log.error("Error geting Namespaces ", e);
}
}
}
} | java | public synchronized void refreshNamespaces() {
/*
* cache namespaces
*/
if (this.namespaceCache == null) {
this.namespaceCache = new TreeMap<String, Namespace>();
Node[] nodes = client.getNodes();
for (Node node : nodes) {
try {
String namespaceString = Info.request(getInfoPolicy(), node, "namespaces");
if (!namespaceString.isEmpty()) {
String[] namespaceList = namespaceString.split(";");
for (String namespace : namespaceList) {
Namespace ns = this.namespaceCache.get(namespace);
if (ns == null) {
ns = new Namespace(namespace);
this.namespaceCache.put(namespace, ns);
}
refreshNamespaceData(node, ns);
}
}
} catch (AerospikeException e) {
log.error("Error geting Namespaces ", e);
}
}
}
} | [
"public",
"synchronized",
"void",
"refreshNamespaces",
"(",
")",
"{",
"/*\n\t\t * cache namespaces\n\t\t */",
"if",
"(",
"this",
".",
"namespaceCache",
"==",
"null",
")",
"{",
"this",
".",
"namespaceCache",
"=",
"new",
"TreeMap",
"<",
"String",
",",
"Namespace",
... | refreshes the cached Namespace information | [
"refreshes",
"the",
"cached",
"Namespace",
"information"
] | eeb4a1464bc8d9c6716c014d250c8166b5caa82d | https://github.com/aerospike/aerospike-helper/blob/eeb4a1464bc8d9c6716c014d250c8166b5caa82d/java/src/main/java/com/aerospike/helper/query/QueryEngine.java#L581-L608 | train |
aerospike/aerospike-helper | java/src/main/java/com/aerospike/helper/query/QueryEngine.java | QueryEngine.refreshIndexes | public synchronized void refreshIndexes() {
/*
* cache index by Bin name
*/
if (this.indexCache == null)
this.indexCache = new TreeMap<String, Index>();
Node[] nodes = client.getNodes();
for (Node node : nodes) {
if (node.isActive()) {
try {
String indexString = Info.request(getInfoPolicy(), node, "sindex");
if (!indexString.isEmpty()) {
String[] indexList = indexString.split(";");
for (String oneIndexString : indexList) {
Index index = new Index(oneIndexString);
this.indexCache.put(index.toKeyString(), index);
}
}
break;
} catch (AerospikeException e) {
log.error("Error geting Index informaton", e);
}
}
}
} | java | public synchronized void refreshIndexes() {
/*
* cache index by Bin name
*/
if (this.indexCache == null)
this.indexCache = new TreeMap<String, Index>();
Node[] nodes = client.getNodes();
for (Node node : nodes) {
if (node.isActive()) {
try {
String indexString = Info.request(getInfoPolicy(), node, "sindex");
if (!indexString.isEmpty()) {
String[] indexList = indexString.split(";");
for (String oneIndexString : indexList) {
Index index = new Index(oneIndexString);
this.indexCache.put(index.toKeyString(), index);
}
}
break;
} catch (AerospikeException e) {
log.error("Error geting Index informaton", e);
}
}
}
} | [
"public",
"synchronized",
"void",
"refreshIndexes",
"(",
")",
"{",
"/*\n\t\t * cache index by Bin name\n\t\t */",
"if",
"(",
"this",
".",
"indexCache",
"==",
"null",
")",
"this",
".",
"indexCache",
"=",
"new",
"TreeMap",
"<",
"String",
",",
"Index",
">",
"(",
... | refreshes the Index cache from the Cluster | [
"refreshes",
"the",
"Index",
"cache",
"from",
"the",
"Cluster"
] | eeb4a1464bc8d9c6716c014d250c8166b5caa82d | https://github.com/aerospike/aerospike-helper/blob/eeb4a1464bc8d9c6716c014d250c8166b5caa82d/java/src/main/java/com/aerospike/helper/query/QueryEngine.java#L651-L676 | train |
aerospike/aerospike-helper | java/src/main/java/com/aerospike/helper/query/QueryEngine.java | QueryEngine.refreshModules | public synchronized void refreshModules() {
if (this.moduleCache == null)
this.moduleCache = new TreeMap<String, Module>();
boolean loadedModules = false;
Node[] nodes = client.getNodes();
for (Node node : nodes) {
try {
String packagesString = Info.request(infoPolicy, node, "udf-list");
if (!packagesString.isEmpty()) {
String[] packagesList = packagesString.split(";");
for (String pkgString : packagesList) {
Module module = new Module(pkgString);
String udfString = Info.request(infoPolicy, node, "udf-get:filename=" + module.getName());
module.setDetailInfo(udfString);//gen=qgmyp0d8hQNvJdnR42X3BXgUGPE=;type=LUA;recordContent=bG9jYWwgZnVuY3Rpb24gcHV0QmluKHIsbmFtZSx2YWx1ZSkKICAgIGlmIG5vdCBhZXJvc3Bpa2U6ZXhpc3RzKHIpIHRoZW4gYWVyb3NwaWtlOmNyZWF0ZShyKSBlbmQKICAgIHJbbmFtZV0gPSB2YWx1ZQogICAgYWVyb3NwaWtlOnVwZGF0ZShyKQplbmQKCi0tIFNldCBhIHBhcnRpY3VsYXIgYmluCmZ1bmN0aW9uIHdyaXRlQmluKHIsbmFtZSx2YWx1ZSkKICAgIHB1dEJpbihyLG5hbWUsdmFsdWUpCmVuZAoKLS0gR2V0IGEgcGFydGljdWxhciBiaW4KZnVuY3Rpb24gcmVhZEJpbihyLG5hbWUpCiAgICByZXR1cm4gcltuYW1lXQplbmQKCi0tIFJldHVybiBnZW5lcmF0aW9uIGNvdW50IG9mIHJlY29yZApmdW5jdGlvbiBnZXRHZW5lcmF0aW9uKHIpCiAgICByZXR1cm4gcmVjb3JkLmdlbihyKQplbmQKCi0tIFVwZGF0ZSByZWNvcmQgb25seSBpZiBnZW4gaGFzbid0IGNoYW5nZWQKZnVuY3Rpb24gd3JpdGVJZkdlbmVyYXRpb25Ob3RDaGFuZ2VkKHIsbmFtZSx2YWx1ZSxnZW4pCiAgICBpZiByZWNvcmQuZ2VuKHIpID09IGdlbiB0aGVuCiAgICAgICAgcltuYW1lXSA9IHZhbHVlCiAgICAgICAgYWVyb3NwaWtlOnVwZGF0ZShyKQogICAgZW5kCmVuZAoKLS0gU2V0IGEgcGFydGljdWxhciBiaW4gb25seSBpZiByZWNvcmQgZG9lcyBub3QgYWxyZWFkeSBleGlzdC4KZnVuY3Rpb24gd3JpdGVVbmlxdWUocixuYW1lLHZhbHVlKQogICAgaWYgbm90IGFlcm9zcGlrZTpleGlzdHMocikgdGhlbiAKICAgICAgICBhZXJvc3Bpa2U6Y3JlYXRlKHIpIAogICAgICAgIHJbbmFtZV0gPSB2YWx1ZQogICAgICAgIGFlcm9zcGlrZTp1cGRhdGUocikKICAgIGVuZAplbmQKCi0tIFZhbGlkYXRlIHZhbHVlIGJlZm9yZSB3cml0aW5nLgpmdW5jdGlvbiB3cml0ZVdpdGhWYWxpZGF0aW9uKHIsbmFtZSx2YWx1ZSkKICAgIGlmICh2YWx1ZSA+PSAxIGFuZCB2YWx1ZSA8PSAxMCkgdGhlbgogICAgICAgIHB1dEJpbihyLG5hbWUsdmFsdWUpCiAgICBlbHNlCiAgICAgICAgZXJyb3IoIjEwMDA6SW52YWxpZCB2YWx1ZSIpIAogICAgZW5kCmVuZAoKLS0gUmVjb3JkIGNvbnRhaW5zIHR3byBpbnRlZ2VyIGJpbnMsIG5hbWUxIGFuZCBuYW1lMi4KLS0gRm9yIG5hbWUxIGV2ZW4gaW50ZWdlcnMsIGFkZCB2YWx1ZSB0byBleGlzdGluZyBuYW1lMSBiaW4uCi0tIEZvciBuYW1lMSBpbnRlZ2VycyB3aXRoIGEgbXVsdGlwbGUgb2YgNSwgZGVsZXRlIG5hbWUyIGJpbi4KLS0gRm9yIG5hbWUxIGludGVnZXJzIHdpdGggYSBtdWx0aXBsZSBvZiA5LCBkZWxldGUgcmVjb3JkLiAKZnVuY3Rpb24gcHJvY2Vzc1JlY29yZChyLG5hbWUxLG5hbWUyLGFkZFZhbHVlKQogICAgbG9jYWwgdiA9IHJbbmFtZTFdCgogICAgaWYgKHYgJSA5ID09IDApIHRoZW4KICAgICAgICBhZXJvc3Bpa2U6cmVtb3ZlKHIpCiAgICAgICAgcmV0dXJuCiAgICBlbmQKCiAgICBpZiAodiAlIDUgPT0gMCkgdGhlbgogICAgICAgIHJbbmFtZTJdID0gbmlsCiAgICAgICAgYWVyb3NwaWtlOnVwZGF0ZShyKQogICAgICAgIHJldHVybgogICAgZW5kCgogICAgaWYgKHYgJSAyID09IDApIHRoZW4KICAgICAgICByW25hbWUxXSA9IHYgKyBhZGRWYWx1ZQogICAgICAgIGFlcm9zcGlrZTp1cGRhdGUocikKICAgIGVuZAplbmQKCi0tIFNldCBleHBpcmF0aW9uIG9mIHJlY29yZAotLSBmdW5jdGlvbiBleHBpcmUocix0dGwpCi0tICAgIGlmIHJlY29yZC50dGwocikgPT0gZ2VuIHRoZW4KLS0gICAgICAgIHJbbmFtZV0gPSB2YWx1ZQotLSAgICAgICAgYWVyb3NwaWtlOnVwZGF0ZShyKQotLSAgICBlbmQKLS0gZW5kCg==;
this.moduleCache.put(module.getName(), module);
}
}
loadedModules = true;
break;
} catch (AerospikeException e) {
}
}
if (!loadedModules) {
throw new ClusterRefreshError("Cannot find UDF modules");
}
} | java | public synchronized void refreshModules() {
if (this.moduleCache == null)
this.moduleCache = new TreeMap<String, Module>();
boolean loadedModules = false;
Node[] nodes = client.getNodes();
for (Node node : nodes) {
try {
String packagesString = Info.request(infoPolicy, node, "udf-list");
if (!packagesString.isEmpty()) {
String[] packagesList = packagesString.split(";");
for (String pkgString : packagesList) {
Module module = new Module(pkgString);
String udfString = Info.request(infoPolicy, node, "udf-get:filename=" + module.getName());
module.setDetailInfo(udfString);//gen=qgmyp0d8hQNvJdnR42X3BXgUGPE=;type=LUA;recordContent=bG9jYWwgZnVuY3Rpb24gcHV0QmluKHIsbmFtZSx2YWx1ZSkKICAgIGlmIG5vdCBhZXJvc3Bpa2U6ZXhpc3RzKHIpIHRoZW4gYWVyb3NwaWtlOmNyZWF0ZShyKSBlbmQKICAgIHJbbmFtZV0gPSB2YWx1ZQogICAgYWVyb3NwaWtlOnVwZGF0ZShyKQplbmQKCi0tIFNldCBhIHBhcnRpY3VsYXIgYmluCmZ1bmN0aW9uIHdyaXRlQmluKHIsbmFtZSx2YWx1ZSkKICAgIHB1dEJpbihyLG5hbWUsdmFsdWUpCmVuZAoKLS0gR2V0IGEgcGFydGljdWxhciBiaW4KZnVuY3Rpb24gcmVhZEJpbihyLG5hbWUpCiAgICByZXR1cm4gcltuYW1lXQplbmQKCi0tIFJldHVybiBnZW5lcmF0aW9uIGNvdW50IG9mIHJlY29yZApmdW5jdGlvbiBnZXRHZW5lcmF0aW9uKHIpCiAgICByZXR1cm4gcmVjb3JkLmdlbihyKQplbmQKCi0tIFVwZGF0ZSByZWNvcmQgb25seSBpZiBnZW4gaGFzbid0IGNoYW5nZWQKZnVuY3Rpb24gd3JpdGVJZkdlbmVyYXRpb25Ob3RDaGFuZ2VkKHIsbmFtZSx2YWx1ZSxnZW4pCiAgICBpZiByZWNvcmQuZ2VuKHIpID09IGdlbiB0aGVuCiAgICAgICAgcltuYW1lXSA9IHZhbHVlCiAgICAgICAgYWVyb3NwaWtlOnVwZGF0ZShyKQogICAgZW5kCmVuZAoKLS0gU2V0IGEgcGFydGljdWxhciBiaW4gb25seSBpZiByZWNvcmQgZG9lcyBub3QgYWxyZWFkeSBleGlzdC4KZnVuY3Rpb24gd3JpdGVVbmlxdWUocixuYW1lLHZhbHVlKQogICAgaWYgbm90IGFlcm9zcGlrZTpleGlzdHMocikgdGhlbiAKICAgICAgICBhZXJvc3Bpa2U6Y3JlYXRlKHIpIAogICAgICAgIHJbbmFtZV0gPSB2YWx1ZQogICAgICAgIGFlcm9zcGlrZTp1cGRhdGUocikKICAgIGVuZAplbmQKCi0tIFZhbGlkYXRlIHZhbHVlIGJlZm9yZSB3cml0aW5nLgpmdW5jdGlvbiB3cml0ZVdpdGhWYWxpZGF0aW9uKHIsbmFtZSx2YWx1ZSkKICAgIGlmICh2YWx1ZSA+PSAxIGFuZCB2YWx1ZSA8PSAxMCkgdGhlbgogICAgICAgIHB1dEJpbihyLG5hbWUsdmFsdWUpCiAgICBlbHNlCiAgICAgICAgZXJyb3IoIjEwMDA6SW52YWxpZCB2YWx1ZSIpIAogICAgZW5kCmVuZAoKLS0gUmVjb3JkIGNvbnRhaW5zIHR3byBpbnRlZ2VyIGJpbnMsIG5hbWUxIGFuZCBuYW1lMi4KLS0gRm9yIG5hbWUxIGV2ZW4gaW50ZWdlcnMsIGFkZCB2YWx1ZSB0byBleGlzdGluZyBuYW1lMSBiaW4uCi0tIEZvciBuYW1lMSBpbnRlZ2VycyB3aXRoIGEgbXVsdGlwbGUgb2YgNSwgZGVsZXRlIG5hbWUyIGJpbi4KLS0gRm9yIG5hbWUxIGludGVnZXJzIHdpdGggYSBtdWx0aXBsZSBvZiA5LCBkZWxldGUgcmVjb3JkLiAKZnVuY3Rpb24gcHJvY2Vzc1JlY29yZChyLG5hbWUxLG5hbWUyLGFkZFZhbHVlKQogICAgbG9jYWwgdiA9IHJbbmFtZTFdCgogICAgaWYgKHYgJSA5ID09IDApIHRoZW4KICAgICAgICBhZXJvc3Bpa2U6cmVtb3ZlKHIpCiAgICAgICAgcmV0dXJuCiAgICBlbmQKCiAgICBpZiAodiAlIDUgPT0gMCkgdGhlbgogICAgICAgIHJbbmFtZTJdID0gbmlsCiAgICAgICAgYWVyb3NwaWtlOnVwZGF0ZShyKQogICAgICAgIHJldHVybgogICAgZW5kCgogICAgaWYgKHYgJSAyID09IDApIHRoZW4KICAgICAgICByW25hbWUxXSA9IHYgKyBhZGRWYWx1ZQogICAgICAgIGFlcm9zcGlrZTp1cGRhdGUocikKICAgIGVuZAplbmQKCi0tIFNldCBleHBpcmF0aW9uIG9mIHJlY29yZAotLSBmdW5jdGlvbiBleHBpcmUocix0dGwpCi0tICAgIGlmIHJlY29yZC50dGwocikgPT0gZ2VuIHRoZW4KLS0gICAgICAgIHJbbmFtZV0gPSB2YWx1ZQotLSAgICAgICAgYWVyb3NwaWtlOnVwZGF0ZShyKQotLSAgICBlbmQKLS0gZW5kCg==;
this.moduleCache.put(module.getName(), module);
}
}
loadedModules = true;
break;
} catch (AerospikeException e) {
}
}
if (!loadedModules) {
throw new ClusterRefreshError("Cannot find UDF modules");
}
} | [
"public",
"synchronized",
"void",
"refreshModules",
"(",
")",
"{",
"if",
"(",
"this",
".",
"moduleCache",
"==",
"null",
")",
"this",
".",
"moduleCache",
"=",
"new",
"TreeMap",
"<",
"String",
",",
"Module",
">",
"(",
")",
";",
"boolean",
"loadedModules",
... | refreshes the Module cache from the cluster. The Module cache contains a list of register UDF modules. | [
"refreshes",
"the",
"Module",
"cache",
"from",
"the",
"cluster",
".",
"The",
"Module",
"cache",
"contains",
"a",
"list",
"of",
"register",
"UDF",
"modules",
"."
] | eeb4a1464bc8d9c6716c014d250c8166b5caa82d | https://github.com/aerospike/aerospike-helper/blob/eeb4a1464bc8d9c6716c014d250c8166b5caa82d/java/src/main/java/com/aerospike/helper/query/QueryEngine.java#L691-L718 | train |
aerospike/aerospike-helper | java/src/main/java/com/aerospike/helper/query/QueryEngine.java | QueryEngine.close | @Override
public void close() throws IOException {
if (this.client != null)
this.client.close();
indexCache.clear();
indexCache = null;
updatePolicy = null;
insertPolicy = null;
infoPolicy = null;
queryPolicy = null;
moduleCache.clear();
moduleCache = null;
} | java | @Override
public void close() throws IOException {
if (this.client != null)
this.client.close();
indexCache.clear();
indexCache = null;
updatePolicy = null;
insertPolicy = null;
infoPolicy = null;
queryPolicy = null;
moduleCache.clear();
moduleCache = null;
} | [
"@",
"Override",
"public",
"void",
"close",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"this",
".",
"client",
"!=",
"null",
")",
"this",
".",
"client",
".",
"close",
"(",
")",
";",
"indexCache",
".",
"clear",
"(",
")",
";",
"indexCache",
"=",... | closes the QueryEngine, clearing the cached information are closing the AerospikeClient.
Once the QueryEngine is closed, it cannot be used, nor can the AerospikeClient. | [
"closes",
"the",
"QueryEngine",
"clearing",
"the",
"cached",
"information",
"are",
"closing",
"the",
"AerospikeClient",
".",
"Once",
"the",
"QueryEngine",
"is",
"closed",
"it",
"cannot",
"be",
"used",
"nor",
"can",
"the",
"AerospikeClient",
"."
] | eeb4a1464bc8d9c6716c014d250c8166b5caa82d | https://github.com/aerospike/aerospike-helper/blob/eeb4a1464bc8d9c6716c014d250c8166b5caa82d/java/src/main/java/com/aerospike/helper/query/QueryEngine.java#L734-L746 | train |
aerospike/aerospike-helper | java/src/main/java/com/aerospike/helper/model/Index.java | Index.setIndexInfo | public void setIndexInfo(String info) {
//ns=phobos_sindex:set=longevity:indexname=str_100_idx:num_bins=1:bins=str_100_bin:type=TEXT:sync_state=synced:state=RW;
//ns=test:set=Customers:indexname=mail_index_userss:bin=email:type=STRING:indextype=LIST:path=email:sync_state=synced:state=RW
if (!info.isEmpty()) {
String[] parts = info.split(":");
for (String part : parts) {
kvPut(part);
}
}
} | java | public void setIndexInfo(String info) {
//ns=phobos_sindex:set=longevity:indexname=str_100_idx:num_bins=1:bins=str_100_bin:type=TEXT:sync_state=synced:state=RW;
//ns=test:set=Customers:indexname=mail_index_userss:bin=email:type=STRING:indextype=LIST:path=email:sync_state=synced:state=RW
if (!info.isEmpty()) {
String[] parts = info.split(":");
for (String part : parts) {
kvPut(part);
}
}
} | [
"public",
"void",
"setIndexInfo",
"(",
"String",
"info",
")",
"{",
"//ns=phobos_sindex:set=longevity:indexname=str_100_idx:num_bins=1:bins=str_100_bin:type=TEXT:sync_state=synced:state=RW;",
"//ns=test:set=Customers:indexname=mail_index_userss:bin=email:type=STRING:indextype=LIST:path=email:sync_s... | Populates the Index object from an "info" message from Aerospike
@param info Info string from node | [
"Populates",
"the",
"Index",
"object",
"from",
"an",
"info",
"message",
"from",
"Aerospike"
] | eeb4a1464bc8d9c6716c014d250c8166b5caa82d | https://github.com/aerospike/aerospike-helper/blob/eeb4a1464bc8d9c6716c014d250c8166b5caa82d/java/src/main/java/com/aerospike/helper/model/Index.java#L61-L70 | train |
aerospike/aerospike-helper | java/src/main/java/com/aerospike/helper/collections/TimeSeries.java | TimeSeries.clear | public void clear() {
Record record = this.client.get(null, key, tailBin, topBin);
long tail = record.getLong(tailBin);
long top = record.getLong(topBin);
List<Key> subKeys = subrecordKeys(tail, top);
for (Key key : subKeys) {
this.client.delete(null, key);
}
} | java | public void clear() {
Record record = this.client.get(null, key, tailBin, topBin);
long tail = record.getLong(tailBin);
long top = record.getLong(topBin);
List<Key> subKeys = subrecordKeys(tail, top);
for (Key key : subKeys) {
this.client.delete(null, key);
}
} | [
"public",
"void",
"clear",
"(",
")",
"{",
"Record",
"record",
"=",
"this",
".",
"client",
".",
"get",
"(",
"null",
",",
"key",
",",
"tailBin",
",",
"topBin",
")",
";",
"long",
"tail",
"=",
"record",
".",
"getLong",
"(",
"tailBin",
")",
";",
"long",... | clear all elements from the TimeSeries associated with a Key | [
"clear",
"all",
"elements",
"from",
"the",
"TimeSeries",
"associated",
"with",
"a",
"Key"
] | eeb4a1464bc8d9c6716c014d250c8166b5caa82d | https://github.com/aerospike/aerospike-helper/blob/eeb4a1464bc8d9c6716c014d250c8166b5caa82d/java/src/main/java/com/aerospike/helper/collections/TimeSeries.java#L122-L130 | train |
aerospike/aerospike-helper | java/src/main/java/com/aerospike/helper/collections/TimeSeries.java | TimeSeries.destroy | public void destroy() {
clear();
this.client.operate(null, key, Operation.put(Bin.asNull(binName)));
} | java | public void destroy() {
clear();
this.client.operate(null, key, Operation.put(Bin.asNull(binName)));
} | [
"public",
"void",
"destroy",
"(",
")",
"{",
"clear",
"(",
")",
";",
"this",
".",
"client",
".",
"operate",
"(",
"null",
",",
"key",
",",
"Operation",
".",
"put",
"(",
"Bin",
".",
"asNull",
"(",
"binName",
")",
")",
")",
";",
"}"
] | Destroy the TimeSeries associated with a Key | [
"Destroy",
"the",
"TimeSeries",
"associated",
"with",
"a",
"Key"
] | eeb4a1464bc8d9c6716c014d250c8166b5caa82d | https://github.com/aerospike/aerospike-helper/blob/eeb4a1464bc8d9c6716c014d250c8166b5caa82d/java/src/main/java/com/aerospike/helper/collections/TimeSeries.java#L135-L138 | train |
aerospike/aerospike-helper | java/src/main/java/com/aerospike/helper/collections/TimeSeries.java | TimeSeries.subrecordKeys | List<Key> subrecordKeys(long lowTime, long highTime) {
List<Key> keys = new ArrayList<Key>();
long lowBucketNumber = bucketNumber(lowTime);
long highBucketNumber = bucketNumber(highTime);
for (long index = lowBucketNumber; index <= highBucketNumber; index += this.bucketSize) {
keys.add(formSubrecordKey(index));
}
return keys;
} | java | List<Key> subrecordKeys(long lowTime, long highTime) {
List<Key> keys = new ArrayList<Key>();
long lowBucketNumber = bucketNumber(lowTime);
long highBucketNumber = bucketNumber(highTime);
for (long index = lowBucketNumber; index <= highBucketNumber; index += this.bucketSize) {
keys.add(formSubrecordKey(index));
}
return keys;
} | [
"List",
"<",
"Key",
">",
"subrecordKeys",
"(",
"long",
"lowTime",
",",
"long",
"highTime",
")",
"{",
"List",
"<",
"Key",
">",
"keys",
"=",
"new",
"ArrayList",
"<",
"Key",
">",
"(",
")",
";",
"long",
"lowBucketNumber",
"=",
"bucketNumber",
"(",
"lowTime... | creates a list of Keys in the time series
@param lowTime
@param highTime
@return | [
"creates",
"a",
"list",
"of",
"Keys",
"in",
"the",
"time",
"series"
] | eeb4a1464bc8d9c6716c014d250c8166b5caa82d | https://github.com/aerospike/aerospike-helper/blob/eeb4a1464bc8d9c6716c014d250c8166b5caa82d/java/src/main/java/com/aerospike/helper/collections/TimeSeries.java#L147-L155 | train |
aerospike/aerospike-helper | java/src/main/java/com/aerospike/helper/collections/LargeList.java | LargeList.update | public void update(Value value) {
if (size() == 0) {
add(value);
} else {
Key subKey = makeSubKey(value);
client.put(this.policy, subKey, new Bin(ListElementBinName, value));
}
} | java | public void update(Value value) {
if (size() == 0) {
add(value);
} else {
Key subKey = makeSubKey(value);
client.put(this.policy, subKey, new Bin(ListElementBinName, value));
}
} | [
"public",
"void",
"update",
"(",
"Value",
"value",
")",
"{",
"if",
"(",
"size",
"(",
")",
"==",
"0",
")",
"{",
"add",
"(",
"value",
")",
";",
"}",
"else",
"{",
"Key",
"subKey",
"=",
"makeSubKey",
"(",
"value",
")",
";",
"client",
".",
"put",
"(... | Update value in list if key exists. Add value to list if key does not exist.
If value is a map, the key is identified by "key" entry. Otherwise, the value is the key.
If large list does not exist, create it.
@param value value to update | [
"Update",
"value",
"in",
"list",
"if",
"key",
"exists",
".",
"Add",
"value",
"to",
"list",
"if",
"key",
"does",
"not",
"exist",
".",
"If",
"value",
"is",
"a",
"map",
"the",
"key",
"is",
"identified",
"by",
"key",
"entry",
".",
"Otherwise",
"the",
"va... | eeb4a1464bc8d9c6716c014d250c8166b5caa82d | https://github.com/aerospike/aerospike-helper/blob/eeb4a1464bc8d9c6716c014d250c8166b5caa82d/java/src/main/java/com/aerospike/helper/collections/LargeList.java#L224-L231 | train |
aerospike/aerospike-helper | java/src/main/java/com/aerospike/helper/collections/LargeList.java | LargeList.remove | public void remove(Value value) {
Key subKey = makeSubKey(value);
List<byte[]> digestList = getDigestList();
int index = digestList.indexOf(subKey.digest);
client.delete(this.policy, subKey);
client.operate(this.policy, this.key, ListOperation.remove(this.binNameString, index));
} | java | public void remove(Value value) {
Key subKey = makeSubKey(value);
List<byte[]> digestList = getDigestList();
int index = digestList.indexOf(subKey.digest);
client.delete(this.policy, subKey);
client.operate(this.policy, this.key, ListOperation.remove(this.binNameString, index));
} | [
"public",
"void",
"remove",
"(",
"Value",
"value",
")",
"{",
"Key",
"subKey",
"=",
"makeSubKey",
"(",
"value",
")",
";",
"List",
"<",
"byte",
"[",
"]",
">",
"digestList",
"=",
"getDigestList",
"(",
")",
";",
"int",
"index",
"=",
"digestList",
".",
"i... | Delete value from list.
@param value The value to value to delete | [
"Delete",
"value",
"from",
"list",
"."
] | eeb4a1464bc8d9c6716c014d250c8166b5caa82d | https://github.com/aerospike/aerospike-helper/blob/eeb4a1464bc8d9c6716c014d250c8166b5caa82d/java/src/main/java/com/aerospike/helper/collections/LargeList.java#L264-L270 | train |
aerospike/aerospike-helper | java/src/main/java/com/aerospike/helper/collections/LargeList.java | LargeList.remove | public void remove(List<Value> values) {
Key[] keys = makeSubKeys(values);
List<byte[]> digestList = getDigestList();
// int startIndex = digestList.IndexOf (subKey.digest);
// int count = values.Count;
// foreach (Key key in keys){
//
// client.Delete (this.policy, key);
// }
// client.Operate(this.policy, this.key, ListOperation.Remove(this.binNameString, startIndex, count));
for (Key key : keys) {
client.delete(this.policy, key);
digestList.remove(key.digest);
}
client.put(this.policy, this.key, new Bin(this.binNameString, digestList));
} | java | public void remove(List<Value> values) {
Key[] keys = makeSubKeys(values);
List<byte[]> digestList = getDigestList();
// int startIndex = digestList.IndexOf (subKey.digest);
// int count = values.Count;
// foreach (Key key in keys){
//
// client.Delete (this.policy, key);
// }
// client.Operate(this.policy, this.key, ListOperation.Remove(this.binNameString, startIndex, count));
for (Key key : keys) {
client.delete(this.policy, key);
digestList.remove(key.digest);
}
client.put(this.policy, this.key, new Bin(this.binNameString, digestList));
} | [
"public",
"void",
"remove",
"(",
"List",
"<",
"Value",
">",
"values",
")",
"{",
"Key",
"[",
"]",
"keys",
"=",
"makeSubKeys",
"(",
"values",
")",
";",
"List",
"<",
"byte",
"[",
"]",
">",
"digestList",
"=",
"getDigestList",
"(",
")",
";",
"//\t\tint st... | Delete values from list.
@param values A list of values to delete | [
"Delete",
"values",
"from",
"list",
"."
] | eeb4a1464bc8d9c6716c014d250c8166b5caa82d | https://github.com/aerospike/aerospike-helper/blob/eeb4a1464bc8d9c6716c014d250c8166b5caa82d/java/src/main/java/com/aerospike/helper/collections/LargeList.java#L277-L295 | train |
aerospike/aerospike-helper | java/src/main/java/com/aerospike/helper/collections/LargeList.java | LargeList.find | @SuppressWarnings("serial")
public List<?> find(Value value) throws AerospikeException {
Key subKey = makeSubKey(value);
Record record = client.get(this.policy, subKey, ListElementBinName);
if (record != null) {
final Object result = record.getValue(ListElementBinName);
return new ArrayList<Object>() {{
add(result);
}};
} else {
return null;
}
} | java | @SuppressWarnings("serial")
public List<?> find(Value value) throws AerospikeException {
Key subKey = makeSubKey(value);
Record record = client.get(this.policy, subKey, ListElementBinName);
if (record != null) {
final Object result = record.getValue(ListElementBinName);
return new ArrayList<Object>() {{
add(result);
}};
} else {
return null;
}
} | [
"@",
"SuppressWarnings",
"(",
"\"serial\"",
")",
"public",
"List",
"<",
"?",
">",
"find",
"(",
"Value",
"value",
")",
"throws",
"AerospikeException",
"{",
"Key",
"subKey",
"=",
"makeSubKey",
"(",
"value",
")",
";",
"Record",
"record",
"=",
"client",
".",
... | Select values from list.
@param value value to select
@return list of entries selected | [
"Select",
"values",
"from",
"list",
"."
] | eeb4a1464bc8d9c6716c014d250c8166b5caa82d | https://github.com/aerospike/aerospike-helper/blob/eeb4a1464bc8d9c6716c014d250c8166b5caa82d/java/src/main/java/com/aerospike/helper/collections/LargeList.java#L354-L366 | train |
aerospike/aerospike-helper | java/src/main/java/com/aerospike/helper/collections/LargeList.java | LargeList.destroy | public void destroy() {
List<byte[]> digestList = getDigestList();
client.put(this.policy, this.key, Bin.asNull(this.binNameString));
for (byte[] digest : digestList) {
Key subKey = new Key(this.key.namespace, digest, null, null);
client.delete(this.policy, subKey);
}
} | java | public void destroy() {
List<byte[]> digestList = getDigestList();
client.put(this.policy, this.key, Bin.asNull(this.binNameString));
for (byte[] digest : digestList) {
Key subKey = new Key(this.key.namespace, digest, null, null);
client.delete(this.policy, subKey);
}
} | [
"public",
"void",
"destroy",
"(",
")",
"{",
"List",
"<",
"byte",
"[",
"]",
">",
"digestList",
"=",
"getDigestList",
"(",
")",
";",
"client",
".",
"put",
"(",
"this",
".",
"policy",
",",
"this",
".",
"key",
",",
"Bin",
".",
"asNull",
"(",
"this",
... | Delete bin containing the list. | [
"Delete",
"bin",
"containing",
"the",
"list",
"."
] | eeb4a1464bc8d9c6716c014d250c8166b5caa82d | https://github.com/aerospike/aerospike-helper/blob/eeb4a1464bc8d9c6716c014d250c8166b5caa82d/java/src/main/java/com/aerospike/helper/collections/LargeList.java#L503-L512 | train |
aerospike/aerospike-helper | java/src/main/java/com/aerospike/helper/collections/LargeList.java | LargeList.size | public int size() {
Record record = client.operate(this.policy, this.key, ListOperation.size(this.binNameString));
if (record != null) {
return record.getInt(this.binNameString);
}
return 0;
} | java | public int size() {
Record record = client.operate(this.policy, this.key, ListOperation.size(this.binNameString));
if (record != null) {
return record.getInt(this.binNameString);
}
return 0;
} | [
"public",
"int",
"size",
"(",
")",
"{",
"Record",
"record",
"=",
"client",
".",
"operate",
"(",
"this",
".",
"policy",
",",
"this",
".",
"key",
",",
"ListOperation",
".",
"size",
"(",
"this",
".",
"binNameString",
")",
")",
";",
"if",
"(",
"record",
... | Return size of list.
@return size of list. | [
"Return",
"size",
"of",
"list",
"."
] | eeb4a1464bc8d9c6716c014d250c8166b5caa82d | https://github.com/aerospike/aerospike-helper/blob/eeb4a1464bc8d9c6716c014d250c8166b5caa82d/java/src/main/java/com/aerospike/helper/collections/LargeList.java#L519-L525 | train |
aerospike/aerospike-helper | java/src/main/java/com/aerospike/helper/Utils.java | Utils.printInfo | public static void printInfo(String title, String infoString) {
if (infoString == null) {
System.out.println("Null info string");
return;
}
String[] outerParts = infoString.split(";");
System.out.println(title);
for (String s : outerParts) {
String[] innerParts = s.split(":");
for (String parts : innerParts) {
System.out.println("\t" + parts);
}
System.out.println();
}
} | java | public static void printInfo(String title, String infoString) {
if (infoString == null) {
System.out.println("Null info string");
return;
}
String[] outerParts = infoString.split(";");
System.out.println(title);
for (String s : outerParts) {
String[] innerParts = s.split(":");
for (String parts : innerParts) {
System.out.println("\t" + parts);
}
System.out.println();
}
} | [
"public",
"static",
"void",
"printInfo",
"(",
"String",
"title",
",",
"String",
"infoString",
")",
"{",
"if",
"(",
"infoString",
"==",
"null",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"Null info string\"",
")",
";",
"return",
";",
"}",
"Str... | Prints an "Info" message with a title to System.out
@param title Title to be printed
@param infoString Info string from cluster | [
"Prints",
"an",
"Info",
"message",
"with",
"a",
"title",
"to",
"System",
".",
"out"
] | eeb4a1464bc8d9c6716c014d250c8166b5caa82d | https://github.com/aerospike/aerospike-helper/blob/eeb4a1464bc8d9c6716c014d250c8166b5caa82d/java/src/main/java/com/aerospike/helper/Utils.java#L36-L51 | train |
aerospike/aerospike-helper | java/src/main/java/com/aerospike/helper/Utils.java | Utils.infoAll | public static String infoAll(AerospikeClient client, String cmd) {
Node[] nodes = client.getNodes();
StringBuilder results = new StringBuilder();
for (Node node : nodes) {
results.append(Info.request(node.getHost().name, node.getHost().port, cmd)).append("\n");
}
return results.toString();
} | java | public static String infoAll(AerospikeClient client, String cmd) {
Node[] nodes = client.getNodes();
StringBuilder results = new StringBuilder();
for (Node node : nodes) {
results.append(Info.request(node.getHost().name, node.getHost().port, cmd)).append("\n");
}
return results.toString();
} | [
"public",
"static",
"String",
"infoAll",
"(",
"AerospikeClient",
"client",
",",
"String",
"cmd",
")",
"{",
"Node",
"[",
"]",
"nodes",
"=",
"client",
".",
"getNodes",
"(",
")",
";",
"StringBuilder",
"results",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"... | Sends an "Info" command to all nodes in the cluster
@param client AerospikeClient instance
@param cmd Info command to be sent to the cluster
@return A string containing the results from all nodes in the cluster | [
"Sends",
"an",
"Info",
"command",
"to",
"all",
"nodes",
"in",
"the",
"cluster"
] | eeb4a1464bc8d9c6716c014d250c8166b5caa82d | https://github.com/aerospike/aerospike-helper/blob/eeb4a1464bc8d9c6716c014d250c8166b5caa82d/java/src/main/java/com/aerospike/helper/Utils.java#L60-L67 | train |
aerospike/aerospike-helper | java/src/main/java/com/aerospike/helper/Utils.java | Utils.toMap | public static Map<String, String> toMap(String source) {
HashMap<String, String> responses = new HashMap<String, String>();
String values[] = source.split(";");
for (String value : values) {
String nv[] = value.split("=");
if (nv.length >= 2) {
responses.put(nv[0], nv[1]);
} else if (nv.length == 1) {
responses.put(nv[0], null);
}
}
return responses.size() != 0 ? responses : null;
} | java | public static Map<String, String> toMap(String source) {
HashMap<String, String> responses = new HashMap<String, String>();
String values[] = source.split(";");
for (String value : values) {
String nv[] = value.split("=");
if (nv.length >= 2) {
responses.put(nv[0], nv[1]);
} else if (nv.length == 1) {
responses.put(nv[0], null);
}
}
return responses.size() != 0 ? responses : null;
} | [
"public",
"static",
"Map",
"<",
"String",
",",
"String",
">",
"toMap",
"(",
"String",
"source",
")",
"{",
"HashMap",
"<",
"String",
",",
"String",
">",
"responses",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"String",
"v... | converts the results of an "Info" command to a Map
@param source Info string to be converted
@return A map containing the info string fields | [
"converts",
"the",
"results",
"of",
"an",
"Info",
"command",
"to",
"a",
"Map"
] | eeb4a1464bc8d9c6716c014d250c8166b5caa82d | https://github.com/aerospike/aerospike-helper/blob/eeb4a1464bc8d9c6716c014d250c8166b5caa82d/java/src/main/java/com/aerospike/helper/Utils.java#L75-L90 | train |
aerospike/aerospike-helper | java/src/main/java/com/aerospike/helper/Utils.java | Utils.toNameValuePair | public static List<NameValuePair> toNameValuePair(Object parent, Map<String, String> map) {
List<NameValuePair> list = new ArrayList<NameValuePair>();
for (String key : map.keySet()) {
NameValuePair nvp = new NameValuePair(parent, key, map.get(key));
list.add(nvp);
}
return list;
} | java | public static List<NameValuePair> toNameValuePair(Object parent, Map<String, String> map) {
List<NameValuePair> list = new ArrayList<NameValuePair>();
for (String key : map.keySet()) {
NameValuePair nvp = new NameValuePair(parent, key, map.get(key));
list.add(nvp);
}
return list;
} | [
"public",
"static",
"List",
"<",
"NameValuePair",
">",
"toNameValuePair",
"(",
"Object",
"parent",
",",
"Map",
"<",
"String",
",",
"String",
">",
"map",
")",
"{",
"List",
"<",
"NameValuePair",
">",
"list",
"=",
"new",
"ArrayList",
"<",
"NameValuePair",
">"... | Creates a List of NameValuePair from a Map
@param parent The Parent object to be added to the NameValuePair of each element
@param map The map to be converted
@return The List of NameValuePairs | [
"Creates",
"a",
"List",
"of",
"NameValuePair",
"from",
"a",
"Map"
] | eeb4a1464bc8d9c6716c014d250c8166b5caa82d | https://github.com/aerospike/aerospike-helper/blob/eeb4a1464bc8d9c6716c014d250c8166b5caa82d/java/src/main/java/com/aerospike/helper/Utils.java#L99-L106 | train |
filosganga/geogson | core/src/main/java/com/github/filosganga/geogson/model/MultiPoint.java | MultiPoint.of | public static MultiPoint of(Stream<Point> points) {
return of(points.collect(Collectors.toList()));
} | java | public static MultiPoint of(Stream<Point> points) {
return of(points.collect(Collectors.toList()));
} | [
"public",
"static",
"MultiPoint",
"of",
"(",
"Stream",
"<",
"Point",
">",
"points",
")",
"{",
"return",
"of",
"(",
"points",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
")",
";",
"}"
] | Creates a MultiPoint from the given points.
@param points The {@link Point} Iterable.
@return MultiPoint | [
"Creates",
"a",
"MultiPoint",
"from",
"the",
"given",
"points",
"."
] | f0c7b0adfecc174caa8a03a6c19d301c7a47d4a0 | https://github.com/filosganga/geogson/blob/f0c7b0adfecc174caa8a03a6c19d301c7a47d4a0/core/src/main/java/com/github/filosganga/geogson/model/MultiPoint.java#L75-L77 | train |
filosganga/geogson | core/src/main/java/com/github/filosganga/geogson/model/LinearRing.java | LinearRing.of | public static LinearRing of(Iterable<Point> points) {
LinearPositions.Builder builder = LinearPositions.builder();
for(Point point : points) {
builder.addSinglePosition(point.positions());
}
return new LinearRing(builder.build());
} | java | public static LinearRing of(Iterable<Point> points) {
LinearPositions.Builder builder = LinearPositions.builder();
for(Point point : points) {
builder.addSinglePosition(point.positions());
}
return new LinearRing(builder.build());
} | [
"public",
"static",
"LinearRing",
"of",
"(",
"Iterable",
"<",
"Point",
">",
"points",
")",
"{",
"LinearPositions",
".",
"Builder",
"builder",
"=",
"LinearPositions",
".",
"builder",
"(",
")",
";",
"for",
"(",
"Point",
"point",
":",
"points",
")",
"{",
"b... | Create a LinearRing from the given points.
@param points Point Iterable composed at least by 4 points, with the first and the last that are the same.
@return a LinearRing | [
"Create",
"a",
"LinearRing",
"from",
"the",
"given",
"points",
"."
] | f0c7b0adfecc174caa8a03a6c19d301c7a47d4a0 | https://github.com/filosganga/geogson/blob/f0c7b0adfecc174caa8a03a6c19d301c7a47d4a0/core/src/main/java/com/github/filosganga/geogson/model/LinearRing.java#L52-L58 | train |
filosganga/geogson | core/src/main/java/com/github/filosganga/geogson/model/LinearGeometry.java | LinearGeometry.points | public List<Point> points() {
return positions().children().stream()
.map(Point::new)
.collect(Collectors.toList());
} | java | public List<Point> points() {
return positions().children().stream()
.map(Point::new)
.collect(Collectors.toList());
} | [
"public",
"List",
"<",
"Point",
">",
"points",
"(",
")",
"{",
"return",
"positions",
"(",
")",
".",
"children",
"(",
")",
".",
"stream",
"(",
")",
".",
"map",
"(",
"Point",
"::",
"new",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
... | Returns the points composing this Geometry.
@return {@code Iterable<Point>} a Guava lazy Iterable. | [
"Returns",
"the",
"points",
"composing",
"this",
"Geometry",
"."
] | f0c7b0adfecc174caa8a03a6c19d301c7a47d4a0 | https://github.com/filosganga/geogson/blob/f0c7b0adfecc174caa8a03a6c19d301c7a47d4a0/core/src/main/java/com/github/filosganga/geogson/model/LinearGeometry.java#L68-L73 | train |
filosganga/geogson | core/src/main/java/com/github/filosganga/geogson/model/Point.java | Point.from | public static Point from(double lon, double lat, double alt) {
return new Point(new SinglePosition(lon, lat, alt));
} | java | public static Point from(double lon, double lat, double alt) {
return new Point(new SinglePosition(lon, lat, alt));
} | [
"public",
"static",
"Point",
"from",
"(",
"double",
"lon",
",",
"double",
"lat",
",",
"double",
"alt",
")",
"{",
"return",
"new",
"Point",
"(",
"new",
"SinglePosition",
"(",
"lon",
",",
"lat",
",",
"alt",
")",
")",
";",
"}"
] | Create a Point from the given coordinates.
@param lon The x axis value. Longitude in a geographic projection.
@param lat The y axis value. Latitude in a geographic projection.
@param alt The z axis value. Altitude in a geographic projection.
@return Point instance. | [
"Create",
"a",
"Point",
"from",
"the",
"given",
"coordinates",
"."
] | f0c7b0adfecc174caa8a03a6c19d301c7a47d4a0 | https://github.com/filosganga/geogson/blob/f0c7b0adfecc174caa8a03a6c19d301c7a47d4a0/core/src/main/java/com/github/filosganga/geogson/model/Point.java#L59-L61 | train |
hal/core | gui/src/main/java/org/useware/kernel/gui/behaviour/InteractionCoordinator.java | InteractionCoordinator.fireEvent | public void fireEvent(final Event<?> event)
{
Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
@Override
public void execute() {
bus.fireEventFromSource(event, dialog.getInterfaceModel().getId());
}
});
} | java | public void fireEvent(final Event<?> event)
{
Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
@Override
public void execute() {
bus.fireEventFromSource(event, dialog.getInterfaceModel().getId());
}
});
} | [
"public",
"void",
"fireEvent",
"(",
"final",
"Event",
"<",
"?",
">",
"event",
")",
"{",
"Scheduler",
".",
"get",
"(",
")",
".",
"scheduleDeferred",
"(",
"new",
"Scheduler",
".",
"ScheduledCommand",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"execu... | Event delegation. Uses the dialog ID as source.
@param event | [
"Event",
"delegation",
".",
"Uses",
"the",
"dialog",
"ID",
"as",
"source",
"."
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/useware/kernel/gui/behaviour/InteractionCoordinator.java#L118-L127 | train |
hal/core | gui/src/main/java/org/useware/kernel/gui/behaviour/InteractionCoordinator.java | InteractionCoordinator.onInteractionEvent | @Override
public void onInteractionEvent(final InteractionEvent event) {
QName id = event.getId();
QName source = (QName)event.getSource();
final Set<Procedure> collection = procedures.get(id);
Procedure execution = null;
if(collection!=null)
{
for(Procedure consumer : collection) {
// TODO: This isn't optimal (creation of new resource with every comparison)
Resource<ResourceType> resource = new Resource<ResourceType>(id, ResourceType.Interaction);
resource.setSource(source);
boolean justified = consumer.getJustification() == null
|| source.equals(consumer.getJustification());
if(consumer.doesConsume(resource) && justified)
{
execution = consumer;
break;
}
}
}
if(null==execution)
{
Window.alert("No procedure for " + event);
Log.warn("No procedure for " + event);
}
else if(execution.getPrecondition().isMet(getStatementContext(source))) // guarded
{
try {
execution.getCommand().execute(InteractionCoordinator.this.dialog, event.getPayload());
} catch (Throwable e) {
Log.error("Failed to execute procedure "+execution, e);
}
}
} | java | @Override
public void onInteractionEvent(final InteractionEvent event) {
QName id = event.getId();
QName source = (QName)event.getSource();
final Set<Procedure> collection = procedures.get(id);
Procedure execution = null;
if(collection!=null)
{
for(Procedure consumer : collection) {
// TODO: This isn't optimal (creation of new resource with every comparison)
Resource<ResourceType> resource = new Resource<ResourceType>(id, ResourceType.Interaction);
resource.setSource(source);
boolean justified = consumer.getJustification() == null
|| source.equals(consumer.getJustification());
if(consumer.doesConsume(resource) && justified)
{
execution = consumer;
break;
}
}
}
if(null==execution)
{
Window.alert("No procedure for " + event);
Log.warn("No procedure for " + event);
}
else if(execution.getPrecondition().isMet(getStatementContext(source))) // guarded
{
try {
execution.getCommand().execute(InteractionCoordinator.this.dialog, event.getPayload());
} catch (Throwable e) {
Log.error("Failed to execute procedure "+execution, e);
}
}
} | [
"@",
"Override",
"public",
"void",
"onInteractionEvent",
"(",
"final",
"InteractionEvent",
"event",
")",
"{",
"QName",
"id",
"=",
"event",
".",
"getId",
"(",
")",
";",
"QName",
"source",
"=",
"(",
"QName",
")",
"event",
".",
"getSource",
"(",
")",
";",
... | Find the corresponding procedures and execute it.
@param event | [
"Find",
"the",
"corresponding",
"procedures",
"and",
"execute",
"it",
"."
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/useware/kernel/gui/behaviour/InteractionCoordinator.java#L169-L210 | train |
hal/core | gui/src/main/java/org/jboss/as/console/client/shared/subsys/jca/XADataSourcePresenter.java | XADataSourcePresenter.onSaveDatasource | public void onSaveDatasource(AddressTemplate template, final String dsName, final Map changeset) {
dataSourceStore.saveDatasource(template, dsName, changeset,
new SimpleCallback<ResponseWrapper<Boolean>>() {
@Override
public void onSuccess(ResponseWrapper<Boolean> response) {
if (response.getUnderlying()) {
Console.info(Console.MESSAGES.saved("Datasource " + dsName));
} else {
Console.error(Console.MESSAGES.saveFailed("Datasource ") + dsName,
response.getResponse().toString());
}
loadXADataSource();
}
});
} | java | public void onSaveDatasource(AddressTemplate template, final String dsName, final Map changeset) {
dataSourceStore.saveDatasource(template, dsName, changeset,
new SimpleCallback<ResponseWrapper<Boolean>>() {
@Override
public void onSuccess(ResponseWrapper<Boolean> response) {
if (response.getUnderlying()) {
Console.info(Console.MESSAGES.saved("Datasource " + dsName));
} else {
Console.error(Console.MESSAGES.saveFailed("Datasource ") + dsName,
response.getResponse().toString());
}
loadXADataSource();
}
});
} | [
"public",
"void",
"onSaveDatasource",
"(",
"AddressTemplate",
"template",
",",
"final",
"String",
"dsName",
",",
"final",
"Map",
"changeset",
")",
"{",
"dataSourceStore",
".",
"saveDatasource",
"(",
"template",
",",
"dsName",
",",
"changeset",
",",
"new",
"Simpl... | Saves the changes into data-source or xa-data-source using ModelNodeAdapter instead of autobean DataSource
@param template The AddressTemplate to use
@param dsName the datasource name
@param changeset | [
"Saves",
"the",
"changes",
"into",
"data",
"-",
"source",
"or",
"xa",
"-",
"data",
"-",
"source",
"using",
"ModelNodeAdapter",
"instead",
"of",
"autobean",
"DataSource"
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/jboss/as/console/client/shared/subsys/jca/XADataSourcePresenter.java#L506-L521 | train |
hal/core | gui/src/main/java/org/jboss/as/console/client/shared/subsys/jca/XADataSourceEditor.java | XADataSourceEditor.onCreateProperty | @Override
public void onCreateProperty(String reference, PropertyRecord prop) {
presenter.onCreateXAProperty(reference, prop);
} | java | @Override
public void onCreateProperty(String reference, PropertyRecord prop) {
presenter.onCreateXAProperty(reference, prop);
} | [
"@",
"Override",
"public",
"void",
"onCreateProperty",
"(",
"String",
"reference",
",",
"PropertyRecord",
"prop",
")",
"{",
"presenter",
".",
"onCreateXAProperty",
"(",
"reference",
",",
"prop",
")",
";",
"}"
] | property management below | [
"property",
"management",
"below"
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/jboss/as/console/client/shared/subsys/jca/XADataSourceEditor.java#L324-L327 | train |
hal/core | processors/src/main/java/org/jboss/hal/processors/AbstractHalProcessor.java | AbstractHalProcessor.code | protected void code(String template, String packageName, String className, Supplier<Map<String, Object>> context) {
StringBuffer code = generate(template, context);
writeCode(packageName, className, code);
} | java | protected void code(String template, String packageName, String className, Supplier<Map<String, Object>> context) {
StringBuffer code = generate(template, context);
writeCode(packageName, className, code);
} | [
"protected",
"void",
"code",
"(",
"String",
"template",
",",
"String",
"packageName",
",",
"String",
"className",
",",
"Supplier",
"<",
"Map",
"<",
"String",
",",
"Object",
">",
">",
"context",
")",
"{",
"StringBuffer",
"code",
"=",
"generate",
"(",
"templ... | Generates and writes java code in one call.
@param template the relative template name (w/o path or package name)
@param packageName the package name
@param className the class name
@param context a function to create the templates' context | [
"Generates",
"and",
"writes",
"java",
"code",
"in",
"one",
"call",
"."
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/processors/src/main/java/org/jboss/hal/processors/AbstractHalProcessor.java#L195-L198 | train |
hal/core | processors/src/main/java/org/jboss/hal/processors/AbstractHalProcessor.java | AbstractHalProcessor.resource | protected void resource(String template, String packageName, String resourceName, Supplier<Map<String, Object>> context) {
StringBuffer code = generate(template, context);
writeResource(packageName, resourceName, code);
} | java | protected void resource(String template, String packageName, String resourceName, Supplier<Map<String, Object>> context) {
StringBuffer code = generate(template, context);
writeResource(packageName, resourceName, code);
} | [
"protected",
"void",
"resource",
"(",
"String",
"template",
",",
"String",
"packageName",
",",
"String",
"resourceName",
",",
"Supplier",
"<",
"Map",
"<",
"String",
",",
"Object",
">",
">",
"context",
")",
"{",
"StringBuffer",
"code",
"=",
"generate",
"(",
... | Generates and writes a resource in one call.
@param template the relative template name (w/o path or package name)
@param packageName the package name
@param resourceName the resource name
@param context a function to create the templates' context | [
"Generates",
"and",
"writes",
"a",
"resource",
"in",
"one",
"call",
"."
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/processors/src/main/java/org/jboss/hal/processors/AbstractHalProcessor.java#L208-L211 | train |
hal/core | gui/src/main/java/org/useware/kernel/gui/behaviour/DialogState.java | DialogState.flushChildScopes | public void flushChildScopes(QName unitId) {
Set<Integer> childScopes = findChildScopes(unitId);
for(Integer scopeId : childScopes)
{
MutableContext mutableContext = statementContexts.get(scopeId);
mutableContext.clearStatements();
}
} | java | public void flushChildScopes(QName unitId) {
Set<Integer> childScopes = findChildScopes(unitId);
for(Integer scopeId : childScopes)
{
MutableContext mutableContext = statementContexts.get(scopeId);
mutableContext.clearStatements();
}
} | [
"public",
"void",
"flushChildScopes",
"(",
"QName",
"unitId",
")",
"{",
"Set",
"<",
"Integer",
">",
"childScopes",
"=",
"findChildScopes",
"(",
"unitId",
")",
";",
"for",
"(",
"Integer",
"scopeId",
":",
"childScopes",
")",
"{",
"MutableContext",
"mutableContex... | Flush the scope of unit and all children.
@param unitId | [
"Flush",
"the",
"scope",
"of",
"unit",
"and",
"all",
"children",
"."
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/useware/kernel/gui/behaviour/DialogState.java#L115-L122 | train |
hal/core | gui/src/main/java/org/useware/kernel/gui/behaviour/DialogState.java | DialogState.isWithinActiveScope | public boolean isWithinActiveScope(final QName unitId) {
final Node<Scope> self = dialog.getScopeModel().findNode(
dialog.findUnit(unitId).getScopeId()
);
final Scope scopeOfUnit = self.getData();
int parentScopeId = getParentScope(unitId).getId();
Scope activeScope = activeChildMapping.get(parentScopeId);
boolean selfIsActive = activeScope != null && activeScope.equals(scopeOfUnit);
if(selfIsActive) // only verify parents if necessary
{
LinkedList<Scope> parentScopes = new LinkedList<Scope>();
getParentScopes(self, parentScopes);
boolean inActiveParent = false;
for(Scope parent : parentScopes)
{
if(!parent.isActive())
{
inActiveParent = true;
break;
}
}
return inActiveParent;
}
return selfIsActive;
} | java | public boolean isWithinActiveScope(final QName unitId) {
final Node<Scope> self = dialog.getScopeModel().findNode(
dialog.findUnit(unitId).getScopeId()
);
final Scope scopeOfUnit = self.getData();
int parentScopeId = getParentScope(unitId).getId();
Scope activeScope = activeChildMapping.get(parentScopeId);
boolean selfIsActive = activeScope != null && activeScope.equals(scopeOfUnit);
if(selfIsActive) // only verify parents if necessary
{
LinkedList<Scope> parentScopes = new LinkedList<Scope>();
getParentScopes(self, parentScopes);
boolean inActiveParent = false;
for(Scope parent : parentScopes)
{
if(!parent.isActive())
{
inActiveParent = true;
break;
}
}
return inActiveParent;
}
return selfIsActive;
} | [
"public",
"boolean",
"isWithinActiveScope",
"(",
"final",
"QName",
"unitId",
")",
"{",
"final",
"Node",
"<",
"Scope",
">",
"self",
"=",
"dialog",
".",
"getScopeModel",
"(",
")",
".",
"findNode",
"(",
"dialog",
".",
"findUnit",
"(",
"unitId",
")",
".",
"g... | Is within active scope when itself and all it's parent scopes are active as well.
This is necessary to ensure access to statements from parent scopes.
@param unitId
@return | [
"Is",
"within",
"active",
"scope",
"when",
"itself",
"and",
"all",
"it",
"s",
"parent",
"scopes",
"are",
"active",
"as",
"well",
".",
"This",
"is",
"necessary",
"to",
"ensure",
"access",
"to",
"statements",
"from",
"parent",
"scopes",
"."
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/useware/kernel/gui/behaviour/DialogState.java#L235-L264 | train |
hal/core | gui/src/main/java/org/jboss/as/console/client/v3/behaviour/ModelNodeAdapter.java | ModelNodeAdapter.fromChangeSet | public ModelNode fromChangeSet(ResourceAddress resourceAddress, Map<String, Object> changeSet) {
ModelNode define = new ModelNode();
define.get(ADDRESS).set(resourceAddress);
define.get(OP).set(WRITE_ATTRIBUTE_OPERATION);
ModelNode undefine = new ModelNode();
undefine.get(ADDRESS).set(resourceAddress);
undefine.get(OP).set(UNDEFINE_ATTRIBUTE);
ModelNode operation = new ModelNode();
operation.get(OP).set(COMPOSITE);
operation.get(ADDRESS).setEmptyList();
List<ModelNode> steps = new ArrayList<>();
for (String key : changeSet.keySet()) {
Object value = changeSet.get(key);
ModelNode step;
if (value.equals(FormItem.VALUE_SEMANTICS.UNDEFINED)) {
step = undefine.clone();
step.get(NAME).set(key);
} else {
step = define.clone();
step.get(NAME).set(key);
// set value, including type conversion
ModelNode valueNode = step.get(VALUE);
setValue(valueNode, value);
}
steps.add(step);
}
operation.get(STEPS).set(steps);
return operation;
} | java | public ModelNode fromChangeSet(ResourceAddress resourceAddress, Map<String, Object> changeSet) {
ModelNode define = new ModelNode();
define.get(ADDRESS).set(resourceAddress);
define.get(OP).set(WRITE_ATTRIBUTE_OPERATION);
ModelNode undefine = new ModelNode();
undefine.get(ADDRESS).set(resourceAddress);
undefine.get(OP).set(UNDEFINE_ATTRIBUTE);
ModelNode operation = new ModelNode();
operation.get(OP).set(COMPOSITE);
operation.get(ADDRESS).setEmptyList();
List<ModelNode> steps = new ArrayList<>();
for (String key : changeSet.keySet()) {
Object value = changeSet.get(key);
ModelNode step;
if (value.equals(FormItem.VALUE_SEMANTICS.UNDEFINED)) {
step = undefine.clone();
step.get(NAME).set(key);
} else {
step = define.clone();
step.get(NAME).set(key);
// set value, including type conversion
ModelNode valueNode = step.get(VALUE);
setValue(valueNode, value);
}
steps.add(step);
}
operation.get(STEPS).set(steps);
return operation;
} | [
"public",
"ModelNode",
"fromChangeSet",
"(",
"ResourceAddress",
"resourceAddress",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"changeSet",
")",
"{",
"ModelNode",
"define",
"=",
"new",
"ModelNode",
"(",
")",
";",
"define",
".",
"get",
"(",
"ADDRESS",
")",... | Turns a change set into a composite write attribute operation.
@param resourceAddress the address
@param changeSet the changed attributes
@return composite operation | [
"Turns",
"a",
"change",
"set",
"into",
"a",
"composite",
"write",
"attribute",
"operation",
"."
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/jboss/as/console/client/v3/behaviour/ModelNodeAdapter.java#L26-L61 | train |
hal/core | gui/src/main/java/org/jboss/as/console/client/domain/model/EntityFilter.java | EntityFilter.apply | public List<T> apply(Predicate<T> predicate, List<T> candidates)
{
List<T> filtered = new ArrayList<T>(candidates.size());
for(T entity : candidates)
{
if(predicate.appliesTo(entity))
filtered.add(entity);
}
return filtered;
} | java | public List<T> apply(Predicate<T> predicate, List<T> candidates)
{
List<T> filtered = new ArrayList<T>(candidates.size());
for(T entity : candidates)
{
if(predicate.appliesTo(entity))
filtered.add(entity);
}
return filtered;
} | [
"public",
"List",
"<",
"T",
">",
"apply",
"(",
"Predicate",
"<",
"T",
">",
"predicate",
",",
"List",
"<",
"T",
">",
"candidates",
")",
"{",
"List",
"<",
"T",
">",
"filtered",
"=",
"new",
"ArrayList",
"<",
"T",
">",
"(",
"candidates",
".",
"size",
... | Filter a list of entities through a predicate.
If the the predicate applies the entity will be included.
@param predicate
@param candidates
@return a subset of the actual list of candidates | [
"Filter",
"a",
"list",
"of",
"entities",
"through",
"a",
"predicate",
".",
"If",
"the",
"the",
"predicate",
"applies",
"the",
"entity",
"will",
"be",
"included",
"."
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/jboss/as/console/client/domain/model/EntityFilter.java#L42-L53 | train |
hal/core | gui/src/main/java/org/jboss/as/console/client/v3/deployment/Deployment.java | Deployment.parseSubsystems | static void parseSubsystems(ModelNode node, List<Subsystem> subsystems) {
List<Property> properties = node.get("subsystem").asPropertyList();
for (Property property : properties) {
Subsystem subsystem = new Subsystem(property.getName(), property.getValue());
subsystems.add(subsystem);
}
} | java | static void parseSubsystems(ModelNode node, List<Subsystem> subsystems) {
List<Property> properties = node.get("subsystem").asPropertyList();
for (Property property : properties) {
Subsystem subsystem = new Subsystem(property.getName(), property.getValue());
subsystems.add(subsystem);
}
} | [
"static",
"void",
"parseSubsystems",
"(",
"ModelNode",
"node",
",",
"List",
"<",
"Subsystem",
">",
"subsystems",
")",
"{",
"List",
"<",
"Property",
">",
"properties",
"=",
"node",
".",
"get",
"(",
"\"subsystem\"",
")",
".",
"asPropertyList",
"(",
")",
";",... | Expects a "subsystem" child resource. Modeled as a static helper method to make it usable from both
deployments and subdeployments. | [
"Expects",
"a",
"subsystem",
"child",
"resource",
".",
"Modeled",
"as",
"a",
"static",
"helper",
"method",
"to",
"make",
"it",
"usable",
"from",
"both",
"deployments",
"and",
"subdeployments",
"."
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/jboss/as/console/client/v3/deployment/Deployment.java#L46-L52 | train |
hal/core | gui/src/main/java/org/jboss/as/console/mbui/behaviour/LoadResourceProcedure.java | LoadResourceProcedure.assignKeyFromAddressNode | private static void assignKeyFromAddressNode(ModelNode payload, ModelNode address) {
List<Property> props = address.asPropertyList();
Property lastToken = props.get(props.size()-1);
payload.get("entity.key").set(lastToken.getValue().asString());
} | java | private static void assignKeyFromAddressNode(ModelNode payload, ModelNode address) {
List<Property> props = address.asPropertyList();
Property lastToken = props.get(props.size()-1);
payload.get("entity.key").set(lastToken.getValue().asString());
} | [
"private",
"static",
"void",
"assignKeyFromAddressNode",
"(",
"ModelNode",
"payload",
",",
"ModelNode",
"address",
")",
"{",
"List",
"<",
"Property",
">",
"props",
"=",
"address",
".",
"asPropertyList",
"(",
")",
";",
"Property",
"lastToken",
"=",
"props",
"."... | the model representations we use internally carry along the entity keys.
these are derived from the resource address, but will be available as synthetic resource attributes.
@param payload
@param address | [
"the",
"model",
"representations",
"we",
"use",
"internally",
"carry",
"along",
"the",
"entity",
"keys",
".",
"these",
"are",
"derived",
"from",
"the",
"resource",
"address",
"but",
"will",
"be",
"available",
"as",
"synthetic",
"resource",
"attributes",
"."
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/jboss/as/console/mbui/behaviour/LoadResourceProcedure.java#L179-L183 | train |
hal/core | gui/src/main/java/org/jboss/as/console/client/shared/subsys/ws/WebServiceView.java | WebServiceView.navigateHandlerView | public void navigateHandlerView() {
// if endpoint tab
if (tabLayoutpanel.getSelectedIndex() == 1) {
if (endpointHandlerPages.getPage() == 0)
endpointHandlerPages.showPage(1);
// else the client tab
} else if (tabLayoutpanel.getSelectedIndex() == 2) {
if (clientHandlerPages.getPage() == 0)
clientHandlerPages.showPage(1);
}
} | java | public void navigateHandlerView() {
// if endpoint tab
if (tabLayoutpanel.getSelectedIndex() == 1) {
if (endpointHandlerPages.getPage() == 0)
endpointHandlerPages.showPage(1);
// else the client tab
} else if (tabLayoutpanel.getSelectedIndex() == 2) {
if (clientHandlerPages.getPage() == 0)
clientHandlerPages.showPage(1);
}
} | [
"public",
"void",
"navigateHandlerView",
"(",
")",
"{",
"// if endpoint tab",
"if",
"(",
"tabLayoutpanel",
".",
"getSelectedIndex",
"(",
")",
"==",
"1",
")",
"{",
"if",
"(",
"endpointHandlerPages",
".",
"getPage",
"(",
")",
"==",
"0",
")",
"endpointHandlerPage... | to show a specific panel accordingly to the selected tab | [
"to",
"show",
"a",
"specific",
"panel",
"accordingly",
"to",
"the",
"selected",
"tab"
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/jboss/as/console/client/shared/subsys/ws/WebServiceView.java#L208-L218 | train |
hal/core | gui/src/main/java/org/jboss/as/console/client/semver/util/Stream.java | Stream.positiveLookaheadBefore | @SuppressWarnings("unchecked")
public <T extends ElementType> boolean positiveLookaheadBefore(
ElementType before,
T... expected
) {
Character lookahead;
for (int i = 1; i <= elements.length; i++) {
lookahead = lookahead(i);
if (before.isMatchedBy(lookahead)) {
break;
}
for (ElementType type : expected) {
if (type.isMatchedBy(lookahead)) {
return true;
}
}
}
return false;
} | java | @SuppressWarnings("unchecked")
public <T extends ElementType> boolean positiveLookaheadBefore(
ElementType before,
T... expected
) {
Character lookahead;
for (int i = 1; i <= elements.length; i++) {
lookahead = lookahead(i);
if (before.isMatchedBy(lookahead)) {
break;
}
for (ElementType type : expected) {
if (type.isMatchedBy(lookahead)) {
return true;
}
}
}
return false;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"T",
"extends",
"ElementType",
">",
"boolean",
"positiveLookaheadBefore",
"(",
"ElementType",
"before",
",",
"T",
"...",
"expected",
")",
"{",
"Character",
"lookahead",
";",
"for",
"(",
"int",
... | Checks if there exists an element in this stream of
the expected types before the specified type.
@param <T> represents the element type of this stream, removes the
"unchecked generic array creation for varargs parameter"
warnings
@param before the type before which to search
@param expected the expected types
@return {@code true} if there is an element of the expected types
before the specified type or {@code false} otherwise | [
"Checks",
"if",
"there",
"exists",
"an",
"element",
"in",
"this",
"stream",
"of",
"the",
"expected",
"types",
"before",
"the",
"specified",
"type",
"."
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/jboss/as/console/client/semver/util/Stream.java#L188-L206 | train |
hal/core | gui/src/main/java/org/jboss/as/console/client/v3/widgets/wizard/Wizard.java | Wizard.pushState | private void pushState(final S state) {
this.state = state;
header.setHTML(TEMPLATE.header(currentStep().getTitle()));
clearError();
body.showWidget(state); // will call onShow(C) for the current step
footer.back.setEnabled(state != initialState());
footer.next
.setHTML(
lastStates().contains(state) ? CONSTANTS.common_label_finish() : CONSTANTS.common_label_next());
} | java | private void pushState(final S state) {
this.state = state;
header.setHTML(TEMPLATE.header(currentStep().getTitle()));
clearError();
body.showWidget(state); // will call onShow(C) for the current step
footer.back.setEnabled(state != initialState());
footer.next
.setHTML(
lastStates().contains(state) ? CONSTANTS.common_label_finish() : CONSTANTS.common_label_next());
} | [
"private",
"void",
"pushState",
"(",
"final",
"S",
"state",
")",
"{",
"this",
".",
"state",
"=",
"state",
";",
"header",
".",
"setHTML",
"(",
"TEMPLATE",
".",
"header",
"(",
"currentStep",
"(",
")",
".",
"getTitle",
"(",
")",
")",
")",
";",
"clearErr... | Sets the current state to the specified state and updates the UI to reflect the current state.
@param state the next state | [
"Sets",
"the",
"current",
"state",
"to",
"the",
"specified",
"state",
"and",
"updates",
"the",
"UI",
"to",
"reflect",
"the",
"current",
"state",
"."
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/jboss/as/console/client/v3/widgets/wizard/Wizard.java#L269-L279 | train |
hal/core | gui/src/main/java/org/jboss/as/console/client/tools/ChildView.java | ChildView.showAddDialog | public void showAddDialog(final ModelNode address, boolean isSingleton, SecurityContext securityContext, ModelNode description) {
String resourceAddress = AddressUtils.asKey(address, isSingleton);
if(securityContext.getOperationPriviledge(resourceAddress, "add").isGranted()) {
_showAddDialog(address, isSingleton, securityContext, description);
}
else
{
Feedback.alert(Console.CONSTANTS.unauthorized(),
Console.CONSTANTS.unauthorizedAdd());
}
} | java | public void showAddDialog(final ModelNode address, boolean isSingleton, SecurityContext securityContext, ModelNode description) {
String resourceAddress = AddressUtils.asKey(address, isSingleton);
if(securityContext.getOperationPriviledge(resourceAddress, "add").isGranted()) {
_showAddDialog(address, isSingleton, securityContext, description);
}
else
{
Feedback.alert(Console.CONSTANTS.unauthorized(),
Console.CONSTANTS.unauthorizedAdd());
}
} | [
"public",
"void",
"showAddDialog",
"(",
"final",
"ModelNode",
"address",
",",
"boolean",
"isSingleton",
",",
"SecurityContext",
"securityContext",
",",
"ModelNode",
"description",
")",
"{",
"String",
"resourceAddress",
"=",
"AddressUtils",
".",
"asKey",
"(",
"addres... | Callback for creation of add dialogs.
Will be invoked once the presenter has loaded the resource description.
@param address
@param isSingleton
@param securityContext
@param description | [
"Callback",
"for",
"creation",
"of",
"add",
"dialogs",
".",
"Will",
"be",
"invoked",
"once",
"the",
"presenter",
"has",
"loaded",
"the",
"resource",
"description",
"."
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/jboss/as/console/client/tools/ChildView.java#L231-L244 | train |
hal/core | gui/src/main/java/org/jboss/as/console/client/shared/subsys/undertow/FilterPresenter.java | FilterPresenter.onSaveFilter | public void onSaveFilter(AddressTemplate address, String name, Map changeset) {
operationDelegate.onSaveResource(address, name, changeset, defaultSaveOpCallbacks);
} | java | public void onSaveFilter(AddressTemplate address, String name, Map changeset) {
operationDelegate.onSaveResource(address, name, changeset, defaultSaveOpCallbacks);
} | [
"public",
"void",
"onSaveFilter",
"(",
"AddressTemplate",
"address",
",",
"String",
"name",
",",
"Map",
"changeset",
")",
"{",
"operationDelegate",
".",
"onSaveResource",
"(",
"address",
",",
"name",
",",
"changeset",
",",
"defaultSaveOpCallbacks",
")",
";",
"}"... | Save an existent filter. | [
"Save",
"an",
"existent",
"filter",
"."
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/jboss/as/console/client/shared/subsys/undertow/FilterPresenter.java#L252-L254 | train |
hal/core | gui/src/main/java/org/jboss/as/console/server/proxy/XmlHttpProxyServlet.java | XmlHttpProxyServlet.configUpdated | private boolean configUpdated() {
try {
URL url = ctx.getResource(resourcesDir + configResource);
URLConnection con;
if (url == null) return false ;
con = url.openConnection();
long lastModified = con.getLastModified();
long XHP_LAST_MODIFIEDModified = 0;
if (ctx.getAttribute(XHP_LAST_MODIFIED) != null) {
XHP_LAST_MODIFIEDModified = ((Long)ctx.getAttribute(XHP_LAST_MODIFIED)).longValue();
} else {
ctx.setAttribute(XHP_LAST_MODIFIED, new Long(lastModified));
return false;
}
if (XHP_LAST_MODIFIEDModified < lastModified) {
ctx.setAttribute(XHP_LAST_MODIFIED, new Long(lastModified));
return true;
}
} catch (Exception ex) {
getLogger().severe("XmlHttpProxyServlet error checking configuration: " + ex);
}
return false;
} | java | private boolean configUpdated() {
try {
URL url = ctx.getResource(resourcesDir + configResource);
URLConnection con;
if (url == null) return false ;
con = url.openConnection();
long lastModified = con.getLastModified();
long XHP_LAST_MODIFIEDModified = 0;
if (ctx.getAttribute(XHP_LAST_MODIFIED) != null) {
XHP_LAST_MODIFIEDModified = ((Long)ctx.getAttribute(XHP_LAST_MODIFIED)).longValue();
} else {
ctx.setAttribute(XHP_LAST_MODIFIED, new Long(lastModified));
return false;
}
if (XHP_LAST_MODIFIEDModified < lastModified) {
ctx.setAttribute(XHP_LAST_MODIFIED, new Long(lastModified));
return true;
}
} catch (Exception ex) {
getLogger().severe("XmlHttpProxyServlet error checking configuration: " + ex);
}
return false;
} | [
"private",
"boolean",
"configUpdated",
"(",
")",
"{",
"try",
"{",
"URL",
"url",
"=",
"ctx",
".",
"getResource",
"(",
"resourcesDir",
"+",
"configResource",
")",
";",
"URLConnection",
"con",
";",
"if",
"(",
"url",
"==",
"null",
")",
"return",
"false",
";"... | Check to see if the configuration file has been updated so that it may be reloaded. | [
"Check",
"to",
"see",
"if",
"the",
"configuration",
"file",
"has",
"been",
"updated",
"so",
"that",
"it",
"may",
"be",
"reloaded",
"."
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/jboss/as/console/server/proxy/XmlHttpProxyServlet.java#L568-L590 | train |
hal/core | gui/src/main/java/org/useware/kernel/model/structure/InteractionUnit.java | InteractionUnit.getMapping | public <T extends Mapping> T getMapping(MappingType type)
{
return (T) mappings.get(type);
} | java | public <T extends Mapping> T getMapping(MappingType type)
{
return (T) mappings.get(type);
} | [
"public",
"<",
"T",
"extends",
"Mapping",
">",
"T",
"getMapping",
"(",
"MappingType",
"type",
")",
"{",
"return",
"(",
"T",
")",
"mappings",
".",
"get",
"(",
"type",
")",
";",
"}"
] | Get a mapping local to this unit.
@param type
@param <T>
@return | [
"Get",
"a",
"mapping",
"local",
"to",
"this",
"unit",
"."
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/useware/kernel/model/structure/InteractionUnit.java#L129-L132 | train |
hal/core | gui/src/main/java/org/useware/kernel/model/structure/InteractionUnit.java | InteractionUnit.findMapping | public <T extends Mapping> T findMapping(MappingType type)
{
return (T) this.findMapping(type, DEFAULT_PREDICATE);
} | java | public <T extends Mapping> T findMapping(MappingType type)
{
return (T) this.findMapping(type, DEFAULT_PREDICATE);
} | [
"public",
"<",
"T",
"extends",
"Mapping",
">",
"T",
"findMapping",
"(",
"MappingType",
"type",
")",
"{",
"return",
"(",
"T",
")",
"this",
".",
"findMapping",
"(",
"type",
",",
"DEFAULT_PREDICATE",
")",
";",
"}"
] | Finds the first mapping of a type within the hierarchy.
Uses parent delegation if the mapping cannot be found locally.
@param type
@return | [
"Finds",
"the",
"first",
"mapping",
"of",
"a",
"type",
"within",
"the",
"hierarchy",
".",
"Uses",
"parent",
"delegation",
"if",
"the",
"mapping",
"cannot",
"be",
"found",
"locally",
"."
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/useware/kernel/model/structure/InteractionUnit.java#L142-L145 | train |
hal/core | gui/src/main/java/org/jboss/as/console/server/proxy/XmlHttpProxy.java | XmlHttpProxy.transform | public void transform( InputStream xmlIS,
InputStream xslIS,
Map params,
OutputStream result,
String encoding) {
try {
TransformerFactory trFac = TransformerFactory.newInstance();
Transformer transformer = trFac.newTransformer(new StreamSource(xslIS));
Iterator it = params.keySet().iterator();
while (it.hasNext()) {
String key = (String)it.next();
transformer.setParameter(key, (String)params.get(key));
}
transformer.setOutputProperty("encoding", encoding);
transformer.transform(new StreamSource(xmlIS), new StreamResult(result));
} catch (Exception e) {
getLogger().severe("XmlHttpProxy: Exception with xslt " + e);
}
} | java | public void transform( InputStream xmlIS,
InputStream xslIS,
Map params,
OutputStream result,
String encoding) {
try {
TransformerFactory trFac = TransformerFactory.newInstance();
Transformer transformer = trFac.newTransformer(new StreamSource(xslIS));
Iterator it = params.keySet().iterator();
while (it.hasNext()) {
String key = (String)it.next();
transformer.setParameter(key, (String)params.get(key));
}
transformer.setOutputProperty("encoding", encoding);
transformer.transform(new StreamSource(xmlIS), new StreamResult(result));
} catch (Exception e) {
getLogger().severe("XmlHttpProxy: Exception with xslt " + e);
}
} | [
"public",
"void",
"transform",
"(",
"InputStream",
"xmlIS",
",",
"InputStream",
"xslIS",
",",
"Map",
"params",
",",
"OutputStream",
"result",
",",
"String",
"encoding",
")",
"{",
"try",
"{",
"TransformerFactory",
"trFac",
"=",
"TransformerFactory",
".",
"newInst... | Do the XSLT transformation | [
"Do",
"the",
"XSLT",
"transformation"
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/jboss/as/console/server/proxy/XmlHttpProxy.java#L370-L388 | train |
hal/core | dmr/src/main/java/org/jboss/dmr/client/ModelValue.java | ModelValue.jsonEscape | protected static String jsonEscape(final String orig) {
final int length = orig.length();
final StringBuilder builder = new StringBuilder(length + 32);
builder.append('"');
for (int i = 0; i < length; i = orig.offsetByCodePoints(i,1)) {
final char cp = orig.charAt(i);
switch(cp) {
case '"':
builder.append("\\\"");
break;
case '\\':
builder.append("\\\\");
break;
case '\b':
builder.append("\\b");
break;
case '\f':
builder.append("\\f");
break;
case '\n':
builder.append("\\n");
break;
case '\r':
builder.append("\\r");
break;
case '\t':
builder.append("\\t");
break;
case '/':
builder.append("\\/");
break;
default:
if((cp >= '\u0000' && cp <='\u001F') || (cp >= '\u007F' && cp <= '\u009F') || (cp >= '\u2000' && cp <= '\u20FF')){
final String hexString = Integer.toHexString(cp);
builder.append("\\u");
for(int k=0; k < 4-hexString.length(); k++) {
builder.append('0');
}
builder.append(hexString.toUpperCase());
} else {
builder.append(cp);
}
break;
}
}
builder.append('"');
return builder.toString();
} | java | protected static String jsonEscape(final String orig) {
final int length = orig.length();
final StringBuilder builder = new StringBuilder(length + 32);
builder.append('"');
for (int i = 0; i < length; i = orig.offsetByCodePoints(i,1)) {
final char cp = orig.charAt(i);
switch(cp) {
case '"':
builder.append("\\\"");
break;
case '\\':
builder.append("\\\\");
break;
case '\b':
builder.append("\\b");
break;
case '\f':
builder.append("\\f");
break;
case '\n':
builder.append("\\n");
break;
case '\r':
builder.append("\\r");
break;
case '\t':
builder.append("\\t");
break;
case '/':
builder.append("\\/");
break;
default:
if((cp >= '\u0000' && cp <='\u001F') || (cp >= '\u007F' && cp <= '\u009F') || (cp >= '\u2000' && cp <= '\u20FF')){
final String hexString = Integer.toHexString(cp);
builder.append("\\u");
for(int k=0; k < 4-hexString.length(); k++) {
builder.append('0');
}
builder.append(hexString.toUpperCase());
} else {
builder.append(cp);
}
break;
}
}
builder.append('"');
return builder.toString();
} | [
"protected",
"static",
"String",
"jsonEscape",
"(",
"final",
"String",
"orig",
")",
"{",
"final",
"int",
"length",
"=",
"orig",
".",
"length",
"(",
")",
";",
"final",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
"length",
"+",
"32",
")",
... | Escapes the original string for inclusion in a JSON string.
@param orig A string to be included in a JSON string.
@return The string appropriately escaped to produce valid JSON. | [
"Escapes",
"the",
"original",
"string",
"for",
"inclusion",
"in",
"a",
"JSON",
"string",
"."
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/dmr/src/main/java/org/jboss/dmr/client/ModelValue.java#L163-L210 | train |
hal/core | dmr/src/main/java/org/jboss/dmr/client/ModelValue.java | ModelValue.toJSONString | public String toJSONString(final boolean compact) {
final StringBuilder builder = new StringBuilder();
formatAsJSON(builder, 0, !compact);
return builder.toString();
} | java | public String toJSONString(final boolean compact) {
final StringBuilder builder = new StringBuilder();
formatAsJSON(builder, 0, !compact);
return builder.toString();
} | [
"public",
"String",
"toJSONString",
"(",
"final",
"boolean",
"compact",
")",
"{",
"final",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"formatAsJSON",
"(",
"builder",
",",
"0",
",",
"!",
"compact",
")",
";",
"return",
"builder",
... | Converts this value to a JSON string representation.
@param compact Flag indicating whether or not to include new lines
in the generated string representation.
@return The JSON formatted string. | [
"Converts",
"this",
"value",
"to",
"a",
"JSON",
"string",
"representation",
"."
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/dmr/src/main/java/org/jboss/dmr/client/ModelValue.java#L299-L303 | train |
hal/core | gui/src/main/java/org/jboss/as/console/client/shared/flow/FunctionContext.java | FunctionContext.set | public <T> void set(String key, T value) {
data.put(key, value);
} | java | public <T> void set(String key, T value) {
data.put(key, value);
} | [
"public",
"<",
"T",
">",
"void",
"set",
"(",
"String",
"key",
",",
"T",
"value",
")",
"{",
"data",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"}"
] | Stores the value under the given key in the context map. | [
"Stores",
"the",
"value",
"under",
"the",
"given",
"key",
"in",
"the",
"context",
"map",
"."
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/jboss/as/console/client/shared/flow/FunctionContext.java#L74-L76 | train |
hal/core | flow/core/src/main/java/org/jboss/gwt/flow/client/Async.java | Async.single | public void single(final C context, Outcome<C> outcome, final Function<C> function) {
SingletonControl ctrl = new SingletonControl(context, outcome);
progress.reset(1);
function.execute(ctrl);
} | java | public void single(final C context, Outcome<C> outcome, final Function<C> function) {
SingletonControl ctrl = new SingletonControl(context, outcome);
progress.reset(1);
function.execute(ctrl);
} | [
"public",
"void",
"single",
"(",
"final",
"C",
"context",
",",
"Outcome",
"<",
"C",
">",
"outcome",
",",
"final",
"Function",
"<",
"C",
">",
"function",
")",
"{",
"SingletonControl",
"ctrl",
"=",
"new",
"SingletonControl",
"(",
"context",
",",
"outcome",
... | Convenience method to executes a single function. Use this method if you have implemented your business logic
across different functions, but just want to execute a single function. | [
"Convenience",
"method",
"to",
"executes",
"a",
"single",
"function",
".",
"Use",
"this",
"method",
"if",
"you",
"have",
"implemented",
"your",
"business",
"logic",
"across",
"different",
"functions",
"but",
"just",
"want",
"to",
"execute",
"a",
"single",
"fun... | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/flow/core/src/main/java/org/jboss/gwt/flow/client/Async.java#L46-L50 | train |
hal/core | flow/core/src/main/java/org/jboss/gwt/flow/client/Async.java | Async.series | @SuppressWarnings("unchecked")
public void series(final Outcome outcome, final Function... functions) {
_series(null, outcome, functions); // generic signature problem, hence null
} | java | @SuppressWarnings("unchecked")
public void series(final Outcome outcome, final Function... functions) {
_series(null, outcome, functions); // generic signature problem, hence null
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"void",
"series",
"(",
"final",
"Outcome",
"outcome",
",",
"final",
"Function",
"...",
"functions",
")",
"{",
"_series",
"(",
"null",
",",
"outcome",
",",
"functions",
")",
";",
"// generic signatur... | Run an array of functions in series, each one running once the previous function has completed.
If any functions in the series pass an error to its callback,
no more functions are run and outcome for the series is immediately called with the value of the error. | [
"Run",
"an",
"array",
"of",
"functions",
"in",
"series",
"each",
"one",
"running",
"once",
"the",
"previous",
"function",
"has",
"completed",
".",
"If",
"any",
"functions",
"in",
"the",
"series",
"pass",
"an",
"error",
"to",
"its",
"callback",
"no",
"more"... | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/flow/core/src/main/java/org/jboss/gwt/flow/client/Async.java#L57-L60 | train |
hal/core | flow/core/src/main/java/org/jboss/gwt/flow/client/Async.java | Async.waterfall | @SafeVarargs
public final void waterfall(final C context, final Outcome<C> outcome, final Function<C>... functions) {
_series(context, outcome, functions);
} | java | @SafeVarargs
public final void waterfall(final C context, final Outcome<C> outcome, final Function<C>... functions) {
_series(context, outcome, functions);
} | [
"@",
"SafeVarargs",
"public",
"final",
"void",
"waterfall",
"(",
"final",
"C",
"context",
",",
"final",
"Outcome",
"<",
"C",
">",
"outcome",
",",
"final",
"Function",
"<",
"C",
">",
"...",
"functions",
")",
"{",
"_series",
"(",
"context",
",",
"outcome",... | Runs an array of functions in series, working on a shared context.
However, if any of the functions pass an error to the callback,
the next function is not executed and the outcome is immediately called with the error. | [
"Runs",
"an",
"array",
"of",
"functions",
"in",
"series",
"working",
"on",
"a",
"shared",
"context",
".",
"However",
"if",
"any",
"of",
"the",
"functions",
"pass",
"an",
"error",
"to",
"the",
"callback",
"the",
"next",
"function",
"is",
"not",
"executed",
... | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/flow/core/src/main/java/org/jboss/gwt/flow/client/Async.java#L67-L70 | train |
hal/core | flow/core/src/main/java/org/jboss/gwt/flow/client/Async.java | Async.parallel | @SuppressWarnings("unchecked")
public void parallel(C context, final Outcome<C> outcome, final Function<C>... functions) {
final C finalContext = context != null ? context : (C) EMPTY_CONTEXT;
final CountingControl ctrl = new CountingControl(finalContext, functions);
progress.reset(functions.length);
Scheduler.get().scheduleIncremental(new Scheduler.RepeatingCommand() {
@Override
public boolean execute() {
if (ctrl.isAborted() || ctrl.allFinished()) {
// schedule deferred so that 'return false' executes first!
Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
@Override
@SuppressWarnings("unchecked")
public void execute() {
if (ctrl.isAborted()) {
progress.finish();
outcome.onFailure(finalContext);
} else {
progress.finish();
outcome.onSuccess(finalContext);
}
}
});
return false;
} else {
// one after the other until all are active
ctrl.next();
return true;
}
}
});
} | java | @SuppressWarnings("unchecked")
public void parallel(C context, final Outcome<C> outcome, final Function<C>... functions) {
final C finalContext = context != null ? context : (C) EMPTY_CONTEXT;
final CountingControl ctrl = new CountingControl(finalContext, functions);
progress.reset(functions.length);
Scheduler.get().scheduleIncremental(new Scheduler.RepeatingCommand() {
@Override
public boolean execute() {
if (ctrl.isAborted() || ctrl.allFinished()) {
// schedule deferred so that 'return false' executes first!
Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
@Override
@SuppressWarnings("unchecked")
public void execute() {
if (ctrl.isAborted()) {
progress.finish();
outcome.onFailure(finalContext);
} else {
progress.finish();
outcome.onSuccess(finalContext);
}
}
});
return false;
} else {
// one after the other until all are active
ctrl.next();
return true;
}
}
});
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"void",
"parallel",
"(",
"C",
"context",
",",
"final",
"Outcome",
"<",
"C",
">",
"outcome",
",",
"final",
"Function",
"<",
"C",
">",
"...",
"functions",
")",
"{",
"final",
"C",
"finalContext",
... | Run an array of functions in parallel, without waiting until the previous function has completed.
If any of the functions pass an error to its callback, the outcome is immediately called with the value of the
error. | [
"Run",
"an",
"array",
"of",
"functions",
"in",
"parallel",
"without",
"waiting",
"until",
"the",
"previous",
"function",
"has",
"completed",
".",
"If",
"any",
"of",
"the",
"functions",
"pass",
"an",
"error",
"to",
"its",
"callback",
"the",
"outcome",
"is",
... | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/flow/core/src/main/java/org/jboss/gwt/flow/client/Async.java#L119-L152 | train |
hal/core | flow/core/src/main/java/org/jboss/gwt/flow/client/Async.java | Async.whilst | public void whilst(Precondition condition, final Outcome outcome, final Function function) {
whilst(condition, outcome, function, -1);
} | java | public void whilst(Precondition condition, final Outcome outcome, final Function function) {
whilst(condition, outcome, function, -1);
} | [
"public",
"void",
"whilst",
"(",
"Precondition",
"condition",
",",
"final",
"Outcome",
"outcome",
",",
"final",
"Function",
"function",
")",
"{",
"whilst",
"(",
"condition",
",",
"outcome",
",",
"function",
",",
"-",
"1",
")",
";",
"}"
] | Repeatedly call function, while condition is met. Calls the callback when stopped, or an error occurs. | [
"Repeatedly",
"call",
"function",
"while",
"condition",
"is",
"met",
".",
"Calls",
"the",
"callback",
"when",
"stopped",
"or",
"an",
"error",
"occurs",
"."
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/flow/core/src/main/java/org/jboss/gwt/flow/client/Async.java#L157-L159 | train |
hal/core | gui/src/main/java/org/useware/kernel/gui/behaviour/Integrity.java | Integrity.assertConsumer | private static void assertConsumer(InteractionUnit unit, Map<QName, Set<Procedure>> behaviours, IntegrityErrors err) {
Set<Resource<ResourceType>> producedTypes = unit.getOutputs();
for (Resource<ResourceType> resource : producedTypes) {
boolean match = false;
for(QName id : behaviours.keySet())
{
for (Behaviour behaviour : behaviours.get(id)) {
if (behaviour.doesConsume(resource)) {
match = true;
break;
}
}
}
if (!match)
err.add(unit.getId(), "Missing consumer for <<" + resource + ">>");
}
} | java | private static void assertConsumer(InteractionUnit unit, Map<QName, Set<Procedure>> behaviours, IntegrityErrors err) {
Set<Resource<ResourceType>> producedTypes = unit.getOutputs();
for (Resource<ResourceType> resource : producedTypes) {
boolean match = false;
for(QName id : behaviours.keySet())
{
for (Behaviour behaviour : behaviours.get(id)) {
if (behaviour.doesConsume(resource)) {
match = true;
break;
}
}
}
if (!match)
err.add(unit.getId(), "Missing consumer for <<" + resource + ">>");
}
} | [
"private",
"static",
"void",
"assertConsumer",
"(",
"InteractionUnit",
"unit",
",",
"Map",
"<",
"QName",
",",
"Set",
"<",
"Procedure",
">",
">",
"behaviours",
",",
"IntegrityErrors",
"err",
")",
"{",
"Set",
"<",
"Resource",
"<",
"ResourceType",
">>",
"produc... | Assertion that a consumer exists for the produced resources of an interaction unit.
@param unit
@param err | [
"Assertion",
"that",
"a",
"consumer",
"exists",
"for",
"the",
"produced",
"resources",
"of",
"an",
"interaction",
"unit",
"."
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/useware/kernel/gui/behaviour/Integrity.java#L63-L84 | train |
hal/core | gui/src/main/java/org/useware/kernel/gui/behaviour/Integrity.java | Integrity.assertProducer | private static void assertProducer(InteractionUnit unit, Map<QName, Set<Procedure>> behaviours, IntegrityErrors err) {
Set<Resource<ResourceType>> consumedTypes = unit.getInputs();
for (Resource<ResourceType> resource : consumedTypes) {
boolean match = false;
for(QName id : behaviours.keySet())
{
for (Behaviour candidate : behaviours.get(id)) {
if (candidate.doesProduce(resource)) {
match = candidate.getJustification() == null || unit.getId().equals(candidate.getJustification());
}
if(match)break;
}
if(match)break;
}
if (!match)
err.add(unit.getId(), "Missing producer for <<" + resource + ">>");
}
} | java | private static void assertProducer(InteractionUnit unit, Map<QName, Set<Procedure>> behaviours, IntegrityErrors err) {
Set<Resource<ResourceType>> consumedTypes = unit.getInputs();
for (Resource<ResourceType> resource : consumedTypes) {
boolean match = false;
for(QName id : behaviours.keySet())
{
for (Behaviour candidate : behaviours.get(id)) {
if (candidate.doesProduce(resource)) {
match = candidate.getJustification() == null || unit.getId().equals(candidate.getJustification());
}
if(match)break;
}
if(match)break;
}
if (!match)
err.add(unit.getId(), "Missing producer for <<" + resource + ">>");
}
} | [
"private",
"static",
"void",
"assertProducer",
"(",
"InteractionUnit",
"unit",
",",
"Map",
"<",
"QName",
",",
"Set",
"<",
"Procedure",
">",
">",
"behaviours",
",",
"IntegrityErrors",
"err",
")",
"{",
"Set",
"<",
"Resource",
"<",
"ResourceType",
">>",
"consum... | Assertion that a producer exists for the consumed resources of an interaction unit.
@param unit
@param behaviours
@param err | [
"Assertion",
"that",
"a",
"producer",
"exists",
"for",
"the",
"consumed",
"resources",
"of",
"an",
"interaction",
"unit",
"."
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/useware/kernel/gui/behaviour/Integrity.java#L93-L115 | train |
hal/core | gui/src/main/java/org/jboss/as/console/client/widgets/deprecated/NewListItemWizard.java | NewListItemWizard.setChoices | public void setChoices(List<String> choices) {
if (!limitChoices) throw new IllegalArgumentException("Attempted to set choices when choices are not limited.");
List<String> sorted = new ArrayList<String>();
sorted.addAll(choices);
Collections.sort(sorted);
((ComboBoxItem)this.nameItem).setValueMap(sorted);
} | java | public void setChoices(List<String> choices) {
if (!limitChoices) throw new IllegalArgumentException("Attempted to set choices when choices are not limited.");
List<String> sorted = new ArrayList<String>();
sorted.addAll(choices);
Collections.sort(sorted);
((ComboBoxItem)this.nameItem).setValueMap(sorted);
} | [
"public",
"void",
"setChoices",
"(",
"List",
"<",
"String",
">",
"choices",
")",
"{",
"if",
"(",
"!",
"limitChoices",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Attempted to set choices when choices are not limited.\"",
")",
";",
"List",
"<",
"String",... | Called before opening the dialog so that the user sees only the valid choices.
@param choices | [
"Called",
"before",
"opening",
"the",
"dialog",
"so",
"that",
"the",
"user",
"sees",
"only",
"the",
"valid",
"choices",
"."
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/jboss/as/console/client/widgets/deprecated/NewListItemWizard.java#L112-L119 | train |
hal/core | gui/src/main/java/org/jboss/as/console/client/v3/dmr/AddressTemplate.java | AddressTemplate.getResourceType | public String getResourceType() {
if (!tokens.isEmpty() && tokens.getLast().hasKey()) {
return tokens.getLast().getKey();
}
return null;
} | java | public String getResourceType() {
if (!tokens.isEmpty() && tokens.getLast().hasKey()) {
return tokens.getLast().getKey();
}
return null;
} | [
"public",
"String",
"getResourceType",
"(",
")",
"{",
"if",
"(",
"!",
"tokens",
".",
"isEmpty",
"(",
")",
"&&",
"tokens",
".",
"getLast",
"(",
")",
".",
"hasKey",
"(",
")",
")",
"{",
"return",
"tokens",
".",
"getLast",
"(",
")",
".",
"getKey",
"(",... | Returns the resource type of the last segment for this address template
@return the resource type | [
"Returns",
"the",
"resource",
"type",
"of",
"the",
"last",
"segment",
"for",
"this",
"address",
"template"
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/jboss/as/console/client/v3/dmr/AddressTemplate.java#L202-L207 | train |
hal/core | gui/src/main/java/org/jboss/as/console/client/search/Index.java | Index.reset | public void reset() {
for (long i = 0; i < idCounter; i++) {
localStorage.removeItem(key(i));
}
idCounter = 0;
localStorage.removeItem(documentsKey());
localStorage.removeItem(indexKey());
resetInternal();
Log.info("Reset index to " + indexKey());
} | java | public void reset() {
for (long i = 0; i < idCounter; i++) {
localStorage.removeItem(key(i));
}
idCounter = 0;
localStorage.removeItem(documentsKey());
localStorage.removeItem(indexKey());
resetInternal();
Log.info("Reset index to " + indexKey());
} | [
"public",
"void",
"reset",
"(",
")",
"{",
"for",
"(",
"long",
"i",
"=",
"0",
";",
"i",
"<",
"idCounter",
";",
"i",
"++",
")",
"{",
"localStorage",
".",
"removeItem",
"(",
"key",
"(",
"i",
")",
")",
";",
"}",
"idCounter",
"=",
"0",
";",
"localSt... | Resets the index | [
"Resets",
"the",
"index"
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/jboss/as/console/client/search/Index.java#L108-L118 | train |
hal/core | dmr/src/main/java/org/jboss/dmr/client/ModelNode.java | ModelNode.asPropertyList | public List<Property> asPropertyList() throws IllegalArgumentException {
if(ModelValue.UNDEFINED == value)
return Collections.EMPTY_LIST;
else
return value.asPropertyList();
} | java | public List<Property> asPropertyList() throws IllegalArgumentException {
if(ModelValue.UNDEFINED == value)
return Collections.EMPTY_LIST;
else
return value.asPropertyList();
} | [
"public",
"List",
"<",
"Property",
">",
"asPropertyList",
"(",
")",
"throws",
"IllegalArgumentException",
"{",
"if",
"(",
"ModelValue",
".",
"UNDEFINED",
"==",
"value",
")",
"return",
"Collections",
".",
"EMPTY_LIST",
";",
"else",
"return",
"value",
".",
"asPr... | Get the value of this node as a property list. Object values will return a list of properties representing
each key-value pair in the object. List values will return all the values of the list, failing if any of the
values are not convertible to a property value.
@return the property list value
@throws IllegalArgumentException if no conversion is possible | [
"Get",
"the",
"value",
"of",
"this",
"node",
"as",
"a",
"property",
"list",
".",
"Object",
"values",
"will",
"return",
"a",
"list",
"of",
"properties",
"representing",
"each",
"key",
"-",
"value",
"pair",
"in",
"the",
"object",
".",
"List",
"values",
"wi... | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/dmr/src/main/java/org/jboss/dmr/client/ModelNode.java#L253-L258 | train |
hal/core | dmr/src/main/java/org/jboss/dmr/client/ModelNode.java | ModelNode.setExpression | public ModelNode setExpression(final String newValue) {
if (newValue == null) {
throw new IllegalArgumentException("newValue is null");
}
checkProtect();
value = new ExpressionValue(newValue);
return this;
} | java | public ModelNode setExpression(final String newValue) {
if (newValue == null) {
throw new IllegalArgumentException("newValue is null");
}
checkProtect();
value = new ExpressionValue(newValue);
return this;
} | [
"public",
"ModelNode",
"setExpression",
"(",
"final",
"String",
"newValue",
")",
"{",
"if",
"(",
"newValue",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"newValue is null\"",
")",
";",
"}",
"checkProtect",
"(",
")",
";",
"value",... | Change this node's value to the given expression value.
@param newValue the new value
@return this node | [
"Change",
"this",
"node",
"s",
"value",
"to",
"the",
"given",
"expression",
"value",
"."
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/dmr/src/main/java/org/jboss/dmr/client/ModelNode.java#L342-L349 | train |
hal/core | dmr/src/main/java/org/jboss/dmr/client/ModelNode.java | ModelNode.set | public ModelNode set(final String newValue) {
if (newValue == null) {
throw new IllegalArgumentException("newValue is null");
}
checkProtect();
value = new StringModelValue(newValue);
return this;
} | java | public ModelNode set(final String newValue) {
if (newValue == null) {
throw new IllegalArgumentException("newValue is null");
}
checkProtect();
value = new StringModelValue(newValue);
return this;
} | [
"public",
"ModelNode",
"set",
"(",
"final",
"String",
"newValue",
")",
"{",
"if",
"(",
"newValue",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"newValue is null\"",
")",
";",
"}",
"checkProtect",
"(",
")",
";",
"value",
"=",
... | Change this node's value to the given value.
@param newValue the new value
@return this node | [
"Change",
"this",
"node",
"s",
"value",
"to",
"the",
"given",
"value",
"."
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/dmr/src/main/java/org/jboss/dmr/client/ModelNode.java#L357-L364 | train |
hal/core | gui/src/main/java/org/jboss/as/console/client/v3/behaviour/CrudOperationDelegate.java | CrudOperationDelegate.onCreateResource | public void onCreateResource(final AddressTemplate addressTemplate, final String name, final ModelNode payload,
final Callback... callback) {
ModelNode op = payload.clone();
op.get(ADDRESS).set(addressTemplate.resolve(statementContext, name));
op.get(OP).set(ADD);
dispatcher.execute(new DMRAction(op), new AsyncCallback<DMRResponse>() {
@Override
public void onFailure(Throwable caught) {
for (Callback cb : callback) {
cb.onFailure(addressTemplate, name, caught);
}
}
@Override
public void onSuccess(DMRResponse result) {
ModelNode response = result.get();
if (response.isFailure()) {
for (Callback cb : callback) {
cb.onFailure(addressTemplate, name,
new RuntimeException("Failed to add resource " +
addressTemplate.replaceWildcards(name) + ":" + response.getFailureDescription()));
}
} else {
for (Callback cb : callback) {
cb.onSuccess(addressTemplate, name);
}
}
}
});
} | java | public void onCreateResource(final AddressTemplate addressTemplate, final String name, final ModelNode payload,
final Callback... callback) {
ModelNode op = payload.clone();
op.get(ADDRESS).set(addressTemplate.resolve(statementContext, name));
op.get(OP).set(ADD);
dispatcher.execute(new DMRAction(op), new AsyncCallback<DMRResponse>() {
@Override
public void onFailure(Throwable caught) {
for (Callback cb : callback) {
cb.onFailure(addressTemplate, name, caught);
}
}
@Override
public void onSuccess(DMRResponse result) {
ModelNode response = result.get();
if (response.isFailure()) {
for (Callback cb : callback) {
cb.onFailure(addressTemplate, name,
new RuntimeException("Failed to add resource " +
addressTemplate.replaceWildcards(name) + ":" + response.getFailureDescription()));
}
} else {
for (Callback cb : callback) {
cb.onSuccess(addressTemplate, name);
}
}
}
});
} | [
"public",
"void",
"onCreateResource",
"(",
"final",
"AddressTemplate",
"addressTemplate",
",",
"final",
"String",
"name",
",",
"final",
"ModelNode",
"payload",
",",
"final",
"Callback",
"...",
"callback",
")",
"{",
"ModelNode",
"op",
"=",
"payload",
".",
"clone"... | Creates a new resource using the given address, name and payload.
@param addressTemplate The address template for the new resource. Might end with a wildcard,
in that case the name is mandatory.
@param name the name of the new resource. Might be null if the address template already contains the name.
@param payload the payload
@param callback the callbacks | [
"Creates",
"a",
"new",
"resource",
"using",
"the",
"given",
"address",
"name",
"and",
"payload",
"."
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/jboss/as/console/client/v3/behaviour/CrudOperationDelegate.java#L47-L77 | train |
hal/core | gui/src/main/java/org/jboss/as/console/client/v3/behaviour/CrudOperationDelegate.java | CrudOperationDelegate.onSaveResource | public void onSaveResource(final AddressTemplate addressTemplate, final String name,
Map<String, Object> changedValues, final Callback... callback) {
final ResourceAddress address = addressTemplate.resolve(statementContext, name);
final ModelNodeAdapter adapter = new ModelNodeAdapter();
ModelNode op = adapter.fromChangeSet(address, changedValues);
dispatcher.execute(new DMRAction(op), new AsyncCallback<DMRResponse>() {
@Override
public void onFailure(Throwable caught) {
for (Callback cb : callback) {
cb.onFailure(addressTemplate, name, caught);
}
}
@Override
public void onSuccess(DMRResponse dmrResponse) {
ModelNode response = dmrResponse.get();
if (response.isFailure()) {
Console.error(Console.MESSAGES.saveFailed(name), response.getFailureDescription());
for (Callback cb : callback) {
cb.onFailure(addressTemplate, name,
new RuntimeException(Console.MESSAGES.saveFailed(
addressTemplate.replaceWildcards(name).toString()) + ":" + response.getFailureDescription()));
}
} else {
for (Callback cb : callback) {
cb.onSuccess(addressTemplate, name);
}
}
}
});
} | java | public void onSaveResource(final AddressTemplate addressTemplate, final String name,
Map<String, Object> changedValues, final Callback... callback) {
final ResourceAddress address = addressTemplate.resolve(statementContext, name);
final ModelNodeAdapter adapter = new ModelNodeAdapter();
ModelNode op = adapter.fromChangeSet(address, changedValues);
dispatcher.execute(new DMRAction(op), new AsyncCallback<DMRResponse>() {
@Override
public void onFailure(Throwable caught) {
for (Callback cb : callback) {
cb.onFailure(addressTemplate, name, caught);
}
}
@Override
public void onSuccess(DMRResponse dmrResponse) {
ModelNode response = dmrResponse.get();
if (response.isFailure()) {
Console.error(Console.MESSAGES.saveFailed(name), response.getFailureDescription());
for (Callback cb : callback) {
cb.onFailure(addressTemplate, name,
new RuntimeException(Console.MESSAGES.saveFailed(
addressTemplate.replaceWildcards(name).toString()) + ":" + response.getFailureDescription()));
}
} else {
for (Callback cb : callback) {
cb.onSuccess(addressTemplate, name);
}
}
}
});
} | [
"public",
"void",
"onSaveResource",
"(",
"final",
"AddressTemplate",
"addressTemplate",
",",
"final",
"String",
"name",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"changedValues",
",",
"final",
"Callback",
"...",
"callback",
")",
"{",
"final",
"ResourceAddre... | Updates an existing resource using the given address, name and changed values.
@param addressTemplate The address template for the resource. Might end with a wildcard,
in that case the name is mandatory.
@param name the name of the new resource. Might be null if the address template already contains the name.
@param changedValues the changed values
@param callback the callbacks | [
"Updates",
"an",
"existing",
"resource",
"using",
"the",
"given",
"address",
"name",
"and",
"changed",
"values",
"."
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/jboss/as/console/client/v3/behaviour/CrudOperationDelegate.java#L87-L119 | train |
hal/core | gui/src/main/java/org/jboss/as/console/client/widgets/nav/v3/FinderTooltip.java | FinderTooltip.prepare | public void prepare(Element anchor, T item) {
this.currentAnchor = anchor;
this.currentItem = item;
if(!this.timer.isRunning())
{
timer.schedule(DELAY_MS);
}
} | java | public void prepare(Element anchor, T item) {
this.currentAnchor = anchor;
this.currentItem = item;
if(!this.timer.isRunning())
{
timer.schedule(DELAY_MS);
}
} | [
"public",
"void",
"prepare",
"(",
"Element",
"anchor",
",",
"T",
"item",
")",
"{",
"this",
".",
"currentAnchor",
"=",
"anchor",
";",
"this",
".",
"currentItem",
"=",
"item",
";",
"if",
"(",
"!",
"this",
".",
"timer",
".",
"isRunning",
"(",
")",
")",
... | prepare the displaying of the tooltip
or ignore the call when it's already active | [
"prepare",
"the",
"displaying",
"of",
"the",
"tooltip",
"or",
"ignore",
"the",
"call",
"when",
"it",
"s",
"already",
"active"
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/jboss/as/console/client/widgets/nav/v3/FinderTooltip.java#L72-L79 | train |
hal/core | gui/src/main/java/org/jboss/as/console/client/widgets/CollapsibleSplitLayoutPanel.java | CollapsibleSplitLayoutPanel.setWidgetMinSize | public void setWidgetMinSize(Widget child, int minSize) {
assertIsChild(child);
Splitter splitter = getAssociatedSplitter(child);
// The splitter is null for the center element.
if (splitter != null) {
splitter.setMinSize(minSize);
}
} | java | public void setWidgetMinSize(Widget child, int minSize) {
assertIsChild(child);
Splitter splitter = getAssociatedSplitter(child);
// The splitter is null for the center element.
if (splitter != null) {
splitter.setMinSize(minSize);
}
} | [
"public",
"void",
"setWidgetMinSize",
"(",
"Widget",
"child",
",",
"int",
"minSize",
")",
"{",
"assertIsChild",
"(",
"child",
")",
";",
"Splitter",
"splitter",
"=",
"getAssociatedSplitter",
"(",
"child",
")",
";",
"// The splitter is null for the center element.",
"... | Sets the minimum allowable size for the given widget.
<p>
Its associated splitter cannot be dragged to a position that would make it
smaller than this size. This method has no effect for the
{@link DockLayoutPanel.Direction#CENTER} widget.
</p>
@param child the child whose minimum size will be set
@param minSize the minimum size for this widget | [
"Sets",
"the",
"minimum",
"allowable",
"size",
"for",
"the",
"given",
"widget",
"."
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/jboss/as/console/client/widgets/CollapsibleSplitLayoutPanel.java#L416-L423 | train |
hal/core | gui/src/main/java/org/jboss/as/console/client/widgets/CollapsibleSplitLayoutPanel.java | CollapsibleSplitLayoutPanel.setWidgetToggleDisplayAllowed | public void setWidgetToggleDisplayAllowed(Widget child, boolean allowed) {
assertIsChild(child);
Splitter splitter = getAssociatedSplitter(child);
// The splitter is null for the center element.
if (splitter != null) {
splitter.setToggleDisplayAllowed(allowed);
}
} | java | public void setWidgetToggleDisplayAllowed(Widget child, boolean allowed) {
assertIsChild(child);
Splitter splitter = getAssociatedSplitter(child);
// The splitter is null for the center element.
if (splitter != null) {
splitter.setToggleDisplayAllowed(allowed);
}
} | [
"public",
"void",
"setWidgetToggleDisplayAllowed",
"(",
"Widget",
"child",
",",
"boolean",
"allowed",
")",
"{",
"assertIsChild",
"(",
"child",
")",
";",
"Splitter",
"splitter",
"=",
"getAssociatedSplitter",
"(",
"child",
")",
";",
"// The splitter is null for the cent... | Sets whether or not double-clicking on the splitter should toggle the
display of the widget.
@param child the child whose display toggling will be allowed or not.
@param allowed whether or not display toggling is allowed for this widget | [
"Sets",
"whether",
"or",
"not",
"double",
"-",
"clicking",
"on",
"the",
"splitter",
"should",
"toggle",
"the",
"display",
"of",
"the",
"widget",
"."
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/jboss/as/console/client/widgets/CollapsibleSplitLayoutPanel.java#L456-L463 | train |
hal/core | gui/src/main/java/org/jboss/as/console/client/tools/ModelBrowserView.java | ModelBrowserView.onItemSelected | private void onItemSelected(TreeItem treeItem) {
treeItem.getElement().focus();
final LinkedList<String> path = resolvePath(treeItem);
formView.clearDisplay();
descView.clearDisplay();
ModelNode address = toAddress(path);
ModelNode displayAddress = address.clone();
boolean isPlaceHolder = (treeItem instanceof PlaceholderItem);
//ChildInformation childInfo = findChildInfo(treeItem);
if(path.size()%2==0) {
/*String denominatorType = AddressUtils.getDenominatorType(address.asPropertyList());
boolean isSingleton = denominatorType!=null ? childInfo.isSingleton(denominatorType) : false; // false==root*/
// addressable resources
presenter.readResource(address, isPlaceHolder);
toggleEditor(true);
filter.setEnabled(true);
}
else {
toggleEditor(false);
// display tweaks
displayAddress.add(path.getLast(), WILDCARD);
// force loading of children upon selection
loadChildren((ModelTreeItem)treeItem, false);
filter.setEnabled(false);
}
nodeHeader.updateDescription(displayAddress);
} | java | private void onItemSelected(TreeItem treeItem) {
treeItem.getElement().focus();
final LinkedList<String> path = resolvePath(treeItem);
formView.clearDisplay();
descView.clearDisplay();
ModelNode address = toAddress(path);
ModelNode displayAddress = address.clone();
boolean isPlaceHolder = (treeItem instanceof PlaceholderItem);
//ChildInformation childInfo = findChildInfo(treeItem);
if(path.size()%2==0) {
/*String denominatorType = AddressUtils.getDenominatorType(address.asPropertyList());
boolean isSingleton = denominatorType!=null ? childInfo.isSingleton(denominatorType) : false; // false==root*/
// addressable resources
presenter.readResource(address, isPlaceHolder);
toggleEditor(true);
filter.setEnabled(true);
}
else {
toggleEditor(false);
// display tweaks
displayAddress.add(path.getLast(), WILDCARD);
// force loading of children upon selection
loadChildren((ModelTreeItem)treeItem, false);
filter.setEnabled(false);
}
nodeHeader.updateDescription(displayAddress);
} | [
"private",
"void",
"onItemSelected",
"(",
"TreeItem",
"treeItem",
")",
"{",
"treeItem",
".",
"getElement",
"(",
")",
".",
"focus",
"(",
")",
";",
"final",
"LinkedList",
"<",
"String",
">",
"path",
"=",
"resolvePath",
"(",
"treeItem",
")",
";",
"formView",
... | When a tree item is clicked we load the resource.
@param treeItem | [
"When",
"a",
"tree",
"item",
"is",
"clicked",
"we",
"load",
"the",
"resource",
"."
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/jboss/as/console/client/tools/ModelBrowserView.java#L229-L266 | train |
hal/core | gui/src/main/java/org/jboss/as/console/client/tools/ModelBrowserView.java | ModelBrowserView.updateRootTypes | public void updateRootTypes(ModelNode address, List<ModelNode> modelNodes) {
deck.showWidget(CHILD_VIEW);
tree.clear();
descView.clearDisplay();
formView.clearDisplay();
offsetDisplay.clear();
// IMPORTANT: when pin down is active, we need to consider the offset to calculate the real address
addressOffset = address;
nodeHeader.updateDescription(address);
List<Property> offset = addressOffset.asPropertyList();
if(offset.size()>0)
{
String parentName = offset.get(offset.size() - 1).getName();
HTML parentTag = new HTML("<div class='gwt-ToggleButton gwt-ToggleButton-down' title='Remove Filter'> " + parentName + " <i class='icon-remove'></i></div>");
parentTag.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
presenter.onPinTreeSelection(null);
}
});
offsetDisplay.add(parentTag);
}
TreeItem rootItem = null;
String rootTitle = null;
String key = null;
if(address.asList().isEmpty())
{
rootTitle = DEFAULT_ROOT;
key = DEFAULT_ROOT;
}
else
{
List<ModelNode> tuples = address.asList();
rootTitle = tuples.get(tuples.size() - 1).asProperty().getValue().asString();
key = rootTitle;
}
SafeHtmlBuilder html = new SafeHtmlBuilder().appendEscaped(rootTitle);
rootItem = new ModelTreeItem(html.toSafeHtml(), key, address, false);
tree.addItem(rootItem);
deck.showWidget(RESOURCE_VIEW);
rootItem.setSelected(true);
currentRootKey = key;
addChildrenTypes((ModelTreeItem)rootItem, modelNodes);
} | java | public void updateRootTypes(ModelNode address, List<ModelNode> modelNodes) {
deck.showWidget(CHILD_VIEW);
tree.clear();
descView.clearDisplay();
formView.clearDisplay();
offsetDisplay.clear();
// IMPORTANT: when pin down is active, we need to consider the offset to calculate the real address
addressOffset = address;
nodeHeader.updateDescription(address);
List<Property> offset = addressOffset.asPropertyList();
if(offset.size()>0)
{
String parentName = offset.get(offset.size() - 1).getName();
HTML parentTag = new HTML("<div class='gwt-ToggleButton gwt-ToggleButton-down' title='Remove Filter'> " + parentName + " <i class='icon-remove'></i></div>");
parentTag.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
presenter.onPinTreeSelection(null);
}
});
offsetDisplay.add(parentTag);
}
TreeItem rootItem = null;
String rootTitle = null;
String key = null;
if(address.asList().isEmpty())
{
rootTitle = DEFAULT_ROOT;
key = DEFAULT_ROOT;
}
else
{
List<ModelNode> tuples = address.asList();
rootTitle = tuples.get(tuples.size() - 1).asProperty().getValue().asString();
key = rootTitle;
}
SafeHtmlBuilder html = new SafeHtmlBuilder().appendEscaped(rootTitle);
rootItem = new ModelTreeItem(html.toSafeHtml(), key, address, false);
tree.addItem(rootItem);
deck.showWidget(RESOURCE_VIEW);
rootItem.setSelected(true);
currentRootKey = key;
addChildrenTypes((ModelTreeItem)rootItem, modelNodes);
} | [
"public",
"void",
"updateRootTypes",
"(",
"ModelNode",
"address",
",",
"List",
"<",
"ModelNode",
">",
"modelNodes",
")",
"{",
"deck",
".",
"showWidget",
"(",
"CHILD_VIEW",
")",
";",
"tree",
".",
"clear",
"(",
")",
";",
"descView",
".",
"clearDisplay",
"(",... | Update root node. Basicaly a refresh of the tree.
@param address
@param modelNodes | [
"Update",
"root",
"node",
".",
"Basicaly",
"a",
"refresh",
"of",
"the",
"tree",
"."
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/jboss/as/console/client/tools/ModelBrowserView.java#L411-L463 | train |
hal/core | gui/src/main/java/org/jboss/as/console/client/tools/ModelBrowserView.java | ModelBrowserView.updateChildrenTypes | public void updateChildrenTypes(ModelNode address, List<ModelNode> modelNodes) {
TreeItem rootItem = findTreeItem(tree, address);
addChildrenTypes((ModelTreeItem) rootItem, modelNodes);
} | java | public void updateChildrenTypes(ModelNode address, List<ModelNode> modelNodes) {
TreeItem rootItem = findTreeItem(tree, address);
addChildrenTypes((ModelTreeItem) rootItem, modelNodes);
} | [
"public",
"void",
"updateChildrenTypes",
"(",
"ModelNode",
"address",
",",
"List",
"<",
"ModelNode",
">",
"modelNodes",
")",
"{",
"TreeItem",
"rootItem",
"=",
"findTreeItem",
"(",
"tree",
",",
"address",
")",
";",
"addChildrenTypes",
"(",
"(",
"ModelTreeItem",
... | Update sub parts of the tree
@param address
@param modelNodes | [
"Update",
"sub",
"parts",
"of",
"the",
"tree"
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/jboss/as/console/client/tools/ModelBrowserView.java#L471-L476 | train |
hal/core | gui/src/main/java/org/jboss/as/console/client/domain/model/impl/ServerGroupDAOImpl.java | ServerGroupDAOImpl.model2ServerGroup | private ServerGroupRecord model2ServerGroup(String groupName, ModelNode model) {
ServerGroupRecord record = factory.serverGroup().as();
record.setName(groupName);
record.setProfileName(model.get("profile").asString());
record.setSocketBinding(model.get("socket-binding-group").asString());
Jvm jvm = ModelAdapter.model2JVM(factory, model);
if(jvm!=null)
jvm.setInherited(false); // on this level they can't inherit from anyone
record.setJvm(jvm);
List<PropertyRecord> propertyRecords = ModelAdapter.model2Property(factory, model);
record.setProperties(propertyRecords);
return record;
} | java | private ServerGroupRecord model2ServerGroup(String groupName, ModelNode model) {
ServerGroupRecord record = factory.serverGroup().as();
record.setName(groupName);
record.setProfileName(model.get("profile").asString());
record.setSocketBinding(model.get("socket-binding-group").asString());
Jvm jvm = ModelAdapter.model2JVM(factory, model);
if(jvm!=null)
jvm.setInherited(false); // on this level they can't inherit from anyone
record.setJvm(jvm);
List<PropertyRecord> propertyRecords = ModelAdapter.model2Property(factory, model);
record.setProperties(propertyRecords);
return record;
} | [
"private",
"ServerGroupRecord",
"model2ServerGroup",
"(",
"String",
"groupName",
",",
"ModelNode",
"model",
")",
"{",
"ServerGroupRecord",
"record",
"=",
"factory",
".",
"serverGroup",
"(",
")",
".",
"as",
"(",
")",
";",
"record",
".",
"setName",
"(",
"groupNa... | Turns a server group DMR model into a strongly typed entity
@param groupName
@param model
@return | [
"Turns",
"a",
"server",
"group",
"DMR",
"model",
"into",
"a",
"strongly",
"typed",
"entity"
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/jboss/as/console/client/domain/model/impl/ServerGroupDAOImpl.java#L217-L235 | train |
hal/core | gui/src/main/java/org/jboss/as/console/client/rbac/SecurityContextImpl.java | SecurityContextImpl.getReadPriviledge | public AuthorisationDecision getReadPriviledge() {
return checkPriviledge(new Priviledge() {
@Override
public boolean isGranted(Constraints c) {
boolean readable = c.isReadResource();
if (!readable)
Log.info("read privilege denied for: " + c.getResourceAddress());
return readable;
}
}, false);
} | java | public AuthorisationDecision getReadPriviledge() {
return checkPriviledge(new Priviledge() {
@Override
public boolean isGranted(Constraints c) {
boolean readable = c.isReadResource();
if (!readable)
Log.info("read privilege denied for: " + c.getResourceAddress());
return readable;
}
}, false);
} | [
"public",
"AuthorisationDecision",
"getReadPriviledge",
"(",
")",
"{",
"return",
"checkPriviledge",
"(",
"new",
"Priviledge",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"isGranted",
"(",
"Constraints",
"c",
")",
"{",
"boolean",
"readable",
"=",
"c",
... | If any of the required resources is not accessible, overall access will be rejected
@return | [
"If",
"any",
"of",
"the",
"required",
"resources",
"is",
"not",
"accessible",
"overall",
"access",
"will",
"be",
"rejected"
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/jboss/as/console/client/rbac/SecurityContextImpl.java#L114-L127 | train |
hal/core | gui/src/main/java/org/jboss/as/console/mbui/widgets/ModelNodeFormBuilder.java | ModelNodeFormBuilder.setValue | public static void setValue(ModelNode target, ModelType type, Object propValue) {
if (type.equals(ModelType.STRING)) {
target.set((String) propValue);
} else if (type.equals(ModelType.INT)) {
target.set((Integer) propValue);
} else if (type.equals(ModelType.DOUBLE)) {
target.set((Double) propValue);
} else if (type.equals(ModelType.LONG)) {
// in some cases the server returns the wrong model type for numeric values
// i.e the description affords a ModelType.LONG, but a ModelType.INTEGER is returned
try {
target.set((Long) propValue);
} catch (Throwable e) { // ClassCastException
target.set(Integer.valueOf((Integer) propValue));
}
} else if (type.equals(ModelType.BIG_DECIMAL)) {
// in some cases the server returns the wrong model type for numeric values
// i.e the description affords a ModelType.LONG, but a ModelType.INTEGER is returned
try {
target.set((BigDecimal) propValue);
} catch (Throwable e) { // ClassCastException
target.set(Double.valueOf((Double) propValue));
}
} else if (type.equals(ModelType.BOOLEAN)) {
target.set((Boolean) propValue);
} else if (type.equals(ModelType.LIST)) {
target.setEmptyList();
List list = (List) propValue;
for (Object item : list) {
target.add(String.valueOf(item));
}
} else {
Log.warn("Type conversionnot supported for " + type);
target.setEmptyObject();
}
} | java | public static void setValue(ModelNode target, ModelType type, Object propValue) {
if (type.equals(ModelType.STRING)) {
target.set((String) propValue);
} else if (type.equals(ModelType.INT)) {
target.set((Integer) propValue);
} else if (type.equals(ModelType.DOUBLE)) {
target.set((Double) propValue);
} else if (type.equals(ModelType.LONG)) {
// in some cases the server returns the wrong model type for numeric values
// i.e the description affords a ModelType.LONG, but a ModelType.INTEGER is returned
try {
target.set((Long) propValue);
} catch (Throwable e) { // ClassCastException
target.set(Integer.valueOf((Integer) propValue));
}
} else if (type.equals(ModelType.BIG_DECIMAL)) {
// in some cases the server returns the wrong model type for numeric values
// i.e the description affords a ModelType.LONG, but a ModelType.INTEGER is returned
try {
target.set((BigDecimal) propValue);
} catch (Throwable e) { // ClassCastException
target.set(Double.valueOf((Double) propValue));
}
} else if (type.equals(ModelType.BOOLEAN)) {
target.set((Boolean) propValue);
} else if (type.equals(ModelType.LIST)) {
target.setEmptyList();
List list = (List) propValue;
for (Object item : list) {
target.add(String.valueOf(item));
}
} else {
Log.warn("Type conversionnot supported for " + type);
target.setEmptyObject();
}
} | [
"public",
"static",
"void",
"setValue",
"(",
"ModelNode",
"target",
",",
"ModelType",
"type",
",",
"Object",
"propValue",
")",
"{",
"if",
"(",
"type",
".",
"equals",
"(",
"ModelType",
".",
"STRING",
")",
")",
"{",
"target",
".",
"set",
"(",
"(",
"Strin... | a more lenient way to update values by type | [
"a",
"more",
"lenient",
"way",
"to",
"update",
"values",
"by",
"type"
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/jboss/as/console/mbui/widgets/ModelNodeFormBuilder.java#L94-L132 | train |
hal/core | gui/src/main/java/org/jboss/as/console/client/widgets/forms/FormMetaData.java | FormMetaData.doGroupCheck | private void doGroupCheck() {
if (!hasTabs()) return;
for (String groupName : getGroupNames()) {
String tabName = getGroupedAttribtes(groupName).get(0).getTabName();
for (PropertyBinding propBinding : getGroupedAttribtes(groupName)) {
if (!tabName.equals(propBinding.getTabName())) {
throw new RuntimeException("FormItem " + propBinding.getJavaName() + " must be on the same tab with all members of its subgroup.");
}
}
}
} | java | private void doGroupCheck() {
if (!hasTabs()) return;
for (String groupName : getGroupNames()) {
String tabName = getGroupedAttribtes(groupName).get(0).getTabName();
for (PropertyBinding propBinding : getGroupedAttribtes(groupName)) {
if (!tabName.equals(propBinding.getTabName())) {
throw new RuntimeException("FormItem " + propBinding.getJavaName() + " must be on the same tab with all members of its subgroup.");
}
}
}
} | [
"private",
"void",
"doGroupCheck",
"(",
")",
"{",
"if",
"(",
"!",
"hasTabs",
"(",
")",
")",
"return",
";",
"for",
"(",
"String",
"groupName",
":",
"getGroupNames",
"(",
")",
")",
"{",
"String",
"tabName",
"=",
"getGroupedAttribtes",
"(",
"groupName",
")"... | make sure all grouped attributes are on the same tab | [
"make",
"sure",
"all",
"grouped",
"attributes",
"are",
"on",
"the",
"same",
"tab"
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/jboss/as/console/client/widgets/forms/FormMetaData.java#L94-L105 | train |
hal/core | gui/src/main/java/org/jboss/as/console/client/tools/ModelBrowser.java | ModelBrowser.onRemoveChildResource | public void onRemoveChildResource(final ModelNode address, final ModelNode selection) {
final ModelNode fqAddress = AddressUtils.toFqAddress(address, selection.asString());
_loadMetaData(fqAddress, new ResourceData(true), new Outcome<ResourceData>() {
@Override
public void onFailure(ResourceData context) {
Console.error("Failed to load metadata for " + address.asString());
}
@Override
public void onSuccess(ResourceData context) {
String resourceAddress = AddressUtils.asKey(fqAddress, true);
if (context.securityContext.getWritePrivilege(resourceAddress).isGranted()) {
_onRemoveChildResource(address, selection);
} else {
Feedback.alert(Console.CONSTANTS.unauthorized(), Console.CONSTANTS.unauthorizedRemove());
}
}
}
);
} | java | public void onRemoveChildResource(final ModelNode address, final ModelNode selection) {
final ModelNode fqAddress = AddressUtils.toFqAddress(address, selection.asString());
_loadMetaData(fqAddress, new ResourceData(true), new Outcome<ResourceData>() {
@Override
public void onFailure(ResourceData context) {
Console.error("Failed to load metadata for " + address.asString());
}
@Override
public void onSuccess(ResourceData context) {
String resourceAddress = AddressUtils.asKey(fqAddress, true);
if (context.securityContext.getWritePrivilege(resourceAddress).isGranted()) {
_onRemoveChildResource(address, selection);
} else {
Feedback.alert(Console.CONSTANTS.unauthorized(), Console.CONSTANTS.unauthorizedRemove());
}
}
}
);
} | [
"public",
"void",
"onRemoveChildResource",
"(",
"final",
"ModelNode",
"address",
",",
"final",
"ModelNode",
"selection",
")",
"{",
"final",
"ModelNode",
"fqAddress",
"=",
"AddressUtils",
".",
"toFqAddress",
"(",
"address",
",",
"selection",
".",
"asString",
"(",
... | Checks permissions and removes a child resource
@param address
@param selection | [
"Checks",
"permissions",
"and",
"removes",
"a",
"child",
"resource"
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/jboss/as/console/client/tools/ModelBrowser.java#L447-L468 | train |
hal/core | gui/src/main/java/org/jboss/as/console/client/tools/ModelBrowser.java | ModelBrowser._onRemoveChildResource | private void _onRemoveChildResource(final ModelNode address, final ModelNode selection) {
final ModelNode fqAddress = AddressUtils.toFqAddress(address, selection.asString());
final ModelNode operation = new ModelNode();
operation.get(OP).set(REMOVE);
operation.get(ADDRESS).set(fqAddress);
Feedback.confirm(
"Remove Resource",
"Do you really want to remove resource "+fqAddress.toString(),
new Feedback.ConfirmationHandler() {
@Override
public void onConfirmation(boolean isConfirmed) {
if(isConfirmed) {
dispatcher.execute(new DMRAction(operation), new SimpleCallback<DMRResponse>() {
@Override
public void onSuccess(DMRResponse dmrResponse) {
ModelNode response = dmrResponse.get();
if (response.isFailure()) {
Console.error("Failed to remove resource " + fqAddress.asString(), response.getFailureDescription());
} else {
Console.info("Successfully removed resource " + fqAddress.asString());
readChildrenNames(address);
}
}
});
}
}
}
);
} | java | private void _onRemoveChildResource(final ModelNode address, final ModelNode selection) {
final ModelNode fqAddress = AddressUtils.toFqAddress(address, selection.asString());
final ModelNode operation = new ModelNode();
operation.get(OP).set(REMOVE);
operation.get(ADDRESS).set(fqAddress);
Feedback.confirm(
"Remove Resource",
"Do you really want to remove resource "+fqAddress.toString(),
new Feedback.ConfirmationHandler() {
@Override
public void onConfirmation(boolean isConfirmed) {
if(isConfirmed) {
dispatcher.execute(new DMRAction(operation), new SimpleCallback<DMRResponse>() {
@Override
public void onSuccess(DMRResponse dmrResponse) {
ModelNode response = dmrResponse.get();
if (response.isFailure()) {
Console.error("Failed to remove resource " + fqAddress.asString(), response.getFailureDescription());
} else {
Console.info("Successfully removed resource " + fqAddress.asString());
readChildrenNames(address);
}
}
});
}
}
}
);
} | [
"private",
"void",
"_onRemoveChildResource",
"(",
"final",
"ModelNode",
"address",
",",
"final",
"ModelNode",
"selection",
")",
"{",
"final",
"ModelNode",
"fqAddress",
"=",
"AddressUtils",
".",
"toFqAddress",
"(",
"address",
",",
"selection",
".",
"asString",
"(",... | Remove a child resource
@param address
@param selection | [
"Remove",
"a",
"child",
"resource"
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/jboss/as/console/client/tools/ModelBrowser.java#L475-L510 | train |
hal/core | gui/src/main/java/org/jboss/as/console/client/tools/ModelBrowser.java | ModelBrowser.onPrepareAddChildResource | public void onPrepareAddChildResource(final ModelNode address, final boolean isSingleton) {
_loadMetaData(address, new ResourceData(true), new Outcome<ResourceData>() {
@Override
public void onFailure(ResourceData context) {
Console.error("Failed to load metadata for " + address.asString());
}
@Override
public void onSuccess(ResourceData context) {
if (isSingleton && context.description.get(ATTRIBUTES).asList().isEmpty()
&& context.description.get(OPERATIONS).get(ADD).get(REQUEST_PROPERTIES).asList().isEmpty()) {
// no attributes need to be assigned -> skip the next step
onAddChildResource(address, new ModelNode());
} else {
view.showAddDialog(address, isSingleton, context.securityContext, context.description);
}
}
}
);
} | java | public void onPrepareAddChildResource(final ModelNode address, final boolean isSingleton) {
_loadMetaData(address, new ResourceData(true), new Outcome<ResourceData>() {
@Override
public void onFailure(ResourceData context) {
Console.error("Failed to load metadata for " + address.asString());
}
@Override
public void onSuccess(ResourceData context) {
if (isSingleton && context.description.get(ATTRIBUTES).asList().isEmpty()
&& context.description.get(OPERATIONS).get(ADD).get(REQUEST_PROPERTIES).asList().isEmpty()) {
// no attributes need to be assigned -> skip the next step
onAddChildResource(address, new ModelNode());
} else {
view.showAddDialog(address, isSingleton, context.securityContext, context.description);
}
}
}
);
} | [
"public",
"void",
"onPrepareAddChildResource",
"(",
"final",
"ModelNode",
"address",
",",
"final",
"boolean",
"isSingleton",
")",
"{",
"_loadMetaData",
"(",
"address",
",",
"new",
"ResourceData",
"(",
"true",
")",
",",
"new",
"Outcome",
"<",
"ResourceData",
">",... | Add a child resource
@param address
@param isSingleton | [
"Add",
"a",
"child",
"resource"
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/jboss/as/console/client/tools/ModelBrowser.java#L517-L538 | train |
hal/core | gui/src/main/java/org/jboss/as/console/client/shared/subsys/undertow/ApplicationSecurityDomainResourceView.java | ApplicationSecurityDomainResourceView.populateRepackagedToCredentialReference | private void populateRepackagedToCredentialReference(ModelNode payload, String repackagedPropName, String propertyName) {
ModelNode value = payload.get(repackagedPropName);
if (payload.hasDefined(repackagedPropName) && value.asString().trim().length() > 0) {
payload.get(CREDENTIAL_REFERENCE).get(propertyName).set(value);
}
payload.remove(repackagedPropName);
} | java | private void populateRepackagedToCredentialReference(ModelNode payload, String repackagedPropName, String propertyName) {
ModelNode value = payload.get(repackagedPropName);
if (payload.hasDefined(repackagedPropName) && value.asString().trim().length() > 0) {
payload.get(CREDENTIAL_REFERENCE).get(propertyName).set(value);
}
payload.remove(repackagedPropName);
} | [
"private",
"void",
"populateRepackagedToCredentialReference",
"(",
"ModelNode",
"payload",
",",
"String",
"repackagedPropName",
",",
"String",
"propertyName",
")",
"{",
"ModelNode",
"value",
"=",
"payload",
".",
"get",
"(",
"repackagedPropName",
")",
";",
"if",
"(",... | create a flat node, copying the credential-reference complex attribute as regular attributes of the payload | [
"create",
"a",
"flat",
"node",
"copying",
"the",
"credential",
"-",
"reference",
"complex",
"attribute",
"as",
"regular",
"attributes",
"of",
"the",
"payload"
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/jboss/as/console/client/shared/subsys/undertow/ApplicationSecurityDomainResourceView.java#L328-L334 | train |
hal/core | gui/src/main/java/org/jboss/as/console/mbui/model/mapping/AddressMapping.java | AddressMapping.getRequiredStatements | public Map<String, Integer> getRequiredStatements() {
Map<String, Integer> required = new HashMap<String,Integer>();
for(Token token : address)
{
if(!token.hasKey())
{
// a single token or token expression
// These are currently skipped: See asResource() parsing logic
continue;
}
else
{
// a value expression. key and value of the expression might be resolved
// TODO: keys are not supported: Do we actually need that?
String value_ref = token.getValue();
if(value_ref.startsWith("{"))
{
value_ref = value_ref.substring(1, value_ref.length()-1);
if(!required.containsKey(value_ref))
{
required.put(value_ref, 1);
}
else
{
Integer count = required.get(value_ref);
++count;
required.put(value_ref, count);
}
}
}
}
return required;
} | java | public Map<String, Integer> getRequiredStatements() {
Map<String, Integer> required = new HashMap<String,Integer>();
for(Token token : address)
{
if(!token.hasKey())
{
// a single token or token expression
// These are currently skipped: See asResource() parsing logic
continue;
}
else
{
// a value expression. key and value of the expression might be resolved
// TODO: keys are not supported: Do we actually need that?
String value_ref = token.getValue();
if(value_ref.startsWith("{"))
{
value_ref = value_ref.substring(1, value_ref.length()-1);
if(!required.containsKey(value_ref))
{
required.put(value_ref, 1);
}
else
{
Integer count = required.get(value_ref);
++count;
required.put(value_ref, count);
}
}
}
}
return required;
} | [
"public",
"Map",
"<",
"String",
",",
"Integer",
">",
"getRequiredStatements",
"(",
")",
"{",
"Map",
"<",
"String",
",",
"Integer",
">",
"required",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Integer",
">",
"(",
")",
";",
"for",
"(",
"Token",
"token",
... | Parses the address declaration for tokens
that need to be resolved against the statement context.
@return | [
"Parses",
"the",
"address",
"declaration",
"for",
"tokens",
"that",
"need",
"to",
"be",
"resolved",
"against",
"the",
"statement",
"context",
"."
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/jboss/as/console/mbui/model/mapping/AddressMapping.java#L65-L99 | train |
hal/core | gui/src/main/java/org/jboss/as/console/server/proxy/HttpClient.java | HttpClient.getURLConnection | private HttpURLConnection getURLConnection(String str)
throws MalformedURLException {
try {
if (isHttps) {
/* when communicating with the server which has unsigned or invalid
* certificate (https), SSLException or IOException is thrown.
* the following line is a hack to avoid that
*/
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol");
if (isProxy) {
System.setProperty("https.proxyHost", proxyHost);
System.setProperty("https.proxyPort", proxyPort + "");
}
}
else
{
if (isProxy)
{
System.setProperty("http.proxyHost", proxyHost);
System.setProperty("http.proxyPort", proxyPort + "");
}
}
URL url = new URL(str);
HttpURLConnection uc = (HttpURLConnection)url.openConnection();
// if this header has not been set by a request set the user agent.
if (headers == null ||
(headers != null && headers.get("user-agent") == null)) {
// set user agent to mimic a common browser
String ua="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)";
uc.setRequestProperty("user-agent", ua);
}
uc.setInstanceFollowRedirects(false);
return uc;
}
catch (MalformedURLException me)
{
throw new MalformedURLException(str + " is not a valid URL");
}
catch (Exception e)
{
throw new RuntimeException("Unknown error creating UrlConnection: " + e);
}
} | java | private HttpURLConnection getURLConnection(String str)
throws MalformedURLException {
try {
if (isHttps) {
/* when communicating with the server which has unsigned or invalid
* certificate (https), SSLException or IOException is thrown.
* the following line is a hack to avoid that
*/
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol");
if (isProxy) {
System.setProperty("https.proxyHost", proxyHost);
System.setProperty("https.proxyPort", proxyPort + "");
}
}
else
{
if (isProxy)
{
System.setProperty("http.proxyHost", proxyHost);
System.setProperty("http.proxyPort", proxyPort + "");
}
}
URL url = new URL(str);
HttpURLConnection uc = (HttpURLConnection)url.openConnection();
// if this header has not been set by a request set the user agent.
if (headers == null ||
(headers != null && headers.get("user-agent") == null)) {
// set user agent to mimic a common browser
String ua="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)";
uc.setRequestProperty("user-agent", ua);
}
uc.setInstanceFollowRedirects(false);
return uc;
}
catch (MalformedURLException me)
{
throw new MalformedURLException(str + " is not a valid URL");
}
catch (Exception e)
{
throw new RuntimeException("Unknown error creating UrlConnection: " + e);
}
} | [
"private",
"HttpURLConnection",
"getURLConnection",
"(",
"String",
"str",
")",
"throws",
"MalformedURLException",
"{",
"try",
"{",
"if",
"(",
"isHttps",
")",
"{",
"/* when communicating with the server which has unsigned or invalid\n * certificate (https), SSLExcepti... | private method to get the URLConnection
@param str URL string | [
"private",
"method",
"to",
"get",
"the",
"URLConnection"
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/jboss/as/console/server/proxy/HttpClient.java#L185-L233 | train |
hal/core | gui/src/main/java/org/jboss/as/console/server/proxy/HttpClient.java | HttpClient.getInputStream | public InputStream getInputStream() {
try
{
int responseCode = this.urlConnection.getResponseCode();
try
{
// HACK: manually follow redirects, for the login to work
// HTTPUrlConnection auto redirect doesn't respect the provided headers
if(responseCode ==302)
{
HttpClient redirectClient =
new HttpClient(proxyHost,proxyPort, urlConnection.getHeaderField("Location"),
headers, urlConnection.getRequestMethod(), callback, authHeader);
redirectClient.getInputStream().close();
}
}
catch (Throwable e)
{
System.out.println("Following redirect failed");
}
setCookieHeader = this.urlConnection.getHeaderField("Set-Cookie");
InputStream in = responseCode != HttpURLConnection.HTTP_OK ?
this.urlConnection.getErrorStream() : this.urlConnection.getInputStream();
return in;
} catch (Exception e) {
return null;
}
} | java | public InputStream getInputStream() {
try
{
int responseCode = this.urlConnection.getResponseCode();
try
{
// HACK: manually follow redirects, for the login to work
// HTTPUrlConnection auto redirect doesn't respect the provided headers
if(responseCode ==302)
{
HttpClient redirectClient =
new HttpClient(proxyHost,proxyPort, urlConnection.getHeaderField("Location"),
headers, urlConnection.getRequestMethod(), callback, authHeader);
redirectClient.getInputStream().close();
}
}
catch (Throwable e)
{
System.out.println("Following redirect failed");
}
setCookieHeader = this.urlConnection.getHeaderField("Set-Cookie");
InputStream in = responseCode != HttpURLConnection.HTTP_OK ?
this.urlConnection.getErrorStream() : this.urlConnection.getInputStream();
return in;
} catch (Exception e) {
return null;
}
} | [
"public",
"InputStream",
"getInputStream",
"(",
")",
"{",
"try",
"{",
"int",
"responseCode",
"=",
"this",
".",
"urlConnection",
".",
"getResponseCode",
"(",
")",
";",
"try",
"{",
"// HACK: manually follow redirects, for the login to work",
"// HTTPUrlConnection auto redir... | returns the inputstream from URLConnection
@return InputStream | [
"returns",
"the",
"inputstream",
"from",
"URLConnection"
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/jboss/as/console/server/proxy/HttpClient.java#L260-L292 | train |
hal/core | gui/src/main/java/org/jboss/as/console/server/proxy/HttpClient.java | HttpClient.doPost | public InputStream doPost(byte[] postData, String contentType) {
this.urlConnection.setDoOutput(true);
if (contentType != null) this.urlConnection.setRequestProperty( "Content-type", contentType );
OutputStream out = null;
try {
out = this.getOutputStream();
if(out!=null)
{
out.write(postData);
out.flush();
}
} catch (IOException e) {
e.printStackTrace();
}finally {
if(out!=null)
try {
out.close();
} catch (IOException e) {
//
}
}
return (this.getInputStream());
} | java | public InputStream doPost(byte[] postData, String contentType) {
this.urlConnection.setDoOutput(true);
if (contentType != null) this.urlConnection.setRequestProperty( "Content-type", contentType );
OutputStream out = null;
try {
out = this.getOutputStream();
if(out!=null)
{
out.write(postData);
out.flush();
}
} catch (IOException e) {
e.printStackTrace();
}finally {
if(out!=null)
try {
out.close();
} catch (IOException e) {
//
}
}
return (this.getInputStream());
} | [
"public",
"InputStream",
"doPost",
"(",
"byte",
"[",
"]",
"postData",
",",
"String",
"contentType",
")",
"{",
"this",
".",
"urlConnection",
".",
"setDoOutput",
"(",
"true",
")",
";",
"if",
"(",
"contentType",
"!=",
"null",
")",
"this",
".",
"urlConnection"... | posts data to the inputstream and returns the InputStream.
@param postData data to be posted. must be url-encoded already.
@param contentType allows you to set the contentType of the request.
@return InputStream input stream from URLConnection | [
"posts",
"data",
"to",
"the",
"inputstream",
"and",
"returns",
"the",
"InputStream",
"."
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/jboss/as/console/server/proxy/HttpClient.java#L315-L340 | train |
hal/core | diagnostics/src/main/java/com/google/gwt/debugpanel/widgets/TogglingCommandLink.java | TogglingCommandLink.toggle | public void toggle() {
Command cmd = state.isPrimary() ? command1 : command2;
setState(state.other());
cmd.execute();
} | java | public void toggle() {
Command cmd = state.isPrimary() ? command1 : command2;
setState(state.other());
cmd.execute();
} | [
"public",
"void",
"toggle",
"(",
")",
"{",
"Command",
"cmd",
"=",
"state",
".",
"isPrimary",
"(",
")",
"?",
"command1",
":",
"command2",
";",
"setState",
"(",
"state",
".",
"other",
"(",
")",
")",
";",
"cmd",
".",
"execute",
"(",
")",
";",
"}"
] | Toggles the link executing the command. All state is changed before the command
is executed and it is therefore safe to call this from within the commands. | [
"Toggles",
"the",
"link",
"executing",
"the",
"command",
".",
"All",
"state",
"is",
"changed",
"before",
"the",
"command",
"is",
"executed",
"and",
"it",
"is",
"therefore",
"safe",
"to",
"call",
"this",
"from",
"within",
"the",
"commands",
"."
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/diagnostics/src/main/java/com/google/gwt/debugpanel/widgets/TogglingCommandLink.java#L53-L57 | train |
hal/core | diagnostics/src/main/java/com/google/gwt/debugpanel/widgets/TogglingCommandLink.java | TogglingCommandLink.setState | public void setState(State state) {
this.state = state;
setText(state.isPrimary() ? text1 : text2);
} | java | public void setState(State state) {
this.state = state;
setText(state.isPrimary() ? text1 : text2);
} | [
"public",
"void",
"setState",
"(",
"State",
"state",
")",
"{",
"this",
".",
"state",
"=",
"state",
";",
"setText",
"(",
"state",
".",
"isPrimary",
"(",
")",
"?",
"text1",
":",
"text2",
")",
";",
"}"
] | Changes the state without executing the command. | [
"Changes",
"the",
"state",
"without",
"executing",
"the",
"command",
"."
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/diagnostics/src/main/java/com/google/gwt/debugpanel/widgets/TogglingCommandLink.java#L69-L72 | train |
hal/core | gui/src/main/java/org/useware/kernel/model/structure/QName.java | QName.getNormalizedLocalPart | public String getNormalizedLocalPart() {
int i = localPart.indexOf("#");
if(i!=-1)
return localPart.substring(0, i);
else
return localPart;
} | java | public String getNormalizedLocalPart() {
int i = localPart.indexOf("#");
if(i!=-1)
return localPart.substring(0, i);
else
return localPart;
} | [
"public",
"String",
"getNormalizedLocalPart",
"(",
")",
"{",
"int",
"i",
"=",
"localPart",
".",
"indexOf",
"(",
"\"#\"",
")",
";",
"if",
"(",
"i",
"!=",
"-",
"1",
")",
"return",
"localPart",
".",
"substring",
"(",
"0",
",",
"i",
")",
";",
"else",
"... | return the local part without suffix | [
"return",
"the",
"local",
"part",
"without",
"suffix"
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/useware/kernel/model/structure/QName.java#L289-L295 | train |
hal/core | gui/src/main/java/org/jboss/as/console/client/shared/runtime/naming/JndiTreeParser.java | JndiTreeParser.createChild | private boolean createChild(Property sibling, String parentURI) {
boolean skipped = sibling.getName().equals("children");
if (!skipped) {
//dump(sibling);
String dataType = null;
String uri = "";
if (sibling.getValue().hasDefined("class-name")) {
dataType = sibling.getValue().get("class-name").asString();
uri = parentURI + "/" + sibling.getName();
int idx = uri.indexOf(':');
if (idx > 0) {
int idx2 = uri.lastIndexOf('/', idx);
if (idx2 >= 0 && (idx2 + 1) < uri.length())
uri = uri.substring(idx2 + 1);
}
}
JndiEntry next = new JndiEntry(sibling.getName(), uri, dataType);
if (sibling.getValue().hasDefined("value"))
next.setValue(sibling.getValue().get("value").asString());
stack.peek().getChildren().add(next);
stack.push(next);
}
return skipped;
} | java | private boolean createChild(Property sibling, String parentURI) {
boolean skipped = sibling.getName().equals("children");
if (!skipped) {
//dump(sibling);
String dataType = null;
String uri = "";
if (sibling.getValue().hasDefined("class-name")) {
dataType = sibling.getValue().get("class-name").asString();
uri = parentURI + "/" + sibling.getName();
int idx = uri.indexOf(':');
if (idx > 0) {
int idx2 = uri.lastIndexOf('/', idx);
if (idx2 >= 0 && (idx2 + 1) < uri.length())
uri = uri.substring(idx2 + 1);
}
}
JndiEntry next = new JndiEntry(sibling.getName(), uri, dataType);
if (sibling.getValue().hasDefined("value"))
next.setValue(sibling.getValue().get("value").asString());
stack.peek().getChildren().add(next);
stack.push(next);
}
return skipped;
} | [
"private",
"boolean",
"createChild",
"(",
"Property",
"sibling",
",",
"String",
"parentURI",
")",
"{",
"boolean",
"skipped",
"=",
"sibling",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"\"children\"",
")",
";",
"if",
"(",
"!",
"skipped",
")",
"{",
"//d... | create actual children
@param sibling
@return | [
"create",
"actual",
"children"
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/jboss/as/console/client/shared/runtime/naming/JndiTreeParser.java#L103-L131 | train |
hal/core | gui/src/main/java/org/jboss/as/console/client/widgets/tabs/DefaultTabLayoutPanel.java | DefaultTabLayoutPanel.selectTab | @Override
public void selectTab(final String text) {
for (int i = 0; i < tabs.size(); i++) {
if (text.equals(tabs.get(i).getText())) {
selectTab(i);
return;
}
}
// not found in visible tabs, should be in off-page
for (OffPageText opt : offPageContainer.getTexts()) {
if (text.equals(opt.getText())) {
if (opt.getIndex() == 0) {
// the first off-page needs special treatment
offPageContainer.selectDeck(opt.getIndex());
if (getSelectedIndex() == PAGE_LIMIT - 1) {
SelectionEvent.fire(this, PAGE_LIMIT - 1);
}
tabs.lastTab().setText(opt.getText());
selectTab(PAGE_LIMIT - 1);
} else {
selectTab(PAGE_LIMIT - 1 + opt.getIndex());
}
}
}
} | java | @Override
public void selectTab(final String text) {
for (int i = 0; i < tabs.size(); i++) {
if (text.equals(tabs.get(i).getText())) {
selectTab(i);
return;
}
}
// not found in visible tabs, should be in off-page
for (OffPageText opt : offPageContainer.getTexts()) {
if (text.equals(opt.getText())) {
if (opt.getIndex() == 0) {
// the first off-page needs special treatment
offPageContainer.selectDeck(opt.getIndex());
if (getSelectedIndex() == PAGE_LIMIT - 1) {
SelectionEvent.fire(this, PAGE_LIMIT - 1);
}
tabs.lastTab().setText(opt.getText());
selectTab(PAGE_LIMIT - 1);
} else {
selectTab(PAGE_LIMIT - 1 + opt.getIndex());
}
}
}
} | [
"@",
"Override",
"public",
"void",
"selectTab",
"(",
"final",
"String",
"text",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"tabs",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"if",
"(",
"text",
".",
"equals",
"(",
"tabs",
... | Selects the tab with the specified text. If there's no tab with the specified text, the selected tab remains
unchanged. If there's more than one tab with the specified text, the first one will be selected.
@param text | [
"Selects",
"the",
"tab",
"with",
"the",
"specified",
"text",
".",
"If",
"there",
"s",
"no",
"tab",
"with",
"the",
"specified",
"text",
"the",
"selected",
"tab",
"remains",
"unchanged",
".",
"If",
"there",
"s",
"more",
"than",
"one",
"tab",
"with",
"the",... | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/jboss/as/console/client/widgets/tabs/DefaultTabLayoutPanel.java#L210-L235 | train |
hal/core | gui/src/main/java/org/jboss/as/console/client/shared/expr/DefaultExpressionResolver.java | DefaultExpressionResolver.parseResponse | private void parseResponse(ModelNode response, AsyncCallback<Map<String,String>> callback) {
//System.out.println(response.toString());
Map<String, String> serverValues = new HashMap<String,String>();
if(isStandalone)
{
serverValues.put("Standalone Server", response.get(RESULT).asString());
}
else if(response.hasDefined("server-groups"))
{
List<Property> groups = response.get("server-groups").asPropertyList();
for(Property serverGroup : groups)
{
List<Property> hosts = serverGroup.getValue().get("host").asPropertyList();
for(Property host : hosts)
{
List<Property> servers = host.getValue().asPropertyList();
for(Property server : servers)
{
serverValues.put(server.getName(),
server.getValue().get("response").get("result").asString()
);
}
}
}
}
callback.onSuccess(serverValues);
} | java | private void parseResponse(ModelNode response, AsyncCallback<Map<String,String>> callback) {
//System.out.println(response.toString());
Map<String, String> serverValues = new HashMap<String,String>();
if(isStandalone)
{
serverValues.put("Standalone Server", response.get(RESULT).asString());
}
else if(response.hasDefined("server-groups"))
{
List<Property> groups = response.get("server-groups").asPropertyList();
for(Property serverGroup : groups)
{
List<Property> hosts = serverGroup.getValue().get("host").asPropertyList();
for(Property host : hosts)
{
List<Property> servers = host.getValue().asPropertyList();
for(Property server : servers)
{
serverValues.put(server.getName(),
server.getValue().get("response").get("result").asString()
);
}
}
}
}
callback.onSuccess(serverValues);
} | [
"private",
"void",
"parseResponse",
"(",
"ModelNode",
"response",
",",
"AsyncCallback",
"<",
"Map",
"<",
"String",
",",
"String",
">",
">",
"callback",
")",
"{",
"//System.out.println(response.toString());",
"Map",
"<",
"String",
",",
"String",
">",
"serverValues"... | Distinguish domain and standalone response values
@param response
@param callback | [
"Distinguish",
"domain",
"and",
"standalone",
"response",
"values"
] | d6d03f0bb128dc0470f5dc75fdb1ea1014400602 | https://github.com/hal/core/blob/d6d03f0bb128dc0470f5dc75fdb1ea1014400602/gui/src/main/java/org/jboss/as/console/client/shared/expr/DefaultExpressionResolver.java#L71-L102 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.