id
int32 0
165k
| repo
stringlengths 7
58
| path
stringlengths 12
218
| func_name
stringlengths 3
140
| original_string
stringlengths 73
34.1k
| language
stringclasses 1
value | code
stringlengths 73
34.1k
| code_tokens
list | docstring
stringlengths 3
16k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 105
339
|
|---|---|---|---|---|---|---|---|---|---|---|---|
8,700
|
Gant/Gant
|
src/main/groovy/org/codehaus/gant/ant/Gant.java
|
Gant.execute
|
@Override public void execute() throws BuildException {
//
// At first it might seem appropriate to use the Project object from the calling Ant instance as the
// Project object used by the AntBuilder object and hence GantBuilder object associated with the Gant
// instance we are going to create here. However, if we just use that Project object directly then
// there are problems with proper annotation of the lines of output, so it isn't really an option.
// Therefore create a new Project instance and set the things appropriately from the original Project
// object.
//
// Issues driving things here are GANT-50 and GANT-80. GANT-50 is about having the correct base
// directory for operations, GANT-80 is about ensuring that all output generation actually generated
// observable output.
//
// NB As this class is called Gant, we have to use fully qualified name to get to the Gant main class.
//
final Project antProject = getOwningTarget().getProject();
final Project newProject = new Project();
newProject.init();
// Deal with GANT-80 by getting all the the loggers from the Ant instance Project object and adding
// them to the new Project Object. This was followed up by GANT-91 so the code was amended to copying
// over all listeners except the class loader if present.
for (final Object o : antProject.getBuildListeners()) {
final BuildListener listener = (BuildListener) o;
if (!(listener instanceof AntClassLoader)) { newProject.addBuildListener(listener); }
}
// Deal with GANT-50 by getting the base directory from the Ant instance Project object and use it for
// the new Project object. GANT-93 leads to change in the way the Gant file is extracted.
newProject.setBaseDir(antProject.getBaseDir());
// Deal with GANT-110 by using the strategy proposed by Eric Van Dewoestine.
if (inheritAll) { addAlmostAll(newProject, antProject); }
final File gantFile = newProject.resolveFile(file);
if (! gantFile.exists()) { throw new BuildException("Gantfile does not exist.", getLocation()); }
final GantBuilder ant = new GantBuilder(newProject);
final Map<String,String> environmentParameter = new HashMap<String,String>();
environmentParameter.put("environment", "environment");
ant.invokeMethod("property", new Object[] { environmentParameter });
final GantBinding binding = new GantBinding();
binding.forcedSettingOfVariable("ant", ant);
for (final Definition definition : definitions) {
final Map<String,String> definitionParameter = new HashMap<String,String>();
definitionParameter.put("name", definition.getName());
definitionParameter.put("value", definition.getValue());
ant.invokeMethod("property", new Object[] { definitionParameter });
}
final gant.Gant gant = new gant.Gant(binding);
gant.loadScript(gantFile);
final List<String> targetsAsStrings = new ArrayList<String>();
for (final GantTarget g : targets) { targetsAsStrings.add(g.getValue()); }
final int returnCode = gant.processTargets(targetsAsStrings);
if (returnCode != 0) { throw new BuildException("Gant execution failed with return code " + returnCode + '.', getLocation()); }
}
|
java
|
@Override public void execute() throws BuildException {
//
// At first it might seem appropriate to use the Project object from the calling Ant instance as the
// Project object used by the AntBuilder object and hence GantBuilder object associated with the Gant
// instance we are going to create here. However, if we just use that Project object directly then
// there are problems with proper annotation of the lines of output, so it isn't really an option.
// Therefore create a new Project instance and set the things appropriately from the original Project
// object.
//
// Issues driving things here are GANT-50 and GANT-80. GANT-50 is about having the correct base
// directory for operations, GANT-80 is about ensuring that all output generation actually generated
// observable output.
//
// NB As this class is called Gant, we have to use fully qualified name to get to the Gant main class.
//
final Project antProject = getOwningTarget().getProject();
final Project newProject = new Project();
newProject.init();
// Deal with GANT-80 by getting all the the loggers from the Ant instance Project object and adding
// them to the new Project Object. This was followed up by GANT-91 so the code was amended to copying
// over all listeners except the class loader if present.
for (final Object o : antProject.getBuildListeners()) {
final BuildListener listener = (BuildListener) o;
if (!(listener instanceof AntClassLoader)) { newProject.addBuildListener(listener); }
}
// Deal with GANT-50 by getting the base directory from the Ant instance Project object and use it for
// the new Project object. GANT-93 leads to change in the way the Gant file is extracted.
newProject.setBaseDir(antProject.getBaseDir());
// Deal with GANT-110 by using the strategy proposed by Eric Van Dewoestine.
if (inheritAll) { addAlmostAll(newProject, antProject); }
final File gantFile = newProject.resolveFile(file);
if (! gantFile.exists()) { throw new BuildException("Gantfile does not exist.", getLocation()); }
final GantBuilder ant = new GantBuilder(newProject);
final Map<String,String> environmentParameter = new HashMap<String,String>();
environmentParameter.put("environment", "environment");
ant.invokeMethod("property", new Object[] { environmentParameter });
final GantBinding binding = new GantBinding();
binding.forcedSettingOfVariable("ant", ant);
for (final Definition definition : definitions) {
final Map<String,String> definitionParameter = new HashMap<String,String>();
definitionParameter.put("name", definition.getName());
definitionParameter.put("value", definition.getValue());
ant.invokeMethod("property", new Object[] { definitionParameter });
}
final gant.Gant gant = new gant.Gant(binding);
gant.loadScript(gantFile);
final List<String> targetsAsStrings = new ArrayList<String>();
for (final GantTarget g : targets) { targetsAsStrings.add(g.getValue()); }
final int returnCode = gant.processTargets(targetsAsStrings);
if (returnCode != 0) { throw new BuildException("Gant execution failed with return code " + returnCode + '.', getLocation()); }
}
|
[
"@",
"Override",
"public",
"void",
"execute",
"(",
")",
"throws",
"BuildException",
"{",
"//",
"// At first it might seem appropriate to use the Project object from the calling Ant instance as the",
"// Project object used by the AntBuilder object and hence GantBuilder object associated with the Gant",
"// instance we are going to create here. However, if we just use that Project object directly then",
"// there are problems with proper annotation of the lines of output, so it isn't really an option.",
"// Therefore create a new Project instance and set the things appropriately from the original Project",
"// object.",
"//",
"// Issues driving things here are GANT-50 and GANT-80. GANT-50 is about having the correct base",
"// directory for operations, GANT-80 is about ensuring that all output generation actually generated",
"// observable output.",
"//",
"// NB As this class is called Gant, we have to use fully qualified name to get to the Gant main class.",
"//",
"final",
"Project",
"antProject",
"=",
"getOwningTarget",
"(",
")",
".",
"getProject",
"(",
")",
";",
"final",
"Project",
"newProject",
"=",
"new",
"Project",
"(",
")",
";",
"newProject",
".",
"init",
"(",
")",
";",
"// Deal with GANT-80 by getting all the the loggers from the Ant instance Project object and adding",
"// them to the new Project Object. This was followed up by GANT-91 so the code was amended to copying",
"// over all listeners except the class loader if present.",
"for",
"(",
"final",
"Object",
"o",
":",
"antProject",
".",
"getBuildListeners",
"(",
")",
")",
"{",
"final",
"BuildListener",
"listener",
"=",
"(",
"BuildListener",
")",
"o",
";",
"if",
"(",
"!",
"(",
"listener",
"instanceof",
"AntClassLoader",
")",
")",
"{",
"newProject",
".",
"addBuildListener",
"(",
"listener",
")",
";",
"}",
"}",
"// Deal with GANT-50 by getting the base directory from the Ant instance Project object and use it for",
"// the new Project object. GANT-93 leads to change in the way the Gant file is extracted.",
"newProject",
".",
"setBaseDir",
"(",
"antProject",
".",
"getBaseDir",
"(",
")",
")",
";",
"// Deal with GANT-110 by using the strategy proposed by Eric Van Dewoestine.",
"if",
"(",
"inheritAll",
")",
"{",
"addAlmostAll",
"(",
"newProject",
",",
"antProject",
")",
";",
"}",
"final",
"File",
"gantFile",
"=",
"newProject",
".",
"resolveFile",
"(",
"file",
")",
";",
"if",
"(",
"!",
"gantFile",
".",
"exists",
"(",
")",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"\"Gantfile does not exist.\"",
",",
"getLocation",
"(",
")",
")",
";",
"}",
"final",
"GantBuilder",
"ant",
"=",
"new",
"GantBuilder",
"(",
"newProject",
")",
";",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"environmentParameter",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"environmentParameter",
".",
"put",
"(",
"\"environment\"",
",",
"\"environment\"",
")",
";",
"ant",
".",
"invokeMethod",
"(",
"\"property\"",
",",
"new",
"Object",
"[",
"]",
"{",
"environmentParameter",
"}",
")",
";",
"final",
"GantBinding",
"binding",
"=",
"new",
"GantBinding",
"(",
")",
";",
"binding",
".",
"forcedSettingOfVariable",
"(",
"\"ant\"",
",",
"ant",
")",
";",
"for",
"(",
"final",
"Definition",
"definition",
":",
"definitions",
")",
"{",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"definitionParameter",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"definitionParameter",
".",
"put",
"(",
"\"name\"",
",",
"definition",
".",
"getName",
"(",
")",
")",
";",
"definitionParameter",
".",
"put",
"(",
"\"value\"",
",",
"definition",
".",
"getValue",
"(",
")",
")",
";",
"ant",
".",
"invokeMethod",
"(",
"\"property\"",
",",
"new",
"Object",
"[",
"]",
"{",
"definitionParameter",
"}",
")",
";",
"}",
"final",
"gant",
".",
"Gant",
"gant",
"=",
"new",
"gant",
".",
"Gant",
"(",
"binding",
")",
";",
"gant",
".",
"loadScript",
"(",
"gantFile",
")",
";",
"final",
"List",
"<",
"String",
">",
"targetsAsStrings",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"final",
"GantTarget",
"g",
":",
"targets",
")",
"{",
"targetsAsStrings",
".",
"add",
"(",
"g",
".",
"getValue",
"(",
")",
")",
";",
"}",
"final",
"int",
"returnCode",
"=",
"gant",
".",
"processTargets",
"(",
"targetsAsStrings",
")",
";",
"if",
"(",
"returnCode",
"!=",
"0",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"\"Gant execution failed with return code \"",
"+",
"returnCode",
"+",
"'",
"'",
",",
"getLocation",
"(",
")",
")",
";",
"}",
"}"
] |
Load the file and then execute it.
|
[
"Load",
"the",
"file",
"and",
"then",
"execute",
"it",
"."
] |
8f82b3cd8968d5595dc44e2beae9f7948172868b
|
https://github.com/Gant/Gant/blob/8f82b3cd8968d5595dc44e2beae9f7948172868b/src/main/groovy/org/codehaus/gant/ant/Gant.java#L144-L194
|
8,701
|
Gant/Gant
|
src/main/groovy/org/codehaus/gant/ant/Gant.java
|
Gant.addAlmostAll
|
private void addAlmostAll(final Project newProject, final Project oldProject) {
final Hashtable<String,Object> properties = oldProject.getProperties();
final Enumeration<String> e = properties.keys();
while (e.hasMoreElements()) {
final String key = e.nextElement();
if (!(MagicNames.PROJECT_BASEDIR.equals(key) || MagicNames.ANT_FILE.equals(key))) {
if (newProject.getProperty(key) == null) { newProject.setNewProperty(key, (String)properties.get(key)); }
}
}
}
|
java
|
private void addAlmostAll(final Project newProject, final Project oldProject) {
final Hashtable<String,Object> properties = oldProject.getProperties();
final Enumeration<String> e = properties.keys();
while (e.hasMoreElements()) {
final String key = e.nextElement();
if (!(MagicNames.PROJECT_BASEDIR.equals(key) || MagicNames.ANT_FILE.equals(key))) {
if (newProject.getProperty(key) == null) { newProject.setNewProperty(key, (String)properties.get(key)); }
}
}
}
|
[
"private",
"void",
"addAlmostAll",
"(",
"final",
"Project",
"newProject",
",",
"final",
"Project",
"oldProject",
")",
"{",
"final",
"Hashtable",
"<",
"String",
",",
"Object",
">",
"properties",
"=",
"oldProject",
".",
"getProperties",
"(",
")",
";",
"final",
"Enumeration",
"<",
"String",
">",
"e",
"=",
"properties",
".",
"keys",
"(",
")",
";",
"while",
"(",
"e",
".",
"hasMoreElements",
"(",
")",
")",
"{",
"final",
"String",
"key",
"=",
"e",
".",
"nextElement",
"(",
")",
";",
"if",
"(",
"!",
"(",
"MagicNames",
".",
"PROJECT_BASEDIR",
".",
"equals",
"(",
"key",
")",
"||",
"MagicNames",
".",
"ANT_FILE",
".",
"equals",
"(",
"key",
")",
")",
")",
"{",
"if",
"(",
"newProject",
".",
"getProperty",
"(",
"key",
")",
"==",
"null",
")",
"{",
"newProject",
".",
"setNewProperty",
"(",
"key",
",",
"(",
"String",
")",
"properties",
".",
"get",
"(",
"key",
")",
")",
";",
"}",
"}",
"}",
"}"
] |
Russel Winder rehacked the code provided by Eric Van Dewoestine.
|
[
"Russel",
"Winder",
"rehacked",
"the",
"code",
"provided",
"by",
"Eric",
"Van",
"Dewoestine",
"."
] |
8f82b3cd8968d5595dc44e2beae9f7948172868b
|
https://github.com/Gant/Gant/blob/8f82b3cd8968d5595dc44e2beae9f7948172868b/src/main/groovy/org/codehaus/gant/ant/Gant.java#L204-L213
|
8,702
|
Gant/Gant
|
src/main/groovy/org/codehaus/gant/GantBuilder.java
|
GantBuilder.invokeMethod
|
@Override public Object invokeMethod(final String name, final Object arguments) {
if (GantState.dryRun) {
if (GantState.verbosity > GantState.SILENT) {
final StringBuilder sb = new StringBuilder();
int padding = 9 - name.length();
if (padding < 0) { padding = 0; }
sb.append(" ".substring(0, padding) + '[' + name + "] ");
final Object[] args = (Object[]) arguments;
if (args[0] instanceof Map<?,?>) {
//////////////////////////////////////////////////////////////////////////////////////////////////////////
// Eclipse and IntelliJ IDEA warn that (Map) is not a proper cast but using the
// cast (Map<?,?>) causes a type check error due to the capture algorithm.
//
// TODO : Fix this rather than use a SuppressWarnings.
//////////////////////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings({ "unchecked", "rawtypes" } ) final Iterator<Map.Entry<?,?>> i =((Map) args[0]).entrySet().iterator();
while (i.hasNext()) {
final Map.Entry<?,?> e = i.next();
sb.append(e.getKey() + " : '" + e.getValue() + '\'');
if (i.hasNext()) { sb.append(", "); }
}
sb.append('\n');
getProject().log(sb.toString());
if (args.length == 2) {((Closure<?>) args[1]).call(); }
}
else if (args[0] instanceof Closure) { ((Closure<?>) args[0]).call(); }
else { throw new RuntimeException("Unexpected type of parameter to method " + name); }
}
return null;
}
return super.invokeMethod(name, arguments);
}
|
java
|
@Override public Object invokeMethod(final String name, final Object arguments) {
if (GantState.dryRun) {
if (GantState.verbosity > GantState.SILENT) {
final StringBuilder sb = new StringBuilder();
int padding = 9 - name.length();
if (padding < 0) { padding = 0; }
sb.append(" ".substring(0, padding) + '[' + name + "] ");
final Object[] args = (Object[]) arguments;
if (args[0] instanceof Map<?,?>) {
//////////////////////////////////////////////////////////////////////////////////////////////////////////
// Eclipse and IntelliJ IDEA warn that (Map) is not a proper cast but using the
// cast (Map<?,?>) causes a type check error due to the capture algorithm.
//
// TODO : Fix this rather than use a SuppressWarnings.
//////////////////////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings({ "unchecked", "rawtypes" } ) final Iterator<Map.Entry<?,?>> i =((Map) args[0]).entrySet().iterator();
while (i.hasNext()) {
final Map.Entry<?,?> e = i.next();
sb.append(e.getKey() + " : '" + e.getValue() + '\'');
if (i.hasNext()) { sb.append(", "); }
}
sb.append('\n');
getProject().log(sb.toString());
if (args.length == 2) {((Closure<?>) args[1]).call(); }
}
else if (args[0] instanceof Closure) { ((Closure<?>) args[0]).call(); }
else { throw new RuntimeException("Unexpected type of parameter to method " + name); }
}
return null;
}
return super.invokeMethod(name, arguments);
}
|
[
"@",
"Override",
"public",
"Object",
"invokeMethod",
"(",
"final",
"String",
"name",
",",
"final",
"Object",
"arguments",
")",
"{",
"if",
"(",
"GantState",
".",
"dryRun",
")",
"{",
"if",
"(",
"GantState",
".",
"verbosity",
">",
"GantState",
".",
"SILENT",
")",
"{",
"final",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"int",
"padding",
"=",
"9",
"-",
"name",
".",
"length",
"(",
")",
";",
"if",
"(",
"padding",
"<",
"0",
")",
"{",
"padding",
"=",
"0",
";",
"}",
"sb",
".",
"append",
"(",
"\" \"",
".",
"substring",
"(",
"0",
",",
"padding",
")",
"+",
"'",
"'",
"+",
"name",
"+",
"\"] \"",
")",
";",
"final",
"Object",
"[",
"]",
"args",
"=",
"(",
"Object",
"[",
"]",
")",
"arguments",
";",
"if",
"(",
"args",
"[",
"0",
"]",
"instanceof",
"Map",
"<",
"?",
",",
"?",
">",
")",
"{",
"//////////////////////////////////////////////////////////////////////////////////////////////////////////",
"// Eclipse and IntelliJ IDEA warn that (Map) is not a proper cast but using the",
"// cast (Map<?,?>) causes a type check error due to the capture algorithm.",
"//",
"// TODO : Fix this rather than use a SuppressWarnings.",
"//////////////////////////////////////////////////////////////////////////////////////////////////////////",
"@",
"SuppressWarnings",
"(",
"{",
"\"unchecked\"",
",",
"\"rawtypes\"",
"}",
")",
"final",
"Iterator",
"<",
"Map",
".",
"Entry",
"<",
"?",
",",
"?",
">",
">",
"i",
"=",
"(",
"(",
"Map",
")",
"args",
"[",
"0",
"]",
")",
".",
"entrySet",
"(",
")",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"i",
".",
"hasNext",
"(",
")",
")",
"{",
"final",
"Map",
".",
"Entry",
"<",
"?",
",",
"?",
">",
"e",
"=",
"i",
".",
"next",
"(",
")",
";",
"sb",
".",
"append",
"(",
"e",
".",
"getKey",
"(",
")",
"+",
"\" : '\"",
"+",
"e",
".",
"getValue",
"(",
")",
"+",
"'",
"'",
")",
";",
"if",
"(",
"i",
".",
"hasNext",
"(",
")",
")",
"{",
"sb",
".",
"append",
"(",
"\", \"",
")",
";",
"}",
"}",
"sb",
".",
"append",
"(",
"'",
"'",
")",
";",
"getProject",
"(",
")",
".",
"log",
"(",
"sb",
".",
"toString",
"(",
")",
")",
";",
"if",
"(",
"args",
".",
"length",
"==",
"2",
")",
"{",
"(",
"(",
"Closure",
"<",
"?",
">",
")",
"args",
"[",
"1",
"]",
")",
".",
"call",
"(",
")",
";",
"}",
"}",
"else",
"if",
"(",
"args",
"[",
"0",
"]",
"instanceof",
"Closure",
")",
"{",
"(",
"(",
"Closure",
"<",
"?",
">",
")",
"args",
"[",
"0",
"]",
")",
".",
"call",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Unexpected type of parameter to method \"",
"+",
"name",
")",
";",
"}",
"}",
"return",
"null",
";",
"}",
"return",
"super",
".",
"invokeMethod",
"(",
"name",
",",
"arguments",
")",
";",
"}"
] |
Invoke a method.
@param name The name of the method to invoke.
@param arguments The parameters to the method call.
@return The value returned by the method call or null if no value is returned.
|
[
"Invoke",
"a",
"method",
"."
] |
8f82b3cd8968d5595dc44e2beae9f7948172868b
|
https://github.com/Gant/Gant/blob/8f82b3cd8968d5595dc44e2beae9f7948172868b/src/main/groovy/org/codehaus/gant/GantBuilder.java#L69-L100
|
8,703
|
pavlospt/RxIAPv3
|
androidiap/src/main/java/com/pavlospt/androidiap/billing/BillingProcessor.java
|
BillingProcessor.checkMerchant
|
private boolean checkMerchant(PurchaseDataModel details) {
if (developerMerchantId == null) //omit merchant id checking
return true;
if (details.getPurchaseTime().before(dateMerchantLimit1)) //new format [merchantId].[orderId] applied or not?
return true;
if (details.getPurchaseTime().after(dateMerchantLimit2)) //newest format applied
return true;
if (details.getOrderId() == null || details.getOrderId() .trim().length() == 0)
return false;
int index = details.getOrderId() .indexOf('.');
if (index <= 0)
return false; //protect on missing merchant id
//extract merchant id
String merchantId = details.getOrderId().substring(0, index);
return merchantId.compareTo(developerMerchantId) == 0;
}
|
java
|
private boolean checkMerchant(PurchaseDataModel details) {
if (developerMerchantId == null) //omit merchant id checking
return true;
if (details.getPurchaseTime().before(dateMerchantLimit1)) //new format [merchantId].[orderId] applied or not?
return true;
if (details.getPurchaseTime().after(dateMerchantLimit2)) //newest format applied
return true;
if (details.getOrderId() == null || details.getOrderId() .trim().length() == 0)
return false;
int index = details.getOrderId() .indexOf('.');
if (index <= 0)
return false; //protect on missing merchant id
//extract merchant id
String merchantId = details.getOrderId().substring(0, index);
return merchantId.compareTo(developerMerchantId) == 0;
}
|
[
"private",
"boolean",
"checkMerchant",
"(",
"PurchaseDataModel",
"details",
")",
"{",
"if",
"(",
"developerMerchantId",
"==",
"null",
")",
"//omit merchant id checking",
"return",
"true",
";",
"if",
"(",
"details",
".",
"getPurchaseTime",
"(",
")",
".",
"before",
"(",
"dateMerchantLimit1",
")",
")",
"//new format [merchantId].[orderId] applied or not?",
"return",
"true",
";",
"if",
"(",
"details",
".",
"getPurchaseTime",
"(",
")",
".",
"after",
"(",
"dateMerchantLimit2",
")",
")",
"//newest format applied",
"return",
"true",
";",
"if",
"(",
"details",
".",
"getOrderId",
"(",
")",
"==",
"null",
"||",
"details",
".",
"getOrderId",
"(",
")",
".",
"trim",
"(",
")",
".",
"length",
"(",
")",
"==",
"0",
")",
"return",
"false",
";",
"int",
"index",
"=",
"details",
".",
"getOrderId",
"(",
")",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"index",
"<=",
"0",
")",
"return",
"false",
";",
"//protect on missing merchant id",
"//extract merchant id",
"String",
"merchantId",
"=",
"details",
".",
"getOrderId",
"(",
")",
".",
"substring",
"(",
"0",
",",
"index",
")",
";",
"return",
"merchantId",
".",
"compareTo",
"(",
"developerMerchantId",
")",
"==",
"0",
";",
"}"
] |
Checks merchant's id validity. If purchase was generated by Freedom alike program it doesn't know
real merchant id, unless publisher GoogleId was hacked
If merchantId was not supplied function checks nothing
@param details TransactionDetails
@return boolean
|
[
"Checks",
"merchant",
"s",
"id",
"validity",
".",
"If",
"purchase",
"was",
"generated",
"by",
"Freedom",
"alike",
"program",
"it",
"doesn",
"t",
"know",
"real",
"merchant",
"id",
"unless",
"publisher",
"GoogleId",
"was",
"hacked",
"If",
"merchantId",
"was",
"not",
"supplied",
"function",
"checks",
"nothing"
] |
b7a02458ecc7529adaa25959822bd6d08cd3ebd0
|
https://github.com/pavlospt/RxIAPv3/blob/b7a02458ecc7529adaa25959822bd6d08cd3ebd0/androidiap/src/main/java/com/pavlospt/androidiap/billing/BillingProcessor.java#L927-L942
|
8,704
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/help/DocletUtils.java
|
DocletUtils.getClassName
|
protected static String getClassName(ProgramElementDoc doc, boolean binaryName) {
PackageDoc containingPackage = doc.containingPackage();
String className = doc.name();
if (binaryName) {
className = className.replaceAll("\\.", "\\$");
}
return containingPackage.name().length() > 0 ?
String.format("%s.%s", containingPackage.name(), className) :
String.format("%s", className);
}
|
java
|
protected static String getClassName(ProgramElementDoc doc, boolean binaryName) {
PackageDoc containingPackage = doc.containingPackage();
String className = doc.name();
if (binaryName) {
className = className.replaceAll("\\.", "\\$");
}
return containingPackage.name().length() > 0 ?
String.format("%s.%s", containingPackage.name(), className) :
String.format("%s", className);
}
|
[
"protected",
"static",
"String",
"getClassName",
"(",
"ProgramElementDoc",
"doc",
",",
"boolean",
"binaryName",
")",
"{",
"PackageDoc",
"containingPackage",
"=",
"doc",
".",
"containingPackage",
"(",
")",
";",
"String",
"className",
"=",
"doc",
".",
"name",
"(",
")",
";",
"if",
"(",
"binaryName",
")",
"{",
"className",
"=",
"className",
".",
"replaceAll",
"(",
"\"\\\\.\"",
",",
"\"\\\\$\"",
")",
";",
"}",
"return",
"containingPackage",
".",
"name",
"(",
")",
".",
"length",
"(",
")",
">",
"0",
"?",
"String",
".",
"format",
"(",
"\"%s.%s\"",
",",
"containingPackage",
".",
"name",
"(",
")",
",",
"className",
")",
":",
"String",
".",
"format",
"(",
"\"%s\"",
",",
"className",
")",
";",
"}"
] |
Reconstitute the class name from the given class JavaDoc object.
@param doc the Javadoc model for the given class.
@return The (string) class name of the given class.
|
[
"Reconstitute",
"the",
"class",
"name",
"from",
"the",
"given",
"class",
"JavaDoc",
"object",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/help/DocletUtils.java#L35-L44
|
8,705
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/help/DefaultDocWorkUnitHandler.java
|
DefaultDocWorkUnitHandler.getSummaryForWorkUnit
|
@Override
public String getSummaryForWorkUnit(final DocWorkUnit workUnit) {
String summary = workUnit.getDocumentedFeature().summary();
if (summary == null || summary.isEmpty()) {
final CommandLineProgramProperties commandLineProperties = workUnit.getCommandLineProperties();
if (commandLineProperties != null) {
summary = commandLineProperties.oneLineSummary();
}
if (summary == null || summary.isEmpty()) {
// If no summary was found from annotations, use the javadoc if there is any
summary = Arrays.stream(workUnit.getClassDoc().firstSentenceTags())
.map(tag -> tag.text())
.collect(Collectors.joining());
}
}
return summary == null ? "" : summary;
}
|
java
|
@Override
public String getSummaryForWorkUnit(final DocWorkUnit workUnit) {
String summary = workUnit.getDocumentedFeature().summary();
if (summary == null || summary.isEmpty()) {
final CommandLineProgramProperties commandLineProperties = workUnit.getCommandLineProperties();
if (commandLineProperties != null) {
summary = commandLineProperties.oneLineSummary();
}
if (summary == null || summary.isEmpty()) {
// If no summary was found from annotations, use the javadoc if there is any
summary = Arrays.stream(workUnit.getClassDoc().firstSentenceTags())
.map(tag -> tag.text())
.collect(Collectors.joining());
}
}
return summary == null ? "" : summary;
}
|
[
"@",
"Override",
"public",
"String",
"getSummaryForWorkUnit",
"(",
"final",
"DocWorkUnit",
"workUnit",
")",
"{",
"String",
"summary",
"=",
"workUnit",
".",
"getDocumentedFeature",
"(",
")",
".",
"summary",
"(",
")",
";",
"if",
"(",
"summary",
"==",
"null",
"||",
"summary",
".",
"isEmpty",
"(",
")",
")",
"{",
"final",
"CommandLineProgramProperties",
"commandLineProperties",
"=",
"workUnit",
".",
"getCommandLineProperties",
"(",
")",
";",
"if",
"(",
"commandLineProperties",
"!=",
"null",
")",
"{",
"summary",
"=",
"commandLineProperties",
".",
"oneLineSummary",
"(",
")",
";",
"}",
"if",
"(",
"summary",
"==",
"null",
"||",
"summary",
".",
"isEmpty",
"(",
")",
")",
"{",
"// If no summary was found from annotations, use the javadoc if there is any",
"summary",
"=",
"Arrays",
".",
"stream",
"(",
"workUnit",
".",
"getClassDoc",
"(",
")",
".",
"firstSentenceTags",
"(",
")",
")",
".",
"map",
"(",
"tag",
"->",
"tag",
".",
"text",
"(",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"joining",
"(",
")",
")",
";",
"}",
"}",
"return",
"summary",
"==",
"null",
"?",
"\"\"",
":",
"summary",
";",
"}"
] |
Get the summary string to be used for a given work unit, applying any fallback policy. This is
called by the work unit handler after the work unit has been populated, and may be overridden by
subclasses to provide custom behavior.
@param workUnit
@return the summary string to be used for this work unit
|
[
"Get",
"the",
"summary",
"string",
"to",
"be",
"used",
"for",
"a",
"given",
"work",
"unit",
"applying",
"any",
"fallback",
"policy",
".",
"This",
"is",
"called",
"by",
"the",
"work",
"unit",
"handler",
"after",
"the",
"work",
"unit",
"has",
"been",
"populated",
"and",
"may",
"be",
"overridden",
"by",
"subclasses",
"to",
"provide",
"custom",
"behavior",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/help/DefaultDocWorkUnitHandler.java#L56-L73
|
8,706
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/help/DefaultDocWorkUnitHandler.java
|
DefaultDocWorkUnitHandler.getGroupNameForWorkUnit
|
@Override
public String getGroupNameForWorkUnit(final DocWorkUnit workUnit) {
String groupName = workUnit.getDocumentedFeature().groupName();
if (groupName == null || groupName.isEmpty()) {
final CommandLineProgramGroup clpGroup = workUnit.getCommandLineProgramGroup();
if (clpGroup != null) {
groupName = clpGroup.getName();
}
if (groupName == null || groupName.isEmpty()) {
logger.warn("No group name declared for: " + workUnit.getClazz().getCanonicalName());
groupName = "";
}
}
return groupName;
}
|
java
|
@Override
public String getGroupNameForWorkUnit(final DocWorkUnit workUnit) {
String groupName = workUnit.getDocumentedFeature().groupName();
if (groupName == null || groupName.isEmpty()) {
final CommandLineProgramGroup clpGroup = workUnit.getCommandLineProgramGroup();
if (clpGroup != null) {
groupName = clpGroup.getName();
}
if (groupName == null || groupName.isEmpty()) {
logger.warn("No group name declared for: " + workUnit.getClazz().getCanonicalName());
groupName = "";
}
}
return groupName;
}
|
[
"@",
"Override",
"public",
"String",
"getGroupNameForWorkUnit",
"(",
"final",
"DocWorkUnit",
"workUnit",
")",
"{",
"String",
"groupName",
"=",
"workUnit",
".",
"getDocumentedFeature",
"(",
")",
".",
"groupName",
"(",
")",
";",
"if",
"(",
"groupName",
"==",
"null",
"||",
"groupName",
".",
"isEmpty",
"(",
")",
")",
"{",
"final",
"CommandLineProgramGroup",
"clpGroup",
"=",
"workUnit",
".",
"getCommandLineProgramGroup",
"(",
")",
";",
"if",
"(",
"clpGroup",
"!=",
"null",
")",
"{",
"groupName",
"=",
"clpGroup",
".",
"getName",
"(",
")",
";",
"}",
"if",
"(",
"groupName",
"==",
"null",
"||",
"groupName",
".",
"isEmpty",
"(",
")",
")",
"{",
"logger",
".",
"warn",
"(",
"\"No group name declared for: \"",
"+",
"workUnit",
".",
"getClazz",
"(",
")",
".",
"getCanonicalName",
"(",
")",
")",
";",
"groupName",
"=",
"\"\"",
";",
"}",
"}",
"return",
"groupName",
";",
"}"
] |
Get the group name string to be used for a given work unit, applying any fallback policy. This is
called by the work unit handler after the work unit has been populated, and may be overridden by
subclasses to provide custom behavior.
@param workUnit
@return the group name to be used for this work unit
|
[
"Get",
"the",
"group",
"name",
"string",
"to",
"be",
"used",
"for",
"a",
"given",
"work",
"unit",
"applying",
"any",
"fallback",
"policy",
".",
"This",
"is",
"called",
"by",
"the",
"work",
"unit",
"handler",
"after",
"the",
"work",
"unit",
"has",
"been",
"populated",
"and",
"may",
"be",
"overridden",
"by",
"subclasses",
"to",
"provide",
"custom",
"behavior",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/help/DefaultDocWorkUnitHandler.java#L83-L97
|
8,707
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/help/DefaultDocWorkUnitHandler.java
|
DefaultDocWorkUnitHandler.getGroupSummaryForWorkUnit
|
@Override
public String getGroupSummaryForWorkUnit( final DocWorkUnit workUnit){
String groupSummary = workUnit.getDocumentedFeature().groupSummary();
final CommandLineProgramGroup clpGroup = workUnit.getCommandLineProgramGroup();
if (groupSummary == null || groupSummary.isEmpty()) {
if (clpGroup != null) {
groupSummary = clpGroup.getDescription();
}
if (groupSummary == null || groupSummary.isEmpty()) {
logger.warn("No group summary declared for: " + workUnit.getClazz().getCanonicalName());
groupSummary = "";
}
}
return groupSummary;
}
|
java
|
@Override
public String getGroupSummaryForWorkUnit( final DocWorkUnit workUnit){
String groupSummary = workUnit.getDocumentedFeature().groupSummary();
final CommandLineProgramGroup clpGroup = workUnit.getCommandLineProgramGroup();
if (groupSummary == null || groupSummary.isEmpty()) {
if (clpGroup != null) {
groupSummary = clpGroup.getDescription();
}
if (groupSummary == null || groupSummary.isEmpty()) {
logger.warn("No group summary declared for: " + workUnit.getClazz().getCanonicalName());
groupSummary = "";
}
}
return groupSummary;
}
|
[
"@",
"Override",
"public",
"String",
"getGroupSummaryForWorkUnit",
"(",
"final",
"DocWorkUnit",
"workUnit",
")",
"{",
"String",
"groupSummary",
"=",
"workUnit",
".",
"getDocumentedFeature",
"(",
")",
".",
"groupSummary",
"(",
")",
";",
"final",
"CommandLineProgramGroup",
"clpGroup",
"=",
"workUnit",
".",
"getCommandLineProgramGroup",
"(",
")",
";",
"if",
"(",
"groupSummary",
"==",
"null",
"||",
"groupSummary",
".",
"isEmpty",
"(",
")",
")",
"{",
"if",
"(",
"clpGroup",
"!=",
"null",
")",
"{",
"groupSummary",
"=",
"clpGroup",
".",
"getDescription",
"(",
")",
";",
"}",
"if",
"(",
"groupSummary",
"==",
"null",
"||",
"groupSummary",
".",
"isEmpty",
"(",
")",
")",
"{",
"logger",
".",
"warn",
"(",
"\"No group summary declared for: \"",
"+",
"workUnit",
".",
"getClazz",
"(",
")",
".",
"getCanonicalName",
"(",
")",
")",
";",
"groupSummary",
"=",
"\"\"",
";",
"}",
"}",
"return",
"groupSummary",
";",
"}"
] |
Get the group summary string to be used for a given work unit's group, applying any fallback policy.
This is called by the work unit handler after the work unit has been populated, and may be overridden by
subclasses to provide custom behavior.
@param workUnit
@return the group summary to be used for this work unit's group
|
[
"Get",
"the",
"group",
"summary",
"string",
"to",
"be",
"used",
"for",
"a",
"given",
"work",
"unit",
"s",
"group",
"applying",
"any",
"fallback",
"policy",
".",
"This",
"is",
"called",
"by",
"the",
"work",
"unit",
"handler",
"after",
"the",
"work",
"unit",
"has",
"been",
"populated",
"and",
"may",
"be",
"overridden",
"by",
"subclasses",
"to",
"provide",
"custom",
"behavior",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/help/DefaultDocWorkUnitHandler.java#L107-L121
|
8,708
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/help/DefaultDocWorkUnitHandler.java
|
DefaultDocWorkUnitHandler.getDescription
|
protected String getDescription(final DocWorkUnit currentWorkUnit) {
return Arrays.stream(currentWorkUnit.getClassDoc().inlineTags())
.filter(t -> getTagPrefix() == null || !t.name().startsWith(getTagPrefix()))
.map(t -> t.text())
.collect(Collectors.joining());
}
|
java
|
protected String getDescription(final DocWorkUnit currentWorkUnit) {
return Arrays.stream(currentWorkUnit.getClassDoc().inlineTags())
.filter(t -> getTagPrefix() == null || !t.name().startsWith(getTagPrefix()))
.map(t -> t.text())
.collect(Collectors.joining());
}
|
[
"protected",
"String",
"getDescription",
"(",
"final",
"DocWorkUnit",
"currentWorkUnit",
")",
"{",
"return",
"Arrays",
".",
"stream",
"(",
"currentWorkUnit",
".",
"getClassDoc",
"(",
")",
".",
"inlineTags",
"(",
")",
")",
".",
"filter",
"(",
"t",
"->",
"getTagPrefix",
"(",
")",
"==",
"null",
"||",
"!",
"t",
".",
"name",
"(",
")",
".",
"startsWith",
"(",
"getTagPrefix",
"(",
")",
")",
")",
".",
"map",
"(",
"t",
"->",
"t",
".",
"text",
"(",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"joining",
"(",
")",
")",
";",
"}"
] |
Return the description to be used for the work unit. We need to manually strip
out any inline custom javadoc tags since we don't those in the summary.
@param currentWorkUnit
@return Description to be used or the work unit.
|
[
"Return",
"the",
"description",
"to",
"be",
"used",
"for",
"the",
"work",
"unit",
".",
"We",
"need",
"to",
"manually",
"strip",
"out",
"any",
"inline",
"custom",
"javadoc",
"tags",
"since",
"we",
"don",
"t",
"those",
"in",
"the",
"summary",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/help/DefaultDocWorkUnitHandler.java#L130-L135
|
8,709
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/help/DefaultDocWorkUnitHandler.java
|
DefaultDocWorkUnitHandler.addHighLevelBindings
|
protected void addHighLevelBindings(final DocWorkUnit workUnit)
{
workUnit.setProperty("name", workUnit.getName());
workUnit.setProperty("group", workUnit.getGroupName());
workUnit.setProperty("summary", workUnit.getSummary());
// Note that these properties are inserted into the toplevel WorkUnit FreeMarker map typed
// as Strings, with values "true" or "false", but the same entries are typed as Booleans in the
// FreeMarker map for the index.
workUnit.setProperty("beta", workUnit.isBetaFeature());
workUnit.setProperty("experimental", workUnit.isExperimentalFeature());
workUnit.setProperty("description", getDescription(workUnit));
workUnit.setProperty("version", getDoclet().getBuildVersion());
workUnit.setProperty("timestamp", getDoclet().getBuildTimeStamp());
}
|
java
|
protected void addHighLevelBindings(final DocWorkUnit workUnit)
{
workUnit.setProperty("name", workUnit.getName());
workUnit.setProperty("group", workUnit.getGroupName());
workUnit.setProperty("summary", workUnit.getSummary());
// Note that these properties are inserted into the toplevel WorkUnit FreeMarker map typed
// as Strings, with values "true" or "false", but the same entries are typed as Booleans in the
// FreeMarker map for the index.
workUnit.setProperty("beta", workUnit.isBetaFeature());
workUnit.setProperty("experimental", workUnit.isExperimentalFeature());
workUnit.setProperty("description", getDescription(workUnit));
workUnit.setProperty("version", getDoclet().getBuildVersion());
workUnit.setProperty("timestamp", getDoclet().getBuildTimeStamp());
}
|
[
"protected",
"void",
"addHighLevelBindings",
"(",
"final",
"DocWorkUnit",
"workUnit",
")",
"{",
"workUnit",
".",
"setProperty",
"(",
"\"name\"",
",",
"workUnit",
".",
"getName",
"(",
")",
")",
";",
"workUnit",
".",
"setProperty",
"(",
"\"group\"",
",",
"workUnit",
".",
"getGroupName",
"(",
")",
")",
";",
"workUnit",
".",
"setProperty",
"(",
"\"summary\"",
",",
"workUnit",
".",
"getSummary",
"(",
")",
")",
";",
"// Note that these properties are inserted into the toplevel WorkUnit FreeMarker map typed",
"// as Strings, with values \"true\" or \"false\", but the same entries are typed as Booleans in the",
"// FreeMarker map for the index.",
"workUnit",
".",
"setProperty",
"(",
"\"beta\"",
",",
"workUnit",
".",
"isBetaFeature",
"(",
")",
")",
";",
"workUnit",
".",
"setProperty",
"(",
"\"experimental\"",
",",
"workUnit",
".",
"isExperimentalFeature",
"(",
")",
")",
";",
"workUnit",
".",
"setProperty",
"(",
"\"description\"",
",",
"getDescription",
"(",
"workUnit",
")",
")",
";",
"workUnit",
".",
"setProperty",
"(",
"\"version\"",
",",
"getDoclet",
"(",
")",
".",
"getBuildVersion",
"(",
")",
")",
";",
"workUnit",
".",
"setProperty",
"(",
"\"timestamp\"",
",",
"getDoclet",
"(",
")",
".",
"getBuildTimeStamp",
"(",
")",
")",
";",
"}"
] |
Add high-level summary information, such as name, summary, description, version, etc.
@param workUnit
|
[
"Add",
"high",
"-",
"level",
"summary",
"information",
"such",
"as",
"name",
"summary",
"description",
"version",
"etc",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/help/DefaultDocWorkUnitHandler.java#L226-L242
|
8,710
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/help/DefaultDocWorkUnitHandler.java
|
DefaultDocWorkUnitHandler.addCustomBindings
|
protected void addCustomBindings(final DocWorkUnit currentWorkUnit) {
final String tagFilterPrefix = getTagPrefix();
Arrays.stream(currentWorkUnit.getClassDoc().inlineTags())
.filter(t -> t.name().startsWith(tagFilterPrefix))
.forEach(t -> currentWorkUnit.setProperty(t.name().substring(tagFilterPrefix.length()), t.text()));
}
|
java
|
protected void addCustomBindings(final DocWorkUnit currentWorkUnit) {
final String tagFilterPrefix = getTagPrefix();
Arrays.stream(currentWorkUnit.getClassDoc().inlineTags())
.filter(t -> t.name().startsWith(tagFilterPrefix))
.forEach(t -> currentWorkUnit.setProperty(t.name().substring(tagFilterPrefix.length()), t.text()));
}
|
[
"protected",
"void",
"addCustomBindings",
"(",
"final",
"DocWorkUnit",
"currentWorkUnit",
")",
"{",
"final",
"String",
"tagFilterPrefix",
"=",
"getTagPrefix",
"(",
")",
";",
"Arrays",
".",
"stream",
"(",
"currentWorkUnit",
".",
"getClassDoc",
"(",
")",
".",
"inlineTags",
"(",
")",
")",
".",
"filter",
"(",
"t",
"->",
"t",
".",
"name",
"(",
")",
".",
"startsWith",
"(",
"tagFilterPrefix",
")",
")",
".",
"forEach",
"(",
"t",
"->",
"currentWorkUnit",
".",
"setProperty",
"(",
"t",
".",
"name",
"(",
")",
".",
"substring",
"(",
"tagFilterPrefix",
".",
"length",
"(",
")",
")",
",",
"t",
".",
"text",
"(",
")",
")",
")",
";",
"}"
] |
Add any custom freemarker bindings discovered via custom javadoc tags. Subclasses can override this to
provide additional custom bindings.
@param currentWorkUnit the work unit for the feature being documented
|
[
"Add",
"any",
"custom",
"freemarker",
"bindings",
"discovered",
"via",
"custom",
"javadoc",
"tags",
".",
"Subclasses",
"can",
"override",
"this",
"to",
"provide",
"additional",
"custom",
"bindings",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/help/DefaultDocWorkUnitHandler.java#L250-L255
|
8,711
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/help/DefaultDocWorkUnitHandler.java
|
DefaultDocWorkUnitHandler.addExtraDocsBindings
|
protected void addExtraDocsBindings(final DocWorkUnit currentWorkUnit)
{
final List<Map<String, Object>> extraDocsData = new ArrayList<Map<String, Object>>();
// add in all of the explicitly related extradocs items
for (final Class<?> extraDocClass : currentWorkUnit.getDocumentedFeature().extraDocs()) {
final DocWorkUnit otherUnit = getDoclet().findWorkUnitForClass(extraDocClass);
if (otherUnit != null) {
extraDocsData.add(
new HashMap<String, Object>() {
static final long serialVersionUID = 0L;
{
put("name", otherUnit.getName());
put("filename", otherUnit.getTargetFileName());
}
});
} else {
final String msg = String.format(
"An \"extradocs\" value (%s) was specified for (%s), but the target was not included in the " +
"source list for this javadoc run, or the target has no documentation.",
extraDocClass,
currentWorkUnit.getName()
);
throw new DocException(msg);
}
}
currentWorkUnit.setProperty("extradocs", extraDocsData);
}
|
java
|
protected void addExtraDocsBindings(final DocWorkUnit currentWorkUnit)
{
final List<Map<String, Object>> extraDocsData = new ArrayList<Map<String, Object>>();
// add in all of the explicitly related extradocs items
for (final Class<?> extraDocClass : currentWorkUnit.getDocumentedFeature().extraDocs()) {
final DocWorkUnit otherUnit = getDoclet().findWorkUnitForClass(extraDocClass);
if (otherUnit != null) {
extraDocsData.add(
new HashMap<String, Object>() {
static final long serialVersionUID = 0L;
{
put("name", otherUnit.getName());
put("filename", otherUnit.getTargetFileName());
}
});
} else {
final String msg = String.format(
"An \"extradocs\" value (%s) was specified for (%s), but the target was not included in the " +
"source list for this javadoc run, or the target has no documentation.",
extraDocClass,
currentWorkUnit.getName()
);
throw new DocException(msg);
}
}
currentWorkUnit.setProperty("extradocs", extraDocsData);
}
|
[
"protected",
"void",
"addExtraDocsBindings",
"(",
"final",
"DocWorkUnit",
"currentWorkUnit",
")",
"{",
"final",
"List",
"<",
"Map",
"<",
"String",
",",
"Object",
">",
">",
"extraDocsData",
"=",
"new",
"ArrayList",
"<",
"Map",
"<",
"String",
",",
"Object",
">",
">",
"(",
")",
";",
"// add in all of the explicitly related extradocs items",
"for",
"(",
"final",
"Class",
"<",
"?",
">",
"extraDocClass",
":",
"currentWorkUnit",
".",
"getDocumentedFeature",
"(",
")",
".",
"extraDocs",
"(",
")",
")",
"{",
"final",
"DocWorkUnit",
"otherUnit",
"=",
"getDoclet",
"(",
")",
".",
"findWorkUnitForClass",
"(",
"extraDocClass",
")",
";",
"if",
"(",
"otherUnit",
"!=",
"null",
")",
"{",
"extraDocsData",
".",
"add",
"(",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
"{",
"static",
"final",
"long",
"serialVersionUID",
"=",
"0L",
";",
"{",
"put",
"(",
"\"name\"",
",",
"otherUnit",
".",
"getName",
"(",
")",
")",
";",
"put",
"(",
"\"filename\"",
",",
"otherUnit",
".",
"getTargetFileName",
"(",
")",
")",
";",
"}",
"}",
")",
";",
"}",
"else",
"{",
"final",
"String",
"msg",
"=",
"String",
".",
"format",
"(",
"\"An \\\"extradocs\\\" value (%s) was specified for (%s), but the target was not included in the \"",
"+",
"\"source list for this javadoc run, or the target has no documentation.\"",
",",
"extraDocClass",
",",
"currentWorkUnit",
".",
"getName",
"(",
")",
")",
";",
"throw",
"new",
"DocException",
"(",
"msg",
")",
";",
"}",
"}",
"currentWorkUnit",
".",
"setProperty",
"(",
"\"extradocs\"",
",",
"extraDocsData",
")",
";",
"}"
] |
Add bindings describing related capabilities to currentWorkUnit
|
[
"Add",
"bindings",
"describing",
"related",
"capabilities",
"to",
"currentWorkUnit"
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/help/DefaultDocWorkUnitHandler.java#L266-L293
|
8,712
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/help/DefaultDocWorkUnitHandler.java
|
DefaultDocWorkUnitHandler.createArgumentMap
|
private Map<String, List<Map<String, Object>>> createArgumentMap() {
final Map<String, List<Map<String, Object>>> args = new HashMap<String, List<Map<String, Object>>>();
args.put("all", new ArrayList<>());
args.put("common", new ArrayList<>());
args.put("positional", new ArrayList<>());
args.put("required", new ArrayList<>());
args.put("optional", new ArrayList<>());
args.put("advanced", new ArrayList<>());
args.put("dependent", new ArrayList<>());
args.put("hidden", new ArrayList<>());
args.put("deprecated", new ArrayList<>());
return args;
}
|
java
|
private Map<String, List<Map<String, Object>>> createArgumentMap() {
final Map<String, List<Map<String, Object>>> args = new HashMap<String, List<Map<String, Object>>>();
args.put("all", new ArrayList<>());
args.put("common", new ArrayList<>());
args.put("positional", new ArrayList<>());
args.put("required", new ArrayList<>());
args.put("optional", new ArrayList<>());
args.put("advanced", new ArrayList<>());
args.put("dependent", new ArrayList<>());
args.put("hidden", new ArrayList<>());
args.put("deprecated", new ArrayList<>());
return args;
}
|
[
"private",
"Map",
"<",
"String",
",",
"List",
"<",
"Map",
"<",
"String",
",",
"Object",
">",
">",
">",
"createArgumentMap",
"(",
")",
"{",
"final",
"Map",
"<",
"String",
",",
"List",
"<",
"Map",
"<",
"String",
",",
"Object",
">",
">",
">",
"args",
"=",
"new",
"HashMap",
"<",
"String",
",",
"List",
"<",
"Map",
"<",
"String",
",",
"Object",
">",
">",
">",
"(",
")",
";",
"args",
".",
"put",
"(",
"\"all\"",
",",
"new",
"ArrayList",
"<>",
"(",
")",
")",
";",
"args",
".",
"put",
"(",
"\"common\"",
",",
"new",
"ArrayList",
"<>",
"(",
")",
")",
";",
"args",
".",
"put",
"(",
"\"positional\"",
",",
"new",
"ArrayList",
"<>",
"(",
")",
")",
";",
"args",
".",
"put",
"(",
"\"required\"",
",",
"new",
"ArrayList",
"<>",
"(",
")",
")",
";",
"args",
".",
"put",
"(",
"\"optional\"",
",",
"new",
"ArrayList",
"<>",
"(",
")",
")",
";",
"args",
".",
"put",
"(",
"\"advanced\"",
",",
"new",
"ArrayList",
"<>",
"(",
")",
")",
";",
"args",
".",
"put",
"(",
"\"dependent\"",
",",
"new",
"ArrayList",
"<>",
"(",
")",
")",
";",
"args",
".",
"put",
"(",
"\"hidden\"",
",",
"new",
"ArrayList",
"<>",
"(",
")",
")",
";",
"args",
".",
"put",
"(",
"\"deprecated\"",
",",
"new",
"ArrayList",
"<>",
"(",
")",
")",
";",
"return",
"args",
";",
"}"
] |
Create the argument map for holding class arguments
@return
|
[
"Create",
"the",
"argument",
"map",
"for",
"holding",
"class",
"arguments"
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/help/DefaultDocWorkUnitHandler.java#L514-L526
|
8,713
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/help/DefaultDocWorkUnitHandler.java
|
DefaultDocWorkUnitHandler.sortArguments
|
private List<Map<String, Object>> sortArguments(final List<Map<String, Object>> unsorted) {
Collections.sort(unsorted, new CompareArgumentsByName());
return unsorted;
}
|
java
|
private List<Map<String, Object>> sortArguments(final List<Map<String, Object>> unsorted) {
Collections.sort(unsorted, new CompareArgumentsByName());
return unsorted;
}
|
[
"private",
"List",
"<",
"Map",
"<",
"String",
",",
"Object",
">",
">",
"sortArguments",
"(",
"final",
"List",
"<",
"Map",
"<",
"String",
",",
"Object",
">",
">",
"unsorted",
")",
"{",
"Collections",
".",
"sort",
"(",
"unsorted",
",",
"new",
"CompareArgumentsByName",
"(",
")",
")",
";",
"return",
"unsorted",
";",
"}"
] |
Sorts the individual argument list in unsorted according to CompareArgumentsByName
@param unsorted
@return
|
[
"Sorts",
"the",
"individual",
"argument",
"list",
"in",
"unsorted",
"according",
"to",
"CompareArgumentsByName"
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/help/DefaultDocWorkUnitHandler.java#L534-L537
|
8,714
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/help/DefaultDocWorkUnitHandler.java
|
DefaultDocWorkUnitHandler.prettyPrintValueString
|
private Object prettyPrintValueString(final Object value) {
if (value instanceof String) {
return value.equals("") ? "\"\"" : value;
} else {
return value.toString();
}
}
|
java
|
private Object prettyPrintValueString(final Object value) {
if (value instanceof String) {
return value.equals("") ? "\"\"" : value;
} else {
return value.toString();
}
}
|
[
"private",
"Object",
"prettyPrintValueString",
"(",
"final",
"Object",
"value",
")",
"{",
"if",
"(",
"value",
"instanceof",
"String",
")",
"{",
"return",
"value",
".",
"equals",
"(",
"\"\"",
")",
"?",
"\"\\\"\\\"\"",
":",
"value",
";",
"}",
"else",
"{",
"return",
"value",
".",
"toString",
"(",
")",
";",
"}",
"}"
] |
Pretty prints value
Assumes value != null
@param value
@return
|
[
"Pretty",
"prints",
"value"
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/help/DefaultDocWorkUnitHandler.java#L568-L574
|
8,715
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/help/DefaultDocWorkUnitHandler.java
|
DefaultDocWorkUnitHandler.argumentTypeString
|
protected String argumentTypeString(final Type type) {
if (type instanceof ParameterizedType) {
final ParameterizedType parameterizedType = (ParameterizedType) type;
final List<String> subs = new ArrayList<>();
for (final Type actualType : parameterizedType.getActualTypeArguments())
subs.add(argumentTypeString(actualType));
return argumentTypeString(((ParameterizedType) type).getRawType()) + "[" + String.join(",", subs) + "]";
} else if (type instanceof GenericArrayType) {
return argumentTypeString(((GenericArrayType) type).getGenericComponentType()) + "[]";
} else if (type instanceof WildcardType) {
throw new RuntimeException("We don't support wildcards in arguments: " + type);
} else if (type instanceof Class<?>) {
return ((Class) type).getSimpleName();
} else {
throw new DocException("Unknown type: " + type);
}
}
|
java
|
protected String argumentTypeString(final Type type) {
if (type instanceof ParameterizedType) {
final ParameterizedType parameterizedType = (ParameterizedType) type;
final List<String> subs = new ArrayList<>();
for (final Type actualType : parameterizedType.getActualTypeArguments())
subs.add(argumentTypeString(actualType));
return argumentTypeString(((ParameterizedType) type).getRawType()) + "[" + String.join(",", subs) + "]";
} else if (type instanceof GenericArrayType) {
return argumentTypeString(((GenericArrayType) type).getGenericComponentType()) + "[]";
} else if (type instanceof WildcardType) {
throw new RuntimeException("We don't support wildcards in arguments: " + type);
} else if (type instanceof Class<?>) {
return ((Class) type).getSimpleName();
} else {
throw new DocException("Unknown type: " + type);
}
}
|
[
"protected",
"String",
"argumentTypeString",
"(",
"final",
"Type",
"type",
")",
"{",
"if",
"(",
"type",
"instanceof",
"ParameterizedType",
")",
"{",
"final",
"ParameterizedType",
"parameterizedType",
"=",
"(",
"ParameterizedType",
")",
"type",
";",
"final",
"List",
"<",
"String",
">",
"subs",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"final",
"Type",
"actualType",
":",
"parameterizedType",
".",
"getActualTypeArguments",
"(",
")",
")",
"subs",
".",
"(",
"argumentTypeString",
"(",
"actualType",
")",
")",
";",
"return",
"argumentTypeString",
"(",
"(",
"(",
"ParameterizedType",
")",
"type",
")",
".",
"getRawType",
"(",
")",
")",
"+",
"\"[\"",
"+",
"String",
".",
"join",
"(",
"\",\"",
",",
"subs",
")",
"+",
"\"]\"",
";",
"}",
"else",
"if",
"(",
"type",
"instanceof",
"GenericArrayType",
")",
"{",
"return",
"argumentTypeString",
"(",
"(",
"(",
"GenericArrayType",
")",
"type",
")",
".",
"getGenericComponentType",
"(",
")",
")",
"+",
"\"[]\"",
";",
"}",
"else",
"if",
"(",
"type",
"instanceof",
"WildcardType",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"We don't support wildcards in arguments: \"",
"+",
"type",
")",
";",
"}",
"else",
"if",
"(",
"type",
"instanceof",
"Class",
"<",
"?",
">",
")",
"{",
"return",
"(",
"(",
"Class",
")",
"type",
")",
".",
"getSimpleName",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"DocException",
"(",
"\"Unknown type: \"",
"+",
"type",
")",
";",
"}",
"}"
] |
Returns a human readable string that describes the Type type of an argument.
This will include parametrized types, so that Set{T} shows up as Set(T) and not
just Set in the docs.
@param type
@return String representing the argument type
|
[
"Returns",
"a",
"human",
"readable",
"string",
"that",
"describes",
"the",
"Type",
"type",
"of",
"an",
"argument",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/help/DefaultDocWorkUnitHandler.java#L654-L670
|
8,716
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/help/DefaultDocWorkUnitHandler.java
|
DefaultDocWorkUnitHandler.docForEnumArgument
|
private List<Map<String, Object>> docForEnumArgument(final Class<?> enumClass) {
final ClassDoc doc = this.getDoclet().getClassDocForClass(enumClass);
if ( doc == null ) {
throw new RuntimeException("Tried to get docs for enum " + enumClass + " but got null instead");
}
final Set<String> enumConstantFieldNames = enumConstantsNames(enumClass);
final List<Map<String, Object>> bindings = new ArrayList<Map<String, Object>>();
for (final FieldDoc fieldDoc : doc.fields(false)) {
if (enumConstantFieldNames.contains(fieldDoc.name()) ) {
bindings.add(
new HashMap<String, Object>() {
static final long serialVersionUID = 0L;
{
put("name", fieldDoc.name());
put("summary", fieldDoc.commentText());
}
}
);
}
}
return bindings;
}
|
java
|
private List<Map<String, Object>> docForEnumArgument(final Class<?> enumClass) {
final ClassDoc doc = this.getDoclet().getClassDocForClass(enumClass);
if ( doc == null ) {
throw new RuntimeException("Tried to get docs for enum " + enumClass + " but got null instead");
}
final Set<String> enumConstantFieldNames = enumConstantsNames(enumClass);
final List<Map<String, Object>> bindings = new ArrayList<Map<String, Object>>();
for (final FieldDoc fieldDoc : doc.fields(false)) {
if (enumConstantFieldNames.contains(fieldDoc.name()) ) {
bindings.add(
new HashMap<String, Object>() {
static final long serialVersionUID = 0L;
{
put("name", fieldDoc.name());
put("summary", fieldDoc.commentText());
}
}
);
}
}
return bindings;
}
|
[
"private",
"List",
"<",
"Map",
"<",
"String",
",",
"Object",
">",
">",
"docForEnumArgument",
"(",
"final",
"Class",
"<",
"?",
">",
"enumClass",
")",
"{",
"final",
"ClassDoc",
"doc",
"=",
"this",
".",
"getDoclet",
"(",
")",
".",
"getClassDocForClass",
"(",
"enumClass",
")",
";",
"if",
"(",
"doc",
"==",
"null",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Tried to get docs for enum \"",
"+",
"enumClass",
"+",
"\" but got null instead\"",
")",
";",
"}",
"final",
"Set",
"<",
"String",
">",
"enumConstantFieldNames",
"=",
"enumConstantsNames",
"(",
"enumClass",
")",
";",
"final",
"List",
"<",
"Map",
"<",
"String",
",",
"Object",
">",
">",
"bindings",
"=",
"new",
"ArrayList",
"<",
"Map",
"<",
"String",
",",
"Object",
">",
">",
"(",
")",
";",
"for",
"(",
"final",
"FieldDoc",
"fieldDoc",
":",
"doc",
".",
"fields",
"(",
"false",
")",
")",
"{",
"if",
"(",
"enumConstantFieldNames",
".",
"contains",
"(",
"fieldDoc",
".",
"name",
"(",
")",
")",
")",
"{",
"bindings",
".",
"add",
"(",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
"{",
"static",
"final",
"long",
"serialVersionUID",
"=",
"0L",
";",
"{",
"put",
"(",
"\"name\"",
",",
"fieldDoc",
".",
"name",
"(",
")",
")",
";",
"put",
"(",
"\"summary\"",
",",
"fieldDoc",
".",
"commentText",
"(",
")",
")",
";",
"}",
"}",
")",
";",
"}",
"}",
"return",
"bindings",
";",
"}"
] |
Helper routine that provides a FreeMarker map for an enumClass, grabbing the
values of the enum and their associated javadoc documentation.
@param enumClass
@return
|
[
"Helper",
"routine",
"that",
"provides",
"a",
"FreeMarker",
"map",
"for",
"an",
"enumClass",
"grabbing",
"the",
"values",
"of",
"the",
"enum",
"and",
"their",
"associated",
"javadoc",
"documentation",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/help/DefaultDocWorkUnitHandler.java#L767-L790
|
8,717
|
ReactiveX/RxJavaJoins
|
src/main/java/rx/observables/JoinObservable.java
|
JoinObservable.from
|
public static <T> JoinObservable<T> from(Observable<T> o) {
return new JoinObservable<T>(o);
}
|
java
|
public static <T> JoinObservable<T> from(Observable<T> o) {
return new JoinObservable<T>(o);
}
|
[
"public",
"static",
"<",
"T",
">",
"JoinObservable",
"<",
"T",
">",
"from",
"(",
"Observable",
"<",
"T",
">",
"o",
")",
"{",
"return",
"new",
"JoinObservable",
"<",
"T",
">",
"(",
"o",
")",
";",
"}"
] |
Creates a JoinObservable from a regular Observable.
@param o the observable to wrap
@return the created JoinObservable instance
|
[
"Creates",
"a",
"JoinObservable",
"from",
"a",
"regular",
"Observable",
"."
] |
65b5c7fa03bd375c9e1f7906d7143068fde9b714
|
https://github.com/ReactiveX/RxJavaJoins/blob/65b5c7fa03bd375c9e1f7906d7143068fde9b714/src/main/java/rx/observables/JoinObservable.java#L27-L29
|
8,718
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/utils/Utils.java
|
Utils.prettyPrintWarningMessage
|
private static void prettyPrintWarningMessage(final List<String> results, final String message) {
for (final String line: message.split("\\r?\\n")) {
final StringBuilder builder = new StringBuilder(line);
while (builder.length() > TEXT_WARNING_WIDTH) {
int space = getLastSpace(builder, TEXT_WARNING_WIDTH);
if (space <= 0) space = TEXT_WARNING_WIDTH;
results.add(String.format("%s%s", TEXT_WARNING_PREFIX, builder.substring(0, space)));
builder.delete(0, space + 1);
}
results.add(String.format("%s%s", TEXT_WARNING_PREFIX, builder));
}
}
|
java
|
private static void prettyPrintWarningMessage(final List<String> results, final String message) {
for (final String line: message.split("\\r?\\n")) {
final StringBuilder builder = new StringBuilder(line);
while (builder.length() > TEXT_WARNING_WIDTH) {
int space = getLastSpace(builder, TEXT_WARNING_WIDTH);
if (space <= 0) space = TEXT_WARNING_WIDTH;
results.add(String.format("%s%s", TEXT_WARNING_PREFIX, builder.substring(0, space)));
builder.delete(0, space + 1);
}
results.add(String.format("%s%s", TEXT_WARNING_PREFIX, builder));
}
}
|
[
"private",
"static",
"void",
"prettyPrintWarningMessage",
"(",
"final",
"List",
"<",
"String",
">",
"results",
",",
"final",
"String",
"message",
")",
"{",
"for",
"(",
"final",
"String",
"line",
":",
"message",
".",
"split",
"(",
"\"\\\\r?\\\\n\"",
")",
")",
"{",
"final",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
"line",
")",
";",
"while",
"(",
"builder",
".",
"length",
"(",
")",
">",
"TEXT_WARNING_WIDTH",
")",
"{",
"int",
"space",
"=",
"getLastSpace",
"(",
"builder",
",",
"TEXT_WARNING_WIDTH",
")",
";",
"if",
"(",
"space",
"<=",
"0",
")",
"space",
"=",
"TEXT_WARNING_WIDTH",
";",
"results",
".",
"add",
"(",
"String",
".",
"format",
"(",
"\"%s%s\"",
",",
"TEXT_WARNING_PREFIX",
",",
"builder",
".",
"substring",
"(",
"0",
",",
"space",
")",
")",
")",
";",
"builder",
".",
"delete",
"(",
"0",
",",
"space",
"+",
"1",
")",
";",
"}",
"results",
".",
"add",
"(",
"String",
".",
"format",
"(",
"\"%s%s\"",
",",
"TEXT_WARNING_PREFIX",
",",
"builder",
")",
")",
";",
"}",
"}"
] |
pretty print the warning message supplied
@param results the pretty printed message
@param message the message
|
[
"pretty",
"print",
"the",
"warning",
"message",
"supplied"
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/utils/Utils.java#L79-L90
|
8,719
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/utils/Utils.java
|
Utils.getLastSpace
|
private static int getLastSpace(final CharSequence message, int width) {
final int length = message.length();
int stopPos = width;
int currPos = 0;
int lastSpace = -1;
boolean inEscape = false;
while (currPos < stopPos && currPos < length) {
final char c = message.charAt(currPos);
if (c == ESCAPE_CHAR) {
stopPos++;
inEscape = true;
} else if (inEscape) {
stopPos++;
if (Character.isLetter(c))
inEscape = false;
} else if (Character.isWhitespace(c)) {
lastSpace = currPos;
}
currPos++;
}
return lastSpace;
}
|
java
|
private static int getLastSpace(final CharSequence message, int width) {
final int length = message.length();
int stopPos = width;
int currPos = 0;
int lastSpace = -1;
boolean inEscape = false;
while (currPos < stopPos && currPos < length) {
final char c = message.charAt(currPos);
if (c == ESCAPE_CHAR) {
stopPos++;
inEscape = true;
} else if (inEscape) {
stopPos++;
if (Character.isLetter(c))
inEscape = false;
} else if (Character.isWhitespace(c)) {
lastSpace = currPos;
}
currPos++;
}
return lastSpace;
}
|
[
"private",
"static",
"int",
"getLastSpace",
"(",
"final",
"CharSequence",
"message",
",",
"int",
"width",
")",
"{",
"final",
"int",
"length",
"=",
"message",
".",
"length",
"(",
")",
";",
"int",
"stopPos",
"=",
"width",
";",
"int",
"currPos",
"=",
"0",
";",
"int",
"lastSpace",
"=",
"-",
"1",
";",
"boolean",
"inEscape",
"=",
"false",
";",
"while",
"(",
"currPos",
"<",
"stopPos",
"&&",
"currPos",
"<",
"length",
")",
"{",
"final",
"char",
"c",
"=",
"message",
".",
"charAt",
"(",
"currPos",
")",
";",
"if",
"(",
"c",
"==",
"ESCAPE_CHAR",
")",
"{",
"stopPos",
"++",
";",
"inEscape",
"=",
"true",
";",
"}",
"else",
"if",
"(",
"inEscape",
")",
"{",
"stopPos",
"++",
";",
"if",
"(",
"Character",
".",
"isLetter",
"(",
"c",
")",
")",
"inEscape",
"=",
"false",
";",
"}",
"else",
"if",
"(",
"Character",
".",
"isWhitespace",
"(",
"c",
")",
")",
"{",
"lastSpace",
"=",
"currPos",
";",
"}",
"currPos",
"++",
";",
"}",
"return",
"lastSpace",
";",
"}"
] |
Returns the last whitespace location in string, before width characters.
@param message The message to break.
@param width The width of the line.
@return The last whitespace location.
|
[
"Returns",
"the",
"last",
"whitespace",
"location",
"in",
"string",
"before",
"width",
"characters",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/utils/Utils.java#L98-L119
|
8,720
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/utils/Utils.java
|
Utils.dupString
|
public static String dupString(char c, int nCopies) {
char[] chars = new char[nCopies];
Arrays.fill(chars, c);
return new String(chars);
}
|
java
|
public static String dupString(char c, int nCopies) {
char[] chars = new char[nCopies];
Arrays.fill(chars, c);
return new String(chars);
}
|
[
"public",
"static",
"String",
"dupString",
"(",
"char",
"c",
",",
"int",
"nCopies",
")",
"{",
"char",
"[",
"]",
"chars",
"=",
"new",
"char",
"[",
"nCopies",
"]",
";",
"Arrays",
".",
"fill",
"(",
"chars",
",",
"c",
")",
";",
"return",
"new",
"String",
"(",
"chars",
")",
";",
"}"
] |
Create a new string thats a n duplicate copies of c
@param c the char to duplicate
@param nCopies how many copies?
@return a string
|
[
"Create",
"a",
"new",
"string",
"thats",
"a",
"n",
"duplicate",
"copies",
"of",
"c"
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/utils/Utils.java#L127-L131
|
8,721
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/utils/Utils.java
|
Utils.wrapParagraph
|
public static String wrapParagraph(final String input, final int width) {
if (input == null || input.isEmpty()) {
return input;
}
final StringBuilder out = new StringBuilder();
try (final BufferedReader bufReader = new BufferedReader(new StringReader(input))) {
out.append(bufReader.lines()
.map(line -> WordUtils.wrap(line, width))
.collect(Collectors.joining("\n")));
} catch (IOException e) {
throw new RuntimeException("Unreachable Statement.\nHow did the Buffered reader throw when it was " +
"wrapping a StringReader?", e);
}
//if the last character of the input is a newline, we need to add another newline to conserve that.
if (input.charAt(input.length() - 1) == '\n') {
out.append('\n');
}
return out.toString();
}
|
java
|
public static String wrapParagraph(final String input, final int width) {
if (input == null || input.isEmpty()) {
return input;
}
final StringBuilder out = new StringBuilder();
try (final BufferedReader bufReader = new BufferedReader(new StringReader(input))) {
out.append(bufReader.lines()
.map(line -> WordUtils.wrap(line, width))
.collect(Collectors.joining("\n")));
} catch (IOException e) {
throw new RuntimeException("Unreachable Statement.\nHow did the Buffered reader throw when it was " +
"wrapping a StringReader?", e);
}
//if the last character of the input is a newline, we need to add another newline to conserve that.
if (input.charAt(input.length() - 1) == '\n') {
out.append('\n');
}
return out.toString();
}
|
[
"public",
"static",
"String",
"wrapParagraph",
"(",
"final",
"String",
"input",
",",
"final",
"int",
"width",
")",
"{",
"if",
"(",
"input",
"==",
"null",
"||",
"input",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"input",
";",
"}",
"final",
"StringBuilder",
"out",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"try",
"(",
"final",
"BufferedReader",
"bufReader",
"=",
"new",
"BufferedReader",
"(",
"new",
"StringReader",
"(",
"input",
")",
")",
")",
"{",
"out",
".",
"append",
"(",
"bufReader",
".",
"lines",
"(",
")",
".",
"map",
"(",
"line",
"->",
"WordUtils",
".",
"wrap",
"(",
"line",
",",
"width",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"joining",
"(",
"\"\\n\"",
")",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Unreachable Statement.\\nHow did the Buffered reader throw when it was \"",
"+",
"\"wrapping a StringReader?\"",
",",
"e",
")",
";",
"}",
"//if the last character of the input is a newline, we need to add another newline to conserve that.",
"if",
"(",
"input",
".",
"charAt",
"(",
"input",
".",
"length",
"(",
")",
"-",
"1",
")",
"==",
"'",
"'",
")",
"{",
"out",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"return",
"out",
".",
"toString",
"(",
")",
";",
"}"
] |
A utility method to wrap multiple lines of text, while respecting the original
newlines.
@param input the String of text to wrap
@param width the width in characters into which to wrap the text. Less than 1 is treated as 1
@return the original string with newlines added, and starting spaces trimmed
so that the resulting lines fit inside a column of with characters.
|
[
"A",
"utility",
"method",
"to",
"wrap",
"multiple",
"lines",
"of",
"text",
"while",
"respecting",
"the",
"original",
"newlines",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/utils/Utils.java#L154-L175
|
8,722
|
michaelquigley/zabbixj
|
zabbixj-core/src/main/java/com/quigley/zabbixj/agent/passive/ListenerThread.java
|
ListenerThread.run
|
public void run() {
if(log.isDebugEnabled()) {
log.debug("ListenerThread Starting.");
}
while(running) {
try {
Socket clientSocket = serverSocket.accept();
WorkerThread worker = new WorkerThread(container, clientSocket);
worker.start();
} catch(SocketTimeoutException ste) {
// Ignore. We receive one of these every second, when the accept()
// method times out. This is done to give us the opportunity to break
// out of the blocking accept() call in order to shut down cleanly.
} catch(Exception e) {
if(log.isErrorEnabled()) {
log.error("Error Accepting: " + e.toString(), e);
}
}
}
try {
serverSocket.close();
} catch (IOException e) {
if(log.isErrorEnabled()) {
log.error("Error closing the server socket: " + e.toString(), e);
}
}
}
|
java
|
public void run() {
if(log.isDebugEnabled()) {
log.debug("ListenerThread Starting.");
}
while(running) {
try {
Socket clientSocket = serverSocket.accept();
WorkerThread worker = new WorkerThread(container, clientSocket);
worker.start();
} catch(SocketTimeoutException ste) {
// Ignore. We receive one of these every second, when the accept()
// method times out. This is done to give us the opportunity to break
// out of the blocking accept() call in order to shut down cleanly.
} catch(Exception e) {
if(log.isErrorEnabled()) {
log.error("Error Accepting: " + e.toString(), e);
}
}
}
try {
serverSocket.close();
} catch (IOException e) {
if(log.isErrorEnabled()) {
log.error("Error closing the server socket: " + e.toString(), e);
}
}
}
|
[
"public",
"void",
"run",
"(",
")",
"{",
"if",
"(",
"log",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"log",
".",
"debug",
"(",
"\"ListenerThread Starting.\"",
")",
";",
"}",
"while",
"(",
"running",
")",
"{",
"try",
"{",
"Socket",
"clientSocket",
"=",
"serverSocket",
".",
"accept",
"(",
")",
";",
"WorkerThread",
"worker",
"=",
"new",
"WorkerThread",
"(",
"container",
",",
"clientSocket",
")",
";",
"worker",
".",
"start",
"(",
")",
";",
"}",
"catch",
"(",
"SocketTimeoutException",
"ste",
")",
"{",
"// Ignore. We receive one of these every second, when the accept()",
"// method times out. This is done to give us the opportunity to break",
"// out of the blocking accept() call in order to shut down cleanly.",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"if",
"(",
"log",
".",
"isErrorEnabled",
"(",
")",
")",
"{",
"log",
".",
"error",
"(",
"\"Error Accepting: \"",
"+",
"e",
".",
"toString",
"(",
")",
",",
"e",
")",
";",
"}",
"}",
"}",
"try",
"{",
"serverSocket",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"if",
"(",
"log",
".",
"isErrorEnabled",
"(",
")",
")",
"{",
"log",
".",
"error",
"(",
"\"Error closing the server socket: \"",
"+",
"e",
".",
"toString",
"(",
")",
",",
"e",
")",
";",
"}",
"}",
"}"
] |
ListenerThread execution begins.
|
[
"ListenerThread",
"execution",
"begins",
"."
] |
15cfe46e45750b3857bec7eecc75ff5e5a3d774d
|
https://github.com/michaelquigley/zabbixj/blob/15cfe46e45750b3857bec7eecc75ff5e5a3d774d/zabbixj-core/src/main/java/com/quigley/zabbixj/agent/passive/ListenerThread.java#L74-L106
|
8,723
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/utils/JVMUtils.java
|
JVMUtils.isConcrete
|
public static boolean isConcrete( Class<?> clazz ) {
return !Modifier.isAbstract(clazz.getModifiers()) &&
!Modifier.isInterface(clazz.getModifiers());
}
|
java
|
public static boolean isConcrete( Class<?> clazz ) {
return !Modifier.isAbstract(clazz.getModifiers()) &&
!Modifier.isInterface(clazz.getModifiers());
}
|
[
"public",
"static",
"boolean",
"isConcrete",
"(",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"return",
"!",
"Modifier",
".",
"isAbstract",
"(",
"clazz",
".",
"getModifiers",
"(",
")",
")",
"&&",
"!",
"Modifier",
".",
"isInterface",
"(",
"clazz",
".",
"getModifiers",
"(",
")",
")",
";",
"}"
] |
Is the specified class a concrete implementation of baseClass?
@param clazz Class to check.
@return True if clazz is concrete. False otherwise.
|
[
"Is",
"the",
"specified",
"class",
"a",
"concrete",
"implementation",
"of",
"baseClass?"
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/utils/JVMUtils.java#L15-L18
|
8,724
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/utils/JVMUtils.java
|
JVMUtils.findField
|
public static Field findField(Class<?> type, String fieldName ) {
while( type != null ) {
Field[] fields = type.getDeclaredFields();
for( Field field: fields ) {
if( field.getName().equals(fieldName) )
return field;
}
type = type.getSuperclass();
}
return null;
}
|
java
|
public static Field findField(Class<?> type, String fieldName ) {
while( type != null ) {
Field[] fields = type.getDeclaredFields();
for( Field field: fields ) {
if( field.getName().equals(fieldName) )
return field;
}
type = type.getSuperclass();
}
return null;
}
|
[
"public",
"static",
"Field",
"findField",
"(",
"Class",
"<",
"?",
">",
"type",
",",
"String",
"fieldName",
")",
"{",
"while",
"(",
"type",
"!=",
"null",
")",
"{",
"Field",
"[",
"]",
"fields",
"=",
"type",
".",
"getDeclaredFields",
"(",
")",
";",
"for",
"(",
"Field",
"field",
":",
"fields",
")",
"{",
"if",
"(",
"field",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"fieldName",
")",
")",
"return",
"field",
";",
"}",
"type",
"=",
"type",
".",
"getSuperclass",
"(",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Find the field with the given name in the class. Will inspect all fields, independent
of access level.
@param type Class in which to search for the given field.
@param fieldName Name of the field for which to search.
@return The field, or null if no such field exists.
|
[
"Find",
"the",
"field",
"with",
"the",
"given",
"name",
"in",
"the",
"class",
".",
"Will",
"inspect",
"all",
"fields",
"independent",
"of",
"access",
"level",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/utils/JVMUtils.java#L27-L37
|
8,725
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/help/DocWorkUnit.java
|
DocWorkUnit.processDoc
|
public void processDoc(final List<Map<String, String>> featureMaps, final List<Map<String, String>> groupMaps) {
workUnitHandler.processWorkUnit(this, featureMaps, groupMaps);
}
|
java
|
public void processDoc(final List<Map<String, String>> featureMaps, final List<Map<String, String>> groupMaps) {
workUnitHandler.processWorkUnit(this, featureMaps, groupMaps);
}
|
[
"public",
"void",
"processDoc",
"(",
"final",
"List",
"<",
"Map",
"<",
"String",
",",
"String",
">",
">",
"featureMaps",
",",
"final",
"List",
"<",
"Map",
"<",
"String",
",",
"String",
">",
">",
"groupMaps",
")",
"{",
"workUnitHandler",
".",
"processWorkUnit",
"(",
"this",
",",
"featureMaps",
",",
"groupMaps",
")",
";",
"}"
] |
Populate the property map for this work unit by delegating to the documented feature handler for this work unit.
@param featureMaps map of all features included in this javadoc run
@param groupMaps map of all groups included in the javadoc run
|
[
"Populate",
"the",
"property",
"map",
"for",
"this",
"work",
"unit",
"by",
"delegating",
"to",
"the",
"documented",
"feature",
"handler",
"for",
"this",
"work",
"unit",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/help/DocWorkUnit.java#L147-L150
|
8,726
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/help/DocWorkUnit.java
|
DocWorkUnit.getCommandLineProgramGroup
|
public CommandLineProgramGroup getCommandLineProgramGroup() {
if (commandLineProperties != null) {
try {
return commandLineProperties.programGroup().newInstance();
} catch (IllegalAccessException | InstantiationException e) {
logger.warn(
String.format("Can't instantiate program group class to retrieve summary for group %s for class %s",
commandLineProperties.programGroup().getName(),
clazz.getName()));
}
}
return null;
}
|
java
|
public CommandLineProgramGroup getCommandLineProgramGroup() {
if (commandLineProperties != null) {
try {
return commandLineProperties.programGroup().newInstance();
} catch (IllegalAccessException | InstantiationException e) {
logger.warn(
String.format("Can't instantiate program group class to retrieve summary for group %s for class %s",
commandLineProperties.programGroup().getName(),
clazz.getName()));
}
}
return null;
}
|
[
"public",
"CommandLineProgramGroup",
"getCommandLineProgramGroup",
"(",
")",
"{",
"if",
"(",
"commandLineProperties",
"!=",
"null",
")",
"{",
"try",
"{",
"return",
"commandLineProperties",
".",
"programGroup",
"(",
")",
".",
"newInstance",
"(",
")",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"|",
"InstantiationException",
"e",
")",
"{",
"logger",
".",
"warn",
"(",
"String",
".",
"format",
"(",
"\"Can't instantiate program group class to retrieve summary for group %s for class %s\"",
",",
"commandLineProperties",
".",
"programGroup",
"(",
")",
".",
"getName",
"(",
")",
",",
"clazz",
".",
"getName",
"(",
")",
")",
")",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Get the CommandLineProgramGroup object from the CommandLineProgramProperties of this work unit.
@return CommandLineProgramGroup if the feature has one, otherwise null.
|
[
"Get",
"the",
"CommandLineProgramGroup",
"object",
"from",
"the",
"CommandLineProgramProperties",
"of",
"this",
"work",
"unit",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/help/DocWorkUnit.java#L184-L196
|
8,727
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/help/HelpDoclet.java
|
HelpDoclet.startProcessDocs
|
protected boolean startProcessDocs(final RootDoc rootDoc) throws IOException {
for (String[] options : rootDoc.options()) {
parseOption(options);
}
// Make sure the user specified a settings directory OR that we should use the defaults.
// Both are not allowed.
// Neither are not allowed.
if ( (useDefaultTemplates && isSettingsDirSet) ||
(!useDefaultTemplates && !isSettingsDirSet)) {
throw new RuntimeException("ERROR: must specify only ONE of: " + USE_DEFAULT_TEMPLATES_OPTION + " , " + SETTINGS_DIR_OPTION);
}
// Make sure we can use the directory for settings we have set:
if (!useDefaultTemplates) {
validateSettingsDir();
}
// Make sure we're in a good state to run:
validateDocletStartingState();
processDocs(rootDoc);
return true;
}
|
java
|
protected boolean startProcessDocs(final RootDoc rootDoc) throws IOException {
for (String[] options : rootDoc.options()) {
parseOption(options);
}
// Make sure the user specified a settings directory OR that we should use the defaults.
// Both are not allowed.
// Neither are not allowed.
if ( (useDefaultTemplates && isSettingsDirSet) ||
(!useDefaultTemplates && !isSettingsDirSet)) {
throw new RuntimeException("ERROR: must specify only ONE of: " + USE_DEFAULT_TEMPLATES_OPTION + " , " + SETTINGS_DIR_OPTION);
}
// Make sure we can use the directory for settings we have set:
if (!useDefaultTemplates) {
validateSettingsDir();
}
// Make sure we're in a good state to run:
validateDocletStartingState();
processDocs(rootDoc);
return true;
}
|
[
"protected",
"boolean",
"startProcessDocs",
"(",
"final",
"RootDoc",
"rootDoc",
")",
"throws",
"IOException",
"{",
"for",
"(",
"String",
"[",
"]",
"options",
":",
"rootDoc",
".",
"options",
"(",
")",
")",
"{",
"parseOption",
"(",
"options",
")",
";",
"}",
"// Make sure the user specified a settings directory OR that we should use the defaults.",
"// Both are not allowed.",
"// Neither are not allowed.",
"if",
"(",
"(",
"useDefaultTemplates",
"&&",
"isSettingsDirSet",
")",
"||",
"(",
"!",
"useDefaultTemplates",
"&&",
"!",
"isSettingsDirSet",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"ERROR: must specify only ONE of: \"",
"+",
"USE_DEFAULT_TEMPLATES_OPTION",
"+",
"\" , \"",
"+",
"SETTINGS_DIR_OPTION",
")",
";",
"}",
"// Make sure we can use the directory for settings we have set:",
"if",
"(",
"!",
"useDefaultTemplates",
")",
"{",
"validateSettingsDir",
"(",
")",
";",
"}",
"// Make sure we're in a good state to run:",
"validateDocletStartingState",
"(",
")",
";",
"processDocs",
"(",
"rootDoc",
")",
";",
"return",
"true",
";",
"}"
] |
Extracts the contents of certain types of javadoc and adds them to an output file.
@param rootDoc The documentation root.
@return Whether the JavaDoc run succeeded.
@throws java.io.IOException if output can't be written.
|
[
"Extracts",
"the",
"contents",
"of",
"certain",
"types",
"of",
"javadoc",
"and",
"adds",
"them",
"to",
"an",
"output",
"file",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/help/HelpDoclet.java#L139-L164
|
8,728
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/help/HelpDoclet.java
|
HelpDoclet.optionLength
|
public static int optionLength(final String option) {
// Any arguments used for the doclet need to be recognized here. Many javadoc plugins (ie. gradle)
// automatically add some such as "-doctitle", "-windowtitle", which we ignore.
if (option.equals(DOC_TITLE_OPTION) ||
option.equals(WINDOW_TITLE_OPTION) ||
option.equals(SETTINGS_DIR_OPTION) ||
option.equals(DESTINATION_DIR_OPTION) ||
option.equals(BUILD_TIMESTAMP_OPTION) ||
option.equals(ABSOLUTE_VERSION_OPTION) ||
option.equals(OUTPUT_FILE_EXTENSION_OPTION) ||
option.equals(INDEX_FILE_EXTENSION_OPTION)) {
return 2;
} else if (option.equals(QUIET_OPTION) ||
option.equals(USE_DEFAULT_TEMPLATES_OPTION)) {
return 1;
} else {
logger.error("The Javadoc command line option is not recognized by the Barclay doclet: " + option);
return 0;
}
}
|
java
|
public static int optionLength(final String option) {
// Any arguments used for the doclet need to be recognized here. Many javadoc plugins (ie. gradle)
// automatically add some such as "-doctitle", "-windowtitle", which we ignore.
if (option.equals(DOC_TITLE_OPTION) ||
option.equals(WINDOW_TITLE_OPTION) ||
option.equals(SETTINGS_DIR_OPTION) ||
option.equals(DESTINATION_DIR_OPTION) ||
option.equals(BUILD_TIMESTAMP_OPTION) ||
option.equals(ABSOLUTE_VERSION_OPTION) ||
option.equals(OUTPUT_FILE_EXTENSION_OPTION) ||
option.equals(INDEX_FILE_EXTENSION_OPTION)) {
return 2;
} else if (option.equals(QUIET_OPTION) ||
option.equals(USE_DEFAULT_TEMPLATES_OPTION)) {
return 1;
} else {
logger.error("The Javadoc command line option is not recognized by the Barclay doclet: " + option);
return 0;
}
}
|
[
"public",
"static",
"int",
"optionLength",
"(",
"final",
"String",
"option",
")",
"{",
"// Any arguments used for the doclet need to be recognized here. Many javadoc plugins (ie. gradle)",
"// automatically add some such as \"-doctitle\", \"-windowtitle\", which we ignore.",
"if",
"(",
"option",
".",
"equals",
"(",
"DOC_TITLE_OPTION",
")",
"||",
"option",
".",
"equals",
"(",
"WINDOW_TITLE_OPTION",
")",
"||",
"option",
".",
"equals",
"(",
"SETTINGS_DIR_OPTION",
")",
"||",
"option",
".",
"equals",
"(",
"DESTINATION_DIR_OPTION",
")",
"||",
"option",
".",
"equals",
"(",
"BUILD_TIMESTAMP_OPTION",
")",
"||",
"option",
".",
"equals",
"(",
"ABSOLUTE_VERSION_OPTION",
")",
"||",
"option",
".",
"equals",
"(",
"OUTPUT_FILE_EXTENSION_OPTION",
")",
"||",
"option",
".",
"equals",
"(",
"INDEX_FILE_EXTENSION_OPTION",
")",
")",
"{",
"return",
"2",
";",
"}",
"else",
"if",
"(",
"option",
".",
"equals",
"(",
"QUIET_OPTION",
")",
"||",
"option",
".",
"equals",
"(",
"USE_DEFAULT_TEMPLATES_OPTION",
")",
")",
"{",
"return",
"1",
";",
"}",
"else",
"{",
"logger",
".",
"error",
"(",
"\"The Javadoc command line option is not recognized by the Barclay doclet: \"",
"+",
"option",
")",
";",
"return",
"0",
";",
"}",
"}"
] |
Validates the given options against options supported by this doclet.
<p>Custom Barclay doclets that want to have custom command line options should provide an
implementation of this static method, and also override override {@link #parseOption}).
Both methods should handle the custom options, delegating back to the base class methods
defined here to allow default handling of builtin options.
@param option Option to validate.
@return Number of potential parameters; 0 if not supported.
|
[
"Validates",
"the",
"given",
"options",
"against",
"options",
"supported",
"by",
"this",
"doclet",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/help/HelpDoclet.java#L230-L249
|
8,729
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/help/HelpDoclet.java
|
HelpDoclet.processDocs
|
private void processDocs(final RootDoc rootDoc) {
this.rootDoc = rootDoc;
// Get a list of all the features and groups that we'll actually retain
workUnits = computeWorkUnits();
final Set<String> uniqueGroups = new HashSet<>();
final List<Map<String, String>> featureMaps = new ArrayList<>();
final List<Map<String, String>> groupMaps = new ArrayList<>();
// First pass over work units: create the top level map of features and groups
workUnits.stream().forEach(
workUnit -> {
featureMaps.add(indexDataMap(workUnit));
if (!uniqueGroups.contains(workUnit.getGroupName())) {
uniqueGroups.add(workUnit.getGroupName());
groupMaps.add(getGroupMap(workUnit));
}
}
);
// Second pass: populate the property map for each work unit
workUnits.stream().forEach(workUnit -> { workUnit.processDoc(featureMaps, groupMaps); });
// Third pass: Generate the individual outputs for each work unit, and the top-level index file
emitOutputFromTemplates(groupMaps, featureMaps);
}
|
java
|
private void processDocs(final RootDoc rootDoc) {
this.rootDoc = rootDoc;
// Get a list of all the features and groups that we'll actually retain
workUnits = computeWorkUnits();
final Set<String> uniqueGroups = new HashSet<>();
final List<Map<String, String>> featureMaps = new ArrayList<>();
final List<Map<String, String>> groupMaps = new ArrayList<>();
// First pass over work units: create the top level map of features and groups
workUnits.stream().forEach(
workUnit -> {
featureMaps.add(indexDataMap(workUnit));
if (!uniqueGroups.contains(workUnit.getGroupName())) {
uniqueGroups.add(workUnit.getGroupName());
groupMaps.add(getGroupMap(workUnit));
}
}
);
// Second pass: populate the property map for each work unit
workUnits.stream().forEach(workUnit -> { workUnit.processDoc(featureMaps, groupMaps); });
// Third pass: Generate the individual outputs for each work unit, and the top-level index file
emitOutputFromTemplates(groupMaps, featureMaps);
}
|
[
"private",
"void",
"processDocs",
"(",
"final",
"RootDoc",
"rootDoc",
")",
"{",
"this",
".",
"rootDoc",
"=",
"rootDoc",
";",
"// Get a list of all the features and groups that we'll actually retain",
"workUnits",
"=",
"computeWorkUnits",
"(",
")",
";",
"final",
"Set",
"<",
"String",
">",
"uniqueGroups",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"final",
"List",
"<",
"Map",
"<",
"String",
",",
"String",
">",
">",
"featureMaps",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"final",
"List",
"<",
"Map",
"<",
"String",
",",
"String",
">",
">",
"groupMaps",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"// First pass over work units: create the top level map of features and groups",
"workUnits",
".",
"stream",
"(",
")",
".",
"forEach",
"(",
"workUnit",
"->",
"{",
"featureMaps",
".",
"add",
"(",
"indexDataMap",
"(",
"workUnit",
")",
")",
";",
"if",
"(",
"!",
"uniqueGroups",
".",
"contains",
"(",
"workUnit",
".",
"getGroupName",
"(",
")",
")",
")",
"{",
"uniqueGroups",
".",
"add",
"(",
"workUnit",
".",
"getGroupName",
"(",
")",
")",
";",
"groupMaps",
".",
"add",
"(",
"getGroupMap",
"(",
"workUnit",
")",
")",
";",
"}",
"}",
")",
";",
"// Second pass: populate the property map for each work unit",
"workUnits",
".",
"stream",
"(",
")",
".",
"forEach",
"(",
"workUnit",
"->",
"{",
"workUnit",
".",
"processDoc",
"(",
"featureMaps",
",",
"groupMaps",
")",
";",
"}",
")",
";",
"// Third pass: Generate the individual outputs for each work unit, and the top-level index file",
"emitOutputFromTemplates",
"(",
"groupMaps",
",",
"featureMaps",
")",
";",
"}"
] |
Process the classes that have been included by the javadoc process in the rootDoc object.
@param rootDoc root structure containing the the set of objects accumulated by the javadoc process
|
[
"Process",
"the",
"classes",
"that",
"have",
"been",
"included",
"by",
"the",
"javadoc",
"process",
"in",
"the",
"rootDoc",
"object",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/help/HelpDoclet.java#L256-L282
|
8,730
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/help/HelpDoclet.java
|
HelpDoclet.computeWorkUnits
|
private Set<DocWorkUnit> computeWorkUnits() {
final TreeSet<DocWorkUnit> workUnits = new TreeSet<>();
for (final ClassDoc classDoc : rootDoc.classes()) {
final Class<?> clazz = getClassForClassDoc(classDoc);
final DocumentedFeature documentedFeature = getDocumentedFeatureForClass(clazz);
if (documentedFeature != null) {
if (documentedFeature.enable()) {
DocWorkUnit workUnit = createWorkUnit(
documentedFeature,
classDoc,
clazz);
if (workUnit != null) {
workUnits.add(workUnit);
}
} else {
logger.info("Skipping disabled documentation for feature: " + classDoc);
}
}
}
return workUnits;
}
|
java
|
private Set<DocWorkUnit> computeWorkUnits() {
final TreeSet<DocWorkUnit> workUnits = new TreeSet<>();
for (final ClassDoc classDoc : rootDoc.classes()) {
final Class<?> clazz = getClassForClassDoc(classDoc);
final DocumentedFeature documentedFeature = getDocumentedFeatureForClass(clazz);
if (documentedFeature != null) {
if (documentedFeature.enable()) {
DocWorkUnit workUnit = createWorkUnit(
documentedFeature,
classDoc,
clazz);
if (workUnit != null) {
workUnits.add(workUnit);
}
} else {
logger.info("Skipping disabled documentation for feature: " + classDoc);
}
}
}
return workUnits;
}
|
[
"private",
"Set",
"<",
"DocWorkUnit",
">",
"computeWorkUnits",
"(",
")",
"{",
"final",
"TreeSet",
"<",
"DocWorkUnit",
">",
"workUnits",
"=",
"new",
"TreeSet",
"<>",
"(",
")",
";",
"for",
"(",
"final",
"ClassDoc",
"classDoc",
":",
"rootDoc",
".",
"classes",
"(",
")",
")",
"{",
"final",
"Class",
"<",
"?",
">",
"clazz",
"=",
"getClassForClassDoc",
"(",
"classDoc",
")",
";",
"final",
"DocumentedFeature",
"documentedFeature",
"=",
"getDocumentedFeatureForClass",
"(",
"clazz",
")",
";",
"if",
"(",
"documentedFeature",
"!=",
"null",
")",
"{",
"if",
"(",
"documentedFeature",
".",
"enable",
"(",
")",
")",
"{",
"DocWorkUnit",
"workUnit",
"=",
"createWorkUnit",
"(",
"documentedFeature",
",",
"classDoc",
",",
"clazz",
")",
";",
"if",
"(",
"workUnit",
"!=",
"null",
")",
"{",
"workUnits",
".",
"add",
"(",
"workUnit",
")",
";",
"}",
"}",
"else",
"{",
"logger",
".",
"info",
"(",
"\"Skipping disabled documentation for feature: \"",
"+",
"classDoc",
")",
";",
"}",
"}",
"}",
"return",
"workUnits",
";",
"}"
] |
For each class in the rootDoc class list, delegate to the appropriate DocWorkUnitHandler to
determine if it should be included in this run, and for each included feature, construct a DocWorkUnit.
@return the set of all DocWorkUnits for which we are actually generating docs
|
[
"For",
"each",
"class",
"in",
"the",
"rootDoc",
"class",
"list",
"delegate",
"to",
"the",
"appropriate",
"DocWorkUnitHandler",
"to",
"determine",
"if",
"it",
"should",
"be",
"included",
"in",
"this",
"run",
"and",
"for",
"each",
"included",
"feature",
"construct",
"a",
"DocWorkUnit",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/help/HelpDoclet.java#L291-L314
|
8,731
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/help/HelpDoclet.java
|
HelpDoclet.includeInDocs
|
public boolean includeInDocs(final DocumentedFeature documentedFeature, final ClassDoc classDoc, final Class<?> clazz) {
boolean hidden = !showHiddenFeatures() && clazz.isAnnotationPresent(Hidden.class);
return !hidden && JVMUtils.isConcrete(clazz);
}
|
java
|
public boolean includeInDocs(final DocumentedFeature documentedFeature, final ClassDoc classDoc, final Class<?> clazz) {
boolean hidden = !showHiddenFeatures() && clazz.isAnnotationPresent(Hidden.class);
return !hidden && JVMUtils.isConcrete(clazz);
}
|
[
"public",
"boolean",
"includeInDocs",
"(",
"final",
"DocumentedFeature",
"documentedFeature",
",",
"final",
"ClassDoc",
"classDoc",
",",
"final",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"boolean",
"hidden",
"=",
"!",
"showHiddenFeatures",
"(",
")",
"&&",
"clazz",
".",
"isAnnotationPresent",
"(",
"Hidden",
".",
"class",
")",
";",
"return",
"!",
"hidden",
"&&",
"JVMUtils",
".",
"isConcrete",
"(",
"clazz",
")",
";",
"}"
] |
Determine if a particular class should be included in the output. This is called by the doclet
to determine if a DocWorkUnit should be created for this feature.
@param documentedFeature feature that is being considered for inclusion in the docs
@param classDoc for the class that is being considered for inclusion in the docs
@param clazz class that is being considered for inclusion in the docs
@return true if the doc should be included, otherwise false
|
[
"Determine",
"if",
"a",
"particular",
"class",
"should",
"be",
"included",
"in",
"the",
"output",
".",
"This",
"is",
"called",
"by",
"the",
"doclet",
"to",
"determine",
"if",
"a",
"DocWorkUnit",
"should",
"be",
"created",
"for",
"this",
"feature",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/help/HelpDoclet.java#L361-L364
|
8,732
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/help/HelpDoclet.java
|
HelpDoclet.createWorkUnit
|
protected DocWorkUnit createWorkUnit(
final DocumentedFeature documentedFeature,
final ClassDoc classDoc,
final Class<?> clazz)
{
return new DocWorkUnit(
new DefaultDocWorkUnitHandler(this),
documentedFeature,
classDoc,
clazz);
}
|
java
|
protected DocWorkUnit createWorkUnit(
final DocumentedFeature documentedFeature,
final ClassDoc classDoc,
final Class<?> clazz)
{
return new DocWorkUnit(
new DefaultDocWorkUnitHandler(this),
documentedFeature,
classDoc,
clazz);
}
|
[
"protected",
"DocWorkUnit",
"createWorkUnit",
"(",
"final",
"DocumentedFeature",
"documentedFeature",
",",
"final",
"ClassDoc",
"classDoc",
",",
"final",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"return",
"new",
"DocWorkUnit",
"(",
"new",
"DefaultDocWorkUnitHandler",
"(",
"this",
")",
",",
"documentedFeature",
",",
"classDoc",
",",
"clazz",
")",
";",
"}"
] |
Create a work unit and handler capable of documenting the feature specified by the input arguments.
Returns null if no appropriate handler is found or doc shouldn't be documented at all.
|
[
"Create",
"a",
"work",
"unit",
"and",
"handler",
"capable",
"of",
"documenting",
"the",
"feature",
"specified",
"by",
"the",
"input",
"arguments",
".",
"Returns",
"null",
"if",
"no",
"appropriate",
"handler",
"is",
"found",
"or",
"doc",
"shouldn",
"t",
"be",
"documented",
"at",
"all",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/help/HelpDoclet.java#L410-L420
|
8,733
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/help/HelpDoclet.java
|
HelpDoclet.getDocumentedFeatureForClass
|
private DocumentedFeature getDocumentedFeatureForClass(final Class<?> clazz) {
if (clazz != null && clazz.isAnnotationPresent(DocumentedFeature.class)) {
return clazz.getAnnotation(DocumentedFeature.class);
}
else {
return null;
}
}
|
java
|
private DocumentedFeature getDocumentedFeatureForClass(final Class<?> clazz) {
if (clazz != null && clazz.isAnnotationPresent(DocumentedFeature.class)) {
return clazz.getAnnotation(DocumentedFeature.class);
}
else {
return null;
}
}
|
[
"private",
"DocumentedFeature",
"getDocumentedFeatureForClass",
"(",
"final",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"if",
"(",
"clazz",
"!=",
"null",
"&&",
"clazz",
".",
"isAnnotationPresent",
"(",
"DocumentedFeature",
".",
"class",
")",
")",
"{",
"return",
"clazz",
".",
"getAnnotation",
"(",
"DocumentedFeature",
".",
"class",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] |
Returns the instantiated DocumentedFeature that describes the doc for this class.
@param clazz
@return DocumentedFeature, or null if this classDoc shouldn't be included/documented
|
[
"Returns",
"the",
"instantiated",
"DocumentedFeature",
"that",
"describes",
"the",
"doc",
"for",
"this",
"class",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/help/HelpDoclet.java#L428-L435
|
8,734
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/help/HelpDoclet.java
|
HelpDoclet.getClassForClassDoc
|
private Class<? extends Object> getClassForClassDoc(final ClassDoc doc) {
try {
return DocletUtils.getClassForDoc(doc);
} catch (ClassNotFoundException e) {
// we got a classdoc for a class we can't find. Maybe in a library or something
return null;
} catch (NoClassDefFoundError e) {
return null;
} catch (UnsatisfiedLinkError e) {
return null; // naughty BWA bindings
}
}
|
java
|
private Class<? extends Object> getClassForClassDoc(final ClassDoc doc) {
try {
return DocletUtils.getClassForDoc(doc);
} catch (ClassNotFoundException e) {
// we got a classdoc for a class we can't find. Maybe in a library or something
return null;
} catch (NoClassDefFoundError e) {
return null;
} catch (UnsatisfiedLinkError e) {
return null; // naughty BWA bindings
}
}
|
[
"private",
"Class",
"<",
"?",
"extends",
"Object",
">",
"getClassForClassDoc",
"(",
"final",
"ClassDoc",
"doc",
")",
"{",
"try",
"{",
"return",
"DocletUtils",
".",
"getClassForDoc",
"(",
"doc",
")",
";",
"}",
"catch",
"(",
"ClassNotFoundException",
"e",
")",
"{",
"// we got a classdoc for a class we can't find. Maybe in a library or something",
"return",
"null",
";",
"}",
"catch",
"(",
"NoClassDefFoundError",
"e",
")",
"{",
"return",
"null",
";",
"}",
"catch",
"(",
"UnsatisfiedLinkError",
"e",
")",
"{",
"return",
"null",
";",
"// naughty BWA bindings",
"}",
"}"
] |
Return the Java class described by the ClassDoc doc
@param doc
@return
|
[
"Return",
"the",
"Java",
"class",
"described",
"by",
"the",
"ClassDoc",
"doc"
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/help/HelpDoclet.java#L443-L454
|
8,735
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/help/HelpDoclet.java
|
HelpDoclet.processIndexTemplate
|
protected void processIndexTemplate(
final Configuration cfg,
final List<DocWorkUnit> workUnitList,
final List<Map<String, String>> groupMaps
) throws IOException {
// Get or create a template and merge in the data
final Template template = cfg.getTemplate(getIndexTemplateName());
final File indexFile = new File(getDestinationDir(),
getIndexBaseFileName() + '.' + getIndexFileExtension()
);
try (final FileOutputStream fileOutStream = new FileOutputStream(indexFile);
final OutputStreamWriter outWriter = new OutputStreamWriter(fileOutStream)) {
template.process(groupIndexMap(workUnitList, groupMaps), outWriter);
} catch (TemplateException e) {
throw new DocException("Freemarker Template Exception during documentation index creation", e);
}
}
|
java
|
protected void processIndexTemplate(
final Configuration cfg,
final List<DocWorkUnit> workUnitList,
final List<Map<String, String>> groupMaps
) throws IOException {
// Get or create a template and merge in the data
final Template template = cfg.getTemplate(getIndexTemplateName());
final File indexFile = new File(getDestinationDir(),
getIndexBaseFileName() + '.' + getIndexFileExtension()
);
try (final FileOutputStream fileOutStream = new FileOutputStream(indexFile);
final OutputStreamWriter outWriter = new OutputStreamWriter(fileOutStream)) {
template.process(groupIndexMap(workUnitList, groupMaps), outWriter);
} catch (TemplateException e) {
throw new DocException("Freemarker Template Exception during documentation index creation", e);
}
}
|
[
"protected",
"void",
"processIndexTemplate",
"(",
"final",
"Configuration",
"cfg",
",",
"final",
"List",
"<",
"DocWorkUnit",
">",
"workUnitList",
",",
"final",
"List",
"<",
"Map",
"<",
"String",
",",
"String",
">",
">",
"groupMaps",
")",
"throws",
"IOException",
"{",
"// Get or create a template and merge in the data",
"final",
"Template",
"template",
"=",
"cfg",
".",
"getTemplate",
"(",
"getIndexTemplateName",
"(",
")",
")",
";",
"final",
"File",
"indexFile",
"=",
"new",
"File",
"(",
"getDestinationDir",
"(",
")",
",",
"getIndexBaseFileName",
"(",
")",
"+",
"'",
"'",
"+",
"getIndexFileExtension",
"(",
")",
")",
";",
"try",
"(",
"final",
"FileOutputStream",
"fileOutStream",
"=",
"new",
"FileOutputStream",
"(",
"indexFile",
")",
";",
"final",
"OutputStreamWriter",
"outWriter",
"=",
"new",
"OutputStreamWriter",
"(",
"fileOutStream",
")",
")",
"{",
"template",
".",
"process",
"(",
"groupIndexMap",
"(",
"workUnitList",
",",
"groupMaps",
")",
",",
"outWriter",
")",
";",
"}",
"catch",
"(",
"TemplateException",
"e",
")",
"{",
"throw",
"new",
"DocException",
"(",
"\"Freemarker Template Exception during documentation index creation\"",
",",
"e",
")",
";",
"}",
"}"
] |
Create the php index listing all of the Docs features
@param cfg
@param workUnitList
@param groupMaps
@throws IOException
|
[
"Create",
"the",
"php",
"index",
"listing",
"all",
"of",
"the",
"Docs",
"features"
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/help/HelpDoclet.java#L464-L482
|
8,736
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/help/HelpDoclet.java
|
HelpDoclet.groupIndexMap
|
protected Map<String, Object> groupIndexMap(
final List<DocWorkUnit> workUnitList,
final List<Map<String, String>> groupMaps
) {
//
// root -> data -> { summary -> y, filename -> z }, etc
// -> groups -> group1, group2, etc.
Map<String, Object> root = new HashMap<>();
Collections.sort(workUnitList);
List<Map<String, String>> data = new ArrayList<>();
workUnitList.stream().forEach(workUnit -> data.add(indexDataMap(workUnit)));
root.put("data", data);
root.put("groups", groupMaps);
root.put("timestamp", getBuildTimeStamp());
root.put("version", getBuildVersion());
return root;
}
|
java
|
protected Map<String, Object> groupIndexMap(
final List<DocWorkUnit> workUnitList,
final List<Map<String, String>> groupMaps
) {
//
// root -> data -> { summary -> y, filename -> z }, etc
// -> groups -> group1, group2, etc.
Map<String, Object> root = new HashMap<>();
Collections.sort(workUnitList);
List<Map<String, String>> data = new ArrayList<>();
workUnitList.stream().forEach(workUnit -> data.add(indexDataMap(workUnit)));
root.put("data", data);
root.put("groups", groupMaps);
root.put("timestamp", getBuildTimeStamp());
root.put("version", getBuildVersion());
return root;
}
|
[
"protected",
"Map",
"<",
"String",
",",
"Object",
">",
"groupIndexMap",
"(",
"final",
"List",
"<",
"DocWorkUnit",
">",
"workUnitList",
",",
"final",
"List",
"<",
"Map",
"<",
"String",
",",
"String",
">",
">",
"groupMaps",
")",
"{",
"//",
"// root -> data -> { summary -> y, filename -> z }, etc",
"// -> groups -> group1, group2, etc.",
"Map",
"<",
"String",
",",
"Object",
">",
"root",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"Collections",
".",
"sort",
"(",
"workUnitList",
")",
";",
"List",
"<",
"Map",
"<",
"String",
",",
"String",
">",
">",
"data",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"workUnitList",
".",
"stream",
"(",
")",
".",
"forEach",
"(",
"workUnit",
"->",
"data",
".",
"add",
"(",
"indexDataMap",
"(",
"workUnit",
")",
")",
")",
";",
"root",
".",
"put",
"(",
"\"data\"",
",",
"data",
")",
";",
"root",
".",
"put",
"(",
"\"groups\"",
",",
"groupMaps",
")",
";",
"root",
".",
"put",
"(",
"\"timestamp\"",
",",
"getBuildTimeStamp",
"(",
")",
")",
";",
"root",
".",
"put",
"(",
"\"version\"",
",",
"getBuildVersion",
"(",
")",
")",
";",
"return",
"root",
";",
"}"
] |
Helpful function to create the php index. Given all of the already run DocWorkUnits,
create the high-level grouping data listing individual features by group.
@param workUnitList
@return The map used to populate the index template used by this doclet.
|
[
"Helpful",
"function",
"to",
"create",
"the",
"php",
"index",
".",
"Given",
"all",
"of",
"the",
"already",
"run",
"DocWorkUnits",
"create",
"the",
"high",
"-",
"level",
"grouping",
"data",
"listing",
"individual",
"features",
"by",
"group",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/help/HelpDoclet.java#L491-L511
|
8,737
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/help/HelpDoclet.java
|
HelpDoclet.getGroupMap
|
protected Map<String, String> getGroupMap(final DocWorkUnit workUnit) {
Map<String, String> propertyMap = new HashMap<>();
propertyMap.put("id", getGroupIdFromName(workUnit.getGroupName()));
propertyMap.put("name", workUnit.getGroupName());
propertyMap.put("summary", workUnit.getGroupSummary());
return propertyMap;
}
|
java
|
protected Map<String, String> getGroupMap(final DocWorkUnit workUnit) {
Map<String, String> propertyMap = new HashMap<>();
propertyMap.put("id", getGroupIdFromName(workUnit.getGroupName()));
propertyMap.put("name", workUnit.getGroupName());
propertyMap.put("summary", workUnit.getGroupSummary());
return propertyMap;
}
|
[
"protected",
"Map",
"<",
"String",
",",
"String",
">",
"getGroupMap",
"(",
"final",
"DocWorkUnit",
"workUnit",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"propertyMap",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"propertyMap",
".",
"put",
"(",
"\"id\"",
",",
"getGroupIdFromName",
"(",
"workUnit",
".",
"getGroupName",
"(",
")",
")",
")",
";",
"propertyMap",
".",
"put",
"(",
"\"name\"",
",",
"workUnit",
".",
"getGroupName",
"(",
")",
")",
";",
"propertyMap",
".",
"put",
"(",
"\"summary\"",
",",
"workUnit",
".",
"getGroupSummary",
"(",
")",
")",
";",
"return",
"propertyMap",
";",
"}"
] |
Helper routine that returns the map of group name and summary given the workUnit. Subclasses that
override this should call this method before doing further processing.
@param workUnit
@return The property map for the work unit's entry in the index map for this doclet.
|
[
"Helper",
"routine",
"that",
"returns",
"the",
"map",
"of",
"group",
"name",
"and",
"summary",
"given",
"the",
"workUnit",
".",
"Subclasses",
"that",
"override",
"this",
"should",
"call",
"this",
"method",
"before",
"doing",
"further",
"processing",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/help/HelpDoclet.java#L520-L526
|
8,738
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/help/HelpDoclet.java
|
HelpDoclet.indexDataMap
|
public Map<String, String> indexDataMap(final DocWorkUnit workUnit) {
Map<String, String> propertyMap = new HashMap<>();
propertyMap.put("name", workUnit.getName());
propertyMap.put("summary", workUnit.getSummary());
propertyMap.put("filename", workUnit.getTargetFileName());
propertyMap.put("group", workUnit.getGroupName());
// Note that these properties are inserted into the toplevel FreeMarker map for the WorkUnit typed
// as Strings with values "true" or "false", but here the same entries are typed as Booleans in the
// in the index.
propertyMap.put("beta", Boolean.toString(workUnit.isBetaFeature()));
propertyMap.put("experimental", Boolean.toString(workUnit.isExperimentalFeature()));
return propertyMap;
}
|
java
|
public Map<String, String> indexDataMap(final DocWorkUnit workUnit) {
Map<String, String> propertyMap = new HashMap<>();
propertyMap.put("name", workUnit.getName());
propertyMap.put("summary", workUnit.getSummary());
propertyMap.put("filename", workUnit.getTargetFileName());
propertyMap.put("group", workUnit.getGroupName());
// Note that these properties are inserted into the toplevel FreeMarker map for the WorkUnit typed
// as Strings with values "true" or "false", but here the same entries are typed as Booleans in the
// in the index.
propertyMap.put("beta", Boolean.toString(workUnit.isBetaFeature()));
propertyMap.put("experimental", Boolean.toString(workUnit.isExperimentalFeature()));
return propertyMap;
}
|
[
"public",
"Map",
"<",
"String",
",",
"String",
">",
"indexDataMap",
"(",
"final",
"DocWorkUnit",
"workUnit",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"propertyMap",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"propertyMap",
".",
"put",
"(",
"\"name\"",
",",
"workUnit",
".",
"getName",
"(",
")",
")",
";",
"propertyMap",
".",
"put",
"(",
"\"summary\"",
",",
"workUnit",
".",
"getSummary",
"(",
")",
")",
";",
"propertyMap",
".",
"put",
"(",
"\"filename\"",
",",
"workUnit",
".",
"getTargetFileName",
"(",
")",
")",
";",
"propertyMap",
".",
"put",
"(",
"\"group\"",
",",
"workUnit",
".",
"getGroupName",
"(",
")",
")",
";",
"// Note that these properties are inserted into the toplevel FreeMarker map for the WorkUnit typed",
"// as Strings with values \"true\" or \"false\", but here the same entries are typed as Booleans in the",
"// in the index.",
"propertyMap",
".",
"put",
"(",
"\"beta\"",
",",
"Boolean",
".",
"toString",
"(",
"workUnit",
".",
"isBetaFeature",
"(",
")",
")",
")",
";",
"propertyMap",
".",
"put",
"(",
"\"experimental\"",
",",
"Boolean",
".",
"toString",
"(",
"workUnit",
".",
"isExperimentalFeature",
"(",
")",
")",
")",
";",
"return",
"propertyMap",
";",
"}"
] |
Return a String -> String map suitable for FreeMarker to create an index to this WorkUnit
@return
|
[
"Return",
"a",
"String",
"-",
">",
"String",
"map",
"suitable",
"for",
"FreeMarker",
"to",
"create",
"an",
"index",
"to",
"this",
"WorkUnit"
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/help/HelpDoclet.java#L535-L549
|
8,739
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/help/HelpDoclet.java
|
HelpDoclet.findWorkUnitForClass
|
public final DocWorkUnit findWorkUnitForClass(final Class<?> c) {
for (final DocWorkUnit workUnit : this.workUnits)
if (workUnit.getClazz().equals(c))
return workUnit;
return null;
}
|
java
|
public final DocWorkUnit findWorkUnitForClass(final Class<?> c) {
for (final DocWorkUnit workUnit : this.workUnits)
if (workUnit.getClazz().equals(c))
return workUnit;
return null;
}
|
[
"public",
"final",
"DocWorkUnit",
"findWorkUnitForClass",
"(",
"final",
"Class",
"<",
"?",
">",
"c",
")",
"{",
"for",
"(",
"final",
"DocWorkUnit",
"workUnit",
":",
"this",
".",
"workUnits",
")",
"if",
"(",
"workUnit",
".",
"getClazz",
"(",
")",
".",
"equals",
"(",
"c",
")",
")",
"return",
"workUnit",
";",
"return",
"null",
";",
"}"
] |
Helper function that finding the DocWorkUnit associated with class from among all of the work units
@param c the class we are looking for
@return the DocWorkUnit whose .clazz.equals(c), or null if none could be found
|
[
"Helper",
"function",
"that",
"finding",
"the",
"DocWorkUnit",
"associated",
"with",
"class",
"from",
"among",
"all",
"of",
"the",
"work",
"units"
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/help/HelpDoclet.java#L557-L562
|
8,740
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/help/HelpDoclet.java
|
HelpDoclet.processWorkUnitTemplate
|
protected void processWorkUnitTemplate(
final Configuration cfg,
final DocWorkUnit workUnit,
final List<Map<String, String>> indexByGroupMaps,
final List<Map<String, String>> featureMaps)
{
try {
// Merge data-model with template
Template template = cfg.getTemplate(workUnit.getTemplateName());
File outputPath = new File(getDestinationDir(), workUnit.getTargetFileName());
try (final Writer out = new OutputStreamWriter(new FileOutputStream(outputPath))) {
template.process(workUnit.getRootMap(), out);
}
} catch (IOException e) {
throw new DocException("IOException during documentation creation", e);
} catch (TemplateException e) {
throw new DocException("TemplateException during documentation creation", e);
}
// Create GSON-friendly container object
GSONWorkUnit gsonworkunit = createGSONWorkUnit(workUnit, indexByGroupMaps, featureMaps);
gsonworkunit.populate(
workUnit.getProperty("summary").toString(),
workUnit.getProperty("gson-arguments"),
workUnit.getProperty("description").toString(),
workUnit.getProperty("name").toString(),
workUnit.getProperty("group").toString(),
Boolean.valueOf(workUnit.getProperty("beta").toString()),
Boolean.valueOf(workUnit.getProperty("experimental").toString())
);
// Convert object to JSON and write JSON entry to file
File outputPathForJSON = new File(getDestinationDir(), workUnit.getJSONFileName());
try (final BufferedWriter jsonWriter = new BufferedWriter(new FileWriter(outputPathForJSON))) {
Gson gson = new GsonBuilder()
.serializeSpecialFloatingPointValues()
.setPrettyPrinting()
.create();
String json = gson.toJson(gsonworkunit);
jsonWriter.write(json);
} catch (IOException e) {
throw new DocException("Failed to create JSON entry", e);
}
}
|
java
|
protected void processWorkUnitTemplate(
final Configuration cfg,
final DocWorkUnit workUnit,
final List<Map<String, String>> indexByGroupMaps,
final List<Map<String, String>> featureMaps)
{
try {
// Merge data-model with template
Template template = cfg.getTemplate(workUnit.getTemplateName());
File outputPath = new File(getDestinationDir(), workUnit.getTargetFileName());
try (final Writer out = new OutputStreamWriter(new FileOutputStream(outputPath))) {
template.process(workUnit.getRootMap(), out);
}
} catch (IOException e) {
throw new DocException("IOException during documentation creation", e);
} catch (TemplateException e) {
throw new DocException("TemplateException during documentation creation", e);
}
// Create GSON-friendly container object
GSONWorkUnit gsonworkunit = createGSONWorkUnit(workUnit, indexByGroupMaps, featureMaps);
gsonworkunit.populate(
workUnit.getProperty("summary").toString(),
workUnit.getProperty("gson-arguments"),
workUnit.getProperty("description").toString(),
workUnit.getProperty("name").toString(),
workUnit.getProperty("group").toString(),
Boolean.valueOf(workUnit.getProperty("beta").toString()),
Boolean.valueOf(workUnit.getProperty("experimental").toString())
);
// Convert object to JSON and write JSON entry to file
File outputPathForJSON = new File(getDestinationDir(), workUnit.getJSONFileName());
try (final BufferedWriter jsonWriter = new BufferedWriter(new FileWriter(outputPathForJSON))) {
Gson gson = new GsonBuilder()
.serializeSpecialFloatingPointValues()
.setPrettyPrinting()
.create();
String json = gson.toJson(gsonworkunit);
jsonWriter.write(json);
} catch (IOException e) {
throw new DocException("Failed to create JSON entry", e);
}
}
|
[
"protected",
"void",
"processWorkUnitTemplate",
"(",
"final",
"Configuration",
"cfg",
",",
"final",
"DocWorkUnit",
"workUnit",
",",
"final",
"List",
"<",
"Map",
"<",
"String",
",",
"String",
">",
">",
"indexByGroupMaps",
",",
"final",
"List",
"<",
"Map",
"<",
"String",
",",
"String",
">",
">",
"featureMaps",
")",
"{",
"try",
"{",
"// Merge data-model with template",
"Template",
"template",
"=",
"cfg",
".",
"getTemplate",
"(",
"workUnit",
".",
"getTemplateName",
"(",
")",
")",
";",
"File",
"outputPath",
"=",
"new",
"File",
"(",
"getDestinationDir",
"(",
")",
",",
"workUnit",
".",
"getTargetFileName",
"(",
")",
")",
";",
"try",
"(",
"final",
"Writer",
"out",
"=",
"new",
"OutputStreamWriter",
"(",
"new",
"FileOutputStream",
"(",
"outputPath",
")",
")",
")",
"{",
"template",
".",
"process",
"(",
"workUnit",
".",
"getRootMap",
"(",
")",
",",
"out",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"DocException",
"(",
"\"IOException during documentation creation\"",
",",
"e",
")",
";",
"}",
"catch",
"(",
"TemplateException",
"e",
")",
"{",
"throw",
"new",
"DocException",
"(",
"\"TemplateException during documentation creation\"",
",",
"e",
")",
";",
"}",
"// Create GSON-friendly container object",
"GSONWorkUnit",
"gsonworkunit",
"=",
"createGSONWorkUnit",
"(",
"workUnit",
",",
"indexByGroupMaps",
",",
"featureMaps",
")",
";",
"gsonworkunit",
".",
"populate",
"(",
"workUnit",
".",
"getProperty",
"(",
"\"summary\"",
")",
".",
"toString",
"(",
")",
",",
"workUnit",
".",
"getProperty",
"(",
"\"gson-arguments\"",
")",
",",
"workUnit",
".",
"getProperty",
"(",
"\"description\"",
")",
".",
"toString",
"(",
")",
",",
"workUnit",
".",
"getProperty",
"(",
"\"name\"",
")",
".",
"toString",
"(",
")",
",",
"workUnit",
".",
"getProperty",
"(",
"\"group\"",
")",
".",
"toString",
"(",
")",
",",
"Boolean",
".",
"valueOf",
"(",
"workUnit",
".",
"getProperty",
"(",
"\"beta\"",
")",
".",
"toString",
"(",
")",
")",
",",
"Boolean",
".",
"valueOf",
"(",
"workUnit",
".",
"getProperty",
"(",
"\"experimental\"",
")",
".",
"toString",
"(",
")",
")",
")",
";",
"// Convert object to JSON and write JSON entry to file",
"File",
"outputPathForJSON",
"=",
"new",
"File",
"(",
"getDestinationDir",
"(",
")",
",",
"workUnit",
".",
"getJSONFileName",
"(",
")",
")",
";",
"try",
"(",
"final",
"BufferedWriter",
"jsonWriter",
"=",
"new",
"BufferedWriter",
"(",
"new",
"FileWriter",
"(",
"outputPathForJSON",
")",
")",
")",
"{",
"Gson",
"gson",
"=",
"new",
"GsonBuilder",
"(",
")",
".",
"serializeSpecialFloatingPointValues",
"(",
")",
".",
"setPrettyPrinting",
"(",
")",
".",
"create",
"(",
")",
";",
"String",
"json",
"=",
"gson",
".",
"toJson",
"(",
"gsonworkunit",
")",
";",
"jsonWriter",
".",
"write",
"(",
"json",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"DocException",
"(",
"\"Failed to create JSON entry\"",
",",
"e",
")",
";",
"}",
"}"
] |
High-level function that processes a single DocWorkUnit unit using its handler
@param cfg
@param workUnit
@param featureMaps
@throws IOException
|
[
"High",
"-",
"level",
"function",
"that",
"processes",
"a",
"single",
"DocWorkUnit",
"unit",
"using",
"its",
"handler"
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/help/HelpDoclet.java#L582-L627
|
8,741
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/argparser/TaggedArgumentParser.java
|
TaggedArgumentParser.preprocessTaggedOptions
|
public String[] preprocessTaggedOptions(final String[] argArray) {
List<String> finalArgs = new ArrayList<>(argArray.length);
Iterator<String> argIt = Arrays.asList(argArray).iterator();
while (argIt.hasNext()) {
final String arg = argIt.next();
if (isShortOptionToken(arg)) {
replaceTaggedOption(SHORT_OPTION_PREFIX, arg.substring(SHORT_OPTION_PREFIX.length()), argIt, finalArgs);
} else if (isLongOptionToken(arg)) {
replaceTaggedOption(LONG_OPTION_PREFIX, arg.substring(LONG_OPTION_PREFIX.length()), argIt, finalArgs);
} else { // Positional arg, etc., just add it
finalArgs.add(arg);
}
}
return finalArgs.toArray(new String[finalArgs.size()]);
}
|
java
|
public String[] preprocessTaggedOptions(final String[] argArray) {
List<String> finalArgs = new ArrayList<>(argArray.length);
Iterator<String> argIt = Arrays.asList(argArray).iterator();
while (argIt.hasNext()) {
final String arg = argIt.next();
if (isShortOptionToken(arg)) {
replaceTaggedOption(SHORT_OPTION_PREFIX, arg.substring(SHORT_OPTION_PREFIX.length()), argIt, finalArgs);
} else if (isLongOptionToken(arg)) {
replaceTaggedOption(LONG_OPTION_PREFIX, arg.substring(LONG_OPTION_PREFIX.length()), argIt, finalArgs);
} else { // Positional arg, etc., just add it
finalArgs.add(arg);
}
}
return finalArgs.toArray(new String[finalArgs.size()]);
}
|
[
"public",
"String",
"[",
"]",
"preprocessTaggedOptions",
"(",
"final",
"String",
"[",
"]",
"argArray",
")",
"{",
"List",
"<",
"String",
">",
"finalArgs",
"=",
"new",
"ArrayList",
"<>",
"(",
"argArray",
".",
"length",
")",
";",
"Iterator",
"<",
"String",
">",
"argIt",
"=",
"Arrays",
".",
"asList",
"(",
"argArray",
")",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"argIt",
".",
"hasNext",
"(",
")",
")",
"{",
"final",
"String",
"arg",
"=",
"argIt",
".",
"next",
"(",
")",
";",
"if",
"(",
"isShortOptionToken",
"(",
"arg",
")",
")",
"{",
"replaceTaggedOption",
"(",
"SHORT_OPTION_PREFIX",
",",
"arg",
".",
"substring",
"(",
"SHORT_OPTION_PREFIX",
".",
"length",
"(",
")",
")",
",",
"argIt",
",",
"finalArgs",
")",
";",
"}",
"else",
"if",
"(",
"isLongOptionToken",
"(",
"arg",
")",
")",
"{",
"replaceTaggedOption",
"(",
"LONG_OPTION_PREFIX",
",",
"arg",
".",
"substring",
"(",
"LONG_OPTION_PREFIX",
".",
"length",
"(",
")",
")",
",",
"argIt",
",",
"finalArgs",
")",
";",
"}",
"else",
"{",
"// Positional arg, etc., just add it",
"finalArgs",
".",
"add",
"(",
"arg",
")",
";",
"}",
"}",
"return",
"finalArgs",
".",
"toArray",
"(",
"new",
"String",
"[",
"finalArgs",
".",
"size",
"(",
")",
"]",
")",
";",
"}"
] |
Given an array of raw arguments provided by the user, return an array of args where tagged arguments
have been replaced with curated arguments containing a key to be used by the parser to retrieve the actual
values.
@param argArray raw arguments as provided by the user
@return curated string of arguments to be presented to the opt parser
|
[
"Given",
"an",
"array",
"of",
"raw",
"arguments",
"provided",
"by",
"the",
"user",
"return",
"an",
"array",
"of",
"args",
"where",
"tagged",
"arguments",
"have",
"been",
"replaced",
"with",
"curated",
"arguments",
"containing",
"a",
"key",
"to",
"be",
"used",
"by",
"the",
"parser",
"to",
"retrieve",
"the",
"actual",
"values",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/argparser/TaggedArgumentParser.java#L74-L89
|
8,742
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/argparser/TaggedArgumentParser.java
|
TaggedArgumentParser.replaceTaggedOption
|
private void replaceTaggedOption(
final String optionPrefix, // the option prefix used (short or long)
final String optionString, // the option string, minus prefix, including any tags/attributes
final Iterator<String> userArgIt, // the original, raw, un-curated input argument list
final List<String> finalArgList // final, curated argument list
)
{
final int separatorIndex = optionString.indexOf(TaggedArgumentParser.ARGUMENT_TAG_NAME_SEPARATOR);
if (separatorIndex == -1) { // no tags, consume one argument and get out
detectAndRejectHybridSyntax(optionString);
finalArgList.add(optionPrefix + optionString);
} else {
final String optionName = optionString.substring(0, separatorIndex);
detectAndRejectHybridSyntax(optionName);
if (userArgIt.hasNext()) {
if (optionName.isEmpty()) {
throw new CommandLineException("Zero length argument name found in tagged argument: " + optionString);
}
final String tagNameAndValues = optionString.substring(separatorIndex+1, optionString.length());
if (tagNameAndValues.isEmpty()) {
throw new CommandLineException("Zero length tag name found in tagged argument: " + optionString);
}
final String argValue = userArgIt.next();
if (isLongOptionToken(argValue) || isShortOptionToken(argValue)) {
// An argument value is required, and there isn't one to consume
throw new CommandLineException("No argument value found for tagged argument: " + optionString);
}
// Replace the original prefix/option/attribute string with the original prefix/option name, and
// replace it's companion argument value with the surrogate key to be used later to retrieve the
// actual values
final String pairKey = getSurrogateKeyForTaggedOption(optionString, argValue, tagNameAndValues);
finalArgList.add(optionPrefix + optionName);
finalArgList.add(pairKey);
} else {
// the option appears to be tagged, but we're already at the end of the argument list,
// and there is no companion value to use
throw new CommandLineException("No argument value found for tagged argument: " + optionString);
}
}
}
|
java
|
private void replaceTaggedOption(
final String optionPrefix, // the option prefix used (short or long)
final String optionString, // the option string, minus prefix, including any tags/attributes
final Iterator<String> userArgIt, // the original, raw, un-curated input argument list
final List<String> finalArgList // final, curated argument list
)
{
final int separatorIndex = optionString.indexOf(TaggedArgumentParser.ARGUMENT_TAG_NAME_SEPARATOR);
if (separatorIndex == -1) { // no tags, consume one argument and get out
detectAndRejectHybridSyntax(optionString);
finalArgList.add(optionPrefix + optionString);
} else {
final String optionName = optionString.substring(0, separatorIndex);
detectAndRejectHybridSyntax(optionName);
if (userArgIt.hasNext()) {
if (optionName.isEmpty()) {
throw new CommandLineException("Zero length argument name found in tagged argument: " + optionString);
}
final String tagNameAndValues = optionString.substring(separatorIndex+1, optionString.length());
if (tagNameAndValues.isEmpty()) {
throw new CommandLineException("Zero length tag name found in tagged argument: " + optionString);
}
final String argValue = userArgIt.next();
if (isLongOptionToken(argValue) || isShortOptionToken(argValue)) {
// An argument value is required, and there isn't one to consume
throw new CommandLineException("No argument value found for tagged argument: " + optionString);
}
// Replace the original prefix/option/attribute string with the original prefix/option name, and
// replace it's companion argument value with the surrogate key to be used later to retrieve the
// actual values
final String pairKey = getSurrogateKeyForTaggedOption(optionString, argValue, tagNameAndValues);
finalArgList.add(optionPrefix + optionName);
finalArgList.add(pairKey);
} else {
// the option appears to be tagged, but we're already at the end of the argument list,
// and there is no companion value to use
throw new CommandLineException("No argument value found for tagged argument: " + optionString);
}
}
}
|
[
"private",
"void",
"replaceTaggedOption",
"(",
"final",
"String",
"optionPrefix",
",",
"// the option prefix used (short or long)",
"final",
"String",
"optionString",
",",
"// the option string, minus prefix, including any tags/attributes",
"final",
"Iterator",
"<",
"String",
">",
"userArgIt",
",",
"// the original, raw, un-curated input argument list",
"final",
"List",
"<",
"String",
">",
"finalArgList",
"// final, curated argument list",
")",
"{",
"final",
"int",
"separatorIndex",
"=",
"optionString",
".",
"indexOf",
"(",
"TaggedArgumentParser",
".",
"ARGUMENT_TAG_NAME_SEPARATOR",
")",
";",
"if",
"(",
"separatorIndex",
"==",
"-",
"1",
")",
"{",
"// no tags, consume one argument and get out",
"detectAndRejectHybridSyntax",
"(",
"optionString",
")",
";",
"finalArgList",
".",
"add",
"(",
"optionPrefix",
"+",
"optionString",
")",
";",
"}",
"else",
"{",
"final",
"String",
"optionName",
"=",
"optionString",
".",
"substring",
"(",
"0",
",",
"separatorIndex",
")",
";",
"detectAndRejectHybridSyntax",
"(",
"optionName",
")",
";",
"if",
"(",
"userArgIt",
".",
"hasNext",
"(",
")",
")",
"{",
"if",
"(",
"optionName",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"CommandLineException",
"(",
"\"Zero length argument name found in tagged argument: \"",
"+",
"optionString",
")",
";",
"}",
"final",
"String",
"tagNameAndValues",
"=",
"optionString",
".",
"substring",
"(",
"separatorIndex",
"+",
"1",
",",
"optionString",
".",
"length",
"(",
")",
")",
";",
"if",
"(",
"tagNameAndValues",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"CommandLineException",
"(",
"\"Zero length tag name found in tagged argument: \"",
"+",
"optionString",
")",
";",
"}",
"final",
"String",
"argValue",
"=",
"userArgIt",
".",
"next",
"(",
")",
";",
"if",
"(",
"isLongOptionToken",
"(",
"argValue",
")",
"||",
"isShortOptionToken",
"(",
"argValue",
")",
")",
"{",
"// An argument value is required, and there isn't one to consume",
"throw",
"new",
"CommandLineException",
"(",
"\"No argument value found for tagged argument: \"",
"+",
"optionString",
")",
";",
"}",
"// Replace the original prefix/option/attribute string with the original prefix/option name, and",
"// replace it's companion argument value with the surrogate key to be used later to retrieve the",
"// actual values",
"final",
"String",
"pairKey",
"=",
"getSurrogateKeyForTaggedOption",
"(",
"optionString",
",",
"argValue",
",",
"tagNameAndValues",
")",
";",
"finalArgList",
".",
"add",
"(",
"optionPrefix",
"+",
"optionName",
")",
";",
"finalArgList",
".",
"add",
"(",
"pairKey",
")",
";",
"}",
"else",
"{",
"// the option appears to be tagged, but we're already at the end of the argument list,",
"// and there is no companion value to use",
"throw",
"new",
"CommandLineException",
"(",
"\"No argument value found for tagged argument: \"",
"+",
"optionString",
")",
";",
"}",
"}",
"}"
] |
Process a single option and add it to the curated args list. If the option is tagged, add the
curated key and value. Otherwise just add the raw option.
@param optionPrefix the actual option prefix used for this option, either "-" or "--"
@param optionString the option string including everything but the prefix
@param userArgIt iterator of raw arguments provided by the user, used to retrieve the value corresponding
to this option
@param finalArgList the curated argument list
|
[
"Process",
"a",
"single",
"option",
"and",
"add",
"it",
"to",
"the",
"curated",
"args",
"list",
".",
"If",
"the",
"option",
"is",
"tagged",
"add",
"the",
"curated",
"key",
"and",
"value",
".",
"Otherwise",
"just",
"add",
"the",
"raw",
"option",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/argparser/TaggedArgumentParser.java#L109-L149
|
8,743
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/argparser/TaggedArgumentParser.java
|
TaggedArgumentParser.getSurrogateKeyForTaggedOption
|
private String getSurrogateKeyForTaggedOption(
final String rawOptionString, // the raw option string provided by the user, including the prefix and option name
final String rawArgumentValue, // the raw argument value provided by the user
final String tagString // the tag string that has been peeled off of the raw option string, including logical name and any attributes
)
{
final String surrogateKey = makeSurrogateKey(rawOptionString, rawArgumentValue);
if (null != tagSurrogates.put(surrogateKey, Pair.of(tagString, rawArgumentValue))) {
throw new CommandLineException.BadArgumentValue(
String.format("The argument value: \"%s %s\" was duplicated on the command line", rawOptionString, rawArgumentValue));
}
return surrogateKey;
}
|
java
|
private String getSurrogateKeyForTaggedOption(
final String rawOptionString, // the raw option string provided by the user, including the prefix and option name
final String rawArgumentValue, // the raw argument value provided by the user
final String tagString // the tag string that has been peeled off of the raw option string, including logical name and any attributes
)
{
final String surrogateKey = makeSurrogateKey(rawOptionString, rawArgumentValue);
if (null != tagSurrogates.put(surrogateKey, Pair.of(tagString, rawArgumentValue))) {
throw new CommandLineException.BadArgumentValue(
String.format("The argument value: \"%s %s\" was duplicated on the command line", rawOptionString, rawArgumentValue));
}
return surrogateKey;
}
|
[
"private",
"String",
"getSurrogateKeyForTaggedOption",
"(",
"final",
"String",
"rawOptionString",
",",
"// the raw option string provided by the user, including the prefix and option name",
"final",
"String",
"rawArgumentValue",
",",
"// the raw argument value provided by the user",
"final",
"String",
"tagString",
"// the tag string that has been peeled off of the raw option string, including logical name and any attributes",
")",
"{",
"final",
"String",
"surrogateKey",
"=",
"makeSurrogateKey",
"(",
"rawOptionString",
",",
"rawArgumentValue",
")",
";",
"if",
"(",
"null",
"!=",
"tagSurrogates",
".",
"put",
"(",
"surrogateKey",
",",
"Pair",
".",
"of",
"(",
"tagString",
",",
"rawArgumentValue",
")",
")",
")",
"{",
"throw",
"new",
"CommandLineException",
".",
"BadArgumentValue",
"(",
"String",
".",
"format",
"(",
"\"The argument value: \\\"%s %s\\\" was duplicated on the command line\"",
",",
"rawOptionString",
",",
"rawArgumentValue",
")",
")",
";",
"}",
"return",
"surrogateKey",
";",
"}"
] |
Stores the option string and value in the tagSurrogates hash map and returns a surrogate key.
|
[
"Stores",
"the",
"option",
"string",
"and",
"value",
"in",
"the",
"tagSurrogates",
"hash",
"map",
"and",
"returns",
"a",
"surrogate",
"key",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/argparser/TaggedArgumentParser.java#L187-L199
|
8,744
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/argparser/TaggedArgumentParser.java
|
TaggedArgumentParser.populateArgumentTags
|
public static void populateArgumentTags(final TaggedArgument taggedArg, final String longArgName, final String tagString) {
if (tagString == null) {
taggedArg.setTag(null);
taggedArg.setTagAttributes(Collections.emptyMap());
} else {
final ParsedArgument pa = ParsedArgument.of(longArgName, tagString);
taggedArg.setTag(pa.getName());
taggedArg.setTagAttributes(pa.keyValueMap());
}
}
|
java
|
public static void populateArgumentTags(final TaggedArgument taggedArg, final String longArgName, final String tagString) {
if (tagString == null) {
taggedArg.setTag(null);
taggedArg.setTagAttributes(Collections.emptyMap());
} else {
final ParsedArgument pa = ParsedArgument.of(longArgName, tagString);
taggedArg.setTag(pa.getName());
taggedArg.setTagAttributes(pa.keyValueMap());
}
}
|
[
"public",
"static",
"void",
"populateArgumentTags",
"(",
"final",
"TaggedArgument",
"taggedArg",
",",
"final",
"String",
"longArgName",
",",
"final",
"String",
"tagString",
")",
"{",
"if",
"(",
"tagString",
"==",
"null",
")",
"{",
"taggedArg",
".",
"setTag",
"(",
"null",
")",
";",
"taggedArg",
".",
"setTagAttributes",
"(",
"Collections",
".",
"emptyMap",
"(",
")",
")",
";",
"}",
"else",
"{",
"final",
"ParsedArgument",
"pa",
"=",
"ParsedArgument",
".",
"of",
"(",
"longArgName",
",",
"tagString",
")",
";",
"taggedArg",
".",
"setTag",
"(",
"pa",
".",
"getName",
"(",
")",
")",
";",
"taggedArg",
".",
"setTagAttributes",
"(",
"pa",
".",
"keyValueMap",
"(",
")",
")",
";",
"}",
"}"
] |
Parse a tag string and populate a TaggedArgument with values.
@param taggedArg TaggedArgument to receive tags
@param longArgName name of the argument being tagged
@param tagString tag string (including logical name and attributes, no option name)
|
[
"Parse",
"a",
"tag",
"string",
"and",
"populate",
"a",
"TaggedArgument",
"with",
"values",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/argparser/TaggedArgumentParser.java#L231-L240
|
8,745
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/argparser/TaggedArgumentParser.java
|
TaggedArgumentParser.getDisplayString
|
public static String getDisplayString(final String longArgName, final TaggedArgument taggedArg) {
Utils.nonNull(longArgName);
Utils.nonNull(taggedArg);
StringBuilder sb = new StringBuilder();
sb.append(longArgName);
if (taggedArg.getTag() != null) {
sb.append(ARGUMENT_TAG_NAME_SEPARATOR);
sb.append(taggedArg.getTag());
if (taggedArg.getTagAttributes() != null) {
taggedArg.getTagAttributes().entrySet().stream()
.forEach(
entry -> {
sb.append(ARGUMENT_KEY_VALUE_PAIR_DELIMITER);
sb.append(entry.getKey().toString());
sb.append(ARGUMENT_KEY_VALUE_SEPARATOR);
sb.append(entry.getValue().toString());
});
}
}
return sb.toString();
}
|
java
|
public static String getDisplayString(final String longArgName, final TaggedArgument taggedArg) {
Utils.nonNull(longArgName);
Utils.nonNull(taggedArg);
StringBuilder sb = new StringBuilder();
sb.append(longArgName);
if (taggedArg.getTag() != null) {
sb.append(ARGUMENT_TAG_NAME_SEPARATOR);
sb.append(taggedArg.getTag());
if (taggedArg.getTagAttributes() != null) {
taggedArg.getTagAttributes().entrySet().stream()
.forEach(
entry -> {
sb.append(ARGUMENT_KEY_VALUE_PAIR_DELIMITER);
sb.append(entry.getKey().toString());
sb.append(ARGUMENT_KEY_VALUE_SEPARATOR);
sb.append(entry.getValue().toString());
});
}
}
return sb.toString();
}
|
[
"public",
"static",
"String",
"getDisplayString",
"(",
"final",
"String",
"longArgName",
",",
"final",
"TaggedArgument",
"taggedArg",
")",
"{",
"Utils",
".",
"nonNull",
"(",
"longArgName",
")",
";",
"Utils",
".",
"nonNull",
"(",
"taggedArg",
")",
";",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"sb",
".",
"append",
"(",
"longArgName",
")",
";",
"if",
"(",
"taggedArg",
".",
"getTag",
"(",
")",
"!=",
"null",
")",
"{",
"sb",
".",
"append",
"(",
"ARGUMENT_TAG_NAME_SEPARATOR",
")",
";",
"sb",
".",
"append",
"(",
"taggedArg",
".",
"getTag",
"(",
")",
")",
";",
"if",
"(",
"taggedArg",
".",
"getTagAttributes",
"(",
")",
"!=",
"null",
")",
"{",
"taggedArg",
".",
"getTagAttributes",
"(",
")",
".",
"entrySet",
"(",
")",
".",
"stream",
"(",
")",
".",
"forEach",
"(",
"entry",
"->",
"{",
"sb",
".",
"append",
"(",
"ARGUMENT_KEY_VALUE_PAIR_DELIMITER",
")",
";",
"sb",
".",
"append",
"(",
"entry",
".",
"getKey",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"ARGUMENT_KEY_VALUE_SEPARATOR",
")",
";",
"sb",
".",
"append",
"(",
"entry",
".",
"getValue",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"}",
")",
";",
"}",
"}",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] |
Given a TaggedArgument implementation and a long argument name, return a string representation of argument,
including the tag and attributes, for display purposes.
@param taggedArg implementation of TaggedArgument interface
@return a display string representing the tag name and attributes. May be empty if no tag name/attributes are present.
|
[
"Given",
"a",
"TaggedArgument",
"implementation",
"and",
"a",
"long",
"argument",
"name",
"return",
"a",
"string",
"representation",
"of",
"argument",
"including",
"the",
"tag",
"and",
"attributes",
"for",
"display",
"purposes",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/argparser/TaggedArgumentParser.java#L249-L272
|
8,746
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/help/BashTabCompletionDoclet.java
|
BashTabCompletionDoclet.optionLength
|
public static int optionLength(final String option) {
if (option.equals(CALLER_SCRIPT_NAME) ||
option.equals(CALLER_SCRIPT_PREFIX_LEGAL_ARGS) ||
option.equals(CALLER_SCRIPT_PREFIX_ARG_VALUE_TYPES) ||
option.equals(CALLER_SCRIPT_PREFIX_MUTEX_ARGS) ||
option.equals(CALLER_SCRIPT_PREFIX_ALIAS_ARGS) ||
option.equals(CALLER_SCRIPT_PREFIX_ARG_MIN_OCCURRENCES) ||
option.equals(CALLER_SCRIPT_PREFIX_ARG_MAX_OCCURRENCES) ||
option.equals(CALLER_SCRIPT_POSTFIX_LEGAL_ARGS) ||
option.equals(CALLER_SCRIPT_POSTFIX_ARG_VALUE_TYPES) ||
option.equals(CALLER_SCRIPT_POSTFIX_MUTEX_ARGS) ||
option.equals(CALLER_SCRIPT_POSTFIX_ALIAS_ARGS) ||
option.equals(CALLER_SCRIPT_POSTFIX_ARG_MIN_OCCURRENCES) ||
option.equals(CALLER_SCRIPT_POSTFIX_ARG_MAX_OCCURRENCES) )
{
return 2;
}
else {
return HelpDoclet.optionLength(option);
}
}
|
java
|
public static int optionLength(final String option) {
if (option.equals(CALLER_SCRIPT_NAME) ||
option.equals(CALLER_SCRIPT_PREFIX_LEGAL_ARGS) ||
option.equals(CALLER_SCRIPT_PREFIX_ARG_VALUE_TYPES) ||
option.equals(CALLER_SCRIPT_PREFIX_MUTEX_ARGS) ||
option.equals(CALLER_SCRIPT_PREFIX_ALIAS_ARGS) ||
option.equals(CALLER_SCRIPT_PREFIX_ARG_MIN_OCCURRENCES) ||
option.equals(CALLER_SCRIPT_PREFIX_ARG_MAX_OCCURRENCES) ||
option.equals(CALLER_SCRIPT_POSTFIX_LEGAL_ARGS) ||
option.equals(CALLER_SCRIPT_POSTFIX_ARG_VALUE_TYPES) ||
option.equals(CALLER_SCRIPT_POSTFIX_MUTEX_ARGS) ||
option.equals(CALLER_SCRIPT_POSTFIX_ALIAS_ARGS) ||
option.equals(CALLER_SCRIPT_POSTFIX_ARG_MIN_OCCURRENCES) ||
option.equals(CALLER_SCRIPT_POSTFIX_ARG_MAX_OCCURRENCES) )
{
return 2;
}
else {
return HelpDoclet.optionLength(option);
}
}
|
[
"public",
"static",
"int",
"optionLength",
"(",
"final",
"String",
"option",
")",
"{",
"if",
"(",
"option",
".",
"equals",
"(",
"CALLER_SCRIPT_NAME",
")",
"||",
"option",
".",
"equals",
"(",
"CALLER_SCRIPT_PREFIX_LEGAL_ARGS",
")",
"||",
"option",
".",
"equals",
"(",
"CALLER_SCRIPT_PREFIX_ARG_VALUE_TYPES",
")",
"||",
"option",
".",
"equals",
"(",
"CALLER_SCRIPT_PREFIX_MUTEX_ARGS",
")",
"||",
"option",
".",
"equals",
"(",
"CALLER_SCRIPT_PREFIX_ALIAS_ARGS",
")",
"||",
"option",
".",
"equals",
"(",
"CALLER_SCRIPT_PREFIX_ARG_MIN_OCCURRENCES",
")",
"||",
"option",
".",
"equals",
"(",
"CALLER_SCRIPT_PREFIX_ARG_MAX_OCCURRENCES",
")",
"||",
"option",
".",
"equals",
"(",
"CALLER_SCRIPT_POSTFIX_LEGAL_ARGS",
")",
"||",
"option",
".",
"equals",
"(",
"CALLER_SCRIPT_POSTFIX_ARG_VALUE_TYPES",
")",
"||",
"option",
".",
"equals",
"(",
"CALLER_SCRIPT_POSTFIX_MUTEX_ARGS",
")",
"||",
"option",
".",
"equals",
"(",
"CALLER_SCRIPT_POSTFIX_ALIAS_ARGS",
")",
"||",
"option",
".",
"equals",
"(",
"CALLER_SCRIPT_POSTFIX_ARG_MIN_OCCURRENCES",
")",
"||",
"option",
".",
"equals",
"(",
"CALLER_SCRIPT_POSTFIX_ARG_MAX_OCCURRENCES",
")",
")",
"{",
"return",
"2",
";",
"}",
"else",
"{",
"return",
"HelpDoclet",
".",
"optionLength",
"(",
"option",
")",
";",
"}",
"}"
] |
Must add options that are applicable to this doclet so that they will be accepted.
|
[
"Must",
"add",
"options",
"that",
"are",
"applicable",
"to",
"this",
"doclet",
"so",
"that",
"they",
"will",
"be",
"accepted",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/help/BashTabCompletionDoclet.java#L276-L297
|
8,747
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/help/BashTabCompletionDoclet.java
|
BashTabCompletionDoclet.processIndexTemplate
|
@Override
protected void processIndexTemplate(
final Configuration cfg,
final List<DocWorkUnit> workUnitList,
final List<Map<String, String>> groupMaps
) throws IOException {
// Create a root map for all the work units so we can access all the info we need:
final Map<String, Object> propertiesMap = new HashMap<>();
workUnits.stream().forEach( workUnit -> propertiesMap.put(workUnit.getName(), workUnit.getRootMap()) );
// Add everything into a nice package that we can iterate over
// while exposing the command line program names as keys:
final Map<String, Object> rootMap = new HashMap<>();
rootMap.put("tools", propertiesMap);
// Add the caller script options into another top-level tree node:
final Map<String, Object> callerScriptOptionsMap = new HashMap<>();
callerScriptOptionsMap.put("callerScriptName", callerScriptName);
callerScriptOptionsMap.put("callerScriptPrefixLegalArgs", callerScriptPrefixLegalArgs);
callerScriptOptionsMap.put("callerScriptPrefixArgValueTypes", callerScriptPrefixArgValueTypes);
callerScriptOptionsMap.put("callerScriptPrefixMutexArgs", callerScriptPrefixMutexArgs);
callerScriptOptionsMap.put("callerScriptPrefixAliasArgs", callerScriptPrefixAliasArgs);
callerScriptOptionsMap.put("callerScriptPrefixMinOccurrences", callerScriptPrefixMinOccurrences);
callerScriptOptionsMap.put("callerScriptPrefixMaxOccurrences", callerScriptPrefixMaxOccurrences);
callerScriptOptionsMap.put("callerScriptPostfixLegalArgs", callerScriptPostfixLegalArgs);
callerScriptOptionsMap.put("callerScriptPostfixArgValueTypes", callerScriptPostfixArgValueTypes);
callerScriptOptionsMap.put("callerScriptPostfixMutexArgs", callerScriptPostfixMutexArgs);
callerScriptOptionsMap.put("callerScriptPostfixAliasArgs", callerScriptPostfixAliasArgs);
callerScriptOptionsMap.put("callerScriptPostfixMinOccurrences", callerScriptPostfixMinOccurrences);
callerScriptOptionsMap.put("callerScriptPostfixMaxOccurrences", callerScriptPostfixMaxOccurrences);
if ( hasCallerScriptPostfixArgs ) {
callerScriptOptionsMap.put("hasCallerScriptPostfixArgs", "true");
}
else {
callerScriptOptionsMap.put("hasCallerScriptPostfixArgs", "false");
}
rootMap.put("callerScriptOptions", callerScriptOptionsMap);
// Get or create a template
final Template template = cfg.getTemplate(getIndexTemplateName());
// Create the output file
final File indexFile = new File(getDestinationDir(),
getIndexBaseFileName() + "." + getIndexFileExtension()
);
// Run the template and merge in the data
try (final FileOutputStream fileOutStream = new FileOutputStream(indexFile);
final OutputStreamWriter outWriter = new OutputStreamWriter(fileOutStream)) {
template.process(rootMap, outWriter);
} catch (TemplateException e) {
throw new DocException("Freemarker Template Exception during documentation index creation", e);
}
}
|
java
|
@Override
protected void processIndexTemplate(
final Configuration cfg,
final List<DocWorkUnit> workUnitList,
final List<Map<String, String>> groupMaps
) throws IOException {
// Create a root map for all the work units so we can access all the info we need:
final Map<String, Object> propertiesMap = new HashMap<>();
workUnits.stream().forEach( workUnit -> propertiesMap.put(workUnit.getName(), workUnit.getRootMap()) );
// Add everything into a nice package that we can iterate over
// while exposing the command line program names as keys:
final Map<String, Object> rootMap = new HashMap<>();
rootMap.put("tools", propertiesMap);
// Add the caller script options into another top-level tree node:
final Map<String, Object> callerScriptOptionsMap = new HashMap<>();
callerScriptOptionsMap.put("callerScriptName", callerScriptName);
callerScriptOptionsMap.put("callerScriptPrefixLegalArgs", callerScriptPrefixLegalArgs);
callerScriptOptionsMap.put("callerScriptPrefixArgValueTypes", callerScriptPrefixArgValueTypes);
callerScriptOptionsMap.put("callerScriptPrefixMutexArgs", callerScriptPrefixMutexArgs);
callerScriptOptionsMap.put("callerScriptPrefixAliasArgs", callerScriptPrefixAliasArgs);
callerScriptOptionsMap.put("callerScriptPrefixMinOccurrences", callerScriptPrefixMinOccurrences);
callerScriptOptionsMap.put("callerScriptPrefixMaxOccurrences", callerScriptPrefixMaxOccurrences);
callerScriptOptionsMap.put("callerScriptPostfixLegalArgs", callerScriptPostfixLegalArgs);
callerScriptOptionsMap.put("callerScriptPostfixArgValueTypes", callerScriptPostfixArgValueTypes);
callerScriptOptionsMap.put("callerScriptPostfixMutexArgs", callerScriptPostfixMutexArgs);
callerScriptOptionsMap.put("callerScriptPostfixAliasArgs", callerScriptPostfixAliasArgs);
callerScriptOptionsMap.put("callerScriptPostfixMinOccurrences", callerScriptPostfixMinOccurrences);
callerScriptOptionsMap.put("callerScriptPostfixMaxOccurrences", callerScriptPostfixMaxOccurrences);
if ( hasCallerScriptPostfixArgs ) {
callerScriptOptionsMap.put("hasCallerScriptPostfixArgs", "true");
}
else {
callerScriptOptionsMap.put("hasCallerScriptPostfixArgs", "false");
}
rootMap.put("callerScriptOptions", callerScriptOptionsMap);
// Get or create a template
final Template template = cfg.getTemplate(getIndexTemplateName());
// Create the output file
final File indexFile = new File(getDestinationDir(),
getIndexBaseFileName() + "." + getIndexFileExtension()
);
// Run the template and merge in the data
try (final FileOutputStream fileOutStream = new FileOutputStream(indexFile);
final OutputStreamWriter outWriter = new OutputStreamWriter(fileOutStream)) {
template.process(rootMap, outWriter);
} catch (TemplateException e) {
throw new DocException("Freemarker Template Exception during documentation index creation", e);
}
}
|
[
"@",
"Override",
"protected",
"void",
"processIndexTemplate",
"(",
"final",
"Configuration",
"cfg",
",",
"final",
"List",
"<",
"DocWorkUnit",
">",
"workUnitList",
",",
"final",
"List",
"<",
"Map",
"<",
"String",
",",
"String",
">",
">",
"groupMaps",
")",
"throws",
"IOException",
"{",
"// Create a root map for all the work units so we can access all the info we need:",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"propertiesMap",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"workUnits",
".",
"stream",
"(",
")",
".",
"forEach",
"(",
"workUnit",
"->",
"propertiesMap",
".",
"put",
"(",
"workUnit",
".",
"getName",
"(",
")",
",",
"workUnit",
".",
"getRootMap",
"(",
")",
")",
")",
";",
"// Add everything into a nice package that we can iterate over",
"// while exposing the command line program names as keys:",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"rootMap",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"rootMap",
".",
"put",
"(",
"\"tools\"",
",",
"propertiesMap",
")",
";",
"// Add the caller script options into another top-level tree node:",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"callerScriptOptionsMap",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"callerScriptOptionsMap",
".",
"put",
"(",
"\"callerScriptName\"",
",",
"callerScriptName",
")",
";",
"callerScriptOptionsMap",
".",
"put",
"(",
"\"callerScriptPrefixLegalArgs\"",
",",
"callerScriptPrefixLegalArgs",
")",
";",
"callerScriptOptionsMap",
".",
"put",
"(",
"\"callerScriptPrefixArgValueTypes\"",
",",
"callerScriptPrefixArgValueTypes",
")",
";",
"callerScriptOptionsMap",
".",
"put",
"(",
"\"callerScriptPrefixMutexArgs\"",
",",
"callerScriptPrefixMutexArgs",
")",
";",
"callerScriptOptionsMap",
".",
"put",
"(",
"\"callerScriptPrefixAliasArgs\"",
",",
"callerScriptPrefixAliasArgs",
")",
";",
"callerScriptOptionsMap",
".",
"put",
"(",
"\"callerScriptPrefixMinOccurrences\"",
",",
"callerScriptPrefixMinOccurrences",
")",
";",
"callerScriptOptionsMap",
".",
"put",
"(",
"\"callerScriptPrefixMaxOccurrences\"",
",",
"callerScriptPrefixMaxOccurrences",
")",
";",
"callerScriptOptionsMap",
".",
"put",
"(",
"\"callerScriptPostfixLegalArgs\"",
",",
"callerScriptPostfixLegalArgs",
")",
";",
"callerScriptOptionsMap",
".",
"put",
"(",
"\"callerScriptPostfixArgValueTypes\"",
",",
"callerScriptPostfixArgValueTypes",
")",
";",
"callerScriptOptionsMap",
".",
"put",
"(",
"\"callerScriptPostfixMutexArgs\"",
",",
"callerScriptPostfixMutexArgs",
")",
";",
"callerScriptOptionsMap",
".",
"put",
"(",
"\"callerScriptPostfixAliasArgs\"",
",",
"callerScriptPostfixAliasArgs",
")",
";",
"callerScriptOptionsMap",
".",
"put",
"(",
"\"callerScriptPostfixMinOccurrences\"",
",",
"callerScriptPostfixMinOccurrences",
")",
";",
"callerScriptOptionsMap",
".",
"put",
"(",
"\"callerScriptPostfixMaxOccurrences\"",
",",
"callerScriptPostfixMaxOccurrences",
")",
";",
"if",
"(",
"hasCallerScriptPostfixArgs",
")",
"{",
"callerScriptOptionsMap",
".",
"put",
"(",
"\"hasCallerScriptPostfixArgs\"",
",",
"\"true\"",
")",
";",
"}",
"else",
"{",
"callerScriptOptionsMap",
".",
"put",
"(",
"\"hasCallerScriptPostfixArgs\"",
",",
"\"false\"",
")",
";",
"}",
"rootMap",
".",
"put",
"(",
"\"callerScriptOptions\"",
",",
"callerScriptOptionsMap",
")",
";",
"// Get or create a template",
"final",
"Template",
"template",
"=",
"cfg",
".",
"getTemplate",
"(",
"getIndexTemplateName",
"(",
")",
")",
";",
"// Create the output file",
"final",
"File",
"indexFile",
"=",
"new",
"File",
"(",
"getDestinationDir",
"(",
")",
",",
"getIndexBaseFileName",
"(",
")",
"+",
"\".\"",
"+",
"getIndexFileExtension",
"(",
")",
")",
";",
"// Run the template and merge in the data",
"try",
"(",
"final",
"FileOutputStream",
"fileOutStream",
"=",
"new",
"FileOutputStream",
"(",
"indexFile",
")",
";",
"final",
"OutputStreamWriter",
"outWriter",
"=",
"new",
"OutputStreamWriter",
"(",
"fileOutStream",
")",
")",
"{",
"template",
".",
"process",
"(",
"rootMap",
",",
"outWriter",
")",
";",
"}",
"catch",
"(",
"TemplateException",
"e",
")",
"{",
"throw",
"new",
"DocException",
"(",
"\"Freemarker Template Exception during documentation index creation\"",
",",
"e",
")",
";",
"}",
"}"
] |
The Index file in the Bash Completion Doclet is what generates the actual tab-completion script.
This will actually write out the shell completion output file.
The Freemarker instance will see a top-level map that has two keys in it.
The first key is for caller script options:
SimpleMap callerScriptOptions = SimpleMap {
"callerScriptName" : caller script name
"callerScriptPrefixLegalArgs" : caller Script Prefix Legal Args
"callerScriptPrefixArgValueTypes" : caller Script Prefix Arg Value Types
"callerScriptPrefixMutexArgs" : caller Script Prefix Mutex Args
"callerScriptPrefixAliasArgs" : caller Script Prefix Alias Args
"callerScriptPrefixMinOccurrences" : caller Script Prefix Min Occurrences
"callerScriptPrefixMaxOccurrences" : caller Script Prefix Max Occurrences
"hasCallerScriptPrefixArgs" : has Caller Script Prefix Args
"callerScriptPostfixLegalArgs" : caller Script Postfix Legal Args
"callerScriptPostfixArgValueTypes" : caller Script Postfix Arg Value Types
"callerScriptPostfixMutexArgs" : caller Script Postfix Mutex Args
"callerScriptPostfixAliasArgs" : caller Script Postfix Alias Args
"callerScriptPostfixMinOccurrences" : caller Script Postfix Min Occurrences
"callerScriptPostfixMaxOccurrences" : caller Script Postfix Max Occurrences
"hasCallerScriptPostfixArgs" : has Caller Script Postfix Args
}
The second key is for tool options:
SimpleMap tools = SimpleMap { ToolName : MasterPropertiesMap }
where
MasterPropertiesMap is a map containing the following Keys:
all
common
positional
hidden
advanced
deprecated
optional
dependent
required
Each of those keys maps to a List<SimpleMap> representing each property.
These property maps each contain the following keys:
kind
name
summary
fulltext
otherArgumentRequired
synonyms
exclusiveOf
type
options
attributes
required
minRecValue
maxRecValue
minValue
maxValue
defaultValue
minElements
maxElements
@param cfg
@param workUnitList
@param groupMaps
@throws IOException
|
[
"The",
"Index",
"file",
"in",
"the",
"Bash",
"Completion",
"Doclet",
"is",
"what",
"generates",
"the",
"actual",
"tab",
"-",
"completion",
"script",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/help/BashTabCompletionDoclet.java#L478-L534
|
8,748
|
michaelquigley/zabbixj
|
zabbixj-core/src/main/java/com/quigley/zabbixj/agent/passive/WorkerThread.java
|
WorkerThread.run
|
public void run() {
// For log messages.
String client = socket.getInetAddress().getHostAddress();
if(log.isDebugEnabled()) {
log.info("Accepted Connection From: " + client);
}
PrintWriter out = null;
BufferedReader in = null;
try {
// Set timeout to 1 second.
socket.setSoTimeout(1000);
out = new PrintWriter(socket.getOutputStream(), true);
in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
String inputLine = in.readLine();
// Fix for zabbix_get.
if(inputLine.substring(0, 4).equals("ZBXD")) {
inputLine = inputLine.substring(13, inputLine.length());
}
if(inputLine != null) {
try {
Object value = container.getMetric(inputLine);
out.print(value.toString());
out.flush();
} catch(MetricsException me) {
if(log.isErrorEnabled()) {
log.error("Client: " + client + " Sent Unknown Key: " + inputLine);
}
out.print("ZBX_NOTSUPPORTED");
out.flush();
}
}
} catch(SocketTimeoutException ste) {
log.debug(client + ": Timeout Detected.");
} catch(Exception e) {
log.error(client + ": Error: " + e.toString());
} finally {
if(log.isDebugEnabled()) {
log.debug(client + ": Disconnected.");
}
try { if(in != null) { in.close(); } } catch(Exception e) { }
try { if(out != null) { out.close(); } } catch(Exception e) { }
try { socket.close(); } catch(Exception e) { }
}
}
|
java
|
public void run() {
// For log messages.
String client = socket.getInetAddress().getHostAddress();
if(log.isDebugEnabled()) {
log.info("Accepted Connection From: " + client);
}
PrintWriter out = null;
BufferedReader in = null;
try {
// Set timeout to 1 second.
socket.setSoTimeout(1000);
out = new PrintWriter(socket.getOutputStream(), true);
in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
String inputLine = in.readLine();
// Fix for zabbix_get.
if(inputLine.substring(0, 4).equals("ZBXD")) {
inputLine = inputLine.substring(13, inputLine.length());
}
if(inputLine != null) {
try {
Object value = container.getMetric(inputLine);
out.print(value.toString());
out.flush();
} catch(MetricsException me) {
if(log.isErrorEnabled()) {
log.error("Client: " + client + " Sent Unknown Key: " + inputLine);
}
out.print("ZBX_NOTSUPPORTED");
out.flush();
}
}
} catch(SocketTimeoutException ste) {
log.debug(client + ": Timeout Detected.");
} catch(Exception e) {
log.error(client + ": Error: " + e.toString());
} finally {
if(log.isDebugEnabled()) {
log.debug(client + ": Disconnected.");
}
try { if(in != null) { in.close(); } } catch(Exception e) { }
try { if(out != null) { out.close(); } } catch(Exception e) { }
try { socket.close(); } catch(Exception e) { }
}
}
|
[
"public",
"void",
"run",
"(",
")",
"{",
"// For log messages.",
"String",
"client",
"=",
"socket",
".",
"getInetAddress",
"(",
")",
".",
"getHostAddress",
"(",
")",
";",
"if",
"(",
"log",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"log",
".",
"info",
"(",
"\"Accepted Connection From: \"",
"+",
"client",
")",
";",
"}",
"PrintWriter",
"out",
"=",
"null",
";",
"BufferedReader",
"in",
"=",
"null",
";",
"try",
"{",
"// Set timeout to 1 second.",
"socket",
".",
"setSoTimeout",
"(",
"1000",
")",
";",
"out",
"=",
"new",
"PrintWriter",
"(",
"socket",
".",
"getOutputStream",
"(",
")",
",",
"true",
")",
";",
"in",
"=",
"new",
"BufferedReader",
"(",
"new",
"InputStreamReader",
"(",
"socket",
".",
"getInputStream",
"(",
")",
")",
")",
";",
"String",
"inputLine",
"=",
"in",
".",
"readLine",
"(",
")",
";",
"// Fix for zabbix_get.",
"if",
"(",
"inputLine",
".",
"substring",
"(",
"0",
",",
"4",
")",
".",
"equals",
"(",
"\"ZBXD\"",
")",
")",
"{",
"inputLine",
"=",
"inputLine",
".",
"substring",
"(",
"13",
",",
"inputLine",
".",
"length",
"(",
")",
")",
";",
"}",
"if",
"(",
"inputLine",
"!=",
"null",
")",
"{",
"try",
"{",
"Object",
"value",
"=",
"container",
".",
"getMetric",
"(",
"inputLine",
")",
";",
"out",
".",
"print",
"(",
"value",
".",
"toString",
"(",
")",
")",
";",
"out",
".",
"flush",
"(",
")",
";",
"}",
"catch",
"(",
"MetricsException",
"me",
")",
"{",
"if",
"(",
"log",
".",
"isErrorEnabled",
"(",
")",
")",
"{",
"log",
".",
"error",
"(",
"\"Client: \"",
"+",
"client",
"+",
"\" Sent Unknown Key: \"",
"+",
"inputLine",
")",
";",
"}",
"out",
".",
"print",
"(",
"\"ZBX_NOTSUPPORTED\"",
")",
";",
"out",
".",
"flush",
"(",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"SocketTimeoutException",
"ste",
")",
"{",
"log",
".",
"debug",
"(",
"client",
"+",
"\": Timeout Detected.\"",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"log",
".",
"error",
"(",
"client",
"+",
"\": Error: \"",
"+",
"e",
".",
"toString",
"(",
")",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"log",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"log",
".",
"debug",
"(",
"client",
"+",
"\": Disconnected.\"",
")",
";",
"}",
"try",
"{",
"if",
"(",
"in",
"!=",
"null",
")",
"{",
"in",
".",
"close",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"}",
"try",
"{",
"if",
"(",
"out",
"!=",
"null",
")",
"{",
"out",
".",
"close",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"}",
"try",
"{",
"socket",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"}",
"}",
"}"
] |
WorkerThread execution begins.
|
[
"WorkerThread",
"execution",
"begins",
"."
] |
15cfe46e45750b3857bec7eecc75ff5e5a3d774d
|
https://github.com/michaelquigley/zabbixj/blob/15cfe46e45750b3857bec7eecc75ff5e5a3d774d/zabbixj-core/src/main/java/com/quigley/zabbixj/agent/passive/WorkerThread.java#L56-L113
|
8,749
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/argparser/LegacyCommandLineArgumentParser.java
|
LegacyCommandLineArgumentParser.hasWebDocumentation
|
public boolean hasWebDocumentation(final Class<?> clazz) {
for (final String pkg : PACKAGES_WITH_WEB_DOCUMENTATION) {
if (clazz.getPackage().getName().startsWith(pkg)) {
return true;
}
}
return false;
}
|
java
|
public boolean hasWebDocumentation(final Class<?> clazz) {
for (final String pkg : PACKAGES_WITH_WEB_DOCUMENTATION) {
if (clazz.getPackage().getName().startsWith(pkg)) {
return true;
}
}
return false;
}
|
[
"public",
"boolean",
"hasWebDocumentation",
"(",
"final",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"for",
"(",
"final",
"String",
"pkg",
":",
"PACKAGES_WITH_WEB_DOCUMENTATION",
")",
"{",
"if",
"(",
"clazz",
".",
"getPackage",
"(",
")",
".",
"getName",
"(",
")",
".",
"startsWith",
"(",
"pkg",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Determines if a class has web documentation based on its package name
@param clazz
@return true if the class has web documentation, false otherwise
|
[
"Determines",
"if",
"a",
"class",
"has",
"web",
"documentation",
"based",
"on",
"its",
"package",
"name"
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/argparser/LegacyCommandLineArgumentParser.java#L127-L134
|
8,750
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/argparser/LegacyCommandLineArgumentParser.java
|
LegacyCommandLineArgumentParser.usage
|
@Override
public String usage(final boolean printCommon, final boolean printHidden) {
final StringBuilder sb = new StringBuilder();
if (!printHidden) {
logger.warn("Hidden arguments are always printed in LegacyCommandLineArgumentParser");
}
if (prefix.isEmpty()) {
final String preamble = htmlUnescape(convertFromHtml(getStandardUsagePreamble(callerOptions.getClass()) + getUsagePreamble()));
checkForNonASCII(preamble, "Tool description");
sb.append(Utils.wrapParagraph(preamble,OPTION_COLUMN_WIDTH + DESCRIPTION_COLUMN_WIDTH));
sb.append("\nVersion: " + getVersion());
sb.append("\n");
sb.append("\n\nOptions:\n\n");
for (final String[] optionDoc : FRAMEWORK_OPTION_DOC) {
printOptionParamUsage(sb, optionDoc[0], optionDoc[1], null, optionDoc[2]);
}
}
if (!optionDefinitions.isEmpty()) {
optionDefinitions.stream().filter(optionDefinition -> printCommon || !optionDefinition.isCommon).forEach(optionDefinition -> printOptionUsage(sb, optionDefinition));
}
if (printCommon) {
final Field fileField;
try {
//Temp class OPTIONS_FILE
class OptionFileContainerForUsage { public File optionFileContainer;}
fileField = OptionFileContainerForUsage.class.getField("optionFileContainer");
} catch (final NoSuchFieldException e) {
throw new CommandLineException("Should never happen", e);
}
final OptionDefinition optionsFileOptionDefinition =
new OptionDefinition(fileField, null, OPTIONS_FILE, "",
"File of OPTION_NAME=value pairs. No positional parameters allowed. Unlike command-line options, " +
"unrecognized options are ignored. " + "A single-valued option set in an options file may be overridden " +
"by a subsequent command-line option. " +
"A line starting with '#' is considered a comment.",
false, false, 0, Integer.MAX_VALUE, null, true, new String[0]);
printOptionUsage(sb, optionsFileOptionDefinition);
}
return sb.toString();
}
|
java
|
@Override
public String usage(final boolean printCommon, final boolean printHidden) {
final StringBuilder sb = new StringBuilder();
if (!printHidden) {
logger.warn("Hidden arguments are always printed in LegacyCommandLineArgumentParser");
}
if (prefix.isEmpty()) {
final String preamble = htmlUnescape(convertFromHtml(getStandardUsagePreamble(callerOptions.getClass()) + getUsagePreamble()));
checkForNonASCII(preamble, "Tool description");
sb.append(Utils.wrapParagraph(preamble,OPTION_COLUMN_WIDTH + DESCRIPTION_COLUMN_WIDTH));
sb.append("\nVersion: " + getVersion());
sb.append("\n");
sb.append("\n\nOptions:\n\n");
for (final String[] optionDoc : FRAMEWORK_OPTION_DOC) {
printOptionParamUsage(sb, optionDoc[0], optionDoc[1], null, optionDoc[2]);
}
}
if (!optionDefinitions.isEmpty()) {
optionDefinitions.stream().filter(optionDefinition -> printCommon || !optionDefinition.isCommon).forEach(optionDefinition -> printOptionUsage(sb, optionDefinition));
}
if (printCommon) {
final Field fileField;
try {
//Temp class OPTIONS_FILE
class OptionFileContainerForUsage { public File optionFileContainer;}
fileField = OptionFileContainerForUsage.class.getField("optionFileContainer");
} catch (final NoSuchFieldException e) {
throw new CommandLineException("Should never happen", e);
}
final OptionDefinition optionsFileOptionDefinition =
new OptionDefinition(fileField, null, OPTIONS_FILE, "",
"File of OPTION_NAME=value pairs. No positional parameters allowed. Unlike command-line options, " +
"unrecognized options are ignored. " + "A single-valued option set in an options file may be overridden " +
"by a subsequent command-line option. " +
"A line starting with '#' is considered a comment.",
false, false, 0, Integer.MAX_VALUE, null, true, new String[0]);
printOptionUsage(sb, optionsFileOptionDefinition);
}
return sb.toString();
}
|
[
"@",
"Override",
"public",
"String",
"usage",
"(",
"final",
"boolean",
"printCommon",
",",
"final",
"boolean",
"printHidden",
")",
"{",
"final",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"if",
"(",
"!",
"printHidden",
")",
"{",
"logger",
".",
"warn",
"(",
"\"Hidden arguments are always printed in LegacyCommandLineArgumentParser\"",
")",
";",
"}",
"if",
"(",
"prefix",
".",
"isEmpty",
"(",
")",
")",
"{",
"final",
"String",
"preamble",
"=",
"htmlUnescape",
"(",
"convertFromHtml",
"(",
"getStandardUsagePreamble",
"(",
"callerOptions",
".",
"getClass",
"(",
")",
")",
"+",
"getUsagePreamble",
"(",
")",
")",
")",
";",
"checkForNonASCII",
"(",
"preamble",
",",
"\"Tool description\"",
")",
";",
"sb",
".",
"append",
"(",
"Utils",
".",
"wrapParagraph",
"(",
"preamble",
",",
"OPTION_COLUMN_WIDTH",
"+",
"DESCRIPTION_COLUMN_WIDTH",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"\\nVersion: \"",
"+",
"getVersion",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\"\\n\"",
")",
";",
"sb",
".",
"append",
"(",
"\"\\n\\nOptions:\\n\\n\"",
")",
";",
"for",
"(",
"final",
"String",
"[",
"]",
"optionDoc",
":",
"FRAMEWORK_OPTION_DOC",
")",
"{",
"printOptionParamUsage",
"(",
"sb",
",",
"optionDoc",
"[",
"0",
"]",
",",
"optionDoc",
"[",
"1",
"]",
",",
"null",
",",
"optionDoc",
"[",
"2",
"]",
")",
";",
"}",
"}",
"if",
"(",
"!",
"optionDefinitions",
".",
"isEmpty",
"(",
")",
")",
"{",
"optionDefinitions",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"optionDefinition",
"->",
"printCommon",
"||",
"!",
"optionDefinition",
".",
"isCommon",
")",
".",
"forEach",
"(",
"optionDefinition",
"->",
"printOptionUsage",
"(",
"sb",
",",
"optionDefinition",
")",
")",
";",
"}",
"if",
"(",
"printCommon",
")",
"{",
"final",
"Field",
"fileField",
";",
"try",
"{",
"//Temp class OPTIONS_FILE",
"class",
"OptionFileContainerForUsage",
"{",
"public",
"File",
"optionFileContainer",
";",
"}",
"fileField",
"=",
"OptionFileContainerForUsage",
".",
"class",
".",
"getField",
"(",
"\"optionFileContainer\"",
")",
";",
"}",
"catch",
"(",
"final",
"NoSuchFieldException",
"e",
")",
"{",
"throw",
"new",
"CommandLineException",
"(",
"\"Should never happen\"",
",",
"e",
")",
";",
"}",
"final",
"OptionDefinition",
"optionsFileOptionDefinition",
"=",
"new",
"OptionDefinition",
"(",
"fileField",
",",
"null",
",",
"OPTIONS_FILE",
",",
"\"\"",
",",
"\"File of OPTION_NAME=value pairs. No positional parameters allowed. Unlike command-line options, \"",
"+",
"\"unrecognized options are ignored. \"",
"+",
"\"A single-valued option set in an options file may be overridden \"",
"+",
"\"by a subsequent command-line option. \"",
"+",
"\"A line starting with '#' is considered a comment.\"",
",",
"false",
",",
"false",
",",
"0",
",",
"Integer",
".",
"MAX_VALUE",
",",
"null",
",",
"true",
",",
"new",
"String",
"[",
"0",
"]",
")",
";",
"printOptionUsage",
"(",
"sb",
",",
"optionsFileOptionDefinition",
")",
";",
"}",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] |
Print a usage message based on the options object passed to the ctor.
@param printCommon True if common args should be included in the usage message.
@param printHidden Ignored in legacy.
@return Usage string generated by the command line parser.
|
[
"Print",
"a",
"usage",
"message",
"based",
"on",
"the",
"options",
"object",
"passed",
"to",
"the",
"ctor",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/argparser/LegacyCommandLineArgumentParser.java#L266-L310
|
8,751
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/argparser/LegacyCommandLineArgumentParser.java
|
LegacyCommandLineArgumentParser.convertFromHtml
|
static String convertFromHtml(final String textToConvert) {
//LinkedHashmap since the order matters
final Map<String, String> regexps = new LinkedHashMap<>();
regexps.put("< *a *href=[\'\"](.*?)[\'\"] *>(.*?)</ *a *>","$2 ($1)");
regexps.put("< *a *href=[\'\"](.*?)[\'\"] *>(.*?)< *a */>","$2 ($1)");
regexps.put("</ *(br|p|table|h[1-4]|pre|hr|li|ul) *>","\n");
regexps.put("< *(br|p|table|h[1-4]|pre|hr|li|ul) */>","\n");
regexps.put("< *(p|table|h[1-4]|ul|pre) *>","\n");
regexps.put("<li>", " - ");
regexps.put("</th>", "\t");
regexps.put("<\\w*?>", "");
return regexps.entrySet().stream().sequential()
.reduce(textToConvert, (string, entrySet) -> string.replaceAll(entrySet.getKey(), entrySet.getValue()), (a, b) -> b);
}
|
java
|
static String convertFromHtml(final String textToConvert) {
//LinkedHashmap since the order matters
final Map<String, String> regexps = new LinkedHashMap<>();
regexps.put("< *a *href=[\'\"](.*?)[\'\"] *>(.*?)</ *a *>","$2 ($1)");
regexps.put("< *a *href=[\'\"](.*?)[\'\"] *>(.*?)< *a */>","$2 ($1)");
regexps.put("</ *(br|p|table|h[1-4]|pre|hr|li|ul) *>","\n");
regexps.put("< *(br|p|table|h[1-4]|pre|hr|li|ul) */>","\n");
regexps.put("< *(p|table|h[1-4]|ul|pre) *>","\n");
regexps.put("<li>", " - ");
regexps.put("</th>", "\t");
regexps.put("<\\w*?>", "");
return regexps.entrySet().stream().sequential()
.reduce(textToConvert, (string, entrySet) -> string.replaceAll(entrySet.getKey(), entrySet.getValue()), (a, b) -> b);
}
|
[
"static",
"String",
"convertFromHtml",
"(",
"final",
"String",
"textToConvert",
")",
"{",
"//LinkedHashmap since the order matters",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"regexps",
"=",
"new",
"LinkedHashMap",
"<>",
"(",
")",
";",
"regexps",
".",
"put",
"(",
"\"< *a *href=[\\'\\\"](.*?)[\\'\\\"] *>(.*?)</ *a *>\"",
",",
"\"$2 ($1)\"",
")",
";",
"regexps",
".",
"put",
"(",
"\"< *a *href=[\\'\\\"](.*?)[\\'\\\"] *>(.*?)< *a */>\"",
",",
"\"$2 ($1)\"",
")",
";",
"regexps",
".",
"put",
"(",
"\"</ *(br|p|table|h[1-4]|pre|hr|li|ul) *>\"",
",",
"\"\\n\"",
")",
";",
"regexps",
".",
"put",
"(",
"\"< *(br|p|table|h[1-4]|pre|hr|li|ul) */>\"",
",",
"\"\\n\"",
")",
";",
"regexps",
".",
"put",
"(",
"\"< *(p|table|h[1-4]|ul|pre) *>\"",
",",
"\"\\n\"",
")",
";",
"regexps",
".",
"put",
"(",
"\"<li>\"",
",",
"\" - \"",
")",
";",
"regexps",
".",
"put",
"(",
"\"</th>\"",
",",
"\"\\t\"",
")",
";",
"regexps",
".",
"put",
"(",
"\"<\\\\w*?>\"",
",",
"\"\"",
")",
";",
"return",
"regexps",
".",
"entrySet",
"(",
")",
".",
"stream",
"(",
")",
".",
"sequential",
"(",
")",
".",
"reduce",
"(",
"textToConvert",
",",
"(",
"string",
",",
"entrySet",
")",
"->",
"string",
".",
"replaceAll",
"(",
"entrySet",
".",
"getKey",
"(",
")",
",",
"entrySet",
".",
"getValue",
"(",
")",
")",
",",
"(",
"a",
",",
"b",
")",
"->",
"b",
")",
";",
"}"
] |
package local for testing
|
[
"package",
"local",
"for",
"testing"
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/argparser/LegacyCommandLineArgumentParser.java#L322-L338
|
8,752
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/argparser/LegacyCommandLineArgumentParser.java
|
LegacyCommandLineArgumentParser.parseArguments
|
@Override
public boolean parseArguments(final PrintStream messageStream, final String[] args) {
this.argv = args;
this.messageStream = messageStream;
if (prefix.isEmpty()) {
commandLine = callerOptions.getClass().getSimpleName();
}
for (int i = 0; i < args.length; ++i) {
final String arg = args[i];
if (arg.equals("-h") || arg.equals("--help")) {
messageStream.append(usage(false, true));
return false;
}
if (arg.equals("-H") || arg.equals("--stdhelp")) {
messageStream.append(usage(true, true));
return false;
}
if (arg.equals("--version")) {
messageStream.println(getVersion());
return false;
}
final String[] pair = arg.split("=", 2);
if (pair.length == 2) {
if (pair[1].isEmpty() && i < args.length - 1) {
pair[1] = args[++i];
}
if (!parseOption(pair[0], pair[1], false)) {
messageStream.println();
messageStream.append(usage(true, true));
return false;
}
} else if (!parsePositionalArgument(arg)) {
messageStream.println();
messageStream.append(usage(false, true));
return false;
}
}
if (!checkNumArguments()) {
messageStream.println();
messageStream.append(usage(false, true));
return false;
}
return true;
}
|
java
|
@Override
public boolean parseArguments(final PrintStream messageStream, final String[] args) {
this.argv = args;
this.messageStream = messageStream;
if (prefix.isEmpty()) {
commandLine = callerOptions.getClass().getSimpleName();
}
for (int i = 0; i < args.length; ++i) {
final String arg = args[i];
if (arg.equals("-h") || arg.equals("--help")) {
messageStream.append(usage(false, true));
return false;
}
if (arg.equals("-H") || arg.equals("--stdhelp")) {
messageStream.append(usage(true, true));
return false;
}
if (arg.equals("--version")) {
messageStream.println(getVersion());
return false;
}
final String[] pair = arg.split("=", 2);
if (pair.length == 2) {
if (pair[1].isEmpty() && i < args.length - 1) {
pair[1] = args[++i];
}
if (!parseOption(pair[0], pair[1], false)) {
messageStream.println();
messageStream.append(usage(true, true));
return false;
}
} else if (!parsePositionalArgument(arg)) {
messageStream.println();
messageStream.append(usage(false, true));
return false;
}
}
if (!checkNumArguments()) {
messageStream.println();
messageStream.append(usage(false, true));
return false;
}
return true;
}
|
[
"@",
"Override",
"public",
"boolean",
"parseArguments",
"(",
"final",
"PrintStream",
"messageStream",
",",
"final",
"String",
"[",
"]",
"args",
")",
"{",
"this",
".",
"argv",
"=",
"args",
";",
"this",
".",
"messageStream",
"=",
"messageStream",
";",
"if",
"(",
"prefix",
".",
"isEmpty",
"(",
")",
")",
"{",
"commandLine",
"=",
"callerOptions",
".",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"args",
".",
"length",
";",
"++",
"i",
")",
"{",
"final",
"String",
"arg",
"=",
"args",
"[",
"i",
"]",
";",
"if",
"(",
"arg",
".",
"equals",
"(",
"\"-h\"",
")",
"||",
"arg",
".",
"equals",
"(",
"\"--help\"",
")",
")",
"{",
"messageStream",
".",
"append",
"(",
"usage",
"(",
"false",
",",
"true",
")",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"arg",
".",
"equals",
"(",
"\"-H\"",
")",
"||",
"arg",
".",
"equals",
"(",
"\"--stdhelp\"",
")",
")",
"{",
"messageStream",
".",
"append",
"(",
"usage",
"(",
"true",
",",
"true",
")",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"arg",
".",
"equals",
"(",
"\"--version\"",
")",
")",
"{",
"messageStream",
".",
"println",
"(",
"getVersion",
"(",
")",
")",
";",
"return",
"false",
";",
"}",
"final",
"String",
"[",
"]",
"pair",
"=",
"arg",
".",
"split",
"(",
"\"=\"",
",",
"2",
")",
";",
"if",
"(",
"pair",
".",
"length",
"==",
"2",
")",
"{",
"if",
"(",
"pair",
"[",
"1",
"]",
".",
"isEmpty",
"(",
")",
"&&",
"i",
"<",
"args",
".",
"length",
"-",
"1",
")",
"{",
"pair",
"[",
"1",
"]",
"=",
"args",
"[",
"++",
"i",
"]",
";",
"}",
"if",
"(",
"!",
"parseOption",
"(",
"pair",
"[",
"0",
"]",
",",
"pair",
"[",
"1",
"]",
",",
"false",
")",
")",
"{",
"messageStream",
".",
"println",
"(",
")",
";",
"messageStream",
".",
"append",
"(",
"usage",
"(",
"true",
",",
"true",
")",
")",
";",
"return",
"false",
";",
"}",
"}",
"else",
"if",
"(",
"!",
"parsePositionalArgument",
"(",
"arg",
")",
")",
"{",
"messageStream",
".",
"println",
"(",
")",
";",
"messageStream",
".",
"append",
"(",
"usage",
"(",
"false",
",",
"true",
")",
")",
";",
"return",
"false",
";",
"}",
"}",
"if",
"(",
"!",
"checkNumArguments",
"(",
")",
")",
"{",
"messageStream",
".",
"println",
"(",
")",
";",
"messageStream",
".",
"append",
"(",
"usage",
"(",
"false",
",",
"true",
")",
")",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Parse command-line options, and store values in callerOptions object passed to ctor.
@param messageStream Where to write error messages.
@param args Command line tokens.
@return true if command line is valid.
|
[
"Parse",
"command",
"-",
"line",
"options",
"and",
"store",
"values",
"in",
"callerOptions",
"object",
"passed",
"to",
"ctor",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/argparser/LegacyCommandLineArgumentParser.java#L365-L411
|
8,753
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/argparser/LegacyCommandLineArgumentParser.java
|
LegacyCommandLineArgumentParser.getUnderlyingType
|
private Class<?> getUnderlyingType(final Field field) {
if (isCollectionField(field)) {
final ParameterizedType clazz = (ParameterizedType) (field.getGenericType());
final Type[] genericTypes = clazz.getActualTypeArguments();
if (genericTypes.length != 1) {
throw new CommandLineException.CommandLineParserInternalException("Strange collection type for field " +
field.getName());
}
return (Class) genericTypes[0];
} else {
final Class<?> type = field.getType();
if (type == Byte.TYPE) return Byte.class;
if (type == Short.TYPE) return Short.class;
if (type == Integer.TYPE) return Integer.class;
if (type == Long.TYPE) return Long.class;
if (type == Float.TYPE) return Float.class;
if (type == Double.TYPE) return Double.class;
if (type == Boolean.TYPE) return Boolean.class;
return type;
}
}
|
java
|
private Class<?> getUnderlyingType(final Field field) {
if (isCollectionField(field)) {
final ParameterizedType clazz = (ParameterizedType) (field.getGenericType());
final Type[] genericTypes = clazz.getActualTypeArguments();
if (genericTypes.length != 1) {
throw new CommandLineException.CommandLineParserInternalException("Strange collection type for field " +
field.getName());
}
return (Class) genericTypes[0];
} else {
final Class<?> type = field.getType();
if (type == Byte.TYPE) return Byte.class;
if (type == Short.TYPE) return Short.class;
if (type == Integer.TYPE) return Integer.class;
if (type == Long.TYPE) return Long.class;
if (type == Float.TYPE) return Float.class;
if (type == Double.TYPE) return Double.class;
if (type == Boolean.TYPE) return Boolean.class;
return type;
}
}
|
[
"private",
"Class",
"<",
"?",
">",
"getUnderlyingType",
"(",
"final",
"Field",
"field",
")",
"{",
"if",
"(",
"isCollectionField",
"(",
"field",
")",
")",
"{",
"final",
"ParameterizedType",
"clazz",
"=",
"(",
"ParameterizedType",
")",
"(",
"field",
".",
"getGenericType",
"(",
")",
")",
";",
"final",
"Type",
"[",
"]",
"genericTypes",
"=",
"clazz",
".",
"getActualTypeArguments",
"(",
")",
";",
"if",
"(",
"genericTypes",
".",
"length",
"!=",
"1",
")",
"{",
"throw",
"new",
"CommandLineException",
".",
"CommandLineParserInternalException",
"(",
"\"Strange collection type for field \"",
"+",
"field",
".",
"getName",
"(",
")",
")",
";",
"}",
"return",
"(",
"Class",
")",
"genericTypes",
"[",
"0",
"]",
";",
"}",
"else",
"{",
"final",
"Class",
"<",
"?",
">",
"type",
"=",
"field",
".",
"getType",
"(",
")",
";",
"if",
"(",
"type",
"==",
"Byte",
".",
"TYPE",
")",
"return",
"Byte",
".",
"class",
";",
"if",
"(",
"type",
"==",
"Short",
".",
"TYPE",
")",
"return",
"Short",
".",
"class",
";",
"if",
"(",
"type",
"==",
"Integer",
".",
"TYPE",
")",
"return",
"Integer",
".",
"class",
";",
"if",
"(",
"type",
"==",
"Long",
".",
"TYPE",
")",
"return",
"Long",
".",
"class",
";",
"if",
"(",
"type",
"==",
"Float",
".",
"TYPE",
")",
"return",
"Float",
".",
"class",
";",
"if",
"(",
"type",
"==",
"Double",
".",
"TYPE",
")",
"return",
"Double",
".",
"class",
";",
"if",
"(",
"type",
"==",
"Boolean",
".",
"TYPE",
")",
"return",
"Boolean",
".",
"class",
";",
"return",
"type",
";",
"}",
"}"
] |
Returns the type that each instance of the argument needs to be converted to. In
the case of primitive fields it will return the wrapper type so that String
constructors can be found.
|
[
"Returns",
"the",
"type",
"that",
"each",
"instance",
"of",
"the",
"argument",
"needs",
"to",
"be",
"converted",
"to",
".",
"In",
"the",
"case",
"of",
"primitive",
"fields",
"it",
"will",
"return",
"the",
"wrapper",
"type",
"so",
"that",
"String",
"constructors",
"can",
"be",
"found",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/argparser/LegacyCommandLineArgumentParser.java#L902-L924
|
8,754
|
ReactiveX/RxJavaJoins
|
src/main/java/rx/joins/Pattern9.java
|
Pattern9.and
|
public PatternN and(Observable<? extends Object> other) {
if (other == null) {
throw new NullPointerException();
}
List<Observable<? extends Object>> list = new ArrayList<Observable<? extends Object>>();
list.add(o1);
list.add(o2);
list.add(o3);
list.add(o4);
list.add(o5);
list.add(o6);
list.add(o7);
list.add(o8);
list.add(o9);
list.add(other);
return new PatternN(list);
}
|
java
|
public PatternN and(Observable<? extends Object> other) {
if (other == null) {
throw new NullPointerException();
}
List<Observable<? extends Object>> list = new ArrayList<Observable<? extends Object>>();
list.add(o1);
list.add(o2);
list.add(o3);
list.add(o4);
list.add(o5);
list.add(o6);
list.add(o7);
list.add(o8);
list.add(o9);
list.add(other);
return new PatternN(list);
}
|
[
"public",
"PatternN",
"and",
"(",
"Observable",
"<",
"?",
"extends",
"Object",
">",
"other",
")",
"{",
"if",
"(",
"other",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
")",
";",
"}",
"List",
"<",
"Observable",
"<",
"?",
"extends",
"Object",
">",
">",
"list",
"=",
"new",
"ArrayList",
"<",
"Observable",
"<",
"?",
"extends",
"Object",
">",
">",
"(",
")",
";",
"list",
".",
"add",
"(",
"o1",
")",
";",
"list",
".",
"add",
"(",
"o2",
")",
";",
"list",
".",
"add",
"(",
"o3",
")",
";",
"list",
".",
"add",
"(",
"o4",
")",
";",
"list",
".",
"add",
"(",
"o5",
")",
";",
"list",
".",
"add",
"(",
"o6",
")",
";",
"list",
".",
"add",
"(",
"o7",
")",
";",
"list",
".",
"add",
"(",
"o8",
")",
";",
"list",
".",
"add",
"(",
"o9",
")",
";",
"list",
".",
"add",
"(",
"other",
")",
";",
"return",
"new",
"PatternN",
"(",
"list",
")",
";",
"}"
] |
Creates a pattern that matches when all nine observable sequences have an available element.
@param other
Observable sequence to match with the eight previous sequences.
@return Pattern object that matches when all observable sequences have an available element.
|
[
"Creates",
"a",
"pattern",
"that",
"matches",
"when",
"all",
"nine",
"observable",
"sequences",
"have",
"an",
"available",
"element",
"."
] |
65b5c7fa03bd375c9e1f7906d7143068fde9b714
|
https://github.com/ReactiveX/RxJavaJoins/blob/65b5c7fa03bd375c9e1f7906d7143068fde9b714/src/main/java/rx/joins/Pattern9.java#L103-L119
|
8,755
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/argparser/CommandLineArgumentParser.java
|
CommandLineArgumentParser.parseArguments
|
@Override
public boolean parseArguments(final PrintStream messageStream, String[] args) {
final OptionSet parsedArguments;
final OptionParser parser = getOptionParser();
try {
// Preprocess the arguments before the parser sees them, replacing any tagged options
// and their values with raw option names and surrogate key values, so that tagged
// options can be recognized by the parser. The actual values will be retrieved using
// the key when the fields's values are set.
parsedArguments = parser.parse(tagParser.preprocessTaggedOptions(args));
} catch (final OptionException e) {
throw new CommandLineException(e.getMessage());
}
// Check if special short circuiting arguments were set
if (isSpecialFlagSet(parsedArguments, SpecialArgumentsCollection.HELP_FULLNAME)) {
messageStream.print(usage(true, isSpecialFlagSet(parsedArguments, SpecialArgumentsCollection.SHOW_HIDDEN_FULLNAME)));
return false;
} else if (isSpecialFlagSet(parsedArguments, SpecialArgumentsCollection.VERSION_FULLNAME)) {
messageStream.println(getVersion());
return false;
} else if (parsedArguments.has(SpecialArgumentsCollection.ARGUMENTS_FILE_FULLNAME)) {
// If a special arguments file was specified, read arguments from it and recursively call parseArguments()
final List<String> newArgs = expandFromArgumentFile(parsedArguments);
if (!newArgs.isEmpty()) {
// If we've expanded any argument files, we need to do another pass on the entire list post-expansion,
// so clear any tag surrogates created in this pass (they'll be regenerated in the next pass).
tagParser.resetTagSurrogates();
newArgs.addAll(Arrays.asList(args));
return parseArguments(messageStream, newArgs.toArray(new String[newArgs.size()]));
}
}
return propagateParsedValues(parsedArguments);
}
|
java
|
@Override
public boolean parseArguments(final PrintStream messageStream, String[] args) {
final OptionSet parsedArguments;
final OptionParser parser = getOptionParser();
try {
// Preprocess the arguments before the parser sees them, replacing any tagged options
// and their values with raw option names and surrogate key values, so that tagged
// options can be recognized by the parser. The actual values will be retrieved using
// the key when the fields's values are set.
parsedArguments = parser.parse(tagParser.preprocessTaggedOptions(args));
} catch (final OptionException e) {
throw new CommandLineException(e.getMessage());
}
// Check if special short circuiting arguments were set
if (isSpecialFlagSet(parsedArguments, SpecialArgumentsCollection.HELP_FULLNAME)) {
messageStream.print(usage(true, isSpecialFlagSet(parsedArguments, SpecialArgumentsCollection.SHOW_HIDDEN_FULLNAME)));
return false;
} else if (isSpecialFlagSet(parsedArguments, SpecialArgumentsCollection.VERSION_FULLNAME)) {
messageStream.println(getVersion());
return false;
} else if (parsedArguments.has(SpecialArgumentsCollection.ARGUMENTS_FILE_FULLNAME)) {
// If a special arguments file was specified, read arguments from it and recursively call parseArguments()
final List<String> newArgs = expandFromArgumentFile(parsedArguments);
if (!newArgs.isEmpty()) {
// If we've expanded any argument files, we need to do another pass on the entire list post-expansion,
// so clear any tag surrogates created in this pass (they'll be regenerated in the next pass).
tagParser.resetTagSurrogates();
newArgs.addAll(Arrays.asList(args));
return parseArguments(messageStream, newArgs.toArray(new String[newArgs.size()]));
}
}
return propagateParsedValues(parsedArguments);
}
|
[
"@",
"Override",
"public",
"boolean",
"parseArguments",
"(",
"final",
"PrintStream",
"messageStream",
",",
"String",
"[",
"]",
"args",
")",
"{",
"final",
"OptionSet",
"parsedArguments",
";",
"final",
"OptionParser",
"parser",
"=",
"getOptionParser",
"(",
")",
";",
"try",
"{",
"// Preprocess the arguments before the parser sees them, replacing any tagged options",
"// and their values with raw option names and surrogate key values, so that tagged",
"// options can be recognized by the parser. The actual values will be retrieved using",
"// the key when the fields's values are set.",
"parsedArguments",
"=",
"parser",
".",
"parse",
"(",
"tagParser",
".",
"preprocessTaggedOptions",
"(",
"args",
")",
")",
";",
"}",
"catch",
"(",
"final",
"OptionException",
"e",
")",
"{",
"throw",
"new",
"CommandLineException",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"// Check if special short circuiting arguments were set",
"if",
"(",
"isSpecialFlagSet",
"(",
"parsedArguments",
",",
"SpecialArgumentsCollection",
".",
"HELP_FULLNAME",
")",
")",
"{",
"messageStream",
".",
"print",
"(",
"usage",
"(",
"true",
",",
"isSpecialFlagSet",
"(",
"parsedArguments",
",",
"SpecialArgumentsCollection",
".",
"SHOW_HIDDEN_FULLNAME",
")",
")",
")",
";",
"return",
"false",
";",
"}",
"else",
"if",
"(",
"isSpecialFlagSet",
"(",
"parsedArguments",
",",
"SpecialArgumentsCollection",
".",
"VERSION_FULLNAME",
")",
")",
"{",
"messageStream",
".",
"println",
"(",
"getVersion",
"(",
")",
")",
";",
"return",
"false",
";",
"}",
"else",
"if",
"(",
"parsedArguments",
".",
"has",
"(",
"SpecialArgumentsCollection",
".",
"ARGUMENTS_FILE_FULLNAME",
")",
")",
"{",
"// If a special arguments file was specified, read arguments from it and recursively call parseArguments()",
"final",
"List",
"<",
"String",
">",
"newArgs",
"=",
"expandFromArgumentFile",
"(",
"parsedArguments",
")",
";",
"if",
"(",
"!",
"newArgs",
".",
"isEmpty",
"(",
")",
")",
"{",
"// If we've expanded any argument files, we need to do another pass on the entire list post-expansion,",
"// so clear any tag surrogates created in this pass (they'll be regenerated in the next pass).",
"tagParser",
".",
"resetTagSurrogates",
"(",
")",
";",
"newArgs",
".",
"addAll",
"(",
"Arrays",
".",
"asList",
"(",
"args",
")",
")",
";",
"return",
"parseArguments",
"(",
"messageStream",
",",
"newArgs",
".",
"toArray",
"(",
"new",
"String",
"[",
"newArgs",
".",
"size",
"(",
")",
"]",
")",
")",
";",
"}",
"}",
"return",
"propagateParsedValues",
"(",
"parsedArguments",
")",
";",
"}"
] |
Parse command-line arguments, and store values in callerArguments object passed to ctor.
@param messageStream Where to write error messages.
@param args Command line tokens.
@return true if command line is valid and the program should run, false if help or version was requested
@throws CommandLineException if there is an invalid command line
|
[
"Parse",
"command",
"-",
"line",
"arguments",
"and",
"store",
"values",
"in",
"callerArguments",
"object",
"passed",
"to",
"ctor",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/argparser/CommandLineArgumentParser.java#L134-L167
|
8,756
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/argparser/CommandLineArgumentParser.java
|
CommandLineArgumentParser.getPluginDescriptor
|
@Override
public <T> T getPluginDescriptor(final Class<T> targetDescriptor) {
return targetDescriptor.cast(pluginDescriptors.get(targetDescriptor.getName()));
}
|
java
|
@Override
public <T> T getPluginDescriptor(final Class<T> targetDescriptor) {
return targetDescriptor.cast(pluginDescriptors.get(targetDescriptor.getName()));
}
|
[
"@",
"Override",
"public",
"<",
"T",
">",
"T",
"getPluginDescriptor",
"(",
"final",
"Class",
"<",
"T",
">",
"targetDescriptor",
")",
"{",
"return",
"targetDescriptor",
".",
"cast",
"(",
"pluginDescriptors",
".",
"get",
"(",
"targetDescriptor",
".",
"getName",
"(",
")",
")",
")",
";",
"}"
] |
Return the plugin instance corresponding to the targetDescriptor class
|
[
"Return",
"the",
"plugin",
"instance",
"corresponding",
"to",
"the",
"targetDescriptor",
"class"
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/argparser/CommandLineArgumentParser.java#L198-L201
|
8,757
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/argparser/CommandLineArgumentParser.java
|
CommandLineArgumentParser.validateArgumentDefinitions
|
private void validateArgumentDefinitions() {
for (final NamedArgumentDefinition mutexSourceDef : namedArgumentDefinitions) {
for (final String mutexTarget : mutexSourceDef.getMutexTargetList()) {
final NamedArgumentDefinition mutexTargetDef = namedArgumentsDefinitionsByAlias.get(mutexTarget);
if (mutexTargetDef == null) {
throw new CommandLineException.CommandLineParserInternalException(
String.format("Argument '%s' references a nonexistent mutex argument '%s'",
mutexSourceDef.getArgumentAliasDisplayString(),
mutexTarget)
);
} else {
// Add at least one alias for the mutex source to the mutex target to ensure the
// relationship is symmetric for purposes of usage/help doc display.
mutexTargetDef.addMutexTarget(mutexSourceDef.getLongName());
}
}
}
}
|
java
|
private void validateArgumentDefinitions() {
for (final NamedArgumentDefinition mutexSourceDef : namedArgumentDefinitions) {
for (final String mutexTarget : mutexSourceDef.getMutexTargetList()) {
final NamedArgumentDefinition mutexTargetDef = namedArgumentsDefinitionsByAlias.get(mutexTarget);
if (mutexTargetDef == null) {
throw new CommandLineException.CommandLineParserInternalException(
String.format("Argument '%s' references a nonexistent mutex argument '%s'",
mutexSourceDef.getArgumentAliasDisplayString(),
mutexTarget)
);
} else {
// Add at least one alias for the mutex source to the mutex target to ensure the
// relationship is symmetric for purposes of usage/help doc display.
mutexTargetDef.addMutexTarget(mutexSourceDef.getLongName());
}
}
}
}
|
[
"private",
"void",
"validateArgumentDefinitions",
"(",
")",
"{",
"for",
"(",
"final",
"NamedArgumentDefinition",
"mutexSourceDef",
":",
"namedArgumentDefinitions",
")",
"{",
"for",
"(",
"final",
"String",
"mutexTarget",
":",
"mutexSourceDef",
".",
"getMutexTargetList",
"(",
")",
")",
"{",
"final",
"NamedArgumentDefinition",
"mutexTargetDef",
"=",
"namedArgumentsDefinitionsByAlias",
".",
"get",
"(",
"mutexTarget",
")",
";",
"if",
"(",
"mutexTargetDef",
"==",
"null",
")",
"{",
"throw",
"new",
"CommandLineException",
".",
"CommandLineParserInternalException",
"(",
"String",
".",
"format",
"(",
"\"Argument '%s' references a nonexistent mutex argument '%s'\"",
",",
"mutexSourceDef",
".",
"getArgumentAliasDisplayString",
"(",
")",
",",
"mutexTarget",
")",
")",
";",
"}",
"else",
"{",
"// Add at least one alias for the mutex source to the mutex target to ensure the",
"// relationship is symmetric for purposes of usage/help doc display.",
"mutexTargetDef",
".",
"addMutexTarget",
"(",
"mutexSourceDef",
".",
"getLongName",
"(",
")",
")",
";",
"}",
"}",
"}",
"}"
] |
arguments involved.
|
[
"arguments",
"involved",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/argparser/CommandLineArgumentParser.java#L266-L283
|
8,758
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/argparser/CommandLineArgumentParser.java
|
CommandLineArgumentParser.createCommandLinePluginArgumentDefinitions
|
private void createCommandLinePluginArgumentDefinitions(
final List<? extends CommandLinePluginDescriptor<?>> requestedPluginDescriptors)
{
// For each descriptor, create the argument definitions for the descriptor object itself,
// then process it's plugin classes
requestedPluginDescriptors.forEach(
descriptor -> {
pluginDescriptors.put(descriptor.getClass().getName(), descriptor);
createArgumentDefinitions(descriptor, null);
findPluginsForDescriptor(descriptor);
}
);
}
|
java
|
private void createCommandLinePluginArgumentDefinitions(
final List<? extends CommandLinePluginDescriptor<?>> requestedPluginDescriptors)
{
// For each descriptor, create the argument definitions for the descriptor object itself,
// then process it's plugin classes
requestedPluginDescriptors.forEach(
descriptor -> {
pluginDescriptors.put(descriptor.getClass().getName(), descriptor);
createArgumentDefinitions(descriptor, null);
findPluginsForDescriptor(descriptor);
}
);
}
|
[
"private",
"void",
"createCommandLinePluginArgumentDefinitions",
"(",
"final",
"List",
"<",
"?",
"extends",
"CommandLinePluginDescriptor",
"<",
"?",
">",
">",
"requestedPluginDescriptors",
")",
"{",
"// For each descriptor, create the argument definitions for the descriptor object itself,",
"// then process it's plugin classes",
"requestedPluginDescriptors",
".",
"forEach",
"(",
"descriptor",
"->",
"{",
"pluginDescriptors",
".",
"put",
"(",
"descriptor",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
",",
"descriptor",
")",
";",
"createArgumentDefinitions",
"(",
"descriptor",
",",
"null",
")",
";",
"findPluginsForDescriptor",
"(",
"descriptor",
")",
";",
"}",
")",
";",
"}"
] |
Find all the instances of plugins specified by the provided plugin descriptors
|
[
"Find",
"all",
"the",
"instances",
"of",
"plugins",
"specified",
"by",
"the",
"provided",
"plugin",
"descriptors"
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/argparser/CommandLineArgumentParser.java#L347-L359
|
8,759
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/argparser/CommandLineArgumentParser.java
|
CommandLineArgumentParser.findPluginsForDescriptor
|
private void findPluginsForDescriptor(final CommandLinePluginDescriptor<?> pluginDescriptor)
{
final ClassFinder classFinder = new ClassFinder();
pluginDescriptor.getPackageNames().forEach(
pkg -> classFinder.find(pkg, pluginDescriptor.getPluginBaseClass()));
final Set<Class<?>> pluginClasses = classFinder.getClasses();
for (Class<?> c : pluginClasses) {
if (pluginDescriptor.includePluginClass(c)) {
try {
final Object plugin = pluginDescriptor.createInstanceForPlugin(c);
createArgumentDefinitions(plugin, pluginDescriptor);
} catch (InstantiationException | IllegalAccessException e) {
throw new CommandLineException.CommandLineParserInternalException("Problem making an instance of plugin " + c +
" Do check that the class has a non-arg constructor", e);
}
}
}
}
|
java
|
private void findPluginsForDescriptor(final CommandLinePluginDescriptor<?> pluginDescriptor)
{
final ClassFinder classFinder = new ClassFinder();
pluginDescriptor.getPackageNames().forEach(
pkg -> classFinder.find(pkg, pluginDescriptor.getPluginBaseClass()));
final Set<Class<?>> pluginClasses = classFinder.getClasses();
for (Class<?> c : pluginClasses) {
if (pluginDescriptor.includePluginClass(c)) {
try {
final Object plugin = pluginDescriptor.createInstanceForPlugin(c);
createArgumentDefinitions(plugin, pluginDescriptor);
} catch (InstantiationException | IllegalAccessException e) {
throw new CommandLineException.CommandLineParserInternalException("Problem making an instance of plugin " + c +
" Do check that the class has a non-arg constructor", e);
}
}
}
}
|
[
"private",
"void",
"findPluginsForDescriptor",
"(",
"final",
"CommandLinePluginDescriptor",
"<",
"?",
">",
"pluginDescriptor",
")",
"{",
"final",
"ClassFinder",
"classFinder",
"=",
"new",
"ClassFinder",
"(",
")",
";",
"pluginDescriptor",
".",
"getPackageNames",
"(",
")",
".",
"forEach",
"(",
"pkg",
"->",
"classFinder",
".",
"find",
"(",
"pkg",
",",
"pluginDescriptor",
".",
"getPluginBaseClass",
"(",
")",
")",
")",
";",
"final",
"Set",
"<",
"Class",
"<",
"?",
">",
">",
"pluginClasses",
"=",
"classFinder",
".",
"getClasses",
"(",
")",
";",
"for",
"(",
"Class",
"<",
"?",
">",
"c",
":",
"pluginClasses",
")",
"{",
"if",
"(",
"pluginDescriptor",
".",
"includePluginClass",
"(",
"c",
")",
")",
"{",
"try",
"{",
"final",
"Object",
"plugin",
"=",
"pluginDescriptor",
".",
"createInstanceForPlugin",
"(",
"c",
")",
";",
"createArgumentDefinitions",
"(",
"plugin",
",",
"pluginDescriptor",
")",
";",
"}",
"catch",
"(",
"InstantiationException",
"|",
"IllegalAccessException",
"e",
")",
"{",
"throw",
"new",
"CommandLineException",
".",
"CommandLineParserInternalException",
"(",
"\"Problem making an instance of plugin \"",
"+",
"c",
"+",
"\" Do check that the class has a non-arg constructor\"",
",",
"e",
")",
";",
"}",
"}",
"}",
"}"
] |
instance each and add its ArgumentDefinitions
|
[
"instance",
"each",
"and",
"add",
"its",
"ArgumentDefinitions"
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/argparser/CommandLineArgumentParser.java#L363-L381
|
8,760
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/argparser/CommandLineArgumentParser.java
|
CommandLineArgumentParser.isSpecialFlagSet
|
private boolean isSpecialFlagSet(final OptionSet parsedArguments, final String flagName){
if (parsedArguments.has(flagName)){
Object value = parsedArguments.valueOf(flagName);
return (value == null || !value.equals("false"));
} else{
return false;
}
}
|
java
|
private boolean isSpecialFlagSet(final OptionSet parsedArguments, final String flagName){
if (parsedArguments.has(flagName)){
Object value = parsedArguments.valueOf(flagName);
return (value == null || !value.equals("false"));
} else{
return false;
}
}
|
[
"private",
"boolean",
"isSpecialFlagSet",
"(",
"final",
"OptionSet",
"parsedArguments",
",",
"final",
"String",
"flagName",
")",
"{",
"if",
"(",
"parsedArguments",
".",
"has",
"(",
"flagName",
")",
")",
"{",
"Object",
"value",
"=",
"parsedArguments",
".",
"valueOf",
"(",
"flagName",
")",
";",
"return",
"(",
"value",
"==",
"null",
"||",
"!",
"value",
".",
"equals",
"(",
"\"false\"",
")",
")",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
helper to deal with the case of special flags that are evaluated before the options are properly set
|
[
"helper",
"to",
"deal",
"with",
"the",
"case",
"of",
"special",
"flags",
"that",
"are",
"evaluated",
"before",
"the",
"options",
"are",
"properly",
"set"
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/argparser/CommandLineArgumentParser.java#L541-L548
|
8,761
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/argparser/CommandLineArgumentParser.java
|
CommandLineArgumentParser.validatePluginArgumentValues
|
private List<NamedArgumentDefinition> validatePluginArgumentValues() {
final List<NamedArgumentDefinition> actualArgumentDefinitions = new ArrayList<>();
for (final NamedArgumentDefinition argumentDefinition : namedArgumentDefinitions) {
if (!argumentDefinition.isControlledByPlugin()) {
actualArgumentDefinitions.add(argumentDefinition);
} else {
final boolean isAllowed = argumentDefinition.getDescriptorForControllingPlugin().isDependentArgumentAllowed(
argumentDefinition.getContainingObject().getClass());
if (argumentDefinition.getHasBeenSet()) {
if (!isAllowed) {
// dangling dependent argument; a value was specified but it's containing
// (predecessor) plugin argument wasn't specified
throw new CommandLineException(
String.format(
"Argument \"%s/%s\" is only valid when the argument \"%s\" is specified",
argumentDefinition.getShortName(),
argumentDefinition.getLongName(),
argumentDefinition.getContainingObject().getClass().getSimpleName()));
}
actualArgumentDefinitions.add(argumentDefinition);
} else if (isAllowed) {
// the predecessor argument was seen, so this value is allowed but hasn't been set; keep the
// argument definition to allow validation to check for missing required args
actualArgumentDefinitions.add(argumentDefinition);
}
}
}
// finally, give each plugin a chance to trim down any unseen instances from it's own list
pluginDescriptors.entrySet().forEach(e -> e.getValue().validateAndResolvePlugins());
// return the updated list of argument definitions with the new list
return actualArgumentDefinitions;
}
|
java
|
private List<NamedArgumentDefinition> validatePluginArgumentValues() {
final List<NamedArgumentDefinition> actualArgumentDefinitions = new ArrayList<>();
for (final NamedArgumentDefinition argumentDefinition : namedArgumentDefinitions) {
if (!argumentDefinition.isControlledByPlugin()) {
actualArgumentDefinitions.add(argumentDefinition);
} else {
final boolean isAllowed = argumentDefinition.getDescriptorForControllingPlugin().isDependentArgumentAllowed(
argumentDefinition.getContainingObject().getClass());
if (argumentDefinition.getHasBeenSet()) {
if (!isAllowed) {
// dangling dependent argument; a value was specified but it's containing
// (predecessor) plugin argument wasn't specified
throw new CommandLineException(
String.format(
"Argument \"%s/%s\" is only valid when the argument \"%s\" is specified",
argumentDefinition.getShortName(),
argumentDefinition.getLongName(),
argumentDefinition.getContainingObject().getClass().getSimpleName()));
}
actualArgumentDefinitions.add(argumentDefinition);
} else if (isAllowed) {
// the predecessor argument was seen, so this value is allowed but hasn't been set; keep the
// argument definition to allow validation to check for missing required args
actualArgumentDefinitions.add(argumentDefinition);
}
}
}
// finally, give each plugin a chance to trim down any unseen instances from it's own list
pluginDescriptors.entrySet().forEach(e -> e.getValue().validateAndResolvePlugins());
// return the updated list of argument definitions with the new list
return actualArgumentDefinitions;
}
|
[
"private",
"List",
"<",
"NamedArgumentDefinition",
">",
"validatePluginArgumentValues",
"(",
")",
"{",
"final",
"List",
"<",
"NamedArgumentDefinition",
">",
"actualArgumentDefinitions",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"final",
"NamedArgumentDefinition",
"argumentDefinition",
":",
"namedArgumentDefinitions",
")",
"{",
"if",
"(",
"!",
"argumentDefinition",
".",
"isControlledByPlugin",
"(",
")",
")",
"{",
"actualArgumentDefinitions",
".",
"add",
"(",
"argumentDefinition",
")",
";",
"}",
"else",
"{",
"final",
"boolean",
"isAllowed",
"=",
"argumentDefinition",
".",
"getDescriptorForControllingPlugin",
"(",
")",
".",
"isDependentArgumentAllowed",
"(",
"argumentDefinition",
".",
"getContainingObject",
"(",
")",
".",
"getClass",
"(",
")",
")",
";",
"if",
"(",
"argumentDefinition",
".",
"getHasBeenSet",
"(",
")",
")",
"{",
"if",
"(",
"!",
"isAllowed",
")",
"{",
"// dangling dependent argument; a value was specified but it's containing",
"// (predecessor) plugin argument wasn't specified",
"throw",
"new",
"CommandLineException",
"(",
"String",
".",
"format",
"(",
"\"Argument \\\"%s/%s\\\" is only valid when the argument \\\"%s\\\" is specified\"",
",",
"argumentDefinition",
".",
"getShortName",
"(",
")",
",",
"argumentDefinition",
".",
"getLongName",
"(",
")",
",",
"argumentDefinition",
".",
"getContainingObject",
"(",
")",
".",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
")",
")",
";",
"}",
"actualArgumentDefinitions",
".",
"add",
"(",
"argumentDefinition",
")",
";",
"}",
"else",
"if",
"(",
"isAllowed",
")",
"{",
"// the predecessor argument was seen, so this value is allowed but hasn't been set; keep the",
"// argument definition to allow validation to check for missing required args",
"actualArgumentDefinitions",
".",
"add",
"(",
"argumentDefinition",
")",
";",
"}",
"}",
"}",
"// finally, give each plugin a chance to trim down any unseen instances from it's own list",
"pluginDescriptors",
".",
"entrySet",
"(",
")",
".",
"forEach",
"(",
"e",
"->",
"e",
".",
"getValue",
"(",
")",
".",
"validateAndResolvePlugins",
"(",
")",
")",
";",
"// return the updated list of argument definitions with the new list",
"return",
"actualArgumentDefinitions",
";",
"}"
] |
other arguments that require validation.
|
[
"other",
"arguments",
"that",
"require",
"validation",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/argparser/CommandLineArgumentParser.java#L573-L606
|
8,762
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/argparser/CommandLineArgumentParser.java
|
CommandLineArgumentParser.expandFromExpansionFile
|
public List<String> expandFromExpansionFile(
final ArgumentDefinition argumentDefinition,
final String stringValue,
final List<String> originalValuesForPreservation) {
List<String> expandedValues = new ArrayList<>();
if (EXPANSION_FILE_EXTENSIONS.stream().anyMatch(ext -> stringValue.endsWith(ext))) {
// If any value provided for this argument is an expansion file, expand it in place,
// but preserve the original values for subsequent retrieval during command line
// display, since expansion files can result in very large post-expansion command lines
// (its harmless to update this multiple times).
expandedValues.addAll(loadCollectionListFile(stringValue));
argumentDefinition.setOriginalCommandLineValues(originalValuesForPreservation);
} else {
expandedValues.add(stringValue);
}
return expandedValues;
}
|
java
|
public List<String> expandFromExpansionFile(
final ArgumentDefinition argumentDefinition,
final String stringValue,
final List<String> originalValuesForPreservation) {
List<String> expandedValues = new ArrayList<>();
if (EXPANSION_FILE_EXTENSIONS.stream().anyMatch(ext -> stringValue.endsWith(ext))) {
// If any value provided for this argument is an expansion file, expand it in place,
// but preserve the original values for subsequent retrieval during command line
// display, since expansion files can result in very large post-expansion command lines
// (its harmless to update this multiple times).
expandedValues.addAll(loadCollectionListFile(stringValue));
argumentDefinition.setOriginalCommandLineValues(originalValuesForPreservation);
} else {
expandedValues.add(stringValue);
}
return expandedValues;
}
|
[
"public",
"List",
"<",
"String",
">",
"expandFromExpansionFile",
"(",
"final",
"ArgumentDefinition",
"argumentDefinition",
",",
"final",
"String",
"stringValue",
",",
"final",
"List",
"<",
"String",
">",
"originalValuesForPreservation",
")",
"{",
"List",
"<",
"String",
">",
"expandedValues",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"if",
"(",
"EXPANSION_FILE_EXTENSIONS",
".",
"stream",
"(",
")",
".",
"anyMatch",
"(",
"ext",
"->",
"stringValue",
".",
"endsWith",
"(",
"ext",
")",
")",
")",
"{",
"// If any value provided for this argument is an expansion file, expand it in place,",
"// but preserve the original values for subsequent retrieval during command line",
"// display, since expansion files can result in very large post-expansion command lines",
"// (its harmless to update this multiple times).",
"expandedValues",
".",
"addAll",
"(",
"loadCollectionListFile",
"(",
"stringValue",
")",
")",
";",
"argumentDefinition",
".",
"setOriginalCommandLineValues",
"(",
"originalValuesForPreservation",
")",
";",
"}",
"else",
"{",
"expandedValues",
".",
"add",
"(",
"stringValue",
")",
";",
"}",
"return",
"expandedValues",
";",
"}"
] |
Expand any collection value that references a filename that ends in one of the accepted expansion
extensions, and add the contents of the file to the list of values for that argument.
@param argumentDefinition ArgumentDefinition for the arg being populated
@param stringValue the argument value as presented on the command line
@param originalValuesForPreservation list of original values provided on the command line
@return a list containing the original entries in {@code originalValues}, with any
values from list files expanded in place, preserving both the original list order and
the file order
|
[
"Expand",
"any",
"collection",
"value",
"that",
"references",
"a",
"filename",
"that",
"ends",
"in",
"one",
"of",
"the",
"accepted",
"expansion",
"extensions",
"and",
"add",
"the",
"contents",
"of",
"the",
"file",
"to",
"the",
"list",
"of",
"values",
"for",
"that",
"argument",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/argparser/CommandLineArgumentParser.java#L618-L634
|
8,763
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/argparser/CommandLineArgumentParser.java
|
CommandLineArgumentParser.gatherArgumentValuesOfType
|
@Override
public <T> List<Pair<ArgumentDefinition, T>> gatherArgumentValuesOfType( final Class<T> type ) {
final List<Pair<ArgumentDefinition, T>> argumentValues = new ArrayList<>();
// include all named and positional argument definitions
final List<ArgumentDefinition> allArgDefs = new ArrayList<>(namedArgumentDefinitions.size());
allArgDefs.addAll(namedArgumentDefinitions);
if (positionalArgumentDefinition != null) {
allArgDefs.add(positionalArgumentDefinition);
}
for ( final ArgumentDefinition argDef : allArgDefs) {
if ( type.isAssignableFrom(argDef.getUnderlyingFieldClass()) ) {
// Consider only fields that are either of the target type, subtypes of the target type,
// or Collections of the target type or one of its subtypes:
if ( argDef.isCollection() ) {
// Collection arguments are guaranteed by the parsing system to be non-null (at worst, empty)
final Collection<?> argumentContainer = (Collection<?>) argDef.getArgumentValue();
// Emit a Pair with an explicit null value for empty Collection arguments
if (argumentContainer.isEmpty()) {
argumentValues.add(Pair.of(argDef, null));
}
// Unpack non-empty Collections of the target type into individual values,
// each paired with the same Field object.
else {
for (final Object argumentValue : argumentContainer) {
argumentValues.add(Pair.of(argDef, type.cast(argumentValue)));
}
}
}
else {
// Add values for non-Collection arguments of the target type directly
argumentValues.add(Pair.of(argDef, type.cast(argDef.getArgumentValue())));
}
}
}
return argumentValues;
}
|
java
|
@Override
public <T> List<Pair<ArgumentDefinition, T>> gatherArgumentValuesOfType( final Class<T> type ) {
final List<Pair<ArgumentDefinition, T>> argumentValues = new ArrayList<>();
// include all named and positional argument definitions
final List<ArgumentDefinition> allArgDefs = new ArrayList<>(namedArgumentDefinitions.size());
allArgDefs.addAll(namedArgumentDefinitions);
if (positionalArgumentDefinition != null) {
allArgDefs.add(positionalArgumentDefinition);
}
for ( final ArgumentDefinition argDef : allArgDefs) {
if ( type.isAssignableFrom(argDef.getUnderlyingFieldClass()) ) {
// Consider only fields that are either of the target type, subtypes of the target type,
// or Collections of the target type or one of its subtypes:
if ( argDef.isCollection() ) {
// Collection arguments are guaranteed by the parsing system to be non-null (at worst, empty)
final Collection<?> argumentContainer = (Collection<?>) argDef.getArgumentValue();
// Emit a Pair with an explicit null value for empty Collection arguments
if (argumentContainer.isEmpty()) {
argumentValues.add(Pair.of(argDef, null));
}
// Unpack non-empty Collections of the target type into individual values,
// each paired with the same Field object.
else {
for (final Object argumentValue : argumentContainer) {
argumentValues.add(Pair.of(argDef, type.cast(argumentValue)));
}
}
}
else {
// Add values for non-Collection arguments of the target type directly
argumentValues.add(Pair.of(argDef, type.cast(argDef.getArgumentValue())));
}
}
}
return argumentValues;
}
|
[
"@",
"Override",
"public",
"<",
"T",
">",
"List",
"<",
"Pair",
"<",
"ArgumentDefinition",
",",
"T",
">",
">",
"gatherArgumentValuesOfType",
"(",
"final",
"Class",
"<",
"T",
">",
"type",
")",
"{",
"final",
"List",
"<",
"Pair",
"<",
"ArgumentDefinition",
",",
"T",
">",
">",
"argumentValues",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"// include all named and positional argument definitions",
"final",
"List",
"<",
"ArgumentDefinition",
">",
"allArgDefs",
"=",
"new",
"ArrayList",
"<>",
"(",
"namedArgumentDefinitions",
".",
"size",
"(",
")",
")",
";",
"allArgDefs",
".",
"addAll",
"(",
"namedArgumentDefinitions",
")",
";",
"if",
"(",
"positionalArgumentDefinition",
"!=",
"null",
")",
"{",
"allArgDefs",
".",
"add",
"(",
"positionalArgumentDefinition",
")",
";",
"}",
"for",
"(",
"final",
"ArgumentDefinition",
"argDef",
":",
"allArgDefs",
")",
"{",
"if",
"(",
"type",
".",
"isAssignableFrom",
"(",
"argDef",
".",
"getUnderlyingFieldClass",
"(",
")",
")",
")",
"{",
"// Consider only fields that are either of the target type, subtypes of the target type,",
"// or Collections of the target type or one of its subtypes:",
"if",
"(",
"argDef",
".",
"isCollection",
"(",
")",
")",
"{",
"// Collection arguments are guaranteed by the parsing system to be non-null (at worst, empty)",
"final",
"Collection",
"<",
"?",
">",
"argumentContainer",
"=",
"(",
"Collection",
"<",
"?",
">",
")",
"argDef",
".",
"getArgumentValue",
"(",
")",
";",
"// Emit a Pair with an explicit null value for empty Collection arguments",
"if",
"(",
"argumentContainer",
".",
"isEmpty",
"(",
")",
")",
"{",
"argumentValues",
".",
"add",
"(",
"Pair",
".",
"of",
"(",
"argDef",
",",
"null",
")",
")",
";",
"}",
"// Unpack non-empty Collections of the target type into individual values,",
"// each paired with the same Field object.",
"else",
"{",
"for",
"(",
"final",
"Object",
"argumentValue",
":",
"argumentContainer",
")",
"{",
"argumentValues",
".",
"add",
"(",
"Pair",
".",
"of",
"(",
"argDef",
",",
"type",
".",
"cast",
"(",
"argumentValue",
")",
")",
")",
";",
"}",
"}",
"}",
"else",
"{",
"// Add values for non-Collection arguments of the target type directly",
"argumentValues",
".",
"add",
"(",
"Pair",
".",
"of",
"(",
"argDef",
",",
"type",
".",
"cast",
"(",
"argDef",
".",
"getArgumentValue",
"(",
")",
")",
")",
")",
";",
"}",
"}",
"}",
"return",
"argumentValues",
";",
"}"
] |
Locates and returns the VALUES of all Argument-annotated fields of a specified type in a given object,
pairing each field value with its corresponding Field object.
Must be called AFTER argument parsing and value injection into argumentSource is complete (otherwise there
will be no values to gather!).
Locates Argument-annotated fields of the target type, subtypes of the target type, and Collections of
the target type or one of its subtypes. Unpacks Collection fields, returning a separate Pair for each
value in each Collection.
Searches argumentSource itself, as well as ancestor classes, and also recurses into any ArgumentCollections
found.
Will return Pairs containing a null second element for fields having no value, including empty Collection fields
(these represent arguments of the target type that were not specified on the command line and so never initialized).
@param type Target type. Search for Argument-annotated fields that are either of this type, subtypes of this type, or Collections of this type or one of its subtypes.
@param <T> Type parameter representing the type to search for and return
@return A List of Pairs containing all Argument-annotated field values found of the target type. First element in each Pair
is the ArgumentDefinition object, and the second element is the actual value of the argument field. The second
element will be null for uninitialized fields.
|
[
"Locates",
"and",
"returns",
"the",
"VALUES",
"of",
"all",
"Argument",
"-",
"annotated",
"fields",
"of",
"a",
"specified",
"type",
"in",
"a",
"given",
"object",
"pairing",
"each",
"field",
"value",
"with",
"its",
"corresponding",
"Field",
"object",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/argparser/CommandLineArgumentParser.java#L729-L769
|
8,764
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/argparser/ClassFinder.java
|
ClassFinder.scanDir
|
protected void scanDir(final File file, final String path) {
for ( final File child: file.listFiles() ) {
final String newPath = (path==null ? child.getName() : path + '/' + child.getName() );
if ( child.isDirectory() ) {
scanDir(child, newPath);
}
else {
handleItem(newPath);
}
}
}
|
java
|
protected void scanDir(final File file, final String path) {
for ( final File child: file.listFiles() ) {
final String newPath = (path==null ? child.getName() : path + '/' + child.getName() );
if ( child.isDirectory() ) {
scanDir(child, newPath);
}
else {
handleItem(newPath);
}
}
}
|
[
"protected",
"void",
"scanDir",
"(",
"final",
"File",
"file",
",",
"final",
"String",
"path",
")",
"{",
"for",
"(",
"final",
"File",
"child",
":",
"file",
".",
"listFiles",
"(",
")",
")",
"{",
"final",
"String",
"newPath",
"=",
"(",
"path",
"==",
"null",
"?",
"child",
".",
"getName",
"(",
")",
":",
"path",
"+",
"'",
"'",
"+",
"child",
".",
"getName",
"(",
")",
")",
";",
"if",
"(",
"child",
".",
"isDirectory",
"(",
")",
")",
"{",
"scanDir",
"(",
"child",
",",
"newPath",
")",
";",
"}",
"else",
"{",
"handleItem",
"(",
"newPath",
")",
";",
"}",
"}",
"}"
] |
Scans a directory on the filesystem for classes.
@param file the directory or file to examine
@param path the package path acculmulated so far (e.g. edu/mit/broad)
|
[
"Scans",
"a",
"directory",
"on",
"the",
"filesystem",
"for",
"classes",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/argparser/ClassFinder.java#L124-L134
|
8,765
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/argparser/ClassFinder.java
|
ClassFinder.handleItem
|
protected void handleItem(final String name) {
if (name.endsWith(".class")) {
final String classname = toClassName(name);
try {
final Class<?> type = loader.loadClass(classname);
if (parentType.isAssignableFrom(type)) {
this.classes.add(type);
}
}
catch (Throwable t) {
log.debug("could not load class: " + classname, t);
}
}
}
|
java
|
protected void handleItem(final String name) {
if (name.endsWith(".class")) {
final String classname = toClassName(name);
try {
final Class<?> type = loader.loadClass(classname);
if (parentType.isAssignableFrom(type)) {
this.classes.add(type);
}
}
catch (Throwable t) {
log.debug("could not load class: " + classname, t);
}
}
}
|
[
"protected",
"void",
"handleItem",
"(",
"final",
"String",
"name",
")",
"{",
"if",
"(",
"name",
".",
"endsWith",
"(",
"\".class\"",
")",
")",
"{",
"final",
"String",
"classname",
"=",
"toClassName",
"(",
"name",
")",
";",
"try",
"{",
"final",
"Class",
"<",
"?",
">",
"type",
"=",
"loader",
".",
"loadClass",
"(",
"classname",
")",
";",
"if",
"(",
"parentType",
".",
"isAssignableFrom",
"(",
"type",
")",
")",
"{",
"this",
".",
"classes",
".",
"add",
"(",
"type",
")",
";",
"}",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"log",
".",
"debug",
"(",
"\"could not load class: \"",
"+",
"classname",
",",
"t",
")",
";",
"}",
"}",
"}"
] |
Checks an item to see if it is a class and is annotated with the specified
annotation. If so, adds it to the set, otherwise ignores it.
@param name the path equivelant to the package + class/item name
|
[
"Checks",
"an",
"item",
"to",
"see",
"if",
"it",
"is",
"a",
"class",
"and",
"is",
"annotated",
"with",
"the",
"specified",
"annotation",
".",
"If",
"so",
"adds",
"it",
"to",
"the",
"set",
"otherwise",
"ignores",
"it",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/argparser/ClassFinder.java#L141-L155
|
8,766
|
ReactiveX/RxJavaJoins
|
src/main/java/rx/joins/operators/OperatorJoinPatterns.java
|
OperatorJoinPatterns.and
|
public static <T1, T2> Pattern2<T1, T2> and(/* this */Observable<T1> left, Observable<T2> right) {
if (left == null) {
throw new NullPointerException("left");
}
if (right == null) {
throw new NullPointerException("right");
}
return new Pattern2<T1, T2>(left, right);
}
|
java
|
public static <T1, T2> Pattern2<T1, T2> and(/* this */Observable<T1> left, Observable<T2> right) {
if (left == null) {
throw new NullPointerException("left");
}
if (right == null) {
throw new NullPointerException("right");
}
return new Pattern2<T1, T2>(left, right);
}
|
[
"public",
"static",
"<",
"T1",
",",
"T2",
">",
"Pattern2",
"<",
"T1",
",",
"T2",
">",
"and",
"(",
"/* this */",
"Observable",
"<",
"T1",
">",
"left",
",",
"Observable",
"<",
"T2",
">",
"right",
")",
"{",
"if",
"(",
"left",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"left\"",
")",
";",
"}",
"if",
"(",
"right",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"right\"",
")",
";",
"}",
"return",
"new",
"Pattern2",
"<",
"T1",
",",
"T2",
">",
"(",
"left",
",",
"right",
")",
";",
"}"
] |
Creates a pattern that matches when both observable sequences have an available element.
|
[
"Creates",
"a",
"pattern",
"that",
"matches",
"when",
"both",
"observable",
"sequences",
"have",
"an",
"available",
"element",
"."
] |
65b5c7fa03bd375c9e1f7906d7143068fde9b714
|
https://github.com/ReactiveX/RxJavaJoins/blob/65b5c7fa03bd375c9e1f7906d7143068fde9b714/src/main/java/rx/joins/operators/OperatorJoinPatterns.java#L45-L53
|
8,767
|
ReactiveX/RxJavaJoins
|
src/main/java/rx/joins/operators/OperatorJoinPatterns.java
|
OperatorJoinPatterns.then
|
public static <T1, R> Plan0<R> then(/* this */Observable<T1> source, Func1<T1, R> selector) {
if (source == null) {
throw new NullPointerException("source");
}
if (selector == null) {
throw new NullPointerException("selector");
}
return new Pattern1<T1>(source).then(selector);
}
|
java
|
public static <T1, R> Plan0<R> then(/* this */Observable<T1> source, Func1<T1, R> selector) {
if (source == null) {
throw new NullPointerException("source");
}
if (selector == null) {
throw new NullPointerException("selector");
}
return new Pattern1<T1>(source).then(selector);
}
|
[
"public",
"static",
"<",
"T1",
",",
"R",
">",
"Plan0",
"<",
"R",
">",
"then",
"(",
"/* this */",
"Observable",
"<",
"T1",
">",
"source",
",",
"Func1",
"<",
"T1",
",",
"R",
">",
"selector",
")",
"{",
"if",
"(",
"source",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"source\"",
")",
";",
"}",
"if",
"(",
"selector",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"selector\"",
")",
";",
"}",
"return",
"new",
"Pattern1",
"<",
"T1",
">",
"(",
"source",
")",
".",
"then",
"(",
"selector",
")",
";",
"}"
] |
Matches when the observable sequence has an available element and projects the element by invoking the selector function.
|
[
"Matches",
"when",
"the",
"observable",
"sequence",
"has",
"an",
"available",
"element",
"and",
"projects",
"the",
"element",
"by",
"invoking",
"the",
"selector",
"function",
"."
] |
65b5c7fa03bd375c9e1f7906d7143068fde9b714
|
https://github.com/ReactiveX/RxJavaJoins/blob/65b5c7fa03bd375c9e1f7906d7143068fde9b714/src/main/java/rx/joins/operators/OperatorJoinPatterns.java#L58-L66
|
8,768
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/argparser/NamedArgumentDefinition.java
|
NamedArgumentDefinition.getArgumentAliases
|
public List<String> getArgumentAliases() {
final List<String> aliases = new ArrayList<>();
if (!getShortName().isEmpty()) {
aliases.add(getShortName());
}
if (!getFullName().isEmpty()) {
aliases.add(getFullName());
} else {
aliases.add(getUnderlyingField().getName());
}
return aliases;
}
|
java
|
public List<String> getArgumentAliases() {
final List<String> aliases = new ArrayList<>();
if (!getShortName().isEmpty()) {
aliases.add(getShortName());
}
if (!getFullName().isEmpty()) {
aliases.add(getFullName());
} else {
aliases.add(getUnderlyingField().getName());
}
return aliases;
}
|
[
"public",
"List",
"<",
"String",
">",
"getArgumentAliases",
"(",
")",
"{",
"final",
"List",
"<",
"String",
">",
"aliases",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"if",
"(",
"!",
"getShortName",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"aliases",
".",
"add",
"(",
"getShortName",
"(",
")",
")",
";",
"}",
"if",
"(",
"!",
"getFullName",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"aliases",
".",
"add",
"(",
"getFullName",
"(",
")",
")",
";",
"}",
"else",
"{",
"aliases",
".",
"add",
"(",
"getUnderlyingField",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"}",
"return",
"aliases",
";",
"}"
] |
Get the list of short and long aliases for this argument.
@return The list of possible aliases for this argument. Will not be null or empty, and contain only
1 or 2 values. the names are drawn from the fullName, shortName, and {@code Field} name for this argument.
|
[
"Get",
"the",
"list",
"of",
"short",
"and",
"long",
"aliases",
"for",
"this",
"argument",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/argparser/NamedArgumentDefinition.java#L252-L263
|
8,769
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/argparser/NamedArgumentDefinition.java
|
NamedArgumentDefinition.setCollectionValues
|
@SuppressWarnings({"rawtypes", "unchecked"})
private void setCollectionValues(
final CommandLineArgumentParser commandLineArgumentParser,
final List<String> preprocessedValues) // Note that some of these might be tag surrogates
{
final Collection c = (Collection) getArgumentValue();
if (!commandLineArgumentParser.getAppendToCollectionsParserOption()) {
// if this is a collection then we only want to clear it once at the beginning, before we
// process any of the values, unless we're in APPEND_TO_COLLECTIONS mode
c.clear();
}
for (int i = 0; i < preprocessedValues.size(); i++) {
final String stringValue = preprocessedValues.get(i);
if (stringValue.equals(NULL_ARGUMENT_STRING)) {
if (i != 0) {
// if a "null" is included that isn't the first value for this option, honor it but warn, since it
// will clobber any previously set values, and may indicate an unintentional error on the user's part
logger.warn(String.format(
"A \"null\" value was detected for an option after values for that option were already set. " +
"Clobbering previously set values for this option: %s.", getArgumentAliasDisplayString()));
}
if (!isOptional()) {
throw new CommandLineException(
String.format("Non \"null\" value must be provided for '%s'", getArgumentAliasDisplayString()));
}
c.clear();
} else {
// if a collection argument was presented as a tagged argument on the command line, and an expansion
// file was provided as the value, propagate the tags to each value from the expansion file
final Pair<String, String> normalizedSurrogatePair = getNormalizedTagValuePair(commandLineArgumentParser, stringValue);
final List<String> expandedValues = argumentAnnotation.suppressFileExpansion() ?
Collections.singletonList(normalizedSurrogatePair.getRight()) :
commandLineArgumentParser.expandFromExpansionFile(
this,
normalizedSurrogatePair.getRight(),
preprocessedValues);
for (final String expandedValue : expandedValues) {
final Object actualValue = getValuePopulatedWithTags(
normalizedSurrogatePair.getLeft(),
expandedValue);
checkArgumentRange(actualValue);
c.add(actualValue);
}
}
}
}
|
java
|
@SuppressWarnings({"rawtypes", "unchecked"})
private void setCollectionValues(
final CommandLineArgumentParser commandLineArgumentParser,
final List<String> preprocessedValues) // Note that some of these might be tag surrogates
{
final Collection c = (Collection) getArgumentValue();
if (!commandLineArgumentParser.getAppendToCollectionsParserOption()) {
// if this is a collection then we only want to clear it once at the beginning, before we
// process any of the values, unless we're in APPEND_TO_COLLECTIONS mode
c.clear();
}
for (int i = 0; i < preprocessedValues.size(); i++) {
final String stringValue = preprocessedValues.get(i);
if (stringValue.equals(NULL_ARGUMENT_STRING)) {
if (i != 0) {
// if a "null" is included that isn't the first value for this option, honor it but warn, since it
// will clobber any previously set values, and may indicate an unintentional error on the user's part
logger.warn(String.format(
"A \"null\" value was detected for an option after values for that option were already set. " +
"Clobbering previously set values for this option: %s.", getArgumentAliasDisplayString()));
}
if (!isOptional()) {
throw new CommandLineException(
String.format("Non \"null\" value must be provided for '%s'", getArgumentAliasDisplayString()));
}
c.clear();
} else {
// if a collection argument was presented as a tagged argument on the command line, and an expansion
// file was provided as the value, propagate the tags to each value from the expansion file
final Pair<String, String> normalizedSurrogatePair = getNormalizedTagValuePair(commandLineArgumentParser, stringValue);
final List<String> expandedValues = argumentAnnotation.suppressFileExpansion() ?
Collections.singletonList(normalizedSurrogatePair.getRight()) :
commandLineArgumentParser.expandFromExpansionFile(
this,
normalizedSurrogatePair.getRight(),
preprocessedValues);
for (final String expandedValue : expandedValues) {
final Object actualValue = getValuePopulatedWithTags(
normalizedSurrogatePair.getLeft(),
expandedValue);
checkArgumentRange(actualValue);
c.add(actualValue);
}
}
}
}
|
[
"@",
"SuppressWarnings",
"(",
"{",
"\"rawtypes\"",
",",
"\"unchecked\"",
"}",
")",
"private",
"void",
"setCollectionValues",
"(",
"final",
"CommandLineArgumentParser",
"commandLineArgumentParser",
",",
"final",
"List",
"<",
"String",
">",
"preprocessedValues",
")",
"// Note that some of these might be tag surrogates",
"{",
"final",
"Collection",
"c",
"=",
"(",
"Collection",
")",
"getArgumentValue",
"(",
")",
";",
"if",
"(",
"!",
"commandLineArgumentParser",
".",
"getAppendToCollectionsParserOption",
"(",
")",
")",
"{",
"// if this is a collection then we only want to clear it once at the beginning, before we",
"// process any of the values, unless we're in APPEND_TO_COLLECTIONS mode",
"c",
".",
"clear",
"(",
")",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"preprocessedValues",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"final",
"String",
"stringValue",
"=",
"preprocessedValues",
".",
"get",
"(",
"i",
")",
";",
"if",
"(",
"stringValue",
".",
"equals",
"(",
"NULL_ARGUMENT_STRING",
")",
")",
"{",
"if",
"(",
"i",
"!=",
"0",
")",
"{",
"// if a \"null\" is included that isn't the first value for this option, honor it but warn, since it",
"// will clobber any previously set values, and may indicate an unintentional error on the user's part",
"logger",
".",
"warn",
"(",
"String",
".",
"format",
"(",
"\"A \\\"null\\\" value was detected for an option after values for that option were already set. \"",
"+",
"\"Clobbering previously set values for this option: %s.\"",
",",
"getArgumentAliasDisplayString",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"!",
"isOptional",
"(",
")",
")",
"{",
"throw",
"new",
"CommandLineException",
"(",
"String",
".",
"format",
"(",
"\"Non \\\"null\\\" value must be provided for '%s'\"",
",",
"getArgumentAliasDisplayString",
"(",
")",
")",
")",
";",
"}",
"c",
".",
"clear",
"(",
")",
";",
"}",
"else",
"{",
"// if a collection argument was presented as a tagged argument on the command line, and an expansion",
"// file was provided as the value, propagate the tags to each value from the expansion file",
"final",
"Pair",
"<",
"String",
",",
"String",
">",
"normalizedSurrogatePair",
"=",
"getNormalizedTagValuePair",
"(",
"commandLineArgumentParser",
",",
"stringValue",
")",
";",
"final",
"List",
"<",
"String",
">",
"expandedValues",
"=",
"argumentAnnotation",
".",
"suppressFileExpansion",
"(",
")",
"?",
"Collections",
".",
"singletonList",
"(",
"normalizedSurrogatePair",
".",
"getRight",
"(",
")",
")",
":",
"commandLineArgumentParser",
".",
"expandFromExpansionFile",
"(",
"this",
",",
"normalizedSurrogatePair",
".",
"getRight",
"(",
")",
",",
"preprocessedValues",
")",
";",
"for",
"(",
"final",
"String",
"expandedValue",
":",
"expandedValues",
")",
"{",
"final",
"Object",
"actualValue",
"=",
"getValuePopulatedWithTags",
"(",
"normalizedSurrogatePair",
".",
"getLeft",
"(",
")",
",",
"expandedValue",
")",
";",
"checkArgumentRange",
"(",
"actualValue",
")",
";",
"c",
".",
"add",
"(",
"actualValue",
")",
";",
"}",
"}",
"}",
"}"
] |
surrogate, each instance added to the collection must be populated with any tags and attributes.
|
[
"surrogate",
"each",
"instance",
"added",
"to",
"the",
"collection",
"must",
"be",
"populated",
"with",
"any",
"tags",
"and",
"attributes",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/argparser/NamedArgumentDefinition.java#L298-L345
|
8,770
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/argparser/NamedArgumentDefinition.java
|
NamedArgumentDefinition.setScalarValue
|
private void setScalarValue(
final CommandLineArgumentParser commandLineArgumentParser,
final List<String> originalValues) // Note that these might be tag surrogates
{
if (getHasBeenSet() || originalValues.size() > 1) {
throw new CommandLineException.BadArgumentValue(
String.format("Argument '%s' cannot be specified more than once.", getArgumentAliasDisplayString()));
}
if (isFlag() && originalValues.isEmpty()){
setArgumentValue(true);
} else {
final String stringValue = originalValues.get(0);
Object value = null;
if (stringValue.equals(NULL_ARGUMENT_STRING)) {
if (getUnderlyingField().getType().isPrimitive()) {
throw new CommandLineException.BadArgumentValue(
String.format("Argument '%s' is not a nullable argument type.", getArgumentAliasDisplayString()));
}
} else {
final Pair<String, String> normalizedSurrogatePair = getNormalizedTagValuePair(commandLineArgumentParser, stringValue);
value = getValuePopulatedWithTags(normalizedSurrogatePair.getLeft(), normalizedSurrogatePair.getRight());
}
checkArgumentRange(value);
setArgumentValue(value);
}
}
|
java
|
private void setScalarValue(
final CommandLineArgumentParser commandLineArgumentParser,
final List<String> originalValues) // Note that these might be tag surrogates
{
if (getHasBeenSet() || originalValues.size() > 1) {
throw new CommandLineException.BadArgumentValue(
String.format("Argument '%s' cannot be specified more than once.", getArgumentAliasDisplayString()));
}
if (isFlag() && originalValues.isEmpty()){
setArgumentValue(true);
} else {
final String stringValue = originalValues.get(0);
Object value = null;
if (stringValue.equals(NULL_ARGUMENT_STRING)) {
if (getUnderlyingField().getType().isPrimitive()) {
throw new CommandLineException.BadArgumentValue(
String.format("Argument '%s' is not a nullable argument type.", getArgumentAliasDisplayString()));
}
} else {
final Pair<String, String> normalizedSurrogatePair = getNormalizedTagValuePair(commandLineArgumentParser, stringValue);
value = getValuePopulatedWithTags(normalizedSurrogatePair.getLeft(), normalizedSurrogatePair.getRight());
}
checkArgumentRange(value);
setArgumentValue(value);
}
}
|
[
"private",
"void",
"setScalarValue",
"(",
"final",
"CommandLineArgumentParser",
"commandLineArgumentParser",
",",
"final",
"List",
"<",
"String",
">",
"originalValues",
")",
"// Note that these might be tag surrogates",
"{",
"if",
"(",
"getHasBeenSet",
"(",
")",
"||",
"originalValues",
".",
"size",
"(",
")",
">",
"1",
")",
"{",
"throw",
"new",
"CommandLineException",
".",
"BadArgumentValue",
"(",
"String",
".",
"format",
"(",
"\"Argument '%s' cannot be specified more than once.\"",
",",
"getArgumentAliasDisplayString",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"isFlag",
"(",
")",
"&&",
"originalValues",
".",
"isEmpty",
"(",
")",
")",
"{",
"setArgumentValue",
"(",
"true",
")",
";",
"}",
"else",
"{",
"final",
"String",
"stringValue",
"=",
"originalValues",
".",
"get",
"(",
"0",
")",
";",
"Object",
"value",
"=",
"null",
";",
"if",
"(",
"stringValue",
".",
"equals",
"(",
"NULL_ARGUMENT_STRING",
")",
")",
"{",
"if",
"(",
"getUnderlyingField",
"(",
")",
".",
"getType",
"(",
")",
".",
"isPrimitive",
"(",
")",
")",
"{",
"throw",
"new",
"CommandLineException",
".",
"BadArgumentValue",
"(",
"String",
".",
"format",
"(",
"\"Argument '%s' is not a nullable argument type.\"",
",",
"getArgumentAliasDisplayString",
"(",
")",
")",
")",
";",
"}",
"}",
"else",
"{",
"final",
"Pair",
"<",
"String",
",",
"String",
">",
"normalizedSurrogatePair",
"=",
"getNormalizedTagValuePair",
"(",
"commandLineArgumentParser",
",",
"stringValue",
")",
";",
"value",
"=",
"getValuePopulatedWithTags",
"(",
"normalizedSurrogatePair",
".",
"getLeft",
"(",
")",
",",
"normalizedSurrogatePair",
".",
"getRight",
"(",
")",
")",
";",
"}",
"checkArgumentRange",
"(",
"value",
")",
";",
"setArgumentValue",
"(",
"value",
")",
";",
"}",
"}"
] |
one value, in which case we throw.
|
[
"one",
"value",
"in",
"which",
"case",
"we",
"throw",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/argparser/NamedArgumentDefinition.java#L351-L377
|
8,771
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/argparser/NamedArgumentDefinition.java
|
NamedArgumentDefinition.getArgumentUsage
|
public String getArgumentUsage(
final Map<String, NamedArgumentDefinition> allActualArguments,
final Collection<CommandLinePluginDescriptor<?>> pluginDescriptors,
final int argumentColumnWidth,
final int descriptionColumnWidth) {
final StringBuilder sb = new StringBuilder();
sb.append("--").append(getLongName());
if (!getShortName().isEmpty()) {
sb.append(",-").append(getShortName());
}
sb.append(":").append(getUnderlyingFieldClass().getSimpleName());
int labelLength = sb.toString().length();
int numSpaces = argumentColumnWidth - labelLength;
if (labelLength > argumentColumnWidth) {
sb.append("\n");
numSpaces = argumentColumnWidth;
}
printSpaces(sb, numSpaces);
final String description = getArgumentDescription(allActualArguments, pluginDescriptors);
final String wrappedDescription = Utils.wrapParagraph(description, descriptionColumnWidth);
final String[] descriptionLines = wrappedDescription.split("\n");
for (int i = 0; i < descriptionLines.length; ++i) {
if (i > 0) {
printSpaces(sb, argumentColumnWidth);
}
sb.append(descriptionLines[i]);
sb.append("\n");
}
sb.append("\n");
return sb.toString();
}
|
java
|
public String getArgumentUsage(
final Map<String, NamedArgumentDefinition> allActualArguments,
final Collection<CommandLinePluginDescriptor<?>> pluginDescriptors,
final int argumentColumnWidth,
final int descriptionColumnWidth) {
final StringBuilder sb = new StringBuilder();
sb.append("--").append(getLongName());
if (!getShortName().isEmpty()) {
sb.append(",-").append(getShortName());
}
sb.append(":").append(getUnderlyingFieldClass().getSimpleName());
int labelLength = sb.toString().length();
int numSpaces = argumentColumnWidth - labelLength;
if (labelLength > argumentColumnWidth) {
sb.append("\n");
numSpaces = argumentColumnWidth;
}
printSpaces(sb, numSpaces);
final String description = getArgumentDescription(allActualArguments, pluginDescriptors);
final String wrappedDescription = Utils.wrapParagraph(description, descriptionColumnWidth);
final String[] descriptionLines = wrappedDescription.split("\n");
for (int i = 0; i < descriptionLines.length; ++i) {
if (i > 0) {
printSpaces(sb, argumentColumnWidth);
}
sb.append(descriptionLines[i]);
sb.append("\n");
}
sb.append("\n");
return sb.toString();
}
|
[
"public",
"String",
"getArgumentUsage",
"(",
"final",
"Map",
"<",
"String",
",",
"NamedArgumentDefinition",
">",
"allActualArguments",
",",
"final",
"Collection",
"<",
"CommandLinePluginDescriptor",
"<",
"?",
">",
">",
"pluginDescriptors",
",",
"final",
"int",
"argumentColumnWidth",
",",
"final",
"int",
"descriptionColumnWidth",
")",
"{",
"final",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"sb",
".",
"append",
"(",
"\"--\"",
")",
".",
"append",
"(",
"getLongName",
"(",
")",
")",
";",
"if",
"(",
"!",
"getShortName",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"sb",
".",
"append",
"(",
"\",-\"",
")",
".",
"append",
"(",
"getShortName",
"(",
")",
")",
";",
"}",
"sb",
".",
"append",
"(",
"\":\"",
")",
".",
"append",
"(",
"getUnderlyingFieldClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
")",
";",
"int",
"labelLength",
"=",
"sb",
".",
"toString",
"(",
")",
".",
"length",
"(",
")",
";",
"int",
"numSpaces",
"=",
"argumentColumnWidth",
"-",
"labelLength",
";",
"if",
"(",
"labelLength",
">",
"argumentColumnWidth",
")",
"{",
"sb",
".",
"append",
"(",
"\"\\n\"",
")",
";",
"numSpaces",
"=",
"argumentColumnWidth",
";",
"}",
"printSpaces",
"(",
"sb",
",",
"numSpaces",
")",
";",
"final",
"String",
"description",
"=",
"getArgumentDescription",
"(",
"allActualArguments",
",",
"pluginDescriptors",
")",
";",
"final",
"String",
"wrappedDescription",
"=",
"Utils",
".",
"wrapParagraph",
"(",
"description",
",",
"descriptionColumnWidth",
")",
";",
"final",
"String",
"[",
"]",
"descriptionLines",
"=",
"wrappedDescription",
".",
"split",
"(",
"\"\\n\"",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"descriptionLines",
".",
"length",
";",
"++",
"i",
")",
"{",
"if",
"(",
"i",
">",
"0",
")",
"{",
"printSpaces",
"(",
"sb",
",",
"argumentColumnWidth",
")",
";",
"}",
"sb",
".",
"append",
"(",
"descriptionLines",
"[",
"i",
"]",
")",
";",
"sb",
".",
"append",
"(",
"\"\\n\"",
")",
";",
"}",
"sb",
".",
"append",
"(",
"\"\\n\"",
")",
";",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] |
Return a string with the usage statement for this argument.
@param allActualArguments {code Map} of all namedArgumentDefinitions for the containing object
@param pluginDescriptors Collection of {@code CommandLinePluginDescriptor} objects for the containing object
@param argumentColumnWidth width reserved for argument name column display
@param descriptionColumnWidth width reserved for argument description column display
@return the usage string for this argument
|
[
"Return",
"a",
"string",
"with",
"the",
"usage",
"statement",
"for",
"this",
"argument",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/argparser/NamedArgumentDefinition.java#L429-L463
|
8,772
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/argparser/NamedArgumentDefinition.java
|
NamedArgumentDefinition.getNameValuePairForDisplay
|
private String getNameValuePairForDisplay(final Object value) {
if (value != null) {
if (argumentAnnotation.sensitive()) {
return String.format("--%s ***********", getLongName());
} else {
// if we're displaying a tagged argument, include the tag name and attributes
if (value instanceof TaggedArgument) {
return String.format("--%s %s", TaggedArgumentParser.getDisplayString(getLongName(), (TaggedArgument) value), value);
} else {
return String.format("--%s %s", getLongName(), value);
}
}
}
return "";
}
|
java
|
private String getNameValuePairForDisplay(final Object value) {
if (value != null) {
if (argumentAnnotation.sensitive()) {
return String.format("--%s ***********", getLongName());
} else {
// if we're displaying a tagged argument, include the tag name and attributes
if (value instanceof TaggedArgument) {
return String.format("--%s %s", TaggedArgumentParser.getDisplayString(getLongName(), (TaggedArgument) value), value);
} else {
return String.format("--%s %s", getLongName(), value);
}
}
}
return "";
}
|
[
"private",
"String",
"getNameValuePairForDisplay",
"(",
"final",
"Object",
"value",
")",
"{",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"if",
"(",
"argumentAnnotation",
".",
"sensitive",
"(",
")",
")",
"{",
"return",
"String",
".",
"format",
"(",
"\"--%s ***********\"",
",",
"getLongName",
"(",
")",
")",
";",
"}",
"else",
"{",
"// if we're displaying a tagged argument, include the tag name and attributes",
"if",
"(",
"value",
"instanceof",
"TaggedArgument",
")",
"{",
"return",
"String",
".",
"format",
"(",
"\"--%s %s\"",
",",
"TaggedArgumentParser",
".",
"getDisplayString",
"(",
"getLongName",
"(",
")",
",",
"(",
"TaggedArgument",
")",
"value",
")",
",",
"value",
")",
";",
"}",
"else",
"{",
"return",
"String",
".",
"format",
"(",
"\"--%s %s\"",
",",
"getLongName",
"(",
")",
",",
"value",
")",
";",
"}",
"}",
"}",
"return",
"\"\"",
";",
"}"
] |
Get a name value pair for this argument and a value, suitable for display.
|
[
"Get",
"a",
"name",
"value",
"pair",
"for",
"this",
"argument",
"and",
"a",
"value",
"suitable",
"for",
"display",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/argparser/NamedArgumentDefinition.java#L466-L480
|
8,773
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/argparser/NamedArgumentDefinition.java
|
NamedArgumentDefinition.convertDefaultValueToString
|
private String convertDefaultValueToString() {
final Object initialValue = getArgumentValue();
if (initialValue != null) {
if (isCollection() && ((Collection<?>) initialValue).isEmpty()) {
// treat empty collections the same as uninitialized non-collection types
return NULL_ARGUMENT_STRING;
} else {
// this is an initialized primitive type or a non-empty collection
return initialValue.toString();
}
} else {
return NULL_ARGUMENT_STRING;
}
}
|
java
|
private String convertDefaultValueToString() {
final Object initialValue = getArgumentValue();
if (initialValue != null) {
if (isCollection() && ((Collection<?>) initialValue).isEmpty()) {
// treat empty collections the same as uninitialized non-collection types
return NULL_ARGUMENT_STRING;
} else {
// this is an initialized primitive type or a non-empty collection
return initialValue.toString();
}
} else {
return NULL_ARGUMENT_STRING;
}
}
|
[
"private",
"String",
"convertDefaultValueToString",
"(",
")",
"{",
"final",
"Object",
"initialValue",
"=",
"getArgumentValue",
"(",
")",
";",
"if",
"(",
"initialValue",
"!=",
"null",
")",
"{",
"if",
"(",
"isCollection",
"(",
")",
"&&",
"(",
"(",
"Collection",
"<",
"?",
">",
")",
"initialValue",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"// treat empty collections the same as uninitialized non-collection types",
"return",
"NULL_ARGUMENT_STRING",
";",
"}",
"else",
"{",
"// this is an initialized primitive type or a non-empty collection",
"return",
"initialValue",
".",
"toString",
"(",
")",
";",
"}",
"}",
"else",
"{",
"return",
"NULL_ARGUMENT_STRING",
";",
"}",
"}"
] |
Convert the initial value for this argument to a string representation.
|
[
"Convert",
"the",
"initial",
"value",
"for",
"this",
"argument",
"to",
"a",
"string",
"representation",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/argparser/NamedArgumentDefinition.java#L483-L496
|
8,774
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/argparser/NamedArgumentDefinition.java
|
NamedArgumentDefinition.validateBoundsDefinitions
|
private void validateBoundsDefinitions() {
// bounds should be only set for numeric arguments and if the type is integer it should
// be set to an integer
if (!Number.class.isAssignableFrom(getUnderlyingFieldClass())) {
if (hasBoundedRange() || hasRecommendedRange()) {
throw new CommandLineException.CommandLineParserInternalException(
String.format(
"Min/max value ranges can only be set for numeric arguments. " +
"Argument --%s has a minimum or maximum value but has a non-numeric type.",
getLongName()));
}
}
if (Integer.class.isAssignableFrom(getUnderlyingFieldClass())) {
if (!isInfinityOrMathematicalInteger(getMaxValue())
|| !isInfinityOrMathematicalInteger(getMinValue())
|| !isInfinityOrMathematicalInteger(getMaxRecommendedValue())
|| !isInfinityOrMathematicalInteger(getMinRecommendedValue())) {
throw new CommandLineException.CommandLineParserInternalException(
String.format(
"Integer argument --%s has a minimum or maximum attribute with a non-integral value.",
getLongName()));
}
}
}
|
java
|
private void validateBoundsDefinitions() {
// bounds should be only set for numeric arguments and if the type is integer it should
// be set to an integer
if (!Number.class.isAssignableFrom(getUnderlyingFieldClass())) {
if (hasBoundedRange() || hasRecommendedRange()) {
throw new CommandLineException.CommandLineParserInternalException(
String.format(
"Min/max value ranges can only be set for numeric arguments. " +
"Argument --%s has a minimum or maximum value but has a non-numeric type.",
getLongName()));
}
}
if (Integer.class.isAssignableFrom(getUnderlyingFieldClass())) {
if (!isInfinityOrMathematicalInteger(getMaxValue())
|| !isInfinityOrMathematicalInteger(getMinValue())
|| !isInfinityOrMathematicalInteger(getMaxRecommendedValue())
|| !isInfinityOrMathematicalInteger(getMinRecommendedValue())) {
throw new CommandLineException.CommandLineParserInternalException(
String.format(
"Integer argument --%s has a minimum or maximum attribute with a non-integral value.",
getLongName()));
}
}
}
|
[
"private",
"void",
"validateBoundsDefinitions",
"(",
")",
"{",
"// bounds should be only set for numeric arguments and if the type is integer it should",
"// be set to an integer",
"if",
"(",
"!",
"Number",
".",
"class",
".",
"isAssignableFrom",
"(",
"getUnderlyingFieldClass",
"(",
")",
")",
")",
"{",
"if",
"(",
"hasBoundedRange",
"(",
")",
"||",
"hasRecommendedRange",
"(",
")",
")",
"{",
"throw",
"new",
"CommandLineException",
".",
"CommandLineParserInternalException",
"(",
"String",
".",
"format",
"(",
"\"Min/max value ranges can only be set for numeric arguments. \"",
"+",
"\"Argument --%s has a minimum or maximum value but has a non-numeric type.\"",
",",
"getLongName",
"(",
")",
")",
")",
";",
"}",
"}",
"if",
"(",
"Integer",
".",
"class",
".",
"isAssignableFrom",
"(",
"getUnderlyingFieldClass",
"(",
")",
")",
")",
"{",
"if",
"(",
"!",
"isInfinityOrMathematicalInteger",
"(",
"getMaxValue",
"(",
")",
")",
"||",
"!",
"isInfinityOrMathematicalInteger",
"(",
"getMinValue",
"(",
")",
")",
"||",
"!",
"isInfinityOrMathematicalInteger",
"(",
"getMaxRecommendedValue",
"(",
")",
")",
"||",
"!",
"isInfinityOrMathematicalInteger",
"(",
"getMinRecommendedValue",
"(",
")",
")",
")",
"{",
"throw",
"new",
"CommandLineException",
".",
"CommandLineParserInternalException",
"(",
"String",
".",
"format",
"(",
"\"Integer argument --%s has a minimum or maximum attribute with a non-integral value.\"",
",",
"getLongName",
"(",
")",
")",
")",
";",
"}",
"}",
"}"
] |
and are self-consistent.
|
[
"and",
"are",
"self",
"-",
"consistent",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/argparser/NamedArgumentDefinition.java#L505-L528
|
8,775
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/argparser/NamedArgumentDefinition.java
|
NamedArgumentDefinition.getValuePopulatedWithTags
|
private Object getValuePopulatedWithTags(final String originalTag, final String stringValue)
{
// See if the value is a surrogate key in the tag parser's map that was placed there during preprocessing,
// and if so, unpack the values retrieved via the key and use those to populate the field
final Object value = constructFromString(stringValue, getLongName());
if (TaggedArgument.class.isAssignableFrom(getUnderlyingFieldClass())) {
// NOTE: this propagates the tag name/attributes to the field BEFORE the value is set
TaggedArgument taggedArgument = (TaggedArgument) value;
TaggedArgumentParser.populateArgumentTags(
taggedArgument,
getLongName(),
originalTag);
} else if (originalTag != null) {
// a tag was found for a non-taggable argument
throw new CommandLineException(
String.format("The argument: \"%s/%s\" does not accept tags: \"%s\"",
getShortName(),
getFullName(),
originalTag));
}
return value;
}
|
java
|
private Object getValuePopulatedWithTags(final String originalTag, final String stringValue)
{
// See if the value is a surrogate key in the tag parser's map that was placed there during preprocessing,
// and if so, unpack the values retrieved via the key and use those to populate the field
final Object value = constructFromString(stringValue, getLongName());
if (TaggedArgument.class.isAssignableFrom(getUnderlyingFieldClass())) {
// NOTE: this propagates the tag name/attributes to the field BEFORE the value is set
TaggedArgument taggedArgument = (TaggedArgument) value;
TaggedArgumentParser.populateArgumentTags(
taggedArgument,
getLongName(),
originalTag);
} else if (originalTag != null) {
// a tag was found for a non-taggable argument
throw new CommandLineException(
String.format("The argument: \"%s/%s\" does not accept tags: \"%s\"",
getShortName(),
getFullName(),
originalTag));
}
return value;
}
|
[
"private",
"Object",
"getValuePopulatedWithTags",
"(",
"final",
"String",
"originalTag",
",",
"final",
"String",
"stringValue",
")",
"{",
"// See if the value is a surrogate key in the tag parser's map that was placed there during preprocessing,",
"// and if so, unpack the values retrieved via the key and use those to populate the field",
"final",
"Object",
"value",
"=",
"constructFromString",
"(",
"stringValue",
",",
"getLongName",
"(",
")",
")",
";",
"if",
"(",
"TaggedArgument",
".",
"class",
".",
"isAssignableFrom",
"(",
"getUnderlyingFieldClass",
"(",
")",
")",
")",
"{",
"// NOTE: this propagates the tag name/attributes to the field BEFORE the value is set",
"TaggedArgument",
"taggedArgument",
"=",
"(",
"TaggedArgument",
")",
"value",
";",
"TaggedArgumentParser",
".",
"populateArgumentTags",
"(",
"taggedArgument",
",",
"getLongName",
"(",
")",
",",
"originalTag",
")",
";",
"}",
"else",
"if",
"(",
"originalTag",
"!=",
"null",
")",
"{",
"// a tag was found for a non-taggable argument",
"throw",
"new",
"CommandLineException",
"(",
"String",
".",
"format",
"(",
"\"The argument: \\\"%s/%s\\\" does not accept tags: \\\"%s\\\"\"",
",",
"getShortName",
"(",
")",
",",
"getFullName",
"(",
")",
",",
"originalTag",
")",
")",
";",
"}",
"return",
"value",
";",
"}"
] |
populated with the actual value and tags and attributes provided by the user for that argument.
|
[
"populated",
"with",
"the",
"actual",
"value",
"and",
"tags",
"and",
"attributes",
"provided",
"by",
"the",
"user",
"for",
"that",
"argument",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/argparser/NamedArgumentDefinition.java#L532-L554
|
8,776
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/argparser/NamedArgumentDefinition.java
|
NamedArgumentDefinition.getArgumentDescription
|
private String getArgumentDescription(
final Map<String, NamedArgumentDefinition> allActualArguments,
final Collection<CommandLinePluginDescriptor<?>> pluginDescriptors) {
final StringBuilder sb = new StringBuilder();
if (!getDocString().isEmpty()) {
sb.append(getDocString());
sb.append(" ");
}
if (isCollection()) {
if (isOptional()) {
sb.append("This argument may be specified 0 or more times. ");
} else {
sb.append("This argument must be specified at least once. ");
}
}
if (isOptional()) {
sb.append("Default value: ");
sb.append(getDefaultValueAsString());
sb.append(". ");
} else {
sb.append("Required. ");
}
// if this argument definition is a string field claimed by a plugin descriptor (i.e.,
// it holds the names of plugins specified by the user on the command line, such as read filter names),
// then we need to delegate to the plugin descriptor to generate the list of allowed values
if (!usageForPluginDescriptorArgument(sb, pluginDescriptors)) {
// If the argument wasn't claimed by any descriptor, treat it as a normal argument
sb.append(getOptionsAsDisplayString());
}
if (!getMutexTargetList().isEmpty()) {
sb.append(" Cannot be used in conjunction with argument(s)");
for (final String argument : getMutexTargetList()) {
final NamedArgumentDefinition mutexArgumentDefinition = allActualArguments.get(argument);
sb.append(" ").append(mutexArgumentDefinition.getUnderlyingField().getName());
if (!mutexArgumentDefinition.getShortName().isEmpty()) {
sb.append(" (").append(mutexArgumentDefinition.getShortName()).append(")");
}
}
}
return sb.toString();
}
|
java
|
private String getArgumentDescription(
final Map<String, NamedArgumentDefinition> allActualArguments,
final Collection<CommandLinePluginDescriptor<?>> pluginDescriptors) {
final StringBuilder sb = new StringBuilder();
if (!getDocString().isEmpty()) {
sb.append(getDocString());
sb.append(" ");
}
if (isCollection()) {
if (isOptional()) {
sb.append("This argument may be specified 0 or more times. ");
} else {
sb.append("This argument must be specified at least once. ");
}
}
if (isOptional()) {
sb.append("Default value: ");
sb.append(getDefaultValueAsString());
sb.append(". ");
} else {
sb.append("Required. ");
}
// if this argument definition is a string field claimed by a plugin descriptor (i.e.,
// it holds the names of plugins specified by the user on the command line, such as read filter names),
// then we need to delegate to the plugin descriptor to generate the list of allowed values
if (!usageForPluginDescriptorArgument(sb, pluginDescriptors)) {
// If the argument wasn't claimed by any descriptor, treat it as a normal argument
sb.append(getOptionsAsDisplayString());
}
if (!getMutexTargetList().isEmpty()) {
sb.append(" Cannot be used in conjunction with argument(s)");
for (final String argument : getMutexTargetList()) {
final NamedArgumentDefinition mutexArgumentDefinition = allActualArguments.get(argument);
sb.append(" ").append(mutexArgumentDefinition.getUnderlyingField().getName());
if (!mutexArgumentDefinition.getShortName().isEmpty()) {
sb.append(" (").append(mutexArgumentDefinition.getShortName()).append(")");
}
}
}
return sb.toString();
}
|
[
"private",
"String",
"getArgumentDescription",
"(",
"final",
"Map",
"<",
"String",
",",
"NamedArgumentDefinition",
">",
"allActualArguments",
",",
"final",
"Collection",
"<",
"CommandLinePluginDescriptor",
"<",
"?",
">",
">",
"pluginDescriptors",
")",
"{",
"final",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"if",
"(",
"!",
"getDocString",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"sb",
".",
"append",
"(",
"getDocString",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\" \"",
")",
";",
"}",
"if",
"(",
"isCollection",
"(",
")",
")",
"{",
"if",
"(",
"isOptional",
"(",
")",
")",
"{",
"sb",
".",
"append",
"(",
"\"This argument may be specified 0 or more times. \"",
")",
";",
"}",
"else",
"{",
"sb",
".",
"append",
"(",
"\"This argument must be specified at least once. \"",
")",
";",
"}",
"}",
"if",
"(",
"isOptional",
"(",
")",
")",
"{",
"sb",
".",
"append",
"(",
"\"Default value: \"",
")",
";",
"sb",
".",
"append",
"(",
"getDefaultValueAsString",
"(",
")",
")",
";",
"sb",
".",
"append",
"(",
"\". \"",
")",
";",
"}",
"else",
"{",
"sb",
".",
"append",
"(",
"\"Required. \"",
")",
";",
"}",
"// if this argument definition is a string field claimed by a plugin descriptor (i.e.,",
"// it holds the names of plugins specified by the user on the command line, such as read filter names),",
"// then we need to delegate to the plugin descriptor to generate the list of allowed values",
"if",
"(",
"!",
"usageForPluginDescriptorArgument",
"(",
"sb",
",",
"pluginDescriptors",
")",
")",
"{",
"// If the argument wasn't claimed by any descriptor, treat it as a normal argument",
"sb",
".",
"append",
"(",
"getOptionsAsDisplayString",
"(",
")",
")",
";",
"}",
"if",
"(",
"!",
"getMutexTargetList",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"sb",
".",
"append",
"(",
"\" Cannot be used in conjunction with argument(s)\"",
")",
";",
"for",
"(",
"final",
"String",
"argument",
":",
"getMutexTargetList",
"(",
")",
")",
"{",
"final",
"NamedArgumentDefinition",
"mutexArgumentDefinition",
"=",
"allActualArguments",
".",
"get",
"(",
"argument",
")",
";",
"sb",
".",
"append",
"(",
"\" \"",
")",
".",
"append",
"(",
"mutexArgumentDefinition",
".",
"getUnderlyingField",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"if",
"(",
"!",
"mutexArgumentDefinition",
".",
"getShortName",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"sb",
".",
"append",
"(",
"\" (\"",
")",
".",
"append",
"(",
"mutexArgumentDefinition",
".",
"getShortName",
"(",
")",
")",
".",
"append",
"(",
"\")\"",
")",
";",
"}",
"}",
"}",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] |
Return a usage string representing this argument.
|
[
"Return",
"a",
"usage",
"string",
"representing",
"this",
"argument",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/argparser/NamedArgumentDefinition.java#L557-L599
|
8,777
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/argparser/NamedArgumentDefinition.java
|
NamedArgumentDefinition.checkArgumentRange
|
private void checkArgumentRange(final Object argumentValue) {
// Only validate numeric types because we have already ensured at constructor time that only numeric types have bounds
if (!Number.class.isAssignableFrom(getUnderlyingFieldClass())) {
return;
}
final Double argumentDoubleValue = (argumentValue == null) ? null : ((Number)argumentValue).doubleValue();
// Check hard limits first, if specified
if (hasBoundedRange() && isValueOutOfRange(argumentDoubleValue)) {
throw new CommandLineException.OutOfRangeArgumentValue(getLongName(), getMinValue(), getMaxValue(), argumentValue);
}
// Check recommended values
if (hasRecommendedRange() && isValueOutOfRange(argumentDoubleValue)) {
final boolean outMinValue = getMinRecommendedValue() != Double.NEGATIVE_INFINITY;
final boolean outMaxValue = getMaxRecommendedValue() != Double.POSITIVE_INFINITY;
if (outMinValue && outMaxValue) {
logger.warn("Argument --{} has value {}, but recommended within range ({},{})",
getLongName(), argumentDoubleValue, getMinRecommendedValue(), getMaxRecommendedValue());
} else if (outMinValue) {
logger.warn("Argument --{} has value {}, but minimum recommended is {}",
getLongName(), argumentDoubleValue, getMinRecommendedValue());
} else if (outMaxValue) {
logger.warn("Argument --{} has value {}, but maximum recommended is {}",
getLongName(), argumentDoubleValue, getMaxRecommendedValue());
}
// if there is no recommended value, do not log anything
}
}
|
java
|
private void checkArgumentRange(final Object argumentValue) {
// Only validate numeric types because we have already ensured at constructor time that only numeric types have bounds
if (!Number.class.isAssignableFrom(getUnderlyingFieldClass())) {
return;
}
final Double argumentDoubleValue = (argumentValue == null) ? null : ((Number)argumentValue).doubleValue();
// Check hard limits first, if specified
if (hasBoundedRange() && isValueOutOfRange(argumentDoubleValue)) {
throw new CommandLineException.OutOfRangeArgumentValue(getLongName(), getMinValue(), getMaxValue(), argumentValue);
}
// Check recommended values
if (hasRecommendedRange() && isValueOutOfRange(argumentDoubleValue)) {
final boolean outMinValue = getMinRecommendedValue() != Double.NEGATIVE_INFINITY;
final boolean outMaxValue = getMaxRecommendedValue() != Double.POSITIVE_INFINITY;
if (outMinValue && outMaxValue) {
logger.warn("Argument --{} has value {}, but recommended within range ({},{})",
getLongName(), argumentDoubleValue, getMinRecommendedValue(), getMaxRecommendedValue());
} else if (outMinValue) {
logger.warn("Argument --{} has value {}, but minimum recommended is {}",
getLongName(), argumentDoubleValue, getMinRecommendedValue());
} else if (outMaxValue) {
logger.warn("Argument --{} has value {}, but maximum recommended is {}",
getLongName(), argumentDoubleValue, getMaxRecommendedValue());
}
// if there is no recommended value, do not log anything
}
}
|
[
"private",
"void",
"checkArgumentRange",
"(",
"final",
"Object",
"argumentValue",
")",
"{",
"// Only validate numeric types because we have already ensured at constructor time that only numeric types have bounds",
"if",
"(",
"!",
"Number",
".",
"class",
".",
"isAssignableFrom",
"(",
"getUnderlyingFieldClass",
"(",
")",
")",
")",
"{",
"return",
";",
"}",
"final",
"Double",
"argumentDoubleValue",
"=",
"(",
"argumentValue",
"==",
"null",
")",
"?",
"null",
":",
"(",
"(",
"Number",
")",
"argumentValue",
")",
".",
"doubleValue",
"(",
")",
";",
"// Check hard limits first, if specified",
"if",
"(",
"hasBoundedRange",
"(",
")",
"&&",
"isValueOutOfRange",
"(",
"argumentDoubleValue",
")",
")",
"{",
"throw",
"new",
"CommandLineException",
".",
"OutOfRangeArgumentValue",
"(",
"getLongName",
"(",
")",
",",
"getMinValue",
"(",
")",
",",
"getMaxValue",
"(",
")",
",",
"argumentValue",
")",
";",
"}",
"// Check recommended values",
"if",
"(",
"hasRecommendedRange",
"(",
")",
"&&",
"isValueOutOfRange",
"(",
"argumentDoubleValue",
")",
")",
"{",
"final",
"boolean",
"outMinValue",
"=",
"getMinRecommendedValue",
"(",
")",
"!=",
"Double",
".",
"NEGATIVE_INFINITY",
";",
"final",
"boolean",
"outMaxValue",
"=",
"getMaxRecommendedValue",
"(",
")",
"!=",
"Double",
".",
"POSITIVE_INFINITY",
";",
"if",
"(",
"outMinValue",
"&&",
"outMaxValue",
")",
"{",
"logger",
".",
"warn",
"(",
"\"Argument --{} has value {}, but recommended within range ({},{})\"",
",",
"getLongName",
"(",
")",
",",
"argumentDoubleValue",
",",
"getMinRecommendedValue",
"(",
")",
",",
"getMaxRecommendedValue",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"outMinValue",
")",
"{",
"logger",
".",
"warn",
"(",
"\"Argument --{} has value {}, but minimum recommended is {}\"",
",",
"getLongName",
"(",
")",
",",
"argumentDoubleValue",
",",
"getMinRecommendedValue",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"outMaxValue",
")",
"{",
"logger",
".",
"warn",
"(",
"\"Argument --{} has value {}, but maximum recommended is {}\"",
",",
"getLongName",
"(",
")",
",",
"argumentDoubleValue",
",",
"getMaxRecommendedValue",
"(",
")",
")",
";",
"}",
"// if there is no recommended value, do not log anything",
"}",
"}"
] |
Check the provided value against any range constraints specified in the Argument annotation
for the corresponding field. Throw an exception if limits are violated.
- Only checks numeric types (int, double, etc.)
|
[
"Check",
"the",
"provided",
"value",
"against",
"any",
"range",
"constraints",
"specified",
"in",
"the",
"Argument",
"annotation",
"for",
"the",
"corresponding",
"field",
".",
"Throw",
"an",
"exception",
"if",
"limits",
"are",
"violated",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/argparser/NamedArgumentDefinition.java#L638-L667
|
8,778
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/argparser/NamedArgumentDefinition.java
|
NamedArgumentDefinition.setArgumentValue
|
private void setArgumentValue(final Object value) {
try {
getUnderlyingField().set(getContainingObject(), value);
} catch (final IllegalAccessException e) {
throw new CommandLineException.ShouldNeverReachHereException(
String.format(
"Couldn't set field value for %s in %s with value %s.",
getUnderlyingField().getName(),
getContainingObject().toString(),
value.toString()),
e);
}
}
|
java
|
private void setArgumentValue(final Object value) {
try {
getUnderlyingField().set(getContainingObject(), value);
} catch (final IllegalAccessException e) {
throw new CommandLineException.ShouldNeverReachHereException(
String.format(
"Couldn't set field value for %s in %s with value %s.",
getUnderlyingField().getName(),
getContainingObject().toString(),
value.toString()),
e);
}
}
|
[
"private",
"void",
"setArgumentValue",
"(",
"final",
"Object",
"value",
")",
"{",
"try",
"{",
"getUnderlyingField",
"(",
")",
".",
"set",
"(",
"getContainingObject",
"(",
")",
",",
"value",
")",
";",
"}",
"catch",
"(",
"final",
"IllegalAccessException",
"e",
")",
"{",
"throw",
"new",
"CommandLineException",
".",
"ShouldNeverReachHereException",
"(",
"String",
".",
"format",
"(",
"\"Couldn't set field value for %s in %s with value %s.\"",
",",
"getUnderlyingField",
"(",
")",
".",
"getName",
"(",
")",
",",
"getContainingObject",
"(",
")",
".",
"toString",
"(",
")",
",",
"value",
".",
"toString",
"(",
")",
")",
",",
"e",
")",
";",
"}",
"}"
] |
Set the underlying field to the new value.
|
[
"Set",
"the",
"underlying",
"field",
"to",
"the",
"new",
"value",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/argparser/NamedArgumentDefinition.java#L670-L682
|
8,779
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/argparser/NamedArgumentDefinition.java
|
NamedArgumentDefinition.isValueOutOfRange
|
private boolean isValueOutOfRange(final Double value) {
return value == null || getMinValue() != Double.NEGATIVE_INFINITY && value < getMinValue()
|| getMaxValue() != Double.POSITIVE_INFINITY && value > getMaxValue();
}
|
java
|
private boolean isValueOutOfRange(final Double value) {
return value == null || getMinValue() != Double.NEGATIVE_INFINITY && value < getMinValue()
|| getMaxValue() != Double.POSITIVE_INFINITY && value > getMaxValue();
}
|
[
"private",
"boolean",
"isValueOutOfRange",
"(",
"final",
"Double",
"value",
")",
"{",
"return",
"value",
"==",
"null",
"||",
"getMinValue",
"(",
")",
"!=",
"Double",
".",
"NEGATIVE_INFINITY",
"&&",
"value",
"<",
"getMinValue",
"(",
")",
"||",
"getMaxValue",
"(",
")",
"!=",
"Double",
".",
"POSITIVE_INFINITY",
"&&",
"value",
">",
"getMaxValue",
"(",
")",
";",
"}"
] |
null values are always out of range
|
[
"null",
"values",
"are",
"always",
"out",
"of",
"range"
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/argparser/NamedArgumentDefinition.java#L685-L688
|
8,780
|
ReactiveX/RxJavaJoins
|
src/main/java/rx/joins/Pattern4.java
|
Pattern4.and
|
public <T5> Pattern5<T1, T2, T3, T4, T5> and(Observable<T5> other) {
if (other == null) {
throw new NullPointerException();
}
return new Pattern5<T1, T2, T3, T4, T5>(o1, o2, o3, o4, other);
}
|
java
|
public <T5> Pattern5<T1, T2, T3, T4, T5> and(Observable<T5> other) {
if (other == null) {
throw new NullPointerException();
}
return new Pattern5<T1, T2, T3, T4, T5>(o1, o2, o3, o4, other);
}
|
[
"public",
"<",
"T5",
">",
"Pattern5",
"<",
"T1",
",",
"T2",
",",
"T3",
",",
"T4",
",",
"T5",
">",
"and",
"(",
"Observable",
"<",
"T5",
">",
"other",
")",
"{",
"if",
"(",
"other",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
")",
";",
"}",
"return",
"new",
"Pattern5",
"<",
"T1",
",",
"T2",
",",
"T3",
",",
"T4",
",",
"T5",
">",
"(",
"o1",
",",
"o2",
",",
"o3",
",",
"o4",
",",
"other",
")",
";",
"}"
] |
Creates a pattern that matches when all four observable sequences have an available element.
@param other
Observable sequence to match with the three previous sequences.
@return Pattern object that matches when all observable sequences have an available element.
|
[
"Creates",
"a",
"pattern",
"that",
"matches",
"when",
"all",
"four",
"observable",
"sequences",
"have",
"an",
"available",
"element",
"."
] |
65b5c7fa03bd375c9e1f7906d7143068fde9b714
|
https://github.com/ReactiveX/RxJavaJoins/blob/65b5c7fa03bd375c9e1f7906d7143068fde9b714/src/main/java/rx/joins/Pattern4.java#L65-L70
|
8,781
|
michaelquigley/zabbixj
|
zabbixj-core/src/main/java/com/quigley/zabbixj/metrics/MetricsContainer.java
|
MetricsContainer.listProviders
|
public String[] listProviders() {
String[] providers = new String[container.size()];
int i = 0;
Iterator<String> ki = container.keySet().iterator();
while(ki.hasNext()) {
providers[i++] = (String) ki.next();
}
return providers;
}
|
java
|
public String[] listProviders() {
String[] providers = new String[container.size()];
int i = 0;
Iterator<String> ki = container.keySet().iterator();
while(ki.hasNext()) {
providers[i++] = (String) ki.next();
}
return providers;
}
|
[
"public",
"String",
"[",
"]",
"listProviders",
"(",
")",
"{",
"String",
"[",
"]",
"providers",
"=",
"new",
"String",
"[",
"container",
".",
"size",
"(",
")",
"]",
";",
"int",
"i",
"=",
"0",
";",
"Iterator",
"<",
"String",
">",
"ki",
"=",
"container",
".",
"keySet",
"(",
")",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"ki",
".",
"hasNext",
"(",
")",
")",
"{",
"providers",
"[",
"i",
"++",
"]",
"=",
"(",
"String",
")",
"ki",
".",
"next",
"(",
")",
";",
"}",
"return",
"providers",
";",
"}"
] |
List the MetricsProvider keys in this MetricsContainer.
@return a String[] containing the MetricsProvider keys.
|
[
"List",
"the",
"MetricsProvider",
"keys",
"in",
"this",
"MetricsContainer",
"."
] |
15cfe46e45750b3857bec7eecc75ff5e5a3d774d
|
https://github.com/michaelquigley/zabbixj/blob/15cfe46e45750b3857bec7eecc75ff5e5a3d774d/zabbixj-core/src/main/java/com/quigley/zabbixj/metrics/MetricsContainer.java#L35-L45
|
8,782
|
michaelquigley/zabbixj
|
zabbixj-core/src/main/java/com/quigley/zabbixj/metrics/MetricsContainer.java
|
MetricsContainer.addProvider
|
public void addProvider(String name, MetricsProvider provider) {
if(log.isInfoEnabled()) {
log.info("Adding Provider: " + provider.getClass().getName() + "=" + name);
}
container.put(name, provider);
}
|
java
|
public void addProvider(String name, MetricsProvider provider) {
if(log.isInfoEnabled()) {
log.info("Adding Provider: " + provider.getClass().getName() + "=" + name);
}
container.put(name, provider);
}
|
[
"public",
"void",
"addProvider",
"(",
"String",
"name",
",",
"MetricsProvider",
"provider",
")",
"{",
"if",
"(",
"log",
".",
"isInfoEnabled",
"(",
")",
")",
"{",
"log",
".",
"info",
"(",
"\"Adding Provider: \"",
"+",
"provider",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\"=\"",
"+",
"name",
")",
";",
"}",
"container",
".",
"put",
"(",
"name",
",",
"provider",
")",
";",
"}"
] |
Add a MetricsProvider to this container.
@param name the name of the MetricsProvider.
@param provider the MetricsProvider instance.
|
[
"Add",
"a",
"MetricsProvider",
"to",
"this",
"container",
"."
] |
15cfe46e45750b3857bec7eecc75ff5e5a3d774d
|
https://github.com/michaelquigley/zabbixj/blob/15cfe46e45750b3857bec7eecc75ff5e5a3d774d/zabbixj-core/src/main/java/com/quigley/zabbixj/metrics/MetricsContainer.java#L52-L58
|
8,783
|
michaelquigley/zabbixj
|
zabbixj-core/src/main/java/com/quigley/zabbixj/metrics/MetricsContainer.java
|
MetricsContainer.getProvider
|
public MetricsProvider getProvider(String name) throws MetricsException {
if(container.containsKey(name)) {
return (MetricsProvider) container.get(name);
} else {
throw new MetricsException("No MetricsProvider with name: " + name);
}
}
|
java
|
public MetricsProvider getProvider(String name) throws MetricsException {
if(container.containsKey(name)) {
return (MetricsProvider) container.get(name);
} else {
throw new MetricsException("No MetricsProvider with name: " + name);
}
}
|
[
"public",
"MetricsProvider",
"getProvider",
"(",
"String",
"name",
")",
"throws",
"MetricsException",
"{",
"if",
"(",
"container",
".",
"containsKey",
"(",
"name",
")",
")",
"{",
"return",
"(",
"MetricsProvider",
")",
"container",
".",
"get",
"(",
"name",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"MetricsException",
"(",
"\"No MetricsProvider with name: \"",
"+",
"name",
")",
";",
"}",
"}"
] |
Retrieve a MetricsProvider.
@param name the name of the MetricsProvider to retrieve.
@return the named MetricsProvider instance.
@throws MetricsException when the named MetricsProvider does not exist.
|
[
"Retrieve",
"a",
"MetricsProvider",
"."
] |
15cfe46e45750b3857bec7eecc75ff5e5a3d774d
|
https://github.com/michaelquigley/zabbixj/blob/15cfe46e45750b3857bec7eecc75ff5e5a3d774d/zabbixj-core/src/main/java/com/quigley/zabbixj/metrics/MetricsContainer.java#L76-L82
|
8,784
|
michaelquigley/zabbixj
|
zabbixj-core/src/main/java/com/quigley/zabbixj/metrics/MetricsContainer.java
|
MetricsContainer.getMetric
|
public Object getMetric(String key) throws MetricsException {
MetricsKey mk = new MetricsKey(key);
MetricsProvider provider = getProvider(mk.getProvider());
return provider.getValue(mk);
}
|
java
|
public Object getMetric(String key) throws MetricsException {
MetricsKey mk = new MetricsKey(key);
MetricsProvider provider = getProvider(mk.getProvider());
return provider.getValue(mk);
}
|
[
"public",
"Object",
"getMetric",
"(",
"String",
"key",
")",
"throws",
"MetricsException",
"{",
"MetricsKey",
"mk",
"=",
"new",
"MetricsKey",
"(",
"key",
")",
";",
"MetricsProvider",
"provider",
"=",
"getProvider",
"(",
"mk",
".",
"getProvider",
"(",
")",
")",
";",
"return",
"provider",
".",
"getValue",
"(",
"mk",
")",
";",
"}"
] |
Retrieve a value from this MetricsContainer.
@param key the fully-qualified key naming the metric.
@return the requested value.
@throws MetricsException when the fully-qualified key does not exist.
|
[
"Retrieve",
"a",
"value",
"from",
"this",
"MetricsContainer",
"."
] |
15cfe46e45750b3857bec7eecc75ff5e5a3d774d
|
https://github.com/michaelquigley/zabbixj/blob/15cfe46e45750b3857bec7eecc75ff5e5a3d774d/zabbixj-core/src/main/java/com/quigley/zabbixj/metrics/MetricsContainer.java#L90-L94
|
8,785
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/argparser/ArgumentDefinition.java
|
ArgumentDefinition.intializeCollection
|
protected void intializeCollection(final String annotationType) {
final Field field = getUnderlyingField();
final Object callerArguments = containingObject;
try {
if (field.get(containingObject) == null) {
field.set(callerArguments, field.getType().newInstance());
}
} catch (final Exception ex) {
// If we can't instantiate the collection, try falling back to Note: I assume this catches Exception to
// handle the case where the type is not instantiable
try {
field.set(callerArguments, new ArrayList<>());
} catch (final IllegalArgumentException e) {
throw new CommandLineException.CommandLineParserInternalException(
String.format(
"Collection member %s of type %s must be explicitly initialized. " +
"It cannot be constructed or auto-initialized with ArrayList.",
field.getName(),
annotationType));
} catch (final IllegalAccessException e) {
throw new CommandLineException.ShouldNeverReachHereException(
"We should not have reached here because we set accessible to true", e);
}
}
}
|
java
|
protected void intializeCollection(final String annotationType) {
final Field field = getUnderlyingField();
final Object callerArguments = containingObject;
try {
if (field.get(containingObject) == null) {
field.set(callerArguments, field.getType().newInstance());
}
} catch (final Exception ex) {
// If we can't instantiate the collection, try falling back to Note: I assume this catches Exception to
// handle the case where the type is not instantiable
try {
field.set(callerArguments, new ArrayList<>());
} catch (final IllegalArgumentException e) {
throw new CommandLineException.CommandLineParserInternalException(
String.format(
"Collection member %s of type %s must be explicitly initialized. " +
"It cannot be constructed or auto-initialized with ArrayList.",
field.getName(),
annotationType));
} catch (final IllegalAccessException e) {
throw new CommandLineException.ShouldNeverReachHereException(
"We should not have reached here because we set accessible to true", e);
}
}
}
|
[
"protected",
"void",
"intializeCollection",
"(",
"final",
"String",
"annotationType",
")",
"{",
"final",
"Field",
"field",
"=",
"getUnderlyingField",
"(",
")",
";",
"final",
"Object",
"callerArguments",
"=",
"containingObject",
";",
"try",
"{",
"if",
"(",
"field",
".",
"get",
"(",
"containingObject",
")",
"==",
"null",
")",
"{",
"field",
".",
"set",
"(",
"callerArguments",
",",
"field",
".",
"getType",
"(",
")",
".",
"newInstance",
"(",
")",
")",
";",
"}",
"}",
"catch",
"(",
"final",
"Exception",
"ex",
")",
"{",
"// If we can't instantiate the collection, try falling back to Note: I assume this catches Exception to",
"// handle the case where the type is not instantiable",
"try",
"{",
"field",
".",
"set",
"(",
"callerArguments",
",",
"new",
"ArrayList",
"<>",
"(",
")",
")",
";",
"}",
"catch",
"(",
"final",
"IllegalArgumentException",
"e",
")",
"{",
"throw",
"new",
"CommandLineException",
".",
"CommandLineParserInternalException",
"(",
"String",
".",
"format",
"(",
"\"Collection member %s of type %s must be explicitly initialized. \"",
"+",
"\"It cannot be constructed or auto-initialized with ArrayList.\"",
",",
"field",
".",
"getName",
"(",
")",
",",
"annotationType",
")",
")",
";",
"}",
"catch",
"(",
"final",
"IllegalAccessException",
"e",
")",
"{",
"throw",
"new",
"CommandLineException",
".",
"ShouldNeverReachHereException",
"(",
"\"We should not have reached here because we set accessible to true\"",
",",
"e",
")",
";",
"}",
"}",
"}"
] |
Initialize a collection value for this field. If the collection can't be instantiated directly
because its the underlying type is not a concrete type, an attempt assign an ArrayList will be made.
@param annotationType the type of annotation used for ths argument, for error reporting purposes
|
[
"Initialize",
"a",
"collection",
"value",
"for",
"this",
"field",
".",
"If",
"the",
"collection",
"can",
"t",
"be",
"instantiated",
"directly",
"because",
"its",
"the",
"underlying",
"type",
"is",
"not",
"a",
"concrete",
"type",
"an",
"attempt",
"assign",
"an",
"ArrayList",
"will",
"be",
"made",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/argparser/ArgumentDefinition.java#L174-L198
|
8,786
|
broadinstitute/barclay
|
src/main/java/org/broadinstitute/barclay/argparser/ArgumentDefinition.java
|
ArgumentDefinition.getOptionsAsDisplayString
|
@SuppressWarnings({"unchecked","rawtypes"})
protected String getOptionsAsDisplayString() {
final Class<?> clazz = getUnderlyingFieldClass();
if (clazz == Boolean.class) {
return String.format("%s%s, %s%s", OPTION_DOC_PREFIX, Boolean.TRUE, Boolean.FALSE, OPTION_DOC_SUFFIX);
} else if (clazz.isEnum()) {
final Class<? extends Enum> enumClass = (Class<? extends Enum>)clazz;
return getEnumOptions(enumClass);
} else {
return "";
}
}
|
java
|
@SuppressWarnings({"unchecked","rawtypes"})
protected String getOptionsAsDisplayString() {
final Class<?> clazz = getUnderlyingFieldClass();
if (clazz == Boolean.class) {
return String.format("%s%s, %s%s", OPTION_DOC_PREFIX, Boolean.TRUE, Boolean.FALSE, OPTION_DOC_SUFFIX);
} else if (clazz.isEnum()) {
final Class<? extends Enum> enumClass = (Class<? extends Enum>)clazz;
return getEnumOptions(enumClass);
} else {
return "";
}
}
|
[
"@",
"SuppressWarnings",
"(",
"{",
"\"unchecked\"",
",",
"\"rawtypes\"",
"}",
")",
"protected",
"String",
"getOptionsAsDisplayString",
"(",
")",
"{",
"final",
"Class",
"<",
"?",
">",
"clazz",
"=",
"getUnderlyingFieldClass",
"(",
")",
";",
"if",
"(",
"clazz",
"==",
"Boolean",
".",
"class",
")",
"{",
"return",
"String",
".",
"format",
"(",
"\"%s%s, %s%s\"",
",",
"OPTION_DOC_PREFIX",
",",
"Boolean",
".",
"TRUE",
",",
"Boolean",
".",
"FALSE",
",",
"OPTION_DOC_SUFFIX",
")",
";",
"}",
"else",
"if",
"(",
"clazz",
".",
"isEnum",
"(",
")",
")",
"{",
"final",
"Class",
"<",
"?",
"extends",
"Enum",
">",
"enumClass",
"=",
"(",
"Class",
"<",
"?",
"extends",
"Enum",
">",
")",
"clazz",
";",
"return",
"getEnumOptions",
"(",
"enumClass",
")",
";",
"}",
"else",
"{",
"return",
"\"\"",
";",
"}",
"}"
] |
Returns the list of possible options values for this argument.
<p>
Currently this only make sense with {@link Boolean} and {@link Enum}. Any other class
will result in an empty string.
</p>
@return String representing the list of possible option values, never {@code null}.
|
[
"Returns",
"the",
"list",
"of",
"possible",
"options",
"values",
"for",
"this",
"argument",
"."
] |
7e56d725766b0da3baff23e79a31c3d01c3589c2
|
https://github.com/broadinstitute/barclay/blob/7e56d725766b0da3baff23e79a31c3d01c3589c2/src/main/java/org/broadinstitute/barclay/argparser/ArgumentDefinition.java#L271-L282
|
8,787
|
ReactiveX/RxJavaJoins
|
src/main/java/rx/joins/Pattern8.java
|
Pattern8.and
|
public <T9> Pattern9<T1, T2, T3, T4, T5, T6, T7, T8, T9> and(Observable<T9> other) {
if (other == null) {
throw new NullPointerException();
}
return new Pattern9<T1, T2, T3, T4, T5, T6, T7, T8, T9>(o1, o2, o3, o4, o5, o6, o7, o8, other);
}
|
java
|
public <T9> Pattern9<T1, T2, T3, T4, T5, T6, T7, T8, T9> and(Observable<T9> other) {
if (other == null) {
throw new NullPointerException();
}
return new Pattern9<T1, T2, T3, T4, T5, T6, T7, T8, T9>(o1, o2, o3, o4, o5, o6, o7, o8, other);
}
|
[
"public",
"<",
"T9",
">",
"Pattern9",
"<",
"T1",
",",
"T2",
",",
"T3",
",",
"T4",
",",
"T5",
",",
"T6",
",",
"T7",
",",
"T8",
",",
"T9",
">",
"and",
"(",
"Observable",
"<",
"T9",
">",
"other",
")",
"{",
"if",
"(",
"other",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
")",
";",
"}",
"return",
"new",
"Pattern9",
"<",
"T1",
",",
"T2",
",",
"T3",
",",
"T4",
",",
"T5",
",",
"T6",
",",
"T7",
",",
"T8",
",",
"T9",
">",
"(",
"o1",
",",
"o2",
",",
"o3",
",",
"o4",
",",
"o5",
",",
"o6",
",",
"o7",
",",
"o8",
",",
"other",
")",
";",
"}"
] |
Creates a pattern that matches when all eight observable sequences have an available element.
@param other
Observable sequence to match with the seven previous sequences.
@return Pattern object that matches when all observable sequences have an available element.
|
[
"Creates",
"a",
"pattern",
"that",
"matches",
"when",
"all",
"eight",
"observable",
"sequences",
"have",
"an",
"available",
"element",
"."
] |
65b5c7fa03bd375c9e1f7906d7143068fde9b714
|
https://github.com/ReactiveX/RxJavaJoins/blob/65b5c7fa03bd375c9e1f7906d7143068fde9b714/src/main/java/rx/joins/Pattern8.java#L93-L98
|
8,788
|
ReactiveX/RxJavaJoins
|
src/main/java/rx/joins/Pattern5.java
|
Pattern5.and
|
public <T6> Pattern6<T1, T2, T3, T4, T5, T6> and(Observable<T6> other) {
if (other == null) {
throw new NullPointerException();
}
return new Pattern6<T1, T2, T3, T4, T5, T6>(o1, o2, o3, o4, o5, other);
}
|
java
|
public <T6> Pattern6<T1, T2, T3, T4, T5, T6> and(Observable<T6> other) {
if (other == null) {
throw new NullPointerException();
}
return new Pattern6<T1, T2, T3, T4, T5, T6>(o1, o2, o3, o4, o5, other);
}
|
[
"public",
"<",
"T6",
">",
"Pattern6",
"<",
"T1",
",",
"T2",
",",
"T3",
",",
"T4",
",",
"T5",
",",
"T6",
">",
"and",
"(",
"Observable",
"<",
"T6",
">",
"other",
")",
"{",
"if",
"(",
"other",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
")",
";",
"}",
"return",
"new",
"Pattern6",
"<",
"T1",
",",
"T2",
",",
"T3",
",",
"T4",
",",
"T5",
",",
"T6",
">",
"(",
"o1",
",",
"o2",
",",
"o3",
",",
"o4",
",",
"o5",
",",
"other",
")",
";",
"}"
] |
Creates a pattern that matches when all five observable sequences have an available element.
@param other
Observable sequence to match with the four previous sequences.
@return Pattern object that matches when all observable sequences have an available element.
|
[
"Creates",
"a",
"pattern",
"that",
"matches",
"when",
"all",
"five",
"observable",
"sequences",
"have",
"an",
"available",
"element",
"."
] |
65b5c7fa03bd375c9e1f7906d7143068fde9b714
|
https://github.com/ReactiveX/RxJavaJoins/blob/65b5c7fa03bd375c9e1f7906d7143068fde9b714/src/main/java/rx/joins/Pattern5.java#L72-L77
|
8,789
|
ReactiveX/RxJavaJoins
|
src/main/java/rx/joins/PatternN.java
|
PatternN.and
|
public PatternN and(Observable<? extends Object> other) {
if (other == null) {
throw new NullPointerException();
}
return new PatternN(observables, other);
}
|
java
|
public PatternN and(Observable<? extends Object> other) {
if (other == null) {
throw new NullPointerException();
}
return new PatternN(observables, other);
}
|
[
"public",
"PatternN",
"and",
"(",
"Observable",
"<",
"?",
"extends",
"Object",
">",
"other",
")",
"{",
"if",
"(",
"other",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
")",
";",
"}",
"return",
"new",
"PatternN",
"(",
"observables",
",",
"other",
")",
";",
"}"
] |
Creates a pattern that matches when all previous observable sequences have an available element.
@param other
Observable sequence to match with the previous sequences.
@return Pattern object that matches when all observable sequences have an available element.
|
[
"Creates",
"a",
"pattern",
"that",
"matches",
"when",
"all",
"previous",
"observable",
"sequences",
"have",
"an",
"available",
"element",
"."
] |
65b5c7fa03bd375c9e1f7906d7143068fde9b714
|
https://github.com/ReactiveX/RxJavaJoins/blob/65b5c7fa03bd375c9e1f7906d7143068fde9b714/src/main/java/rx/joins/PatternN.java#L61-L66
|
8,790
|
Clivern/Racter
|
src/main/java/com/clivern/racter/senders/templates/GenericTemplate.java
|
GenericTemplate.setElementDefaultAction
|
public void setElementDefaultAction(Integer index, String type, String url, Boolean messenger_extensions, String webview_height_ratio, String fallback_url)
{
this.elements.get(index).put("default_action_type", type);
this.elements.get(index).put("default_action_url", url);
this.elements.get(index).put("default_action_messenger_extensions", String.valueOf(messenger_extensions));
this.elements.get(index).put("default_action_webview_height_ratio", webview_height_ratio);
this.elements.get(index).put("default_action_fallback_url", fallback_url);
}
|
java
|
public void setElementDefaultAction(Integer index, String type, String url, Boolean messenger_extensions, String webview_height_ratio, String fallback_url)
{
this.elements.get(index).put("default_action_type", type);
this.elements.get(index).put("default_action_url", url);
this.elements.get(index).put("default_action_messenger_extensions", String.valueOf(messenger_extensions));
this.elements.get(index).put("default_action_webview_height_ratio", webview_height_ratio);
this.elements.get(index).put("default_action_fallback_url", fallback_url);
}
|
[
"public",
"void",
"setElementDefaultAction",
"(",
"Integer",
"index",
",",
"String",
"type",
",",
"String",
"url",
",",
"Boolean",
"messenger_extensions",
",",
"String",
"webview_height_ratio",
",",
"String",
"fallback_url",
")",
"{",
"this",
".",
"elements",
".",
"get",
"(",
"index",
")",
".",
"put",
"(",
"\"default_action_type\"",
",",
"type",
")",
";",
"this",
".",
"elements",
".",
"get",
"(",
"index",
")",
".",
"put",
"(",
"\"default_action_url\"",
",",
"url",
")",
";",
"this",
".",
"elements",
".",
"get",
"(",
"index",
")",
".",
"put",
"(",
"\"default_action_messenger_extensions\"",
",",
"String",
".",
"valueOf",
"(",
"messenger_extensions",
")",
")",
";",
"this",
".",
"elements",
".",
"get",
"(",
"index",
")",
".",
"put",
"(",
"\"default_action_webview_height_ratio\"",
",",
"webview_height_ratio",
")",
";",
"this",
".",
"elements",
".",
"get",
"(",
"index",
")",
".",
"put",
"(",
"\"default_action_fallback_url\"",
",",
"fallback_url",
")",
";",
"}"
] |
Set Element Default Action
@param index the element index
@param type the element type
@param url the element url
@param messenger_extensions the messenger extensions
@param webview_height_ratio the webview height ratio
@param fallback_url the fallback url
|
[
"Set",
"Element",
"Default",
"Action"
] |
bbde02f0c2a8a80653ad6b1607376d8408acd71c
|
https://github.com/Clivern/Racter/blob/bbde02f0c2a8a80653ad6b1607376d8408acd71c/src/main/java/com/clivern/racter/senders/templates/GenericTemplate.java#L84-L91
|
8,791
|
Clivern/Racter
|
src/main/java/com/clivern/racter/senders/templates/GenericTemplate.java
|
GenericTemplate.setElementButton
|
public void setElementButton(Integer index, String title, String type, String url, Boolean messenger_extensions, String webview_height_ratio, String fallback_url)
{
if( this.elements.get(index).containsKey("buttons") ){
HashMap<String, String> button = new HashMap<String, String>();
button.put("title", title);
button.put("type", type);
button.put("url", url);
button.put("messenger_extensions", String.valueOf(messenger_extensions));
button.put("webview_height_ratio", webview_height_ratio);
button.put("fallback_url", fallback_url);
@SuppressWarnings("unchecked")
ArrayList<HashMap<String, String>> element_buttons = (ArrayList<HashMap<String, String>>) this.elements.get(index).get("buttons");
element_buttons.add(button);
this.elements.get(index).put("buttons", element_buttons);
}else{
ArrayList<HashMap<String, String>> element_buttons = new ArrayList<HashMap<String, String>>();
HashMap<String, String> button = new HashMap<String, String>();
button.put("title", title);
button.put("type", type);
button.put("url", url);
button.put("messenger_extensions", String.valueOf(messenger_extensions));
button.put("webview_height_ratio", webview_height_ratio);
button.put("fallback_url", fallback_url);
element_buttons.add(button);
this.elements.get(index).put("buttons", element_buttons);
}
}
|
java
|
public void setElementButton(Integer index, String title, String type, String url, Boolean messenger_extensions, String webview_height_ratio, String fallback_url)
{
if( this.elements.get(index).containsKey("buttons") ){
HashMap<String, String> button = new HashMap<String, String>();
button.put("title", title);
button.put("type", type);
button.put("url", url);
button.put("messenger_extensions", String.valueOf(messenger_extensions));
button.put("webview_height_ratio", webview_height_ratio);
button.put("fallback_url", fallback_url);
@SuppressWarnings("unchecked")
ArrayList<HashMap<String, String>> element_buttons = (ArrayList<HashMap<String, String>>) this.elements.get(index).get("buttons");
element_buttons.add(button);
this.elements.get(index).put("buttons", element_buttons);
}else{
ArrayList<HashMap<String, String>> element_buttons = new ArrayList<HashMap<String, String>>();
HashMap<String, String> button = new HashMap<String, String>();
button.put("title", title);
button.put("type", type);
button.put("url", url);
button.put("messenger_extensions", String.valueOf(messenger_extensions));
button.put("webview_height_ratio", webview_height_ratio);
button.put("fallback_url", fallback_url);
element_buttons.add(button);
this.elements.get(index).put("buttons", element_buttons);
}
}
|
[
"public",
"void",
"setElementButton",
"(",
"Integer",
"index",
",",
"String",
"title",
",",
"String",
"type",
",",
"String",
"url",
",",
"Boolean",
"messenger_extensions",
",",
"String",
"webview_height_ratio",
",",
"String",
"fallback_url",
")",
"{",
"if",
"(",
"this",
".",
"elements",
".",
"get",
"(",
"index",
")",
".",
"containsKey",
"(",
"\"buttons\"",
")",
")",
"{",
"HashMap",
"<",
"String",
",",
"String",
">",
"button",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"button",
".",
"put",
"(",
"\"title\"",
",",
"title",
")",
";",
"button",
".",
"put",
"(",
"\"type\"",
",",
"type",
")",
";",
"button",
".",
"put",
"(",
"\"url\"",
",",
"url",
")",
";",
"button",
".",
"put",
"(",
"\"messenger_extensions\"",
",",
"String",
".",
"valueOf",
"(",
"messenger_extensions",
")",
")",
";",
"button",
".",
"put",
"(",
"\"webview_height_ratio\"",
",",
"webview_height_ratio",
")",
";",
"button",
".",
"put",
"(",
"\"fallback_url\"",
",",
"fallback_url",
")",
";",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"ArrayList",
"<",
"HashMap",
"<",
"String",
",",
"String",
">",
">",
"element_buttons",
"=",
"(",
"ArrayList",
"<",
"HashMap",
"<",
"String",
",",
"String",
">",
">",
")",
"this",
".",
"elements",
".",
"get",
"(",
"index",
")",
".",
"get",
"(",
"\"buttons\"",
")",
";",
"element_buttons",
".",
"add",
"(",
"button",
")",
";",
"this",
".",
"elements",
".",
"get",
"(",
"index",
")",
".",
"put",
"(",
"\"buttons\"",
",",
"element_buttons",
")",
";",
"}",
"else",
"{",
"ArrayList",
"<",
"HashMap",
"<",
"String",
",",
"String",
">",
">",
"element_buttons",
"=",
"new",
"ArrayList",
"<",
"HashMap",
"<",
"String",
",",
"String",
">",
">",
"(",
")",
";",
"HashMap",
"<",
"String",
",",
"String",
">",
"button",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"button",
".",
"put",
"(",
"\"title\"",
",",
"title",
")",
";",
"button",
".",
"put",
"(",
"\"type\"",
",",
"type",
")",
";",
"button",
".",
"put",
"(",
"\"url\"",
",",
"url",
")",
";",
"button",
".",
"put",
"(",
"\"messenger_extensions\"",
",",
"String",
".",
"valueOf",
"(",
"messenger_extensions",
")",
")",
";",
"button",
".",
"put",
"(",
"\"webview_height_ratio\"",
",",
"webview_height_ratio",
")",
";",
"button",
".",
"put",
"(",
"\"fallback_url\"",
",",
"fallback_url",
")",
";",
"element_buttons",
".",
"add",
"(",
"button",
")",
";",
"this",
".",
"elements",
".",
"get",
"(",
"index",
")",
".",
"put",
"(",
"\"buttons\"",
",",
"element_buttons",
")",
";",
"}",
"}"
] |
Set Element Button
@param index the element index
@param title the element title
@param type the element type
@param url the element url
@param messenger_extensions the messenger extensions
@param webview_height_ratio the webview height ratio
@param fallback_url the fallback url
|
[
"Set",
"Element",
"Button"
] |
bbde02f0c2a8a80653ad6b1607376d8408acd71c
|
https://github.com/Clivern/Racter/blob/bbde02f0c2a8a80653ad6b1607376d8408acd71c/src/main/java/com/clivern/racter/senders/templates/GenericTemplate.java#L104-L130
|
8,792
|
Clivern/Racter
|
src/main/java/com/clivern/racter/receivers/VerifyWebhook.java
|
VerifyWebhook.challenge
|
public Boolean challenge()
{
if( (this.hub_mode.equals("subscribe")) && (this.hub_verify_token.equals(this.configs.get("verify_token", ""))) ){
Logger.info("Verify token validated successfully.");
return true;
}
Logger.error("Error validating verify token.");
return false;
}
|
java
|
public Boolean challenge()
{
if( (this.hub_mode.equals("subscribe")) && (this.hub_verify_token.equals(this.configs.get("verify_token", ""))) ){
Logger.info("Verify token validated successfully.");
return true;
}
Logger.error("Error validating verify token.");
return false;
}
|
[
"public",
"Boolean",
"challenge",
"(",
")",
"{",
"if",
"(",
"(",
"this",
".",
"hub_mode",
".",
"equals",
"(",
"\"subscribe\"",
")",
")",
"&&",
"(",
"this",
".",
"hub_verify_token",
".",
"equals",
"(",
"this",
".",
"configs",
".",
"get",
"(",
"\"verify_token\"",
",",
"\"\"",
")",
")",
")",
")",
"{",
"Logger",
".",
"info",
"(",
"\"Verify token validated successfully.\"",
")",
";",
"return",
"true",
";",
"}",
"Logger",
".",
"error",
"(",
"\"Error validating verify token.\"",
")",
";",
"return",
"false",
";",
"}"
] |
Verify Challenge Data
@return boolean whether challenge passed or not
|
[
"Verify",
"Challenge",
"Data"
] |
bbde02f0c2a8a80653ad6b1607376d8408acd71c
|
https://github.com/Clivern/Racter/blob/bbde02f0c2a8a80653ad6b1607376d8408acd71c/src/main/java/com/clivern/racter/receivers/VerifyWebhook.java#L110-L119
|
8,793
|
Clivern/Racter
|
src/main/java/com/clivern/racter/senders/templates/MessageTemplate.java
|
MessageTemplate.setQuickReply
|
public void setQuickReply(String content_type, String title, String payload, String image_url)
{
HashMap<String, String> quick_reply = new HashMap<String, String>();
quick_reply.put("content_type", content_type);
quick_reply.put("title", title);
quick_reply.put("payload", payload);
quick_reply.put("image_url", image_url);
this.message_quick_replies.add(quick_reply);
}
|
java
|
public void setQuickReply(String content_type, String title, String payload, String image_url)
{
HashMap<String, String> quick_reply = new HashMap<String, String>();
quick_reply.put("content_type", content_type);
quick_reply.put("title", title);
quick_reply.put("payload", payload);
quick_reply.put("image_url", image_url);
this.message_quick_replies.add(quick_reply);
}
|
[
"public",
"void",
"setQuickReply",
"(",
"String",
"content_type",
",",
"String",
"title",
",",
"String",
"payload",
",",
"String",
"image_url",
")",
"{",
"HashMap",
"<",
"String",
",",
"String",
">",
"quick_reply",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"quick_reply",
".",
"put",
"(",
"\"content_type\"",
",",
"content_type",
")",
";",
"quick_reply",
".",
"put",
"(",
"\"title\"",
",",
"title",
")",
";",
"quick_reply",
".",
"put",
"(",
"\"payload\"",
",",
"payload",
")",
";",
"quick_reply",
".",
"put",
"(",
"\"image_url\"",
",",
"image_url",
")",
";",
"this",
".",
"message_quick_replies",
".",
"add",
"(",
"quick_reply",
")",
";",
"}"
] |
Set Quick Reply
@param content_type the content type
@param title the title
@param payload the payload flag
@param image_url the image URL
|
[
"Set",
"Quick",
"Reply"
] |
bbde02f0c2a8a80653ad6b1607376d8408acd71c
|
https://github.com/Clivern/Racter/blob/bbde02f0c2a8a80653ad6b1607376d8408acd71c/src/main/java/com/clivern/racter/senders/templates/MessageTemplate.java#L117-L125
|
8,794
|
Clivern/Racter
|
src/main/java/com/clivern/racter/utils/Config.java
|
Config.loadPropertiesFile
|
public Boolean loadPropertiesFile(String path) throws IOException
{
Properties prop = new Properties();
InputStream input = null;
try {
input = new FileInputStream(path);
prop.load(input);
for(String key : prop.stringPropertyNames()) {
String value = prop.getProperty(key);
configs.put(key, value);
}
return true;
} catch (IOException ex) {
return false;
}
}
|
java
|
public Boolean loadPropertiesFile(String path) throws IOException
{
Properties prop = new Properties();
InputStream input = null;
try {
input = new FileInputStream(path);
prop.load(input);
for(String key : prop.stringPropertyNames()) {
String value = prop.getProperty(key);
configs.put(key, value);
}
return true;
} catch (IOException ex) {
return false;
}
}
|
[
"public",
"Boolean",
"loadPropertiesFile",
"(",
"String",
"path",
")",
"throws",
"IOException",
"{",
"Properties",
"prop",
"=",
"new",
"Properties",
"(",
")",
";",
"InputStream",
"input",
"=",
"null",
";",
"try",
"{",
"input",
"=",
"new",
"FileInputStream",
"(",
"path",
")",
";",
"prop",
".",
"load",
"(",
"input",
")",
";",
"for",
"(",
"String",
"key",
":",
"prop",
".",
"stringPropertyNames",
"(",
")",
")",
"{",
"String",
"value",
"=",
"prop",
".",
"getProperty",
"(",
"key",
")",
";",
"configs",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"}",
"return",
"true",
";",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"return",
"false",
";",
"}",
"}"
] |
Load Properties File
@param path relative path to the config file
@return Boolean whether config file loaded or not
@throws IOException May throw IOException if it cannot open configs file
|
[
"Load",
"Properties",
"File"
] |
bbde02f0c2a8a80653ad6b1607376d8408acd71c
|
https://github.com/Clivern/Racter/blob/bbde02f0c2a8a80653ad6b1607376d8408acd71c/src/main/java/com/clivern/racter/utils/Config.java#L47-L66
|
8,795
|
Clivern/Racter
|
src/main/java/com/clivern/racter/utils/Config.java
|
Config.storePropertiesFile
|
public Boolean storePropertiesFile(String path) throws IOException
{
Properties prop = new Properties();
OutputStream output = null;
try {
output = new FileOutputStream(path);
for (String key : configs.keySet()){
prop.setProperty(key, configs.get(key));
}
prop.store(output, null);
return true;
} catch (IOException io) {
return false;
}
}
|
java
|
public Boolean storePropertiesFile(String path) throws IOException
{
Properties prop = new Properties();
OutputStream output = null;
try {
output = new FileOutputStream(path);
for (String key : configs.keySet()){
prop.setProperty(key, configs.get(key));
}
prop.store(output, null);
return true;
} catch (IOException io) {
return false;
}
}
|
[
"public",
"Boolean",
"storePropertiesFile",
"(",
"String",
"path",
")",
"throws",
"IOException",
"{",
"Properties",
"prop",
"=",
"new",
"Properties",
"(",
")",
";",
"OutputStream",
"output",
"=",
"null",
";",
"try",
"{",
"output",
"=",
"new",
"FileOutputStream",
"(",
"path",
")",
";",
"for",
"(",
"String",
"key",
":",
"configs",
".",
"keySet",
"(",
")",
")",
"{",
"prop",
".",
"setProperty",
"(",
"key",
",",
"configs",
".",
"get",
"(",
"key",
")",
")",
";",
"}",
"prop",
".",
"store",
"(",
"output",
",",
"null",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"IOException",
"io",
")",
"{",
"return",
"false",
";",
"}",
"}"
] |
Store Configs in Properties File
@param path relative path to the config file
@return Boolean whether config file stored or not
@throws IOException May throw IOException if it cannot open configs file
|
[
"Store",
"Configs",
"in",
"Properties",
"File"
] |
bbde02f0c2a8a80653ad6b1607376d8408acd71c
|
https://github.com/Clivern/Racter/blob/bbde02f0c2a8a80653ad6b1607376d8408acd71c/src/main/java/com/clivern/racter/utils/Config.java#L75-L92
|
8,796
|
Clivern/Racter
|
src/main/java/com/clivern/racter/senders/BaseSender.java
|
BaseSender.send
|
public Boolean send(MessageTemplate template) throws UnirestException
{
String url = this.remote_url + this.configs.get("page_access_token", "");
String body = template.build();
Logger.info("curl -X POST -H \"Content-Type: application/json\" -d '" + body + "' \"" + url + "\"");
HttpResponse<String> response = Unirest.post(url).header("Content-Type", "application/json").body(body).asString();
return true;
}
|
java
|
public Boolean send(MessageTemplate template) throws UnirestException
{
String url = this.remote_url + this.configs.get("page_access_token", "");
String body = template.build();
Logger.info("curl -X POST -H \"Content-Type: application/json\" -d '" + body + "' \"" + url + "\"");
HttpResponse<String> response = Unirest.post(url).header("Content-Type", "application/json").body(body).asString();
return true;
}
|
[
"public",
"Boolean",
"send",
"(",
"MessageTemplate",
"template",
")",
"throws",
"UnirestException",
"{",
"String",
"url",
"=",
"this",
".",
"remote_url",
"+",
"this",
".",
"configs",
".",
"get",
"(",
"\"page_access_token\"",
",",
"\"\"",
")",
";",
"String",
"body",
"=",
"template",
".",
"build",
"(",
")",
";",
"Logger",
".",
"info",
"(",
"\"curl -X POST -H \\\"Content-Type: application/json\\\" -d '\"",
"+",
"body",
"+",
"\"' \\\"\"",
"+",
"url",
"+",
"\"\\\"\"",
")",
";",
"HttpResponse",
"<",
"String",
">",
"response",
"=",
"Unirest",
".",
"post",
"(",
"url",
")",
".",
"header",
"(",
"\"Content-Type\"",
",",
"\"application/json\"",
")",
".",
"body",
"(",
"body",
")",
".",
"asString",
"(",
")",
";",
"return",
"true",
";",
"}"
] |
Send Default Message
@param template an instance of message template
@return Boolean whether the message sent or not
@throws UnirestException Throws exception in case it fails to perform the request
|
[
"Send",
"Default",
"Message"
] |
bbde02f0c2a8a80653ad6b1607376d8408acd71c
|
https://github.com/Clivern/Racter/blob/bbde02f0c2a8a80653ad6b1607376d8408acd71c/src/main/java/com/clivern/racter/senders/BaseSender.java#L114-L122
|
8,797
|
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/journal/readerwriter/multifile/LockingFollowingJournalReader.java
|
LockingFollowingJournalReader.openNextFile
|
@Override
protected synchronized JournalInputFile openNextFile()
throws JournalException {
while (open) {
boolean locked = processLockingMechanism();
if (pauseBeforePolling) {
try {
wait(pollingIntervalMillis);
} catch (InterruptedException e) {
// no special action on interrupt.
}
}
if (!locked) {
JournalInputFile nextFile = super.openNextFile();
if (nextFile != null) {
return nextFile;
}
}
try {
wait(pollingIntervalMillis);
} catch (InterruptedException e) {
// no special action on interrupt.
}
}
return null;
}
|
java
|
@Override
protected synchronized JournalInputFile openNextFile()
throws JournalException {
while (open) {
boolean locked = processLockingMechanism();
if (pauseBeforePolling) {
try {
wait(pollingIntervalMillis);
} catch (InterruptedException e) {
// no special action on interrupt.
}
}
if (!locked) {
JournalInputFile nextFile = super.openNextFile();
if (nextFile != null) {
return nextFile;
}
}
try {
wait(pollingIntervalMillis);
} catch (InterruptedException e) {
// no special action on interrupt.
}
}
return null;
}
|
[
"@",
"Override",
"protected",
"synchronized",
"JournalInputFile",
"openNextFile",
"(",
")",
"throws",
"JournalException",
"{",
"while",
"(",
"open",
")",
"{",
"boolean",
"locked",
"=",
"processLockingMechanism",
"(",
")",
";",
"if",
"(",
"pauseBeforePolling",
")",
"{",
"try",
"{",
"wait",
"(",
"pollingIntervalMillis",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"// no special action on interrupt.",
"}",
"}",
"if",
"(",
"!",
"locked",
")",
"{",
"JournalInputFile",
"nextFile",
"=",
"super",
".",
"openNextFile",
"(",
")",
";",
"if",
"(",
"nextFile",
"!=",
"null",
")",
"{",
"return",
"nextFile",
";",
"}",
"}",
"try",
"{",
"wait",
"(",
"pollingIntervalMillis",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"// no special action on interrupt.",
"}",
"}",
"return",
"null",
";",
"}"
] |
Process the locking mechanism. If we are not locked, we should look for
another journal file to process. Ask for a new file, using the superclass
method, but if none is found, wait for a while and repeat. This will
continue until we get a server shutdown signal.
|
[
"Process",
"the",
"locking",
"mechanism",
".",
"If",
"we",
"are",
"not",
"locked",
"we",
"should",
"look",
"for",
"another",
"journal",
"file",
"to",
"process",
".",
"Ask",
"for",
"a",
"new",
"file",
"using",
"the",
"superclass",
"method",
"but",
"if",
"none",
"is",
"found",
"wait",
"for",
"a",
"while",
"and",
"repeat",
".",
"This",
"will",
"continue",
"until",
"we",
"get",
"a",
"server",
"shutdown",
"signal",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/readerwriter/multifile/LockingFollowingJournalReader.java#L92-L120
|
8,798
|
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/journal/readerwriter/multifile/LockingFollowingJournalReader.java
|
LockingFollowingJournalReader.processLockingMechanism
|
private boolean processLockingMechanism() throws JournalException {
boolean locked;
if (lockRequestedFile.exists()) {
try {
if (!lockAcceptedFile.exists()) {
lockAcceptedFile.createNewFile();
}
} catch (IOException e) {
throw new JournalException("Unable to create 'Lock Accepted' file at '"
+ lockAcceptedFile.getPath() + "'");
}
locked = true;
} else {
if (lockAcceptedFile.exists()) {
lockAcceptedFile.delete();
}
locked = false;
}
if (locked && !wasLocked) {
recoveryLog.log("Lock request detected: "
+ lockRequestedFile.getPath() + ", Lock accepted: "
+ lockAcceptedFile.getPath());
} else if (wasLocked && !locked) {
recoveryLog.log("Lock request removed: "
+ lockRequestedFile.getPath());
}
wasLocked = locked;
return locked;
}
|
java
|
private boolean processLockingMechanism() throws JournalException {
boolean locked;
if (lockRequestedFile.exists()) {
try {
if (!lockAcceptedFile.exists()) {
lockAcceptedFile.createNewFile();
}
} catch (IOException e) {
throw new JournalException("Unable to create 'Lock Accepted' file at '"
+ lockAcceptedFile.getPath() + "'");
}
locked = true;
} else {
if (lockAcceptedFile.exists()) {
lockAcceptedFile.delete();
}
locked = false;
}
if (locked && !wasLocked) {
recoveryLog.log("Lock request detected: "
+ lockRequestedFile.getPath() + ", Lock accepted: "
+ lockAcceptedFile.getPath());
} else if (wasLocked && !locked) {
recoveryLog.log("Lock request removed: "
+ lockRequestedFile.getPath());
}
wasLocked = locked;
return locked;
}
|
[
"private",
"boolean",
"processLockingMechanism",
"(",
")",
"throws",
"JournalException",
"{",
"boolean",
"locked",
";",
"if",
"(",
"lockRequestedFile",
".",
"exists",
"(",
")",
")",
"{",
"try",
"{",
"if",
"(",
"!",
"lockAcceptedFile",
".",
"exists",
"(",
")",
")",
"{",
"lockAcceptedFile",
".",
"createNewFile",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"JournalException",
"(",
"\"Unable to create 'Lock Accepted' file at '\"",
"+",
"lockAcceptedFile",
".",
"getPath",
"(",
")",
"+",
"\"'\"",
")",
";",
"}",
"locked",
"=",
"true",
";",
"}",
"else",
"{",
"if",
"(",
"lockAcceptedFile",
".",
"exists",
"(",
")",
")",
"{",
"lockAcceptedFile",
".",
"delete",
"(",
")",
";",
"}",
"locked",
"=",
"false",
";",
"}",
"if",
"(",
"locked",
"&&",
"!",
"wasLocked",
")",
"{",
"recoveryLog",
".",
"log",
"(",
"\"Lock request detected: \"",
"+",
"lockRequestedFile",
".",
"getPath",
"(",
")",
"+",
"\", Lock accepted: \"",
"+",
"lockAcceptedFile",
".",
"getPath",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"wasLocked",
"&&",
"!",
"locked",
")",
"{",
"recoveryLog",
".",
"log",
"(",
"\"Lock request removed: \"",
"+",
"lockRequestedFile",
".",
"getPath",
"(",
")",
")",
";",
"}",
"wasLocked",
"=",
"locked",
";",
"return",
"locked",
";",
"}"
] |
If we see a lock request, issue an acceptance. If we do not, withdraw the
acceptance.
@return true if locked, false if not locked.
@throws JournalException
if we fail to create the 'lock accepted' file.
|
[
"If",
"we",
"see",
"a",
"lock",
"request",
"issue",
"an",
"acceptance",
".",
"If",
"we",
"do",
"not",
"withdraw",
"the",
"acceptance",
"."
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/journal/readerwriter/multifile/LockingFollowingJournalReader.java#L139-L169
|
8,799
|
fcrepo3/fcrepo
|
fcrepo-server/src/main/java/org/fcrepo/server/storage/lowlevel/akubra/HashPathIdMapper.java
|
HashPathIdMapper.getPath
|
private void getPath(String uri, StringBuilder builder) {
if (pattern.length() == 0) {
return;
}
String hash = getHash(uri);
int hashPos = 0;
for (int i = 0; i < pattern.length(); i++) {
char c = pattern.charAt(i);
if (c == '#') {
builder.append(hash.charAt(hashPos++));
} else {
builder.append(c);
}
}
builder.append('/');
}
|
java
|
private void getPath(String uri, StringBuilder builder) {
if (pattern.length() == 0) {
return;
}
String hash = getHash(uri);
int hashPos = 0;
for (int i = 0; i < pattern.length(); i++) {
char c = pattern.charAt(i);
if (c == '#') {
builder.append(hash.charAt(hashPos++));
} else {
builder.append(c);
}
}
builder.append('/');
}
|
[
"private",
"void",
"getPath",
"(",
"String",
"uri",
",",
"StringBuilder",
"builder",
")",
"{",
"if",
"(",
"pattern",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"return",
";",
"}",
"String",
"hash",
"=",
"getHash",
"(",
"uri",
")",
";",
"int",
"hashPos",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"pattern",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"char",
"c",
"=",
"pattern",
".",
"charAt",
"(",
"i",
")",
";",
"if",
"(",
"c",
"==",
"'",
"'",
")",
"{",
"builder",
".",
"append",
"(",
"hash",
".",
"charAt",
"(",
"hashPos",
"++",
")",
")",
";",
"}",
"else",
"{",
"builder",
".",
"append",
"(",
"c",
")",
";",
"}",
"}",
"builder",
".",
"append",
"(",
"'",
"'",
")",
";",
"}"
] |
gets the path based on the hash of the uri, or "" if the pattern is empty
|
[
"gets",
"the",
"path",
"based",
"on",
"the",
"hash",
"of",
"the",
"uri",
"or",
"if",
"the",
"pattern",
"is",
"empty"
] |
37df51b9b857fd12c6ab8269820d406c3c4ad774
|
https://github.com/fcrepo3/fcrepo/blob/37df51b9b857fd12c6ab8269820d406c3c4ad774/fcrepo-server/src/main/java/org/fcrepo/server/storage/lowlevel/akubra/HashPathIdMapper.java#L130-L145
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.