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
155,500
RogerParkinson/madura-objects-parent
madura-rules/src/main/java/nz/co/senanque/rules/RulesPlugin.java
RulesPlugin.getEmptyField
public FieldMetadata getEmptyField(FieldMetadata fieldMetadata) { ValidationSession session = fieldMetadata.getValidationSession(); RuleSessionImpl ruleSession = getRuleSession(session); ProxyField proxyField = session.getProxyField(fieldMetadata); RuleProxyField ruleProxyField = ruleSession.getRuleProxyField(proxyField); while (true) { RuleProxyField rpf = ruleProxyField.backChain(); if (rpf == null) { // there are no unfilled fields return null; } else { // We got an unfilled field return it return rpf.getProxyField().getFieldMetadata(); } } }
java
public FieldMetadata getEmptyField(FieldMetadata fieldMetadata) { ValidationSession session = fieldMetadata.getValidationSession(); RuleSessionImpl ruleSession = getRuleSession(session); ProxyField proxyField = session.getProxyField(fieldMetadata); RuleProxyField ruleProxyField = ruleSession.getRuleProxyField(proxyField); while (true) { RuleProxyField rpf = ruleProxyField.backChain(); if (rpf == null) { // there are no unfilled fields return null; } else { // We got an unfilled field return it return rpf.getProxyField().getFieldMetadata(); } } }
[ "public", "FieldMetadata", "getEmptyField", "(", "FieldMetadata", "fieldMetadata", ")", "{", "ValidationSession", "session", "=", "fieldMetadata", ".", "getValidationSession", "(", ")", ";", "RuleSessionImpl", "ruleSession", "=", "getRuleSession", "(", "session", ")", ";", "ProxyField", "proxyField", "=", "session", ".", "getProxyField", "(", "fieldMetadata", ")", ";", "RuleProxyField", "ruleProxyField", "=", "ruleSession", ".", "getRuleProxyField", "(", "proxyField", ")", ";", "while", "(", "true", ")", "{", "RuleProxyField", "rpf", "=", "ruleProxyField", ".", "backChain", "(", ")", ";", "if", "(", "rpf", "==", "null", ")", "{", "// there are no unfilled fields", "return", "null", ";", "}", "else", "{", "// We got an unfilled field return it", "return", "rpf", ".", "getProxyField", "(", ")", ".", "getFieldMetadata", "(", ")", ";", "}", "}", "}" ]
Find an empty field, ie one that is unknown and not 'not known' If we don't find one then return null. @param fieldMetadata @return qualifying field
[ "Find", "an", "empty", "field", "ie", "one", "that", "is", "unknown", "and", "not", "not", "known", "If", "we", "don", "t", "find", "one", "then", "return", "null", "." ]
9b5385dd0437611f0ce8506f63646e018d06fb8e
https://github.com/RogerParkinson/madura-objects-parent/blob/9b5385dd0437611f0ce8506f63646e018d06fb8e/madura-rules/src/main/java/nz/co/senanque/rules/RulesPlugin.java#L434-L453
155,501
RogerParkinson/madura-objects-parent
madura-rules/src/main/java/nz/co/senanque/rules/RulesPlugin.java
RulesPlugin.clearUnknowns
public void clearUnknowns(ValidationObject object) { ObjectMetadata objectMetadata = object.getMetadata(); ValidationSession session = object.getMetadata().getProxyObject().getSession(); session.setEnabled(false); Map<String,ProxyField> fieldMap = objectMetadata.getProxyObject().getFieldMap(); for (Map.Entry<String,ProxyField> entry: fieldMap.entrySet()) { FieldMetadata fieldMetadata = entry.getValue().getFieldMetadata(); ProxyFieldImpl proxyField = (ProxyFieldImpl)session.getProxyField(fieldMetadata); if (proxyField.getPropertyMetadata().isUnknown()) // this tests the static unknown flag { // force the value to null and then set the dynamic unknown flag proxyField.reset(); proxyField.setValue(null); proxyField.updateValue(); proxyField.setUnknown(true); logger.debug("Cleared {}",proxyField.toString()); } } session.setEnabled(true); }
java
public void clearUnknowns(ValidationObject object) { ObjectMetadata objectMetadata = object.getMetadata(); ValidationSession session = object.getMetadata().getProxyObject().getSession(); session.setEnabled(false); Map<String,ProxyField> fieldMap = objectMetadata.getProxyObject().getFieldMap(); for (Map.Entry<String,ProxyField> entry: fieldMap.entrySet()) { FieldMetadata fieldMetadata = entry.getValue().getFieldMetadata(); ProxyFieldImpl proxyField = (ProxyFieldImpl)session.getProxyField(fieldMetadata); if (proxyField.getPropertyMetadata().isUnknown()) // this tests the static unknown flag { // force the value to null and then set the dynamic unknown flag proxyField.reset(); proxyField.setValue(null); proxyField.updateValue(); proxyField.setUnknown(true); logger.debug("Cleared {}",proxyField.toString()); } } session.setEnabled(true); }
[ "public", "void", "clearUnknowns", "(", "ValidationObject", "object", ")", "{", "ObjectMetadata", "objectMetadata", "=", "object", ".", "getMetadata", "(", ")", ";", "ValidationSession", "session", "=", "object", ".", "getMetadata", "(", ")", ".", "getProxyObject", "(", ")", ".", "getSession", "(", ")", ";", "session", ".", "setEnabled", "(", "false", ")", ";", "Map", "<", "String", ",", "ProxyField", ">", "fieldMap", "=", "objectMetadata", ".", "getProxyObject", "(", ")", ".", "getFieldMap", "(", ")", ";", "for", "(", "Map", ".", "Entry", "<", "String", ",", "ProxyField", ">", "entry", ":", "fieldMap", ".", "entrySet", "(", ")", ")", "{", "FieldMetadata", "fieldMetadata", "=", "entry", ".", "getValue", "(", ")", ".", "getFieldMetadata", "(", ")", ";", "ProxyFieldImpl", "proxyField", "=", "(", "ProxyFieldImpl", ")", "session", ".", "getProxyField", "(", "fieldMetadata", ")", ";", "if", "(", "proxyField", ".", "getPropertyMetadata", "(", ")", ".", "isUnknown", "(", ")", ")", "// this tests the static unknown flag", "{", "// force the value to null and then set the dynamic unknown flag", "proxyField", ".", "reset", "(", ")", ";", "proxyField", ".", "setValue", "(", "null", ")", ";", "proxyField", ".", "updateValue", "(", ")", ";", "proxyField", ".", "setUnknown", "(", "true", ")", ";", "logger", ".", "debug", "(", "\"Cleared {}\"", ",", "proxyField", ".", "toString", "(", ")", ")", ";", "}", "}", "session", ".", "setEnabled", "(", "true", ")", ";", "}" ]
Clear all the fields that were originally flagged as unknown on this object we should assume the dynamic flag has been removed and we need to reset it. Also set the current value of each to null, ie we lose any data from the unknown fields for this object. Because you only do this one object at a time there may be problems if the unknowns use rules that cross multiple objects. @param object
[ "Clear", "all", "the", "fields", "that", "were", "originally", "flagged", "as", "unknown", "on", "this", "object", "we", "should", "assume", "the", "dynamic", "flag", "has", "been", "removed", "and", "we", "need", "to", "reset", "it", ".", "Also", "set", "the", "current", "value", "of", "each", "to", "null", "ie", "we", "lose", "any", "data", "from", "the", "unknown", "fields", "for", "this", "object", ".", "Because", "you", "only", "do", "this", "one", "object", "at", "a", "time", "there", "may", "be", "problems", "if", "the", "unknowns", "use", "rules", "that", "cross", "multiple", "objects", "." ]
9b5385dd0437611f0ce8506f63646e018d06fb8e
https://github.com/RogerParkinson/madura-objects-parent/blob/9b5385dd0437611f0ce8506f63646e018d06fb8e/madura-rules/src/main/java/nz/co/senanque/rules/RulesPlugin.java#L462-L483
155,502
hudson3-plugins/warnings-plugin
src/main/java/hudson/plugins/warnings/WarningsPublisher.java
WarningsPublisher.readResolve
@Override protected Object readResolve() { super.readResolve(); if (consoleParsers == null) { consoleParsers = Lists.newArrayList(); if (isOlderThanRelease318()) { upgradeFrom318(); } for (String parser : consoleLogParsers) { consoleParsers.add(new ConsoleParser(parser)); } } return this; }
java
@Override protected Object readResolve() { super.readResolve(); if (consoleParsers == null) { consoleParsers = Lists.newArrayList(); if (isOlderThanRelease318()) { upgradeFrom318(); } for (String parser : consoleLogParsers) { consoleParsers.add(new ConsoleParser(parser)); } } return this; }
[ "@", "Override", "protected", "Object", "readResolve", "(", ")", "{", "super", ".", "readResolve", "(", ")", ";", "if", "(", "consoleParsers", "==", "null", ")", "{", "consoleParsers", "=", "Lists", ".", "newArrayList", "(", ")", ";", "if", "(", "isOlderThanRelease318", "(", ")", ")", "{", "upgradeFrom318", "(", ")", ";", "}", "for", "(", "String", "parser", ":", "consoleLogParsers", ")", "{", "consoleParsers", ".", "add", "(", "new", "ConsoleParser", "(", "parser", ")", ")", ";", "}", "}", "return", "this", ";", "}" ]
Upgrade for release 4.5 or older. @return this
[ "Upgrade", "for", "release", "4", ".", "5", "or", "older", "." ]
462c9f3dffede9120173935567392b22520b0966
https://github.com/hudson3-plugins/warnings-plugin/blob/462c9f3dffede9120173935567392b22520b0966/src/main/java/hudson/plugins/warnings/WarningsPublisher.java#L182-L199
155,503
pip-services3-java/pip-services3-commons-java
src/org/pipservices3/commons/validate/Schema.java
Schema.withRule
public Schema withRule(IValidationRule rule) { _rules = _rules != null ? _rules : new ArrayList<IValidationRule>(); _rules.add(rule); return this; }
java
public Schema withRule(IValidationRule rule) { _rules = _rules != null ? _rules : new ArrayList<IValidationRule>(); _rules.add(rule); return this; }
[ "public", "Schema", "withRule", "(", "IValidationRule", "rule", ")", "{", "_rules", "=", "_rules", "!=", "null", "?", "_rules", ":", "new", "ArrayList", "<", "IValidationRule", ">", "(", ")", ";", "_rules", ".", "add", "(", "rule", ")", ";", "return", "this", ";", "}" ]
Adds validation rule to this schema. This method returns reference to this exception to implement Builder pattern to chain additional calls. @param rule a validation rule to be added. @return this validation schema.
[ "Adds", "validation", "rule", "to", "this", "schema", "." ]
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/validate/Schema.java#L118-L122
155,504
pip-services3-java/pip-services3-commons-java
src/org/pipservices3/commons/validate/Schema.java
Schema.performTypeValidation
protected void performTypeValidation(String path, Object type, Object value, List<ValidationResult> results) { // If type it not defined then skip if (type == null) return; // Perform validation against schema if (type instanceof Schema) { Schema schema = (Schema) type; schema.performValidation(path, value, results); return; } // If value is null then skip value = ObjectReader.getValue(value); if (value == null) return; String name = path != null ? path : "value"; Class<?> valueType = value.getClass(); // Match types if (TypeMatcher.matchType(type, valueType)) return; // Generate type mismatch error results.add(new ValidationResult(path, ValidationResultType.Error, "TYPE_MISMATCH", name + " type must be " + type + " but found " + valueType, type, valueType)); }
java
protected void performTypeValidation(String path, Object type, Object value, List<ValidationResult> results) { // If type it not defined then skip if (type == null) return; // Perform validation against schema if (type instanceof Schema) { Schema schema = (Schema) type; schema.performValidation(path, value, results); return; } // If value is null then skip value = ObjectReader.getValue(value); if (value == null) return; String name = path != null ? path : "value"; Class<?> valueType = value.getClass(); // Match types if (TypeMatcher.matchType(type, valueType)) return; // Generate type mismatch error results.add(new ValidationResult(path, ValidationResultType.Error, "TYPE_MISMATCH", name + " type must be " + type + " but found " + valueType, type, valueType)); }
[ "protected", "void", "performTypeValidation", "(", "String", "path", ",", "Object", "type", ",", "Object", "value", ",", "List", "<", "ValidationResult", ">", "results", ")", "{", "// If type it not defined then skip", "if", "(", "type", "==", "null", ")", "return", ";", "// Perform validation against schema", "if", "(", "type", "instanceof", "Schema", ")", "{", "Schema", "schema", "=", "(", "Schema", ")", "type", ";", "schema", ".", "performValidation", "(", "path", ",", "value", ",", "results", ")", ";", "return", ";", "}", "// If value is null then skip", "value", "=", "ObjectReader", ".", "getValue", "(", "value", ")", ";", "if", "(", "value", "==", "null", ")", "return", ";", "String", "name", "=", "path", "!=", "null", "?", "path", ":", "\"value\"", ";", "Class", "<", "?", ">", "valueType", "=", "value", ".", "getClass", "(", ")", ";", "// Match types", "if", "(", "TypeMatcher", ".", "matchType", "(", "type", ",", "valueType", ")", ")", "return", ";", "// Generate type mismatch error", "results", ".", "add", "(", "new", "ValidationResult", "(", "path", ",", "ValidationResultType", ".", "Error", ",", "\"TYPE_MISMATCH\"", ",", "name", "+", "\" type must be \"", "+", "type", "+", "\" but found \"", "+", "valueType", ",", "type", ",", "valueType", ")", ")", ";", "}" ]
Validates a given value to match specified type. The type can be defined as a Schema, type, a type name or TypeCode When type is a Schema, it executes validation recursively against that Schema. @param path a dot notation path to the value. @param type a type to match the value type @param value a value to be validated. @param results a list with validation results to add new results. @see #performValidation(String, Object, List)
[ "Validates", "a", "given", "value", "to", "match", "specified", "type", ".", "The", "type", "can", "be", "defined", "as", "a", "Schema", "type", "a", "type", "name", "or", "TypeCode", "When", "type", "is", "a", "Schema", "it", "executes", "validation", "recursively", "against", "that", "Schema", "." ]
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/validate/Schema.java#L162-L189
155,505
pip-services3-java/pip-services3-commons-java
src/org/pipservices3/commons/validate/Schema.java
Schema.validate
public List<ValidationResult> validate(Object value) { List<ValidationResult> results = new ArrayList<ValidationResult>(); performValidation("", value, results); return results; }
java
public List<ValidationResult> validate(Object value) { List<ValidationResult> results = new ArrayList<ValidationResult>(); performValidation("", value, results); return results; }
[ "public", "List", "<", "ValidationResult", ">", "validate", "(", "Object", "value", ")", "{", "List", "<", "ValidationResult", ">", "results", "=", "new", "ArrayList", "<", "ValidationResult", ">", "(", ")", ";", "performValidation", "(", "\"\"", ",", "value", ",", "results", ")", ";", "return", "results", ";", "}" ]
Validates the given value and results validation results. @param value a value to be validated. @return a list with validation results. @see ValidationResult
[ "Validates", "the", "given", "value", "and", "results", "validation", "results", "." ]
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/validate/Schema.java#L199-L203
155,506
pip-services3-java/pip-services3-commons-java
src/org/pipservices3/commons/validate/Schema.java
Schema.validateAndThrowException
public void validateAndThrowException(String correlationId, Object value, boolean strict) throws ValidationException { List<ValidationResult> results = validate(value); ValidationException.throwExceptionIfNeeded(correlationId, results, strict); }
java
public void validateAndThrowException(String correlationId, Object value, boolean strict) throws ValidationException { List<ValidationResult> results = validate(value); ValidationException.throwExceptionIfNeeded(correlationId, results, strict); }
[ "public", "void", "validateAndThrowException", "(", "String", "correlationId", ",", "Object", "value", ",", "boolean", "strict", ")", "throws", "ValidationException", "{", "List", "<", "ValidationResult", ">", "results", "=", "validate", "(", "value", ")", ";", "ValidationException", ".", "throwExceptionIfNeeded", "(", "correlationId", ",", "results", ",", "strict", ")", ";", "}" ]
Validates the given value and returns a ValidationException if errors were found. @param correlationId (optional) transaction id to trace execution through call chain. @param value a value to be validated. @param strict true to treat warnings as errors. @throws ValidationException when errors occured in validation
[ "Validates", "the", "given", "value", "and", "returns", "a", "ValidationException", "if", "errors", "were", "found", "." ]
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/validate/Schema.java#L215-L219
155,507
pip-services3-java/pip-services3-commons-java
src/org/pipservices3/commons/validate/Schema.java
Schema.validateAndThrowException
public void validateAndThrowException(String correlationId, Object value) throws ValidationException { validateAndThrowException(correlationId, value, false); }
java
public void validateAndThrowException(String correlationId, Object value) throws ValidationException { validateAndThrowException(correlationId, value, false); }
[ "public", "void", "validateAndThrowException", "(", "String", "correlationId", ",", "Object", "value", ")", "throws", "ValidationException", "{", "validateAndThrowException", "(", "correlationId", ",", "value", ",", "false", ")", ";", "}" ]
Validates the given value and throws a ValidationException if errors were found. @param correlationId (optional) transaction id to trace execution through call chain. @param value a value to be validated. @throws ValidationException when errors occured in validation @see ValidationException#throwExceptionIfNeeded(String, List, boolean)
[ "Validates", "the", "given", "value", "and", "throws", "a", "ValidationException", "if", "errors", "were", "found", "." ]
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/validate/Schema.java#L232-L234
155,508
pip-services3-java/pip-services3-commons-java
src/org/pipservices3/commons/errors/ErrorDescriptionFactory.java
ErrorDescriptionFactory.create
public static ErrorDescription create(ApplicationException ex) { ErrorDescription description = new ErrorDescription(); description.setCategory(ex.getCategory()); description.setStatus(ex.getStatus()); description.setCode(ex.getCode()); description.setMessage(ex.getMessage()); description.setDetails(ex.getDetails()); description.setCorrelationId(ex.getCorrelationId()); description.setCause(ex.getCauseString()); description.setStackTrace(ex.getStackTraceString()); return description; }
java
public static ErrorDescription create(ApplicationException ex) { ErrorDescription description = new ErrorDescription(); description.setCategory(ex.getCategory()); description.setStatus(ex.getStatus()); description.setCode(ex.getCode()); description.setMessage(ex.getMessage()); description.setDetails(ex.getDetails()); description.setCorrelationId(ex.getCorrelationId()); description.setCause(ex.getCauseString()); description.setStackTrace(ex.getStackTraceString()); return description; }
[ "public", "static", "ErrorDescription", "create", "(", "ApplicationException", "ex", ")", "{", "ErrorDescription", "description", "=", "new", "ErrorDescription", "(", ")", ";", "description", ".", "setCategory", "(", "ex", ".", "getCategory", "(", ")", ")", ";", "description", ".", "setStatus", "(", "ex", ".", "getStatus", "(", ")", ")", ";", "description", ".", "setCode", "(", "ex", ".", "getCode", "(", ")", ")", ";", "description", ".", "setMessage", "(", "ex", ".", "getMessage", "(", ")", ")", ";", "description", ".", "setDetails", "(", "ex", ".", "getDetails", "(", ")", ")", ";", "description", ".", "setCorrelationId", "(", "ex", ".", "getCorrelationId", "(", ")", ")", ";", "description", ".", "setCause", "(", "ex", ".", "getCauseString", "(", ")", ")", ";", "description", ".", "setStackTrace", "(", "ex", ".", "getStackTraceString", "(", ")", ")", ";", "return", "description", ";", "}" ]
Creates a serializable ErrorDescription from error object. @param ex an error object @return a serializeable ErrorDescription object that describes the error.
[ "Creates", "a", "serializable", "ErrorDescription", "from", "error", "object", "." ]
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/errors/ErrorDescriptionFactory.java#L22-L33
155,509
pip-services3-java/pip-services3-commons-java
src/org/pipservices3/commons/errors/ErrorDescriptionFactory.java
ErrorDescriptionFactory.create
public static ErrorDescription create(Throwable ex, String correlationId) { ErrorDescription description = new ErrorDescription(); description.setType(ex.getClass().getCanonicalName()); description.setCategory(ErrorCategory.Unknown); description.setStatus(500); description.setCode("Unknown"); description.setMessage(ex.getMessage()); Throwable t = ex.getCause(); description.setCause(t != null ? t.toString() : null); StackTraceElement[] ste = ex.getStackTrace(); StringBuilder builder = new StringBuilder(); if (ste != null) { for (int i = 0; i < ste.length; i++) { if (builder.length() > 0) builder.append(" "); builder.append(ste[i].toString()); } } description.setStackTrace(builder.toString()); description.setCorrelationId(correlationId); return description; }
java
public static ErrorDescription create(Throwable ex, String correlationId) { ErrorDescription description = new ErrorDescription(); description.setType(ex.getClass().getCanonicalName()); description.setCategory(ErrorCategory.Unknown); description.setStatus(500); description.setCode("Unknown"); description.setMessage(ex.getMessage()); Throwable t = ex.getCause(); description.setCause(t != null ? t.toString() : null); StackTraceElement[] ste = ex.getStackTrace(); StringBuilder builder = new StringBuilder(); if (ste != null) { for (int i = 0; i < ste.length; i++) { if (builder.length() > 0) builder.append(" "); builder.append(ste[i].toString()); } } description.setStackTrace(builder.toString()); description.setCorrelationId(correlationId); return description; }
[ "public", "static", "ErrorDescription", "create", "(", "Throwable", "ex", ",", "String", "correlationId", ")", "{", "ErrorDescription", "description", "=", "new", "ErrorDescription", "(", ")", ";", "description", ".", "setType", "(", "ex", ".", "getClass", "(", ")", ".", "getCanonicalName", "(", ")", ")", ";", "description", ".", "setCategory", "(", "ErrorCategory", ".", "Unknown", ")", ";", "description", ".", "setStatus", "(", "500", ")", ";", "description", ".", "setCode", "(", "\"Unknown\"", ")", ";", "description", ".", "setMessage", "(", "ex", ".", "getMessage", "(", ")", ")", ";", "Throwable", "t", "=", "ex", ".", "getCause", "(", ")", ";", "description", ".", "setCause", "(", "t", "!=", "null", "?", "t", ".", "toString", "(", ")", ":", "null", ")", ";", "StackTraceElement", "[", "]", "ste", "=", "ex", ".", "getStackTrace", "(", ")", ";", "StringBuilder", "builder", "=", "new", "StringBuilder", "(", ")", ";", "if", "(", "ste", "!=", "null", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "ste", ".", "length", ";", "i", "++", ")", "{", "if", "(", "builder", ".", "length", "(", ")", ">", "0", ")", "builder", ".", "append", "(", "\" \"", ")", ";", "builder", ".", "append", "(", "ste", "[", "i", "]", ".", "toString", "(", ")", ")", ";", "}", "}", "description", ".", "setStackTrace", "(", "builder", ".", "toString", "(", ")", ")", ";", "description", ".", "setCorrelationId", "(", "correlationId", ")", ";", "return", "description", ";", "}" ]
Creates a serializable ErrorDescription from throwable object with unknown error category. @param ex an error object @param correlationId (optional) a unique transaction id to trace execution through call chain. @return a serializeable ErrorDescription object that describes the error.
[ "Creates", "a", "serializable", "ErrorDescription", "from", "throwable", "object", "with", "unknown", "error", "category", "." ]
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/errors/ErrorDescriptionFactory.java#L42-L66
155,510
app55/app55-java
src/support/java/com/googlecode/openbeans/XMLDecoder.java
XMLDecoder.close
public void close() { if (inputStream == null) { return; } try { inputStream.close(); } catch (Exception e) { listener.exceptionThrown(e); } }
java
public void close() { if (inputStream == null) { return; } try { inputStream.close(); } catch (Exception e) { listener.exceptionThrown(e); } }
[ "public", "void", "close", "(", ")", "{", "if", "(", "inputStream", "==", "null", ")", "{", "return", ";", "}", "try", "{", "inputStream", ".", "close", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "listener", ".", "exceptionThrown", "(", "e", ")", ";", "}", "}" ]
Close the input stream of xml data.
[ "Close", "the", "input", "stream", "of", "xml", "data", "." ]
73e51d0f3141a859dfbd37ca9becef98477e553e
https://github.com/app55/app55-java/blob/73e51d0f3141a859dfbd37ca9becef98477e553e/src/support/java/com/googlecode/openbeans/XMLDecoder.java#L738-L752
155,511
app55/app55-java
src/support/java/com/googlecode/openbeans/XMLDecoder.java
XMLDecoder.readObject
@SuppressWarnings("nls") public Object readObject() { if (inputStream == null) { return null; } if (saxHandler == null) { saxHandler = new SAXHandler(); try { SAXParserFactory.newInstance().newSAXParser().parse(inputStream, saxHandler); } catch (Exception e) { this.listener.exceptionThrown(e); } } if (readObjIndex >= readObjs.size()) { throw new ArrayIndexOutOfBoundsException(Messages.getString("beans.70")); } Elem elem = readObjs.get(readObjIndex); if (!elem.isClosed) { // bad element, error occurred while parsing throw new ArrayIndexOutOfBoundsException(Messages.getString("beans.70")); } readObjIndex++; return elem.result; }
java
@SuppressWarnings("nls") public Object readObject() { if (inputStream == null) { return null; } if (saxHandler == null) { saxHandler = new SAXHandler(); try { SAXParserFactory.newInstance().newSAXParser().parse(inputStream, saxHandler); } catch (Exception e) { this.listener.exceptionThrown(e); } } if (readObjIndex >= readObjs.size()) { throw new ArrayIndexOutOfBoundsException(Messages.getString("beans.70")); } Elem elem = readObjs.get(readObjIndex); if (!elem.isClosed) { // bad element, error occurred while parsing throw new ArrayIndexOutOfBoundsException(Messages.getString("beans.70")); } readObjIndex++; return elem.result; }
[ "@", "SuppressWarnings", "(", "\"nls\"", ")", "public", "Object", "readObject", "(", ")", "{", "if", "(", "inputStream", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "saxHandler", "==", "null", ")", "{", "saxHandler", "=", "new", "SAXHandler", "(", ")", ";", "try", "{", "SAXParserFactory", ".", "newInstance", "(", ")", ".", "newSAXParser", "(", ")", ".", "parse", "(", "inputStream", ",", "saxHandler", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "this", ".", "listener", ".", "exceptionThrown", "(", "e", ")", ";", "}", "}", "if", "(", "readObjIndex", ">=", "readObjs", ".", "size", "(", ")", ")", "{", "throw", "new", "ArrayIndexOutOfBoundsException", "(", "Messages", ".", "getString", "(", "\"beans.70\"", ")", ")", ";", "}", "Elem", "elem", "=", "readObjs", ".", "get", "(", "readObjIndex", ")", ";", "if", "(", "!", "elem", ".", "isClosed", ")", "{", "// bad element, error occurred while parsing", "throw", "new", "ArrayIndexOutOfBoundsException", "(", "Messages", ".", "getString", "(", "\"beans.70\"", ")", ")", ";", "}", "readObjIndex", "++", ";", "return", "elem", ".", "result", ";", "}" ]
Reads the next object. @return the next object @exception ArrayIndexOutOfBoundsException if no more objects to read
[ "Reads", "the", "next", "object", "." ]
73e51d0f3141a859dfbd37ca9becef98477e553e
https://github.com/app55/app55-java/blob/73e51d0f3141a859dfbd37ca9becef98477e553e/src/support/java/com/googlecode/openbeans/XMLDecoder.java#L781-L813
155,512
james-hu/jabb-core
src/main/java/net/sf/jabb/util/col/MapGetter.java
MapGetter.get
public V get(Map<?, V> map){ for (Object k : keys){ V v = map.get(k); if (v != null){ return v; } } return null; }
java
public V get(Map<?, V> map){ for (Object k : keys){ V v = map.get(k); if (v != null){ return v; } } return null; }
[ "public", "V", "get", "(", "Map", "<", "?", ",", "V", ">", "map", ")", "{", "for", "(", "Object", "k", ":", "keys", ")", "{", "V", "v", "=", "map", ".", "get", "(", "k", ")", ";", "if", "(", "v", "!=", "null", ")", "{", "return", "v", ";", "}", "}", "return", "null", ";", "}" ]
Get the first matching value in the map. @param map @return null if nothing found
[ "Get", "the", "first", "matching", "value", "in", "the", "map", "." ]
bceed441595c5e5195a7418795f03b69fa7b61e4
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/util/col/MapGetter.java#L42-L50
155,513
konvergeio/cofoja
src/main/java/com/google/java/contract/core/agent/ContractFixingClassAdapter.java
ContractFixingClassAdapter.visitMethod
@Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { MethodVisitor mv = cv.visitMethod(access | Opcodes.ACC_SYNTHETIC, name, desc, signature, exceptions); return new AccessMethodAdapter(mv); }
java
@Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { MethodVisitor mv = cv.visitMethod(access | Opcodes.ACC_SYNTHETIC, name, desc, signature, exceptions); return new AccessMethodAdapter(mv); }
[ "@", "Override", "public", "MethodVisitor", "visitMethod", "(", "int", "access", ",", "String", "name", ",", "String", "desc", ",", "String", "signature", ",", "String", "[", "]", "exceptions", ")", "{", "MethodVisitor", "mv", "=", "cv", ".", "visitMethod", "(", "access", "|", "Opcodes", ".", "ACC_SYNTHETIC", ",", "name", ",", "desc", ",", "signature", ",", "exceptions", ")", ";", "return", "new", "AccessMethodAdapter", "(", "mv", ")", ";", "}" ]
Visits the specified method fixing method calls.
[ "Visits", "the", "specified", "method", "fixing", "method", "calls", "." ]
6ded58fa05eb5bf85f16353c8dd4c70bee59121a
https://github.com/konvergeio/cofoja/blob/6ded58fa05eb5bf85f16353c8dd4c70bee59121a/src/main/java/com/google/java/contract/core/agent/ContractFixingClassAdapter.java#L87-L93
155,514
james-hu/jabb-core
src/main/java/net/sf/jabb/util/stat/TimePeriod.java
TimePeriod.from
static public TimePeriod from(String quantityAndUnit) { String trimed = quantityAndUnit.trim(); String allExceptLast = trimed.substring(0, trimed.length() - 1); if (StringUtils.isNumericSpace(allExceptLast)){ // short format long quantity = Long.parseLong(allExceptLast.trim()); TimePeriodUnit unit = TimePeriodUnit.from(Character.toUpperCase(trimed.charAt(trimed.length() - 1))); return new TimePeriod(quantity, unit); }else{ String[] durationAndUnit = StringUtils.split(trimed); Long duration = Long.valueOf(durationAndUnit[0]); TimePeriodUnit unit = TimePeriodUnit.from(durationAndUnit[1]); return new TimePeriod(duration, unit); } }
java
static public TimePeriod from(String quantityAndUnit) { String trimed = quantityAndUnit.trim(); String allExceptLast = trimed.substring(0, trimed.length() - 1); if (StringUtils.isNumericSpace(allExceptLast)){ // short format long quantity = Long.parseLong(allExceptLast.trim()); TimePeriodUnit unit = TimePeriodUnit.from(Character.toUpperCase(trimed.charAt(trimed.length() - 1))); return new TimePeriod(quantity, unit); }else{ String[] durationAndUnit = StringUtils.split(trimed); Long duration = Long.valueOf(durationAndUnit[0]); TimePeriodUnit unit = TimePeriodUnit.from(durationAndUnit[1]); return new TimePeriod(duration, unit); } }
[ "static", "public", "TimePeriod", "from", "(", "String", "quantityAndUnit", ")", "{", "String", "trimed", "=", "quantityAndUnit", ".", "trim", "(", ")", ";", "String", "allExceptLast", "=", "trimed", ".", "substring", "(", "0", ",", "trimed", ".", "length", "(", ")", "-", "1", ")", ";", "if", "(", "StringUtils", ".", "isNumericSpace", "(", "allExceptLast", ")", ")", "{", "// short format", "long", "quantity", "=", "Long", ".", "parseLong", "(", "allExceptLast", ".", "trim", "(", ")", ")", ";", "TimePeriodUnit", "unit", "=", "TimePeriodUnit", ".", "from", "(", "Character", ".", "toUpperCase", "(", "trimed", ".", "charAt", "(", "trimed", ".", "length", "(", ")", "-", "1", ")", ")", ")", ";", "return", "new", "TimePeriod", "(", "quantity", ",", "unit", ")", ";", "}", "else", "{", "String", "[", "]", "durationAndUnit", "=", "StringUtils", ".", "split", "(", "trimed", ")", ";", "Long", "duration", "=", "Long", ".", "valueOf", "(", "durationAndUnit", "[", "0", "]", ")", ";", "TimePeriodUnit", "unit", "=", "TimePeriodUnit", ".", "from", "(", "durationAndUnit", "[", "1", "]", ")", ";", "return", "new", "TimePeriod", "(", "duration", ",", "unit", ")", ";", "}", "}" ]
Parse strings like '1 hour', '2 days', '3 Years', '12 minute' into TimePeriod. Short formats like '1H', '2 D', '3y' are also supported. @param quantityAndUnit the string to be parsed @return Both quantity and unit
[ "Parse", "strings", "like", "1", "hour", "2", "days", "3", "Years", "12", "minute", "into", "TimePeriod", ".", "Short", "formats", "like", "1H", "2", "D", "3y", "are", "also", "supported", "." ]
bceed441595c5e5195a7418795f03b69fa7b61e4
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/util/stat/TimePeriod.java#L104-L117
155,515
ryanbrainard/richsobjects
richsobjects-cache-memcached/src/main/java/com/github/ryanbrainard/richsobjects/api/client/ClassLoaderRegisteringObjectInputStream.java
ClassLoaderRegisteringObjectInputStream.resolveClass
@Override protected Class resolveClass(ObjectStreamClass classDesc) throws IOException, ClassNotFoundException { for (ClassLoader loader : classLoaderRegistration) { try { return resolveClass(classDesc, loader); } catch (ClassNotFoundException e) { // ignore } } return super.resolveClass(classDesc); }
java
@Override protected Class resolveClass(ObjectStreamClass classDesc) throws IOException, ClassNotFoundException { for (ClassLoader loader : classLoaderRegistration) { try { return resolveClass(classDesc, loader); } catch (ClassNotFoundException e) { // ignore } } return super.resolveClass(classDesc); }
[ "@", "Override", "protected", "Class", "resolveClass", "(", "ObjectStreamClass", "classDesc", ")", "throws", "IOException", ",", "ClassNotFoundException", "{", "for", "(", "ClassLoader", "loader", ":", "classLoaderRegistration", ")", "{", "try", "{", "return", "resolveClass", "(", "classDesc", ",", "loader", ")", ";", "}", "catch", "(", "ClassNotFoundException", "e", ")", "{", "// ignore", "}", "}", "return", "super", ".", "resolveClass", "(", "classDesc", ")", ";", "}" ]
Use the registered ClassLoaders to resolve and then use system class loader
[ "Use", "the", "registered", "ClassLoaders", "to", "resolve", "and", "then", "use", "system", "class", "loader" ]
d1af259d9098557c2abd53f94c20cc663cf9b6e7
https://github.com/ryanbrainard/richsobjects/blob/d1af259d9098557c2abd53f94c20cc663cf9b6e7/richsobjects-cache-memcached/src/main/java/com/github/ryanbrainard/richsobjects/api/client/ClassLoaderRegisteringObjectInputStream.java#L49-L59
155,516
app55/app55-java
src/support/java/com/googlecode/openbeans/beancontext/BeanContextSupport.java
BeanContextSupport.classEquals
protected static final boolean classEquals(Class clz1, Class clz2) { if (clz1 == null || clz2 == null) { throw new NullPointerException(); } return clz1 == clz2 || clz1.getName().equals(clz2.getName()); }
java
protected static final boolean classEquals(Class clz1, Class clz2) { if (clz1 == null || clz2 == null) { throw new NullPointerException(); } return clz1 == clz2 || clz1.getName().equals(clz2.getName()); }
[ "protected", "static", "final", "boolean", "classEquals", "(", "Class", "clz1", ",", "Class", "clz2", ")", "{", "if", "(", "clz1", "==", "null", "||", "clz2", "==", "null", ")", "{", "throw", "new", "NullPointerException", "(", ")", ";", "}", "return", "clz1", "==", "clz2", "||", "clz1", ".", "getName", "(", ")", ".", "equals", "(", "clz2", ".", "getName", "(", ")", ")", ";", "}" ]
Compares if two classes are equal or their class names are equal. @param clz1 a class @param clz2 another class @return true if two class objects are equal or their class names are equal.
[ "Compares", "if", "two", "classes", "are", "equal", "or", "their", "class", "names", "are", "equal", "." ]
73e51d0f3141a859dfbd37ca9becef98477e553e
https://github.com/app55/app55-java/blob/73e51d0f3141a859dfbd37ca9becef98477e553e/src/support/java/com/googlecode/openbeans/beancontext/BeanContextSupport.java#L476-L483
155,517
app55/app55-java
src/support/java/com/googlecode/openbeans/beancontext/BeanContextSupport.java
BeanContextSupport.toArray
@SuppressWarnings("unchecked") public Object[] toArray(Object[] array) { synchronized (children) { return children.keySet().toArray(array); } }
java
@SuppressWarnings("unchecked") public Object[] toArray(Object[] array) { synchronized (children) { return children.keySet().toArray(array); } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "Object", "[", "]", "toArray", "(", "Object", "[", "]", "array", ")", "{", "synchronized", "(", "children", ")", "{", "return", "children", ".", "keySet", "(", ")", ".", "toArray", "(", "array", ")", ";", "}", "}" ]
Returns an array of children of this context. @return an array of children of this context @see java.util.Collection#toArray(java.lang.Object[])
[ "Returns", "an", "array", "of", "children", "of", "this", "context", "." ]
73e51d0f3141a859dfbd37ca9becef98477e553e
https://github.com/app55/app55-java/blob/73e51d0f3141a859dfbd37ca9becef98477e553e/src/support/java/com/googlecode/openbeans/beancontext/BeanContextSupport.java#L1302-L1309
155,518
SimiaCryptus/utilities
java-util/src/main/java/com/simiacryptus/util/data/DensityTree.java
DensityTree.setMinSplitFract
@javax.annotation.Nonnull public com.simiacryptus.util.data.DensityTree setMinSplitFract(double minSplitFract) { this.minSplitFract = minSplitFract; return this; }
java
@javax.annotation.Nonnull public com.simiacryptus.util.data.DensityTree setMinSplitFract(double minSplitFract) { this.minSplitFract = minSplitFract; return this; }
[ "@", "javax", ".", "annotation", ".", "Nonnull", "public", "com", ".", "simiacryptus", ".", "util", ".", "data", ".", "DensityTree", "setMinSplitFract", "(", "double", "minSplitFract", ")", "{", "this", ".", "minSplitFract", "=", "minSplitFract", ";", "return", "this", ";", "}" ]
Sets min split fract. @param minSplitFract the min split fract @return the min split fract
[ "Sets", "min", "split", "fract", "." ]
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/data/DensityTree.java#L81-L85
155,519
SimiaCryptus/utilities
java-util/src/main/java/com/simiacryptus/util/data/DensityTree.java
DensityTree.setSplitSizeThreshold
@javax.annotation.Nonnull public com.simiacryptus.util.data.DensityTree setSplitSizeThreshold(int splitSizeThreshold) { this.splitSizeThreshold = splitSizeThreshold; return this; }
java
@javax.annotation.Nonnull public com.simiacryptus.util.data.DensityTree setSplitSizeThreshold(int splitSizeThreshold) { this.splitSizeThreshold = splitSizeThreshold; return this; }
[ "@", "javax", ".", "annotation", ".", "Nonnull", "public", "com", ".", "simiacryptus", ".", "util", ".", "data", ".", "DensityTree", "setSplitSizeThreshold", "(", "int", "splitSizeThreshold", ")", "{", "this", ".", "splitSizeThreshold", "=", "splitSizeThreshold", ";", "return", "this", ";", "}" ]
Sets split size threshold. @param splitSizeThreshold the split size threshold @return the split size threshold
[ "Sets", "split", "size", "threshold", "." ]
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/data/DensityTree.java#L102-L106
155,520
SimiaCryptus/utilities
java-util/src/main/java/com/simiacryptus/util/data/DensityTree.java
DensityTree.setMinFitness
@javax.annotation.Nonnull public com.simiacryptus.util.data.DensityTree setMinFitness(double minFitness) { this.minFitness = minFitness; return this; }
java
@javax.annotation.Nonnull public com.simiacryptus.util.data.DensityTree setMinFitness(double minFitness) { this.minFitness = minFitness; return this; }
[ "@", "javax", ".", "annotation", ".", "Nonnull", "public", "com", ".", "simiacryptus", ".", "util", ".", "data", ".", "DensityTree", "setMinFitness", "(", "double", "minFitness", ")", "{", "this", ".", "minFitness", "=", "minFitness", ";", "return", "this", ";", "}" ]
Sets min fitness. @param minFitness the min fitness @return the min fitness
[ "Sets", "min", "fitness", "." ]
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/data/DensityTree.java#L132-L136
155,521
SimiaCryptus/utilities
java-util/src/main/java/com/simiacryptus/util/data/DensityTree.java
DensityTree.setMaxDepth
@javax.annotation.Nonnull public com.simiacryptus.util.data.DensityTree setMaxDepth(int maxDepth) { this.maxDepth = maxDepth; return this; }
java
@javax.annotation.Nonnull public com.simiacryptus.util.data.DensityTree setMaxDepth(int maxDepth) { this.maxDepth = maxDepth; return this; }
[ "@", "javax", ".", "annotation", ".", "Nonnull", "public", "com", ".", "simiacryptus", ".", "util", ".", "data", ".", "DensityTree", "setMaxDepth", "(", "int", "maxDepth", ")", "{", "this", ".", "maxDepth", "=", "maxDepth", ";", "return", "this", ";", "}" ]
Sets max depth. @param maxDepth the max depth @return the max depth
[ "Sets", "max", "depth", "." ]
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/data/DensityTree.java#L153-L157
155,522
JM-Lab/utils-java8
src/main/java/kr/jm/utils/stats/collector/WordNumberCollectorBundle.java
WordNumberCollectorBundle.addWord
public WordNumberCollectorBundle addWord(String key, String word) { wordCollector.add(key, word); return this; }
java
public WordNumberCollectorBundle addWord(String key, String word) { wordCollector.add(key, word); return this; }
[ "public", "WordNumberCollectorBundle", "addWord", "(", "String", "key", ",", "String", "word", ")", "{", "wordCollector", ".", "add", "(", "key", ",", "word", ")", ";", "return", "this", ";", "}" ]
Add word word number collector bundle. @param key the key @param word the word @return the word number collector bundle
[ "Add", "word", "word", "number", "collector", "bundle", "." ]
9e407b3f28a7990418a1e877229fa8344f4d78a5
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/stats/collector/WordNumberCollectorBundle.java#L45-L48
155,523
JM-Lab/utils-java8
src/main/java/kr/jm/utils/stats/collector/WordNumberCollectorBundle.java
WordNumberCollectorBundle.addWordList
public WordNumberCollectorBundle addWordList(String key, List<String> wordList) { wordCollector.addAll(key, wordList); return this; }
java
public WordNumberCollectorBundle addWordList(String key, List<String> wordList) { wordCollector.addAll(key, wordList); return this; }
[ "public", "WordNumberCollectorBundle", "addWordList", "(", "String", "key", ",", "List", "<", "String", ">", "wordList", ")", "{", "wordCollector", ".", "addAll", "(", "key", ",", "wordList", ")", ";", "return", "this", ";", "}" ]
Add word list word number collector bundle. @param key the key @param wordList the word list @return the word number collector bundle
[ "Add", "word", "list", "word", "number", "collector", "bundle", "." ]
9e407b3f28a7990418a1e877229fa8344f4d78a5
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/stats/collector/WordNumberCollectorBundle.java#L57-L61
155,524
JM-Lab/utils-java8
src/main/java/kr/jm/utils/stats/collector/WordNumberCollectorBundle.java
WordNumberCollectorBundle.addNumber
public WordNumberCollectorBundle addNumber(String key, Number number) { numberCollector.add(key, number); return this; }
java
public WordNumberCollectorBundle addNumber(String key, Number number) { numberCollector.add(key, number); return this; }
[ "public", "WordNumberCollectorBundle", "addNumber", "(", "String", "key", ",", "Number", "number", ")", "{", "numberCollector", ".", "add", "(", "key", ",", "number", ")", ";", "return", "this", ";", "}" ]
Add number word number collector bundle. @param key the key @param number the number @return the word number collector bundle
[ "Add", "number", "word", "number", "collector", "bundle", "." ]
9e407b3f28a7990418a1e877229fa8344f4d78a5
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/stats/collector/WordNumberCollectorBundle.java#L79-L82
155,525
JM-Lab/utils-java8
src/main/java/kr/jm/utils/stats/collector/WordNumberCollectorBundle.java
WordNumberCollectorBundle.addNumberList
public WordNumberCollectorBundle addNumberList(String key, List<Number> numberList) { numberCollector.addAll(key, numberList); return this; }
java
public WordNumberCollectorBundle addNumberList(String key, List<Number> numberList) { numberCollector.addAll(key, numberList); return this; }
[ "public", "WordNumberCollectorBundle", "addNumberList", "(", "String", "key", ",", "List", "<", "Number", ">", "numberList", ")", "{", "numberCollector", ".", "addAll", "(", "key", ",", "numberList", ")", ";", "return", "this", ";", "}" ]
Add number list word number collector bundle. @param key the key @param numberList the number list @return the word number collector bundle
[ "Add", "number", "list", "word", "number", "collector", "bundle", "." ]
9e407b3f28a7990418a1e877229fa8344f4d78a5
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/stats/collector/WordNumberCollectorBundle.java#L91-L95
155,526
JM-Lab/utils-java8
src/main/java/kr/jm/utils/stats/collector/WordNumberCollectorBundle.java
WordNumberCollectorBundle.addData
public WordNumberCollectorBundle addData(String key, String data) { if (JMString.isNumber(data)) addNumber(key, Double.valueOf(data)); else addWord(key, data); return this; }
java
public WordNumberCollectorBundle addData(String key, String data) { if (JMString.isNumber(data)) addNumber(key, Double.valueOf(data)); else addWord(key, data); return this; }
[ "public", "WordNumberCollectorBundle", "addData", "(", "String", "key", ",", "String", "data", ")", "{", "if", "(", "JMString", ".", "isNumber", "(", "data", ")", ")", "addNumber", "(", "key", ",", "Double", ".", "valueOf", "(", "data", ")", ")", ";", "else", "addWord", "(", "key", ",", "data", ")", ";", "return", "this", ";", "}" ]
Add data word number collector bundle. @param key the key @param data the data @return the word number collector bundle
[ "Add", "data", "word", "number", "collector", "bundle", "." ]
9e407b3f28a7990418a1e877229fa8344f4d78a5
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/stats/collector/WordNumberCollectorBundle.java#L113-L119
155,527
JM-Lab/utils-java8
src/main/java/kr/jm/utils/stats/collector/WordNumberCollectorBundle.java
WordNumberCollectorBundle.merge
public WordNumberCollectorBundle merge( WordNumberCollectorBundle wordNumberCollector) { wordCollector.merge(wordNumberCollector.wordCollector); numberCollector.merge(wordNumberCollector.numberCollector); return this; }
java
public WordNumberCollectorBundle merge( WordNumberCollectorBundle wordNumberCollector) { wordCollector.merge(wordNumberCollector.wordCollector); numberCollector.merge(wordNumberCollector.numberCollector); return this; }
[ "public", "WordNumberCollectorBundle", "merge", "(", "WordNumberCollectorBundle", "wordNumberCollector", ")", "{", "wordCollector", ".", "merge", "(", "wordNumberCollector", ".", "wordCollector", ")", ";", "numberCollector", ".", "merge", "(", "wordNumberCollector", ".", "numberCollector", ")", ";", "return", "this", ";", "}" ]
Merge word number collector bundle. @param wordNumberCollector the word number collector @return the word number collector bundle
[ "Merge", "word", "number", "collector", "bundle", "." ]
9e407b3f28a7990418a1e877229fa8344f4d78a5
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/stats/collector/WordNumberCollectorBundle.java#L127-L132
155,528
jwcarman/Domdrides
hibernate/src/main/java/org/domdrides/hibernate/repository/HibernateRepository.java
HibernateRepository.list
public List<E> list(int first, int max, String sortProperty, boolean ascending) { Criteria c = createCriteria() .setMaxResults(max) .setFirstResult(first); final int ndx = sortProperty.lastIndexOf('.'); if (ndx != -1) { final String associationPath = sortProperty.substring(0, ndx); final String propertyName = sortProperty.substring(ndx + 1); c = c.createAlias(associationPath, ASSOCIATION_ALIAS) .addOrder(ascending ? Order.asc(ASSOCIATION_ALIAS + "." + propertyName) : Order.desc(ASSOCIATION_ALIAS + "." + propertyName)); } else { c = c.addOrder(ascending ? Order.asc(sortProperty) : Order.desc(sortProperty)); } return list(c); }
java
public List<E> list(int first, int max, String sortProperty, boolean ascending) { Criteria c = createCriteria() .setMaxResults(max) .setFirstResult(first); final int ndx = sortProperty.lastIndexOf('.'); if (ndx != -1) { final String associationPath = sortProperty.substring(0, ndx); final String propertyName = sortProperty.substring(ndx + 1); c = c.createAlias(associationPath, ASSOCIATION_ALIAS) .addOrder(ascending ? Order.asc(ASSOCIATION_ALIAS + "." + propertyName) : Order.desc(ASSOCIATION_ALIAS + "." + propertyName)); } else { c = c.addOrder(ascending ? Order.asc(sortProperty) : Order.desc(sortProperty)); } return list(c); }
[ "public", "List", "<", "E", ">", "list", "(", "int", "first", ",", "int", "max", ",", "String", "sortProperty", ",", "boolean", "ascending", ")", "{", "Criteria", "c", "=", "createCriteria", "(", ")", ".", "setMaxResults", "(", "max", ")", ".", "setFirstResult", "(", "first", ")", ";", "final", "int", "ndx", "=", "sortProperty", ".", "lastIndexOf", "(", "'", "'", ")", ";", "if", "(", "ndx", "!=", "-", "1", ")", "{", "final", "String", "associationPath", "=", "sortProperty", ".", "substring", "(", "0", ",", "ndx", ")", ";", "final", "String", "propertyName", "=", "sortProperty", ".", "substring", "(", "ndx", "+", "1", ")", ";", "c", "=", "c", ".", "createAlias", "(", "associationPath", ",", "ASSOCIATION_ALIAS", ")", ".", "addOrder", "(", "ascending", "?", "Order", ".", "asc", "(", "ASSOCIATION_ALIAS", "+", "\".\"", "+", "propertyName", ")", ":", "Order", ".", "desc", "(", "ASSOCIATION_ALIAS", "+", "\".\"", "+", "propertyName", ")", ")", ";", "}", "else", "{", "c", "=", "c", ".", "addOrder", "(", "ascending", "?", "Order", ".", "asc", "(", "sortProperty", ")", ":", "Order", ".", "desc", "(", "sortProperty", ")", ")", ";", "}", "return", "list", "(", "c", ")", ";", "}" ]
Returns one page of data from this repository. @param first the first entity to return @param max the maximum number of entities to return @param sortProperty the property to sort by @param ascending whether or not the sorting is asceding @return one page of data from this repository
[ "Returns", "one", "page", "of", "data", "from", "this", "repository", "." ]
dde68b0fc6fee54410afd9100aac0d7d23cfe098
https://github.com/jwcarman/Domdrides/blob/dde68b0fc6fee54410afd9100aac0d7d23cfe098/hibernate/src/main/java/org/domdrides/hibernate/repository/HibernateRepository.java#L80-L98
155,529
jwcarman/Domdrides
hibernate/src/main/java/org/domdrides/hibernate/repository/HibernateRepository.java
HibernateRepository.list
@SuppressWarnings(UNCHECKED) protected List<E> list(Criteria criteria) { return new ArrayList<E>(criteria.list()); }
java
@SuppressWarnings(UNCHECKED) protected List<E> list(Criteria criteria) { return new ArrayList<E>(criteria.list()); }
[ "@", "SuppressWarnings", "(", "UNCHECKED", ")", "protected", "List", "<", "E", ">", "list", "(", "Criteria", "criteria", ")", "{", "return", "new", "ArrayList", "<", "E", ">", "(", "criteria", ".", "list", "(", ")", ")", ";", "}" ]
Returns a list of entities based on the provided criteria. @param criteria the criteria @return a list of entities based on the provided criteria
[ "Returns", "a", "list", "of", "entities", "based", "on", "the", "provided", "criteria", "." ]
dde68b0fc6fee54410afd9100aac0d7d23cfe098
https://github.com/jwcarman/Domdrides/blob/dde68b0fc6fee54410afd9100aac0d7d23cfe098/hibernate/src/main/java/org/domdrides/hibernate/repository/HibernateRepository.java#L175-L179
155,530
jwcarman/Domdrides
hibernate/src/main/java/org/domdrides/hibernate/repository/HibernateRepository.java
HibernateRepository.list
@SuppressWarnings(UNCHECKED) protected List<E> list(Query query) { return new ArrayList<E>(query.list()); }
java
@SuppressWarnings(UNCHECKED) protected List<E> list(Query query) { return new ArrayList<E>(query.list()); }
[ "@", "SuppressWarnings", "(", "UNCHECKED", ")", "protected", "List", "<", "E", ">", "list", "(", "Query", "query", ")", "{", "return", "new", "ArrayList", "<", "E", ">", "(", "query", ".", "list", "(", ")", ")", ";", "}" ]
Returns a list of entities based on the provided query. @param query the query @return a list of entities based on the provided query
[ "Returns", "a", "list", "of", "entities", "based", "on", "the", "provided", "query", "." ]
dde68b0fc6fee54410afd9100aac0d7d23cfe098
https://github.com/jwcarman/Domdrides/blob/dde68b0fc6fee54410afd9100aac0d7d23cfe098/hibernate/src/main/java/org/domdrides/hibernate/repository/HibernateRepository.java#L187-L191
155,531
jwcarman/Domdrides
hibernate/src/main/java/org/domdrides/hibernate/repository/HibernateRepository.java
HibernateRepository.set
@SuppressWarnings(UNCHECKED) protected Set<E> set(Criteria criteria) { return new HashSet<E>(criteria.list()); }
java
@SuppressWarnings(UNCHECKED) protected Set<E> set(Criteria criteria) { return new HashSet<E>(criteria.list()); }
[ "@", "SuppressWarnings", "(", "UNCHECKED", ")", "protected", "Set", "<", "E", ">", "set", "(", "Criteria", "criteria", ")", "{", "return", "new", "HashSet", "<", "E", ">", "(", "criteria", ".", "list", "(", ")", ")", ";", "}" ]
Returns a set of entities based on the provided criteria. @param criteria the criteria @return a set of entities based on the provided criteria
[ "Returns", "a", "set", "of", "entities", "based", "on", "the", "provided", "criteria", "." ]
dde68b0fc6fee54410afd9100aac0d7d23cfe098
https://github.com/jwcarman/Domdrides/blob/dde68b0fc6fee54410afd9100aac0d7d23cfe098/hibernate/src/main/java/org/domdrides/hibernate/repository/HibernateRepository.java#L199-L203
155,532
jwcarman/Domdrides
hibernate/src/main/java/org/domdrides/hibernate/repository/HibernateRepository.java
HibernateRepository.set
@SuppressWarnings(UNCHECKED) protected Set<E> set(Query query) { return new HashSet<E>(query.list()); }
java
@SuppressWarnings(UNCHECKED) protected Set<E> set(Query query) { return new HashSet<E>(query.list()); }
[ "@", "SuppressWarnings", "(", "UNCHECKED", ")", "protected", "Set", "<", "E", ">", "set", "(", "Query", "query", ")", "{", "return", "new", "HashSet", "<", "E", ">", "(", "query", ".", "list", "(", ")", ")", ";", "}" ]
Returns a set of entities based on the provided query. @param query the query @return a set of entities based on the provided query
[ "Returns", "a", "set", "of", "entities", "based", "on", "the", "provided", "query", "." ]
dde68b0fc6fee54410afd9100aac0d7d23cfe098
https://github.com/jwcarman/Domdrides/blob/dde68b0fc6fee54410afd9100aac0d7d23cfe098/hibernate/src/main/java/org/domdrides/hibernate/repository/HibernateRepository.java#L211-L215
155,533
hudson3-plugins/warnings-plugin
src/main/java/hudson/plugins/warnings/parser/AbstractWarningsParser.java
AbstractWarningsParser.getLineNumber
protected final int getLineNumber(final String lineNumber) { if (StringUtils.isNotBlank(lineNumber)) { try { return Integer.parseInt(lineNumber); } catch (NumberFormatException exception) { // ignore and return 0 } } return 0; }
java
protected final int getLineNumber(final String lineNumber) { if (StringUtils.isNotBlank(lineNumber)) { try { return Integer.parseInt(lineNumber); } catch (NumberFormatException exception) { // ignore and return 0 } } return 0; }
[ "protected", "final", "int", "getLineNumber", "(", "final", "String", "lineNumber", ")", "{", "if", "(", "StringUtils", ".", "isNotBlank", "(", "lineNumber", ")", ")", "{", "try", "{", "return", "Integer", ".", "parseInt", "(", "lineNumber", ")", ";", "}", "catch", "(", "NumberFormatException", "exception", ")", "{", "// ignore and return 0", "}", "}", "return", "0", ";", "}" ]
Converts a string line number to an integer value. If the string is not a valid line number, then 0 is returned which indicates a warning at the top of the file. @param lineNumber the line number (as a string) @return the line number
[ "Converts", "a", "string", "line", "number", "to", "an", "integer", "value", ".", "If", "the", "string", "is", "not", "a", "valid", "line", "number", "then", "0", "is", "returned", "which", "indicates", "a", "warning", "at", "the", "top", "of", "the", "file", "." ]
462c9f3dffede9120173935567392b22520b0966
https://github.com/hudson3-plugins/warnings-plugin/blob/462c9f3dffede9120173935567392b22520b0966/src/main/java/hudson/plugins/warnings/parser/AbstractWarningsParser.java#L274-L284
155,534
foundation-runtime/service-directory
1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/lb/RoundRobinLoadBalancer.java
RoundRobinLoadBalancer.vote
@Override public ServiceInstance vote(List<ServiceInstance> instances) { if (instances.isEmpty()) { return null; } int i = index.getAndIncrement(); int pos = i % instances.size(); ServiceInstance instance = instances.get(pos); return instance; }
java
@Override public ServiceInstance vote(List<ServiceInstance> instances) { if (instances.isEmpty()) { return null; } int i = index.getAndIncrement(); int pos = i % instances.size(); ServiceInstance instance = instances.get(pos); return instance; }
[ "@", "Override", "public", "ServiceInstance", "vote", "(", "List", "<", "ServiceInstance", ">", "instances", ")", "{", "if", "(", "instances", ".", "isEmpty", "(", ")", ")", "{", "return", "null", ";", "}", "int", "i", "=", "index", ".", "getAndIncrement", "(", ")", ";", "int", "pos", "=", "i", "%", "instances", ".", "size", "(", ")", ";", "ServiceInstance", "instance", "=", "instances", ".", "get", "(", "pos", ")", ";", "return", "instance", ";", "}" ]
Vote a ServiceInstance based on the RoundRobin LoadBalancer algorithm. @return the voted ServiceInstance.
[ "Vote", "a", "ServiceInstance", "based", "on", "the", "RoundRobin", "LoadBalancer", "algorithm", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/lb/RoundRobinLoadBalancer.java#L57-L66
155,535
bushidowallet/bushido-java-service
bushido-service-lib/src/main/java/com/bccapi/bitlib/util/ByteReader.java
ByteReader.getUInt32
public long getUInt32() throws InsufficientBytesException { checkAvailable(4); byte[] intBytes = getBytes(4); return byteAsULong(intBytes[0]) | (byteAsULong(intBytes[1]) << 8) | (byteAsULong(intBytes[2]) << 16) | (byteAsULong(intBytes[3]) << 24); }
java
public long getUInt32() throws InsufficientBytesException { checkAvailable(4); byte[] intBytes = getBytes(4); return byteAsULong(intBytes[0]) | (byteAsULong(intBytes[1]) << 8) | (byteAsULong(intBytes[2]) << 16) | (byteAsULong(intBytes[3]) << 24); }
[ "public", "long", "getUInt32", "(", ")", "throws", "InsufficientBytesException", "{", "checkAvailable", "(", "4", ")", ";", "byte", "[", "]", "intBytes", "=", "getBytes", "(", "4", ")", ";", "return", "byteAsULong", "(", "intBytes", "[", "0", "]", ")", "|", "(", "byteAsULong", "(", "intBytes", "[", "1", "]", ")", "<<", "8", ")", "|", "(", "byteAsULong", "(", "intBytes", "[", "2", "]", ")", "<<", "16", ")", "|", "(", "byteAsULong", "(", "intBytes", "[", "3", "]", ")", "<<", "24", ")", ";", "}" ]
Gets a java long type from 4 bytes of data representing 32-bit unsigned integer @return 32-bit unsigned integer @throws InsufficientBytesException when less than 4 bytes available
[ "Gets", "a", "java", "long", "type", "from", "4", "bytes", "of", "data", "representing", "32", "-", "bit", "unsigned", "integer" ]
e1a0157527e57459b509718044d2df44084876a2
https://github.com/bushidowallet/bushido-java-service/blob/e1a0157527e57459b509718044d2df44084876a2/bushido-service-lib/src/main/java/com/bccapi/bitlib/util/ByteReader.java#L57-L61
155,536
PureSolTechnologies/parsers
parsers/src/main/java/com/puresoltechnologies/parsers/parser/packrat/PackratParser.java
PackratParser.extractHiddenAndIgnoredTokensFromGrammar
private Set<TokenDefinition> extractHiddenAndIgnoredTokensFromGrammar() { Set<TokenDefinition> hiddenAndIgnoredTokens = new LinkedHashSet<TokenDefinition>(); for (TokenDefinition tokenDefinition : grammar.getTokenDefinitions().getDefinitions()) { Visibility visibility = tokenDefinition.getVisibility(); if ((visibility == Visibility.HIDDEN) || (visibility == Visibility.IGNORED)) { hiddenAndIgnoredTokens.add(tokenDefinition); } } return hiddenAndIgnoredTokens; }
java
private Set<TokenDefinition> extractHiddenAndIgnoredTokensFromGrammar() { Set<TokenDefinition> hiddenAndIgnoredTokens = new LinkedHashSet<TokenDefinition>(); for (TokenDefinition tokenDefinition : grammar.getTokenDefinitions().getDefinitions()) { Visibility visibility = tokenDefinition.getVisibility(); if ((visibility == Visibility.HIDDEN) || (visibility == Visibility.IGNORED)) { hiddenAndIgnoredTokens.add(tokenDefinition); } } return hiddenAndIgnoredTokens; }
[ "private", "Set", "<", "TokenDefinition", ">", "extractHiddenAndIgnoredTokensFromGrammar", "(", ")", "{", "Set", "<", "TokenDefinition", ">", "hiddenAndIgnoredTokens", "=", "new", "LinkedHashSet", "<", "TokenDefinition", ">", "(", ")", ";", "for", "(", "TokenDefinition", "tokenDefinition", ":", "grammar", ".", "getTokenDefinitions", "(", ")", ".", "getDefinitions", "(", ")", ")", "{", "Visibility", "visibility", "=", "tokenDefinition", ".", "getVisibility", "(", ")", ";", "if", "(", "(", "visibility", "==", "Visibility", ".", "HIDDEN", ")", "||", "(", "visibility", "==", "Visibility", ".", "IGNORED", ")", ")", "{", "hiddenAndIgnoredTokens", ".", "add", "(", "tokenDefinition", ")", ";", "}", "}", "return", "hiddenAndIgnoredTokens", ";", "}" ]
This method extracts all token definitions which are to be ignored or hidden to process them separately and to put them into special locations into the parser tree. @return
[ "This", "method", "extracts", "all", "token", "definitions", "which", "are", "to", "be", "ignored", "or", "hidden", "to", "process", "them", "separately", "and", "to", "put", "them", "into", "special", "locations", "into", "the", "parser", "tree", "." ]
61077223b90d3768ff9445ae13036343c98b63cd
https://github.com/PureSolTechnologies/parsers/blob/61077223b90d3768ff9445ae13036343c98b63cd/parsers/src/main/java/com/puresoltechnologies/parsers/parser/packrat/PackratParser.java#L129-L138
155,537
PureSolTechnologies/parsers
parsers/src/main/java/com/puresoltechnologies/parsers/parser/packrat/PackratParser.java
PackratParser.initialize
private void initialize(SourceCode sourceCode) { this.sourceCode = sourceCode; textWithSource = new StringWithLocation(sourceCode); text = textWithSource.getText(); memo.clear(); ruleInvocationStack = null; maxPosition = 0; }
java
private void initialize(SourceCode sourceCode) { this.sourceCode = sourceCode; textWithSource = new StringWithLocation(sourceCode); text = textWithSource.getText(); memo.clear(); ruleInvocationStack = null; maxPosition = 0; }
[ "private", "void", "initialize", "(", "SourceCode", "sourceCode", ")", "{", "this", ".", "sourceCode", "=", "sourceCode", ";", "textWithSource", "=", "new", "StringWithLocation", "(", "sourceCode", ")", ";", "text", "=", "textWithSource", ".", "getText", "(", ")", ";", "memo", ".", "clear", "(", ")", ";", "ruleInvocationStack", "=", "null", ";", "maxPosition", "=", "0", ";", "}" ]
This method resets the whole parser and sets the new values for text and name to start the parsing process afterwards. @param text @param name
[ "This", "method", "resets", "the", "whole", "parser", "and", "sets", "the", "new", "values", "for", "text", "and", "name", "to", "start", "the", "parsing", "process", "afterwards", "." ]
61077223b90d3768ff9445ae13036343c98b63cd
https://github.com/PureSolTechnologies/parsers/blob/61077223b90d3768ff9445ae13036343c98b63cd/parsers/src/main/java/com/puresoltechnologies/parsers/parser/packrat/PackratParser.java#L161-L169
155,538
PureSolTechnologies/parsers
parsers/src/main/java/com/puresoltechnologies/parsers/parser/packrat/PackratParser.java
PackratParser.parse
public ParseTreeNode parse(SourceCode sourceCode, String production) throws ParserException { try { initialize(sourceCode); MemoEntry progress = applyRule(production, 0, 1); if (progress.getDeltaPosition() != text.length()) { throw new ParserException(getParserErrorMessage()); } Object answer = progress.getAnswer(); if (answer instanceof Status) { Status status = (Status) answer; switch (status) { case FAILED: throw new ParserException("Parser returned status 'FAILED'."); default: throw new RuntimeException("A status '" + status.toString() + "' is not expected here."); } } ParseTreeNode parserTree = (ParseTreeNode) answer; normalizeParents(parserTree); return parserTree; } catch (TreeException e) { throw new ParserException(e); } }
java
public ParseTreeNode parse(SourceCode sourceCode, String production) throws ParserException { try { initialize(sourceCode); MemoEntry progress = applyRule(production, 0, 1); if (progress.getDeltaPosition() != text.length()) { throw new ParserException(getParserErrorMessage()); } Object answer = progress.getAnswer(); if (answer instanceof Status) { Status status = (Status) answer; switch (status) { case FAILED: throw new ParserException("Parser returned status 'FAILED'."); default: throw new RuntimeException("A status '" + status.toString() + "' is not expected here."); } } ParseTreeNode parserTree = (ParseTreeNode) answer; normalizeParents(parserTree); return parserTree; } catch (TreeException e) { throw new ParserException(e); } }
[ "public", "ParseTreeNode", "parse", "(", "SourceCode", "sourceCode", ",", "String", "production", ")", "throws", "ParserException", "{", "try", "{", "initialize", "(", "sourceCode", ")", ";", "MemoEntry", "progress", "=", "applyRule", "(", "production", ",", "0", ",", "1", ")", ";", "if", "(", "progress", ".", "getDeltaPosition", "(", ")", "!=", "text", ".", "length", "(", ")", ")", "{", "throw", "new", "ParserException", "(", "getParserErrorMessage", "(", ")", ")", ";", "}", "Object", "answer", "=", "progress", ".", "getAnswer", "(", ")", ";", "if", "(", "answer", "instanceof", "Status", ")", "{", "Status", "status", "=", "(", "Status", ")", "answer", ";", "switch", "(", "status", ")", "{", "case", "FAILED", ":", "throw", "new", "ParserException", "(", "\"Parser returned status 'FAILED'.\"", ")", ";", "default", ":", "throw", "new", "RuntimeException", "(", "\"A status '\"", "+", "status", ".", "toString", "(", ")", "+", "\"' is not expected here.\"", ")", ";", "}", "}", "ParseTreeNode", "parserTree", "=", "(", "ParseTreeNode", ")", "answer", ";", "normalizeParents", "(", "parserTree", ")", ";", "return", "parserTree", ";", "}", "catch", "(", "TreeException", "e", ")", "{", "throw", "new", "ParserException", "(", "e", ")", ";", "}", "}" ]
This is the actual parser start. After running the parse, a check is applied to check for full parsing or partial parsing. If partial parsing is found, an exception is thrown. @param sourceCode is the source code to be parser. @param production is the name of the production to be used as root production for the parse process. @return A {@link ParseTreeNode} is returned with the parser result. @throws ParserException is thrown in case the parser could not parse the source.
[ "This", "is", "the", "actual", "parser", "start", ".", "After", "running", "the", "parse", "a", "check", "is", "applied", "to", "check", "for", "full", "parsing", "or", "partial", "parsing", ".", "If", "partial", "parsing", "is", "found", "an", "exception", "is", "thrown", "." ]
61077223b90d3768ff9445ae13036343c98b63cd
https://github.com/PureSolTechnologies/parsers/blob/61077223b90d3768ff9445ae13036343c98b63cd/parsers/src/main/java/com/puresoltechnologies/parsers/parser/packrat/PackratParser.java#L185-L209
155,539
PureSolTechnologies/parsers
parsers/src/main/java/com/puresoltechnologies/parsers/parser/packrat/PackratParser.java
PackratParser.getParserErrorMessage
private String getParserErrorMessage() { StringBuffer code = new StringBuffer(text); code = code.insert(maxPosition, " >><< "); String codeString = code.substring(maxPosition - 100 < 0 ? 0 : maxPosition - 100, maxPosition + 100 >= code.length() ? code.length() : maxPosition + 100); return "Could not parse the input string near '" + codeString + "'!"; }
java
private String getParserErrorMessage() { StringBuffer code = new StringBuffer(text); code = code.insert(maxPosition, " >><< "); String codeString = code.substring(maxPosition - 100 < 0 ? 0 : maxPosition - 100, maxPosition + 100 >= code.length() ? code.length() : maxPosition + 100); return "Could not parse the input string near '" + codeString + "'!"; }
[ "private", "String", "getParserErrorMessage", "(", ")", "{", "StringBuffer", "code", "=", "new", "StringBuffer", "(", "text", ")", ";", "code", "=", "code", ".", "insert", "(", "maxPosition", ",", "\" >><< \"", ")", ";", "String", "codeString", "=", "code", ".", "substring", "(", "maxPosition", "-", "100", "<", "0", "?", "0", ":", "maxPosition", "-", "100", ",", "maxPosition", "+", "100", ">=", "code", ".", "length", "(", ")", "?", "code", ".", "length", "(", ")", ":", "maxPosition", "+", "100", ")", ";", "return", "\"Could not parse the input string near '\"", "+", "codeString", "+", "\"'!\"", ";", "}" ]
This message just generates a parser exception message to be returned containing the maximum position where the parser could not proceed. This should be in most cases the position where the error within the text is located. @return
[ "This", "message", "just", "generates", "a", "parser", "exception", "message", "to", "be", "returned", "containing", "the", "maximum", "position", "where", "the", "parser", "could", "not", "proceed", ".", "This", "should", "be", "in", "most", "cases", "the", "position", "where", "the", "error", "within", "the", "text", "is", "located", "." ]
61077223b90d3768ff9445ae13036343c98b63cd
https://github.com/PureSolTechnologies/parsers/blob/61077223b90d3768ff9445ae13036343c98b63cd/parsers/src/main/java/com/puresoltechnologies/parsers/parser/packrat/PackratParser.java#L219-L225
155,540
PureSolTechnologies/parsers
parsers/src/main/java/com/puresoltechnologies/parsers/parser/packrat/PackratParser.java
PackratParser.applyRule
private MemoEntry applyRule(String rule, int position, int line) throws TreeException, ParserException { printMessage("applyRule: " + rule, position, line); MemoEntry m = recall(rule, position, line); if (m == null) { /* * "Create a new LR and push it onto the rule invocation stack." * * At this point we found a rule which was never processed at this position. We * start completely virgin here... */ LR lr = new LR(MemoEntry.failed(), rule, null); ruleInvocationStack = new RuleInvocation(MemoEntry.failed(), rule, null, ruleInvocationStack); /* * "Memoize lr, then evaluate R." * * Put a fail into memoization memory and evaluate the rule afterwards. */ m = MemoEntry.create(lr); memo.setMemo(rule, position, line, m); final MemoEntry ans = eval(rule, position, line); /* * "Pop lr off the rule invocation stack." * * The evaluation of this lr is finished now and we can remove it from stack. * This was needed in cases a left recursion whould be found within the rule. */ ruleInvocationStack = ruleInvocationStack.getNext(); if ((m.getAnswer() instanceof LR) && (((LR) m.getAnswer()).getHead() != null)) { /* * If a head was added to lr, we found a recursion during evaluation. We need to * set the seed and process with left recursion evaluation. For that purpose we * grow m with ans as seed. */ lr = (LR) m.getAnswer(); lr.setSeed(ans); MemoEntry lrAnswer = lrAnswer(rule, position, line, m); printMessage("grow LR for '" + rule + "' (" + lrAnswer + ").", position, line); return lrAnswer; } else { /* * We finished an evaluation and did not find a recursion. So the result * (independent of the the state) is stored in memo and returned. */ m.set(ans); printMessage("applied '" + rule + "' (" + ans.getAnswer() + ").", position, line); return ans; } } else { /* * We were here already and with the same production. We either have a real * answer or we found a recursion with or without currently seed growing... */ if ((m.getAnswer() instanceof LR)) { /* * There is still a LR object in the memo, so we found a recursion or an * in-progress seed grow. We setup the LR seed grow and return the current seed. */ setupLR(rule, (LR) m.getAnswer()); MemoEntry seed = ((LR) m.getAnswer()).getSeed(); printMessage("Found recursion or grow in process for '" + rule + "' (" + seed + ").", position, line); return seed; } else { /* * We were already here and we have a real result. So we can just return the * answer. */ printMessage("already processed '" + rule + "' (" + m + ").", position, line); return m; } } }
java
private MemoEntry applyRule(String rule, int position, int line) throws TreeException, ParserException { printMessage("applyRule: " + rule, position, line); MemoEntry m = recall(rule, position, line); if (m == null) { /* * "Create a new LR and push it onto the rule invocation stack." * * At this point we found a rule which was never processed at this position. We * start completely virgin here... */ LR lr = new LR(MemoEntry.failed(), rule, null); ruleInvocationStack = new RuleInvocation(MemoEntry.failed(), rule, null, ruleInvocationStack); /* * "Memoize lr, then evaluate R." * * Put a fail into memoization memory and evaluate the rule afterwards. */ m = MemoEntry.create(lr); memo.setMemo(rule, position, line, m); final MemoEntry ans = eval(rule, position, line); /* * "Pop lr off the rule invocation stack." * * The evaluation of this lr is finished now and we can remove it from stack. * This was needed in cases a left recursion whould be found within the rule. */ ruleInvocationStack = ruleInvocationStack.getNext(); if ((m.getAnswer() instanceof LR) && (((LR) m.getAnswer()).getHead() != null)) { /* * If a head was added to lr, we found a recursion during evaluation. We need to * set the seed and process with left recursion evaluation. For that purpose we * grow m with ans as seed. */ lr = (LR) m.getAnswer(); lr.setSeed(ans); MemoEntry lrAnswer = lrAnswer(rule, position, line, m); printMessage("grow LR for '" + rule + "' (" + lrAnswer + ").", position, line); return lrAnswer; } else { /* * We finished an evaluation and did not find a recursion. So the result * (independent of the the state) is stored in memo and returned. */ m.set(ans); printMessage("applied '" + rule + "' (" + ans.getAnswer() + ").", position, line); return ans; } } else { /* * We were here already and with the same production. We either have a real * answer or we found a recursion with or without currently seed growing... */ if ((m.getAnswer() instanceof LR)) { /* * There is still a LR object in the memo, so we found a recursion or an * in-progress seed grow. We setup the LR seed grow and return the current seed. */ setupLR(rule, (LR) m.getAnswer()); MemoEntry seed = ((LR) m.getAnswer()).getSeed(); printMessage("Found recursion or grow in process for '" + rule + "' (" + seed + ").", position, line); return seed; } else { /* * We were already here and we have a real result. So we can just return the * answer. */ printMessage("already processed '" + rule + "' (" + m + ").", position, line); return m; } } }
[ "private", "MemoEntry", "applyRule", "(", "String", "rule", ",", "int", "position", ",", "int", "line", ")", "throws", "TreeException", ",", "ParserException", "{", "printMessage", "(", "\"applyRule: \"", "+", "rule", ",", "position", ",", "line", ")", ";", "MemoEntry", "m", "=", "recall", "(", "rule", ",", "position", ",", "line", ")", ";", "if", "(", "m", "==", "null", ")", "{", "/*\n\t * \"Create a new LR and push it onto the rule invocation stack.\"\n\t * \n\t * At this point we found a rule which was never processed at this position. We\n\t * start completely virgin here...\n\t */", "LR", "lr", "=", "new", "LR", "(", "MemoEntry", ".", "failed", "(", ")", ",", "rule", ",", "null", ")", ";", "ruleInvocationStack", "=", "new", "RuleInvocation", "(", "MemoEntry", ".", "failed", "(", ")", ",", "rule", ",", "null", ",", "ruleInvocationStack", ")", ";", "/*\n\t * \"Memoize lr, then evaluate R.\"\n\t * \n\t * Put a fail into memoization memory and evaluate the rule afterwards.\n\t */", "m", "=", "MemoEntry", ".", "create", "(", "lr", ")", ";", "memo", ".", "setMemo", "(", "rule", ",", "position", ",", "line", ",", "m", ")", ";", "final", "MemoEntry", "ans", "=", "eval", "(", "rule", ",", "position", ",", "line", ")", ";", "/*\n\t * \"Pop lr off the rule invocation stack.\"\n\t * \n\t * The evaluation of this lr is finished now and we can remove it from stack.\n\t * This was needed in cases a left recursion whould be found within the rule.\n\t */", "ruleInvocationStack", "=", "ruleInvocationStack", ".", "getNext", "(", ")", ";", "if", "(", "(", "m", ".", "getAnswer", "(", ")", "instanceof", "LR", ")", "&&", "(", "(", "(", "LR", ")", "m", ".", "getAnswer", "(", ")", ")", ".", "getHead", "(", ")", "!=", "null", ")", ")", "{", "/*\n\t\t * If a head was added to lr, we found a recursion during evaluation. We need to\n\t\t * set the seed and process with left recursion evaluation. For that purpose we\n\t\t * grow m with ans as seed.\n\t\t */", "lr", "=", "(", "LR", ")", "m", ".", "getAnswer", "(", ")", ";", "lr", ".", "setSeed", "(", "ans", ")", ";", "MemoEntry", "lrAnswer", "=", "lrAnswer", "(", "rule", ",", "position", ",", "line", ",", "m", ")", ";", "printMessage", "(", "\"grow LR for '\"", "+", "rule", "+", "\"' (\"", "+", "lrAnswer", "+", "\").\"", ",", "position", ",", "line", ")", ";", "return", "lrAnswer", ";", "}", "else", "{", "/*\n\t\t * We finished an evaluation and did not find a recursion. So the result\n\t\t * (independent of the the state) is stored in memo and returned.\n\t\t */", "m", ".", "set", "(", "ans", ")", ";", "printMessage", "(", "\"applied '\"", "+", "rule", "+", "\"' (\"", "+", "ans", ".", "getAnswer", "(", ")", "+", "\").\"", ",", "position", ",", "line", ")", ";", "return", "ans", ";", "}", "}", "else", "{", "/*\n\t * We were here already and with the same production. We either have a real\n\t * answer or we found a recursion with or without currently seed growing...\n\t */", "if", "(", "(", "m", ".", "getAnswer", "(", ")", "instanceof", "LR", ")", ")", "{", "/*\n\t\t * There is still a LR object in the memo, so we found a recursion or an\n\t\t * in-progress seed grow. We setup the LR seed grow and return the current seed.\n\t\t */", "setupLR", "(", "rule", ",", "(", "LR", ")", "m", ".", "getAnswer", "(", ")", ")", ";", "MemoEntry", "seed", "=", "(", "(", "LR", ")", "m", ".", "getAnswer", "(", ")", ")", ".", "getSeed", "(", ")", ";", "printMessage", "(", "\"Found recursion or grow in process for '\"", "+", "rule", "+", "\"' (\"", "+", "seed", "+", "\").\"", ",", "position", ",", "line", ")", ";", "return", "seed", ";", "}", "else", "{", "/*\n\t\t * We were already here and we have a real result. So we can just return the\n\t\t * answer.\n\t\t */", "printMessage", "(", "\"already processed '\"", "+", "rule", "+", "\"' (\"", "+", "m", "+", "\").\"", ",", "position", ",", "line", ")", ";", "return", "m", ";", "}", "}", "}" ]
This method tries to apply a production at a given position. The production is given as a name and not as a concrete rule to process all choices afterwards. @param rule @param position @return @throws TreeException @throws ParserException
[ "This", "method", "tries", "to", "apply", "a", "production", "at", "a", "given", "position", ".", "The", "production", "is", "given", "as", "a", "name", "and", "not", "as", "a", "concrete", "rule", "to", "process", "all", "choices", "afterwards", "." ]
61077223b90d3768ff9445ae13036343c98b63cd
https://github.com/PureSolTechnologies/parsers/blob/61077223b90d3768ff9445ae13036343c98b63cd/parsers/src/main/java/com/puresoltechnologies/parsers/parser/packrat/PackratParser.java#L260-L331
155,541
PureSolTechnologies/parsers
parsers/src/main/java/com/puresoltechnologies/parsers/parser/packrat/PackratParser.java
PackratParser.setupLR
private void setupLR(String production, final LR l) throws ParserException { /* * If the lr object does not contain a head, we found a new recursion * production. Otherwise we already know the production, but we found another * production which is involved in the recursion. */ if (l.getHead() == null) l.setHead(new Head(production)); /* * Go over all heads and...!? */ RuleInvocation s = ruleInvocationStack; while (!l.getHead().getProduction().equals(s.getProduction())) { s.setHead(l.getHead()); l.getHead().addInvolved(s.getProduction()); s = s.getNext(); if (s == null) throw new RuntimeException("We should find the head again, when we search the stack.\n" + "We found a recursion and the rule should be there again."); } }
java
private void setupLR(String production, final LR l) throws ParserException { /* * If the lr object does not contain a head, we found a new recursion * production. Otherwise we already know the production, but we found another * production which is involved in the recursion. */ if (l.getHead() == null) l.setHead(new Head(production)); /* * Go over all heads and...!? */ RuleInvocation s = ruleInvocationStack; while (!l.getHead().getProduction().equals(s.getProduction())) { s.setHead(l.getHead()); l.getHead().addInvolved(s.getProduction()); s = s.getNext(); if (s == null) throw new RuntimeException("We should find the head again, when we search the stack.\n" + "We found a recursion and the rule should be there again."); } }
[ "private", "void", "setupLR", "(", "String", "production", ",", "final", "LR", "l", ")", "throws", "ParserException", "{", "/*\n\t * If the lr object does not contain a head, we found a new recursion\n\t * production. Otherwise we already know the production, but we found another\n\t * production which is involved in the recursion.\n\t */", "if", "(", "l", ".", "getHead", "(", ")", "==", "null", ")", "l", ".", "setHead", "(", "new", "Head", "(", "production", ")", ")", ";", "/*\n\t * Go over all heads and...!?\n\t */", "RuleInvocation", "s", "=", "ruleInvocationStack", ";", "while", "(", "!", "l", ".", "getHead", "(", ")", ".", "getProduction", "(", ")", ".", "equals", "(", "s", ".", "getProduction", "(", ")", ")", ")", "{", "s", ".", "setHead", "(", "l", ".", "getHead", "(", ")", ")", ";", "l", ".", "getHead", "(", ")", ".", "addInvolved", "(", "s", ".", "getProduction", "(", ")", ")", ";", "s", "=", "s", ".", "getNext", "(", ")", ";", "if", "(", "s", "==", "null", ")", "throw", "new", "RuntimeException", "(", "\"We should find the head again, when we search the stack.\\n\"", "+", "\"We found a recursion and the rule should be there again.\"", ")", ";", "}", "}" ]
After finding a recursion or a seed grow in process, this method puts all information in place for seed grow. This might be the start information for the growth or the current result in the growing, which means the current result. @param production @param l @throws ParserException
[ "After", "finding", "a", "recursion", "or", "a", "seed", "grow", "in", "process", "this", "method", "puts", "all", "information", "in", "place", "for", "seed", "grow", ".", "This", "might", "be", "the", "start", "information", "for", "the", "growth", "or", "the", "current", "result", "in", "the", "growing", "which", "means", "the", "current", "result", "." ]
61077223b90d3768ff9445ae13036343c98b63cd
https://github.com/PureSolTechnologies/parsers/blob/61077223b90d3768ff9445ae13036343c98b63cd/parsers/src/main/java/com/puresoltechnologies/parsers/parser/packrat/PackratParser.java#L343-L363
155,542
PureSolTechnologies/parsers
parsers/src/main/java/com/puresoltechnologies/parsers/parser/packrat/PackratParser.java
PackratParser.recall
private MemoEntry recall(String production, int position, int line) throws TreeException, ParserException { /* * Retrieve the current memoized item for the production and the head on the * current position. */ final MemoEntry m = memo.getMemo(production, position); final Head h = heads.get(position); /* * "If not growing a seed parse, just return what is stored in the memo table." */ if (h == null) { return m; } /* * "Do not evaluate any rule that is not involved in this left recursion." * * If we have never been at this position (NONE) and the head rule (production) * is not the current production and the involved rules in the heads also do not * fit, then we are on a wrong pass here. We need to return a failure. */ if ((m == null) && (!h.getProduction().equals(production)) && (!h.getInvolvedSet().contains(production))) { return MemoEntry.failed(); } /* * "Allow involved rules to be evaluated, but only once, during a seed-growing * iteration." * * If we have been here already, we check the eval set for the containing rule * and evaluate it necessary. If the rule is within the eval set, we need to * parse it once. */ if (h.getEvalSet().contains(production)) { h.getEvalSet().remove(production); final MemoEntry ans = eval(production, position, line); m.set(ans); } return m; }
java
private MemoEntry recall(String production, int position, int line) throws TreeException, ParserException { /* * Retrieve the current memoized item for the production and the head on the * current position. */ final MemoEntry m = memo.getMemo(production, position); final Head h = heads.get(position); /* * "If not growing a seed parse, just return what is stored in the memo table." */ if (h == null) { return m; } /* * "Do not evaluate any rule that is not involved in this left recursion." * * If we have never been at this position (NONE) and the head rule (production) * is not the current production and the involved rules in the heads also do not * fit, then we are on a wrong pass here. We need to return a failure. */ if ((m == null) && (!h.getProduction().equals(production)) && (!h.getInvolvedSet().contains(production))) { return MemoEntry.failed(); } /* * "Allow involved rules to be evaluated, but only once, during a seed-growing * iteration." * * If we have been here already, we check the eval set for the containing rule * and evaluate it necessary. If the rule is within the eval set, we need to * parse it once. */ if (h.getEvalSet().contains(production)) { h.getEvalSet().remove(production); final MemoEntry ans = eval(production, position, line); m.set(ans); } return m; }
[ "private", "MemoEntry", "recall", "(", "String", "production", ",", "int", "position", ",", "int", "line", ")", "throws", "TreeException", ",", "ParserException", "{", "/*\n\t * Retrieve the current memoized item for the production and the head on the\n\t * current position.\n\t */", "final", "MemoEntry", "m", "=", "memo", ".", "getMemo", "(", "production", ",", "position", ")", ";", "final", "Head", "h", "=", "heads", ".", "get", "(", "position", ")", ";", "/*\n\t * \"If not growing a seed parse, just return what is stored in the memo table.\"\n\t */", "if", "(", "h", "==", "null", ")", "{", "return", "m", ";", "}", "/*\n\t * \"Do not evaluate any rule that is not involved in this left recursion.\"\n\t * \n\t * If we have never been at this position (NONE) and the head rule (production)\n\t * is not the current production and the involved rules in the heads also do not\n\t * fit, then we are on a wrong pass here. We need to return a failure.\n\t */", "if", "(", "(", "m", "==", "null", ")", "&&", "(", "!", "h", ".", "getProduction", "(", ")", ".", "equals", "(", "production", ")", ")", "&&", "(", "!", "h", ".", "getInvolvedSet", "(", ")", ".", "contains", "(", "production", ")", ")", ")", "{", "return", "MemoEntry", ".", "failed", "(", ")", ";", "}", "/*\n\t * \"Allow involved rules to be evaluated, but only once, during a seed-growing\n\t * iteration.\"\n\t * \n\t * If we have been here already, we check the eval set for the containing rule\n\t * and evaluate it necessary. If the rule is within the eval set, we need to\n\t * parse it once.\n\t */", "if", "(", "h", ".", "getEvalSet", "(", ")", ".", "contains", "(", "production", ")", ")", "{", "h", ".", "getEvalSet", "(", ")", ".", "remove", "(", "production", ")", ";", "final", "MemoEntry", "ans", "=", "eval", "(", "production", ",", "position", ",", "line", ")", ";", "m", ".", "set", "(", "ans", ")", ";", "}", "return", "m", ";", "}" ]
This method is an extended getMemo function which also takes into account the seed growing processes which might be underway. @param production is the currently processes production. @param position is the current parser position. @return A new memo entry is returned containing the result of the memoization buffer and seed growing status lookup. @throws TreeException @throws ParserException
[ "This", "method", "is", "an", "extended", "getMemo", "function", "which", "also", "takes", "into", "account", "the", "seed", "growing", "processes", "which", "might", "be", "underway", "." ]
61077223b90d3768ff9445ae13036343c98b63cd
https://github.com/PureSolTechnologies/parsers/blob/61077223b90d3768ff9445ae13036343c98b63cd/parsers/src/main/java/com/puresoltechnologies/parsers/parser/packrat/PackratParser.java#L378-L415
155,543
PureSolTechnologies/parsers
parsers/src/main/java/com/puresoltechnologies/parsers/parser/packrat/PackratParser.java
PackratParser.eval
private MemoEntry eval(String productionName, int position, int line) throws ParserException, TreeException { MemoEntry maxProgress = MemoEntry.failed(); for (Production production : grammar.getProductions().get(productionName)) { MemoEntry progress = parseProduction(production, position, line); if (progress.getAnswer() instanceof ParseTreeNode) { if ((maxProgress.getAnswer() == Status.FAILED) || (maxProgress.getDeltaPosition() < progress.getDeltaPosition())) { maxProgress = progress; } } } return maxProgress; }
java
private MemoEntry eval(String productionName, int position, int line) throws ParserException, TreeException { MemoEntry maxProgress = MemoEntry.failed(); for (Production production : grammar.getProductions().get(productionName)) { MemoEntry progress = parseProduction(production, position, line); if (progress.getAnswer() instanceof ParseTreeNode) { if ((maxProgress.getAnswer() == Status.FAILED) || (maxProgress.getDeltaPosition() < progress.getDeltaPosition())) { maxProgress = progress; } } } return maxProgress; }
[ "private", "MemoEntry", "eval", "(", "String", "productionName", ",", "int", "position", ",", "int", "line", ")", "throws", "ParserException", ",", "TreeException", "{", "MemoEntry", "maxProgress", "=", "MemoEntry", ".", "failed", "(", ")", ";", "for", "(", "Production", "production", ":", "grammar", ".", "getProductions", "(", ")", ".", "get", "(", "productionName", ")", ")", "{", "MemoEntry", "progress", "=", "parseProduction", "(", "production", ",", "position", ",", "line", ")", ";", "if", "(", "progress", ".", "getAnswer", "(", ")", "instanceof", "ParseTreeNode", ")", "{", "if", "(", "(", "maxProgress", ".", "getAnswer", "(", ")", "==", "Status", ".", "FAILED", ")", "||", "(", "maxProgress", ".", "getDeltaPosition", "(", ")", "<", "progress", ".", "getDeltaPosition", "(", ")", ")", ")", "{", "maxProgress", "=", "progress", ";", "}", "}", "}", "return", "maxProgress", ";", "}" ]
This method evaluates the production given by it's name. The different choices are tried from the first to the last. The first choice matching is returned. <b><i>Attention:</i></b> There was a test to introduce a parse where the alternative with the largest progress is returned. <b>This does not work!</b> During the parsing of a succeeding alternative a lot of states are changed on the way. By trying another alternative, the parser gets confused by some inconsistent information. @param productionName is the name of the production to be evaluated. @param position is the position within the stream to evaluate the production at. @return A MemoEntry object is returned containing the result. @throws ParserException @throws TreeException
[ "This", "method", "evaluates", "the", "production", "given", "by", "it", "s", "name", ".", "The", "different", "choices", "are", "tried", "from", "the", "first", "to", "the", "last", ".", "The", "first", "choice", "matching", "is", "returned", "." ]
61077223b90d3768ff9445ae13036343c98b63cd
https://github.com/PureSolTechnologies/parsers/blob/61077223b90d3768ff9445ae13036343c98b63cd/parsers/src/main/java/com/puresoltechnologies/parsers/parser/packrat/PackratParser.java#L483-L495
155,544
PureSolTechnologies/parsers
parsers/src/main/java/com/puresoltechnologies/parsers/parser/packrat/PackratParser.java
PackratParser.parseProduction
private MemoEntry parseProduction(Production production, int position, int line) throws TreeException, ParserException { ParseTreeNode node = new ParseTreeNode(production); MemoEntry progress = MemoEntry.success(0, 0, node); for (Construction construction : production.getConstructions()) { processIgnoredLeadingTokens(node, position, line, progress); if (construction.isNonTerminal()) { MemoEntry newProgress = applyRule(construction.getName(), position + progress.getDeltaPosition(), line + progress.getDeltaLine()); if (newProgress.getAnswer() instanceof ParseTreeNode) { ParseTreeNode child = (ParseTreeNode) newProgress.getAnswer(); if (child.isNode()) { if (child.isStackingAllowed()) { node.addChild(child); } else { if (node.getName().equals(child.getName())) { node.addChildren(child.getChildren()); } else { node.addChild(child); } } } else { node.addChildren(child.getChildren()); } progress.add(newProgress); } else if (newProgress.getAnswer().equals(Status.FAILED)) return MemoEntry.failed(); } else { MemoEntry newProgress = processTerminal(node, (Terminal) construction, position + progress.getDeltaPosition(), line + progress.getDeltaLine()); if (newProgress.getAnswer() instanceof ParseTreeNode) { progress.add(newProgress); } else { return MemoEntry.failed(); } } processIgnoredTrailingTokens(node, position, line, progress); } if (logger.isTraceEnabled()) { logger.trace("Parsed: " + production); } return progress; }
java
private MemoEntry parseProduction(Production production, int position, int line) throws TreeException, ParserException { ParseTreeNode node = new ParseTreeNode(production); MemoEntry progress = MemoEntry.success(0, 0, node); for (Construction construction : production.getConstructions()) { processIgnoredLeadingTokens(node, position, line, progress); if (construction.isNonTerminal()) { MemoEntry newProgress = applyRule(construction.getName(), position + progress.getDeltaPosition(), line + progress.getDeltaLine()); if (newProgress.getAnswer() instanceof ParseTreeNode) { ParseTreeNode child = (ParseTreeNode) newProgress.getAnswer(); if (child.isNode()) { if (child.isStackingAllowed()) { node.addChild(child); } else { if (node.getName().equals(child.getName())) { node.addChildren(child.getChildren()); } else { node.addChild(child); } } } else { node.addChildren(child.getChildren()); } progress.add(newProgress); } else if (newProgress.getAnswer().equals(Status.FAILED)) return MemoEntry.failed(); } else { MemoEntry newProgress = processTerminal(node, (Terminal) construction, position + progress.getDeltaPosition(), line + progress.getDeltaLine()); if (newProgress.getAnswer() instanceof ParseTreeNode) { progress.add(newProgress); } else { return MemoEntry.failed(); } } processIgnoredTrailingTokens(node, position, line, progress); } if (logger.isTraceEnabled()) { logger.trace("Parsed: " + production); } return progress; }
[ "private", "MemoEntry", "parseProduction", "(", "Production", "production", ",", "int", "position", ",", "int", "line", ")", "throws", "TreeException", ",", "ParserException", "{", "ParseTreeNode", "node", "=", "new", "ParseTreeNode", "(", "production", ")", ";", "MemoEntry", "progress", "=", "MemoEntry", ".", "success", "(", "0", ",", "0", ",", "node", ")", ";", "for", "(", "Construction", "construction", ":", "production", ".", "getConstructions", "(", ")", ")", "{", "processIgnoredLeadingTokens", "(", "node", ",", "position", ",", "line", ",", "progress", ")", ";", "if", "(", "construction", ".", "isNonTerminal", "(", ")", ")", "{", "MemoEntry", "newProgress", "=", "applyRule", "(", "construction", ".", "getName", "(", ")", ",", "position", "+", "progress", ".", "getDeltaPosition", "(", ")", ",", "line", "+", "progress", ".", "getDeltaLine", "(", ")", ")", ";", "if", "(", "newProgress", ".", "getAnswer", "(", ")", "instanceof", "ParseTreeNode", ")", "{", "ParseTreeNode", "child", "=", "(", "ParseTreeNode", ")", "newProgress", ".", "getAnswer", "(", ")", ";", "if", "(", "child", ".", "isNode", "(", ")", ")", "{", "if", "(", "child", ".", "isStackingAllowed", "(", ")", ")", "{", "node", ".", "addChild", "(", "child", ")", ";", "}", "else", "{", "if", "(", "node", ".", "getName", "(", ")", ".", "equals", "(", "child", ".", "getName", "(", ")", ")", ")", "{", "node", ".", "addChildren", "(", "child", ".", "getChildren", "(", ")", ")", ";", "}", "else", "{", "node", ".", "addChild", "(", "child", ")", ";", "}", "}", "}", "else", "{", "node", ".", "addChildren", "(", "child", ".", "getChildren", "(", ")", ")", ";", "}", "progress", ".", "add", "(", "newProgress", ")", ";", "}", "else", "if", "(", "newProgress", ".", "getAnswer", "(", ")", ".", "equals", "(", "Status", ".", "FAILED", ")", ")", "return", "MemoEntry", ".", "failed", "(", ")", ";", "}", "else", "{", "MemoEntry", "newProgress", "=", "processTerminal", "(", "node", ",", "(", "Terminal", ")", "construction", ",", "position", "+", "progress", ".", "getDeltaPosition", "(", ")", ",", "line", "+", "progress", ".", "getDeltaLine", "(", ")", ")", ";", "if", "(", "newProgress", ".", "getAnswer", "(", ")", "instanceof", "ParseTreeNode", ")", "{", "progress", ".", "add", "(", "newProgress", ")", ";", "}", "else", "{", "return", "MemoEntry", ".", "failed", "(", ")", ";", "}", "}", "processIgnoredTrailingTokens", "(", "node", ",", "position", ",", "line", ",", "progress", ")", ";", "}", "if", "(", "logger", ".", "isTraceEnabled", "(", ")", ")", "{", "logger", ".", "trace", "(", "\"Parsed: \"", "+", "production", ")", ";", "}", "return", "progress", ";", "}" ]
This method performs the actual parsing by reading the production and applying token definitions and starting other non terminal parsings. @param production is the production to be applied. @param position is the position within the stream to evaluate the production at. @return A MemoEntry object is returned containing the result. @throws TreeException @throws ParserException
[ "This", "method", "performs", "the", "actual", "parsing", "by", "reading", "the", "production", "and", "applying", "token", "definitions", "and", "starting", "other", "non", "terminal", "parsings", "." ]
61077223b90d3768ff9445ae13036343c98b63cd
https://github.com/PureSolTechnologies/parsers/blob/61077223b90d3768ff9445ae13036343c98b63cd/parsers/src/main/java/com/puresoltechnologies/parsers/parser/packrat/PackratParser.java#L509-L551
155,545
PureSolTechnologies/parsers
parsers/src/main/java/com/puresoltechnologies/parsers/parser/packrat/PackratParser.java
PackratParser.processIgnoredLeadingTokens
private void processIgnoredLeadingTokens(ParseTreeNode node, int position, int line, MemoEntry progress) throws TreeException, ParserException { if (ignoredLeading) { processIgnoredTokens(node, position, line, progress); } }
java
private void processIgnoredLeadingTokens(ParseTreeNode node, int position, int line, MemoEntry progress) throws TreeException, ParserException { if (ignoredLeading) { processIgnoredTokens(node, position, line, progress); } }
[ "private", "void", "processIgnoredLeadingTokens", "(", "ParseTreeNode", "node", ",", "int", "position", ",", "int", "line", ",", "MemoEntry", "progress", ")", "throws", "TreeException", ",", "ParserException", "{", "if", "(", "ignoredLeading", ")", "{", "processIgnoredTokens", "(", "node", ",", "position", ",", "line", ",", "progress", ")", ";", "}", "}" ]
This method processes leading tokens which are either hidden or ignored. The processing only happens if the configuration allows it. @param node @param position @param id @param line @param progress @throws TreeException @throws ParserException
[ "This", "method", "processes", "leading", "tokens", "which", "are", "either", "hidden", "or", "ignored", ".", "The", "processing", "only", "happens", "if", "the", "configuration", "allows", "it", "." ]
61077223b90d3768ff9445ae13036343c98b63cd
https://github.com/PureSolTechnologies/parsers/blob/61077223b90d3768ff9445ae13036343c98b63cd/parsers/src/main/java/com/puresoltechnologies/parsers/parser/packrat/PackratParser.java#L565-L570
155,546
PureSolTechnologies/parsers
parsers/src/main/java/com/puresoltechnologies/parsers/parser/packrat/PackratParser.java
PackratParser.processTerminal
private MemoEntry processTerminal(ParseTreeNode node, Terminal terminal, int position, int line) throws TreeException { printMessage("applyTerminal: " + terminal, position, line); TokenDefinitionSet tokenDefinitions = grammar.getTokenDefinitions(); TokenDefinition tokenDefinition = tokenDefinitions.getDefinition(terminal.getName()); MemoEntry result = processTokenDefinition(node, tokenDefinition, position, line); if (result == null) { throw new RuntimeException("There should be a result not null!"); } printMessage("applied Terminal '" + terminal + "' (" + result.getAnswer() + ").", position, line); return result; }
java
private MemoEntry processTerminal(ParseTreeNode node, Terminal terminal, int position, int line) throws TreeException { printMessage("applyTerminal: " + terminal, position, line); TokenDefinitionSet tokenDefinitions = grammar.getTokenDefinitions(); TokenDefinition tokenDefinition = tokenDefinitions.getDefinition(terminal.getName()); MemoEntry result = processTokenDefinition(node, tokenDefinition, position, line); if (result == null) { throw new RuntimeException("There should be a result not null!"); } printMessage("applied Terminal '" + terminal + "' (" + result.getAnswer() + ").", position, line); return result; }
[ "private", "MemoEntry", "processTerminal", "(", "ParseTreeNode", "node", ",", "Terminal", "terminal", ",", "int", "position", ",", "int", "line", ")", "throws", "TreeException", "{", "printMessage", "(", "\"applyTerminal: \"", "+", "terminal", ",", "position", ",", "line", ")", ";", "TokenDefinitionSet", "tokenDefinitions", "=", "grammar", ".", "getTokenDefinitions", "(", ")", ";", "TokenDefinition", "tokenDefinition", "=", "tokenDefinitions", ".", "getDefinition", "(", "terminal", ".", "getName", "(", ")", ")", ";", "MemoEntry", "result", "=", "processTokenDefinition", "(", "node", ",", "tokenDefinition", ",", "position", ",", "line", ")", ";", "if", "(", "result", "==", "null", ")", "{", "throw", "new", "RuntimeException", "(", "\"There should be a result not null!\"", ")", ";", "}", "printMessage", "(", "\"applied Terminal '\"", "+", "terminal", "+", "\"' (\"", "+", "result", ".", "getAnswer", "(", ")", "+", "\").\"", ",", "position", ",", "line", ")", ";", "return", "result", ";", "}" ]
This method processes a single terminal. This method uses processTokenDefinition to do this. The information to be put into that method is extracted and prepared here. @param node @param terminal @param position @return @throws TreeException
[ "This", "method", "processes", "a", "single", "terminal", ".", "This", "method", "uses", "processTokenDefinition", "to", "do", "this", ".", "The", "information", "to", "be", "put", "into", "that", "method", "is", "extracted", "and", "prepared", "here", "." ]
61077223b90d3768ff9445ae13036343c98b63cd
https://github.com/PureSolTechnologies/parsers/blob/61077223b90d3768ff9445ae13036343c98b63cd/parsers/src/main/java/com/puresoltechnologies/parsers/parser/packrat/PackratParser.java#L631-L642
155,547
PureSolTechnologies/parsers
parsers/src/main/java/com/puresoltechnologies/parsers/parser/packrat/PackratParser.java
PackratParser.processTokenDefinition
private MemoEntry processTokenDefinition(ParseTreeNode node, TokenDefinition tokenDefinition, int position, int line) throws TreeException { Matcher matcher = tokenDefinition.getPattern().matcher(text.substring(position)); if (!matcher.find()) { return MemoEntry.failed(); } String match = matcher.group(); int lineBreakNum = StringUtils.countLineBreaks(match); SourceCodeLocation source = sourceCode.getLines().get(line - 1).getSource(); int lineNumber = textWithSource.getLineNumber(position); TokenMetaData metaData = new TokenMetaData(source, lineNumber, lineBreakNum + 1, textWithSource.getColumn(position)); Token token = new Token(tokenDefinition.getName(), match, tokenDefinition.getVisibility(), metaData); ParseTreeNode myTree = new ParseTreeNode(token); node.addChild(myTree); if (maxPosition < position + match.length()) { maxPosition = position + match.length(); } return MemoEntry.success(match.length(), lineBreakNum, myTree); }
java
private MemoEntry processTokenDefinition(ParseTreeNode node, TokenDefinition tokenDefinition, int position, int line) throws TreeException { Matcher matcher = tokenDefinition.getPattern().matcher(text.substring(position)); if (!matcher.find()) { return MemoEntry.failed(); } String match = matcher.group(); int lineBreakNum = StringUtils.countLineBreaks(match); SourceCodeLocation source = sourceCode.getLines().get(line - 1).getSource(); int lineNumber = textWithSource.getLineNumber(position); TokenMetaData metaData = new TokenMetaData(source, lineNumber, lineBreakNum + 1, textWithSource.getColumn(position)); Token token = new Token(tokenDefinition.getName(), match, tokenDefinition.getVisibility(), metaData); ParseTreeNode myTree = new ParseTreeNode(token); node.addChild(myTree); if (maxPosition < position + match.length()) { maxPosition = position + match.length(); } return MemoEntry.success(match.length(), lineBreakNum, myTree); }
[ "private", "MemoEntry", "processTokenDefinition", "(", "ParseTreeNode", "node", ",", "TokenDefinition", "tokenDefinition", ",", "int", "position", ",", "int", "line", ")", "throws", "TreeException", "{", "Matcher", "matcher", "=", "tokenDefinition", ".", "getPattern", "(", ")", ".", "matcher", "(", "text", ".", "substring", "(", "position", ")", ")", ";", "if", "(", "!", "matcher", ".", "find", "(", ")", ")", "{", "return", "MemoEntry", ".", "failed", "(", ")", ";", "}", "String", "match", "=", "matcher", ".", "group", "(", ")", ";", "int", "lineBreakNum", "=", "StringUtils", ".", "countLineBreaks", "(", "match", ")", ";", "SourceCodeLocation", "source", "=", "sourceCode", ".", "getLines", "(", ")", ".", "get", "(", "line", "-", "1", ")", ".", "getSource", "(", ")", ";", "int", "lineNumber", "=", "textWithSource", ".", "getLineNumber", "(", "position", ")", ";", "TokenMetaData", "metaData", "=", "new", "TokenMetaData", "(", "source", ",", "lineNumber", ",", "lineBreakNum", "+", "1", ",", "textWithSource", ".", "getColumn", "(", "position", ")", ")", ";", "Token", "token", "=", "new", "Token", "(", "tokenDefinition", ".", "getName", "(", ")", ",", "match", ",", "tokenDefinition", ".", "getVisibility", "(", ")", ",", "metaData", ")", ";", "ParseTreeNode", "myTree", "=", "new", "ParseTreeNode", "(", "token", ")", ";", "node", ".", "addChild", "(", "myTree", ")", ";", "if", "(", "maxPosition", "<", "position", "+", "match", ".", "length", "(", ")", ")", "{", "maxPosition", "=", "position", "+", "match", ".", "length", "(", ")", ";", "}", "return", "MemoEntry", ".", "success", "(", "match", ".", "length", "(", ")", ",", "lineBreakNum", ",", "myTree", ")", ";", "}" ]
This method tries to process a single token definition. If this can be done, true is returned, a new parser tree child is added and all internal states are updated like position, id and line. @param parserTree @param tokenDefinition @return @throws TreeException
[ "This", "method", "tries", "to", "process", "a", "single", "token", "definition", ".", "If", "this", "can", "be", "done", "true", "is", "returned", "a", "new", "parser", "tree", "child", "is", "added", "and", "all", "internal", "states", "are", "updated", "like", "position", "id", "and", "line", "." ]
61077223b90d3768ff9445ae13036343c98b63cd
https://github.com/PureSolTechnologies/parsers/blob/61077223b90d3768ff9445ae13036343c98b63cd/parsers/src/main/java/com/puresoltechnologies/parsers/parser/packrat/PackratParser.java#L689-L708
155,548
aerogear/java-mpns
src/main/java/org/jboss/aerogear/windows/mpns/notifications/AbstractNotificationBuilder.java
AbstractNotificationBuilder.messageId
public A messageId(String messageId) { this.headers.add(Pair.of("X-MessageId", messageId)); return (A)this; }
java
public A messageId(String messageId) { this.headers.add(Pair.of("X-MessageId", messageId)); return (A)this; }
[ "public", "A", "messageId", "(", "String", "messageId", ")", "{", "this", ".", "headers", ".", "add", "(", "Pair", ".", "of", "(", "\"X-MessageId\"", ",", "messageId", ")", ")", ";", "return", "(", "A", ")", "this", ";", "}" ]
Sets the message UUID. The message UUID is optional application-specific identifier for book-keeping and associate it with the response. @param messageId notification message ID @return this
[ "Sets", "the", "message", "UUID", "." ]
d743734578827320eeead7368c50fd2d7b1d14cb
https://github.com/aerogear/java-mpns/blob/d743734578827320eeead7368c50fd2d7b1d14cb/src/main/java/org/jboss/aerogear/windows/mpns/notifications/AbstractNotificationBuilder.java#L67-L70
155,549
aerogear/java-mpns
src/main/java/org/jboss/aerogear/windows/mpns/notifications/AbstractNotificationBuilder.java
AbstractNotificationBuilder.notificationClass
public A notificationClass(DeliveryClass delivery) { this.headers.add(Pair.of("X-NotificationClass", String.valueOf(deliveryValueOf(delivery)))); return (A)this; }
java
public A notificationClass(DeliveryClass delivery) { this.headers.add(Pair.of("X-NotificationClass", String.valueOf(deliveryValueOf(delivery)))); return (A)this; }
[ "public", "A", "notificationClass", "(", "DeliveryClass", "delivery", ")", "{", "this", ".", "headers", ".", "add", "(", "Pair", ".", "of", "(", "\"X-NotificationClass\"", ",", "String", ".", "valueOf", "(", "deliveryValueOf", "(", "delivery", ")", ")", ")", ")", ";", "return", "(", "A", ")", "this", ";", "}" ]
Sets the notification batching interval, indicating when the notification should be delivered to the device @param delivery batching interval @return this
[ "Sets", "the", "notification", "batching", "interval", "indicating", "when", "the", "notification", "should", "be", "delivered", "to", "the", "device" ]
d743734578827320eeead7368c50fd2d7b1d14cb
https://github.com/aerogear/java-mpns/blob/d743734578827320eeead7368c50fd2d7b1d14cb/src/main/java/org/jboss/aerogear/windows/mpns/notifications/AbstractNotificationBuilder.java#L79-L82
155,550
aerogear/java-mpns
src/main/java/org/jboss/aerogear/windows/mpns/notifications/AbstractNotificationBuilder.java
AbstractNotificationBuilder.notificationType
public A notificationType(String type) { this.headers.add(Pair.of("X-WindowsPhone-Target", type)); return (A)this; }
java
public A notificationType(String type) { this.headers.add(Pair.of("X-WindowsPhone-Target", type)); return (A)this; }
[ "public", "A", "notificationType", "(", "String", "type", ")", "{", "this", ".", "headers", ".", "add", "(", "Pair", ".", "of", "(", "\"X-WindowsPhone-Target\"", ",", "type", ")", ")", ";", "return", "(", "A", ")", "this", ";", "}" ]
Sets the type of the push notification being sent. As of Windows Phone OS 7.0, the supported types are: <ul> <li>token (for Tile messages)</li> <li>toast</li> <li>raw</li> </ul> This method should probably not be called directly, as the concrete builder class will set the appropriate notification type. @param type the notification type @return this
[ "Sets", "the", "type", "of", "the", "push", "notification", "being", "sent", "." ]
d743734578827320eeead7368c50fd2d7b1d14cb
https://github.com/aerogear/java-mpns/blob/d743734578827320eeead7368c50fd2d7b1d14cb/src/main/java/org/jboss/aerogear/windows/mpns/notifications/AbstractNotificationBuilder.java#L101-L104
155,551
aerogear/java-mpns
src/main/java/org/jboss/aerogear/windows/mpns/notifications/AbstractNotificationBuilder.java
AbstractNotificationBuilder.callbackUri
public A callbackUri(String callbackUri) { this.headers.add(Pair.of("X-CallbackURI", callbackUri)); return (A)this; }
java
public A callbackUri(String callbackUri) { this.headers.add(Pair.of("X-CallbackURI", callbackUri)); return (A)this; }
[ "public", "A", "callbackUri", "(", "String", "callbackUri", ")", "{", "this", ".", "headers", ".", "add", "(", "Pair", ".", "of", "(", "\"X-CallbackURI\"", ",", "callbackUri", ")", ")", ";", "return", "(", "A", ")", "this", ";", "}" ]
Sets the notification channel URI that the registered callback message will be sent to. When using an authenticated web service, this parameter is required. @param callbackUri the notification channel URI @return this
[ "Sets", "the", "notification", "channel", "URI", "that", "the", "registered", "callback", "message", "will", "be", "sent", "to", "." ]
d743734578827320eeead7368c50fd2d7b1d14cb
https://github.com/aerogear/java-mpns/blob/d743734578827320eeead7368c50fd2d7b1d14cb/src/main/java/org/jboss/aerogear/windows/mpns/notifications/AbstractNotificationBuilder.java#L115-L118
155,552
aerogear/java-mpns
src/main/java/org/jboss/aerogear/windows/mpns/notifications/AbstractNotificationBuilder.java
AbstractNotificationBuilder.contentType
protected A contentType(String contentType) { this.headers.add(Pair.of("Content-Type", contentType)); return (A)this; }
java
protected A contentType(String contentType) { this.headers.add(Pair.of("Content-Type", contentType)); return (A)this; }
[ "protected", "A", "contentType", "(", "String", "contentType", ")", "{", "this", ".", "headers", ".", "add", "(", "Pair", ".", "of", "(", "\"Content-Type\"", ",", "contentType", ")", ")", ";", "return", "(", "A", ")", "this", ";", "}" ]
Sets the notification body content type @param contentType the content type of the body @return this
[ "Sets", "the", "notification", "body", "content", "type" ]
d743734578827320eeead7368c50fd2d7b1d14cb
https://github.com/aerogear/java-mpns/blob/d743734578827320eeead7368c50fd2d7b1d14cb/src/main/java/org/jboss/aerogear/windows/mpns/notifications/AbstractNotificationBuilder.java#L126-L129
155,553
foundation-runtime/service-directory
2.0/sd-core/src/main/java/com/cisco/oss/foundation/directory/utils/ObfuscatUtil.java
ObfuscatUtil.pBKDF2ObfuscatePassword
public static byte[] pBKDF2ObfuscatePassword(String password, byte[] salt) throws NoSuchAlgorithmException, InvalidKeySpecException { String algorithm = "PBKDF2WithHmacSHA1"; int derivedKeyLength = 160; int iterations = 20000; KeySpec spec = new PBEKeySpec(password.toCharArray(), salt, iterations, derivedKeyLength); SecretKeyFactory f = SecretKeyFactory.getInstance(algorithm); return f.generateSecret(spec).getEncoded(); }
java
public static byte[] pBKDF2ObfuscatePassword(String password, byte[] salt) throws NoSuchAlgorithmException, InvalidKeySpecException { String algorithm = "PBKDF2WithHmacSHA1"; int derivedKeyLength = 160; int iterations = 20000; KeySpec spec = new PBEKeySpec(password.toCharArray(), salt, iterations, derivedKeyLength); SecretKeyFactory f = SecretKeyFactory.getInstance(algorithm); return f.generateSecret(spec).getEncoded(); }
[ "public", "static", "byte", "[", "]", "pBKDF2ObfuscatePassword", "(", "String", "password", ",", "byte", "[", "]", "salt", ")", "throws", "NoSuchAlgorithmException", ",", "InvalidKeySpecException", "{", "String", "algorithm", "=", "\"PBKDF2WithHmacSHA1\"", ";", "int", "derivedKeyLength", "=", "160", ";", "int", "iterations", "=", "20000", ";", "KeySpec", "spec", "=", "new", "PBEKeySpec", "(", "password", ".", "toCharArray", "(", ")", ",", "salt", ",", "iterations", ",", "derivedKeyLength", ")", ";", "SecretKeyFactory", "f", "=", "SecretKeyFactory", ".", "getInstance", "(", "algorithm", ")", ";", "return", "f", ".", "generateSecret", "(", "spec", ")", ".", "getEncoded", "(", ")", ";", "}" ]
Encrypt the password in PBKDF2 algorithm. @param password the password to obfuscate. @param salt the randomly sequence of bits of the user. @return the obfuscated password byte array. @throws NoSuchAlgorithmException @throws InvalidKeySpecException
[ "Encrypt", "the", "password", "in", "PBKDF2", "algorithm", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-core/src/main/java/com/cisco/oss/foundation/directory/utils/ObfuscatUtil.java#L47-L57
155,554
foundation-runtime/service-directory
2.0/sd-core/src/main/java/com/cisco/oss/foundation/directory/utils/ObfuscatUtil.java
ObfuscatUtil.computeHash
public static byte[] computeHash(String passwd) throws NoSuchAlgorithmException { java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA-1"); md.reset(); md.update(passwd.getBytes()); return md.digest(); }
java
public static byte[] computeHash(String passwd) throws NoSuchAlgorithmException { java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA-1"); md.reset(); md.update(passwd.getBytes()); return md.digest(); }
[ "public", "static", "byte", "[", "]", "computeHash", "(", "String", "passwd", ")", "throws", "NoSuchAlgorithmException", "{", "java", ".", "security", ".", "MessageDigest", "md", "=", "java", ".", "security", ".", "MessageDigest", ".", "getInstance", "(", "\"SHA-1\"", ")", ";", "md", ".", "reset", "(", ")", ";", "md", ".", "update", "(", "passwd", ".", "getBytes", "(", ")", ")", ";", "return", "md", ".", "digest", "(", ")", ";", "}" ]
Compute the the hash value for the String. @param passwd the password String @return the Hash digest byte. @throws NoSuchAlgorithmException the NoSuchAlgorithmException.
[ "Compute", "the", "the", "hash", "value", "for", "the", "String", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-core/src/main/java/com/cisco/oss/foundation/directory/utils/ObfuscatUtil.java#L69-L74
155,555
foundation-runtime/service-directory
2.0/sd-core/src/main/java/com/cisco/oss/foundation/directory/utils/ObfuscatUtil.java
ObfuscatUtil.generateSalt
public static byte[] generateSalt() throws NoSuchAlgorithmException { SecureRandom random = SecureRandom.getInstance("SHA1PRNG"); byte[] salt = new byte[8]; random.nextBytes(salt); return salt; }
java
public static byte[] generateSalt() throws NoSuchAlgorithmException { SecureRandom random = SecureRandom.getInstance("SHA1PRNG"); byte[] salt = new byte[8]; random.nextBytes(salt); return salt; }
[ "public", "static", "byte", "[", "]", "generateSalt", "(", ")", "throws", "NoSuchAlgorithmException", "{", "SecureRandom", "random", "=", "SecureRandom", ".", "getInstance", "(", "\"SHA1PRNG\"", ")", ";", "byte", "[", "]", "salt", "=", "new", "byte", "[", "8", "]", ";", "random", ".", "nextBytes", "(", "salt", ")", ";", "return", "salt", ";", "}" ]
Generate a random salt. @return the random salt. @throws NoSuchAlgorithmException the NoSuchAlgorithmException.
[ "Generate", "a", "random", "salt", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-core/src/main/java/com/cisco/oss/foundation/directory/utils/ObfuscatUtil.java#L108-L113
155,556
JM-Lab/utils-java8
src/main/java/kr/jm/utils/stats/collector/NumberItemCollector.java
NumberItemCollector.extractCollectingStatsMap
public Map<String, StatsMap> extractCollectingStatsMap( List<Number> dataList) { return JMMap.newChangedValueMap(this, this::buildStatsMap); }
java
public Map<String, StatsMap> extractCollectingStatsMap( List<Number> dataList) { return JMMap.newChangedValueMap(this, this::buildStatsMap); }
[ "public", "Map", "<", "String", ",", "StatsMap", ">", "extractCollectingStatsMap", "(", "List", "<", "Number", ">", "dataList", ")", "{", "return", "JMMap", ".", "newChangedValueMap", "(", "this", ",", "this", "::", "buildStatsMap", ")", ";", "}" ]
Extract collecting stats map map. @param dataList the data list @return the map
[ "Extract", "collecting", "stats", "map", "map", "." ]
9e407b3f28a7990418a1e877229fa8344f4d78a5
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/stats/collector/NumberItemCollector.java#L21-L24
155,557
ksclarke/vertx-pairtree
src/main/java/info/freelibrary/pairtree/s3/S3Client.java
S3Client.list
public void list(final String aBucket, final Handler<HttpClientResponse> aHandler) { createGetRequest(aBucket, "?list-type=2", aHandler).end(); }
java
public void list(final String aBucket, final Handler<HttpClientResponse> aHandler) { createGetRequest(aBucket, "?list-type=2", aHandler).end(); }
[ "public", "void", "list", "(", "final", "String", "aBucket", ",", "final", "Handler", "<", "HttpClientResponse", ">", "aHandler", ")", "{", "createGetRequest", "(", "aBucket", ",", "\"?list-type=2\"", ",", "aHandler", ")", ".", "end", "(", ")", ";", "}" ]
Asynchronous listing of an S3 bucket. @param aBucket A bucket from which to get a listing @param aHandler A response handler
[ "Asynchronous", "listing", "of", "an", "S3", "bucket", "." ]
b2ea1e32057e5df262e9265540d346a732b718df
https://github.com/ksclarke/vertx-pairtree/blob/b2ea1e32057e5df262e9265540d346a732b718df/src/main/java/info/freelibrary/pairtree/s3/S3Client.java#L149-L151
155,558
ksclarke/vertx-pairtree
src/main/java/info/freelibrary/pairtree/s3/S3Client.java
S3Client.put
public void put(final String aBucket, final String aKey, final AsyncFile aFile, final Handler<HttpClientResponse> aHandler) { final S3ClientRequest request = createPutRequest(aBucket, aKey, aHandler); final Buffer buffer = Buffer.buffer(); aFile.endHandler(event -> { request.putHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(buffer.length())); request.end(buffer); }); aFile.handler(data -> { buffer.appendBuffer(data); }); }
java
public void put(final String aBucket, final String aKey, final AsyncFile aFile, final Handler<HttpClientResponse> aHandler) { final S3ClientRequest request = createPutRequest(aBucket, aKey, aHandler); final Buffer buffer = Buffer.buffer(); aFile.endHandler(event -> { request.putHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(buffer.length())); request.end(buffer); }); aFile.handler(data -> { buffer.appendBuffer(data); }); }
[ "public", "void", "put", "(", "final", "String", "aBucket", ",", "final", "String", "aKey", ",", "final", "AsyncFile", "aFile", ",", "final", "Handler", "<", "HttpClientResponse", ">", "aHandler", ")", "{", "final", "S3ClientRequest", "request", "=", "createPutRequest", "(", "aBucket", ",", "aKey", ",", "aHandler", ")", ";", "final", "Buffer", "buffer", "=", "Buffer", ".", "buffer", "(", ")", ";", "aFile", ".", "endHandler", "(", "event", "->", "{", "request", ".", "putHeader", "(", "HttpHeaders", ".", "CONTENT_LENGTH", ",", "String", ".", "valueOf", "(", "buffer", ".", "length", "(", ")", ")", ")", ";", "request", ".", "end", "(", "buffer", ")", ";", "}", ")", ";", "aFile", ".", "handler", "(", "data", "->", "{", "buffer", ".", "appendBuffer", "(", "data", ")", ";", "}", ")", ";", "}" ]
Uploads the file contents to S3. @param aBucket An S3 bucket @param aKey An S3 key @param aFile A file to upload @param aHandler A response handler for the upload
[ "Uploads", "the", "file", "contents", "to", "S3", "." ]
b2ea1e32057e5df262e9265540d346a732b718df
https://github.com/ksclarke/vertx-pairtree/blob/b2ea1e32057e5df262e9265540d346a732b718df/src/main/java/info/freelibrary/pairtree/s3/S3Client.java#L188-L201
155,559
foundation-runtime/service-directory
2.0/sd-core/src/main/java/com/cisco/oss/foundation/directory/exception/ServiceDirectoryError.java
ServiceDirectoryError.getErrorMessage
@JsonIgnore public String getErrorMessage(){ StringBuilder sb = new StringBuilder(); sb.append(exceptionCode.getCode()).append(":").append(exceptionCode.getMessage()); if(this.message != null && ! this.message.isEmpty()){ sb.append(" - ").append(message); } return sb.toString(); }
java
@JsonIgnore public String getErrorMessage(){ StringBuilder sb = new StringBuilder(); sb.append(exceptionCode.getCode()).append(":").append(exceptionCode.getMessage()); if(this.message != null && ! this.message.isEmpty()){ sb.append(" - ").append(message); } return sb.toString(); }
[ "@", "JsonIgnore", "public", "String", "getErrorMessage", "(", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "sb", ".", "append", "(", "exceptionCode", ".", "getCode", "(", ")", ")", ".", "append", "(", "\":\"", ")", ".", "append", "(", "exceptionCode", ".", "getMessage", "(", ")", ")", ";", "if", "(", "this", ".", "message", "!=", "null", "&&", "!", "this", ".", "message", ".", "isEmpty", "(", ")", ")", "{", "sb", ".", "append", "(", "\" - \"", ")", ".", "append", "(", "message", ")", ";", "}", "return", "sb", ".", "toString", "(", ")", ";", "}" ]
Get the locale-specific error message. @return the error message String.
[ "Get", "the", "locale", "-", "specific", "error", "message", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-core/src/main/java/com/cisco/oss/foundation/directory/exception/ServiceDirectoryError.java#L73-L81
155,560
SimiaCryptus/utilities
java-util/src/main/java/com/simiacryptus/util/binary/Bits.java
Bits.divide
public static Bits divide(long numerator, long denominator, long maxBits) { if (maxBits <= 0) return NULL; if (numerator == 0) return ZERO; if (numerator == denominator) return ONE; if (numerator < denominator) { return ZERO.concatenate(divide(numerator * 2, denominator, maxBits - 1)); } else { return ONE.concatenate(divide(2 * (numerator - denominator), denominator, maxBits - 1)); } }
java
public static Bits divide(long numerator, long denominator, long maxBits) { if (maxBits <= 0) return NULL; if (numerator == 0) return ZERO; if (numerator == denominator) return ONE; if (numerator < denominator) { return ZERO.concatenate(divide(numerator * 2, denominator, maxBits - 1)); } else { return ONE.concatenate(divide(2 * (numerator - denominator), denominator, maxBits - 1)); } }
[ "public", "static", "Bits", "divide", "(", "long", "numerator", ",", "long", "denominator", ",", "long", "maxBits", ")", "{", "if", "(", "maxBits", "<=", "0", ")", "return", "NULL", ";", "if", "(", "numerator", "==", "0", ")", "return", "ZERO", ";", "if", "(", "numerator", "==", "denominator", ")", "return", "ONE", ";", "if", "(", "numerator", "<", "denominator", ")", "{", "return", "ZERO", ".", "concatenate", "(", "divide", "(", "numerator", "*", "2", ",", "denominator", ",", "maxBits", "-", "1", ")", ")", ";", "}", "else", "{", "return", "ONE", ".", "concatenate", "(", "divide", "(", "2", "*", "(", "numerator", "-", "denominator", ")", ",", "denominator", ",", "maxBits", "-", "1", ")", ")", ";", "}", "}" ]
Divide bits. @param numerator the numerator @param denominator the denominator @param maxBits the max bits @return the bits
[ "Divide", "bits", "." ]
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/binary/Bits.java#L142-L152
155,561
SimiaCryptus/utilities
java-util/src/main/java/com/simiacryptus/util/binary/Bits.java
Bits.dataCompare
public static int dataCompare(final Bits left, final Bits right) { for (int i = 0; i < left.bytes.length; i++) { if (right.bytes.length <= i) { return 1; } final int a = left.bytes[i] & 0xFF; final int b = right.bytes[i] & 0xFF; if (a < b) { return -1; } if (a > b) { return 1; } } if (left.bitLength < right.bitLength) { return -1; } if (left.bitLength > right.bitLength) { return 1; } return 0; }
java
public static int dataCompare(final Bits left, final Bits right) { for (int i = 0; i < left.bytes.length; i++) { if (right.bytes.length <= i) { return 1; } final int a = left.bytes[i] & 0xFF; final int b = right.bytes[i] & 0xFF; if (a < b) { return -1; } if (a > b) { return 1; } } if (left.bitLength < right.bitLength) { return -1; } if (left.bitLength > right.bitLength) { return 1; } return 0; }
[ "public", "static", "int", "dataCompare", "(", "final", "Bits", "left", ",", "final", "Bits", "right", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "left", ".", "bytes", ".", "length", ";", "i", "++", ")", "{", "if", "(", "right", ".", "bytes", ".", "length", "<=", "i", ")", "{", "return", "1", ";", "}", "final", "int", "a", "=", "left", ".", "bytes", "[", "i", "]", "&", "0xFF", ";", "final", "int", "b", "=", "right", ".", "bytes", "[", "i", "]", "&", "0xFF", ";", "if", "(", "a", "<", "b", ")", "{", "return", "-", "1", ";", "}", "if", "(", "a", ">", "b", ")", "{", "return", "1", ";", "}", "}", "if", "(", "left", ".", "bitLength", "<", "right", ".", "bitLength", ")", "{", "return", "-", "1", ";", "}", "if", "(", "left", ".", "bitLength", ">", "right", ".", "bitLength", ")", "{", "return", "1", ";", "}", "return", "0", ";", "}" ]
Data compare int. @param left the left @param right the right @return the int
[ "Data", "compare", "int", "." ]
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/binary/Bits.java#L161-L182
155,562
SimiaCryptus/utilities
java-util/src/main/java/com/simiacryptus/util/binary/Bits.java
Bits.highestOneBit
public static byte highestOneBit(final long v) { final long h = Long.highestOneBit(v); if (0 == v) { return 0; } for (byte i = 0; i < 64; i++) { if (h == 1l << i) { return (byte) (i + 1); } } throw new RuntimeException(); }
java
public static byte highestOneBit(final long v) { final long h = Long.highestOneBit(v); if (0 == v) { return 0; } for (byte i = 0; i < 64; i++) { if (h == 1l << i) { return (byte) (i + 1); } } throw new RuntimeException(); }
[ "public", "static", "byte", "highestOneBit", "(", "final", "long", "v", ")", "{", "final", "long", "h", "=", "Long", ".", "highestOneBit", "(", "v", ")", ";", "if", "(", "0", "==", "v", ")", "{", "return", "0", ";", "}", "for", "(", "byte", "i", "=", "0", ";", "i", "<", "64", ";", "i", "++", ")", "{", "if", "(", "h", "==", "1l", "<<", "i", ")", "{", "return", "(", "byte", ")", "(", "i", "+", "1", ")", ";", "}", "}", "throw", "new", "RuntimeException", "(", ")", ";", "}" ]
Highest one bit byte. @param v the v @return the byte
[ "Highest", "one", "bit", "byte", "." ]
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/binary/Bits.java#L190-L201
155,563
SimiaCryptus/utilities
java-util/src/main/java/com/simiacryptus/util/binary/Bits.java
Bits.shiftLeft
public static void shiftLeft(final byte[] src, final int bits, final byte[] dst) { final int bitPart = bits % 8; final int bytePart = bits / 8; for (int i = 0; i < dst.length; i++) { final int a = i + bytePart; if (a >= 0 && src.length > a) { dst[i] |= (byte) ((src[a] & 0xFF) << bitPart & 0xFF); } final int b = i + bytePart + 1; if (b >= 0 && src.length > b) { dst[i] |= (byte) ((src[b] & 0xFF) >> 8 - bitPart & 0xFF); } } }
java
public static void shiftLeft(final byte[] src, final int bits, final byte[] dst) { final int bitPart = bits % 8; final int bytePart = bits / 8; for (int i = 0; i < dst.length; i++) { final int a = i + bytePart; if (a >= 0 && src.length > a) { dst[i] |= (byte) ((src[a] & 0xFF) << bitPart & 0xFF); } final int b = i + bytePart + 1; if (b >= 0 && src.length > b) { dst[i] |= (byte) ((src[b] & 0xFF) >> 8 - bitPart & 0xFF); } } }
[ "public", "static", "void", "shiftLeft", "(", "final", "byte", "[", "]", "src", ",", "final", "int", "bits", ",", "final", "byte", "[", "]", "dst", ")", "{", "final", "int", "bitPart", "=", "bits", "%", "8", ";", "final", "int", "bytePart", "=", "bits", "/", "8", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "dst", ".", "length", ";", "i", "++", ")", "{", "final", "int", "a", "=", "i", "+", "bytePart", ";", "if", "(", "a", ">=", "0", "&&", "src", ".", "length", ">", "a", ")", "{", "dst", "[", "i", "]", "|=", "(", "byte", ")", "(", "(", "src", "[", "a", "]", "&", "0xFF", ")", "<<", "bitPart", "&", "0xFF", ")", ";", "}", "final", "int", "b", "=", "i", "+", "bytePart", "+", "1", ";", "if", "(", "b", ">=", "0", "&&", "src", ".", "length", ">", "b", ")", "{", "dst", "[", "i", "]", "|=", "(", "byte", ")", "(", "(", "src", "[", "b", "]", "&", "0xFF", ")", ">>", "8", "-", "bitPart", "&", "0xFF", ")", ";", "}", "}", "}" ]
Shift left. @param src the src @param bits the bits @param dst the dst
[ "Shift", "left", "." ]
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/binary/Bits.java#L238-L252
155,564
SimiaCryptus/utilities
java-util/src/main/java/com/simiacryptus/util/binary/Bits.java
Bits.bitwiseXor
public Bits bitwiseXor(final Bits right) { final int lengthDifference = this.bitLength - right.bitLength; if (lengthDifference < 0) { return this.concatenate( new Bits(0l, -lengthDifference)).bitwiseXor(right); } if (lengthDifference > 0) { return this.bitwiseXor(right .concatenate(new Bits(0l, lengthDifference))); } final Bits returnValue = new Bits( new byte[this.bytes.length], this.bitLength); for (int i = 0; i < this.bytes.length; i++) { returnValue.bytes[i] = this.bytes[i]; } for (int i = 0; i < right.bytes.length; i++) { returnValue.bytes[i] ^= right.bytes[i]; } return returnValue; }
java
public Bits bitwiseXor(final Bits right) { final int lengthDifference = this.bitLength - right.bitLength; if (lengthDifference < 0) { return this.concatenate( new Bits(0l, -lengthDifference)).bitwiseXor(right); } if (lengthDifference > 0) { return this.bitwiseXor(right .concatenate(new Bits(0l, lengthDifference))); } final Bits returnValue = new Bits( new byte[this.bytes.length], this.bitLength); for (int i = 0; i < this.bytes.length; i++) { returnValue.bytes[i] = this.bytes[i]; } for (int i = 0; i < right.bytes.length; i++) { returnValue.bytes[i] ^= right.bytes[i]; } return returnValue; }
[ "public", "Bits", "bitwiseXor", "(", "final", "Bits", "right", ")", "{", "final", "int", "lengthDifference", "=", "this", ".", "bitLength", "-", "right", ".", "bitLength", ";", "if", "(", "lengthDifference", "<", "0", ")", "{", "return", "this", ".", "concatenate", "(", "new", "Bits", "(", "0l", ",", "-", "lengthDifference", ")", ")", ".", "bitwiseXor", "(", "right", ")", ";", "}", "if", "(", "lengthDifference", ">", "0", ")", "{", "return", "this", ".", "bitwiseXor", "(", "right", ".", "concatenate", "(", "new", "Bits", "(", "0l", ",", "lengthDifference", ")", ")", ")", ";", "}", "final", "Bits", "returnValue", "=", "new", "Bits", "(", "new", "byte", "[", "this", ".", "bytes", ".", "length", "]", ",", "this", ".", "bitLength", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "this", ".", "bytes", ".", "length", ";", "i", "++", ")", "{", "returnValue", ".", "bytes", "[", "i", "]", "=", "this", ".", "bytes", "[", "i", "]", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "right", ".", "bytes", ".", "length", ";", "i", "++", ")", "{", "returnValue", ".", "bytes", "[", "i", "]", "^=", "right", ".", "bytes", "[", "i", "]", ";", "}", "return", "returnValue", ";", "}" ]
Bitwise xor bits. @param right the right @return the bits
[ "Bitwise", "xor", "bits", "." ]
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/binary/Bits.java#L378-L398
155,565
SimiaCryptus/utilities
java-util/src/main/java/com/simiacryptus/util/binary/Bits.java
Bits.concatenate
public Bits concatenate(final Bits right) { final int newBitLength = this.bitLength + right.bitLength; final int newByteLength = (int) Math.ceil(newBitLength / 8.); final Bits result = new Bits(new byte[newByteLength], newBitLength); shiftLeft(this.bytes, 0, result.bytes); shiftRight(right.bytes, this.bitLength, result.bytes); return result; }
java
public Bits concatenate(final Bits right) { final int newBitLength = this.bitLength + right.bitLength; final int newByteLength = (int) Math.ceil(newBitLength / 8.); final Bits result = new Bits(new byte[newByteLength], newBitLength); shiftLeft(this.bytes, 0, result.bytes); shiftRight(right.bytes, this.bitLength, result.bytes); return result; }
[ "public", "Bits", "concatenate", "(", "final", "Bits", "right", ")", "{", "final", "int", "newBitLength", "=", "this", ".", "bitLength", "+", "right", ".", "bitLength", ";", "final", "int", "newByteLength", "=", "(", "int", ")", "Math", ".", "ceil", "(", "newBitLength", "/", "8.", ")", ";", "final", "Bits", "result", "=", "new", "Bits", "(", "new", "byte", "[", "newByteLength", "]", ",", "newBitLength", ")", ";", "shiftLeft", "(", "this", ".", "bytes", ",", "0", ",", "result", ".", "bytes", ")", ";", "shiftRight", "(", "right", ".", "bytes", ",", "this", ".", "bitLength", ",", "result", ".", "bytes", ")", ";", "return", "result", ";", "}" ]
Concatenate bits. @param right the right @return the bits
[ "Concatenate", "bits", "." ]
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/binary/Bits.java#L411-L418
155,566
SimiaCryptus/utilities
java-util/src/main/java/com/simiacryptus/util/binary/Bits.java
Bits.range
public Bits range(final int start, final int length) { if (0 == length) { return Bits.NULL; } if (start < 0) { throw new IllegalArgumentException(); } if (start + length > this.bitLength) { throw new IllegalArgumentException(); } final Bits returnValue = new Bits( new byte[(int) Math.ceil(length / 8.)], length); shiftLeft(this.bytes, start, returnValue.bytes); int bitsInLastByte = length % 8; if (0 == bitsInLastByte) { bitsInLastByte = 8; } returnValue.bytes[returnValue.bytes.length - 1] &= 0xFF << 8 - bitsInLastByte; return returnValue; }
java
public Bits range(final int start, final int length) { if (0 == length) { return Bits.NULL; } if (start < 0) { throw new IllegalArgumentException(); } if (start + length > this.bitLength) { throw new IllegalArgumentException(); } final Bits returnValue = new Bits( new byte[(int) Math.ceil(length / 8.)], length); shiftLeft(this.bytes, start, returnValue.bytes); int bitsInLastByte = length % 8; if (0 == bitsInLastByte) { bitsInLastByte = 8; } returnValue.bytes[returnValue.bytes.length - 1] &= 0xFF << 8 - bitsInLastByte; return returnValue; }
[ "public", "Bits", "range", "(", "final", "int", "start", ",", "final", "int", "length", ")", "{", "if", "(", "0", "==", "length", ")", "{", "return", "Bits", ".", "NULL", ";", "}", "if", "(", "start", "<", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", ")", ";", "}", "if", "(", "start", "+", "length", ">", "this", ".", "bitLength", ")", "{", "throw", "new", "IllegalArgumentException", "(", ")", ";", "}", "final", "Bits", "returnValue", "=", "new", "Bits", "(", "new", "byte", "[", "(", "int", ")", "Math", ".", "ceil", "(", "length", "/", "8.", ")", "]", ",", "length", ")", ";", "shiftLeft", "(", "this", ".", "bytes", ",", "start", ",", "returnValue", ".", "bytes", ")", ";", "int", "bitsInLastByte", "=", "length", "%", "8", ";", "if", "(", "0", "==", "bitsInLastByte", ")", "{", "bitsInLastByte", "=", "8", ";", "}", "returnValue", ".", "bytes", "[", "returnValue", ".", "bytes", ".", "length", "-", "1", "]", "&=", "0xFF", "<<", "8", "-", "bitsInLastByte", ";", "return", "returnValue", ";", "}" ]
Range bits. @param start the start @param length the length @return the bits
[ "Range", "bits", "." ]
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/binary/Bits.java#L495-L515
155,567
SimiaCryptus/utilities
java-util/src/main/java/com/simiacryptus/util/binary/Bits.java
Bits.startsWith
public boolean startsWith(final Bits key) { if (key.bitLength > this.bitLength) { return false; } final Bits prefix = key.bitLength < this.bitLength ? this.range(0, key.bitLength) : this; return prefix.compareTo(key) == 0; }
java
public boolean startsWith(final Bits key) { if (key.bitLength > this.bitLength) { return false; } final Bits prefix = key.bitLength < this.bitLength ? this.range(0, key.bitLength) : this; return prefix.compareTo(key) == 0; }
[ "public", "boolean", "startsWith", "(", "final", "Bits", "key", ")", "{", "if", "(", "key", ".", "bitLength", ">", "this", ".", "bitLength", ")", "{", "return", "false", ";", "}", "final", "Bits", "prefix", "=", "key", ".", "bitLength", "<", "this", ".", "bitLength", "?", "this", ".", "range", "(", "0", ",", "key", ".", "bitLength", ")", ":", "this", ";", "return", "prefix", ".", "compareTo", "(", "key", ")", "==", "0", ";", "}" ]
Starts run boolean. @param key the key @return the boolean
[ "Starts", "run", "boolean", "." ]
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/binary/Bits.java#L523-L530
155,568
SimiaCryptus/utilities
java-util/src/main/java/com/simiacryptus/util/binary/Bits.java
Bits.toBitString
public String toBitString() { StringBuffer sb = new StringBuffer(); final int shift = this.bytes.length * 8 - this.bitLength; final byte[] shiftRight = shiftRight(this.bytes, shift); for (final byte b : shiftRight) { String asString = Integer.toBinaryString(b & 0xFF); while (asString.length() < 8) { asString = "0" + asString; } sb.append(asString); } if (sb.length() >= this.bitLength) { return sb.substring(sb.length() - this.bitLength, sb.length()); } else { final String n = sb.toString(); sb = new StringBuffer(); while (sb.length() + n.length() < this.bitLength) { sb.append("0"); } return sb + n; } }
java
public String toBitString() { StringBuffer sb = new StringBuffer(); final int shift = this.bytes.length * 8 - this.bitLength; final byte[] shiftRight = shiftRight(this.bytes, shift); for (final byte b : shiftRight) { String asString = Integer.toBinaryString(b & 0xFF); while (asString.length() < 8) { asString = "0" + asString; } sb.append(asString); } if (sb.length() >= this.bitLength) { return sb.substring(sb.length() - this.bitLength, sb.length()); } else { final String n = sb.toString(); sb = new StringBuffer(); while (sb.length() + n.length() < this.bitLength) { sb.append("0"); } return sb + n; } }
[ "public", "String", "toBitString", "(", ")", "{", "StringBuffer", "sb", "=", "new", "StringBuffer", "(", ")", ";", "final", "int", "shift", "=", "this", ".", "bytes", ".", "length", "*", "8", "-", "this", ".", "bitLength", ";", "final", "byte", "[", "]", "shiftRight", "=", "shiftRight", "(", "this", ".", "bytes", ",", "shift", ")", ";", "for", "(", "final", "byte", "b", ":", "shiftRight", ")", "{", "String", "asString", "=", "Integer", ".", "toBinaryString", "(", "b", "&", "0xFF", ")", ";", "while", "(", "asString", ".", "length", "(", ")", "<", "8", ")", "{", "asString", "=", "\"0\"", "+", "asString", ";", "}", "sb", ".", "append", "(", "asString", ")", ";", "}", "if", "(", "sb", ".", "length", "(", ")", ">=", "this", ".", "bitLength", ")", "{", "return", "sb", ".", "substring", "(", "sb", ".", "length", "(", ")", "-", "this", ".", "bitLength", ",", "sb", ".", "length", "(", ")", ")", ";", "}", "else", "{", "final", "String", "n", "=", "sb", ".", "toString", "(", ")", ";", "sb", "=", "new", "StringBuffer", "(", ")", ";", "while", "(", "sb", ".", "length", "(", ")", "+", "n", ".", "length", "(", ")", "<", "this", ".", "bitLength", ")", "{", "sb", ".", "append", "(", "\"0\"", ")", ";", "}", "return", "sb", "+", "n", ";", "}", "}" ]
To bit string string. @return the string
[ "To", "bit", "string", "string", "." ]
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/binary/Bits.java#L537-L559
155,569
SimiaCryptus/utilities
java-util/src/main/java/com/simiacryptus/util/binary/Bits.java
Bits.toHexString
public String toHexString() { final StringBuffer sb = new StringBuffer(); for (final byte b : this.bytes) { sb.append(Integer.toHexString(b & 0xFF)); } return sb.substring(0, Math.min(this.bitLength / 4, sb.length())); }
java
public String toHexString() { final StringBuffer sb = new StringBuffer(); for (final byte b : this.bytes) { sb.append(Integer.toHexString(b & 0xFF)); } return sb.substring(0, Math.min(this.bitLength / 4, sb.length())); }
[ "public", "String", "toHexString", "(", ")", "{", "final", "StringBuffer", "sb", "=", "new", "StringBuffer", "(", ")", ";", "for", "(", "final", "byte", "b", ":", "this", ".", "bytes", ")", "{", "sb", ".", "append", "(", "Integer", ".", "toHexString", "(", "b", "&", "0xFF", ")", ")", ";", "}", "return", "sb", ".", "substring", "(", "0", ",", "Math", ".", "min", "(", "this", ".", "bitLength", "/", "4", ",", "sb", ".", "length", "(", ")", ")", ")", ";", "}" ]
To hex string string. @return the string
[ "To", "hex", "string", "string", "." ]
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/binary/Bits.java#L566-L572
155,570
SimiaCryptus/utilities
java-util/src/main/java/com/simiacryptus/util/binary/Bits.java
Bits.toLong
public long toLong() { long value = 0; for (final byte b : shiftRight(this.bytes, this.bytes.length * 8 - this.bitLength)) { final long shifted = value << 8; value = shifted; final int asInt = b & 0xFF; value += asInt; } return value; }
java
public long toLong() { long value = 0; for (final byte b : shiftRight(this.bytes, this.bytes.length * 8 - this.bitLength)) { final long shifted = value << 8; value = shifted; final int asInt = b & 0xFF; value += asInt; } return value; }
[ "public", "long", "toLong", "(", ")", "{", "long", "value", "=", "0", ";", "for", "(", "final", "byte", "b", ":", "shiftRight", "(", "this", ".", "bytes", ",", "this", ".", "bytes", ".", "length", "*", "8", "-", "this", ".", "bitLength", ")", ")", "{", "final", "long", "shifted", "=", "value", "<<", "8", ";", "value", "=", "shifted", ";", "final", "int", "asInt", "=", "b", "&", "0xFF", ";", "value", "+=", "asInt", ";", "}", "return", "value", ";", "}" ]
To long long. @return the long
[ "To", "long", "long", "." ]
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/binary/Bits.java#L588-L598
155,571
foundation-runtime/service-directory
1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/query/QueryCriterionParser.java
QueryCriterionParser.toServiceInstanceQuery
public static ServiceInstanceQuery toServiceInstanceQuery(String cli){ char [] delimiters = {';'}; ServiceInstanceQuery query = new ServiceInstanceQuery(); for(String statement : splitStringByDelimiters(cli, delimiters, false)){ QueryCriterion criterion = toQueryCriterion(statement); if(criterion != null){ query.addQueryCriterion(criterion); } }; return query; }
java
public static ServiceInstanceQuery toServiceInstanceQuery(String cli){ char [] delimiters = {';'}; ServiceInstanceQuery query = new ServiceInstanceQuery(); for(String statement : splitStringByDelimiters(cli, delimiters, false)){ QueryCriterion criterion = toQueryCriterion(statement); if(criterion != null){ query.addQueryCriterion(criterion); } }; return query; }
[ "public", "static", "ServiceInstanceQuery", "toServiceInstanceQuery", "(", "String", "cli", ")", "{", "char", "[", "]", "delimiters", "=", "{", "'", "'", "}", ";", "ServiceInstanceQuery", "query", "=", "new", "ServiceInstanceQuery", "(", ")", ";", "for", "(", "String", "statement", ":", "splitStringByDelimiters", "(", "cli", ",", "delimiters", ",", "false", ")", ")", "{", "QueryCriterion", "criterion", "=", "toQueryCriterion", "(", "statement", ")", ";", "if", "(", "criterion", "!=", "null", ")", "{", "query", ".", "addQueryCriterion", "(", "criterion", ")", ";", "}", "}", ";", "return", "query", ";", "}" ]
Parse the ServiceInstanceQuery from commandline String expression. Convert the ServiceInstanceQuery commandline input to the ServiceInstanceQuery. @param cli the ServiceInstanceQuery commandline String expression. @return the QueryCriterion statement String list.
[ "Parse", "the", "ServiceInstanceQuery", "from", "commandline", "String", "expression", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/query/QueryCriterionParser.java#L186-L196
155,572
foundation-runtime/service-directory
1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/query/QueryCriterionParser.java
QueryCriterionParser.queryToExpressionStr
public static String queryToExpressionStr(ServiceInstanceQuery query){ List<QueryCriterion> criteria = query.getCriteria(); StringBuilder sb = new StringBuilder(); for(QueryCriterion criterion : criteria){ String statement = criterionToExpressionStr(criterion); if(statement != null && ! statement.isEmpty()){ sb.append(statement).append(";"); } } return sb.toString(); }
java
public static String queryToExpressionStr(ServiceInstanceQuery query){ List<QueryCriterion> criteria = query.getCriteria(); StringBuilder sb = new StringBuilder(); for(QueryCriterion criterion : criteria){ String statement = criterionToExpressionStr(criterion); if(statement != null && ! statement.isEmpty()){ sb.append(statement).append(";"); } } return sb.toString(); }
[ "public", "static", "String", "queryToExpressionStr", "(", "ServiceInstanceQuery", "query", ")", "{", "List", "<", "QueryCriterion", ">", "criteria", "=", "query", ".", "getCriteria", "(", ")", ";", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "QueryCriterion", "criterion", ":", "criteria", ")", "{", "String", "statement", "=", "criterionToExpressionStr", "(", "criterion", ")", ";", "if", "(", "statement", "!=", "null", "&&", "!", "statement", ".", "isEmpty", "(", ")", ")", "{", "sb", ".", "append", "(", "statement", ")", ".", "append", "(", "\";\"", ")", ";", "}", "}", "return", "sb", ".", "toString", "(", ")", ";", "}" ]
Convert the ServiceInstanceQuery to the commandline string expression. @param query the ServiceInstanceQuery. @return the string expression.
[ "Convert", "the", "ServiceInstanceQuery", "to", "the", "commandline", "string", "expression", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/query/QueryCriterionParser.java#L206-L216
155,573
foundation-runtime/service-directory
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/async/ServiceDirectoryFuture.java
ServiceDirectoryFuture.get
@Override public synchronized Response get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { long now = System.currentTimeMillis(); long mills = unit.toMillis(timeout); long toWait = mills; if (this.completed) { return this.getResult(); } else if (toWait <= 0) { throw new TimeoutException("Timeout is smaller than 0."); } else { for (;;) { wait(toWait); if (this.completed) { return this.getResult(); } long gap = System.currentTimeMillis() - now; toWait = toWait - gap; if (toWait <= 0) { throw new TimeoutException(); } } } }
java
@Override public synchronized Response get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { long now = System.currentTimeMillis(); long mills = unit.toMillis(timeout); long toWait = mills; if (this.completed) { return this.getResult(); } else if (toWait <= 0) { throw new TimeoutException("Timeout is smaller than 0."); } else { for (;;) { wait(toWait); if (this.completed) { return this.getResult(); } long gap = System.currentTimeMillis() - now; toWait = toWait - gap; if (toWait <= 0) { throw new TimeoutException(); } } } }
[ "@", "Override", "public", "synchronized", "Response", "get", "(", "long", "timeout", ",", "TimeUnit", "unit", ")", "throws", "InterruptedException", ",", "ExecutionException", ",", "TimeoutException", "{", "long", "now", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "long", "mills", "=", "unit", ".", "toMillis", "(", "timeout", ")", ";", "long", "toWait", "=", "mills", ";", "if", "(", "this", ".", "completed", ")", "{", "return", "this", ".", "getResult", "(", ")", ";", "}", "else", "if", "(", "toWait", "<=", "0", ")", "{", "throw", "new", "TimeoutException", "(", "\"Timeout is smaller than 0.\"", ")", ";", "}", "else", "{", "for", "(", ";", ";", ")", "{", "wait", "(", "toWait", ")", ";", "if", "(", "this", ".", "completed", ")", "{", "return", "this", ".", "getResult", "(", ")", ";", "}", "long", "gap", "=", "System", ".", "currentTimeMillis", "(", ")", "-", "now", ";", "toWait", "=", "toWait", "-", "gap", ";", "if", "(", "toWait", "<=", "0", ")", "{", "throw", "new", "TimeoutException", "(", ")", ";", "}", "}", "}", "}" ]
Get the Directory Request Response. {@inheritDoc}
[ "Get", "the", "Directory", "Request", "Response", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/async/ServiceDirectoryFuture.java#L106-L129
155,574
foundation-runtime/service-directory
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/async/ServiceDirectoryFuture.java
ServiceDirectoryFuture.complete
public synchronized boolean complete(Response result) { if (completed) { return false; } completed = true; this.result = result; notifyAll(); return true; }
java
public synchronized boolean complete(Response result) { if (completed) { return false; } completed = true; this.result = result; notifyAll(); return true; }
[ "public", "synchronized", "boolean", "complete", "(", "Response", "result", ")", "{", "if", "(", "completed", ")", "{", "return", "false", ";", "}", "completed", "=", "true", ";", "this", ".", "result", "=", "result", ";", "notifyAll", "(", ")", ";", "return", "true", ";", "}" ]
Complete the Future. @param result The Directory Request Response. @return true for complete success.
[ "Complete", "the", "Future", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/async/ServiceDirectoryFuture.java#L139-L147
155,575
foundation-runtime/service-directory
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/async/ServiceDirectoryFuture.java
ServiceDirectoryFuture.fail
public synchronized boolean fail(ServiceException ex) { if (completed) { return false; } this.completed = true; this.ex = ex; notifyAll(); return true; }
java
public synchronized boolean fail(ServiceException ex) { if (completed) { return false; } this.completed = true; this.ex = ex; notifyAll(); return true; }
[ "public", "synchronized", "boolean", "fail", "(", "ServiceException", "ex", ")", "{", "if", "(", "completed", ")", "{", "return", "false", ";", "}", "this", ".", "completed", "=", "true", ";", "this", ".", "ex", "=", "ex", ";", "notifyAll", "(", ")", ";", "return", "true", ";", "}" ]
Fail the Future. @param ex the ServiceException of the Directory Request. @return true for success.
[ "Fail", "the", "Future", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/async/ServiceDirectoryFuture.java#L157-L165
155,576
app55/app55-java
src/support/java/com/googlecode/openbeans/PersistenceDelegate.java
PersistenceDelegate.mutatesTo
protected boolean mutatesTo(Object o1, Object o2) { return null != o1 && null != o2 && o1.getClass() == o2.getClass(); }
java
protected boolean mutatesTo(Object o1, Object o2) { return null != o1 && null != o2 && o1.getClass() == o2.getClass(); }
[ "protected", "boolean", "mutatesTo", "(", "Object", "o1", ",", "Object", "o2", ")", "{", "return", "null", "!=", "o1", "&&", "null", "!=", "o2", "&&", "o1", ".", "getClass", "(", ")", "==", "o2", ".", "getClass", "(", ")", ";", "}" ]
Determines whether one object mutates to the other object. One object is considered able to mutate to another object if they are indistinguishable in terms of behaviors of all public APIs. The default implementation here is to return true only if the two objects are instances of the same class. @param o1 one object @param o2 the other object @return true if second object mutates to the first object, otherwise false
[ "Determines", "whether", "one", "object", "mutates", "to", "the", "other", "object", ".", "One", "object", "is", "considered", "able", "to", "mutate", "to", "another", "object", "if", "they", "are", "indistinguishable", "in", "terms", "of", "behaviors", "of", "all", "public", "APIs", ".", "The", "default", "implementation", "here", "is", "to", "return", "true", "only", "if", "the", "two", "objects", "are", "instances", "of", "the", "same", "class", "." ]
73e51d0f3141a859dfbd37ca9becef98477e553e
https://github.com/app55/app55-java/blob/73e51d0f3141a859dfbd37ca9becef98477e553e/src/support/java/com/googlecode/openbeans/PersistenceDelegate.java#L84-L87
155,577
app55/app55-java
src/support/java/com/googlecode/openbeans/PersistenceDelegate.java
PersistenceDelegate.writeObject
public void writeObject(Object oldInstance, Encoder out) { Object newInstance = out.get(oldInstance); Class<?> clazz = oldInstance.getClass(); if (mutatesTo(oldInstance, newInstance)) { initialize(clazz, oldInstance, newInstance, out); } else { out.remove(oldInstance); out.writeExpression(instantiate(oldInstance, out)); newInstance = out.get(oldInstance); if (newInstance != null) { initialize(clazz, oldInstance, newInstance, out); } } }
java
public void writeObject(Object oldInstance, Encoder out) { Object newInstance = out.get(oldInstance); Class<?> clazz = oldInstance.getClass(); if (mutatesTo(oldInstance, newInstance)) { initialize(clazz, oldInstance, newInstance, out); } else { out.remove(oldInstance); out.writeExpression(instantiate(oldInstance, out)); newInstance = out.get(oldInstance); if (newInstance != null) { initialize(clazz, oldInstance, newInstance, out); } } }
[ "public", "void", "writeObject", "(", "Object", "oldInstance", ",", "Encoder", "out", ")", "{", "Object", "newInstance", "=", "out", ".", "get", "(", "oldInstance", ")", ";", "Class", "<", "?", ">", "clazz", "=", "oldInstance", ".", "getClass", "(", ")", ";", "if", "(", "mutatesTo", "(", "oldInstance", ",", "newInstance", ")", ")", "{", "initialize", "(", "clazz", ",", "oldInstance", ",", "newInstance", ",", "out", ")", ";", "}", "else", "{", "out", ".", "remove", "(", "oldInstance", ")", ";", "out", ".", "writeExpression", "(", "instantiate", "(", "oldInstance", ",", "out", ")", ")", ";", "newInstance", "=", "out", ".", "get", "(", "oldInstance", ")", ";", "if", "(", "newInstance", "!=", "null", ")", "{", "initialize", "(", "clazz", ",", "oldInstance", ",", "newInstance", ",", "out", ")", ";", "}", "}", "}" ]
Writes a bean object to the given encoder. First it is checked whether the simulating new object can be mutated to the old instance. If yes, it is initialized to produce a series of expressions and statements that can be used to restore the old instance. Otherwise, remove the new object in the simulating new environment and writes an expression that can instantiate a new instance of the same type as the old one to the given encoder. @param oldInstance the old instance to be written @param out the encoder that the old instance will be written to
[ "Writes", "a", "bean", "object", "to", "the", "given", "encoder", ".", "First", "it", "is", "checked", "whether", "the", "simulating", "new", "object", "can", "be", "mutated", "to", "the", "old", "instance", ".", "If", "yes", "it", "is", "initialized", "to", "produce", "a", "series", "of", "expressions", "and", "statements", "that", "can", "be", "used", "to", "restore", "the", "old", "instance", ".", "Otherwise", "remove", "the", "new", "object", "in", "the", "simulating", "new", "environment", "and", "writes", "an", "expression", "that", "can", "instantiate", "a", "new", "instance", "of", "the", "same", "type", "as", "the", "old", "one", "to", "the", "given", "encoder", "." ]
73e51d0f3141a859dfbd37ca9becef98477e553e
https://github.com/app55/app55-java/blob/73e51d0f3141a859dfbd37ca9becef98477e553e/src/support/java/com/googlecode/openbeans/PersistenceDelegate.java#L99-L117
155,578
lotaris/jee-validation
src/main/java/com/lotaris/jee/validation/preprocessing/ModifiersPreprocessor.java
ModifiersPreprocessor.fillCache
private synchronized static void fillCache(Class objectClass, Map<Class<? extends Annotation>, IModifier> processors) { if (cache.containsKey(objectClass)) { return; } final Map<Field, Set<Class<? extends Annotation>>> classCache = new HashMap<>(); cache.put(objectClass, classCache); // for each field... for (Field field : getAllFields(objectClass)) { final Set<Class<? extends Annotation>> fieldCache = new HashSet<>(); // for each annotation on that field... for (Annotation annotation : field.getAnnotations()) { // cache the annotation type if there is a registered preprocessor for it final Class<? extends Annotation> annotationType = annotation.annotationType(); if (processors.containsKey(annotationType)) { fieldCache.add(annotationType); } } if (!fieldCache.isEmpty()) { classCache.put(field, fieldCache); } } }
java
private synchronized static void fillCache(Class objectClass, Map<Class<? extends Annotation>, IModifier> processors) { if (cache.containsKey(objectClass)) { return; } final Map<Field, Set<Class<? extends Annotation>>> classCache = new HashMap<>(); cache.put(objectClass, classCache); // for each field... for (Field field : getAllFields(objectClass)) { final Set<Class<? extends Annotation>> fieldCache = new HashSet<>(); // for each annotation on that field... for (Annotation annotation : field.getAnnotations()) { // cache the annotation type if there is a registered preprocessor for it final Class<? extends Annotation> annotationType = annotation.annotationType(); if (processors.containsKey(annotationType)) { fieldCache.add(annotationType); } } if (!fieldCache.isEmpty()) { classCache.put(field, fieldCache); } } }
[ "private", "synchronized", "static", "void", "fillCache", "(", "Class", "objectClass", ",", "Map", "<", "Class", "<", "?", "extends", "Annotation", ">", ",", "IModifier", ">", "processors", ")", "{", "if", "(", "cache", ".", "containsKey", "(", "objectClass", ")", ")", "{", "return", ";", "}", "final", "Map", "<", "Field", ",", "Set", "<", "Class", "<", "?", "extends", "Annotation", ">", ">", ">", "classCache", "=", "new", "HashMap", "<>", "(", ")", ";", "cache", ".", "put", "(", "objectClass", ",", "classCache", ")", ";", "// for each field...", "for", "(", "Field", "field", ":", "getAllFields", "(", "objectClass", ")", ")", "{", "final", "Set", "<", "Class", "<", "?", "extends", "Annotation", ">", ">", "fieldCache", "=", "new", "HashSet", "<>", "(", ")", ";", "// for each annotation on that field...", "for", "(", "Annotation", "annotation", ":", "field", ".", "getAnnotations", "(", ")", ")", "{", "// cache the annotation type if there is a registered preprocessor for it", "final", "Class", "<", "?", "extends", "Annotation", ">", "annotationType", "=", "annotation", ".", "annotationType", "(", ")", ";", "if", "(", "processors", ".", "containsKey", "(", "annotationType", ")", ")", "{", "fieldCache", ".", "add", "(", "annotationType", ")", ";", "}", "}", "if", "(", "!", "fieldCache", ".", "isEmpty", "(", ")", ")", "{", "classCache", ".", "put", "(", "field", ",", "fieldCache", ")", ";", "}", "}", "}" ]
Fills the annotation cache for the specified class. This scans all fields of the class and checks if they have modifier annotations. This information is saved in a synchronized static cache. @param objectClass the class to scan for preprocessing annotations @param processors the map of registered preprocessors (the map key is the annotation type)
[ "Fills", "the", "annotation", "cache", "for", "the", "specified", "class", ".", "This", "scans", "all", "fields", "of", "the", "class", "and", "checks", "if", "they", "have", "modifier", "annotations", ".", "This", "information", "is", "saved", "in", "a", "synchronized", "static", "cache", "." ]
feefff820b5a67c7471a13e08fdaf2d60bb3ad16
https://github.com/lotaris/jee-validation/blob/feefff820b5a67c7471a13e08fdaf2d60bb3ad16/src/main/java/com/lotaris/jee/validation/preprocessing/ModifiersPreprocessor.java#L42-L70
155,579
lotaris/jee-validation
src/main/java/com/lotaris/jee/validation/preprocessing/ModifiersPreprocessor.java
ModifiersPreprocessor.getAllFields
private static List<Field> getAllFields(Class type) { final List<Field> fields = new ArrayList<>(); for (Class<?> c = type; c != null; c = c.getSuperclass()) { fields.addAll(Arrays.asList(c.getDeclaredFields())); } return fields; }
java
private static List<Field> getAllFields(Class type) { final List<Field> fields = new ArrayList<>(); for (Class<?> c = type; c != null; c = c.getSuperclass()) { fields.addAll(Arrays.asList(c.getDeclaredFields())); } return fields; }
[ "private", "static", "List", "<", "Field", ">", "getAllFields", "(", "Class", "type", ")", "{", "final", "List", "<", "Field", ">", "fields", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "Class", "<", "?", ">", "c", "=", "type", ";", "c", "!=", "null", ";", "c", "=", "c", ".", "getSuperclass", "(", ")", ")", "{", "fields", ".", "addAll", "(", "Arrays", ".", "asList", "(", "c", ".", "getDeclaredFields", "(", ")", ")", ")", ";", "}", "return", "fields", ";", "}" ]
Returns the declared and inherited fields of the specified class. @param type the class whose fields to list @return a list of fields
[ "Returns", "the", "declared", "and", "inherited", "fields", "of", "the", "specified", "class", "." ]
feefff820b5a67c7471a13e08fdaf2d60bb3ad16
https://github.com/lotaris/jee-validation/blob/feefff820b5a67c7471a13e08fdaf2d60bb3ad16/src/main/java/com/lotaris/jee/validation/preprocessing/ModifiersPreprocessor.java#L78-L84
155,580
lotaris/jee-validation
src/main/java/com/lotaris/jee/validation/preprocessing/ModifiersPreprocessor.java
ModifiersPreprocessor.configure
@PostConstruct @SuppressWarnings("unchecked") protected void configure() { // scan all fields for (Field field : getClass().getDeclaredFields()) { // if it's a preprocessor, register it if (IModifier.class.isAssignableFrom(field.getType())) { try { field.setAccessible(true); final IModifier processor = (IModifier) field.get(this); processorsCache.put(processor.getAnnotationType(), processor); } catch (IllegalArgumentException | IllegalAccessException ex) { LoggerFactory.getLogger(ModifiersPreprocessor.class) .error("Could not register pre-processor for field " + field.getName()); } } } }
java
@PostConstruct @SuppressWarnings("unchecked") protected void configure() { // scan all fields for (Field field : getClass().getDeclaredFields()) { // if it's a preprocessor, register it if (IModifier.class.isAssignableFrom(field.getType())) { try { field.setAccessible(true); final IModifier processor = (IModifier) field.get(this); processorsCache.put(processor.getAnnotationType(), processor); } catch (IllegalArgumentException | IllegalAccessException ex) { LoggerFactory.getLogger(ModifiersPreprocessor.class) .error("Could not register pre-processor for field " + field.getName()); } } } }
[ "@", "PostConstruct", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "protected", "void", "configure", "(", ")", "{", "// scan all fields", "for", "(", "Field", "field", ":", "getClass", "(", ")", ".", "getDeclaredFields", "(", ")", ")", "{", "// if it's a preprocessor, register it", "if", "(", "IModifier", ".", "class", ".", "isAssignableFrom", "(", "field", ".", "getType", "(", ")", ")", ")", "{", "try", "{", "field", ".", "setAccessible", "(", "true", ")", ";", "final", "IModifier", "processor", "=", "(", "IModifier", ")", "field", ".", "get", "(", "this", ")", ";", "processorsCache", ".", "put", "(", "processor", ".", "getAnnotationType", "(", ")", ",", "processor", ")", ";", "}", "catch", "(", "IllegalArgumentException", "|", "IllegalAccessException", "ex", ")", "{", "LoggerFactory", ".", "getLogger", "(", "ModifiersPreprocessor", ".", "class", ")", ".", "error", "(", "\"Could not register pre-processor for field \"", "+", "field", ".", "getName", "(", ")", ")", ";", "}", "}", "}", "}" ]
Registers all preprocessors injected into this class.
[ "Registers", "all", "preprocessors", "injected", "into", "this", "class", "." ]
feefff820b5a67c7471a13e08fdaf2d60bb3ad16
https://github.com/lotaris/jee-validation/blob/feefff820b5a67c7471a13e08fdaf2d60bb3ad16/src/main/java/com/lotaris/jee/validation/preprocessing/ModifiersPreprocessor.java#L103-L122
155,581
konvergeio/cofoja
src/main/java/com/google/java/contract/core/agent/ContractAnalyzer.java
ContractAnalyzer.getClassHandles
@Requires("kind != null") @Ensures({ "result != null", "!result.contains(null)" }) List<ClassContractHandle> getClassHandles(ContractKind kind) { ArrayList<ClassContractHandle> matched = new ArrayList<ClassContractHandle>(); for (ClassContractHandle h : classHandles) { if (kind.equals(h.getKind())) { matched.add(h); } } return matched; }
java
@Requires("kind != null") @Ensures({ "result != null", "!result.contains(null)" }) List<ClassContractHandle> getClassHandles(ContractKind kind) { ArrayList<ClassContractHandle> matched = new ArrayList<ClassContractHandle>(); for (ClassContractHandle h : classHandles) { if (kind.equals(h.getKind())) { matched.add(h); } } return matched; }
[ "@", "Requires", "(", "\"kind != null\"", ")", "@", "Ensures", "(", "{", "\"result != null\"", ",", "\"!result.contains(null)\"", "}", ")", "List", "<", "ClassContractHandle", ">", "getClassHandles", "(", "ContractKind", "kind", ")", "{", "ArrayList", "<", "ClassContractHandle", ">", "matched", "=", "new", "ArrayList", "<", "ClassContractHandle", ">", "(", ")", ";", "for", "(", "ClassContractHandle", "h", ":", "classHandles", ")", "{", "if", "(", "kind", ".", "equals", "(", "h", ".", "getKind", "(", ")", ")", ")", "{", "matched", ".", "add", "(", "h", ")", ";", "}", "}", "return", "matched", ";", "}" ]
Returns the ClassHandle objects matching the specified criteria. @param kind the kind of the handles @return a list containing the requested handles
[ "Returns", "the", "ClassHandle", "objects", "matching", "the", "specified", "criteria", "." ]
6ded58fa05eb5bf85f16353c8dd4c70bee59121a
https://github.com/konvergeio/cofoja/blob/6ded58fa05eb5bf85f16353c8dd4c70bee59121a/src/main/java/com/google/java/contract/core/agent/ContractAnalyzer.java#L84-L98
155,582
konvergeio/cofoja
src/main/java/com/google/java/contract/core/agent/ContractAnalyzer.java
ContractAnalyzer.getMethodHandles
@Requires({ "kind != null", "name != null", "desc != null", "extraCount >= 0" }) @Ensures({ "result != null", "!result.contains(null)" }) List<MethodContractHandle> getMethodHandles(ContractKind kind, String name, String desc, int extraCount) { ArrayList<MethodContractHandle> candidates = methodHandles.get(name); if (candidates == null) { return Collections.emptyList(); } ArrayList<MethodContractHandle> matched = new ArrayList<MethodContractHandle>(); for (MethodContractHandle h : candidates) { if (kind.equals(h.getKind()) && descArgumentsMatch(desc, h.getContractMethod().desc, extraCount)) { matched.add(h); } } return matched; }
java
@Requires({ "kind != null", "name != null", "desc != null", "extraCount >= 0" }) @Ensures({ "result != null", "!result.contains(null)" }) List<MethodContractHandle> getMethodHandles(ContractKind kind, String name, String desc, int extraCount) { ArrayList<MethodContractHandle> candidates = methodHandles.get(name); if (candidates == null) { return Collections.emptyList(); } ArrayList<MethodContractHandle> matched = new ArrayList<MethodContractHandle>(); for (MethodContractHandle h : candidates) { if (kind.equals(h.getKind()) && descArgumentsMatch(desc, h.getContractMethod().desc, extraCount)) { matched.add(h); } } return matched; }
[ "@", "Requires", "(", "{", "\"kind != null\"", ",", "\"name != null\"", ",", "\"desc != null\"", ",", "\"extraCount >= 0\"", "}", ")", "@", "Ensures", "(", "{", "\"result != null\"", ",", "\"!result.contains(null)\"", "}", ")", "List", "<", "MethodContractHandle", ">", "getMethodHandles", "(", "ContractKind", "kind", ",", "String", "name", ",", "String", "desc", ",", "int", "extraCount", ")", "{", "ArrayList", "<", "MethodContractHandle", ">", "candidates", "=", "methodHandles", ".", "get", "(", "name", ")", ";", "if", "(", "candidates", "==", "null", ")", "{", "return", "Collections", ".", "emptyList", "(", ")", ";", "}", "ArrayList", "<", "MethodContractHandle", ">", "matched", "=", "new", "ArrayList", "<", "MethodContractHandle", ">", "(", ")", ";", "for", "(", "MethodContractHandle", "h", ":", "candidates", ")", "{", "if", "(", "kind", ".", "equals", "(", "h", ".", "getKind", "(", ")", ")", "&&", "descArgumentsMatch", "(", "desc", ",", "h", ".", "getContractMethod", "(", ")", ".", "desc", ",", "extraCount", ")", ")", "{", "matched", ".", "add", "(", "h", ")", ";", "}", "}", "return", "matched", ";", "}" ]
Returns the MethodHandle objects matching the specified criteria. @param kind the kind of the handles @param name the target method name @param desc the target method descriptor @param extraCount the number of extra parameters in the contract method @return a list containing the requested handles
[ "Returns", "the", "MethodHandle", "objects", "matching", "the", "specified", "criteria", "." ]
6ded58fa05eb5bf85f16353c8dd4c70bee59121a
https://github.com/konvergeio/cofoja/blob/6ded58fa05eb5bf85f16353c8dd4c70bee59121a/src/main/java/com/google/java/contract/core/agent/ContractAnalyzer.java#L110-L136
155,583
konvergeio/cofoja
src/main/java/com/google/java/contract/core/agent/ContractAnalyzer.java
ContractAnalyzer.getClassHandle
@Requires("kind != null") ClassContractHandle getClassHandle(ContractKind kind) { ArrayList<ClassContractHandle> matched = new ArrayList<ClassContractHandle>(); for (ClassContractHandle h : classHandles) { if (kind.equals(h.getKind())) { return h; } } return null; }
java
@Requires("kind != null") ClassContractHandle getClassHandle(ContractKind kind) { ArrayList<ClassContractHandle> matched = new ArrayList<ClassContractHandle>(); for (ClassContractHandle h : classHandles) { if (kind.equals(h.getKind())) { return h; } } return null; }
[ "@", "Requires", "(", "\"kind != null\"", ")", "ClassContractHandle", "getClassHandle", "(", "ContractKind", "kind", ")", "{", "ArrayList", "<", "ClassContractHandle", ">", "matched", "=", "new", "ArrayList", "<", "ClassContractHandle", ">", "(", ")", ";", "for", "(", "ClassContractHandle", "h", ":", "classHandles", ")", "{", "if", "(", "kind", ".", "equals", "(", "h", ".", "getKind", "(", ")", ")", ")", "{", "return", "h", ";", "}", "}", "return", "null", ";", "}" ]
Returns the first ClassHandle object matching the specified criteria. @param kind the kind of the handle @return a handle matching the criteria, or {@code null}
[ "Returns", "the", "first", "ClassHandle", "object", "matching", "the", "specified", "criteria", "." ]
6ded58fa05eb5bf85f16353c8dd4c70bee59121a
https://github.com/konvergeio/cofoja/blob/6ded58fa05eb5bf85f16353c8dd4c70bee59121a/src/main/java/com/google/java/contract/core/agent/ContractAnalyzer.java#L145-L155
155,584
konvergeio/cofoja
src/main/java/com/google/java/contract/core/agent/ContractAnalyzer.java
ContractAnalyzer.getMethodHandle
@Requires({ "kind != null", "name != null", "desc != null", "extraCount >= 0" }) MethodContractHandle getMethodHandle(ContractKind kind, String name, String desc, int extraCount) { ArrayList<MethodContractHandle> candidates = methodHandles.get(name); if (candidates == null) { return null; } for (MethodContractHandle h : candidates) { if (kind.equals(h.getKind()) && descArgumentsMatch(desc, h.getContractMethod().desc, extraCount)) { return h; } } return null; }
java
@Requires({ "kind != null", "name != null", "desc != null", "extraCount >= 0" }) MethodContractHandle getMethodHandle(ContractKind kind, String name, String desc, int extraCount) { ArrayList<MethodContractHandle> candidates = methodHandles.get(name); if (candidates == null) { return null; } for (MethodContractHandle h : candidates) { if (kind.equals(h.getKind()) && descArgumentsMatch(desc, h.getContractMethod().desc, extraCount)) { return h; } } return null; }
[ "@", "Requires", "(", "{", "\"kind != null\"", ",", "\"name != null\"", ",", "\"desc != null\"", ",", "\"extraCount >= 0\"", "}", ")", "MethodContractHandle", "getMethodHandle", "(", "ContractKind", "kind", ",", "String", "name", ",", "String", "desc", ",", "int", "extraCount", ")", "{", "ArrayList", "<", "MethodContractHandle", ">", "candidates", "=", "methodHandles", ".", "get", "(", "name", ")", ";", "if", "(", "candidates", "==", "null", ")", "{", "return", "null", ";", "}", "for", "(", "MethodContractHandle", "h", ":", "candidates", ")", "{", "if", "(", "kind", ".", "equals", "(", "h", ".", "getKind", "(", ")", ")", "&&", "descArgumentsMatch", "(", "desc", ",", "h", ".", "getContractMethod", "(", ")", ".", "desc", ",", "extraCount", ")", ")", "{", "return", "h", ";", "}", "}", "return", "null", ";", "}" ]
Returns the first MethodHandle object matching the specified criteria. @param kind the kind of the handle @param name the target method name @param desc the target method descriptor @param extraCount the number of extra parameters in the contract method @return a handle matching the criteria, or {@code null}
[ "Returns", "the", "first", "MethodHandle", "object", "matching", "the", "specified", "criteria", "." ]
6ded58fa05eb5bf85f16353c8dd4c70bee59121a
https://github.com/konvergeio/cofoja/blob/6ded58fa05eb5bf85f16353c8dd4c70bee59121a/src/main/java/com/google/java/contract/core/agent/ContractAnalyzer.java#L168-L188
155,585
konvergeio/cofoja
src/main/java/com/google/java/contract/core/agent/ContractAnalyzer.java
ContractAnalyzer.captureLastMethodNode
@Ensures("lastMethodNode == null") protected void captureLastMethodNode() { if (lastMethodNode == null) { return; } ContractKind kind = ContractMethodSignatures.getKind(lastMethodNode); if (kind != null) { List<Long> lineNumbers = ContractMethodSignatures.getLineNumbers(lastMethodNode); if (kind.isClassContract() || kind.isHelperContract()) { ClassContractHandle ch = new ClassContractHandle(kind, className, lastMethodNode, lineNumbers); classHandles.add(ch); } else { MethodContractHandle mh = new MethodContractHandle(kind, className, lastMethodNode, lineNumbers); internMethod(mh.getMethodName()).add(mh); } } lastMethodNode = null; }
java
@Ensures("lastMethodNode == null") protected void captureLastMethodNode() { if (lastMethodNode == null) { return; } ContractKind kind = ContractMethodSignatures.getKind(lastMethodNode); if (kind != null) { List<Long> lineNumbers = ContractMethodSignatures.getLineNumbers(lastMethodNode); if (kind.isClassContract() || kind.isHelperContract()) { ClassContractHandle ch = new ClassContractHandle(kind, className, lastMethodNode, lineNumbers); classHandles.add(ch); } else { MethodContractHandle mh = new MethodContractHandle(kind, className, lastMethodNode, lineNumbers); internMethod(mh.getMethodName()).add(mh); } } lastMethodNode = null; }
[ "@", "Ensures", "(", "\"lastMethodNode == null\"", ")", "protected", "void", "captureLastMethodNode", "(", ")", "{", "if", "(", "lastMethodNode", "==", "null", ")", "{", "return", ";", "}", "ContractKind", "kind", "=", "ContractMethodSignatures", ".", "getKind", "(", "lastMethodNode", ")", ";", "if", "(", "kind", "!=", "null", ")", "{", "List", "<", "Long", ">", "lineNumbers", "=", "ContractMethodSignatures", ".", "getLineNumbers", "(", "lastMethodNode", ")", ";", "if", "(", "kind", ".", "isClassContract", "(", ")", "||", "kind", ".", "isHelperContract", "(", ")", ")", "{", "ClassContractHandle", "ch", "=", "new", "ClassContractHandle", "(", "kind", ",", "className", ",", "lastMethodNode", ",", "lineNumbers", ")", ";", "classHandles", ".", "add", "(", "ch", ")", ";", "}", "else", "{", "MethodContractHandle", "mh", "=", "new", "MethodContractHandle", "(", "kind", ",", "className", ",", "lastMethodNode", ",", "lineNumbers", ")", ";", "internMethod", "(", "mh", ".", "getMethodName", "(", ")", ")", ".", "add", "(", "mh", ")", ";", "}", "}", "lastMethodNode", "=", "null", ";", "}" ]
Creates a contract handle for the method last visited, if it was a contract method.
[ "Creates", "a", "contract", "handle", "for", "the", "method", "last", "visited", "if", "it", "was", "a", "contract", "method", "." ]
6ded58fa05eb5bf85f16353c8dd4c70bee59121a
https://github.com/konvergeio/cofoja/blob/6ded58fa05eb5bf85f16353c8dd4c70bee59121a/src/main/java/com/google/java/contract/core/agent/ContractAnalyzer.java#L243-L268
155,586
PureSolTechnologies/parsers
parsers/src/main/java/com/puresoltechnologies/parsers/parser/parsetable/ParserAction.java
ParserAction.compareTo
@Override public int compareTo(ParserAction other) { int result = this.action.compareTo(other.action); if (result != 0) { return result; } return other.parameter - this.parameter; }
java
@Override public int compareTo(ParserAction other) { int result = this.action.compareTo(other.action); if (result != 0) { return result; } return other.parameter - this.parameter; }
[ "@", "Override", "public", "int", "compareTo", "(", "ParserAction", "other", ")", "{", "int", "result", "=", "this", ".", "action", ".", "compareTo", "(", "other", ".", "action", ")", ";", "if", "(", "result", "!=", "0", ")", "{", "return", "result", ";", "}", "return", "other", ".", "parameter", "-", "this", ".", "parameter", ";", "}" ]
This comparison is used to sort parser action lists for ambiguous grammars to get the order of fastest progress. The experience tells that the fastest progress is to shift first and try to reduce later. And the sorting of the productions within the grammar file should be from rough to fine definition and the reduction is tried from the latest production to the first. Means, from fine to rough.
[ "This", "comparison", "is", "used", "to", "sort", "parser", "action", "lists", "for", "ambiguous", "grammars", "to", "get", "the", "order", "of", "fastest", "progress", "." ]
61077223b90d3768ff9445ae13036343c98b63cd
https://github.com/PureSolTechnologies/parsers/blob/61077223b90d3768ff9445ae13036343c98b63cd/parsers/src/main/java/com/puresoltechnologies/parsers/parser/parsetable/ParserAction.java#L91-L98
155,587
grails/grails-gdoc-engine
src/main/java/org/radeox/EngineManager.java
EngineManager.getInstance
public static synchronized RenderEngine getInstance(String name) { if (null == availableEngines) { availableEngines = new HashMap(); } //Logger.debug("Engines: " + availableEngines); return (RenderEngine) availableEngines.get(name); }
java
public static synchronized RenderEngine getInstance(String name) { if (null == availableEngines) { availableEngines = new HashMap(); } //Logger.debug("Engines: " + availableEngines); return (RenderEngine) availableEngines.get(name); }
[ "public", "static", "synchronized", "RenderEngine", "getInstance", "(", "String", "name", ")", "{", "if", "(", "null", "==", "availableEngines", ")", "{", "availableEngines", "=", "new", "HashMap", "(", ")", ";", "}", "//Logger.debug(\"Engines: \" + availableEngines);", "return", "(", "RenderEngine", ")", "availableEngines", ".", "get", "(", "name", ")", ";", "}" ]
Get an instance of a RenderEngine. This is a factory method. @param name Name of the RenderEngine to get @return engine RenderEngine for the requested name
[ "Get", "an", "instance", "of", "a", "RenderEngine", ".", "This", "is", "a", "factory", "method", "." ]
e52aa09eaa61510dc48b27603bd9ea116cd6531a
https://github.com/grails/grails-gdoc-engine/blob/e52aa09eaa61510dc48b27603bd9ea116cd6531a/src/main/java/org/radeox/EngineManager.java#L84-L91
155,588
grails/grails-gdoc-engine
src/main/java/org/radeox/EngineManager.java
EngineManager.getInstance
public static synchronized RenderEngine getInstance() { //availableEngines = null; if (null == availableEngines) { availableEngines = new HashMap(); } if (!availableEngines.containsKey(DEFAULT)) { RenderEngine engine = new BaseRenderEngine(); availableEngines.put(engine.getName(), engine); } return (RenderEngine) availableEngines.get(DEFAULT); }
java
public static synchronized RenderEngine getInstance() { //availableEngines = null; if (null == availableEngines) { availableEngines = new HashMap(); } if (!availableEngines.containsKey(DEFAULT)) { RenderEngine engine = new BaseRenderEngine(); availableEngines.put(engine.getName(), engine); } return (RenderEngine) availableEngines.get(DEFAULT); }
[ "public", "static", "synchronized", "RenderEngine", "getInstance", "(", ")", "{", "//availableEngines = null;", "if", "(", "null", "==", "availableEngines", ")", "{", "availableEngines", "=", "new", "HashMap", "(", ")", ";", "}", "if", "(", "!", "availableEngines", ".", "containsKey", "(", "DEFAULT", ")", ")", "{", "RenderEngine", "engine", "=", "new", "BaseRenderEngine", "(", ")", ";", "availableEngines", ".", "put", "(", "engine", ".", "getName", "(", ")", ",", "engine", ")", ";", "}", "return", "(", "RenderEngine", ")", "availableEngines", ".", "get", "(", "DEFAULT", ")", ";", "}" ]
Get an instance of a RenderEngine. This is a factory method. Defaults to a default RenderEngine. Currently this is a basic EngineManager with no additional features that is distributed with Radeox. @return engine default RenderEngine
[ "Get", "an", "instance", "of", "a", "RenderEngine", ".", "This", "is", "a", "factory", "method", ".", "Defaults", "to", "a", "default", "RenderEngine", ".", "Currently", "this", "is", "a", "basic", "EngineManager", "with", "no", "additional", "features", "that", "is", "distributed", "with", "Radeox", "." ]
e52aa09eaa61510dc48b27603bd9ea116cd6531a
https://github.com/grails/grails-gdoc-engine/blob/e52aa09eaa61510dc48b27603bd9ea116cd6531a/src/main/java/org/radeox/EngineManager.java#L101-L113
155,589
pip-services3-java/pip-services3-commons-java
src/org/pipservices3/commons/run/Cleaner.java
Cleaner.clearOne
public static void clearOne(String correlationId, Object component) throws ApplicationException { if (component instanceof ICleanable) ((ICleanable) component).clear(correlationId); }
java
public static void clearOne(String correlationId, Object component) throws ApplicationException { if (component instanceof ICleanable) ((ICleanable) component).clear(correlationId); }
[ "public", "static", "void", "clearOne", "(", "String", "correlationId", ",", "Object", "component", ")", "throws", "ApplicationException", "{", "if", "(", "component", "instanceof", "ICleanable", ")", "(", "(", "ICleanable", ")", "component", ")", ".", "clear", "(", "correlationId", ")", ";", "}" ]
Clears state of specific component. To be cleaned state components must implement ICleanable interface. If they don't the call to this method has no effect. @param correlationId (optional) transaction id to trace execution through call chain. @param component the component that is to be cleaned. @throws ApplicationException when errors occured. @see ICleanable
[ "Clears", "state", "of", "specific", "component", "." ]
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/run/Cleaner.java#L24-L28
155,590
pip-services3-java/pip-services3-commons-java
src/org/pipservices3/commons/run/Cleaner.java
Cleaner.clear
public static void clear(String correlationId, Iterable<Object> components) throws ApplicationException { if (components == null) return; for (Object component : components) clearOne(correlationId, component); }
java
public static void clear(String correlationId, Iterable<Object> components) throws ApplicationException { if (components == null) return; for (Object component : components) clearOne(correlationId, component); }
[ "public", "static", "void", "clear", "(", "String", "correlationId", ",", "Iterable", "<", "Object", ">", "components", ")", "throws", "ApplicationException", "{", "if", "(", "components", "==", "null", ")", "return", ";", "for", "(", "Object", "component", ":", "components", ")", "clearOne", "(", "correlationId", ",", "component", ")", ";", "}" ]
Clears state of multiple components. To be cleaned state components must implement ICleanable interface. If they don't the call to this method has no effect. @param correlationId (optional) transaction id to trace execution through call chain. @param components the list of components that are to be cleaned. @throws ApplicationException when errors occured. @see #clearOne(String, Object) @see ICleanable
[ "Clears", "state", "of", "multiple", "components", "." ]
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/run/Cleaner.java#L45-L52
155,591
foundation-runtime/service-directory
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/WSDirectorySocket.java
WSDirectorySocket.connect
@Override synchronized public boolean connect(InetSocketAddress addr){ long now = System.currentTimeMillis(); if(isStarted){ return true; } isStarted = true; String host = addr.getHostName(); int port = addr.getPort(); serverURI = URI.create("ws://" + host + ":" + port + "/ws/service/"); if(LOGGER.isTraceEnabled()){ LOGGER.trace("WebSocket connect to timeOut=" + connectTimeOut + " - " + serverURI.toString()); } client = new WebSocketClient(); doConnect(); synchronized(sessionLock){ long to = connectTimeOut - (System.currentTimeMillis() - now); while(! connected && to > 0){ try { sessionLock.wait(to); } catch (InterruptedException e) { // do nothing. } to = connectTimeOut - (System.currentTimeMillis() - now); } } return true; }
java
@Override synchronized public boolean connect(InetSocketAddress addr){ long now = System.currentTimeMillis(); if(isStarted){ return true; } isStarted = true; String host = addr.getHostName(); int port = addr.getPort(); serverURI = URI.create("ws://" + host + ":" + port + "/ws/service/"); if(LOGGER.isTraceEnabled()){ LOGGER.trace("WebSocket connect to timeOut=" + connectTimeOut + " - " + serverURI.toString()); } client = new WebSocketClient(); doConnect(); synchronized(sessionLock){ long to = connectTimeOut - (System.currentTimeMillis() - now); while(! connected && to > 0){ try { sessionLock.wait(to); } catch (InterruptedException e) { // do nothing. } to = connectTimeOut - (System.currentTimeMillis() - now); } } return true; }
[ "@", "Override", "synchronized", "public", "boolean", "connect", "(", "InetSocketAddress", "addr", ")", "{", "long", "now", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "if", "(", "isStarted", ")", "{", "return", "true", ";", "}", "isStarted", "=", "true", ";", "String", "host", "=", "addr", ".", "getHostName", "(", ")", ";", "int", "port", "=", "addr", ".", "getPort", "(", ")", ";", "serverURI", "=", "URI", ".", "create", "(", "\"ws://\"", "+", "host", "+", "\":\"", "+", "port", "+", "\"/ws/service/\"", ")", ";", "if", "(", "LOGGER", ".", "isTraceEnabled", "(", ")", ")", "{", "LOGGER", ".", "trace", "(", "\"WebSocket connect to timeOut=\"", "+", "connectTimeOut", "+", "\" - \"", "+", "serverURI", ".", "toString", "(", ")", ")", ";", "}", "client", "=", "new", "WebSocketClient", "(", ")", ";", "doConnect", "(", ")", ";", "synchronized", "(", "sessionLock", ")", "{", "long", "to", "=", "connectTimeOut", "-", "(", "System", ".", "currentTimeMillis", "(", ")", "-", "now", ")", ";", "while", "(", "!", "connected", "&&", "to", ">", "0", ")", "{", "try", "{", "sessionLock", ".", "wait", "(", "to", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "// do nothing.", "}", "to", "=", "connectTimeOut", "-", "(", "System", ".", "currentTimeMillis", "(", ")", "-", "now", ")", ";", "}", "}", "return", "true", ";", "}" ]
Connect to the remote socket. once fail or exception, it do the cleanup itself.
[ "Connect", "to", "the", "remote", "socket", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/WSDirectorySocket.java#L107-L141
155,592
foundation-runtime/service-directory
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/WSDirectorySocket.java
WSDirectorySocket.cleanup
@Override synchronized public void cleanup() { LOGGER.info("Cleanup the DirectorySocket."); if(task != null){ task.toStop(); task = null; } if(client != null){ try { client.stop(); } catch (Exception e) { LOGGER.warn("Close WebSocketClient get exception.", e); } client = null; } try { if(session != null){ session.close(); } } catch (IOException e) { LOGGER.warn("Close the WebSocket Session get exception.", e); } if(sessionFuture != null){ try { sessionFuture.cancel(true); } catch (Exception e) { // do nothing } } session = null; sessionFuture = null; websocketStarted = false; connected = false; isStarted = false; }
java
@Override synchronized public void cleanup() { LOGGER.info("Cleanup the DirectorySocket."); if(task != null){ task.toStop(); task = null; } if(client != null){ try { client.stop(); } catch (Exception e) { LOGGER.warn("Close WebSocketClient get exception.", e); } client = null; } try { if(session != null){ session.close(); } } catch (IOException e) { LOGGER.warn("Close the WebSocket Session get exception.", e); } if(sessionFuture != null){ try { sessionFuture.cancel(true); } catch (Exception e) { // do nothing } } session = null; sessionFuture = null; websocketStarted = false; connected = false; isStarted = false; }
[ "@", "Override", "synchronized", "public", "void", "cleanup", "(", ")", "{", "LOGGER", ".", "info", "(", "\"Cleanup the DirectorySocket.\"", ")", ";", "if", "(", "task", "!=", "null", ")", "{", "task", ".", "toStop", "(", ")", ";", "task", "=", "null", ";", "}", "if", "(", "client", "!=", "null", ")", "{", "try", "{", "client", ".", "stop", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "LOGGER", ".", "warn", "(", "\"Close WebSocketClient get exception.\"", ",", "e", ")", ";", "}", "client", "=", "null", ";", "}", "try", "{", "if", "(", "session", "!=", "null", ")", "{", "session", ".", "close", "(", ")", ";", "}", "}", "catch", "(", "IOException", "e", ")", "{", "LOGGER", ".", "warn", "(", "\"Close the WebSocket Session get exception.\"", ",", "e", ")", ";", "}", "if", "(", "sessionFuture", "!=", "null", ")", "{", "try", "{", "sessionFuture", ".", "cancel", "(", "true", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "// do nothing", "}", "}", "session", "=", "null", ";", "sessionFuture", "=", "null", ";", "websocketStarted", "=", "false", ";", "connected", "=", "false", ";", "isStarted", "=", "false", ";", "}" ]
Cleanup the DirectorySocket to original status to connect to another Socket.
[ "Cleanup", "the", "DirectorySocket", "to", "original", "status", "to", "connect", "to", "another", "Socket", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/WSDirectorySocket.java#L169-L208
155,593
foundation-runtime/service-directory
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/WSDirectorySocket.java
WSDirectorySocket.doConnect
private void doConnect(){ task = new SocketDeamonTask(); connectThread = new Thread(task); connectThread.setDaemon(true); connectThread.start(); }
java
private void doConnect(){ task = new SocketDeamonTask(); connectThread = new Thread(task); connectThread.setDaemon(true); connectThread.start(); }
[ "private", "void", "doConnect", "(", ")", "{", "task", "=", "new", "SocketDeamonTask", "(", ")", ";", "connectThread", "=", "new", "Thread", "(", "task", ")", ";", "connectThread", ".", "setDaemon", "(", "true", ")", ";", "connectThread", ".", "start", "(", ")", ";", "}" ]
Do the WebSocket connect.
[ "Do", "the", "WebSocket", "connect", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/connect/WSDirectorySocket.java#L321-L326
155,594
hudson3-plugins/warnings-plugin
src/main/java/hudson/plugins/warnings/parser/DoxygenParser.java
DoxygenParser.parsePriority
private Priority parsePriority(final String warningTypeString) { if (StringUtils.equalsIgnoreCase(warningTypeString, "notice")) { return Priority.LOW; } else if (StringUtils.equalsIgnoreCase(warningTypeString, "warning")) { return Priority.NORMAL; } else if (StringUtils.equalsIgnoreCase(warningTypeString, "error")) { return Priority.HIGH; } else { // empty label or other unexpected input return Priority.HIGH; } }
java
private Priority parsePriority(final String warningTypeString) { if (StringUtils.equalsIgnoreCase(warningTypeString, "notice")) { return Priority.LOW; } else if (StringUtils.equalsIgnoreCase(warningTypeString, "warning")) { return Priority.NORMAL; } else if (StringUtils.equalsIgnoreCase(warningTypeString, "error")) { return Priority.HIGH; } else { // empty label or other unexpected input return Priority.HIGH; } }
[ "private", "Priority", "parsePriority", "(", "final", "String", "warningTypeString", ")", "{", "if", "(", "StringUtils", ".", "equalsIgnoreCase", "(", "warningTypeString", ",", "\"notice\"", ")", ")", "{", "return", "Priority", ".", "LOW", ";", "}", "else", "if", "(", "StringUtils", ".", "equalsIgnoreCase", "(", "warningTypeString", ",", "\"warning\"", ")", ")", "{", "return", "Priority", ".", "NORMAL", ";", "}", "else", "if", "(", "StringUtils", ".", "equalsIgnoreCase", "(", "warningTypeString", ",", "\"error\"", ")", ")", "{", "return", "Priority", ".", "HIGH", ";", "}", "else", "{", "// empty label or other unexpected input", "return", "Priority", ".", "HIGH", ";", "}", "}" ]
Returns the priority ordinal matching the specified warning type string. @param warningTypeString a string containing the warning type returned by a regular expression group matching it in the warnings output. @return the priority
[ "Returns", "the", "priority", "ordinal", "matching", "the", "specified", "warning", "type", "string", "." ]
462c9f3dffede9120173935567392b22520b0966
https://github.com/hudson3-plugins/warnings-plugin/blob/462c9f3dffede9120173935567392b22520b0966/src/main/java/hudson/plugins/warnings/parser/DoxygenParser.java#L134-L148
155,595
pip-services3-java/pip-services3-commons-java
src/org/pipservices3/commons/data/PagingParams.java
PagingParams.getTake
public long getTake(long maxTake) { if (_take == null) return maxTake; if (_take < 0) return 0; if (_take > maxTake) return maxTake; return _take; }
java
public long getTake(long maxTake) { if (_take == null) return maxTake; if (_take < 0) return 0; if (_take > maxTake) return maxTake; return _take; }
[ "public", "long", "getTake", "(", "long", "maxTake", ")", "{", "if", "(", "_take", "==", "null", ")", "return", "maxTake", ";", "if", "(", "_take", "<", "0", ")", "return", "0", ";", "if", "(", "_take", ">", "maxTake", ")", "return", "maxTake", ";", "return", "_take", ";", "}" ]
Gets the number of items to return in a page. @param maxTake the maximum number of items to return. @return the number of items to return.
[ "Gets", "the", "number", "of", "items", "to", "return", "in", "a", "page", "." ]
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/data/PagingParams.java#L96-L104
155,596
pip-services3-java/pip-services3-commons-java
src/org/pipservices3/commons/data/PagingParams.java
PagingParams.fromValue
public static PagingParams fromValue(Object value) { if (value instanceof PagingParams) return (PagingParams) value; AnyValueMap map = AnyValueMap.fromValue(value); return PagingParams.fromMap(map); }
java
public static PagingParams fromValue(Object value) { if (value instanceof PagingParams) return (PagingParams) value; AnyValueMap map = AnyValueMap.fromValue(value); return PagingParams.fromMap(map); }
[ "public", "static", "PagingParams", "fromValue", "(", "Object", "value", ")", "{", "if", "(", "value", "instanceof", "PagingParams", ")", "return", "(", "PagingParams", ")", "value", ";", "AnyValueMap", "map", "=", "AnyValueMap", ".", "fromValue", "(", "value", ")", ";", "return", "PagingParams", ".", "fromMap", "(", "map", ")", ";", "}" ]
Converts specified value into PagingParams. @param value value to be converted @return a newly created PagingParams.
[ "Converts", "specified", "value", "into", "PagingParams", "." ]
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/data/PagingParams.java#L138-L144
155,597
pip-services3-java/pip-services3-commons-java
src/org/pipservices3/commons/data/PagingParams.java
PagingParams.fromTuples
public static PagingParams fromTuples(Object... tuples) { AnyValueMap map = AnyValueMap.fromTuples(tuples); return PagingParams.fromMap(map); }
java
public static PagingParams fromTuples(Object... tuples) { AnyValueMap map = AnyValueMap.fromTuples(tuples); return PagingParams.fromMap(map); }
[ "public", "static", "PagingParams", "fromTuples", "(", "Object", "...", "tuples", ")", "{", "AnyValueMap", "map", "=", "AnyValueMap", ".", "fromTuples", "(", "tuples", ")", ";", "return", "PagingParams", ".", "fromMap", "(", "map", ")", ";", "}" ]
Creates a new PagingParams from a list of key-value pairs called tuples. @param tuples a list of values where odd elements are keys and the following even elements are values @return a newly created PagingParams.
[ "Creates", "a", "new", "PagingParams", "from", "a", "list", "of", "key", "-", "value", "pairs", "called", "tuples", "." ]
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/data/PagingParams.java#L153-L156
155,598
pip-services3-java/pip-services3-commons-java
src/org/pipservices3/commons/data/PagingParams.java
PagingParams.fromMap
public static PagingParams fromMap(AnyValueMap map) { Long skip = map.getAsNullableLong("skip"); Long take = map.getAsNullableLong("take"); boolean total = map.getAsBooleanWithDefault("total", true); return new PagingParams(skip, take, total); }
java
public static PagingParams fromMap(AnyValueMap map) { Long skip = map.getAsNullableLong("skip"); Long take = map.getAsNullableLong("take"); boolean total = map.getAsBooleanWithDefault("total", true); return new PagingParams(skip, take, total); }
[ "public", "static", "PagingParams", "fromMap", "(", "AnyValueMap", "map", ")", "{", "Long", "skip", "=", "map", ".", "getAsNullableLong", "(", "\"skip\"", ")", ";", "Long", "take", "=", "map", ".", "getAsNullableLong", "(", "\"take\"", ")", ";", "boolean", "total", "=", "map", ".", "getAsBooleanWithDefault", "(", "\"total\"", ",", "true", ")", ";", "return", "new", "PagingParams", "(", "skip", ",", "take", ",", "total", ")", ";", "}" ]
Creates a new PagingParams and sets it parameters from the AnyValueMap map @param map a AnyValueMap to initialize this PagingParams @return a newly created PagingParams.
[ "Creates", "a", "new", "PagingParams", "and", "sets", "it", "parameters", "from", "the", "AnyValueMap", "map" ]
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/data/PagingParams.java#L164-L169
155,599
pierre/eventtracker
smile/src/main/java/com/ning/metrics/eventtracker/HttpCollectorFactory.java
HttpCollectorFactory.createHttpController
public static synchronized CollectorController createHttpController( final String collectorHost, final int collectorPort, final EventType eventType, final long httpMaxWaitTimeInMillis, final long httpMaxKeepAliveInMillis, final String spoolDirectoryName, final boolean isFlushEnabled, final int flushIntervalInSeconds, final SyncType syncType, final int syncBatchSize, final long maxUncommittedWriteCount, final int maxUncommittedPeriodInSeconds, final int httpWorkersPoolSize ) throws IOException { if (singletonController == null) { singletonController = new HttpCollectorFactory( collectorHost, collectorPort, eventType, httpMaxWaitTimeInMillis, httpMaxKeepAliveInMillis, spoolDirectoryName, isFlushEnabled, flushIntervalInSeconds, syncType, syncBatchSize, maxUncommittedWriteCount, maxUncommittedPeriodInSeconds, httpWorkersPoolSize ).get(); } return singletonController; }
java
public static synchronized CollectorController createHttpController( final String collectorHost, final int collectorPort, final EventType eventType, final long httpMaxWaitTimeInMillis, final long httpMaxKeepAliveInMillis, final String spoolDirectoryName, final boolean isFlushEnabled, final int flushIntervalInSeconds, final SyncType syncType, final int syncBatchSize, final long maxUncommittedWriteCount, final int maxUncommittedPeriodInSeconds, final int httpWorkersPoolSize ) throws IOException { if (singletonController == null) { singletonController = new HttpCollectorFactory( collectorHost, collectorPort, eventType, httpMaxWaitTimeInMillis, httpMaxKeepAliveInMillis, spoolDirectoryName, isFlushEnabled, flushIntervalInSeconds, syncType, syncBatchSize, maxUncommittedWriteCount, maxUncommittedPeriodInSeconds, httpWorkersPoolSize ).get(); } return singletonController; }
[ "public", "static", "synchronized", "CollectorController", "createHttpController", "(", "final", "String", "collectorHost", ",", "final", "int", "collectorPort", ",", "final", "EventType", "eventType", ",", "final", "long", "httpMaxWaitTimeInMillis", ",", "final", "long", "httpMaxKeepAliveInMillis", ",", "final", "String", "spoolDirectoryName", ",", "final", "boolean", "isFlushEnabled", ",", "final", "int", "flushIntervalInSeconds", ",", "final", "SyncType", "syncType", ",", "final", "int", "syncBatchSize", ",", "final", "long", "maxUncommittedWriteCount", ",", "final", "int", "maxUncommittedPeriodInSeconds", ",", "final", "int", "httpWorkersPoolSize", ")", "throws", "IOException", "{", "if", "(", "singletonController", "==", "null", ")", "{", "singletonController", "=", "new", "HttpCollectorFactory", "(", "collectorHost", ",", "collectorPort", ",", "eventType", ",", "httpMaxWaitTimeInMillis", ",", "httpMaxKeepAliveInMillis", ",", "spoolDirectoryName", ",", "isFlushEnabled", ",", "flushIntervalInSeconds", ",", "syncType", ",", "syncBatchSize", ",", "maxUncommittedWriteCount", ",", "maxUncommittedPeriodInSeconds", ",", "httpWorkersPoolSize", ")", ".", "get", "(", ")", ";", "}", "return", "singletonController", ";", "}" ]
Factory method for tests cases
[ "Factory", "method", "for", "tests", "cases" ]
d47e74f11b05500fc31eeb43448aa6316a1318f6
https://github.com/pierre/eventtracker/blob/d47e74f11b05500fc31eeb43448aa6316a1318f6/smile/src/main/java/com/ning/metrics/eventtracker/HttpCollectorFactory.java#L41-L76