id int32 0 165k | repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1
value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 |
|---|---|---|---|---|---|---|---|---|---|---|---|
156,100 | ludovicianul/selenium-on-steroids | src/main/java/com/insidecoding/sos/xml/XMLUtils.java | XMLUtils.getNodeList | private NodeList getNodeList(final String xmlString, final String tagName)
throws ParserConfigurationException, SAXException, IOException {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setValidating(false);
dbf.setFeature("http://xml.org/sax/features/namespaces", false);
dbf.setFeature("http://xml.org/sax/features/validation", false);
dbf.setFeature(
"http://apache.org/xml/features/nonvalidating/load-dtd-grammar",
false);
dbf.setFeature(
"http://apache.org/xml/features/nonvalidating/load-external-dtd",
false);
DocumentBuilder db = dbf.newDocumentBuilder();
InputSource is = new InputSource();
is.setCharacterStream(new StringReader(xmlString));
Document doc = db.parse(is);
LOG.info("Getting tagName: " + tagName);
NodeList nodes = doc.getElementsByTagName(tagName);
return nodes;
} | java | private NodeList getNodeList(final String xmlString, final String tagName)
throws ParserConfigurationException, SAXException, IOException {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setValidating(false);
dbf.setFeature("http://xml.org/sax/features/namespaces", false);
dbf.setFeature("http://xml.org/sax/features/validation", false);
dbf.setFeature(
"http://apache.org/xml/features/nonvalidating/load-dtd-grammar",
false);
dbf.setFeature(
"http://apache.org/xml/features/nonvalidating/load-external-dtd",
false);
DocumentBuilder db = dbf.newDocumentBuilder();
InputSource is = new InputSource();
is.setCharacterStream(new StringReader(xmlString));
Document doc = db.parse(is);
LOG.info("Getting tagName: " + tagName);
NodeList nodes = doc.getElementsByTagName(tagName);
return nodes;
} | [
"private",
"NodeList",
"getNodeList",
"(",
"final",
"String",
"xmlString",
",",
"final",
"String",
"tagName",
")",
"throws",
"ParserConfigurationException",
",",
"SAXException",
",",
"IOException",
"{",
"DocumentBuilderFactory",
"dbf",
"=",
"DocumentBuilderFactory",
"."... | Gets the nodes list for a given tag name.
@param xmlString
the XML String
@param tagName
the tag name to be searched
@return the Node List for the given tag name
@throws ParserConfigurationException
if something goes wrong while parsing the XML
@throws SAXException
if XML is malformed
@throws IOException
if something goes wrong when reading the file | [
"Gets",
"the",
"nodes",
"list",
"for",
"a",
"given",
"tag",
"name",
"."
] | f89d91c59f686114f94624bfc55712f278005bfa | https://github.com/ludovicianul/selenium-on-steroids/blob/f89d91c59f686114f94624bfc55712f278005bfa/src/main/java/com/insidecoding/sos/xml/XMLUtils.java#L228-L249 |
156,101 | dancarpenter21/lol-api-rxjava | src/main/java/org/dc/riot/lol/rx/service/ApiKey.java | ApiKey.loadApiKeys | public static ApiKey[] loadApiKeys(File file) throws FileNotFoundException {
ArrayList<ApiKey> keys = new ArrayList<>();
Scanner scanner = null;
try {
scanner = new Scanner(new BufferedInputStream(new FileInputStream(file)));
while (scanner.hasNextLine()) {
String line = scanner.nextLine();
if ("".equals(line.trim())) {
// skip over empty lines
continue;
} else if (line.startsWith("#")) {
// skip over comments
continue;
}
String key = line.trim();
String keyDetails = scanner.nextLine().trim();
RateRule[] rules = null;
if (DEVELOPMENT.equals(keyDetails)) {
rules = RateRule.getDevelopmentRates();
} else if (PRODUCTION.equals(keyDetails)) {
rules = RateRule.getProductionRates();
} else {
rules = parseRules(keyDetails, scanner);
}
keys.add(new ApiKey(key, rules));
}
} finally {
if (scanner != null) {
scanner.close();
}
}
return keys.toArray(new ApiKey[keys.size()]);
} | java | public static ApiKey[] loadApiKeys(File file) throws FileNotFoundException {
ArrayList<ApiKey> keys = new ArrayList<>();
Scanner scanner = null;
try {
scanner = new Scanner(new BufferedInputStream(new FileInputStream(file)));
while (scanner.hasNextLine()) {
String line = scanner.nextLine();
if ("".equals(line.trim())) {
// skip over empty lines
continue;
} else if (line.startsWith("#")) {
// skip over comments
continue;
}
String key = line.trim();
String keyDetails = scanner.nextLine().trim();
RateRule[] rules = null;
if (DEVELOPMENT.equals(keyDetails)) {
rules = RateRule.getDevelopmentRates();
} else if (PRODUCTION.equals(keyDetails)) {
rules = RateRule.getProductionRates();
} else {
rules = parseRules(keyDetails, scanner);
}
keys.add(new ApiKey(key, rules));
}
} finally {
if (scanner != null) {
scanner.close();
}
}
return keys.toArray(new ApiKey[keys.size()]);
} | [
"public",
"static",
"ApiKey",
"[",
"]",
"loadApiKeys",
"(",
"File",
"file",
")",
"throws",
"FileNotFoundException",
"{",
"ArrayList",
"<",
"ApiKey",
">",
"keys",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"Scanner",
"scanner",
"=",
"null",
";",
"try",
... | Read API keys in the given file. This method exists as a convenience for
developers to load keys without command line or checking in API keys to
source control
@param file API key file to read
@return list of {@link ApiKey} found in the specified file
@throws FileNotFoundException if the specified file cannot be found | [
"Read",
"API",
"keys",
"in",
"the",
"given",
"file",
".",
"This",
"method",
"exists",
"as",
"a",
"convenience",
"for",
"developers",
"to",
"load",
"keys",
"without",
"command",
"line",
"or",
"checking",
"in",
"API",
"keys",
"to",
"source",
"control"
] | 3dd0520713253b051deda170e6d431160faf686d | https://github.com/dancarpenter21/lol-api-rxjava/blob/3dd0520713253b051deda170e6d431160faf686d/src/main/java/org/dc/riot/lol/rx/service/ApiKey.java#L94-L129 |
156,102 | pip-services3-java/pip-services3-commons-java | src/org/pipservices3/commons/reflect/RecursiveObjectReader.java | RecursiveObjectReader.hasProperty | public static boolean hasProperty(Object obj, String name) {
if (obj == null || name == null)
return false;
String[] names = name.split("\\.");
if (names == null || names.length == 0)
return false;
return performHasProperty(obj, names, 0);
} | java | public static boolean hasProperty(Object obj, String name) {
if (obj == null || name == null)
return false;
String[] names = name.split("\\.");
if (names == null || names.length == 0)
return false;
return performHasProperty(obj, names, 0);
} | [
"public",
"static",
"boolean",
"hasProperty",
"(",
"Object",
"obj",
",",
"String",
"name",
")",
"{",
"if",
"(",
"obj",
"==",
"null",
"||",
"name",
"==",
"null",
")",
"return",
"false",
";",
"String",
"[",
"]",
"names",
"=",
"name",
".",
"split",
"(",... | Checks recursively if object or its subobjects has a property with specified
name.
The object can be a user defined object, map or array. The property name
correspondently must be object property, map key or array index.
@param obj an object to introspect.
@param name a name of the property to check.
@return true if the object has the property and false if it doesn't. | [
"Checks",
"recursively",
"if",
"object",
"or",
"its",
"subobjects",
"has",
"a",
"property",
"with",
"specified",
"name",
"."
] | a8a0c3e5ec58f0663c295aa855c6b3afad2af86a | https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/reflect/RecursiveObjectReader.java#L41-L50 |
156,103 | pip-services3-java/pip-services3-commons-java | src/org/pipservices3/commons/reflect/RecursiveObjectReader.java | RecursiveObjectReader.getProperty | public static Object getProperty(Object obj, String name) {
if (obj == null || name == null)
return null;
String[] names = name.split("\\.");
if (names == null || names.length == 0)
return null;
return performGetProperty(obj, names, 0);
} | java | public static Object getProperty(Object obj, String name) {
if (obj == null || name == null)
return null;
String[] names = name.split("\\.");
if (names == null || names.length == 0)
return null;
return performGetProperty(obj, names, 0);
} | [
"public",
"static",
"Object",
"getProperty",
"(",
"Object",
"obj",
",",
"String",
"name",
")",
"{",
"if",
"(",
"obj",
"==",
"null",
"||",
"name",
"==",
"null",
")",
"return",
"null",
";",
"String",
"[",
"]",
"names",
"=",
"name",
".",
"split",
"(",
... | Recursively gets value of object or its subobjects property specified by its
name.
The object can be a user defined object, map or array. The property name
correspondently must be object property, map key or array index.
@param obj an object to read property from.
@param name a name of the property to get.
@return the property value or null if property doesn't exist or introspection
failed. | [
"Recursively",
"gets",
"value",
"of",
"object",
"or",
"its",
"subobjects",
"property",
"specified",
"by",
"its",
"name",
"."
] | a8a0c3e5ec58f0663c295aa855c6b3afad2af86a | https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/reflect/RecursiveObjectReader.java#L75-L84 |
156,104 | pip-services3-java/pip-services3-commons-java | src/org/pipservices3/commons/reflect/RecursiveObjectReader.java | RecursiveObjectReader.getPropertyNames | public static List<String> getPropertyNames(Object obj) {
List<String> propertyNames = new ArrayList<String>();
if (obj == null) {
return propertyNames;
} else {
List<Object> cycleDetect = new ArrayList<Object>();
performGetPropertyNames(obj, null, propertyNames, cycleDetect);
return propertyNames;
}
} | java | public static List<String> getPropertyNames(Object obj) {
List<String> propertyNames = new ArrayList<String>();
if (obj == null) {
return propertyNames;
} else {
List<Object> cycleDetect = new ArrayList<Object>();
performGetPropertyNames(obj, null, propertyNames, cycleDetect);
return propertyNames;
}
} | [
"public",
"static",
"List",
"<",
"String",
">",
"getPropertyNames",
"(",
"Object",
"obj",
")",
"{",
"List",
"<",
"String",
">",
"propertyNames",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"if",
"(",
"obj",
"==",
"null",
")",
"{",
"re... | Recursively gets names of all properties implemented in specified object and
its subobjects.
The object can be a user defined object, map or array. Returned property name
correspondently are object properties, map keys or array indexes.
@param obj an objec to introspect.
@return a list with property names. | [
"Recursively",
"gets",
"names",
"of",
"all",
"properties",
"implemented",
"in",
"specified",
"object",
"and",
"its",
"subobjects",
"."
] | a8a0c3e5ec58f0663c295aa855c6b3afad2af86a | https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/reflect/RecursiveObjectReader.java#L134-L144 |
156,105 | pip-services3-java/pip-services3-commons-java | src/org/pipservices3/commons/reflect/RecursiveObjectReader.java | RecursiveObjectReader.getProperties | public static Map<String, Object> getProperties(Object obj) {
Map<String, Object> properties = new HashMap<String, Object>();
if (obj == null) {
return properties;
} else {
List<Object> cycleDetect = new ArrayList<Object>();
performGetProperties(obj, null, properties, cycleDetect);
return properties;
}
} | java | public static Map<String, Object> getProperties(Object obj) {
Map<String, Object> properties = new HashMap<String, Object>();
if (obj == null) {
return properties;
} else {
List<Object> cycleDetect = new ArrayList<Object>();
performGetProperties(obj, null, properties, cycleDetect);
return properties;
}
} | [
"public",
"static",
"Map",
"<",
"String",
",",
"Object",
">",
"getProperties",
"(",
"Object",
"obj",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"properties",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"if",
"(",... | Get values of all properties in specified object and its subobjects and
returns them as a map.
The object can be a user defined object, map or array. Returned properties
correspondently are object properties, map key-pairs or array elements with
their indexes.
@param obj an object to get properties from.
@return a map, containing the names of the object's properties and their
values. | [
"Get",
"values",
"of",
"all",
"properties",
"in",
"specified",
"object",
"and",
"its",
"subobjects",
"and",
"returns",
"them",
"as",
"a",
"map",
"."
] | a8a0c3e5ec58f0663c295aa855c6b3afad2af86a | https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/reflect/RecursiveObjectReader.java#L191-L201 |
156,106 | konvergeio/cofoja | src/main/java/com/google/java/contract/core/agent/ContractClassFileTransformer.java | ContractClassFileTransformer.transform | @Override
public byte[] transform(ClassLoader loader, String className,
Class<?> redefinedClass, ProtectionDomain protectionDomain,
byte[] bytecode) {
if (blacklistManager.isIgnored(className)) {
DebugUtils.info("agent", "ignoring " + className);
return null;
}
try {
this.loader = loader;
ContractAnalyzer contracts = analyze(className);
if (contracts == null) {
if (className.endsWith(JavaUtils.HELPER_CLASS_SUFFIX)) {
DebugUtils.info("agent", "adding source info to " + className);
return instrumentWithDebug(bytecode);
} else {
return null;
}
} else {
DebugUtils.info("agent", "adding contracts to " + className);
return instrumentWithContracts(bytecode, contracts);
}
} catch (Throwable e) {
DebugUtils.err("agent", "while instrumenting " + className, e);
/* Not reached. */
throw new RuntimeException(e);
}
} | java | @Override
public byte[] transform(ClassLoader loader, String className,
Class<?> redefinedClass, ProtectionDomain protectionDomain,
byte[] bytecode) {
if (blacklistManager.isIgnored(className)) {
DebugUtils.info("agent", "ignoring " + className);
return null;
}
try {
this.loader = loader;
ContractAnalyzer contracts = analyze(className);
if (contracts == null) {
if (className.endsWith(JavaUtils.HELPER_CLASS_SUFFIX)) {
DebugUtils.info("agent", "adding source info to " + className);
return instrumentWithDebug(bytecode);
} else {
return null;
}
} else {
DebugUtils.info("agent", "adding contracts to " + className);
return instrumentWithContracts(bytecode, contracts);
}
} catch (Throwable e) {
DebugUtils.err("agent", "while instrumenting " + className, e);
/* Not reached. */
throw new RuntimeException(e);
}
} | [
"@",
"Override",
"public",
"byte",
"[",
"]",
"transform",
"(",
"ClassLoader",
"loader",
",",
"String",
"className",
",",
"Class",
"<",
"?",
">",
"redefinedClass",
",",
"ProtectionDomain",
"protectionDomain",
",",
"byte",
"[",
"]",
"bytecode",
")",
"{",
"if",... | Instruments the specified class, if necessary. | [
"Instruments",
"the",
"specified",
"class",
"if",
"necessary",
"."
] | 6ded58fa05eb5bf85f16353c8dd4c70bee59121a | https://github.com/konvergeio/cofoja/blob/6ded58fa05eb5bf85f16353c8dd4c70bee59121a/src/main/java/com/google/java/contract/core/agent/ContractClassFileTransformer.java#L256-L283 |
156,107 | konvergeio/cofoja | src/main/java/com/google/java/contract/core/agent/ContractClassFileTransformer.java | ContractClassFileTransformer.transformWithContracts | @Requires({
"bytecode != null",
"contractBytecode != null"
})
@Ensures("result != null")
public byte[] transformWithContracts(byte[] bytecode, byte[] contractBytecode)
throws IllegalClassFormatException {
try {
ContractAnalyzer contracts =
extractContracts(new ClassReader(contractBytecode));
return instrumentWithContracts(bytecode, contracts);
} catch (Throwable t) {
/* If the class file contains errors, ASM will just crash. */
IllegalClassFormatException e = new IllegalClassFormatException();
e.initCause(t);
throw e;
}
} | java | @Requires({
"bytecode != null",
"contractBytecode != null"
})
@Ensures("result != null")
public byte[] transformWithContracts(byte[] bytecode, byte[] contractBytecode)
throws IllegalClassFormatException {
try {
ContractAnalyzer contracts =
extractContracts(new ClassReader(contractBytecode));
return instrumentWithContracts(bytecode, contracts);
} catch (Throwable t) {
/* If the class file contains errors, ASM will just crash. */
IllegalClassFormatException e = new IllegalClassFormatException();
e.initCause(t);
throw e;
}
} | [
"@",
"Requires",
"(",
"{",
"\"bytecode != null\"",
",",
"\"contractBytecode != null\"",
"}",
")",
"@",
"Ensures",
"(",
"\"result != null\"",
")",
"public",
"byte",
"[",
"]",
"transformWithContracts",
"(",
"byte",
"[",
"]",
"bytecode",
",",
"byte",
"[",
"]",
"c... | Instruments the specified class with contracts. | [
"Instruments",
"the",
"specified",
"class",
"with",
"contracts",
"."
] | 6ded58fa05eb5bf85f16353c8dd4c70bee59121a | https://github.com/konvergeio/cofoja/blob/6ded58fa05eb5bf85f16353c8dd4c70bee59121a/src/main/java/com/google/java/contract/core/agent/ContractClassFileTransformer.java#L288-L305 |
156,108 | konvergeio/cofoja | src/main/java/com/google/java/contract/core/agent/ContractClassFileTransformer.java | ContractClassFileTransformer.transformWithDebug | @Requires("bytecode != null")
@Ensures("result != null")
public byte[] transformWithDebug(byte[] bytecode)
throws IllegalClassFormatException {
try {
return instrumentWithDebug(bytecode);
} catch (Throwable t) {
/* If the class file contains errors, ASM will just crash. */
IllegalClassFormatException e = new IllegalClassFormatException();
e.initCause(t);
throw e;
}
} | java | @Requires("bytecode != null")
@Ensures("result != null")
public byte[] transformWithDebug(byte[] bytecode)
throws IllegalClassFormatException {
try {
return instrumentWithDebug(bytecode);
} catch (Throwable t) {
/* If the class file contains errors, ASM will just crash. */
IllegalClassFormatException e = new IllegalClassFormatException();
e.initCause(t);
throw e;
}
} | [
"@",
"Requires",
"(",
"\"bytecode != null\"",
")",
"@",
"Ensures",
"(",
"\"result != null\"",
")",
"public",
"byte",
"[",
"]",
"transformWithDebug",
"(",
"byte",
"[",
"]",
"bytecode",
")",
"throws",
"IllegalClassFormatException",
"{",
"try",
"{",
"return",
"inst... | Instruments the specified class with debug information. | [
"Instruments",
"the",
"specified",
"class",
"with",
"debug",
"information",
"."
] | 6ded58fa05eb5bf85f16353c8dd4c70bee59121a | https://github.com/konvergeio/cofoja/blob/6ded58fa05eb5bf85f16353c8dd4c70bee59121a/src/main/java/com/google/java/contract/core/agent/ContractClassFileTransformer.java#L310-L322 |
156,109 | konvergeio/cofoja | src/main/java/com/google/java/contract/core/agent/ContractClassFileTransformer.java | ContractClassFileTransformer.analyze | @Requires("ClassName.isBinaryName(className)")
protected ContractAnalyzer analyze(String className)
throws IOException {
/* Skip helper classes. */
if (className.endsWith(JavaUtils.HELPER_CLASS_SUFFIX)) {
return null;
}
/* Skip interfaces. */
String helperFileName = className + JavaUtils.HELPER_CLASS_SUFFIX
+ Kind.CLASS.extension;
if (JavaUtils.resourceExists(loader, helperFileName)) {
return null;
}
/* Try to get contracts class file. */
InputStream contractStream =
JavaUtils.getContractClassInputStream(loader, className);
if (contractStream == null) {
return null;
}
return extractContracts(new ClassReader(contractStream));
} | java | @Requires("ClassName.isBinaryName(className)")
protected ContractAnalyzer analyze(String className)
throws IOException {
/* Skip helper classes. */
if (className.endsWith(JavaUtils.HELPER_CLASS_SUFFIX)) {
return null;
}
/* Skip interfaces. */
String helperFileName = className + JavaUtils.HELPER_CLASS_SUFFIX
+ Kind.CLASS.extension;
if (JavaUtils.resourceExists(loader, helperFileName)) {
return null;
}
/* Try to get contracts class file. */
InputStream contractStream =
JavaUtils.getContractClassInputStream(loader, className);
if (contractStream == null) {
return null;
}
return extractContracts(new ClassReader(contractStream));
} | [
"@",
"Requires",
"(",
"\"ClassName.isBinaryName(className)\"",
")",
"protected",
"ContractAnalyzer",
"analyze",
"(",
"String",
"className",
")",
"throws",
"IOException",
"{",
"/* Skip helper classes. */",
"if",
"(",
"className",
".",
"endsWith",
"(",
"JavaUtils",
".",
... | Extracts contract methods for the specified class, if necessary.
@param className the class name
@return the extracted contracts or {@code null} if the class has
none and should not be instrumented | [
"Extracts",
"contract",
"methods",
"for",
"the",
"specified",
"class",
"if",
"necessary",
"."
] | 6ded58fa05eb5bf85f16353c8dd4c70bee59121a | https://github.com/konvergeio/cofoja/blob/6ded58fa05eb5bf85f16353c8dd4c70bee59121a/src/main/java/com/google/java/contract/core/agent/ContractClassFileTransformer.java#L331-L354 |
156,110 | konvergeio/cofoja | src/main/java/com/google/java/contract/core/agent/ContractClassFileTransformer.java | ContractClassFileTransformer.extractContracts | @Requires("reader != null")
protected ContractAnalyzer extractContracts(ClassReader reader) {
ContractAnalyzer contractAnalyzer = new ContractAnalyzer();
reader.accept(contractAnalyzer, ClassReader.EXPAND_FRAMES);
return contractAnalyzer;
} | java | @Requires("reader != null")
protected ContractAnalyzer extractContracts(ClassReader reader) {
ContractAnalyzer contractAnalyzer = new ContractAnalyzer();
reader.accept(contractAnalyzer, ClassReader.EXPAND_FRAMES);
return contractAnalyzer;
} | [
"@",
"Requires",
"(",
"\"reader != null\"",
")",
"protected",
"ContractAnalyzer",
"extractContracts",
"(",
"ClassReader",
"reader",
")",
"{",
"ContractAnalyzer",
"contractAnalyzer",
"=",
"new",
"ContractAnalyzer",
"(",
")",
";",
"reader",
".",
"accept",
"(",
"contra... | Processes the specified reader and returns extracted contracts. | [
"Processes",
"the",
"specified",
"reader",
"and",
"returns",
"extracted",
"contracts",
"."
] | 6ded58fa05eb5bf85f16353c8dd4c70bee59121a | https://github.com/konvergeio/cofoja/blob/6ded58fa05eb5bf85f16353c8dd4c70bee59121a/src/main/java/com/google/java/contract/core/agent/ContractClassFileTransformer.java#L359-L364 |
156,111 | konvergeio/cofoja | src/main/java/com/google/java/contract/core/agent/ContractClassFileTransformer.java | ContractClassFileTransformer.instrumentWithDebug | @Requires("bytecode != null")
@Ensures("result != null")
private byte[] instrumentWithDebug(byte[] bytecode) {
ClassReader reader = new ClassReader(bytecode);
ClassWriter writer = new NonLoadingClassWriter(reader, 0);
reader.accept(new HelperClassAdapter(writer), ClassReader.EXPAND_FRAMES);
return writer.toByteArray();
} | java | @Requires("bytecode != null")
@Ensures("result != null")
private byte[] instrumentWithDebug(byte[] bytecode) {
ClassReader reader = new ClassReader(bytecode);
ClassWriter writer = new NonLoadingClassWriter(reader, 0);
reader.accept(new HelperClassAdapter(writer), ClassReader.EXPAND_FRAMES);
return writer.toByteArray();
} | [
"@",
"Requires",
"(",
"\"bytecode != null\"",
")",
"@",
"Ensures",
"(",
"\"result != null\"",
")",
"private",
"byte",
"[",
"]",
"instrumentWithDebug",
"(",
"byte",
"[",
"]",
"bytecode",
")",
"{",
"ClassReader",
"reader",
"=",
"new",
"ClassReader",
"(",
"byteco... | Instruments the passed class file so that it contains debug
information extraction from annotations. | [
"Instruments",
"the",
"passed",
"class",
"file",
"so",
"that",
"it",
"contains",
"debug",
"information",
"extraction",
"from",
"annotations",
"."
] | 6ded58fa05eb5bf85f16353c8dd4c70bee59121a | https://github.com/konvergeio/cofoja/blob/6ded58fa05eb5bf85f16353c8dd4c70bee59121a/src/main/java/com/google/java/contract/core/agent/ContractClassFileTransformer.java#L399-L406 |
156,112 | PureSolTechnologies/parsers | parsers/src/main/java/com/puresoltechnologies/parsers/parser/lr/LALR1ItemSetCollection.java | LALR1ItemSetCollection.calculateLR0KernelItemSets | private void calculateLR0KernelItemSets() {
for (int stateId = 0; stateId < lr0ItemSetCollection.getStateNumber(); stateId++) {
LR0ItemSet lr0ItemSet = lr0ItemSetCollection.getItemSet(stateId);
Set<LR1Item> lr1Items = new LinkedHashSet<LR1Item>();
for (LR0Item lr0Item : lr0ItemSet.getKernelItems()) {
LR1Item lr1Item = new LR1Item(lr0Item.getProduction(),
lr0Item.getPosition(), DUMMY_TERMINAL);
lr1Items.add(lr1Item);
}
itemSetCollection.add(new LR1ItemSet(lr1Items));
}
} | java | private void calculateLR0KernelItemSets() {
for (int stateId = 0; stateId < lr0ItemSetCollection.getStateNumber(); stateId++) {
LR0ItemSet lr0ItemSet = lr0ItemSetCollection.getItemSet(stateId);
Set<LR1Item> lr1Items = new LinkedHashSet<LR1Item>();
for (LR0Item lr0Item : lr0ItemSet.getKernelItems()) {
LR1Item lr1Item = new LR1Item(lr0Item.getProduction(),
lr0Item.getPosition(), DUMMY_TERMINAL);
lr1Items.add(lr1Item);
}
itemSetCollection.add(new LR1ItemSet(lr1Items));
}
} | [
"private",
"void",
"calculateLR0KernelItemSets",
"(",
")",
"{",
"for",
"(",
"int",
"stateId",
"=",
"0",
";",
"stateId",
"<",
"lr0ItemSetCollection",
".",
"getStateNumber",
"(",
")",
";",
"stateId",
"++",
")",
"{",
"LR0ItemSet",
"lr0ItemSet",
"=",
"lr0ItemSetCo... | This method takes all item sets from LR0StateTransitionGraph and makes
them to a LR1ItemSet containing only kernel items. | [
"This",
"method",
"takes",
"all",
"item",
"sets",
"from",
"LR0StateTransitionGraph",
"and",
"makes",
"them",
"to",
"a",
"LR1ItemSet",
"containing",
"only",
"kernel",
"items",
"."
] | 61077223b90d3768ff9445ae13036343c98b63cd | https://github.com/PureSolTechnologies/parsers/blob/61077223b90d3768ff9445ae13036343c98b63cd/parsers/src/main/java/com/puresoltechnologies/parsers/parser/lr/LALR1ItemSetCollection.java#L70-L81 |
156,113 | bushidowallet/bushido-java-service | bushido-service-lib/src/main/java/com/bccapi/bitlib/util/HashUtils.java | HashUtils.addressHash | public static synchronized byte[] addressHash(byte[] pubkeyBytes) {
try {
byte[] sha256 = MessageDigest.getInstance(SHA256).digest(pubkeyBytes);
byte[] out = new byte[20];
ripeMD160.update(sha256, 0, sha256.length);
ripeMD160.doFinal(out, 0); // This also resets the hash function for
// next use
return out;
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e); // Cannot happen.
}
} | java | public static synchronized byte[] addressHash(byte[] pubkeyBytes) {
try {
byte[] sha256 = MessageDigest.getInstance(SHA256).digest(pubkeyBytes);
byte[] out = new byte[20];
ripeMD160.update(sha256, 0, sha256.length);
ripeMD160.doFinal(out, 0); // This also resets the hash function for
// next use
return out;
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e); // Cannot happen.
}
} | [
"public",
"static",
"synchronized",
"byte",
"[",
"]",
"addressHash",
"(",
"byte",
"[",
"]",
"pubkeyBytes",
")",
"{",
"try",
"{",
"byte",
"[",
"]",
"sha256",
"=",
"MessageDigest",
".",
"getInstance",
"(",
"SHA256",
")",
".",
"digest",
"(",
"pubkeyBytes",
... | Calculate the RipeMd160 value of the SHA-256 of an array of bytes. This is
how a Bitcoin address is derived from public key bytes.
@param pubkeyBytes
A Bitcoin public key as an array of bytes.
@return The Bitcoin address as an array of bytes. | [
"Calculate",
"the",
"RipeMd160",
"value",
"of",
"the",
"SHA",
"-",
"256",
"of",
"an",
"array",
"of",
"bytes",
".",
"This",
"is",
"how",
"a",
"Bitcoin",
"address",
"is",
"derived",
"from",
"public",
"key",
"bytes",
"."
] | e1a0157527e57459b509718044d2df44084876a2 | https://github.com/bushidowallet/bushido-java-service/blob/e1a0157527e57459b509718044d2df44084876a2/bushido-service-lib/src/main/java/com/bccapi/bitlib/util/HashUtils.java#L95-L106 |
156,114 | PureSolTechnologies/parsers | parsers/src/main/java/com/puresoltechnologies/parsers/parser/functions/First.java | First.initFirstMapForGrammarProductions | private void initFirstMapForGrammarProductions() {
for (Production production : grammar.getProductions().getList()) {
if (!firstGrammar.containsKey(production.getName())) {
firstGrammar.put(production.getName(), new LinkedHashSet<Terminal>());
}
}
} | java | private void initFirstMapForGrammarProductions() {
for (Production production : grammar.getProductions().getList()) {
if (!firstGrammar.containsKey(production.getName())) {
firstGrammar.put(production.getName(), new LinkedHashSet<Terminal>());
}
}
} | [
"private",
"void",
"initFirstMapForGrammarProductions",
"(",
")",
"{",
"for",
"(",
"Production",
"production",
":",
"grammar",
".",
"getProductions",
"(",
")",
".",
"getList",
"(",
")",
")",
"{",
"if",
"(",
"!",
"firstGrammar",
".",
"containsKey",
"(",
"prod... | Initializes the first map for data input. | [
"Initializes",
"the",
"first",
"map",
"for",
"data",
"input",
"."
] | 61077223b90d3768ff9445ae13036343c98b63cd | https://github.com/PureSolTechnologies/parsers/blob/61077223b90d3768ff9445ae13036343c98b63cd/parsers/src/main/java/com/puresoltechnologies/parsers/parser/functions/First.java#L74-L80 |
156,115 | PureSolTechnologies/parsers | parsers/src/main/java/com/puresoltechnologies/parsers/parser/functions/First.java | First.get | public Set<Terminal> get(Construction construction) {
if (construction.isTerminal()) {
Set<Terminal> result = new LinkedHashSet<Terminal>();
result.add((Terminal) construction);
return result;
}
return firstGrammar.get(construction.getName());
} | java | public Set<Terminal> get(Construction construction) {
if (construction.isTerminal()) {
Set<Terminal> result = new LinkedHashSet<Terminal>();
result.add((Terminal) construction);
return result;
}
return firstGrammar.get(construction.getName());
} | [
"public",
"Set",
"<",
"Terminal",
">",
"get",
"(",
"Construction",
"construction",
")",
"{",
"if",
"(",
"construction",
".",
"isTerminal",
"(",
")",
")",
"{",
"Set",
"<",
"Terminal",
">",
"result",
"=",
"new",
"LinkedHashSet",
"<",
"Terminal",
">",
"(",
... | This method returns the first set for a specified construction.
This method contains rule 1 from Dragon Book:
1) Wenn X ein Terminal ist, ist FIRST(X) = (X).
@param construction
is the construction to get the firsts from.
@return A {@link Set} of {@link Terminal}s is returned. | [
"This",
"method",
"returns",
"the",
"first",
"set",
"for",
"a",
"specified",
"construction",
"."
] | 61077223b90d3768ff9445ae13036343c98b63cd | https://github.com/PureSolTechnologies/parsers/blob/61077223b90d3768ff9445ae13036343c98b63cd/parsers/src/main/java/com/puresoltechnologies/parsers/parser/functions/First.java#L145-L152 |
156,116 | PureSolTechnologies/parsers | parsers/src/main/java/com/puresoltechnologies/parsers/parser/packrat/MemoEntry.java | MemoEntry.success | static MemoEntry success(int deltaPosition, int deltaLine, ParseTreeNode tree) {
return new MemoEntry(deltaPosition, deltaLine, tree);
} | java | static MemoEntry success(int deltaPosition, int deltaLine, ParseTreeNode tree) {
return new MemoEntry(deltaPosition, deltaLine, tree);
} | [
"static",
"MemoEntry",
"success",
"(",
"int",
"deltaPosition",
",",
"int",
"deltaLine",
",",
"ParseTreeNode",
"tree",
")",
"{",
"return",
"new",
"MemoEntry",
"(",
"deltaPosition",
",",
"deltaLine",
",",
"tree",
")",
";",
"}"
] | Creates a simple successs memo entry.
@param deltaPosition
@param deltaId
@param deltaLine
@param tree
@return | [
"Creates",
"a",
"simple",
"successs",
"memo",
"entry",
"."
] | 61077223b90d3768ff9445ae13036343c98b63cd | https://github.com/PureSolTechnologies/parsers/blob/61077223b90d3768ff9445ae13036343c98b63cd/parsers/src/main/java/com/puresoltechnologies/parsers/parser/packrat/MemoEntry.java#L28-L30 |
156,117 | huahin/huahin-core | src/main/java/org/huahinframework/core/util/ObjectUtil.java | ObjectUtil.primitive2Hadoop | public static HadoopObject primitive2Hadoop(Object object) {
if (object == null) {
return new HadoopObject(NULL, NullWritable.get());
}
if (object instanceof Byte) {
return new HadoopObject(BYTE, new ByteWritable((Byte) object));
} else if (object instanceof Integer) {
return new HadoopObject(INTEGER, new IntWritable((Integer) object));
} else if (object instanceof Long) {
return new HadoopObject(LONG, new LongWritable((Long) object));
} else if (object instanceof Double) {
return new HadoopObject(DOUBLE, new DoubleWritable((Double) object));
} else if (object instanceof Float) {
return new HadoopObject(FLOAT, new FloatWritable((Float) object));
} else if (object instanceof Boolean) {
return new HadoopObject(BOOLEAN, new BooleanWritable((Boolean) object));
} else if (object instanceof String) {
return new HadoopObject(STRING, new Text((String) object));
} else if (object.getClass().isArray()) {
return arrayPrimitive2Hadoop(object);
} else if (object instanceof Collection<?>) {
Collection<?> collection = (Collection<?>) object;
return arrayPrimitive2Hadoop(collection.toArray());
} else if (object instanceof Map<?, ?>) {
Map<?, ?> map = (Map<?, ?>) object;
if (map.size() == 0) {
throw new ClassCastException("object not found");
}
MapWritable mapWritable = new MapWritable();
for (Entry<?, ?> entry : map.entrySet()) {
mapWritable.put(primitive2Hadoop(entry.getKey()).getObject(),
primitive2Hadoop(entry.getValue()).getObject());
}
return new HadoopObject(MAP, mapWritable);
}
throw new ClassCastException("cast object not found");
} | java | public static HadoopObject primitive2Hadoop(Object object) {
if (object == null) {
return new HadoopObject(NULL, NullWritable.get());
}
if (object instanceof Byte) {
return new HadoopObject(BYTE, new ByteWritable((Byte) object));
} else if (object instanceof Integer) {
return new HadoopObject(INTEGER, new IntWritable((Integer) object));
} else if (object instanceof Long) {
return new HadoopObject(LONG, new LongWritable((Long) object));
} else if (object instanceof Double) {
return new HadoopObject(DOUBLE, new DoubleWritable((Double) object));
} else if (object instanceof Float) {
return new HadoopObject(FLOAT, new FloatWritable((Float) object));
} else if (object instanceof Boolean) {
return new HadoopObject(BOOLEAN, new BooleanWritable((Boolean) object));
} else if (object instanceof String) {
return new HadoopObject(STRING, new Text((String) object));
} else if (object.getClass().isArray()) {
return arrayPrimitive2Hadoop(object);
} else if (object instanceof Collection<?>) {
Collection<?> collection = (Collection<?>) object;
return arrayPrimitive2Hadoop(collection.toArray());
} else if (object instanceof Map<?, ?>) {
Map<?, ?> map = (Map<?, ?>) object;
if (map.size() == 0) {
throw new ClassCastException("object not found");
}
MapWritable mapWritable = new MapWritable();
for (Entry<?, ?> entry : map.entrySet()) {
mapWritable.put(primitive2Hadoop(entry.getKey()).getObject(),
primitive2Hadoop(entry.getValue()).getObject());
}
return new HadoopObject(MAP, mapWritable);
}
throw new ClassCastException("cast object not found");
} | [
"public",
"static",
"HadoopObject",
"primitive2Hadoop",
"(",
"Object",
"object",
")",
"{",
"if",
"(",
"object",
"==",
"null",
")",
"{",
"return",
"new",
"HadoopObject",
"(",
"NULL",
",",
"NullWritable",
".",
"get",
"(",
")",
")",
";",
"}",
"if",
"(",
"... | Convert the HadoopObject from Java primitive.
@param object Java primitive object
@return HadoopObject | [
"Convert",
"the",
"HadoopObject",
"from",
"Java",
"primitive",
"."
] | a87921b5a12be92a822f753c075ab2431036e6f5 | https://github.com/huahin/huahin-core/blob/a87921b5a12be92a822f753c075ab2431036e6f5/src/main/java/org/huahinframework/core/util/ObjectUtil.java#L204-L244 |
156,118 | huahin/huahin-core | src/main/java/org/huahinframework/core/util/ObjectUtil.java | ObjectUtil.typeCompareTo | public static int typeCompareTo(Writable one, Writable other) {
PrimitiveObject noOne = hadoop2Primitive(one);
PrimitiveObject noOther = hadoop2Primitive(other);
if (noOne.getType() != noOther.getType()) {
return -1;
}
return 0;
} | java | public static int typeCompareTo(Writable one, Writable other) {
PrimitiveObject noOne = hadoop2Primitive(one);
PrimitiveObject noOther = hadoop2Primitive(other);
if (noOne.getType() != noOther.getType()) {
return -1;
}
return 0;
} | [
"public",
"static",
"int",
"typeCompareTo",
"(",
"Writable",
"one",
",",
"Writable",
"other",
")",
"{",
"PrimitiveObject",
"noOne",
"=",
"hadoop2Primitive",
"(",
"one",
")",
";",
"PrimitiveObject",
"noOther",
"=",
"hadoop2Primitive",
"(",
"other",
")",
";",
"i... | Compare the type Writable.
@param one the original object
@param other the object to be compared.
@return if 0, are equal. | [
"Compare",
"the",
"type",
"Writable",
"."
] | a87921b5a12be92a822f753c075ab2431036e6f5 | https://github.com/huahin/huahin-core/blob/a87921b5a12be92a822f753c075ab2431036e6f5/src/main/java/org/huahinframework/core/util/ObjectUtil.java#L339-L347 |
156,119 | dbracewell/hermes | hermes-core/src/main/java/com/davidbracewell/hermes/lexicon/LexiconSpec.java | LexiconSpec.create | public Lexicon create() throws Exception {
Lexicon lexicon = new TrieLexicon(caseSensitive, probabilistic, tagAttribute);
if (resource != null) {
String base = resource.baseName().replaceFirst("\\.[^\\.]*$", "");
try (CSVReader reader = CSV.builder().removeEmptyCells().reader(resource)) {
reader.forEach(row -> {
if (row.size() > 0) {
String lemma = row.get(0);
double probability = 1d;
Tag tag = null;
SerializablePredicate<HString> constraint = null;
int nc = 1;
if (tagAttribute != null && this.tag != null) {
tag = Cast.as(this.tag);
} else if (row.size() > nc && tagAttribute != null && !useResourceNameAsTag) {
tag = tagAttribute.getValueType().decode(row.get(nc));
if (tag == null) {
log.warn("{0} is an invalid {1}, skipping entry {2}.", row.get(nc), tagAttribute.name(), row);
return;
}
nc++;
} else if (tagAttribute != null) {
tag = tagAttribute.getValueType().decode(base);
Preconditions.checkNotNull(tag, base + " is an invalid tag.");
}
if (probabilistic && row.size() > nc && Doubles.tryParse(row.get(nc)) != null) {
probability = Double.parseDouble(row.get(nc));
nc++;
}
if (hasConstraints && row.size() > nc) {
try {
constraint = QueryToPredicate.parse(row.get(nc));
} catch (ParseException e) {
if (tag == null) {
log.warn("Error parsing constraint {0}, skipping entry {1}.", row.get(nc), row);
return;
}
}
}
lexicon.add(new LexiconEntry(lemma, probability, constraint, tag));
}
});
}
}
return lexicon;
} | java | public Lexicon create() throws Exception {
Lexicon lexicon = new TrieLexicon(caseSensitive, probabilistic, tagAttribute);
if (resource != null) {
String base = resource.baseName().replaceFirst("\\.[^\\.]*$", "");
try (CSVReader reader = CSV.builder().removeEmptyCells().reader(resource)) {
reader.forEach(row -> {
if (row.size() > 0) {
String lemma = row.get(0);
double probability = 1d;
Tag tag = null;
SerializablePredicate<HString> constraint = null;
int nc = 1;
if (tagAttribute != null && this.tag != null) {
tag = Cast.as(this.tag);
} else if (row.size() > nc && tagAttribute != null && !useResourceNameAsTag) {
tag = tagAttribute.getValueType().decode(row.get(nc));
if (tag == null) {
log.warn("{0} is an invalid {1}, skipping entry {2}.", row.get(nc), tagAttribute.name(), row);
return;
}
nc++;
} else if (tagAttribute != null) {
tag = tagAttribute.getValueType().decode(base);
Preconditions.checkNotNull(tag, base + " is an invalid tag.");
}
if (probabilistic && row.size() > nc && Doubles.tryParse(row.get(nc)) != null) {
probability = Double.parseDouble(row.get(nc));
nc++;
}
if (hasConstraints && row.size() > nc) {
try {
constraint = QueryToPredicate.parse(row.get(nc));
} catch (ParseException e) {
if (tag == null) {
log.warn("Error parsing constraint {0}, skipping entry {1}.", row.get(nc), row);
return;
}
}
}
lexicon.add(new LexiconEntry(lemma, probability, constraint, tag));
}
});
}
}
return lexicon;
} | [
"public",
"Lexicon",
"create",
"(",
")",
"throws",
"Exception",
"{",
"Lexicon",
"lexicon",
"=",
"new",
"TrieLexicon",
"(",
"caseSensitive",
",",
"probabilistic",
",",
"tagAttribute",
")",
";",
"if",
"(",
"resource",
"!=",
"null",
")",
"{",
"String",
"base",
... | Create lexicon.
@return the lexicon
@throws Exception the exception | [
"Create",
"lexicon",
"."
] | 9ebefe7ad5dea1b731ae6931a30771eb75325ea3 | https://github.com/dbracewell/hermes/blob/9ebefe7ad5dea1b731ae6931a30771eb75325ea3/hermes-core/src/main/java/com/davidbracewell/hermes/lexicon/LexiconSpec.java#L94-L146 |
156,120 | dihedron/dihedron-commons | src/main/java/org/dihedron/patterns/activities/engine/javaee/AsynchronousBeanEngine.java | AsynchronousBeanEngine.submit | @Override
protected Future<ActivityData> submit(ActivityCallable callable) {
try {
if(getEjb() == null) {
logger.info("locating AsynchronousBean EJB through service locator");
setEjb(ServiceLocator.getService(asynchBeanName, AsynchronousBean.class));
} else {
logger.info("asynchronousBean EJB correctly initialized through dependency injection");
}
return getEjb().submit(callable);
} catch(Exception e) {
logger.error("error in the AsynchronousBean service locator lookup", e);
}
return null;
} | java | @Override
protected Future<ActivityData> submit(ActivityCallable callable) {
try {
if(getEjb() == null) {
logger.info("locating AsynchronousBean EJB through service locator");
setEjb(ServiceLocator.getService(asynchBeanName, AsynchronousBean.class));
} else {
logger.info("asynchronousBean EJB correctly initialized through dependency injection");
}
return getEjb().submit(callable);
} catch(Exception e) {
logger.error("error in the AsynchronousBean service locator lookup", e);
}
return null;
} | [
"@",
"Override",
"protected",
"Future",
"<",
"ActivityData",
">",
"submit",
"(",
"ActivityCallable",
"callable",
")",
"{",
"try",
"{",
"if",
"(",
"getEjb",
"(",
")",
"==",
"null",
")",
"{",
"logger",
".",
"info",
"(",
"\"locating AsynchronousBean EJB through s... | Assigns the given activity to a worker thread in the JavaEE application
server, returning the task's Future object.
@param callable
the callable object for the {@code Activity} to be executed asynchronously.
@return
the activity's {@code Future} object, for result retrieval.
@see
org.dihedron.patterns.activities.concurrent.ActivityExecutor#submit(org.dihedron.patterns.activities.Activity) | [
"Assigns",
"the",
"given",
"activity",
"to",
"a",
"worker",
"thread",
"in",
"the",
"JavaEE",
"application",
"server",
"returning",
"the",
"task",
"s",
"Future",
"object",
"."
] | a5194cdaa0d6417ef4aade6ea407a1cad6e8458e | https://github.com/dihedron/dihedron-commons/blob/a5194cdaa0d6417ef4aade6ea407a1cad6e8458e/src/main/java/org/dihedron/patterns/activities/engine/javaee/AsynchronousBeanEngine.java#L89-L103 |
156,121 | janus-project/guava.janusproject.io | guava/src/com/google/common/util/concurrent/Futures.java | Futures.rejectionPropagatingRunnable | private static Runnable rejectionPropagatingRunnable(
final AbstractFuture<?> outputFuture,
final Runnable delegateTask,
final Executor delegateExecutor) {
return new Runnable() {
@Override public void run() {
final AtomicBoolean thrownFromDelegate = new AtomicBoolean(true);
try {
delegateExecutor.execute(new Runnable() {
@Override public void run() {
thrownFromDelegate.set(false);
delegateTask.run();
}
});
} catch (RejectedExecutionException e) {
if (thrownFromDelegate.get()) {
// wrap exception?
outputFuture.setException(e);
}
// otherwise it must have been thrown from a transitive call and the delegate runnable
// should have handled it.
}
}
};
} | java | private static Runnable rejectionPropagatingRunnable(
final AbstractFuture<?> outputFuture,
final Runnable delegateTask,
final Executor delegateExecutor) {
return new Runnable() {
@Override public void run() {
final AtomicBoolean thrownFromDelegate = new AtomicBoolean(true);
try {
delegateExecutor.execute(new Runnable() {
@Override public void run() {
thrownFromDelegate.set(false);
delegateTask.run();
}
});
} catch (RejectedExecutionException e) {
if (thrownFromDelegate.get()) {
// wrap exception?
outputFuture.setException(e);
}
// otherwise it must have been thrown from a transitive call and the delegate runnable
// should have handled it.
}
}
};
} | [
"private",
"static",
"Runnable",
"rejectionPropagatingRunnable",
"(",
"final",
"AbstractFuture",
"<",
"?",
">",
"outputFuture",
",",
"final",
"Runnable",
"delegateTask",
",",
"final",
"Executor",
"delegateExecutor",
")",
"{",
"return",
"new",
"Runnable",
"(",
")",
... | Returns a Runnable that will invoke the delegate Runnable on the delegate executor, but if the
task is rejected, it will propagate that rejection to the output future. | [
"Returns",
"a",
"Runnable",
"that",
"will",
"invoke",
"the",
"delegate",
"Runnable",
"on",
"the",
"delegate",
"executor",
"but",
"if",
"the",
"task",
"is",
"rejected",
"it",
"will",
"propagate",
"that",
"rejection",
"to",
"the",
"output",
"future",
"."
] | 1c48fb672c9fdfddf276970570f703fa1115f588 | https://github.com/janus-project/guava.janusproject.io/blob/1c48fb672c9fdfddf276970570f703fa1115f588/guava/src/com/google/common/util/concurrent/Futures.java#L624-L648 |
156,122 | janus-project/guava.janusproject.io | guava/src/com/google/common/util/concurrent/Futures.java | Futures.asAsyncFunction | private static <I, O> AsyncFunction<I, O> asAsyncFunction(
final Function<? super I, ? extends O> function) {
return new AsyncFunction<I, O>() {
@Override public ListenableFuture<O> apply(I input) {
O output = function.apply(input);
return immediateFuture(output);
}
};
} | java | private static <I, O> AsyncFunction<I, O> asAsyncFunction(
final Function<? super I, ? extends O> function) {
return new AsyncFunction<I, O>() {
@Override public ListenableFuture<O> apply(I input) {
O output = function.apply(input);
return immediateFuture(output);
}
};
} | [
"private",
"static",
"<",
"I",
",",
"O",
">",
"AsyncFunction",
"<",
"I",
",",
"O",
">",
"asAsyncFunction",
"(",
"final",
"Function",
"<",
"?",
"super",
"I",
",",
"?",
"extends",
"O",
">",
"function",
")",
"{",
"return",
"new",
"AsyncFunction",
"<",
"... | Wraps the given function as an AsyncFunction. | [
"Wraps",
"the",
"given",
"function",
"as",
"an",
"AsyncFunction",
"."
] | 1c48fb672c9fdfddf276970570f703fa1115f588 | https://github.com/janus-project/guava.janusproject.io/blob/1c48fb672c9fdfddf276970570f703fa1115f588/guava/src/com/google/common/util/concurrent/Futures.java#L756-L764 |
156,123 | pdef/pdef-java | pdef/src/main/java/io/pdef/descriptors/Descriptors.java | Descriptors.findInterfaceDescriptor | @Nullable
public static <T> InterfaceDescriptor<T> findInterfaceDescriptor(final Class<T> cls) {
if (!cls.isInterface()) {
throw new IllegalArgumentException("Interface required, got " + cls);
}
Field field;
try {
field = cls.getField("DESCRIPTOR");
} catch (NoSuchFieldException e) {
throw new IllegalArgumentException("No DESCRIPTOR field in " + cls);
}
if (!InterfaceDescriptor.class.isAssignableFrom(field.getType())) {
throw new IllegalArgumentException("Not an InterfaceDescriptor field, " + field);
}
try {
// Get the static TYPE field.
@SuppressWarnings("unchecked")
InterfaceDescriptor<T> descriptor = (InterfaceDescriptor<T>) field.get(null);
return descriptor;
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
} | java | @Nullable
public static <T> InterfaceDescriptor<T> findInterfaceDescriptor(final Class<T> cls) {
if (!cls.isInterface()) {
throw new IllegalArgumentException("Interface required, got " + cls);
}
Field field;
try {
field = cls.getField("DESCRIPTOR");
} catch (NoSuchFieldException e) {
throw new IllegalArgumentException("No DESCRIPTOR field in " + cls);
}
if (!InterfaceDescriptor.class.isAssignableFrom(field.getType())) {
throw new IllegalArgumentException("Not an InterfaceDescriptor field, " + field);
}
try {
// Get the static TYPE field.
@SuppressWarnings("unchecked")
InterfaceDescriptor<T> descriptor = (InterfaceDescriptor<T>) field.get(null);
return descriptor;
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
} | [
"@",
"Nullable",
"public",
"static",
"<",
"T",
">",
"InterfaceDescriptor",
"<",
"T",
">",
"findInterfaceDescriptor",
"(",
"final",
"Class",
"<",
"T",
">",
"cls",
")",
"{",
"if",
"(",
"!",
"cls",
".",
"isInterface",
"(",
")",
")",
"{",
"throw",
"new",
... | Returns an interface descriptor or throws an IllegalArgumentException. | [
"Returns",
"an",
"interface",
"descriptor",
"or",
"throws",
"an",
"IllegalArgumentException",
"."
] | 7776c44d1aab0f3dbf7267b0c32b8f9282fe6167 | https://github.com/pdef/pdef-java/blob/7776c44d1aab0f3dbf7267b0c32b8f9282fe6167/pdef/src/main/java/io/pdef/descriptors/Descriptors.java#L58-L83 |
156,124 | PureSolTechnologies/versioning | versioning/src/main/java/com/puresoltechnologies/versioning/VersionMath.java | VersionMath.min | public static Version min(Version... versions) {
if (versions.length == 0) {
throw new IllegalArgumentException(
"At least one version needs to be provided for minimum calculation.");
}
Version minimum = versions[0];
for (int index = 1; index < versions.length; ++index) {
Version version = versions[index];
if (minimum.compareTo(version) > 0) {
minimum = version;
}
}
return minimum;
} | java | public static Version min(Version... versions) {
if (versions.length == 0) {
throw new IllegalArgumentException(
"At least one version needs to be provided for minimum calculation.");
}
Version minimum = versions[0];
for (int index = 1; index < versions.length; ++index) {
Version version = versions[index];
if (minimum.compareTo(version) > 0) {
minimum = version;
}
}
return minimum;
} | [
"public",
"static",
"Version",
"min",
"(",
"Version",
"...",
"versions",
")",
"{",
"if",
"(",
"versions",
".",
"length",
"==",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"At least one version needs to be provided for minimum calculation.\"",
")"... | This class returns the minimum version of the provided versions within
the array.
@param versions
is an optional parameter array with additional versions to be
checked for minimum version.
@return A {@link Version} object is returned containing the minimum
version. | [
"This",
"class",
"returns",
"the",
"minimum",
"version",
"of",
"the",
"provided",
"versions",
"within",
"the",
"array",
"."
] | 7e0d8022ba391938f1b419e353de6e99a27db19f | https://github.com/PureSolTechnologies/versioning/blob/7e0d8022ba391938f1b419e353de6e99a27db19f/versioning/src/main/java/com/puresoltechnologies/versioning/VersionMath.java#L21-L34 |
156,125 | PureSolTechnologies/versioning | versioning/src/main/java/com/puresoltechnologies/versioning/VersionMath.java | VersionMath.max | public static Version max(Version... versions) {
if (versions.length == 0) {
throw new IllegalArgumentException(
"At least one version needs to be provided for maximum calculation.");
}
Version maximum = versions[0];
for (int index = 1; index < versions.length; ++index) {
Version version = versions[index];
if (maximum.compareTo(version) < 0) {
maximum = version;
}
}
return maximum;
} | java | public static Version max(Version... versions) {
if (versions.length == 0) {
throw new IllegalArgumentException(
"At least one version needs to be provided for maximum calculation.");
}
Version maximum = versions[0];
for (int index = 1; index < versions.length; ++index) {
Version version = versions[index];
if (maximum.compareTo(version) < 0) {
maximum = version;
}
}
return maximum;
} | [
"public",
"static",
"Version",
"max",
"(",
"Version",
"...",
"versions",
")",
"{",
"if",
"(",
"versions",
".",
"length",
"==",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"At least one version needs to be provided for maximum calculation.\"",
")"... | This class returns the maximum version of the provided versions within
the array.
@param versions
is an optional parameter array with additional versions to be
checked for maximum version.
@return A {@link Version} object is returned containing the maximum
version. | [
"This",
"class",
"returns",
"the",
"maximum",
"version",
"of",
"the",
"provided",
"versions",
"within",
"the",
"array",
"."
] | 7e0d8022ba391938f1b419e353de6e99a27db19f | https://github.com/PureSolTechnologies/versioning/blob/7e0d8022ba391938f1b419e353de6e99a27db19f/versioning/src/main/java/com/puresoltechnologies/versioning/VersionMath.java#L46-L59 |
156,126 | dihedron/dihedron-commons | src/main/java/org/dihedron/patterns/visitor/nodes/AbstractNode.java | AbstractNode.getFieldValue | protected <T> T getFieldValue(Object object, Field field, Class<T> clazz) throws VisitorException {
boolean reprotect = false;
if(object == null) {
return null;
}
try {
if(!field.isAccessible()) {
field.setAccessible(true);
reprotect = true;
}
Object value = field.get(object);
if(value != null) {
logger.trace("field '{}' has value '{}'", field.getName(), value);
return clazz.cast(value);
}
} catch (IllegalArgumentException e) {
logger.error("trying to access field '{}' on invalid object of class '{}'", field.getName(), object.getClass().getSimpleName());
throw new VisitorException("Trying to access field on invalid object", e);
} catch (IllegalAccessException e) {
logger.error("illegal access to class '{}'", object.getClass().getSimpleName());
throw new VisitorException("Illegal access to class", e);
} finally {
if(reprotect) {
field.setAccessible(false);
}
}
return null;
} | java | protected <T> T getFieldValue(Object object, Field field, Class<T> clazz) throws VisitorException {
boolean reprotect = false;
if(object == null) {
return null;
}
try {
if(!field.isAccessible()) {
field.setAccessible(true);
reprotect = true;
}
Object value = field.get(object);
if(value != null) {
logger.trace("field '{}' has value '{}'", field.getName(), value);
return clazz.cast(value);
}
} catch (IllegalArgumentException e) {
logger.error("trying to access field '{}' on invalid object of class '{}'", field.getName(), object.getClass().getSimpleName());
throw new VisitorException("Trying to access field on invalid object", e);
} catch (IllegalAccessException e) {
logger.error("illegal access to class '{}'", object.getClass().getSimpleName());
throw new VisitorException("Illegal access to class", e);
} finally {
if(reprotect) {
field.setAccessible(false);
}
}
return null;
} | [
"protected",
"<",
"T",
">",
"T",
"getFieldValue",
"(",
"Object",
"object",
",",
"Field",
"field",
",",
"Class",
"<",
"T",
">",
"clazz",
")",
"throws",
"VisitorException",
"{",
"boolean",
"reprotect",
"=",
"false",
";",
"if",
"(",
"object",
"==",
"null",
... | Attempts to retrieve the object stored in this node's object field; the
result will be cast to the appropriate class, as per the user's input.
@param object
the object owning the field represented by this node object.s
@param field
the field containing the object represented by this node object.
@param clazz
the class to which to cast the non-null result.
@throws VisitorException
if an error occurs while evaluating the node's value. | [
"Attempts",
"to",
"retrieve",
"the",
"object",
"stored",
"in",
"this",
"node",
"s",
"object",
"field",
";",
"the",
"result",
"will",
"be",
"cast",
"to",
"the",
"appropriate",
"class",
"as",
"per",
"the",
"user",
"s",
"input",
"."
] | a5194cdaa0d6417ef4aade6ea407a1cad6e8458e | https://github.com/dihedron/dihedron-commons/blob/a5194cdaa0d6417ef4aade6ea407a1cad6e8458e/src/main/java/org/dihedron/patterns/visitor/nodes/AbstractNode.java#L76-L103 |
156,127 | pressgang-ccms/PressGangCCMSDatasourceProviders | rest-provider/src/main/java/org/jboss/pressgang/ccms/provider/RESTDataProvider.java | RESTDataProvider.cleanEntityForSave | protected void cleanEntityForSave(final RESTBaseElementV1<?> entity) throws InvocationTargetException, IllegalAccessException {
if (entity == null) return;
for (final Method method : entity.getClass().getMethods()) {
// If the method isn't a getter or returns void then skip it
if (!method.getName().startsWith("get") || method.getReturnType().equals(Void.TYPE)) continue;
// An entity might have
if (isCollectionClass(method.getReturnType())) {
cleanCollectionForSave((RESTBaseEntityCollectionV1<?, ?, ?>) method.invoke(entity), true);
} else if (isEntityClass(method.getReturnType())) {
cleanEntityForSave((RESTBaseElementWithConfiguredParametersV1) method.invoke(entity));
}
}
} | java | protected void cleanEntityForSave(final RESTBaseElementV1<?> entity) throws InvocationTargetException, IllegalAccessException {
if (entity == null) return;
for (final Method method : entity.getClass().getMethods()) {
// If the method isn't a getter or returns void then skip it
if (!method.getName().startsWith("get") || method.getReturnType().equals(Void.TYPE)) continue;
// An entity might have
if (isCollectionClass(method.getReturnType())) {
cleanCollectionForSave((RESTBaseEntityCollectionV1<?, ?, ?>) method.invoke(entity), true);
} else if (isEntityClass(method.getReturnType())) {
cleanEntityForSave((RESTBaseElementWithConfiguredParametersV1) method.invoke(entity));
}
}
} | [
"protected",
"void",
"cleanEntityForSave",
"(",
"final",
"RESTBaseElementV1",
"<",
"?",
">",
"entity",
")",
"throws",
"InvocationTargetException",
",",
"IllegalAccessException",
"{",
"if",
"(",
"entity",
"==",
"null",
")",
"return",
";",
"for",
"(",
"final",
"Me... | Cleans the entity and it's collections to remove any data that doesn't need to be sent to the server.
@param entity The entity to be cleaned.
@throws InvocationTargetException
@throws IllegalAccessException | [
"Cleans",
"the",
"entity",
"and",
"it",
"s",
"collections",
"to",
"remove",
"any",
"data",
"that",
"doesn",
"t",
"need",
"to",
"be",
"sent",
"to",
"the",
"server",
"."
] | e47588adad0dcd55608b197b37825a512bc8fd25 | https://github.com/pressgang-ccms/PressGangCCMSDatasourceProviders/blob/e47588adad0dcd55608b197b37825a512bc8fd25/rest-provider/src/main/java/org/jboss/pressgang/ccms/provider/RESTDataProvider.java#L93-L107 |
156,128 | pressgang-ccms/PressGangCCMSDatasourceProviders | rest-provider/src/main/java/org/jboss/pressgang/ccms/provider/RESTDataProvider.java | RESTDataProvider.isCollectionClass | private boolean isCollectionClass(Class<?> clazz) {
if (clazz == RESTBaseEntityUpdateCollectionV1.class || clazz == RESTBaseEntityCollectionV1.class) {
return true;
} else if (clazz.getSuperclass() != null) {
return isCollectionClass(clazz.getSuperclass());
} else {
return false;
}
} | java | private boolean isCollectionClass(Class<?> clazz) {
if (clazz == RESTBaseEntityUpdateCollectionV1.class || clazz == RESTBaseEntityCollectionV1.class) {
return true;
} else if (clazz.getSuperclass() != null) {
return isCollectionClass(clazz.getSuperclass());
} else {
return false;
}
} | [
"private",
"boolean",
"isCollectionClass",
"(",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"if",
"(",
"clazz",
"==",
"RESTBaseEntityUpdateCollectionV1",
".",
"class",
"||",
"clazz",
"==",
"RESTBaseEntityCollectionV1",
".",
"class",
")",
"{",
"return",
"true",
... | Checks if a class is or extends the REST Base Collection class.
@param clazz The class to be checked.
@return True if the class is or extends | [
"Checks",
"if",
"a",
"class",
"is",
"or",
"extends",
"the",
"REST",
"Base",
"Collection",
"class",
"."
] | e47588adad0dcd55608b197b37825a512bc8fd25 | https://github.com/pressgang-ccms/PressGangCCMSDatasourceProviders/blob/e47588adad0dcd55608b197b37825a512bc8fd25/rest-provider/src/main/java/org/jboss/pressgang/ccms/provider/RESTDataProvider.java#L115-L123 |
156,129 | pressgang-ccms/PressGangCCMSDatasourceProviders | rest-provider/src/main/java/org/jboss/pressgang/ccms/provider/RESTDataProvider.java | RESTDataProvider.isEntityClass | private boolean isEntityClass(Class<?> clazz) {
if (clazz == RESTBaseAuditedEntityV1.class) {
return true;
} else if (clazz.getSuperclass() != null) {
return isEntityClass(clazz.getSuperclass());
} else {
return false;
}
} | java | private boolean isEntityClass(Class<?> clazz) {
if (clazz == RESTBaseAuditedEntityV1.class) {
return true;
} else if (clazz.getSuperclass() != null) {
return isEntityClass(clazz.getSuperclass());
} else {
return false;
}
} | [
"private",
"boolean",
"isEntityClass",
"(",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"if",
"(",
"clazz",
"==",
"RESTBaseAuditedEntityV1",
".",
"class",
")",
"{",
"return",
"true",
";",
"}",
"else",
"if",
"(",
"clazz",
".",
"getSuperclass",
"(",
")",
... | Checks if a class is or extends the REST Base Entity class.
@param clazz The class to be checked.
@return True if the class is or extends | [
"Checks",
"if",
"a",
"class",
"is",
"or",
"extends",
"the",
"REST",
"Base",
"Entity",
"class",
"."
] | e47588adad0dcd55608b197b37825a512bc8fd25 | https://github.com/pressgang-ccms/PressGangCCMSDatasourceProviders/blob/e47588adad0dcd55608b197b37825a512bc8fd25/rest-provider/src/main/java/org/jboss/pressgang/ccms/provider/RESTDataProvider.java#L131-L139 |
156,130 | pressgang-ccms/PressGangCCMSDatasourceProviders | rest-provider/src/main/java/org/jboss/pressgang/ccms/provider/RESTDataProvider.java | RESTDataProvider.cleanCollectionForSave | protected void cleanCollectionForSave(final RESTBaseEntityCollectionV1<?, ?, ?> collection,
boolean cleanTopLevel) throws InvocationTargetException,
IllegalAccessException {
if (collection == null) return;
if (cleanTopLevel) {
collection.removeInvalidChangeItemRequests();
}
for (final RESTBaseEntityV1<?> item : collection.returnItems()) {
cleanEntityForSave(item);
}
} | java | protected void cleanCollectionForSave(final RESTBaseEntityCollectionV1<?, ?, ?> collection,
boolean cleanTopLevel) throws InvocationTargetException,
IllegalAccessException {
if (collection == null) return;
if (cleanTopLevel) {
collection.removeInvalidChangeItemRequests();
}
for (final RESTBaseEntityV1<?> item : collection.returnItems()) {
cleanEntityForSave(item);
}
} | [
"protected",
"void",
"cleanCollectionForSave",
"(",
"final",
"RESTBaseEntityCollectionV1",
"<",
"?",
",",
"?",
",",
"?",
">",
"collection",
",",
"boolean",
"cleanTopLevel",
")",
"throws",
"InvocationTargetException",
",",
"IllegalAccessException",
"{",
"if",
"(",
"c... | Cleans a collection and it's entities to remove any items in the collection that don't need to be sent to the server.
@param collection The collection to be cleaned.
@throws InvocationTargetException
@throws IllegalAccessException | [
"Cleans",
"a",
"collection",
"and",
"it",
"s",
"entities",
"to",
"remove",
"any",
"items",
"in",
"the",
"collection",
"that",
"don",
"t",
"need",
"to",
"be",
"sent",
"to",
"the",
"server",
"."
] | e47588adad0dcd55608b197b37825a512bc8fd25 | https://github.com/pressgang-ccms/PressGangCCMSDatasourceProviders/blob/e47588adad0dcd55608b197b37825a512bc8fd25/rest-provider/src/main/java/org/jboss/pressgang/ccms/provider/RESTDataProvider.java#L148-L160 |
156,131 | pressgang-ccms/PressGangCCMSDatasourceProviders | rest-provider/src/main/java/org/jboss/pressgang/ccms/provider/RESTDataProvider.java | RESTDataProvider.getExpansionBranches | protected List<ExpandDataTrunk> getExpansionBranches(final Collection<String> expansionNames) {
if (expansionNames != null) {
final List<ExpandDataTrunk> expandDataTrunks = new ArrayList<ExpandDataTrunk>();
for (final String subExpansionName : expansionNames) {
expandDataTrunks.add(new ExpandDataTrunk(new ExpandDataDetails(subExpansionName)));
}
return expandDataTrunks;
}
return null;
} | java | protected List<ExpandDataTrunk> getExpansionBranches(final Collection<String> expansionNames) {
if (expansionNames != null) {
final List<ExpandDataTrunk> expandDataTrunks = new ArrayList<ExpandDataTrunk>();
for (final String subExpansionName : expansionNames) {
expandDataTrunks.add(new ExpandDataTrunk(new ExpandDataDetails(subExpansionName)));
}
return expandDataTrunks;
}
return null;
} | [
"protected",
"List",
"<",
"ExpandDataTrunk",
">",
"getExpansionBranches",
"(",
"final",
"Collection",
"<",
"String",
">",
"expansionNames",
")",
"{",
"if",
"(",
"expansionNames",
"!=",
"null",
")",
"{",
"final",
"List",
"<",
"ExpandDataTrunk",
">",
"expandDataTr... | Get a list of expansion branches created from a list of names.
@param expansionNames The list of names to create the branches from.
@return The list of expanded branches or null if the input list was null. | [
"Get",
"a",
"list",
"of",
"expansion",
"branches",
"created",
"from",
"a",
"list",
"of",
"names",
"."
] | e47588adad0dcd55608b197b37825a512bc8fd25 | https://github.com/pressgang-ccms/PressGangCCMSDatasourceProviders/blob/e47588adad0dcd55608b197b37825a512bc8fd25/rest-provider/src/main/java/org/jboss/pressgang/ccms/provider/RESTDataProvider.java#L194-L205 |
156,132 | pressgang-ccms/PressGangCCMSDatasourceProviders | rest-provider/src/main/java/org/jboss/pressgang/ccms/provider/RESTDataProvider.java | RESTDataProvider.getExpansion | protected ExpandDataTrunk getExpansion(final String expansionName, final Map<String, Collection<String>> subExpansionNames) {
final ExpandDataTrunk expandData = new ExpandDataTrunk(new ExpandDataDetails(expansionName));
// Add the sub expansions
expandData.setBranches(getExpansionBranches(subExpansionNames));
return expandData;
} | java | protected ExpandDataTrunk getExpansion(final String expansionName, final Map<String, Collection<String>> subExpansionNames) {
final ExpandDataTrunk expandData = new ExpandDataTrunk(new ExpandDataDetails(expansionName));
// Add the sub expansions
expandData.setBranches(getExpansionBranches(subExpansionNames));
return expandData;
} | [
"protected",
"ExpandDataTrunk",
"getExpansion",
"(",
"final",
"String",
"expansionName",
",",
"final",
"Map",
"<",
"String",
",",
"Collection",
"<",
"String",
">",
">",
"subExpansionNames",
")",
"{",
"final",
"ExpandDataTrunk",
"expandData",
"=",
"new",
"ExpandDat... | Create an expansion with sub expansions.
@param expansionName The name of the root expansion.
@param subExpansionNames The list of names to create the branches from.
@return The expansion with the branches set. | [
"Create",
"an",
"expansion",
"with",
"sub",
"expansions",
"."
] | e47588adad0dcd55608b197b37825a512bc8fd25 | https://github.com/pressgang-ccms/PressGangCCMSDatasourceProviders/blob/e47588adad0dcd55608b197b37825a512bc8fd25/rest-provider/src/main/java/org/jboss/pressgang/ccms/provider/RESTDataProvider.java#L241-L246 |
156,133 | pressgang-ccms/PressGangCCMSDatasourceProviders | rest-provider/src/main/java/org/jboss/pressgang/ccms/utils/RESTEntityCache.java | RESTEntityCache.add | public void add(final RESTBaseEntityCollectionV1<?, ?, ?> value, final boolean isRevisions) {
if (value != null && value.getItems() != null) {
for (final RESTBaseEntityCollectionItemV1<?, ?, ?> item : value.getItems()) {
if (item.getItem() != null) {
add(item.getItem(), isRevisions);
}
}
}
} | java | public void add(final RESTBaseEntityCollectionV1<?, ?, ?> value, final boolean isRevisions) {
if (value != null && value.getItems() != null) {
for (final RESTBaseEntityCollectionItemV1<?, ?, ?> item : value.getItems()) {
if (item.getItem() != null) {
add(item.getItem(), isRevisions);
}
}
}
} | [
"public",
"void",
"add",
"(",
"final",
"RESTBaseEntityCollectionV1",
"<",
"?",
",",
"?",
",",
"?",
">",
"value",
",",
"final",
"boolean",
"isRevisions",
")",
"{",
"if",
"(",
"value",
"!=",
"null",
"&&",
"value",
".",
"getItems",
"(",
")",
"!=",
"null",... | Add a collection of entities to the cache.
@param value The collection of entities to be added to the cache.
@param isRevisions Whether or not the collection is a collection of revisions or not. | [
"Add",
"a",
"collection",
"of",
"entities",
"to",
"the",
"cache",
"."
] | e47588adad0dcd55608b197b37825a512bc8fd25 | https://github.com/pressgang-ccms/PressGangCCMSDatasourceProviders/blob/e47588adad0dcd55608b197b37825a512bc8fd25/rest-provider/src/main/java/org/jboss/pressgang/ccms/utils/RESTEntityCache.java#L77-L85 |
156,134 | pressgang-ccms/PressGangCCMSDatasourceProviders | rest-provider/src/main/java/org/jboss/pressgang/ccms/utils/RESTEntityCache.java | RESTEntityCache.add | public void add(final RESTBaseEntityV1<?> value, final Number revision) {
add(value, value.getId(), revision);
} | java | public void add(final RESTBaseEntityV1<?> value, final Number revision) {
add(value, value.getId(), revision);
} | [
"public",
"void",
"add",
"(",
"final",
"RESTBaseEntityV1",
"<",
"?",
">",
"value",
",",
"final",
"Number",
"revision",
")",
"{",
"add",
"(",
"value",
",",
"value",
".",
"getId",
"(",
")",
",",
"revision",
")",
";",
"}"
] | Add a Entity to the cache, where the id should be extracted from the entity.
@param value The entity to be added to the cache.
@param revision The revision of the entity to be cached. | [
"Add",
"a",
"Entity",
"to",
"the",
"cache",
"where",
"the",
"id",
"should",
"be",
"extracted",
"from",
"the",
"entity",
"."
] | e47588adad0dcd55608b197b37825a512bc8fd25 | https://github.com/pressgang-ccms/PressGangCCMSDatasourceProviders/blob/e47588adad0dcd55608b197b37825a512bc8fd25/rest-provider/src/main/java/org/jboss/pressgang/ccms/utils/RESTEntityCache.java#L146-L148 |
156,135 | pressgang-ccms/PressGangCCMSDatasourceProviders | rest-provider/src/main/java/org/jboss/pressgang/ccms/utils/RESTEntityCache.java | RESTEntityCache.buildKey | protected String buildKey(final Class<?> clazz, final String id, final Number revision) {
if (revision != null) {
return clazz.getSimpleName() + "-" + id + "-" + revision;
} else {
return clazz.getSimpleName() + "-" + id;
}
} | java | protected String buildKey(final Class<?> clazz, final String id, final Number revision) {
if (revision != null) {
return clazz.getSimpleName() + "-" + id + "-" + revision;
} else {
return clazz.getSimpleName() + "-" + id;
}
} | [
"protected",
"String",
"buildKey",
"(",
"final",
"Class",
"<",
"?",
">",
"clazz",
",",
"final",
"String",
"id",
",",
"final",
"Number",
"revision",
")",
"{",
"if",
"(",
"revision",
"!=",
"null",
")",
"{",
"return",
"clazz",
".",
"getSimpleName",
"(",
"... | Build the unique key to be used for caching entities.
@param clazz The class of the entity to be cached.
@param id The id of the entity to be cached.
@param revision The revision of the entity to be cached, or null if it's the latest entity.
@return The unique key that can be used for caching. | [
"Build",
"the",
"unique",
"key",
"to",
"be",
"used",
"for",
"caching",
"entities",
"."
] | e47588adad0dcd55608b197b37825a512bc8fd25 | https://github.com/pressgang-ccms/PressGangCCMSDatasourceProviders/blob/e47588adad0dcd55608b197b37825a512bc8fd25/rest-provider/src/main/java/org/jboss/pressgang/ccms/utils/RESTEntityCache.java#L206-L212 |
156,136 | lightblueseas/net-extensions | src/main/java/de/alpharogroup/net/socket/SocketExtensions.java | SocketExtensions.closeClientSocket | public static boolean closeClientSocket(final Socket clientSocket)
{
boolean closed = true;
try
{
close(clientSocket);
}
catch (final IOException e)
{
LOGGER.error("IOException occured by trying to close the client socket.", e);
closed = false;
}
finally
{
try
{
close(clientSocket);
}
catch (final IOException e)
{
LOGGER.error("IOException occured by trying to close the client socket.", e);
closed = false;
}
}
return closed;
} | java | public static boolean closeClientSocket(final Socket clientSocket)
{
boolean closed = true;
try
{
close(clientSocket);
}
catch (final IOException e)
{
LOGGER.error("IOException occured by trying to close the client socket.", e);
closed = false;
}
finally
{
try
{
close(clientSocket);
}
catch (final IOException e)
{
LOGGER.error("IOException occured by trying to close the client socket.", e);
closed = false;
}
}
return closed;
} | [
"public",
"static",
"boolean",
"closeClientSocket",
"(",
"final",
"Socket",
"clientSocket",
")",
"{",
"boolean",
"closed",
"=",
"true",
";",
"try",
"{",
"close",
"(",
"clientSocket",
")",
";",
"}",
"catch",
"(",
"final",
"IOException",
"e",
")",
"{",
"LOGG... | Closes the given client socket.
@param clientSocket
The client socket to close.
@return Returns true if the client socket is closed otherwise false. | [
"Closes",
"the",
"given",
"client",
"socket",
"."
] | 771757a93fa9ad13ce0fe061c158e5cba43344cb | https://github.com/lightblueseas/net-extensions/blob/771757a93fa9ad13ce0fe061c158e5cba43344cb/src/main/java/de/alpharogroup/net/socket/SocketExtensions.java#L116-L141 |
156,137 | lightblueseas/net-extensions | src/main/java/de/alpharogroup/net/socket/SocketExtensions.java | SocketExtensions.closeServerSocket | public static boolean closeServerSocket(ServerSocket serverSocket)
{
boolean closed = true;
try
{
if (serverSocket != null && !serverSocket.isClosed())
{
serverSocket.close();
serverSocket = null;
}
}
catch (final IOException e)
{
LOGGER.error("IOException occured by trying to close the server socket.", e);
closed = false;
}
finally
{
try
{
if (serverSocket != null && !serverSocket.isClosed())
{
serverSocket.close();
}
}
catch (final IOException e)
{
LOGGER.error("IOException occured by trying to close the server socket.", e);
closed = false;
}
}
return closed;
} | java | public static boolean closeServerSocket(ServerSocket serverSocket)
{
boolean closed = true;
try
{
if (serverSocket != null && !serverSocket.isClosed())
{
serverSocket.close();
serverSocket = null;
}
}
catch (final IOException e)
{
LOGGER.error("IOException occured by trying to close the server socket.", e);
closed = false;
}
finally
{
try
{
if (serverSocket != null && !serverSocket.isClosed())
{
serverSocket.close();
}
}
catch (final IOException e)
{
LOGGER.error("IOException occured by trying to close the server socket.", e);
closed = false;
}
}
return closed;
} | [
"public",
"static",
"boolean",
"closeServerSocket",
"(",
"ServerSocket",
"serverSocket",
")",
"{",
"boolean",
"closed",
"=",
"true",
";",
"try",
"{",
"if",
"(",
"serverSocket",
"!=",
"null",
"&&",
"!",
"serverSocket",
".",
"isClosed",
"(",
")",
")",
"{",
"... | Closes the given ServerSocket.
@param serverSocket
The ServerSocket to close.
@return Returns true if the ServerSocket is closed otherwise false. | [
"Closes",
"the",
"given",
"ServerSocket",
"."
] | 771757a93fa9ad13ce0fe061c158e5cba43344cb | https://github.com/lightblueseas/net-extensions/blob/771757a93fa9ad13ce0fe061c158e5cba43344cb/src/main/java/de/alpharogroup/net/socket/SocketExtensions.java#L150-L182 |
156,138 | lightblueseas/net-extensions | src/main/java/de/alpharogroup/net/socket/SocketExtensions.java | SocketExtensions.readObject | public static Object readObject(final int port) throws IOException, ClassNotFoundException
{
ServerSocket serverSocket = null;
Socket clientSocket = null;
Object objectToReturn = null;
try
{
serverSocket = new ServerSocket(port);
clientSocket = serverSocket.accept();
objectToReturn = readObject(clientSocket);
}
catch (final IOException e)
{
throw e;
}
catch (final ClassNotFoundException e)
{
throw e;
}
finally
{
closeServerSocket(serverSocket);
}
return objectToReturn;
} | java | public static Object readObject(final int port) throws IOException, ClassNotFoundException
{
ServerSocket serverSocket = null;
Socket clientSocket = null;
Object objectToReturn = null;
try
{
serverSocket = new ServerSocket(port);
clientSocket = serverSocket.accept();
objectToReturn = readObject(clientSocket);
}
catch (final IOException e)
{
throw e;
}
catch (final ClassNotFoundException e)
{
throw e;
}
finally
{
closeServerSocket(serverSocket);
}
return objectToReturn;
} | [
"public",
"static",
"Object",
"readObject",
"(",
"final",
"int",
"port",
")",
"throws",
"IOException",
",",
"ClassNotFoundException",
"{",
"ServerSocket",
"serverSocket",
"=",
"null",
";",
"Socket",
"clientSocket",
"=",
"null",
";",
"Object",
"objectToReturn",
"="... | Reads an object from the given port.
@param port
the port
@return the object
@throws IOException
Signals that an I/O exception has occurred.
@throws ClassNotFoundException
the class not found exception | [
"Reads",
"an",
"object",
"from",
"the",
"given",
"port",
"."
] | 771757a93fa9ad13ce0fe061c158e5cba43344cb | https://github.com/lightblueseas/net-extensions/blob/771757a93fa9ad13ce0fe061c158e5cba43344cb/src/main/java/de/alpharogroup/net/socket/SocketExtensions.java#L230-L254 |
156,139 | lightblueseas/net-extensions | src/main/java/de/alpharogroup/net/socket/SocketExtensions.java | SocketExtensions.readObject | public static Object readObject(final Socket clientSocket)
throws IOException, ClassNotFoundException
{
ObjectInputStream in = null;
Object objectToReturn = null;
try
{
in = new ObjectInputStream(new BufferedInputStream(clientSocket.getInputStream()));
while (true)
{
objectToReturn = in.readObject();
if (objectToReturn != null)
{
break;
}
}
in.close();
clientSocket.close();
}
catch (final IOException e)
{
LOGGER.error("IOException occured by trying to read the object.", e);
throw e;
}
catch (final ClassNotFoundException e)
{
LOGGER.error(
"ClassNotFoundException occured by trying to read the object from the socket.", e);
throw e;
}
finally
{
try
{
if (in != null)
{
in.close();
}
close(clientSocket);
}
catch (final IOException e)
{
LOGGER.error("IOException occured by trying to close the socket.", e);
throw e;
}
}
return objectToReturn;
} | java | public static Object readObject(final Socket clientSocket)
throws IOException, ClassNotFoundException
{
ObjectInputStream in = null;
Object objectToReturn = null;
try
{
in = new ObjectInputStream(new BufferedInputStream(clientSocket.getInputStream()));
while (true)
{
objectToReturn = in.readObject();
if (objectToReturn != null)
{
break;
}
}
in.close();
clientSocket.close();
}
catch (final IOException e)
{
LOGGER.error("IOException occured by trying to read the object.", e);
throw e;
}
catch (final ClassNotFoundException e)
{
LOGGER.error(
"ClassNotFoundException occured by trying to read the object from the socket.", e);
throw e;
}
finally
{
try
{
if (in != null)
{
in.close();
}
close(clientSocket);
}
catch (final IOException e)
{
LOGGER.error("IOException occured by trying to close the socket.", e);
throw e;
}
}
return objectToReturn;
} | [
"public",
"static",
"Object",
"readObject",
"(",
"final",
"Socket",
"clientSocket",
")",
"throws",
"IOException",
",",
"ClassNotFoundException",
"{",
"ObjectInputStream",
"in",
"=",
"null",
";",
"Object",
"objectToReturn",
"=",
"null",
";",
"try",
"{",
"in",
"="... | Reads an object from the given socket object.
@param clientSocket
the socket to read.
@return the object
@throws IOException
Signals that an I/O exception has occurred.
@throws ClassNotFoundException
the class not found exception | [
"Reads",
"an",
"object",
"from",
"the",
"given",
"socket",
"object",
"."
] | 771757a93fa9ad13ce0fe061c158e5cba43344cb | https://github.com/lightblueseas/net-extensions/blob/771757a93fa9ad13ce0fe061c158e5cba43344cb/src/main/java/de/alpharogroup/net/socket/SocketExtensions.java#L267-L317 |
156,140 | lightblueseas/net-extensions | src/main/java/de/alpharogroup/net/socket/SocketExtensions.java | SocketExtensions.writeObject | public static void writeObject(final InetAddress inetAddress, final int port,
final Object objectToSend) throws IOException
{
Socket socketToClient = null;
ObjectOutputStream oos = null;
try
{
socketToClient = new Socket(inetAddress, port);
oos = new ObjectOutputStream(
new BufferedOutputStream(socketToClient.getOutputStream()));
oos.writeObject(objectToSend);
oos.close();
socketToClient.close();
}
catch (final IOException e)
{
LOGGER.error("IOException occured by trying to write the object.", e);
throw e;
}
finally
{
try
{
if (oos != null)
{
oos.close();
}
close(socketToClient);
}
catch (final IOException e)
{
LOGGER.error("IOException occured by trying to close the socket.", e);
throw e;
}
}
} | java | public static void writeObject(final InetAddress inetAddress, final int port,
final Object objectToSend) throws IOException
{
Socket socketToClient = null;
ObjectOutputStream oos = null;
try
{
socketToClient = new Socket(inetAddress, port);
oos = new ObjectOutputStream(
new BufferedOutputStream(socketToClient.getOutputStream()));
oos.writeObject(objectToSend);
oos.close();
socketToClient.close();
}
catch (final IOException e)
{
LOGGER.error("IOException occured by trying to write the object.", e);
throw e;
}
finally
{
try
{
if (oos != null)
{
oos.close();
}
close(socketToClient);
}
catch (final IOException e)
{
LOGGER.error("IOException occured by trying to close the socket.", e);
throw e;
}
}
} | [
"public",
"static",
"void",
"writeObject",
"(",
"final",
"InetAddress",
"inetAddress",
",",
"final",
"int",
"port",
",",
"final",
"Object",
"objectToSend",
")",
"throws",
"IOException",
"{",
"Socket",
"socketToClient",
"=",
"null",
";",
"ObjectOutputStream",
"oos"... | Writes the given Object to the given InetAddress who listen to the given port.
@param inetAddress
the inet address
@param port
The port who listen the receiver.
@param objectToSend
The Object to send.
@throws IOException
Signals that an I/O exception has occurred. | [
"Writes",
"the",
"given",
"Object",
"to",
"the",
"given",
"InetAddress",
"who",
"listen",
"to",
"the",
"given",
"port",
"."
] | 771757a93fa9ad13ce0fe061c158e5cba43344cb | https://github.com/lightblueseas/net-extensions/blob/771757a93fa9ad13ce0fe061c158e5cba43344cb/src/main/java/de/alpharogroup/net/socket/SocketExtensions.java#L351-L387 |
156,141 | lightblueseas/net-extensions | src/main/java/de/alpharogroup/net/socket/SocketExtensions.java | SocketExtensions.writeObject | public static void writeObject(final Socket socket, final int port, final Object objectToSend)
throws IOException
{
writeObject(socket.getInetAddress(), port, objectToSend);
} | java | public static void writeObject(final Socket socket, final int port, final Object objectToSend)
throws IOException
{
writeObject(socket.getInetAddress(), port, objectToSend);
} | [
"public",
"static",
"void",
"writeObject",
"(",
"final",
"Socket",
"socket",
",",
"final",
"int",
"port",
",",
"final",
"Object",
"objectToSend",
")",
"throws",
"IOException",
"{",
"writeObject",
"(",
"socket",
".",
"getInetAddress",
"(",
")",
",",
"port",
"... | Writes the given Object to the given Socket who listen to the given port.
@param socket
The Socket to the receiver.
@param port
The port who listen the receiver.
@param objectToSend
The Object to send.
@throws IOException
Signals that an I/O exception has occurred. | [
"Writes",
"the",
"given",
"Object",
"to",
"the",
"given",
"Socket",
"who",
"listen",
"to",
"the",
"given",
"port",
"."
] | 771757a93fa9ad13ce0fe061c158e5cba43344cb | https://github.com/lightblueseas/net-extensions/blob/771757a93fa9ad13ce0fe061c158e5cba43344cb/src/main/java/de/alpharogroup/net/socket/SocketExtensions.java#L401-L405 |
156,142 | lightblueseas/net-extensions | src/main/java/de/alpharogroup/net/socket/SocketExtensions.java | SocketExtensions.writeObject | public static void writeObject(final String serverName, final int port,
final Object objectToSend) throws IOException
{
final InetAddress inetAddress = InetAddress.getByName(serverName);
writeObject(inetAddress, port, objectToSend);
} | java | public static void writeObject(final String serverName, final int port,
final Object objectToSend) throws IOException
{
final InetAddress inetAddress = InetAddress.getByName(serverName);
writeObject(inetAddress, port, objectToSend);
} | [
"public",
"static",
"void",
"writeObject",
"(",
"final",
"String",
"serverName",
",",
"final",
"int",
"port",
",",
"final",
"Object",
"objectToSend",
")",
"throws",
"IOException",
"{",
"final",
"InetAddress",
"inetAddress",
"=",
"InetAddress",
".",
"getByName",
... | Writes the given Object.
@param serverName
The Name from the receiver(Server).
@param port
The port who listen the receiver.
@param objectToSend
The Object to send.
@throws IOException
Signals that an I/O exception has occurred. | [
"Writes",
"the",
"given",
"Object",
"."
] | 771757a93fa9ad13ce0fe061c158e5cba43344cb | https://github.com/lightblueseas/net-extensions/blob/771757a93fa9ad13ce0fe061c158e5cba43344cb/src/main/java/de/alpharogroup/net/socket/SocketExtensions.java#L419-L424 |
156,143 | wigforss/Ka-Commons-Jmx | core/src/main/java/org/kasource/commons/jmx/registration/MBeanRegistratorImpl.java | MBeanRegistratorImpl.toMBean | private Object toMBean(Object object) throws IllegalArgumentException, NotCompliantMBeanException {
JmxBean jmxBean = AnnotationUtils.getAnnotation(object.getClass(), JmxBean.class);
if (DynamicMBean.class.isAssignableFrom(object.getClass())) {
return object;
}
ClassIntrospector classIntrospector = new ClassIntrospectorImpl(object.getClass());
Class<?> mBeanInterface = classIntrospector.getInterface(new ClassFilterBuilder().name(object.getClass().getName().replace(".", "\\.") + "MBean").build());
if (mBeanInterface != null) {
return new AnnotatedStandardMBean(object, mBeanInterface);
}
Class<?> mxBeanInterface = classIntrospector.getInterface(new ClassFilterBuilder().name(".*MXBean").or().annotated(MXBean.class).build());
if (mxBeanInterface!= null) {
return new AnnotatedStandardMBean(object, mxBeanInterface, true);
}
// Interface set on JmxBean annotation
if (!jmxBean.managedInterface().equals(EmptyInterface.class)) {
if (implementsInterface(object, jmxBean.managedInterface())) {
return new AnnotatedStandardMBean(object, jmxBean.managedInterface());
} else {
throw new IllegalArgumentException(JmxBean.class + " attribute managedInterface is set to " + jmxBean.managedInterface() + " but " + object.getClass() + " does not implement that interface");
}
}
// Search for an implemented interface annotated with JmxInterface
Class<?> annotatedInterface = classIntrospector.getInterface(new ClassFilterBuilder().annotated(JmxInterface.class).build());
if (annotatedInterface != null) {
return new AnnotatedStandardMBean(object, jmxBean.managedInterface());
}
// Create DynamicMBean by using reflection and inspecting annotations
return dynamicBeanFactory.getMBeanFor(object);
} | java | private Object toMBean(Object object) throws IllegalArgumentException, NotCompliantMBeanException {
JmxBean jmxBean = AnnotationUtils.getAnnotation(object.getClass(), JmxBean.class);
if (DynamicMBean.class.isAssignableFrom(object.getClass())) {
return object;
}
ClassIntrospector classIntrospector = new ClassIntrospectorImpl(object.getClass());
Class<?> mBeanInterface = classIntrospector.getInterface(new ClassFilterBuilder().name(object.getClass().getName().replace(".", "\\.") + "MBean").build());
if (mBeanInterface != null) {
return new AnnotatedStandardMBean(object, mBeanInterface);
}
Class<?> mxBeanInterface = classIntrospector.getInterface(new ClassFilterBuilder().name(".*MXBean").or().annotated(MXBean.class).build());
if (mxBeanInterface!= null) {
return new AnnotatedStandardMBean(object, mxBeanInterface, true);
}
// Interface set on JmxBean annotation
if (!jmxBean.managedInterface().equals(EmptyInterface.class)) {
if (implementsInterface(object, jmxBean.managedInterface())) {
return new AnnotatedStandardMBean(object, jmxBean.managedInterface());
} else {
throw new IllegalArgumentException(JmxBean.class + " attribute managedInterface is set to " + jmxBean.managedInterface() + " but " + object.getClass() + " does not implement that interface");
}
}
// Search for an implemented interface annotated with JmxInterface
Class<?> annotatedInterface = classIntrospector.getInterface(new ClassFilterBuilder().annotated(JmxInterface.class).build());
if (annotatedInterface != null) {
return new AnnotatedStandardMBean(object, jmxBean.managedInterface());
}
// Create DynamicMBean by using reflection and inspecting annotations
return dynamicBeanFactory.getMBeanFor(object);
} | [
"private",
"Object",
"toMBean",
"(",
"Object",
"object",
")",
"throws",
"IllegalArgumentException",
",",
"NotCompliantMBeanException",
"{",
"JmxBean",
"jmxBean",
"=",
"AnnotationUtils",
".",
"getAnnotation",
"(",
"object",
".",
"getClass",
"(",
")",
",",
"JmxBean",
... | Returns either a AnnotatedStandardMBean or a DynamicMBean implementation.
@param object Object to create MBean for.
@return either a AnnotatedStandardMBean or a DynamicMBean implementation.
@throws IllegalArgumentException
@throws NotCompliantMBeanException | [
"Returns",
"either",
"a",
"AnnotatedStandardMBean",
"or",
"a",
"DynamicMBean",
"implementation",
"."
] | f31ceda37ff55746bb43a059919842cb92405b5d | https://github.com/wigforss/Ka-Commons-Jmx/blob/f31ceda37ff55746bb43a059919842cb92405b5d/core/src/main/java/org/kasource/commons/jmx/registration/MBeanRegistratorImpl.java#L198-L227 |
156,144 | nilsreiter/uima-util | src/main/java/de/unistuttgart/ims/uimautil/TreeBasedTableExport.java | TreeBasedTableExport.populateTree | protected Tree<FeatureStructure> populateTree(JCas jcas) {
Tree<FeatureStructure> tree = new Tree<FeatureStructure>(jcas.getDocumentAnnotationFs());
for (TOP a : JCasUtil.select(jcas, annotationTypes.get(0))) {
tree.add(populateTree(jcas, a, 1));
}
return tree;
} | java | protected Tree<FeatureStructure> populateTree(JCas jcas) {
Tree<FeatureStructure> tree = new Tree<FeatureStructure>(jcas.getDocumentAnnotationFs());
for (TOP a : JCasUtil.select(jcas, annotationTypes.get(0))) {
tree.add(populateTree(jcas, a, 1));
}
return tree;
} | [
"protected",
"Tree",
"<",
"FeatureStructure",
">",
"populateTree",
"(",
"JCas",
"jcas",
")",
"{",
"Tree",
"<",
"FeatureStructure",
">",
"tree",
"=",
"new",
"Tree",
"<",
"FeatureStructure",
">",
"(",
"jcas",
".",
"getDocumentAnnotationFs",
"(",
")",
")",
";",... | This is the entry point for Tree construction. The root is the document
node.
@param jcas
The document
@return A tree of feature structures | [
"This",
"is",
"the",
"entry",
"point",
"for",
"Tree",
"construction",
".",
"The",
"root",
"is",
"the",
"document",
"node",
"."
] | 6f3bc3b8785702fe4ab9b670b87eaa215006f593 | https://github.com/nilsreiter/uima-util/blob/6f3bc3b8785702fe4ab9b670b87eaa215006f593/src/main/java/de/unistuttgart/ims/uimautil/TreeBasedTableExport.java#L264-L271 |
156,145 | nilsreiter/uima-util | src/main/java/de/unistuttgart/ims/uimautil/TreeBasedTableExport.java | TreeBasedTableExport.populateTree | @SuppressWarnings("unchecked")
protected Tree<FeatureStructure> populateTree(JCas jcas, TOP anno, int typeIndex) {
Tree<FeatureStructure> tree = new Tree<FeatureStructure>(anno);
if (annotationTypes.size() > typeIndex)
if (anno instanceof Annotation) {
Class<? extends Annotation> rAnno = (Class<? extends Annotation>) annotationTypes.get(typeIndex);
for (TOP a : JCasUtil.selectCovered((Class<? extends Annotation>) rAnno, (Annotation) anno)) {
tree.add(populateTree(jcas, a, typeIndex + 1));
}
} else {
for (TOP a : JCasUtil.select(jcas, annotationTypes.get(typeIndex))) {
tree.add(populateTree(jcas, a, typeIndex + 1));
}
}
return tree;
} | java | @SuppressWarnings("unchecked")
protected Tree<FeatureStructure> populateTree(JCas jcas, TOP anno, int typeIndex) {
Tree<FeatureStructure> tree = new Tree<FeatureStructure>(anno);
if (annotationTypes.size() > typeIndex)
if (anno instanceof Annotation) {
Class<? extends Annotation> rAnno = (Class<? extends Annotation>) annotationTypes.get(typeIndex);
for (TOP a : JCasUtil.selectCovered((Class<? extends Annotation>) rAnno, (Annotation) anno)) {
tree.add(populateTree(jcas, a, typeIndex + 1));
}
} else {
for (TOP a : JCasUtil.select(jcas, annotationTypes.get(typeIndex))) {
tree.add(populateTree(jcas, a, typeIndex + 1));
}
}
return tree;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"protected",
"Tree",
"<",
"FeatureStructure",
">",
"populateTree",
"(",
"JCas",
"jcas",
",",
"TOP",
"anno",
",",
"int",
"typeIndex",
")",
"{",
"Tree",
"<",
"FeatureStructure",
">",
"tree",
"=",
"new",
"Tree... | This function recursively constructs a tree containing the feature
structures that are covering each other. Longer annotations should be on
higher levels of the tree.
@param jcas
The document
@param anno
The current annotation
@param typeIndex
An index referring to the list of annotation types to export
@return A Tree with FeatureStructures as payloads | [
"This",
"function",
"recursively",
"constructs",
"a",
"tree",
"containing",
"the",
"feature",
"structures",
"that",
"are",
"covering",
"each",
"other",
".",
"Longer",
"annotations",
"should",
"be",
"on",
"higher",
"levels",
"of",
"the",
"tree",
"."
] | 6f3bc3b8785702fe4ab9b670b87eaa215006f593 | https://github.com/nilsreiter/uima-util/blob/6f3bc3b8785702fe4ab9b670b87eaa215006f593/src/main/java/de/unistuttgart/ims/uimautil/TreeBasedTableExport.java#L287-L302 |
156,146 | autermann/yaml | src/main/java/com/github/autermann/yaml/nodes/YamlSequenceNode.java | YamlSequenceNode.add | @SuppressWarnings("unchecked")
public T add(YamlNode value) {
// small protection: adding this to a collection added to this still works
if (value == this) {
throw new IllegalArgumentException("recursive structures are currently not supported");
}
value().add(YamlNodes.nullToNode(value));
return (T) this;
} | java | @SuppressWarnings("unchecked")
public T add(YamlNode value) {
// small protection: adding this to a collection added to this still works
if (value == this) {
throw new IllegalArgumentException("recursive structures are currently not supported");
}
value().add(YamlNodes.nullToNode(value));
return (T) this;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"T",
"add",
"(",
"YamlNode",
"value",
")",
"{",
"// small protection: adding this to a collection added to this still works",
"if",
"(",
"value",
"==",
"this",
")",
"{",
"throw",
"new",
"IllegalArgumentExcept... | Adds the specified value to this sequence.
@param value the value
@return {@code this} | [
"Adds",
"the",
"specified",
"value",
"to",
"this",
"sequence",
"."
] | 5f8ab03e4fec3a2abe72c03561cdaa3a3936634d | https://github.com/autermann/yaml/blob/5f8ab03e4fec3a2abe72c03561cdaa3a3936634d/src/main/java/com/github/autermann/yaml/nodes/YamlSequenceNode.java#L73-L81 |
156,147 | autermann/yaml | src/main/java/com/github/autermann/yaml/nodes/YamlSequenceNode.java | YamlSequenceNode.addAll | @SuppressWarnings("unchecked")
public T addAll(YamlNode... values) {
for (YamlNode value : values) {
add(value);
}
return (T) this;
} | java | @SuppressWarnings("unchecked")
public T addAll(YamlNode... values) {
for (YamlNode value : values) {
add(value);
}
return (T) this;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"T",
"addAll",
"(",
"YamlNode",
"...",
"values",
")",
"{",
"for",
"(",
"YamlNode",
"value",
":",
"values",
")",
"{",
"add",
"(",
"value",
")",
";",
"}",
"return",
"(",
"T",
")",
"this",
";... | Adds all specified values to this sequence.
@param values the values
@return {@code this} | [
"Adds",
"all",
"specified",
"values",
"to",
"this",
"sequence",
"."
] | 5f8ab03e4fec3a2abe72c03561cdaa3a3936634d | https://github.com/autermann/yaml/blob/5f8ab03e4fec3a2abe72c03561cdaa3a3936634d/src/main/java/com/github/autermann/yaml/nodes/YamlSequenceNode.java#L90-L96 |
156,148 | e-amzallag/dajlab-core | src/main/java/org/dajlab/gui/ModelManager.java | ModelManager.saveModel | public static void saveModel(final File file, final DajlabModel dajlabModel) {
Platform.runLater(new Runnable() {
@Override
public void run() {
Gson fxGson = FxGson.fullBuilder().setPrettyPrinting().create();
JsonElement el = fxGson.toJsonTree(dajlabModel);
try {
JsonWriter w = new JsonWriter(new FileWriter(file));
w.setIndent("\t");
fxGson.toJson(el, w);
w.close();
} catch (Exception e) {
logger.error("Unable to export model to file [{}]", file.getName());
ExceptionFactory.throwDaJLabRuntimeException(DaJLabConstants.ERR_SAVE_MODEL);
}
}
});
} | java | public static void saveModel(final File file, final DajlabModel dajlabModel) {
Platform.runLater(new Runnable() {
@Override
public void run() {
Gson fxGson = FxGson.fullBuilder().setPrettyPrinting().create();
JsonElement el = fxGson.toJsonTree(dajlabModel);
try {
JsonWriter w = new JsonWriter(new FileWriter(file));
w.setIndent("\t");
fxGson.toJson(el, w);
w.close();
} catch (Exception e) {
logger.error("Unable to export model to file [{}]", file.getName());
ExceptionFactory.throwDaJLabRuntimeException(DaJLabConstants.ERR_SAVE_MODEL);
}
}
});
} | [
"public",
"static",
"void",
"saveModel",
"(",
"final",
"File",
"file",
",",
"final",
"DajlabModel",
"dajlabModel",
")",
"{",
"Platform",
".",
"runLater",
"(",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"Gso... | Save to the file the model.
@param file
file
@param dajlabModel
model | [
"Save",
"to",
"the",
"file",
"the",
"model",
"."
] | 2fe25e5f861d426ff68f65728427f80b96a72905 | https://github.com/e-amzallag/dajlab-core/blob/2fe25e5f861d426ff68f65728427f80b96a72905/src/main/java/org/dajlab/gui/ModelManager.java#L62-L81 |
156,149 | e-amzallag/dajlab-core | src/main/java/org/dajlab/gui/ModelManager.java | ModelManager.loadModel | public static <T extends DajlabModelInterface> DajlabModel loadModel(final File file) {
Gson fxGson = FxGson.fullBuilder().create();
DajlabModel model = new DajlabModel();
try {
JsonParser jsonParser = new JsonParser();
JsonReader jsonReader = new JsonReader(new FileReader(file));
jsonReader.beginObject();
if (jsonReader.hasNext()) {
jsonReader.nextName();
JsonObject ob = jsonParser.parse(jsonReader).getAsJsonObject();
Set<Entry<String, JsonElement>> set = ob.entrySet();
for (Entry<String, JsonElement> entry : set) {
String className = entry.getKey();
JsonElement el = entry.getValue();
try {
T obj = (T) fxGson.fromJson(el, Class.forName(className));
model.put(obj);
} catch (ClassNotFoundException e) {
logger.warn("Unable to load model for [{}]", className);
}
}
}
} catch (Exception e) {
logger.debug(e.getMessage());
logger.error("Unable to load model from file [{}]", file.getName());
ExceptionFactory.throwDaJLabRuntimeException(DaJLabConstants.ERR_LOAD_MODEL);
}
return model;
} | java | public static <T extends DajlabModelInterface> DajlabModel loadModel(final File file) {
Gson fxGson = FxGson.fullBuilder().create();
DajlabModel model = new DajlabModel();
try {
JsonParser jsonParser = new JsonParser();
JsonReader jsonReader = new JsonReader(new FileReader(file));
jsonReader.beginObject();
if (jsonReader.hasNext()) {
jsonReader.nextName();
JsonObject ob = jsonParser.parse(jsonReader).getAsJsonObject();
Set<Entry<String, JsonElement>> set = ob.entrySet();
for (Entry<String, JsonElement> entry : set) {
String className = entry.getKey();
JsonElement el = entry.getValue();
try {
T obj = (T) fxGson.fromJson(el, Class.forName(className));
model.put(obj);
} catch (ClassNotFoundException e) {
logger.warn("Unable to load model for [{}]", className);
}
}
}
} catch (Exception e) {
logger.debug(e.getMessage());
logger.error("Unable to load model from file [{}]", file.getName());
ExceptionFactory.throwDaJLabRuntimeException(DaJLabConstants.ERR_LOAD_MODEL);
}
return model;
} | [
"public",
"static",
"<",
"T",
"extends",
"DajlabModelInterface",
">",
"DajlabModel",
"loadModel",
"(",
"final",
"File",
"file",
")",
"{",
"Gson",
"fxGson",
"=",
"FxGson",
".",
"fullBuilder",
"(",
")",
".",
"create",
"(",
")",
";",
"DajlabModel",
"model",
"... | Load a model from a file.
@param file
file
@param <T>
model will implement DajlabModelInterface
@return the model | [
"Load",
"a",
"model",
"from",
"a",
"file",
"."
] | 2fe25e5f861d426ff68f65728427f80b96a72905 | https://github.com/e-amzallag/dajlab-core/blob/2fe25e5f861d426ff68f65728427f80b96a72905/src/main/java/org/dajlab/gui/ModelManager.java#L92-L122 |
156,150 | nakamura5akihito/six-util | src/main/java/jp/go/aist/six/util/search/RelationalBinding.java | RelationalBinding.equalBinding | public static RelationalBinding equalBinding(
final String property,
final Object value
)
{
return (new RelationalBinding( property, Relation.EQUAL, value ));
} | java | public static RelationalBinding equalBinding(
final String property,
final Object value
)
{
return (new RelationalBinding( property, Relation.EQUAL, value ));
} | [
"public",
"static",
"RelationalBinding",
"equalBinding",
"(",
"final",
"String",
"property",
",",
"final",
"Object",
"value",
")",
"{",
"return",
"(",
"new",
"RelationalBinding",
"(",
"property",
",",
"Relation",
".",
"EQUAL",
",",
"value",
")",
")",
";",
"}... | Creates an 'EQUAL' binding.
@param property
the property.
@param value
the value to which the property should be related.
@return
an 'EQUAL' binding. | [
"Creates",
"an",
"EQUAL",
"binding",
"."
] | a6db388a345e220cea2b1fa6324d15c80c6278b6 | https://github.com/nakamura5akihito/six-util/blob/a6db388a345e220cea2b1fa6324d15c80c6278b6/src/main/java/jp/go/aist/six/util/search/RelationalBinding.java#L50-L56 |
156,151 | nakamura5akihito/six-util | src/main/java/jp/go/aist/six/util/search/RelationalBinding.java | RelationalBinding.notEqualBinding | public static RelationalBinding notEqualBinding(
final String property,
final Object value
)
{
return (new RelationalBinding( property, Relation.NOT_EQUAL, value ));
} | java | public static RelationalBinding notEqualBinding(
final String property,
final Object value
)
{
return (new RelationalBinding( property, Relation.NOT_EQUAL, value ));
} | [
"public",
"static",
"RelationalBinding",
"notEqualBinding",
"(",
"final",
"String",
"property",
",",
"final",
"Object",
"value",
")",
"{",
"return",
"(",
"new",
"RelationalBinding",
"(",
"property",
",",
"Relation",
".",
"NOT_EQUAL",
",",
"value",
")",
")",
";... | Creates a 'NOT_EQUAL' binding.
@param property
the property.
@param value
the value to which the property should be related.
@return
a 'NOT_EQUAL' binding. | [
"Creates",
"a",
"NOT_EQUAL",
"binding",
"."
] | a6db388a345e220cea2b1fa6324d15c80c6278b6 | https://github.com/nakamura5akihito/six-util/blob/a6db388a345e220cea2b1fa6324d15c80c6278b6/src/main/java/jp/go/aist/six/util/search/RelationalBinding.java#L70-L76 |
156,152 | nakamura5akihito/six-util | src/main/java/jp/go/aist/six/util/search/RelationalBinding.java | RelationalBinding.lessThanBinding | public static RelationalBinding lessThanBinding(
final String property,
final Object value
)
{
return (new RelationalBinding( property, Relation.LESS_THAN, value ));
} | java | public static RelationalBinding lessThanBinding(
final String property,
final Object value
)
{
return (new RelationalBinding( property, Relation.LESS_THAN, value ));
} | [
"public",
"static",
"RelationalBinding",
"lessThanBinding",
"(",
"final",
"String",
"property",
",",
"final",
"Object",
"value",
")",
"{",
"return",
"(",
"new",
"RelationalBinding",
"(",
"property",
",",
"Relation",
".",
"LESS_THAN",
",",
"value",
")",
")",
";... | Creates a 'LESS_THAN' binding.
@param property
the property.
@param value
the value to which the property should be related.
@return
a 'LESS_THAN' binding. | [
"Creates",
"a",
"LESS_THAN",
"binding",
"."
] | a6db388a345e220cea2b1fa6324d15c80c6278b6 | https://github.com/nakamura5akihito/six-util/blob/a6db388a345e220cea2b1fa6324d15c80c6278b6/src/main/java/jp/go/aist/six/util/search/RelationalBinding.java#L90-L96 |
156,153 | nakamura5akihito/six-util | src/main/java/jp/go/aist/six/util/search/RelationalBinding.java | RelationalBinding.lessEqualBinding | public static RelationalBinding lessEqualBinding(
final String property,
final Object value
)
{
return (new RelationalBinding( property, Relation.LESS_EQUAL, value ));
} | java | public static RelationalBinding lessEqualBinding(
final String property,
final Object value
)
{
return (new RelationalBinding( property, Relation.LESS_EQUAL, value ));
} | [
"public",
"static",
"RelationalBinding",
"lessEqualBinding",
"(",
"final",
"String",
"property",
",",
"final",
"Object",
"value",
")",
"{",
"return",
"(",
"new",
"RelationalBinding",
"(",
"property",
",",
"Relation",
".",
"LESS_EQUAL",
",",
"value",
")",
")",
... | Creates a 'LESS_EQUAL' binding.
@param property
the property.
@param value
the value to which the property should be related.
@return
a 'LESS_EQUAL' binding. | [
"Creates",
"a",
"LESS_EQUAL",
"binding",
"."
] | a6db388a345e220cea2b1fa6324d15c80c6278b6 | https://github.com/nakamura5akihito/six-util/blob/a6db388a345e220cea2b1fa6324d15c80c6278b6/src/main/java/jp/go/aist/six/util/search/RelationalBinding.java#L110-L116 |
156,154 | nakamura5akihito/six-util | src/main/java/jp/go/aist/six/util/search/RelationalBinding.java | RelationalBinding.greaterThanBinding | public static RelationalBinding greaterThanBinding(
final String property,
final Object value
)
{
return (new RelationalBinding( property, Relation.GREATER_THAN, value ));
} | java | public static RelationalBinding greaterThanBinding(
final String property,
final Object value
)
{
return (new RelationalBinding( property, Relation.GREATER_THAN, value ));
} | [
"public",
"static",
"RelationalBinding",
"greaterThanBinding",
"(",
"final",
"String",
"property",
",",
"final",
"Object",
"value",
")",
"{",
"return",
"(",
"new",
"RelationalBinding",
"(",
"property",
",",
"Relation",
".",
"GREATER_THAN",
",",
"value",
")",
")"... | Creates a 'GREATER_THAN' binding.
@param property
the property.
@param value
the value to which the property should be related.
@return
a 'GREATER_THAN' binding. | [
"Creates",
"a",
"GREATER_THAN",
"binding",
"."
] | a6db388a345e220cea2b1fa6324d15c80c6278b6 | https://github.com/nakamura5akihito/six-util/blob/a6db388a345e220cea2b1fa6324d15c80c6278b6/src/main/java/jp/go/aist/six/util/search/RelationalBinding.java#L130-L136 |
156,155 | nakamura5akihito/six-util | src/main/java/jp/go/aist/six/util/search/RelationalBinding.java | RelationalBinding.greaterEqualBinding | public static RelationalBinding greaterEqualBinding(
final String property,
final Object value
)
{
return (new RelationalBinding( property, Relation.GREATER_EQUAL, value ));
} | java | public static RelationalBinding greaterEqualBinding(
final String property,
final Object value
)
{
return (new RelationalBinding( property, Relation.GREATER_EQUAL, value ));
} | [
"public",
"static",
"RelationalBinding",
"greaterEqualBinding",
"(",
"final",
"String",
"property",
",",
"final",
"Object",
"value",
")",
"{",
"return",
"(",
"new",
"RelationalBinding",
"(",
"property",
",",
"Relation",
".",
"GREATER_EQUAL",
",",
"value",
")",
"... | Creates a 'GREATER_EQUAL' binding.
@param property
the property.
@param value
the value to which the property should be related.
@return
a 'GREATER_EQUAL' binding. | [
"Creates",
"a",
"GREATER_EQUAL",
"binding",
"."
] | a6db388a345e220cea2b1fa6324d15c80c6278b6 | https://github.com/nakamura5akihito/six-util/blob/a6db388a345e220cea2b1fa6324d15c80c6278b6/src/main/java/jp/go/aist/six/util/search/RelationalBinding.java#L150-L156 |
156,156 | scottbw/spaws | src/main/java/uk/ac/bolton/spaws/ParadataFetcher.java | ParadataFetcher.getSubmissions | public List<ISubmission> getSubmissions() throws Exception{
List<ISubmission> submissions = new ArrayList<ISubmission>();
LRImporter importer = new LRImporter(node.getHost(), node.getScheme());
submissions = getMoreSubmissions(importer, submissions, null);
return submissions;
} | java | public List<ISubmission> getSubmissions() throws Exception{
List<ISubmission> submissions = new ArrayList<ISubmission>();
LRImporter importer = new LRImporter(node.getHost(), node.getScheme());
submissions = getMoreSubmissions(importer, submissions, null);
return submissions;
} | [
"public",
"List",
"<",
"ISubmission",
">",
"getSubmissions",
"(",
")",
"throws",
"Exception",
"{",
"List",
"<",
"ISubmission",
">",
"submissions",
"=",
"new",
"ArrayList",
"<",
"ISubmission",
">",
"(",
")",
";",
"LRImporter",
"importer",
"=",
"new",
"LRImpor... | Get the submissions associated with the resource
@return a List of ISubmission objects
@throws Exception | [
"Get",
"the",
"submissions",
"associated",
"with",
"the",
"resource"
] | 9b1e07453091f6a8d60c6046d194b1a8f1236502 | https://github.com/scottbw/spaws/blob/9b1e07453091f6a8d60c6046d194b1a8f1236502/src/main/java/uk/ac/bolton/spaws/ParadataFetcher.java#L63-L72 |
156,157 | scottbw/spaws | src/main/java/uk/ac/bolton/spaws/ParadataFetcher.java | ParadataFetcher.getMoreSubmissions | private List<ISubmission> getMoreSubmissions(LRImporter importer, List<ISubmission> submissions, String resumptionToken) throws Exception{
LRResult result;
if (resumptionToken == null){
//
// If there is no resumption token, this is the first request so
// supply all the parameters for the initial request
//
result = importer.getObtainJSONData(widgetIdentifier, true, false, false);
} else {
//
// If there is a resumption token, use it to obtain the next paged set of results
//
result = importer.getObtainJSONData(resumptionToken);
}
//
// If there are no results return the initial List without modification
//
if (result == null || result.getDocuments().size() == 0) return submissions;
//
// Get the result document
//
JSONArray records = result.getDocuments().get(0).getJSONArray("document");
//
// Creating submission objects for each record
//
for (int i=0;i<records.length();i++){
JSONObject record = records.getJSONObject(i);
ISubmission rating = SubmissionFactory.createSubmission(record, this.widgetIdentifier);
if (rating != null){
submissions.add(rating);
}
}
//
// If there is a resumption token, get the next result set by
// calling this method again and passing in both the token and
// the submissions List
//
if (result.getResumptionToken() != null && !result.getResumptionToken().equals("null")){
submissions = getMoreSubmissions(importer, submissions, result.getResumptionToken());
}
return submissions;
} | java | private List<ISubmission> getMoreSubmissions(LRImporter importer, List<ISubmission> submissions, String resumptionToken) throws Exception{
LRResult result;
if (resumptionToken == null){
//
// If there is no resumption token, this is the first request so
// supply all the parameters for the initial request
//
result = importer.getObtainJSONData(widgetIdentifier, true, false, false);
} else {
//
// If there is a resumption token, use it to obtain the next paged set of results
//
result = importer.getObtainJSONData(resumptionToken);
}
//
// If there are no results return the initial List without modification
//
if (result == null || result.getDocuments().size() == 0) return submissions;
//
// Get the result document
//
JSONArray records = result.getDocuments().get(0).getJSONArray("document");
//
// Creating submission objects for each record
//
for (int i=0;i<records.length();i++){
JSONObject record = records.getJSONObject(i);
ISubmission rating = SubmissionFactory.createSubmission(record, this.widgetIdentifier);
if (rating != null){
submissions.add(rating);
}
}
//
// If there is a resumption token, get the next result set by
// calling this method again and passing in both the token and
// the submissions List
//
if (result.getResumptionToken() != null && !result.getResumptionToken().equals("null")){
submissions = getMoreSubmissions(importer, submissions, result.getResumptionToken());
}
return submissions;
} | [
"private",
"List",
"<",
"ISubmission",
">",
"getMoreSubmissions",
"(",
"LRImporter",
"importer",
",",
"List",
"<",
"ISubmission",
">",
"submissions",
",",
"String",
"resumptionToken",
")",
"throws",
"Exception",
"{",
"LRResult",
"result",
";",
"if",
"(",
"resump... | Recursively add submissions by paging through a result set
@param importer the LRImporter being used to obtain results
@param submissions the List of submissions found so far
@param resumptionToken the token from the last request made
@return the updated List of ISubmissions
@throws Exception | [
"Recursively",
"add",
"submissions",
"by",
"paging",
"through",
"a",
"result",
"set"
] | 9b1e07453091f6a8d60c6046d194b1a8f1236502 | https://github.com/scottbw/spaws/blob/9b1e07453091f6a8d60c6046d194b1a8f1236502/src/main/java/uk/ac/bolton/spaws/ParadataFetcher.java#L82-L131 |
156,158 | jronrun/benayn | benayn-ustyle/src/main/java/com/benayn/ustyle/thirdparty/Events.java | Events.addEvent | public static <S extends Subscribable, E> AddEvent<S, E> addEvent(final S source, final E element) {
return new AddEvent<S, E>(source, element);
} | java | public static <S extends Subscribable, E> AddEvent<S, E> addEvent(final S source, final E element) {
return new AddEvent<S, E>(source, element);
} | [
"public",
"static",
"<",
"S",
"extends",
"Subscribable",
",",
"E",
">",
"AddEvent",
"<",
"S",
",",
"E",
">",
"addEvent",
"(",
"final",
"S",
"source",
",",
"final",
"E",
"element",
")",
"{",
"return",
"new",
"AddEvent",
"<",
"S",
",",
"E",
">",
"(",... | Returns a new AddEvent instance | [
"Returns",
"a",
"new",
"AddEvent",
"instance"
] | 7585152e10e4cac07b4274c65f1c72ad7061ae69 | https://github.com/jronrun/benayn/blob/7585152e10e4cac07b4274c65f1c72ad7061ae69/benayn-ustyle/src/main/java/com/benayn/ustyle/thirdparty/Events.java#L63-L65 |
156,159 | jronrun/benayn | benayn-ustyle/src/main/java/com/benayn/ustyle/thirdparty/Events.java | Events.removeEvent | public static <S extends Subscribable, E> RemoveEvent<S, E> removeEvent(final S source, final E element) {
return new RemoveEvent<S, E>(source, element);
} | java | public static <S extends Subscribable, E> RemoveEvent<S, E> removeEvent(final S source, final E element) {
return new RemoveEvent<S, E>(source, element);
} | [
"public",
"static",
"<",
"S",
"extends",
"Subscribable",
",",
"E",
">",
"RemoveEvent",
"<",
"S",
",",
"E",
">",
"removeEvent",
"(",
"final",
"S",
"source",
",",
"final",
"E",
"element",
")",
"{",
"return",
"new",
"RemoveEvent",
"<",
"S",
",",
"E",
">... | Returns a new RemoveEvent instance | [
"Returns",
"a",
"new",
"RemoveEvent",
"instance"
] | 7585152e10e4cac07b4274c65f1c72ad7061ae69 | https://github.com/jronrun/benayn/blob/7585152e10e4cac07b4274c65f1c72ad7061ae69/benayn-ustyle/src/main/java/com/benayn/ustyle/thirdparty/Events.java#L70-L72 |
156,160 | jronrun/benayn | benayn-ustyle/src/main/java/com/benayn/ustyle/thirdparty/Events.java | Events.modifyEvent | public static <S extends Subscribable, E> ModifyEvent<S, E> modifyEvent(
final S source, final E element, final E oldValue) {
return new ModifyEvent<S, E>(source, element, oldValue);
} | java | public static <S extends Subscribable, E> ModifyEvent<S, E> modifyEvent(
final S source, final E element, final E oldValue) {
return new ModifyEvent<S, E>(source, element, oldValue);
} | [
"public",
"static",
"<",
"S",
"extends",
"Subscribable",
",",
"E",
">",
"ModifyEvent",
"<",
"S",
",",
"E",
">",
"modifyEvent",
"(",
"final",
"S",
"source",
",",
"final",
"E",
"element",
",",
"final",
"E",
"oldValue",
")",
"{",
"return",
"new",
"ModifyE... | Returns a new ModifyEvent instance | [
"Returns",
"a",
"new",
"ModifyEvent",
"instance"
] | 7585152e10e4cac07b4274c65f1c72ad7061ae69 | https://github.com/jronrun/benayn/blob/7585152e10e4cac07b4274c65f1c72ad7061ae69/benayn-ustyle/src/main/java/com/benayn/ustyle/thirdparty/Events.java#L77-L80 |
156,161 | jronrun/benayn | benayn-ustyle/src/main/java/com/benayn/ustyle/thirdparty/Events.java | Events.exceptionEvent | public static <S extends Subscribable, X extends Throwable> ExceptionEvent<S, X>
exceptionEvent(final S source, final X exception) {
return new ExceptionEvent<S, X>(source, exception);
} | java | public static <S extends Subscribable, X extends Throwable> ExceptionEvent<S, X>
exceptionEvent(final S source, final X exception) {
return new ExceptionEvent<S, X>(source, exception);
} | [
"public",
"static",
"<",
"S",
"extends",
"Subscribable",
",",
"X",
"extends",
"Throwable",
">",
"ExceptionEvent",
"<",
"S",
",",
"X",
">",
"exceptionEvent",
"(",
"final",
"S",
"source",
",",
"final",
"X",
"exception",
")",
"{",
"return",
"new",
"ExceptionE... | Returns a new ExceptionEvent instance | [
"Returns",
"a",
"new",
"ExceptionEvent",
"instance"
] | 7585152e10e4cac07b4274c65f1c72ad7061ae69 | https://github.com/jronrun/benayn/blob/7585152e10e4cac07b4274c65f1c72ad7061ae69/benayn-ustyle/src/main/java/com/benayn/ustyle/thirdparty/Events.java#L85-L88 |
156,162 | csc19601128/Phynixx | phynixx/phynixx-logger/src/main/java/org/csc/phynixx/loggersystem/logrecord/PhynixxXADataRecorder.java | PhynixxXADataRecorder.recover | @Override
public void recover() {
try {
this.messages.clear();
this.dataLogger.prepareForRead();
this.dataLogger.recover(this);
} catch (Exception e) {
throw new DelegatedRuntimeException(e);
}
} | java | @Override
public void recover() {
try {
this.messages.clear();
this.dataLogger.prepareForRead();
this.dataLogger.recover(this);
} catch (Exception e) {
throw new DelegatedRuntimeException(e);
}
} | [
"@",
"Override",
"public",
"void",
"recover",
"(",
")",
"{",
"try",
"{",
"this",
".",
"messages",
".",
"clear",
"(",
")",
";",
"this",
".",
"dataLogger",
".",
"prepareForRead",
"(",
")",
";",
"this",
".",
"dataLogger",
".",
"recover",
"(",
"this",
")... | recovers the dataRecorder
all messages are removed and all the messsages of the logger are recoverd | [
"recovers",
"the",
"dataRecorder",
"all",
"messages",
"are",
"removed",
"and",
"all",
"the",
"messsages",
"of",
"the",
"logger",
"are",
"recoverd"
] | a26c03bc229a8882c647799834115bec6bdc0ac8 | https://github.com/csc19601128/Phynixx/blob/a26c03bc229a8882c647799834115bec6bdc0ac8/phynixx/phynixx-logger/src/main/java/org/csc/phynixx/loggersystem/logrecord/PhynixxXADataRecorder.java#L89-L98 |
156,163 | csc19601128/Phynixx | phynixx/phynixx-logger/src/main/java/org/csc/phynixx/loggersystem/logrecord/PhynixxXADataRecorder.java | PhynixxXADataRecorder.release | @Override
public void release() {
rewind();
try {
this.dataLogger.prepareForWrite(this.getXADataRecorderId());
} catch (Exception e) {
throw new DelegatedRuntimeException(e);
}
if (dataRecorderLifycycleListner != null) {
this.dataRecorderLifycycleListner.recorderDataRecorderReleased(this);
}
} | java | @Override
public void release() {
rewind();
try {
this.dataLogger.prepareForWrite(this.getXADataRecorderId());
} catch (Exception e) {
throw new DelegatedRuntimeException(e);
}
if (dataRecorderLifycycleListner != null) {
this.dataRecorderLifycycleListner.recorderDataRecorderReleased(this);
}
} | [
"@",
"Override",
"public",
"void",
"release",
"(",
")",
"{",
"rewind",
"(",
")",
";",
"try",
"{",
"this",
".",
"dataLogger",
".",
"prepareForWrite",
"(",
"this",
".",
"getXADataRecorderId",
"(",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
... | rewinds the recorder and resets the dataLogger. Information of the dataLogger is removed | [
"rewinds",
"the",
"recorder",
"and",
"resets",
"the",
"dataLogger",
".",
"Information",
"of",
"the",
"dataLogger",
"is",
"removed"
] | a26c03bc229a8882c647799834115bec6bdc0ac8 | https://github.com/csc19601128/Phynixx/blob/a26c03bc229a8882c647799834115bec6bdc0ac8/phynixx/phynixx-logger/src/main/java/org/csc/phynixx/loggersystem/logrecord/PhynixxXADataRecorder.java#L370-L383 |
156,164 | csc19601128/Phynixx | phynixx/phynixx-logger/src/main/java/org/csc/phynixx/loggersystem/logrecord/PhynixxXADataRecorder.java | PhynixxXADataRecorder.destroy | @Override
public void destroy() {
if (dataRecorderLifycycleListner != null) {
this.dataRecorderLifycycleListner.recorderDataRecorderClosed(this);
}
try {
this.dataLogger.destroy();
} catch (IOException e) {
throw new DelegatedRuntimeException(e);
}
} | java | @Override
public void destroy() {
if (dataRecorderLifycycleListner != null) {
this.dataRecorderLifycycleListner.recorderDataRecorderClosed(this);
}
try {
this.dataLogger.destroy();
} catch (IOException e) {
throw new DelegatedRuntimeException(e);
}
} | [
"@",
"Override",
"public",
"void",
"destroy",
"(",
")",
"{",
"if",
"(",
"dataRecorderLifycycleListner",
"!=",
"null",
")",
"{",
"this",
".",
"dataRecorderLifycycleListner",
".",
"recorderDataRecorderClosed",
"(",
"this",
")",
";",
"}",
"try",
"{",
"this",
".",... | destroys the current dataLogger | [
"destroys",
"the",
"current",
"dataLogger"
] | a26c03bc229a8882c647799834115bec6bdc0ac8 | https://github.com/csc19601128/Phynixx/blob/a26c03bc229a8882c647799834115bec6bdc0ac8/phynixx/phynixx-logger/src/main/java/org/csc/phynixx/loggersystem/logrecord/PhynixxXADataRecorder.java#L404-L414 |
156,165 | dihedron/dihedron-commons | src/main/java/org/dihedron/core/formatters/HexWriter.java | HexWriter.toHex | public static String toHex(byte[] data, int length) {
StringBuffer buffer = new StringBuffer();
for (int i = 0; i != length; i++) {
int v = data[i] & 0xff;
buffer.append(DIGITS.charAt(v >> 4));
buffer.append(DIGITS.charAt(v & 0xf));
}
return buffer.toString();
} | java | public static String toHex(byte[] data, int length) {
StringBuffer buffer = new StringBuffer();
for (int i = 0; i != length; i++) {
int v = data[i] & 0xff;
buffer.append(DIGITS.charAt(v >> 4));
buffer.append(DIGITS.charAt(v & 0xf));
}
return buffer.toString();
} | [
"public",
"static",
"String",
"toHex",
"(",
"byte",
"[",
"]",
"data",
",",
"int",
"length",
")",
"{",
"StringBuffer",
"buffer",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"!=",
"length",
";",
"i",
"++",
... | Return length many bytes of the passed in byte array as a hex string.
@param data the bytes to be converted.
@param length the number of bytes in the data block to be converted.
@return a hex representation of length bytes of data. | [
"Return",
"length",
"many",
"bytes",
"of",
"the",
"passed",
"in",
"byte",
"array",
"as",
"a",
"hex",
"string",
"."
] | a5194cdaa0d6417ef4aade6ea407a1cad6e8458e | https://github.com/dihedron/dihedron-commons/blob/a5194cdaa0d6417ef4aade6ea407a1cad6e8458e/src/main/java/org/dihedron/core/formatters/HexWriter.java#L40-L51 |
156,166 | dottydingo/tracelog | src/main/java/com/dottydingo/service/tracelog/logback/TraceAppender.java | TraceAppender.append | @Override
protected void append(ILoggingEvent eventObject)
{
Trace<ILoggingEvent> trace = traceManager.getTrace();
if(trace != null)
{
trace.addEvent(eventObject);
}
} | java | @Override
protected void append(ILoggingEvent eventObject)
{
Trace<ILoggingEvent> trace = traceManager.getTrace();
if(trace != null)
{
trace.addEvent(eventObject);
}
} | [
"@",
"Override",
"protected",
"void",
"append",
"(",
"ILoggingEvent",
"eventObject",
")",
"{",
"Trace",
"<",
"ILoggingEvent",
">",
"trace",
"=",
"traceManager",
".",
"getTrace",
"(",
")",
";",
"if",
"(",
"trace",
"!=",
"null",
")",
"{",
"trace",
".",
"ad... | Appends the logging event to the trace if one is currently in progress
@param eventObject the event | [
"Appends",
"the",
"logging",
"event",
"to",
"the",
"trace",
"if",
"one",
"is",
"currently",
"in",
"progress"
] | e856d3593f2aad5465a89d50f79d2fc6c4169cb1 | https://github.com/dottydingo/tracelog/blob/e856d3593f2aad5465a89d50f79d2fc6c4169cb1/src/main/java/com/dottydingo/service/tracelog/logback/TraceAppender.java#L44-L52 |
156,167 | adamfisk/littleshoot-util | src/main/java/org/littleshoot/util/xml/XmlUtils.java | XmlUtils.replaceNodeValue | public static void replaceNodeValue(final Document doc, final String xPath,
final String newValue) {
final Text textNode = doc.createTextNode(newValue);
try {
final Node node = (Node) s_path.evaluate(xPath, doc,
XPathConstants.NODE);
if (LOG.isDebugEnabled()) {
LOG.debug("Found node: " + node.getNodeName());
}
if (node == null) {
LOG.warn("Could not find xPath: " + xPath);
return;
}
node.replaceChild(textNode, node.getFirstChild());
} catch (final XPathExpressionException e) {
LOG.error("Bad XPath: " + xPath, e);
}
} | java | public static void replaceNodeValue(final Document doc, final String xPath,
final String newValue) {
final Text textNode = doc.createTextNode(newValue);
try {
final Node node = (Node) s_path.evaluate(xPath, doc,
XPathConstants.NODE);
if (LOG.isDebugEnabled()) {
LOG.debug("Found node: " + node.getNodeName());
}
if (node == null) {
LOG.warn("Could not find xPath: " + xPath);
return;
}
node.replaceChild(textNode, node.getFirstChild());
} catch (final XPathExpressionException e) {
LOG.error("Bad XPath: " + xPath, e);
}
} | [
"public",
"static",
"void",
"replaceNodeValue",
"(",
"final",
"Document",
"doc",
",",
"final",
"String",
"xPath",
",",
"final",
"String",
"newValue",
")",
"{",
"final",
"Text",
"textNode",
"=",
"doc",
".",
"createTextNode",
"(",
"newValue",
")",
";",
"try",
... | Replaces the text value of a node in a document with the specified value
using XPath.
@param doc The document to modify.
@param xPath The XPath string to locate the node to modify. This
should point to the {@link Node} containing a {@link Text} node as its
first child.
@param newValue The new text value to place in the node. | [
"Replaces",
"the",
"text",
"value",
"of",
"a",
"node",
"in",
"a",
"document",
"with",
"the",
"specified",
"value",
"using",
"XPath",
"."
] | 3c0dc4955116b3382d6b0575d2f164b7508a4f73 | https://github.com/adamfisk/littleshoot-util/blob/3c0dc4955116b3382d6b0575d2f164b7508a4f73/src/main/java/org/littleshoot/util/xml/XmlUtils.java#L58-L75 |
156,168 | intellimate/Izou | src/main/java/org/intellimate/izou/security/SecurityManager.java | SecurityManager.createSecurityManager | public static SecurityManager createSecurityManager(SystemMail systemMail, Main main) throws IllegalAccessException {
if (!exists) {
SecurityManager securityManager = new SecurityManager(systemMail, main);
exists = true;
return securityManager;
}
throw new IllegalAccessException("Cannot create more than one instance of IzouSecurityManager");
} | java | public static SecurityManager createSecurityManager(SystemMail systemMail, Main main) throws IllegalAccessException {
if (!exists) {
SecurityManager securityManager = new SecurityManager(systemMail, main);
exists = true;
return securityManager;
}
throw new IllegalAccessException("Cannot create more than one instance of IzouSecurityManager");
} | [
"public",
"static",
"SecurityManager",
"createSecurityManager",
"(",
"SystemMail",
"systemMail",
",",
"Main",
"main",
")",
"throws",
"IllegalAccessException",
"{",
"if",
"(",
"!",
"exists",
")",
"{",
"SecurityManager",
"securityManager",
"=",
"new",
"SecurityManager",... | Creates a SecurityManager. There can only be one single SecurityManager, so calling this method twice
will cause an illegal access exception.
@param systemMail the system mail object in order to send e-mails to owner in case of emergency
@param main a reference to the main instance
@return a SecurityManager from Izou
@throws IllegalAccessException thrown if this method is called more than once | [
"Creates",
"a",
"SecurityManager",
".",
"There",
"can",
"only",
"be",
"one",
"single",
"SecurityManager",
"so",
"calling",
"this",
"method",
"twice",
"will",
"cause",
"an",
"illegal",
"access",
"exception",
"."
] | 40a808b97998e17655c4a78e30ce7326148aed27 | https://github.com/intellimate/Izou/blob/40a808b97998e17655c4a78e30ce7326148aed27/src/main/java/org/intellimate/izou/security/SecurityManager.java#L45-L52 |
156,169 | intellimate/Izou | src/main/java/org/intellimate/izou/security/SecurityManager.java | SecurityManager.getAddOnModelForClassLoader | public Optional<AddOnModel> getAddOnModelForClassLoader() {
Class[] classes = getClassContext();
for (int i = classes.length - 1; i >= 0; i--) {
if (classes[i].getClassLoader() instanceof IzouPluginClassLoader && !classes[i].getName().toLowerCase()
.contains(IzouPluginClassLoader.PLUGIN_PACKAGE_PREFIX_IZOU_SDK)) {
ClassLoader classLoader = classes[i].getClassLoader();
return main.getAddOnInformationManager().getAddOnForClassLoader(classLoader);
}
}
return Optional.empty();
} | java | public Optional<AddOnModel> getAddOnModelForClassLoader() {
Class[] classes = getClassContext();
for (int i = classes.length - 1; i >= 0; i--) {
if (classes[i].getClassLoader() instanceof IzouPluginClassLoader && !classes[i].getName().toLowerCase()
.contains(IzouPluginClassLoader.PLUGIN_PACKAGE_PREFIX_IZOU_SDK)) {
ClassLoader classLoader = classes[i].getClassLoader();
return main.getAddOnInformationManager().getAddOnForClassLoader(classLoader);
}
}
return Optional.empty();
} | [
"public",
"Optional",
"<",
"AddOnModel",
">",
"getAddOnModelForClassLoader",
"(",
")",
"{",
"Class",
"[",
"]",
"classes",
"=",
"getClassContext",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"classes",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
";",
... | Gets the current AddOnModel, that is the AddOnModel for the class loader to which the class belongs that
triggered the security manager call, or throws a IzouPermissionException
@return AddOnModel or IzouPermissionException if the call was made from an AddOn, or null if no AddOn is responsible
@throws IzouPermissionException if the AddOnModel is not found | [
"Gets",
"the",
"current",
"AddOnModel",
"that",
"is",
"the",
"AddOnModel",
"for",
"the",
"class",
"loader",
"to",
"which",
"the",
"class",
"belongs",
"that",
"triggered",
"the",
"security",
"manager",
"call",
"or",
"throws",
"a",
"IzouPermissionException"
] | 40a808b97998e17655c4a78e30ce7326148aed27 | https://github.com/intellimate/Izou/blob/40a808b97998e17655c4a78e30ce7326148aed27/src/main/java/org/intellimate/izou/security/SecurityManager.java#L108-L118 |
156,170 | intellimate/Izou | src/main/java/org/intellimate/izou/security/SecurityManager.java | SecurityManager.check | private <T> void check(T t, BiConsumer<T, AddOnModel> specific) {
if (!shouldCheck()) {
return;
}
secureAccess.doElevated(this::getAddOnModelForClassLoader)
.ifPresent(addOnModel ->
secureAccess.doElevated(() -> specific.accept(t, addOnModel)));
} | java | private <T> void check(T t, BiConsumer<T, AddOnModel> specific) {
if (!shouldCheck()) {
return;
}
secureAccess.doElevated(this::getAddOnModelForClassLoader)
.ifPresent(addOnModel ->
secureAccess.doElevated(() -> specific.accept(t, addOnModel)));
} | [
"private",
"<",
"T",
">",
"void",
"check",
"(",
"T",
"t",
",",
"BiConsumer",
"<",
"T",
",",
"AddOnModel",
">",
"specific",
")",
"{",
"if",
"(",
"!",
"shouldCheck",
"(",
")",
")",
"{",
"return",
";",
"}",
"secureAccess",
".",
"doElevated",
"(",
"thi... | this method first performs some basic checks and then performs the specific check
@param t permission or file
@param specific the specific check | [
"this",
"method",
"first",
"performs",
"some",
"basic",
"checks",
"and",
"then",
"performs",
"the",
"specific",
"check"
] | 40a808b97998e17655c4a78e30ce7326148aed27 | https://github.com/intellimate/Izou/blob/40a808b97998e17655c4a78e30ce7326148aed27/src/main/java/org/intellimate/izou/security/SecurityManager.java#L134-L141 |
156,171 | zzycjcg/foundation | foundation-jersey/foundation-jersey-server/src/main/java/com/github/zzycjcg/foundation/jersey/server/config/SpringResourceConfig.java | SpringResourceConfig.setBeans | public void setBeans(Collection<?> beans)
{
if (!CollectionUtils.isEmpty(beans))
{
for (Object bean : beans)
{
register(bean);
}
}
} | java | public void setBeans(Collection<?> beans)
{
if (!CollectionUtils.isEmpty(beans))
{
for (Object bean : beans)
{
register(bean);
}
}
} | [
"public",
"void",
"setBeans",
"(",
"Collection",
"<",
"?",
">",
"beans",
")",
"{",
"if",
"(",
"!",
"CollectionUtils",
".",
"isEmpty",
"(",
"beans",
")",
")",
"{",
"for",
"(",
"Object",
"bean",
":",
"beans",
")",
"{",
"register",
"(",
"bean",
")",
"... | Sets the beans.
@param beans the new beans | [
"Sets",
"the",
"beans",
"."
] | 99267a1b7401b99bf65ea1ac6f3c466873049fd8 | https://github.com/zzycjcg/foundation/blob/99267a1b7401b99bf65ea1ac6f3c466873049fd8/foundation-jersey/foundation-jersey-server/src/main/java/com/github/zzycjcg/foundation/jersey/server/config/SpringResourceConfig.java#L21-L30 |
156,172 | adamfisk/littleshoot-commons-id | src/main/java/org/apache/commons/id/uuid/state/ReadWriteFileStateImpl.java | ReadWriteFileStateImpl.genXML | private String genXML(Set nodes) throws IOException {
Iterator it = nodes.iterator();
StringBuffer buf = new StringBuffer(1024);
buf.append(StateHelper.XML_DOC_START);
buf.append(getSynchInterval());
buf.append(StateHelper.XML_DOC_START_END);
while (it.hasNext()) {
Node n = (Node) it.next();
buf.append(StateHelper.XML_NODE_TAG_START);
buf.append(StateHelper.encodeMACAddress(n.getNodeIdentifier()));
buf.append(StateHelper.XML_NODE_TAG_AFTER_ID);
buf.append(n.getClockSequence());
buf.append(StateHelper.XML_NODE_TAG_AFTER_CSEQ);
buf.append(n.getLastTimestamp());
buf.append(StateHelper.XML_NODE_TAG_END);
}
buf.append(StateHelper.XML_DOC_END);
return buf.toString();
} | java | private String genXML(Set nodes) throws IOException {
Iterator it = nodes.iterator();
StringBuffer buf = new StringBuffer(1024);
buf.append(StateHelper.XML_DOC_START);
buf.append(getSynchInterval());
buf.append(StateHelper.XML_DOC_START_END);
while (it.hasNext()) {
Node n = (Node) it.next();
buf.append(StateHelper.XML_NODE_TAG_START);
buf.append(StateHelper.encodeMACAddress(n.getNodeIdentifier()));
buf.append(StateHelper.XML_NODE_TAG_AFTER_ID);
buf.append(n.getClockSequence());
buf.append(StateHelper.XML_NODE_TAG_AFTER_CSEQ);
buf.append(n.getLastTimestamp());
buf.append(StateHelper.XML_NODE_TAG_END);
}
buf.append(StateHelper.XML_DOC_END);
return buf.toString();
} | [
"private",
"String",
"genXML",
"(",
"Set",
"nodes",
")",
"throws",
"IOException",
"{",
"Iterator",
"it",
"=",
"nodes",
".",
"iterator",
"(",
")",
";",
"StringBuffer",
"buf",
"=",
"new",
"StringBuffer",
"(",
"1024",
")",
";",
"buf",
".",
"append",
"(",
... | Returns an XML string of the node Set.
@param nodes the Set to create xml for.
@return an XML string of the node Set.
@throws IOException an IOException. | [
"Returns",
"an",
"XML",
"string",
"of",
"the",
"node",
"Set",
"."
] | 49a8f5f2b10831c509876ca463bf1a87e1e49ae9 | https://github.com/adamfisk/littleshoot-commons-id/blob/49a8f5f2b10831c509876ca463bf1a87e1e49ae9/src/main/java/org/apache/commons/id/uuid/state/ReadWriteFileStateImpl.java#L54-L72 |
156,173 | adamfisk/littleshoot-commons-id | src/main/java/org/apache/commons/id/random/SessionIdGenerator.java | SessionIdGenerator.nextStringIdentifier | public String nextStringIdentifier() {
// Random value
//--------------
long currentRandom = randomizer.nextLong();
if (currentRandom < 0) {
currentRandom = -currentRandom;
}
// force value into 6 char range, and add to pad with zeros
// this gives a length of 7, when converted to base 36, and
// the first character (always 1 from the add) is dropped
currentRandom %= MAX_RANDOM_LEN;
currentRandom += MAX_RANDOM_LEN;
long currentTimeValue = 0;
int currentCount = 0;
synchronized (this) {
// Time
//--------------
currentTimeValue = (System.currentTimeMillis() / TIC_DIFFERENCE);
// force value into 3 char range, and add to pad with zeros
// this gives a length of 4, when converted to base 36, and
// the first character (always 1 from the add) is dropped
currentTimeValue %= MAX_TIME_SECTION_LEN;
currentTimeValue += MAX_TIME_SECTION_LEN;
// Count
//--------------
// Make the string unique by appending the count since last
// time flip.
// Count sessions only within tics (so the 'real' counter
// isn't exposed to the public).
if (lastTimeValue != currentTimeValue) {
lastTimeValue = currentTimeValue;
counter = 0;
}
currentCount = counter++;
}
// build string
//--------------
StringBuffer id = new StringBuffer
(AbstractStringIdentifierGenerator.DEFAULT_ALPHANUMERIC_IDENTIFIER_SIZE);
id.append(Long.toString(currentRandom,
AbstractStringIdentifierGenerator.ALPHA_NUMERIC_CHARSET_SIZE).substring(1)); // 6 chars
id.append(Long.toString(currentTimeValue,
AbstractStringIdentifierGenerator.ALPHA_NUMERIC_CHARSET_SIZE).substring(1)); // 3 chars
id.append(Long.toString(currentCount,
AbstractStringIdentifierGenerator.ALPHA_NUMERIC_CHARSET_SIZE)); // 1+ chars
return id.toString();
} | java | public String nextStringIdentifier() {
// Random value
//--------------
long currentRandom = randomizer.nextLong();
if (currentRandom < 0) {
currentRandom = -currentRandom;
}
// force value into 6 char range, and add to pad with zeros
// this gives a length of 7, when converted to base 36, and
// the first character (always 1 from the add) is dropped
currentRandom %= MAX_RANDOM_LEN;
currentRandom += MAX_RANDOM_LEN;
long currentTimeValue = 0;
int currentCount = 0;
synchronized (this) {
// Time
//--------------
currentTimeValue = (System.currentTimeMillis() / TIC_DIFFERENCE);
// force value into 3 char range, and add to pad with zeros
// this gives a length of 4, when converted to base 36, and
// the first character (always 1 from the add) is dropped
currentTimeValue %= MAX_TIME_SECTION_LEN;
currentTimeValue += MAX_TIME_SECTION_LEN;
// Count
//--------------
// Make the string unique by appending the count since last
// time flip.
// Count sessions only within tics (so the 'real' counter
// isn't exposed to the public).
if (lastTimeValue != currentTimeValue) {
lastTimeValue = currentTimeValue;
counter = 0;
}
currentCount = counter++;
}
// build string
//--------------
StringBuffer id = new StringBuffer
(AbstractStringIdentifierGenerator.DEFAULT_ALPHANUMERIC_IDENTIFIER_SIZE);
id.append(Long.toString(currentRandom,
AbstractStringIdentifierGenerator.ALPHA_NUMERIC_CHARSET_SIZE).substring(1)); // 6 chars
id.append(Long.toString(currentTimeValue,
AbstractStringIdentifierGenerator.ALPHA_NUMERIC_CHARSET_SIZE).substring(1)); // 3 chars
id.append(Long.toString(currentCount,
AbstractStringIdentifierGenerator.ALPHA_NUMERIC_CHARSET_SIZE)); // 1+ chars
return id.toString();
} | [
"public",
"String",
"nextStringIdentifier",
"(",
")",
"{",
"// Random value",
"//--------------",
"long",
"currentRandom",
"=",
"randomizer",
".",
"nextLong",
"(",
")",
";",
"if",
"(",
"currentRandom",
"<",
"0",
")",
"{",
"currentRandom",
"=",
"-",
"currentRando... | Gets the next new identifier.
<p>Only guaranteed unique within this JVM, but fairly safe
for cross JVM usage as well.</p>
<p>Format of identifier is
<code>[6 chars random][3 chars time][1+ chars count]</code></p>
@return the next 10 char String identifier | [
"Gets",
"the",
"next",
"new",
"identifier",
"."
] | 49a8f5f2b10831c509876ca463bf1a87e1e49ae9 | https://github.com/adamfisk/littleshoot-commons-id/blob/49a8f5f2b10831c509876ca463bf1a87e1e49ae9/src/main/java/org/apache/commons/id/random/SessionIdGenerator.java#L106-L159 |
156,174 | mbrade/prefixedproperties | pp-spring/src/main/java/net/sf/prefixedproperties/spring/PrefixedPropertyOverrideConfigurer.java | PrefixedPropertyOverrideConfigurer.createProperties | protected synchronized PrefixedProperties createProperties() {
if (myProperties == null) {
PrefixedProperties resultProperties = null;
String environment = defaultPrefix;
if (environmentFactory != null) {
environment = environmentFactory.getEnvironment();
} else if (defaultPrefixSystemPropertyKey != null) {
environment = System.getProperty(defaultPrefixSystemPropertyKey);
if (environment == null) {
if (logger.isWarnEnabled()) {
logger.warn(String.format("Didn't found system property key to set default prefix: %1s",
defaultPrefixSystemPropertyKey));
}
}
}
if (prefixConfigList != null) {
resultProperties = PrefixedProperties.createCascadingPrefixProperties(prefixConfigList);
} else {
if (environment != null) {
resultProperties = PrefixedProperties.createCascadingPrefixProperties(environment);
} else {
resultProperties = new PrefixedProperties();
}
}
resultProperties.setDefaultPrefix(environment);
if (logger.isInfoEnabled()) {
logger.info(String.format("Setting default prefix to: %1s", environment));
}
resultProperties.setMixDefaultAndLocalPrefixSettings(mixDefaultAndLocalPrefixConfigurations);
myProperties = resultProperties;
}
return myProperties;
} | java | protected synchronized PrefixedProperties createProperties() {
if (myProperties == null) {
PrefixedProperties resultProperties = null;
String environment = defaultPrefix;
if (environmentFactory != null) {
environment = environmentFactory.getEnvironment();
} else if (defaultPrefixSystemPropertyKey != null) {
environment = System.getProperty(defaultPrefixSystemPropertyKey);
if (environment == null) {
if (logger.isWarnEnabled()) {
logger.warn(String.format("Didn't found system property key to set default prefix: %1s",
defaultPrefixSystemPropertyKey));
}
}
}
if (prefixConfigList != null) {
resultProperties = PrefixedProperties.createCascadingPrefixProperties(prefixConfigList);
} else {
if (environment != null) {
resultProperties = PrefixedProperties.createCascadingPrefixProperties(environment);
} else {
resultProperties = new PrefixedProperties();
}
}
resultProperties.setDefaultPrefix(environment);
if (logger.isInfoEnabled()) {
logger.info(String.format("Setting default prefix to: %1s", environment));
}
resultProperties.setMixDefaultAndLocalPrefixSettings(mixDefaultAndLocalPrefixConfigurations);
myProperties = resultProperties;
}
return myProperties;
} | [
"protected",
"synchronized",
"PrefixedProperties",
"createProperties",
"(",
")",
"{",
"if",
"(",
"myProperties",
"==",
"null",
")",
"{",
"PrefixedProperties",
"resultProperties",
"=",
"null",
";",
"String",
"environment",
"=",
"defaultPrefix",
";",
"if",
"(",
"env... | Creates the properties.
@return the prefixed properties | [
"Creates",
"the",
"properties",
"."
] | ac430409ea37e244158002b3cf1504417835a0b2 | https://github.com/mbrade/prefixedproperties/blob/ac430409ea37e244158002b3cf1504417835a0b2/pp-spring/src/main/java/net/sf/prefixedproperties/spring/PrefixedPropertyOverrideConfigurer.java#L94-L126 |
156,175 | mbrade/prefixedproperties | pp-spring/src/main/java/net/sf/prefixedproperties/spring/PrefixedPropertyOverrideConfigurer.java | PrefixedPropertyOverrideConfigurer.getEffectiveProperties | @ManagedAttribute()
public List<String> getEffectiveProperties() {
final List<String> properties = new LinkedList<String>();
for (final String key : myProperties.stringPropertyNames()) {
properties.add(key + "=" + myProperties.get(key));
}
return properties;
} | java | @ManagedAttribute()
public List<String> getEffectiveProperties() {
final List<String> properties = new LinkedList<String>();
for (final String key : myProperties.stringPropertyNames()) {
properties.add(key + "=" + myProperties.get(key));
}
return properties;
} | [
"@",
"ManagedAttribute",
"(",
")",
"public",
"List",
"<",
"String",
">",
"getEffectiveProperties",
"(",
")",
"{",
"final",
"List",
"<",
"String",
">",
"properties",
"=",
"new",
"LinkedList",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"final",
"String... | Gets the effective properties.
@return the effective properties | [
"Gets",
"the",
"effective",
"properties",
"."
] | ac430409ea37e244158002b3cf1504417835a0b2 | https://github.com/mbrade/prefixedproperties/blob/ac430409ea37e244158002b3cf1504417835a0b2/pp-spring/src/main/java/net/sf/prefixedproperties/spring/PrefixedPropertyOverrideConfigurer.java#L133-L140 |
156,176 | dbracewell/hermes | hermes-core/src/main/java/com/davidbracewell/hermes/DocumentFactory.java | DocumentFactory.getInstance | public static DocumentFactory getInstance() {
if (CONFIGURED_INSTANCE == null) {
synchronized (DocumentFactory.class) {
if (CONFIGURED_INSTANCE == null) {
CONFIGURED_INSTANCE = new DocumentFactory();
}
}
}
return CONFIGURED_INSTANCE;
} | java | public static DocumentFactory getInstance() {
if (CONFIGURED_INSTANCE == null) {
synchronized (DocumentFactory.class) {
if (CONFIGURED_INSTANCE == null) {
CONFIGURED_INSTANCE = new DocumentFactory();
}
}
}
return CONFIGURED_INSTANCE;
} | [
"public",
"static",
"DocumentFactory",
"getInstance",
"(",
")",
"{",
"if",
"(",
"CONFIGURED_INSTANCE",
"==",
"null",
")",
"{",
"synchronized",
"(",
"DocumentFactory",
".",
"class",
")",
"{",
"if",
"(",
"CONFIGURED_INSTANCE",
"==",
"null",
")",
"{",
"CONFIGURED... | Gets instance of the document factory configured using configuration settings.
@return A document factory whose preprocessors are set via configuration options | [
"Gets",
"instance",
"of",
"the",
"document",
"factory",
"configured",
"using",
"configuration",
"settings",
"."
] | 9ebefe7ad5dea1b731ae6931a30771eb75325ea3 | https://github.com/dbracewell/hermes/blob/9ebefe7ad5dea1b731ae6931a30771eb75325ea3/hermes-core/src/main/java/com/davidbracewell/hermes/DocumentFactory.java#L74-L83 |
156,177 | jpelzer/pelzer-util | src/main/java/com/pelzer/util/mp3/MP3AudioOnlyInputStream.java | MP3AudioOnlyInputStream.bufferedPeek | private int bufferedPeek(final int offset) throws IOException {
if (buffer.size() > offset) {
// We've got enough of the file in memory already, we just pull from the buffer
final ListIterator<Integer> iterator = buffer.listIterator(offset);
return iterator.next();
}
// We don't have enough in the buffer to peek... Read until we do, then recurse.
while (buffer.size() <= offset) {
final int current = in.read();
if (current < 0)
return -1;
buffer.add(current);
}
// Buffer should now be full enough to answer the request.
return bufferedPeek(offset);
} | java | private int bufferedPeek(final int offset) throws IOException {
if (buffer.size() > offset) {
// We've got enough of the file in memory already, we just pull from the buffer
final ListIterator<Integer> iterator = buffer.listIterator(offset);
return iterator.next();
}
// We don't have enough in the buffer to peek... Read until we do, then recurse.
while (buffer.size() <= offset) {
final int current = in.read();
if (current < 0)
return -1;
buffer.add(current);
}
// Buffer should now be full enough to answer the request.
return bufferedPeek(offset);
} | [
"private",
"int",
"bufferedPeek",
"(",
"final",
"int",
"offset",
")",
"throws",
"IOException",
"{",
"if",
"(",
"buffer",
".",
"size",
"(",
")",
">",
"offset",
")",
"{",
"// We've got enough of the file in memory already, we just pull from the buffer\r",
"final",
"List... | Reads throw the buffer up to the given index, filling the buffer from the underlying stream if
necessary. Returns -1 if the underlying stream terminates before the given offset can be
reached. | [
"Reads",
"throw",
"the",
"buffer",
"up",
"to",
"the",
"given",
"index",
"filling",
"the",
"buffer",
"from",
"the",
"underlying",
"stream",
"if",
"necessary",
".",
"Returns",
"-",
"1",
"if",
"the",
"underlying",
"stream",
"terminates",
"before",
"the",
"given... | ec14f2573fd977d1442dba5d1507a264f5ea9aa6 | https://github.com/jpelzer/pelzer-util/blob/ec14f2573fd977d1442dba5d1507a264f5ea9aa6/src/main/java/com/pelzer/util/mp3/MP3AudioOnlyInputStream.java#L89-L104 |
156,178 | riversun/d6 | src/main/java/org/riversun/d6/core/ModelWrapper.java | ModelWrapper.setValue | public void setValue(String columnName, Object value) {
D6ModelClassFieldInfo fieldInfo = mFieldMap.get(columnName);
if (fieldInfo != null) {
fieldInfo.value = value;
}
else {
// case field info is null
final String[] parts = columnName.split("__");
if (parts.length > 0 && mFieldMap.containsKey(parts[0])) {
// check is field composit type like MySQL's Geometry
D6ModelClassFieldInfo compositTypeFieldInfo = mFieldMap.get(parts[0]);
if (compositTypeFieldInfo.valuesForSpecialType == null) {
compositTypeFieldInfo.valuesForSpecialType = new ArrayList<Object>();
}
compositTypeFieldInfo.valuesForSpecialType.add(value);
}
}
} | java | public void setValue(String columnName, Object value) {
D6ModelClassFieldInfo fieldInfo = mFieldMap.get(columnName);
if (fieldInfo != null) {
fieldInfo.value = value;
}
else {
// case field info is null
final String[] parts = columnName.split("__");
if (parts.length > 0 && mFieldMap.containsKey(parts[0])) {
// check is field composit type like MySQL's Geometry
D6ModelClassFieldInfo compositTypeFieldInfo = mFieldMap.get(parts[0]);
if (compositTypeFieldInfo.valuesForSpecialType == null) {
compositTypeFieldInfo.valuesForSpecialType = new ArrayList<Object>();
}
compositTypeFieldInfo.valuesForSpecialType.add(value);
}
}
} | [
"public",
"void",
"setValue",
"(",
"String",
"columnName",
",",
"Object",
"value",
")",
"{",
"D6ModelClassFieldInfo",
"fieldInfo",
"=",
"mFieldMap",
".",
"get",
"(",
"columnName",
")",
";",
"if",
"(",
"fieldInfo",
"!=",
"null",
")",
"{",
"fieldInfo",
".",
... | Set the value to a field of the model object.The field is associated with
DB column name by DBColumn annotation.
@param columnName
@param value | [
"Set",
"the",
"value",
"to",
"a",
"field",
"of",
"the",
"model",
"object",
".",
"The",
"field",
"is",
"associated",
"with",
"DB",
"column",
"name",
"by",
"DBColumn",
"annotation",
"."
] | 2798bd876b9380dbfea8182d11ad306cb1b0e114 | https://github.com/riversun/d6/blob/2798bd876b9380dbfea8182d11ad306cb1b0e114/src/main/java/org/riversun/d6/core/ModelWrapper.java#L74-L101 |
156,179 | riversun/d6 | src/main/java/org/riversun/d6/core/ModelWrapper.java | ModelWrapper.getAsObject | public T getAsObject() {
try {
T modelClassObj = modelClazz.newInstance();
Set<String> columnNameSet = mFieldMap.keySet();
for (String columnName : columnNameSet) {
D6ModelClassFieldInfo fieldInfo = mFieldMap.get(columnName);
final Field field = fieldInfo.field;
final Object value = fieldInfo.value;
if (value != null) {
// try to set 'null' if available
try {
field.set(modelClassObj, null);
} catch (Exception e) {
}
try {
field.set(modelClassObj, value);
} catch (IllegalAccessException e) {
// handling this exception for field.set(o, value);
loge("#getAsObject", e);
} catch (IllegalArgumentException e) {
// e.printStackTrace();
final String name = field.getName();
final Class<?> type = field.getType();
String msg = "The value of '" + columnName + "'=" + value + "(" + value.getClass() + ") couldn't set to variable '" + name + "'(" + type + ")";
loge("#getAsObject " + msg);
}
} else {
// value is null
// check is this column CompositType like MySQL's Geometry
final List<Object> compositObjValues = fieldInfo.valuesForSpecialType;
if (field.getType() == org.riversun.d6.model.Geometry.class) {
if (compositObjValues != null && compositObjValues.size() > 1) {
final org.riversun.d6.model.Geometry newGeometryObj = new org.riversun.d6.model.Geometry();
newGeometryObj.x = (Double) compositObjValues.get(0);
newGeometryObj.y = (Double) compositObjValues.get(1);
field.set(modelClassObj, newGeometryObj);
}
}
}
}
return modelClassObj;
} catch (IllegalAccessException e) {
throw new D6RuntimeException(e);
} catch (InstantiationException e) {
throw new D6RuntimeException("Cannot instanciate model object from '" + modelClazz.getName() + "' If you declare '" + modelClazz.getName() + "' as inner class, please make it static.");
}
} | java | public T getAsObject() {
try {
T modelClassObj = modelClazz.newInstance();
Set<String> columnNameSet = mFieldMap.keySet();
for (String columnName : columnNameSet) {
D6ModelClassFieldInfo fieldInfo = mFieldMap.get(columnName);
final Field field = fieldInfo.field;
final Object value = fieldInfo.value;
if (value != null) {
// try to set 'null' if available
try {
field.set(modelClassObj, null);
} catch (Exception e) {
}
try {
field.set(modelClassObj, value);
} catch (IllegalAccessException e) {
// handling this exception for field.set(o, value);
loge("#getAsObject", e);
} catch (IllegalArgumentException e) {
// e.printStackTrace();
final String name = field.getName();
final Class<?> type = field.getType();
String msg = "The value of '" + columnName + "'=" + value + "(" + value.getClass() + ") couldn't set to variable '" + name + "'(" + type + ")";
loge("#getAsObject " + msg);
}
} else {
// value is null
// check is this column CompositType like MySQL's Geometry
final List<Object> compositObjValues = fieldInfo.valuesForSpecialType;
if (field.getType() == org.riversun.d6.model.Geometry.class) {
if (compositObjValues != null && compositObjValues.size() > 1) {
final org.riversun.d6.model.Geometry newGeometryObj = new org.riversun.d6.model.Geometry();
newGeometryObj.x = (Double) compositObjValues.get(0);
newGeometryObj.y = (Double) compositObjValues.get(1);
field.set(modelClassObj, newGeometryObj);
}
}
}
}
return modelClassObj;
} catch (IllegalAccessException e) {
throw new D6RuntimeException(e);
} catch (InstantiationException e) {
throw new D6RuntimeException("Cannot instanciate model object from '" + modelClazz.getName() + "' If you declare '" + modelClazz.getName() + "' as inner class, please make it static.");
}
} | [
"public",
"T",
"getAsObject",
"(",
")",
"{",
"try",
"{",
"T",
"modelClassObj",
"=",
"modelClazz",
".",
"newInstance",
"(",
")",
";",
"Set",
"<",
"String",
">",
"columnNameSet",
"=",
"mFieldMap",
".",
"keySet",
"(",
")",
";",
"for",
"(",
"String",
"colu... | Get the model object populated with the value of the DB search results
@return | [
"Get",
"the",
"model",
"object",
"populated",
"with",
"the",
"value",
"of",
"the",
"DB",
"search",
"results"
] | 2798bd876b9380dbfea8182d11ad306cb1b0e114 | https://github.com/riversun/d6/blob/2798bd876b9380dbfea8182d11ad306cb1b0e114/src/main/java/org/riversun/d6/core/ModelWrapper.java#L108-L175 |
156,180 | jmeetsma/Iglu-Common | src/main/java/org/ijsberg/iglu/access/StandardSession.java | StandardSession.login | public User login(Credentials credentials) throws SecurityException {
//check if user is logged in already
User loggedInUser = getUser();
if (loggedInUser != null) {
logout();
//throw new SecurityException("user already logged in as '" + loggedInUser.getId() + "'");
}
User user = accessManager.authenticate(credentials);
if (user != null) {
this.user = user;
userSettings = user.getSettings();
}
return user;
} | java | public User login(Credentials credentials) throws SecurityException {
//check if user is logged in already
User loggedInUser = getUser();
if (loggedInUser != null) {
logout();
//throw new SecurityException("user already logged in as '" + loggedInUser.getId() + "'");
}
User user = accessManager.authenticate(credentials);
if (user != null) {
this.user = user;
userSettings = user.getSettings();
}
return user;
} | [
"public",
"User",
"login",
"(",
"Credentials",
"credentials",
")",
"throws",
"SecurityException",
"{",
"//check if user is logged in already\r",
"User",
"loggedInUser",
"=",
"getUser",
"(",
")",
";",
"if",
"(",
"loggedInUser",
"!=",
"null",
")",
"{",
"logout",
"("... | Authenticates a user for a certain realm based on credentials.
@param credentials
@return transient user if authentication succeeded or null if it didn't
@throws SecurityException if user already logged in
@throws AuthenticationException if some user action is required | [
"Authenticates",
"a",
"user",
"for",
"a",
"certain",
"realm",
"based",
"on",
"credentials",
"."
] | 0fb0885775b576209ff1b5a0f67e3c25a99a6420 | https://github.com/jmeetsma/Iglu-Common/blob/0fb0885775b576209ff1b5a0f67e3c25a99a6420/src/main/java/org/ijsberg/iglu/access/StandardSession.java#L170-L185 |
156,181 | jmeetsma/Iglu-Common | src/main/java/org/ijsberg/iglu/access/StandardSession.java | StandardSession.onDestruction | public void onDestruction() {
//Iterator i = new ArrayList(agents.values()).iterator();
for (Component component : agentComponents.values()) {
System.out.println(component + " " + Arrays.asList(component.getInterfaces()).contains(SessionDestructionListener.class));
if(Arrays.asList(component.getInterfaces()).contains(SessionDestructionListener.class)) {
try {
component.invoke("onSessionDestruction");
} catch (InvocationTargetException e) {
throw new ConfigurationException(e);
} catch (NoSuchMethodException e) {
throw new ConfigurationException(e);
}
}
accessManager.removeAgent(component);
}
//close receivers
/* Iterator receiverIterator = getReceivers().iterator();
while (receiverIterator.hasNext())
{
ReceiverQueue r = (ReceiverQueue) receiverIterator.next();
r.close();
}*/
attributes.clear();
} | java | public void onDestruction() {
//Iterator i = new ArrayList(agents.values()).iterator();
for (Component component : agentComponents.values()) {
System.out.println(component + " " + Arrays.asList(component.getInterfaces()).contains(SessionDestructionListener.class));
if(Arrays.asList(component.getInterfaces()).contains(SessionDestructionListener.class)) {
try {
component.invoke("onSessionDestruction");
} catch (InvocationTargetException e) {
throw new ConfigurationException(e);
} catch (NoSuchMethodException e) {
throw new ConfigurationException(e);
}
}
accessManager.removeAgent(component);
}
//close receivers
/* Iterator receiverIterator = getReceivers().iterator();
while (receiverIterator.hasNext())
{
ReceiverQueue r = (ReceiverQueue) receiverIterator.next();
r.close();
}*/
attributes.clear();
} | [
"public",
"void",
"onDestruction",
"(",
")",
"{",
"//Iterator i = new ArrayList(agents.values()).iterator();\r",
"for",
"(",
"Component",
"component",
":",
"agentComponents",
".",
"values",
"(",
")",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"component",
... | Performs destruction of agents and closes message receivers. | [
"Performs",
"destruction",
"of",
"agents",
"and",
"closes",
"message",
"receivers",
"."
] | 0fb0885775b576209ff1b5a0f67e3c25a99a6420 | https://github.com/jmeetsma/Iglu-Common/blob/0fb0885775b576209ff1b5a0f67e3c25a99a6420/src/main/java/org/ijsberg/iglu/access/StandardSession.java#L191-L215 |
156,182 | dihedron/dihedron-commons | src/main/java/org/dihedron/core/properties/Properties.java | Properties.load | public void load(InputStream stream, String separator) throws IOException, PropertiesException {
try(DataInputStream data = new DataInputStream(stream); Reader reader = new InputStreamReader(data); BufferedReader br = new BufferedReader(reader)) {
String line;
StringBuilder buffer = new StringBuilder();
while ((line = br.readLine()) != null) {
if(Strings.trimRight(line).startsWith(LINE_COMMENT_START)) {
// comment line, skip!
continue;
} else {
// now check if multi-line property
if(line.endsWith(CONTINUE_ON_NEW_LINE)) {
// middle line in multi-line, add and skip parsing
buffer.append(line.replaceFirst("\\\\$", ""));
continue;
} else {
// ordinary line, or end of multi-line: add and parse
buffer.append(line);
}
}
line = buffer.toString().trim();
buffer.setLength(0);
int index = -1;
if(line.length() > 0 && (index = line.lastIndexOf(separator)) != -1) {
String key = line.substring(0, index).trim();
String value = line.substring(index + separator.length()).trim();
if("@".equals(key)) {
logger.trace("including and overriding values defined so far with file '{}'", value);
load(value, separator);
} else {
logger.trace("adding '{}' => '{}'", key, value);
this.put(key.trim(), value.trim());
}
}
}
if(buffer.length() > 0) {
logger.warn("multi-line property '{}' is not properly terminated", buffer);
}
}
} | java | public void load(InputStream stream, String separator) throws IOException, PropertiesException {
try(DataInputStream data = new DataInputStream(stream); Reader reader = new InputStreamReader(data); BufferedReader br = new BufferedReader(reader)) {
String line;
StringBuilder buffer = new StringBuilder();
while ((line = br.readLine()) != null) {
if(Strings.trimRight(line).startsWith(LINE_COMMENT_START)) {
// comment line, skip!
continue;
} else {
// now check if multi-line property
if(line.endsWith(CONTINUE_ON_NEW_LINE)) {
// middle line in multi-line, add and skip parsing
buffer.append(line.replaceFirst("\\\\$", ""));
continue;
} else {
// ordinary line, or end of multi-line: add and parse
buffer.append(line);
}
}
line = buffer.toString().trim();
buffer.setLength(0);
int index = -1;
if(line.length() > 0 && (index = line.lastIndexOf(separator)) != -1) {
String key = line.substring(0, index).trim();
String value = line.substring(index + separator.length()).trim();
if("@".equals(key)) {
logger.trace("including and overriding values defined so far with file '{}'", value);
load(value, separator);
} else {
logger.trace("adding '{}' => '{}'", key, value);
this.put(key.trim(), value.trim());
}
}
}
if(buffer.length() > 0) {
logger.warn("multi-line property '{}' is not properly terminated", buffer);
}
}
} | [
"public",
"void",
"load",
"(",
"InputStream",
"stream",
",",
"String",
"separator",
")",
"throws",
"IOException",
",",
"PropertiesException",
"{",
"try",
"(",
"DataInputStream",
"data",
"=",
"new",
"DataInputStream",
"(",
"stream",
")",
";",
"Reader",
"reader",
... | Loads the properties from an input stream.
@param stream
an input stream.
@param separator
the separator character.
@throws IOException
@throws PropertiesException | [
"Loads",
"the",
"properties",
"from",
"an",
"input",
"stream",
"."
] | a5194cdaa0d6417ef4aade6ea407a1cad6e8458e | https://github.com/dihedron/dihedron-commons/blob/a5194cdaa0d6417ef4aade6ea407a1cad6e8458e/src/main/java/org/dihedron/core/properties/Properties.java#L205-L244 |
156,183 | dihedron/dihedron-commons | src/main/java/org/dihedron/core/properties/Properties.java | Properties.merge | public void merge(Properties properties) throws PropertiesException {
if(isLocked()) {
throw new PropertiesException("properties map is locked, its contents cannot be altered.");
}
assert properties != null;
for(Entry<String, String> entry : properties.entrySet()) {
this.put(entry.getKey(), entry.getValue());
}
} | java | public void merge(Properties properties) throws PropertiesException {
if(isLocked()) {
throw new PropertiesException("properties map is locked, its contents cannot be altered.");
}
assert properties != null;
for(Entry<String, String> entry : properties.entrySet()) {
this.put(entry.getKey(), entry.getValue());
}
} | [
"public",
"void",
"merge",
"(",
"Properties",
"properties",
")",
"throws",
"PropertiesException",
"{",
"if",
"(",
"isLocked",
"(",
")",
")",
"{",
"throw",
"new",
"PropertiesException",
"(",
"\"properties map is locked, its contents cannot be altered.\"",
")",
";",
"}"... | Merges the contents of another property set into this; if this object and
the other one both contain the same keys, those is the other object will
override this object's.
@param properties
the other property set to merge into this (possibly overriding).
@throws PropertiesException | [
"Merges",
"the",
"contents",
"of",
"another",
"property",
"set",
"into",
"this",
";",
"if",
"this",
"object",
"and",
"the",
"other",
"one",
"both",
"contain",
"the",
"same",
"keys",
"those",
"is",
"the",
"other",
"object",
"will",
"override",
"this",
"obje... | a5194cdaa0d6417ef4aade6ea407a1cad6e8458e | https://github.com/dihedron/dihedron-commons/blob/a5194cdaa0d6417ef4aade6ea407a1cad6e8458e/src/main/java/org/dihedron/core/properties/Properties.java#L255-L263 |
156,184 | dihedron/dihedron-commons | src/main/java/org/dihedron/core/properties/Properties.java | Properties.put | @Override
public String put(String key, String value) throws PropertiesException {
if(isLocked()) {
throw new PropertiesException("properties map is locked, its contents cannot be altered.");
}
return super.put(key, value);
} | java | @Override
public String put(String key, String value) throws PropertiesException {
if(isLocked()) {
throw new PropertiesException("properties map is locked, its contents cannot be altered.");
}
return super.put(key, value);
} | [
"@",
"Override",
"public",
"String",
"put",
"(",
"String",
"key",
",",
"String",
"value",
")",
"throws",
"PropertiesException",
"{",
"if",
"(",
"isLocked",
"(",
")",
")",
"{",
"throw",
"new",
"PropertiesException",
"(",
"\"properties map is locked, its contents ca... | Puts a new value into the properties map.
@param key
the key of the property to set.
@param value
the value of the property to set.
@return
the previous value associated with the key, or null if no such value
was present in the map.
@throws PropertiesException
if the map is in read-only mode (note: it's a runtime exception). | [
"Puts",
"a",
"new",
"value",
"into",
"the",
"properties",
"map",
"."
] | a5194cdaa0d6417ef4aade6ea407a1cad6e8458e | https://github.com/dihedron/dihedron-commons/blob/a5194cdaa0d6417ef4aade6ea407a1cad6e8458e/src/main/java/org/dihedron/core/properties/Properties.java#L290-L296 |
156,185 | janus-project/guava.janusproject.io | guava/src/com/google/common/util/concurrent/MoreExecutors.java | MoreExecutors.getExitingExecutorService | @Beta
public static ExecutorService getExitingExecutorService(
ThreadPoolExecutor executor, long terminationTimeout, TimeUnit timeUnit) {
return new Application()
.getExitingExecutorService(executor, terminationTimeout, timeUnit);
} | java | @Beta
public static ExecutorService getExitingExecutorService(
ThreadPoolExecutor executor, long terminationTimeout, TimeUnit timeUnit) {
return new Application()
.getExitingExecutorService(executor, terminationTimeout, timeUnit);
} | [
"@",
"Beta",
"public",
"static",
"ExecutorService",
"getExitingExecutorService",
"(",
"ThreadPoolExecutor",
"executor",
",",
"long",
"terminationTimeout",
",",
"TimeUnit",
"timeUnit",
")",
"{",
"return",
"new",
"Application",
"(",
")",
".",
"getExitingExecutorService",
... | Converts the given ThreadPoolExecutor into an ExecutorService that exits
when the application is complete. It does so by using daemon threads and
adding a shutdown hook to wait for their completion.
<p>This is mainly for fixed thread pools.
See {@link Executors#newFixedThreadPool(int)}.
@param executor the executor to modify to make sure it exits when the
application is finished
@param terminationTimeout how long to wait for the executor to
finish before terminating the JVM
@param timeUnit unit of time for the time parameter
@return an unmodifiable version of the input which will not hang the JVM | [
"Converts",
"the",
"given",
"ThreadPoolExecutor",
"into",
"an",
"ExecutorService",
"that",
"exits",
"when",
"the",
"application",
"is",
"complete",
".",
"It",
"does",
"so",
"by",
"using",
"daemon",
"threads",
"and",
"adding",
"a",
"shutdown",
"hook",
"to",
"wa... | 1c48fb672c9fdfddf276970570f703fa1115f588 | https://github.com/janus-project/guava.janusproject.io/blob/1c48fb672c9fdfddf276970570f703fa1115f588/guava/src/com/google/common/util/concurrent/MoreExecutors.java#L83-L88 |
156,186 | janus-project/guava.janusproject.io | guava/src/com/google/common/util/concurrent/MoreExecutors.java | MoreExecutors.getExitingScheduledExecutorService | @Beta
public static ScheduledExecutorService getExitingScheduledExecutorService(
ScheduledThreadPoolExecutor executor, long terminationTimeout, TimeUnit timeUnit) {
return new Application()
.getExitingScheduledExecutorService(executor, terminationTimeout, timeUnit);
} | java | @Beta
public static ScheduledExecutorService getExitingScheduledExecutorService(
ScheduledThreadPoolExecutor executor, long terminationTimeout, TimeUnit timeUnit) {
return new Application()
.getExitingScheduledExecutorService(executor, terminationTimeout, timeUnit);
} | [
"@",
"Beta",
"public",
"static",
"ScheduledExecutorService",
"getExitingScheduledExecutorService",
"(",
"ScheduledThreadPoolExecutor",
"executor",
",",
"long",
"terminationTimeout",
",",
"TimeUnit",
"timeUnit",
")",
"{",
"return",
"new",
"Application",
"(",
")",
".",
"g... | Converts the given ScheduledThreadPoolExecutor into a
ScheduledExecutorService that exits when the application is complete. It
does so by using daemon threads and adding a shutdown hook to wait for
their completion.
<p>This is mainly for fixed thread pools.
See {@link Executors#newScheduledThreadPool(int)}.
@param executor the executor to modify to make sure it exits when the
application is finished
@param terminationTimeout how long to wait for the executor to
finish before terminating the JVM
@param timeUnit unit of time for the time parameter
@return an unmodifiable version of the input which will not hang the JVM | [
"Converts",
"the",
"given",
"ScheduledThreadPoolExecutor",
"into",
"a",
"ScheduledExecutorService",
"that",
"exits",
"when",
"the",
"application",
"is",
"complete",
".",
"It",
"does",
"so",
"by",
"using",
"daemon",
"threads",
"and",
"adding",
"a",
"shutdown",
"hoo... | 1c48fb672c9fdfddf276970570f703fa1115f588 | https://github.com/janus-project/guava.janusproject.io/blob/1c48fb672c9fdfddf276970570f703fa1115f588/guava/src/com/google/common/util/concurrent/MoreExecutors.java#L106-L111 |
156,187 | janus-project/guava.janusproject.io | guava/src/com/google/common/util/concurrent/MoreExecutors.java | MoreExecutors.shutdownAndAwaitTermination | @Beta
public static boolean shutdownAndAwaitTermination(
ExecutorService service, long timeout, TimeUnit unit) {
checkNotNull(unit);
// Disable new tasks from being submitted
service.shutdown();
try {
long halfTimeoutNanos = TimeUnit.NANOSECONDS.convert(timeout, unit) / 2;
// Wait for half the duration of the timeout for existing tasks to terminate
if (!service.awaitTermination(halfTimeoutNanos, TimeUnit.NANOSECONDS)) {
// Cancel currently executing tasks
service.shutdownNow();
// Wait the other half of the timeout for tasks to respond to being cancelled
service.awaitTermination(halfTimeoutNanos, TimeUnit.NANOSECONDS);
}
} catch (InterruptedException ie) {
// Preserve interrupt status
Thread.currentThread().interrupt();
// (Re-)Cancel if current thread also interrupted
service.shutdownNow();
}
return service.isTerminated();
} | java | @Beta
public static boolean shutdownAndAwaitTermination(
ExecutorService service, long timeout, TimeUnit unit) {
checkNotNull(unit);
// Disable new tasks from being submitted
service.shutdown();
try {
long halfTimeoutNanos = TimeUnit.NANOSECONDS.convert(timeout, unit) / 2;
// Wait for half the duration of the timeout for existing tasks to terminate
if (!service.awaitTermination(halfTimeoutNanos, TimeUnit.NANOSECONDS)) {
// Cancel currently executing tasks
service.shutdownNow();
// Wait the other half of the timeout for tasks to respond to being cancelled
service.awaitTermination(halfTimeoutNanos, TimeUnit.NANOSECONDS);
}
} catch (InterruptedException ie) {
// Preserve interrupt status
Thread.currentThread().interrupt();
// (Re-)Cancel if current thread also interrupted
service.shutdownNow();
}
return service.isTerminated();
} | [
"@",
"Beta",
"public",
"static",
"boolean",
"shutdownAndAwaitTermination",
"(",
"ExecutorService",
"service",
",",
"long",
"timeout",
",",
"TimeUnit",
"unit",
")",
"{",
"checkNotNull",
"(",
"unit",
")",
";",
"// Disable new tasks from being submitted",
"service",
".",... | Shuts down the given executor gradually, first disabling new submissions and later cancelling
existing tasks.
<p>The method takes the following steps:
<ol>
<li>calls {@link ExecutorService#shutdown()}, disabling acceptance of new submitted tasks.
<li>waits for half of the specified timeout.
<li>if the timeout expires, it calls {@link ExecutorService#shutdownNow()}, cancelling
pending tasks and interrupting running tasks.
<li>waits for the other half of the specified timeout.
</ol>
<p>If, at any step of the process, the given executor is terminated or the calling thread is
interrupted, the method calls {@link ExecutorService#shutdownNow()}, cancelling
pending tasks and interrupting running tasks.
@param service the {@code ExecutorService} to shut down
@param timeout the maximum time to wait for the {@code ExecutorService} to terminate
@param unit the time unit of the timeout argument
@return {@code true} if the pool was terminated successfully, {@code false} if the
{@code ExecutorService} could not terminate <b>or</b> the thread running this method
is interrupted while waiting for the {@code ExecutorService} to terminate
@since 17.0 | [
"Shuts",
"down",
"the",
"given",
"executor",
"gradually",
"first",
"disabling",
"new",
"submissions",
"and",
"later",
"cancelling",
"existing",
"tasks",
"."
] | 1c48fb672c9fdfddf276970570f703fa1115f588 | https://github.com/janus-project/guava.janusproject.io/blob/1c48fb672c9fdfddf276970570f703fa1115f588/guava/src/com/google/common/util/concurrent/MoreExecutors.java#L939-L961 |
156,188 | cubedtear/aritzh | aritzh-core/src/main/java/io/github/aritzhack/aritzh/timing/Profiler.java | Profiler.startSection | public synchronized void startSection(String section) {
section = section.toLowerCase();
if (this.startTime.containsKey(section))
throw new IllegalArgumentException("Section \"" + section + "\" had already been started!");
this.startTime.put(section, System.nanoTime());
this.trace.push(section);
} | java | public synchronized void startSection(String section) {
section = section.toLowerCase();
if (this.startTime.containsKey(section))
throw new IllegalArgumentException("Section \"" + section + "\" had already been started!");
this.startTime.put(section, System.nanoTime());
this.trace.push(section);
} | [
"public",
"synchronized",
"void",
"startSection",
"(",
"String",
"section",
")",
"{",
"section",
"=",
"section",
".",
"toLowerCase",
"(",
")",
";",
"if",
"(",
"this",
".",
"startTime",
".",
"containsKey",
"(",
"section",
")",
")",
"throw",
"new",
"IllegalA... | Starts a profiling section.
@param section The name of the section | [
"Starts",
"a",
"profiling",
"section",
"."
] | bc7493447a1a6088c4a7306ca4d0f0c20278364f | https://github.com/cubedtear/aritzh/blob/bc7493447a1a6088c4a7306ca4d0f0c20278364f/aritzh-core/src/main/java/io/github/aritzhack/aritzh/timing/Profiler.java#L101-L109 |
156,189 | ginere/ginere-base | src/main/java/eu/ginere/base/util/properties/old/GlobalFileProperties.java | GlobalFileProperties.setInitFilePath | public static void setInitFilePath(String filePath) {
filePath=getPropertiesFilePath(filePath);
if (staticFileProperties == null) {
staticFileProperties=new FileProperties(filePath);
} else {
staticFileProperties.setInitFilePath(filePath);
}
} | java | public static void setInitFilePath(String filePath) {
filePath=getPropertiesFilePath(filePath);
if (staticFileProperties == null) {
staticFileProperties=new FileProperties(filePath);
} else {
staticFileProperties.setInitFilePath(filePath);
}
} | [
"public",
"static",
"void",
"setInitFilePath",
"(",
"String",
"filePath",
")",
"{",
"filePath",
"=",
"getPropertiesFilePath",
"(",
"filePath",
")",
";",
"if",
"(",
"staticFileProperties",
"==",
"null",
")",
"{",
"staticFileProperties",
"=",
"new",
"FileProperties"... | Define el fichero del cual se van a leer las propiedades.
@param filePath | [
"Define",
"el",
"fichero",
"del",
"cual",
"se",
"van",
"a",
"leer",
"las",
"propiedades",
"."
] | b1cc1c5834bd8a31df475c6f3fc0ee51273c5a24 | https://github.com/ginere/ginere-base/blob/b1cc1c5834bd8a31df475c6f3fc0ee51273c5a24/src/main/java/eu/ginere/base/util/properties/old/GlobalFileProperties.java#L61-L69 |
156,190 | dbracewell/hermes | hermes-core/src/main/java/com/davidbracewell/hermes/filter/StopWords.java | StopWords.isStopWord | public boolean isStopWord(HString text) {
if (text == null) {
return true;
} else if (text.isInstance(Types.TOKEN)) {
return isTokenStopWord(Cast.as(text));
}
return text.tokens().stream().allMatch(this::isTokenStopWord);
} | java | public boolean isStopWord(HString text) {
if (text == null) {
return true;
} else if (text.isInstance(Types.TOKEN)) {
return isTokenStopWord(Cast.as(text));
}
return text.tokens().stream().allMatch(this::isTokenStopWord);
} | [
"public",
"boolean",
"isStopWord",
"(",
"HString",
"text",
")",
"{",
"if",
"(",
"text",
"==",
"null",
")",
"{",
"return",
"true",
";",
"}",
"else",
"if",
"(",
"text",
".",
"isInstance",
"(",
"Types",
".",
"TOKEN",
")",
")",
"{",
"return",
"isTokenSto... | Is stop word.
@param text the text
@return the boolean | [
"Is",
"stop",
"word",
"."
] | 9ebefe7ad5dea1b731ae6931a30771eb75325ea3 | https://github.com/dbracewell/hermes/blob/9ebefe7ad5dea1b731ae6931a30771eb75325ea3/hermes-core/src/main/java/com/davidbracewell/hermes/filter/StopWords.java#L79-L86 |
156,191 | dbracewell/hermes | hermes-core/src/main/java/com/davidbracewell/hermes/filter/StopWords.java | StopWords.hasStopWord | public boolean hasStopWord(HString text) {
if (text == null) {
return true;
} else if (text.isInstance(Types.TOKEN)) {
return isTokenStopWord(Cast.as(text));
}
return text.tokens().stream().anyMatch(this::isTokenStopWord);
} | java | public boolean hasStopWord(HString text) {
if (text == null) {
return true;
} else if (text.isInstance(Types.TOKEN)) {
return isTokenStopWord(Cast.as(text));
}
return text.tokens().stream().anyMatch(this::isTokenStopWord);
} | [
"public",
"boolean",
"hasStopWord",
"(",
"HString",
"text",
")",
"{",
"if",
"(",
"text",
"==",
"null",
")",
"{",
"return",
"true",
";",
"}",
"else",
"if",
"(",
"text",
".",
"isInstance",
"(",
"Types",
".",
"TOKEN",
")",
")",
"{",
"return",
"isTokenSt... | Returns true if any token in the supplied text is a stop word.
@param text
@return | [
"Returns",
"true",
"if",
"any",
"token",
"in",
"the",
"supplied",
"text",
"is",
"a",
"stop",
"word",
"."
] | 9ebefe7ad5dea1b731ae6931a30771eb75325ea3 | https://github.com/dbracewell/hermes/blob/9ebefe7ad5dea1b731ae6931a30771eb75325ea3/hermes-core/src/main/java/com/davidbracewell/hermes/filter/StopWords.java#L93-L100 |
156,192 | jmeetsma/Iglu-Http | src/main/java/org/ijsberg/iglu/server/http/filter/WebAppEntryPoint.java | WebAppEntryPoint.onSessionUpdate | public void onSessionUpdate(Request currentRequest, Session session)
{
HttpServletResponse response = (HttpServletResponse)httpResponse.get();
storeSessionDataInCookie(SESSION_TOKEN_KEY, session.getToken(), response);
if(session.getUser(/*realm.getId()*/) != null)
{
storeSessionDataInCookie(USER_ID_KEY, session.getUser(/*realm.getId()*/).getId(), response);
}
else
{
storeSessionDataInCookie(USER_ID_KEY, null, response);
}
} | java | public void onSessionUpdate(Request currentRequest, Session session)
{
HttpServletResponse response = (HttpServletResponse)httpResponse.get();
storeSessionDataInCookie(SESSION_TOKEN_KEY, session.getToken(), response);
if(session.getUser(/*realm.getId()*/) != null)
{
storeSessionDataInCookie(USER_ID_KEY, session.getUser(/*realm.getId()*/).getId(), response);
}
else
{
storeSessionDataInCookie(USER_ID_KEY, null, response);
}
} | [
"public",
"void",
"onSessionUpdate",
"(",
"Request",
"currentRequest",
",",
"Session",
"session",
")",
"{",
"HttpServletResponse",
"response",
"=",
"(",
"HttpServletResponse",
")",
"httpResponse",
".",
"get",
"(",
")",
";",
"storeSessionDataInCookie",
"(",
"SESSION_... | Notification of a session registration event.
@param session | [
"Notification",
"of",
"a",
"session",
"registration",
"event",
"."
] | 5b5ed3b417285dc79b7aa013bf2340bb5ba1ffbe | https://github.com/jmeetsma/Iglu-Http/blob/5b5ed3b417285dc79b7aa013bf2340bb5ba1ffbe/src/main/java/org/ijsberg/iglu/server/http/filter/WebAppEntryPoint.java#L116-L128 |
156,193 | jmeetsma/Iglu-Http | src/main/java/org/ijsberg/iglu/server/http/filter/WebAppEntryPoint.java | WebAppEntryPoint.onSessionDestruction | public void onSessionDestruction(Request currentRequest, Session session)
{
HttpServletResponse response = (HttpServletResponse)httpResponse.get();
storeSessionDataInCookie(SESSION_TOKEN_KEY, null, response);
storeSessionDataInCookie(USER_ID_KEY, null, response);
} | java | public void onSessionDestruction(Request currentRequest, Session session)
{
HttpServletResponse response = (HttpServletResponse)httpResponse.get();
storeSessionDataInCookie(SESSION_TOKEN_KEY, null, response);
storeSessionDataInCookie(USER_ID_KEY, null, response);
} | [
"public",
"void",
"onSessionDestruction",
"(",
"Request",
"currentRequest",
",",
"Session",
"session",
")",
"{",
"HttpServletResponse",
"response",
"=",
"(",
"HttpServletResponse",
")",
"httpResponse",
".",
"get",
"(",
")",
";",
"storeSessionDataInCookie",
"(",
"SES... | Notification of a session destruction.
@param session | [
"Notification",
"of",
"a",
"session",
"destruction",
"."
] | 5b5ed3b417285dc79b7aa013bf2340bb5ba1ffbe | https://github.com/jmeetsma/Iglu-Http/blob/5b5ed3b417285dc79b7aa013bf2340bb5ba1ffbe/src/main/java/org/ijsberg/iglu/server/http/filter/WebAppEntryPoint.java#L135-L140 |
156,194 | jmeetsma/Iglu-Http | src/main/java/org/ijsberg/iglu/server/http/filter/WebAppEntryPoint.java | WebAppEntryPoint.doFilter | public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain) throws ServletException, IOException
{
servletRequest.setCharacterEncoding("UTF-8");
httpRequest.set(servletRequest);
httpResponse.set(servletResponse);
Request appRequest = null;
try
{
// String sessionToken = ServletSupport.getSessionTokenFromCookie(servletRequest);
String sessionToken = ServletSupport.getCookieValue(servletRequest, SESSION_TOKEN_KEY);
String userId = ServletSupport.getCookieValue(servletRequest, USER_ID_KEY);
if("".equals(sessionToken))
{
sessionToken = null;
}
if("".equals(userId))
{
userId = null;
}
if(accessManager != null) {
appRequest = accessManager.bindRequest(this);
// System.out.println("request bound!! " + appRequest);
Session session = appRequest.resolveSession(sessionToken, userId);
}
if (this.syncUserPrefs && appRequest.getTimesEntered() == 0)
{
//pass user preferences here
ServletSupport.importCookieValues(servletRequest, appRequest.getUserSettings());
ServletSupport.exportCookieValues(servletResponse, appRequest.getUserSettings(), "/", userPrefsMaxAge, Arrays.asList(new String[]{SESSION_TOKEN_KEY}));
}
//if a user logged in, the user id must be stored
if(userId == null)
{
User user = appRequest.getUser();
if(user != null)
{
storeSessionDataInCookie(USER_ID_KEY, user.getId(), servletResponse);
}
}
//role based access control
// checkAccess(servletRequest, appRequest);
//delegate request
chain.doFilter(servletRequest, servletResponse);
}
catch (Throwable t)//make sure user gets a controlled response
{
//is this the actual entry point or is this entry point wrapped?
if ( appRequest != null && appRequest.getTimesEntered() > 1)
{
//it's wrapped, so the exception must be thrown at the top entry point
ServletSupport.rethrow(t);
}
handleException(servletRequest, servletResponse, t);
}
finally
{
/* if(loggingEnabled)
{
application.log(new PageVisitLogEntry((HttpServletRequest) servletRequest));
}
application.releaseRequest(); */
if(accessManager != null) {
accessManager.releaseRequest();
}
}
} | java | public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain) throws ServletException, IOException
{
servletRequest.setCharacterEncoding("UTF-8");
httpRequest.set(servletRequest);
httpResponse.set(servletResponse);
Request appRequest = null;
try
{
// String sessionToken = ServletSupport.getSessionTokenFromCookie(servletRequest);
String sessionToken = ServletSupport.getCookieValue(servletRequest, SESSION_TOKEN_KEY);
String userId = ServletSupport.getCookieValue(servletRequest, USER_ID_KEY);
if("".equals(sessionToken))
{
sessionToken = null;
}
if("".equals(userId))
{
userId = null;
}
if(accessManager != null) {
appRequest = accessManager.bindRequest(this);
// System.out.println("request bound!! " + appRequest);
Session session = appRequest.resolveSession(sessionToken, userId);
}
if (this.syncUserPrefs && appRequest.getTimesEntered() == 0)
{
//pass user preferences here
ServletSupport.importCookieValues(servletRequest, appRequest.getUserSettings());
ServletSupport.exportCookieValues(servletResponse, appRequest.getUserSettings(), "/", userPrefsMaxAge, Arrays.asList(new String[]{SESSION_TOKEN_KEY}));
}
//if a user logged in, the user id must be stored
if(userId == null)
{
User user = appRequest.getUser();
if(user != null)
{
storeSessionDataInCookie(USER_ID_KEY, user.getId(), servletResponse);
}
}
//role based access control
// checkAccess(servletRequest, appRequest);
//delegate request
chain.doFilter(servletRequest, servletResponse);
}
catch (Throwable t)//make sure user gets a controlled response
{
//is this the actual entry point or is this entry point wrapped?
if ( appRequest != null && appRequest.getTimesEntered() > 1)
{
//it's wrapped, so the exception must be thrown at the top entry point
ServletSupport.rethrow(t);
}
handleException(servletRequest, servletResponse, t);
}
finally
{
/* if(loggingEnabled)
{
application.log(new PageVisitLogEntry((HttpServletRequest) servletRequest));
}
application.releaseRequest(); */
if(accessManager != null) {
accessManager.releaseRequest();
}
}
} | [
"public",
"void",
"doFilter",
"(",
"ServletRequest",
"servletRequest",
",",
"ServletResponse",
"servletResponse",
",",
"FilterChain",
"chain",
")",
"throws",
"ServletException",
",",
"IOException",
"{",
"servletRequest",
".",
"setCharacterEncoding",
"(",
"\"UTF-8\"",
")... | Must handle all incoming http requests.
Contains hooks for request and session management.
@param servletRequest
@param servletResponse
@throws ServletException
@throws IOException | [
"Must",
"handle",
"all",
"incoming",
"http",
"requests",
".",
"Contains",
"hooks",
"for",
"request",
"and",
"session",
"management",
"."
] | 5b5ed3b417285dc79b7aa013bf2340bb5ba1ffbe | https://github.com/jmeetsma/Iglu-Http/blob/5b5ed3b417285dc79b7aa013bf2340bb5ba1ffbe/src/main/java/org/ijsberg/iglu/server/http/filter/WebAppEntryPoint.java#L340-L410 |
156,195 | fedups/com.obdobion.algebrain | src/main/java/com/obdobion/algebrain/Equ.java | Equ.multiplize | protected List<EquPart> multiplize(final List<EquPart> oldTokens)
{
final EquPart[] equParts = oldTokens.toArray(new EquPart[0]);
final EquPart[] fixed = new EquPart[equParts.length * 2];
/*
* )(, operand (, operand operand, operand function, ) operand, )
* function
*/
fixed[0] = equParts[0];
EquPart m;
int left = 0;
for (int right = 1; right < equParts.length; right++)
{
if (fixed[left].multiplize(equParts[right]))
{
m = new OpMultiply(fixed[left]);
left++;
fixed[left] = m;
}
left++;
fixed[left] = equParts[right];
}
final List<EquPart> tokens = new ArrayList<>();
for (int i = 0; i < fixed.length; i++)
if (fixed[i] != null)
tokens.add(fixed[i]);
return tokens;
} | java | protected List<EquPart> multiplize(final List<EquPart> oldTokens)
{
final EquPart[] equParts = oldTokens.toArray(new EquPart[0]);
final EquPart[] fixed = new EquPart[equParts.length * 2];
/*
* )(, operand (, operand operand, operand function, ) operand, )
* function
*/
fixed[0] = equParts[0];
EquPart m;
int left = 0;
for (int right = 1; right < equParts.length; right++)
{
if (fixed[left].multiplize(equParts[right]))
{
m = new OpMultiply(fixed[left]);
left++;
fixed[left] = m;
}
left++;
fixed[left] = equParts[right];
}
final List<EquPart> tokens = new ArrayList<>();
for (int i = 0; i < fixed.length; i++)
if (fixed[i] != null)
tokens.add(fixed[i]);
return tokens;
} | [
"protected",
"List",
"<",
"EquPart",
">",
"multiplize",
"(",
"final",
"List",
"<",
"EquPart",
">",
"oldTokens",
")",
"{",
"final",
"EquPart",
"[",
"]",
"equParts",
"=",
"oldTokens",
".",
"toArray",
"(",
"new",
"EquPart",
"[",
"0",
"]",
")",
";",
"final... | put implied multipliers into the equation
@param oldTokens a {@link java.util.Collection} object.
@return a {@link java.util.Collection} object. | [
"put",
"implied",
"multipliers",
"into",
"the",
"equation"
] | d0adaa9fbbba907bdcf820961e9058b0d2b15a8a | https://github.com/fedups/com.obdobion.algebrain/blob/d0adaa9fbbba907bdcf820961e9058b0d2b15a8a/src/main/java/com/obdobion/algebrain/Equ.java#L469-L502 |
156,196 | fedups/com.obdobion.algebrain | src/main/java/com/obdobion/algebrain/Equ.java | Equ.negatize | protected List<EquPart> negatize(final List<EquPart> equParts)
{
int left = 0;
for (int right = 1; right < equParts.size(); right++)
{
left = right - 1;
if (equParts.get(left) instanceof OpSubtract)
if (left == 0)
equParts.set(left, new OpNegate(equParts.get(left)));
else
{
if (equParts.get(left - 1).negatize(equParts.get(right)))
equParts.set(left, new OpNegate(equParts.get(left)));
}
}
return equParts;
} | java | protected List<EquPart> negatize(final List<EquPart> equParts)
{
int left = 0;
for (int right = 1; right < equParts.size(); right++)
{
left = right - 1;
if (equParts.get(left) instanceof OpSubtract)
if (left == 0)
equParts.set(left, new OpNegate(equParts.get(left)));
else
{
if (equParts.get(left - 1).negatize(equParts.get(right)))
equParts.set(left, new OpNegate(equParts.get(left)));
}
}
return equParts;
} | [
"protected",
"List",
"<",
"EquPart",
">",
"negatize",
"(",
"final",
"List",
"<",
"EquPart",
">",
"equParts",
")",
"{",
"int",
"left",
"=",
"0",
";",
"for",
"(",
"int",
"right",
"=",
"1",
";",
"right",
"<",
"equParts",
".",
"size",
"(",
")",
";",
... | change subtractions to negations if necessary
@param equParts a {@link java.util.List} object.
@return a {@link java.util.Collection} object. | [
"change",
"subtractions",
"to",
"negations",
"if",
"necessary"
] | d0adaa9fbbba907bdcf820961e9058b0d2b15a8a | https://github.com/fedups/com.obdobion.algebrain/blob/d0adaa9fbbba907bdcf820961e9058b0d2b15a8a/src/main/java/com/obdobion/algebrain/Equ.java#L510-L527 |
156,197 | fedups/com.obdobion.algebrain | src/main/java/com/obdobion/algebrain/Equ.java | Equ.rpnize | protected List<EquPart> rpnize(final List<EquPart> oldTokens)
{
final List<EquPart> _rpn = new Stack<>();
final Stack<EquPart> ops = new Stack<>();
Operation leftOp;
Operation rightOp;
for (final EquPart token : oldTokens)
if (token instanceof Token)
_rpn.add(token);
else
{
rightOp = (Operation) token;
if (ops.empty())
{
if (rightOp.includeInRpn())
ops.push(rightOp);
} else
{
leftOp = (Operation) ops.peek();
if (leftOp.preceeds(rightOp))
{
_rpn.add(ops.pop());
/*
* while knocking one off scan back as long as the level
* doesn't change. A left paren causes the level to
* increase and the left paren has that new level. A
* right paren causes the level to decrease and has this
* new lesser level. So the right paren is one level
* less than the operators within the parens. Since we
* want to only scan those operators we have to adjust
* for the level that they are.
*/
int level = rightOp.getLevel();
if (rightOp instanceof OpRightParen)
level = level + 1;
Operation compareOp = rightOp;
while (!ops.empty())
{
leftOp = (Operation) ops.peek();
if (leftOp.getLevel() < level)
break;
if (leftOp.preceeds(compareOp))
{
_rpn.add(ops.pop());
compareOp = leftOp;
} else
break;
break;
}
}
if (rightOp.includeInRpn())
ops.push(rightOp);
}
}
while (!ops.empty())
_rpn.add(ops.pop());
return _rpn;
} | java | protected List<EquPart> rpnize(final List<EquPart> oldTokens)
{
final List<EquPart> _rpn = new Stack<>();
final Stack<EquPart> ops = new Stack<>();
Operation leftOp;
Operation rightOp;
for (final EquPart token : oldTokens)
if (token instanceof Token)
_rpn.add(token);
else
{
rightOp = (Operation) token;
if (ops.empty())
{
if (rightOp.includeInRpn())
ops.push(rightOp);
} else
{
leftOp = (Operation) ops.peek();
if (leftOp.preceeds(rightOp))
{
_rpn.add(ops.pop());
/*
* while knocking one off scan back as long as the level
* doesn't change. A left paren causes the level to
* increase and the left paren has that new level. A
* right paren causes the level to decrease and has this
* new lesser level. So the right paren is one level
* less than the operators within the parens. Since we
* want to only scan those operators we have to adjust
* for the level that they are.
*/
int level = rightOp.getLevel();
if (rightOp instanceof OpRightParen)
level = level + 1;
Operation compareOp = rightOp;
while (!ops.empty())
{
leftOp = (Operation) ops.peek();
if (leftOp.getLevel() < level)
break;
if (leftOp.preceeds(compareOp))
{
_rpn.add(ops.pop());
compareOp = leftOp;
} else
break;
break;
}
}
if (rightOp.includeInRpn())
ops.push(rightOp);
}
}
while (!ops.empty())
_rpn.add(ops.pop());
return _rpn;
} | [
"protected",
"List",
"<",
"EquPart",
">",
"rpnize",
"(",
"final",
"List",
"<",
"EquPart",
">",
"oldTokens",
")",
"{",
"final",
"List",
"<",
"EquPart",
">",
"_rpn",
"=",
"new",
"Stack",
"<>",
"(",
")",
";",
"final",
"Stack",
"<",
"EquPart",
">",
"ops"... | Create a reverse Polish notation form of the equation
@param oldTokens a {@link java.util.Collection} object.
@return a {@link java.util.Collection} object. | [
"Create",
"a",
"reverse",
"Polish",
"notation",
"form",
"of",
"the",
"equation"
] | d0adaa9fbbba907bdcf820961e9058b0d2b15a8a | https://github.com/fedups/com.obdobion.algebrain/blob/d0adaa9fbbba907bdcf820961e9058b0d2b15a8a/src/main/java/com/obdobion/algebrain/Equ.java#L611-L677 |
156,198 | tempodb/tempodb-java | src/main/java/com/tempodb/Client.java | Client.deleteDataPoints | public Result<Void> deleteDataPoints(Series series, Interval interval) {
checkNotNull(series);
checkNotNull(interval);
URI uri = null;
try {
URIBuilder builder = new URIBuilder(String.format("/%s/series/key/%s/data/", API_VERSION, urlencode(series.getKey())));
addIntervalToURI(builder, interval);
uri = builder.build();
} catch (URISyntaxException e) {
String message = String.format("Could not build URI with inputs: key: %s, interval: %s", series.getKey(), interval);
throw new IllegalArgumentException(message, e);
}
HttpRequest request = buildRequest(uri.toString(), HttpMethod.DELETE);
Result<Void> result = execute(request, Void.class);
return result;
} | java | public Result<Void> deleteDataPoints(Series series, Interval interval) {
checkNotNull(series);
checkNotNull(interval);
URI uri = null;
try {
URIBuilder builder = new URIBuilder(String.format("/%s/series/key/%s/data/", API_VERSION, urlencode(series.getKey())));
addIntervalToURI(builder, interval);
uri = builder.build();
} catch (URISyntaxException e) {
String message = String.format("Could not build URI with inputs: key: %s, interval: %s", series.getKey(), interval);
throw new IllegalArgumentException(message, e);
}
HttpRequest request = buildRequest(uri.toString(), HttpMethod.DELETE);
Result<Void> result = execute(request, Void.class);
return result;
} | [
"public",
"Result",
"<",
"Void",
">",
"deleteDataPoints",
"(",
"Series",
"series",
",",
"Interval",
"interval",
")",
"{",
"checkNotNull",
"(",
"series",
")",
";",
"checkNotNull",
"(",
"interval",
")",
";",
"URI",
"uri",
"=",
"null",
";",
"try",
"{",
"URI... | Deletes a range of datapoints for a Series specified by key.
@param series The series
@param interval The start/end datetime interval to delete.
@return Void
@since 1.0.0 | [
"Deletes",
"a",
"range",
"of",
"datapoints",
"for",
"a",
"Series",
"specified",
"by",
"key",
"."
] | 5733f204fe4c8dda48916ba1f67cf44f5a3f9c69 | https://github.com/tempodb/tempodb-java/blob/5733f204fe4c8dda48916ba1f67cf44f5a3f9c69/src/main/java/com/tempodb/Client.java#L195-L212 |
156,199 | tempodb/tempodb-java | src/main/java/com/tempodb/Client.java | Client.deleteSeries | public Result<DeleteSummary> deleteSeries(Filter filter) {
URI uri = null;
try {
URIBuilder builder = new URIBuilder(String.format("/%s/series/", API_VERSION));
addFilterToURI(builder, filter);
uri = builder.build();
} catch (URISyntaxException e) {
String message = String.format("Could not build URI with input - filter: %s", filter);
throw new IllegalArgumentException(message, e);
}
HttpRequest request = buildRequest(uri.toString(), HttpMethod.DELETE);
Result<DeleteSummary> result = execute(request, DeleteSummary.class);
return result;
} | java | public Result<DeleteSummary> deleteSeries(Filter filter) {
URI uri = null;
try {
URIBuilder builder = new URIBuilder(String.format("/%s/series/", API_VERSION));
addFilterToURI(builder, filter);
uri = builder.build();
} catch (URISyntaxException e) {
String message = String.format("Could not build URI with input - filter: %s", filter);
throw new IllegalArgumentException(message, e);
}
HttpRequest request = buildRequest(uri.toString(), HttpMethod.DELETE);
Result<DeleteSummary> result = execute(request, DeleteSummary.class);
return result;
} | [
"public",
"Result",
"<",
"DeleteSummary",
">",
"deleteSeries",
"(",
"Filter",
"filter",
")",
"{",
"URI",
"uri",
"=",
"null",
";",
"try",
"{",
"URIBuilder",
"builder",
"=",
"new",
"URIBuilder",
"(",
"String",
".",
"format",
"(",
"\"/%s/series/\"",
",",
"API... | Deletes set of series by a filter.
@param filter The series filter @see Filter
@return A DeleteSummary providing information about the series deleted.
@see DeleteSummary
@see Filter
@since 1.0.0 | [
"Deletes",
"set",
"of",
"series",
"by",
"a",
"filter",
"."
] | 5733f204fe4c8dda48916ba1f67cf44f5a3f9c69 | https://github.com/tempodb/tempodb-java/blob/5733f204fe4c8dda48916ba1f67cf44f5a3f9c69/src/main/java/com/tempodb/Client.java#L248-L262 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.