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,700
xmlet/XsdAsmFaster
src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmInterfaces.java
XsdAsmInterfaces.addAttributeGroup
private void addAttributeGroup(XsdAttributeGroup attributeGroup) { String interfaceName = firstToUpper(attributeGroup.getName()); if (!attributeGroupInterfaces.containsKey(interfaceName)){ List<XsdAttribute> ownElements = attributeGroup.getXsdElements() .filter(attribute -> attribute.getParent().equals(attributeGroup)) .map(attribute -> (XsdAttribute) attribute) .collect(Collectors.toList()); List<String> parentNames = attributeGroup.getAttributeGroups().stream().map(XsdNamedElements::getName).collect(Collectors.toList()); AttributeHierarchyItem attributeHierarchyItemItem = new AttributeHierarchyItem(parentNames, ownElements); attributeGroupInterfaces.put(interfaceName, attributeHierarchyItemItem); attributeGroup.getAttributeGroups().forEach(this::addAttributeGroup); } }
java
private void addAttributeGroup(XsdAttributeGroup attributeGroup) { String interfaceName = firstToUpper(attributeGroup.getName()); if (!attributeGroupInterfaces.containsKey(interfaceName)){ List<XsdAttribute> ownElements = attributeGroup.getXsdElements() .filter(attribute -> attribute.getParent().equals(attributeGroup)) .map(attribute -> (XsdAttribute) attribute) .collect(Collectors.toList()); List<String> parentNames = attributeGroup.getAttributeGroups().stream().map(XsdNamedElements::getName).collect(Collectors.toList()); AttributeHierarchyItem attributeHierarchyItemItem = new AttributeHierarchyItem(parentNames, ownElements); attributeGroupInterfaces.put(interfaceName, attributeHierarchyItemItem); attributeGroup.getAttributeGroups().forEach(this::addAttributeGroup); } }
[ "private", "void", "addAttributeGroup", "(", "XsdAttributeGroup", "attributeGroup", ")", "{", "String", "interfaceName", "=", "firstToUpper", "(", "attributeGroup", ".", "getName", "(", ")", ")", ";", "if", "(", "!", "attributeGroupInterfaces", ".", "containsKey", "(", "interfaceName", ")", ")", "{", "List", "<", "XsdAttribute", ">", "ownElements", "=", "attributeGroup", ".", "getXsdElements", "(", ")", ".", "filter", "(", "attribute", "->", "attribute", ".", "getParent", "(", ")", ".", "equals", "(", "attributeGroup", ")", ")", ".", "map", "(", "attribute", "->", "(", "XsdAttribute", ")", "attribute", ")", ".", "collect", "(", "Collectors", ".", "toList", "(", ")", ")", ";", "List", "<", "String", ">", "parentNames", "=", "attributeGroup", ".", "getAttributeGroups", "(", ")", ".", "stream", "(", ")", ".", "map", "(", "XsdNamedElements", "::", "getName", ")", ".", "collect", "(", "Collectors", ".", "toList", "(", ")", ")", ";", "AttributeHierarchyItem", "attributeHierarchyItemItem", "=", "new", "AttributeHierarchyItem", "(", "parentNames", ",", "ownElements", ")", ";", "attributeGroupInterfaces", ".", "put", "(", "interfaceName", ",", "attributeHierarchyItemItem", ")", ";", "attributeGroup", ".", "getAttributeGroups", "(", ")", ".", "forEach", "(", "this", "::", "addAttributeGroup", ")", ";", "}", "}" ]
Adds information about the attribute group interface to the attributeGroupInterfaces variable. @param attributeGroup The attributeGroup to add.
[ "Adds", "information", "about", "the", "attribute", "group", "interface", "to", "the", "attributeGroupInterfaces", "variable", "." ]
ccb78f9dd4b957ad5ac1ca349eaf24338c421e94
https://github.com/xmlet/XsdAsmFaster/blob/ccb78f9dd4b957ad5ac1ca349eaf24338c421e94/src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmInterfaces.java#L275-L291
155,701
xmlet/XsdAsmFaster
src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmInterfaces.java
XsdAsmInterfaces.getAttributeGroupSignature
private StringBuilder getAttributeGroupSignature(String[] interfaces, String apiName) { StringBuilder signature = new StringBuilder("<T::L" + elementType + "<TT;TZ;>;Z::" + elementTypeDesc + ">" + JAVA_OBJECT_DESC); if (interfaces.length == 0){ signature.append("L").append(elementType).append("<TT;TZ;>;"); } else { for (String anInterface : interfaces) { signature.append("L").append(getFullClassTypeName(anInterface, apiName)).append("<TT;TZ;>;"); } } return signature; }
java
private StringBuilder getAttributeGroupSignature(String[] interfaces, String apiName) { StringBuilder signature = new StringBuilder("<T::L" + elementType + "<TT;TZ;>;Z::" + elementTypeDesc + ">" + JAVA_OBJECT_DESC); if (interfaces.length == 0){ signature.append("L").append(elementType).append("<TT;TZ;>;"); } else { for (String anInterface : interfaces) { signature.append("L").append(getFullClassTypeName(anInterface, apiName)).append("<TT;TZ;>;"); } } return signature; }
[ "private", "StringBuilder", "getAttributeGroupSignature", "(", "String", "[", "]", "interfaces", ",", "String", "apiName", ")", "{", "StringBuilder", "signature", "=", "new", "StringBuilder", "(", "\"<T::L\"", "+", "elementType", "+", "\"<TT;TZ;>;Z::\"", "+", "elementTypeDesc", "+", "\">\"", "+", "JAVA_OBJECT_DESC", ")", ";", "if", "(", "interfaces", ".", "length", "==", "0", ")", "{", "signature", ".", "append", "(", "\"L\"", ")", ".", "append", "(", "elementType", ")", ".", "append", "(", "\"<TT;TZ;>;\"", ")", ";", "}", "else", "{", "for", "(", "String", "anInterface", ":", "interfaces", ")", "{", "signature", ".", "append", "(", "\"L\"", ")", ".", "append", "(", "getFullClassTypeName", "(", "anInterface", ",", "apiName", ")", ")", ".", "append", "(", "\"<TT;TZ;>;\"", ")", ";", "}", "}", "return", "signature", ";", "}" ]
Obtains the signature for the attribute group interfaces based on the implemented interfaces. @param interfaces The implemented interfaces. @return The signature of this interface.
[ "Obtains", "the", "signature", "for", "the", "attribute", "group", "interfaces", "based", "on", "the", "implemented", "interfaces", "." ]
ccb78f9dd4b957ad5ac1ca349eaf24338c421e94
https://github.com/xmlet/XsdAsmFaster/blob/ccb78f9dd4b957ad5ac1ca349eaf24338c421e94/src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmInterfaces.java#L297-L309
155,702
xmlet/XsdAsmFaster
src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmInterfaces.java
XsdAsmInterfaces.getAttributeGroupObjectInterfaces
private String[] getAttributeGroupObjectInterfaces(List<String> parentsName) { return listToArray(parentsName.stream().map(XsdAsmUtils::firstToUpper).collect(Collectors.toList()), CUSTOM_ATTRIBUTE_GROUP); }
java
private String[] getAttributeGroupObjectInterfaces(List<String> parentsName) { return listToArray(parentsName.stream().map(XsdAsmUtils::firstToUpper).collect(Collectors.toList()), CUSTOM_ATTRIBUTE_GROUP); }
[ "private", "String", "[", "]", "getAttributeGroupObjectInterfaces", "(", "List", "<", "String", ">", "parentsName", ")", "{", "return", "listToArray", "(", "parentsName", ".", "stream", "(", ")", ".", "map", "(", "XsdAsmUtils", "::", "firstToUpper", ")", ".", "collect", "(", "Collectors", ".", "toList", "(", ")", ")", ",", "CUSTOM_ATTRIBUTE_GROUP", ")", ";", "}" ]
Obtains an array with the names of the interfaces implemented by a attribute group interface with the given parents, as in interfaces that will be extended. @param parentsName The list of interfaces that this interface will extend. @return A {@link String} array containing the names of the interfaces that this interface will extend.
[ "Obtains", "an", "array", "with", "the", "names", "of", "the", "interfaces", "implemented", "by", "a", "attribute", "group", "interface", "with", "the", "given", "parents", "as", "in", "interfaces", "that", "will", "be", "extended", "." ]
ccb78f9dd4b957ad5ac1ca349eaf24338c421e94
https://github.com/xmlet/XsdAsmFaster/blob/ccb78f9dd4b957ad5ac1ca349eaf24338c421e94/src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmInterfaces.java#L317-L319
155,703
xmlet/XsdAsmFaster
src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmInterfaces.java
XsdAsmInterfaces.getInterfaces
String[] getInterfaces(XsdElement element, String apiName) { String[] attributeGroupInterfacesArr = getAttributeGroupInterfaces(element); String[] elementGroupInterfacesArr = getElementInterfaces(element, apiName); String[] hierarchyInterfacesArr = getHierarchyInterfaces(element, apiName); return ArrayUtils.addAll(ArrayUtils.addAll(attributeGroupInterfacesArr, elementGroupInterfacesArr), hierarchyInterfacesArr); }
java
String[] getInterfaces(XsdElement element, String apiName) { String[] attributeGroupInterfacesArr = getAttributeGroupInterfaces(element); String[] elementGroupInterfacesArr = getElementInterfaces(element, apiName); String[] hierarchyInterfacesArr = getHierarchyInterfaces(element, apiName); return ArrayUtils.addAll(ArrayUtils.addAll(attributeGroupInterfacesArr, elementGroupInterfacesArr), hierarchyInterfacesArr); }
[ "String", "[", "]", "getInterfaces", "(", "XsdElement", "element", ",", "String", "apiName", ")", "{", "String", "[", "]", "attributeGroupInterfacesArr", "=", "getAttributeGroupInterfaces", "(", "element", ")", ";", "String", "[", "]", "elementGroupInterfacesArr", "=", "getElementInterfaces", "(", "element", ",", "apiName", ")", ";", "String", "[", "]", "hierarchyInterfacesArr", "=", "getHierarchyInterfaces", "(", "element", ",", "apiName", ")", ";", "return", "ArrayUtils", ".", "addAll", "(", "ArrayUtils", ".", "addAll", "(", "attributeGroupInterfacesArr", ",", "elementGroupInterfacesArr", ")", ",", "hierarchyInterfacesArr", ")", ";", "}" ]
Obtains all the interfaces that a given element will implement. @param element The {@link XsdElement} in which the class will be based. @param apiName The name of the generated fluent interface. @return A {@link String} array with all the interface names.
[ "Obtains", "all", "the", "interfaces", "that", "a", "given", "element", "will", "implement", "." ]
ccb78f9dd4b957ad5ac1ca349eaf24338c421e94
https://github.com/xmlet/XsdAsmFaster/blob/ccb78f9dd4b957ad5ac1ca349eaf24338c421e94/src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmInterfaces.java#L327-L333
155,704
xmlet/XsdAsmFaster
src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmInterfaces.java
XsdAsmInterfaces.sequenceMethod
private void sequenceMethod(Stream<XsdAbstractElement> xsdElements, String className, int interfaceIndex, String apiName, String groupName) { pendingSequenceMethods.put(className, classWriter -> createSequence(classWriter, xsdElements, className, interfaceIndex, apiName, groupName)); }
java
private void sequenceMethod(Stream<XsdAbstractElement> xsdElements, String className, int interfaceIndex, String apiName, String groupName) { pendingSequenceMethods.put(className, classWriter -> createSequence(classWriter, xsdElements, className, interfaceIndex, apiName, groupName)); }
[ "private", "void", "sequenceMethod", "(", "Stream", "<", "XsdAbstractElement", ">", "xsdElements", ",", "String", "className", ",", "int", "interfaceIndex", ",", "String", "apiName", ",", "String", "groupName", ")", "{", "pendingSequenceMethods", ".", "put", "(", "className", ",", "classWriter", "->", "createSequence", "(", "classWriter", ",", "xsdElements", ",", "className", ",", "interfaceIndex", ",", "apiName", ",", "groupName", ")", ")", ";", "}" ]
Postpones the sequence method creation due to solution design. @param xsdElements A {@link Stream} of {@link XsdElement}, ordered, that represent the sequence. @param className The className of the element which contains this sequence. @param interfaceIndex The current interfaceIndex that serves as a base to distinguish interface names. @param apiName The name of the generated fluent interface. @param groupName The groupName, that indicates if this sequence belongs to a group.
[ "Postpones", "the", "sequence", "method", "creation", "due", "to", "solution", "design", "." ]
ccb78f9dd4b957ad5ac1ca349eaf24338c421e94
https://github.com/xmlet/XsdAsmFaster/blob/ccb78f9dd4b957ad5ac1ca349eaf24338c421e94/src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmInterfaces.java#L370-L372
155,705
xmlet/XsdAsmFaster
src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmInterfaces.java
XsdAsmInterfaces.createSequence
private void createSequence(ClassWriter classWriter, Stream<XsdAbstractElement> xsdElements, String className, int interfaceIndex, String apiName, String groupName) { SequenceMethodInfo sequenceInfo = getSequenceInfo(xsdElements, className, interfaceIndex, 0, apiName, groupName); List<XsdAbstractElement> sequenceList = new ArrayList<>(); List<String> sequenceNames = new ArrayList<>(); sequenceList.addAll(sequenceInfo.getSequenceElements()); sequenceNames.add(className); sequenceNames.addAll(sequenceInfo.getSequenceElementNames()); for (int i = 0; i < sequenceNames.size(); i++) { boolean isLast = i == sequenceNames.size() - 1; boolean willPointToLast = i == sequenceNames.size() - 2; String typeName = getNextTypeName(className, groupName, firstToLower(getCleanName(sequenceNames.get(i))), isLast); if (isLast){ if (!typeName.equals(className)){ createdElements.put(getCleanName(typeName), null); writeClassToFile(typeName, generateInnerSequenceClass(typeName, className, apiName), apiName); } break; } String nextTypeName = getNextTypeName(className, groupName, firstToLower(getCleanName(sequenceNames.get(i + 1))), willPointToLast); createSequenceClasses(sequenceList.get(i), classWriter, className, typeName, nextTypeName, apiName, i == 0); ++interfaceIndex; } }
java
private void createSequence(ClassWriter classWriter, Stream<XsdAbstractElement> xsdElements, String className, int interfaceIndex, String apiName, String groupName) { SequenceMethodInfo sequenceInfo = getSequenceInfo(xsdElements, className, interfaceIndex, 0, apiName, groupName); List<XsdAbstractElement> sequenceList = new ArrayList<>(); List<String> sequenceNames = new ArrayList<>(); sequenceList.addAll(sequenceInfo.getSequenceElements()); sequenceNames.add(className); sequenceNames.addAll(sequenceInfo.getSequenceElementNames()); for (int i = 0; i < sequenceNames.size(); i++) { boolean isLast = i == sequenceNames.size() - 1; boolean willPointToLast = i == sequenceNames.size() - 2; String typeName = getNextTypeName(className, groupName, firstToLower(getCleanName(sequenceNames.get(i))), isLast); if (isLast){ if (!typeName.equals(className)){ createdElements.put(getCleanName(typeName), null); writeClassToFile(typeName, generateInnerSequenceClass(typeName, className, apiName), apiName); } break; } String nextTypeName = getNextTypeName(className, groupName, firstToLower(getCleanName(sequenceNames.get(i + 1))), willPointToLast); createSequenceClasses(sequenceList.get(i), classWriter, className, typeName, nextTypeName, apiName, i == 0); ++interfaceIndex; } }
[ "private", "void", "createSequence", "(", "ClassWriter", "classWriter", ",", "Stream", "<", "XsdAbstractElement", ">", "xsdElements", ",", "String", "className", ",", "int", "interfaceIndex", ",", "String", "apiName", ",", "String", "groupName", ")", "{", "SequenceMethodInfo", "sequenceInfo", "=", "getSequenceInfo", "(", "xsdElements", ",", "className", ",", "interfaceIndex", ",", "0", ",", "apiName", ",", "groupName", ")", ";", "List", "<", "XsdAbstractElement", ">", "sequenceList", "=", "new", "ArrayList", "<>", "(", ")", ";", "List", "<", "String", ">", "sequenceNames", "=", "new", "ArrayList", "<>", "(", ")", ";", "sequenceList", ".", "addAll", "(", "sequenceInfo", ".", "getSequenceElements", "(", ")", ")", ";", "sequenceNames", ".", "add", "(", "className", ")", ";", "sequenceNames", ".", "addAll", "(", "sequenceInfo", ".", "getSequenceElementNames", "(", ")", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "sequenceNames", ".", "size", "(", ")", ";", "i", "++", ")", "{", "boolean", "isLast", "=", "i", "==", "sequenceNames", ".", "size", "(", ")", "-", "1", ";", "boolean", "willPointToLast", "=", "i", "==", "sequenceNames", ".", "size", "(", ")", "-", "2", ";", "String", "typeName", "=", "getNextTypeName", "(", "className", ",", "groupName", ",", "firstToLower", "(", "getCleanName", "(", "sequenceNames", ".", "get", "(", "i", ")", ")", ")", ",", "isLast", ")", ";", "if", "(", "isLast", ")", "{", "if", "(", "!", "typeName", ".", "equals", "(", "className", ")", ")", "{", "createdElements", ".", "put", "(", "getCleanName", "(", "typeName", ")", ",", "null", ")", ";", "writeClassToFile", "(", "typeName", ",", "generateInnerSequenceClass", "(", "typeName", ",", "className", ",", "apiName", ")", ",", "apiName", ")", ";", "}", "break", ";", "}", "String", "nextTypeName", "=", "getNextTypeName", "(", "className", ",", "groupName", ",", "firstToLower", "(", "getCleanName", "(", "sequenceNames", ".", "get", "(", "i", "+", "1", ")", ")", ")", ",", "willPointToLast", ")", ";", "createSequenceClasses", "(", "sequenceList", ".", "get", "(", "i", ")", ",", "classWriter", ",", "className", ",", "typeName", ",", "nextTypeName", ",", "apiName", ",", "i", "==", "0", ")", ";", "++", "interfaceIndex", ";", "}", "}" ]
Obtains sequence information and creates all the required classes and methods. @param classWriter The {@link ClassWriter} of the class that contains the sequence. @param xsdElements A {@link Stream} of {@link XsdElement}, ordered, that represent the sequence. @param className The className of the element which contains this sequence. @param interfaceIndex The current interfaceIndex that serves as a base to distinguish interface names. @param apiName The name of the generated fluent interface. @param groupName The groupName, that indicates if this sequence belongs to a group.
[ "Obtains", "sequence", "information", "and", "creates", "all", "the", "required", "classes", "and", "methods", "." ]
ccb78f9dd4b957ad5ac1ca349eaf24338c421e94
https://github.com/xmlet/XsdAsmFaster/blob/ccb78f9dd4b957ad5ac1ca349eaf24338c421e94/src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmInterfaces.java#L383-L413
155,706
xmlet/XsdAsmFaster
src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmInterfaces.java
XsdAsmInterfaces.createSequenceClasses
private void createSequenceClasses(XsdAbstractElement sequenceElement, ClassWriter classWriter, String className, String typeName, String nextTypeName, String apiName, boolean isFirst){ List<XsdElement> elements = null; if (sequenceElement instanceof XsdElement) { elements = Collections.singletonList((XsdElement) sequenceElement); } if (sequenceElement instanceof XsdGroup || sequenceElement instanceof XsdChoice || sequenceElement instanceof XsdAll) { elements = getAllElementsRecursively(sequenceElement); } if (elements != null){ if (isFirst){ createFirstSequenceInterface(classWriter, className, nextTypeName, apiName, elements); } else { createElementsForSequence(className, typeName, nextTypeName, apiName, elements); } } }
java
private void createSequenceClasses(XsdAbstractElement sequenceElement, ClassWriter classWriter, String className, String typeName, String nextTypeName, String apiName, boolean isFirst){ List<XsdElement> elements = null; if (sequenceElement instanceof XsdElement) { elements = Collections.singletonList((XsdElement) sequenceElement); } if (sequenceElement instanceof XsdGroup || sequenceElement instanceof XsdChoice || sequenceElement instanceof XsdAll) { elements = getAllElementsRecursively(sequenceElement); } if (elements != null){ if (isFirst){ createFirstSequenceInterface(classWriter, className, nextTypeName, apiName, elements); } else { createElementsForSequence(className, typeName, nextTypeName, apiName, elements); } } }
[ "private", "void", "createSequenceClasses", "(", "XsdAbstractElement", "sequenceElement", ",", "ClassWriter", "classWriter", ",", "String", "className", ",", "String", "typeName", ",", "String", "nextTypeName", ",", "String", "apiName", ",", "boolean", "isFirst", ")", "{", "List", "<", "XsdElement", ">", "elements", "=", "null", ";", "if", "(", "sequenceElement", "instanceof", "XsdElement", ")", "{", "elements", "=", "Collections", ".", "singletonList", "(", "(", "XsdElement", ")", "sequenceElement", ")", ";", "}", "if", "(", "sequenceElement", "instanceof", "XsdGroup", "||", "sequenceElement", "instanceof", "XsdChoice", "||", "sequenceElement", "instanceof", "XsdAll", ")", "{", "elements", "=", "getAllElementsRecursively", "(", "sequenceElement", ")", ";", "}", "if", "(", "elements", "!=", "null", ")", "{", "if", "(", "isFirst", ")", "{", "createFirstSequenceInterface", "(", "classWriter", ",", "className", ",", "nextTypeName", ",", "apiName", ",", "elements", ")", ";", "}", "else", "{", "createElementsForSequence", "(", "className", ",", "typeName", ",", "nextTypeName", ",", "apiName", ",", "elements", ")", ";", "}", "}", "}" ]
Creates classes and methods required to implement the sequence. @param sequenceElement The current sequence element. @param classWriter The {@link ClassWriter} of the first class, which contains the sequence. @param className The name of the class which contains the sequence. @param typeName The current sequence element type name. @param nextTypeName The next sequence element type name. @param apiName The name of the generated fluent interface. @param isFirst Indication if this is the first element of the sequence.
[ "Creates", "classes", "and", "methods", "required", "to", "implement", "the", "sequence", "." ]
ccb78f9dd4b957ad5ac1ca349eaf24338c421e94
https://github.com/xmlet/XsdAsmFaster/blob/ccb78f9dd4b957ad5ac1ca349eaf24338c421e94/src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmInterfaces.java#L425-L443
155,707
xmlet/XsdAsmFaster
src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmInterfaces.java
XsdAsmInterfaces.createFirstSequenceInterface
private void createFirstSequenceInterface(ClassWriter classWriter, String className, String nextTypeName, String apiName, List<XsdElement> elements){ elements.forEach(element -> generateSequenceMethod(classWriter, className, getJavaType(element.getType()), getCleanName(element.getName()), className, nextTypeName, apiName)); elements.forEach(element -> createElement(element, apiName)); }
java
private void createFirstSequenceInterface(ClassWriter classWriter, String className, String nextTypeName, String apiName, List<XsdElement> elements){ elements.forEach(element -> generateSequenceMethod(classWriter, className, getJavaType(element.getType()), getCleanName(element.getName()), className, nextTypeName, apiName)); elements.forEach(element -> createElement(element, apiName)); }
[ "private", "void", "createFirstSequenceInterface", "(", "ClassWriter", "classWriter", ",", "String", "className", ",", "String", "nextTypeName", ",", "String", "apiName", ",", "List", "<", "XsdElement", ">", "elements", ")", "{", "elements", ".", "forEach", "(", "element", "->", "generateSequenceMethod", "(", "classWriter", ",", "className", ",", "getJavaType", "(", "element", ".", "getType", "(", ")", ")", ",", "getCleanName", "(", "element", ".", "getName", "(", ")", ")", ",", "className", ",", "nextTypeName", ",", "apiName", ")", ")", ";", "elements", ".", "forEach", "(", "element", "->", "createElement", "(", "element", ",", "apiName", ")", ")", ";", "}" ]
Adds a method to the element which contains the sequence. @param classWriter The {@link ClassWriter} of the class which contains the sequence. @param className The name of the class which contains the sequence. @param nextTypeName The next sequence type name. @param apiName The name of the generated fluent interface. @param elements A {@link List} of {@link XsdElement} that are the first sequence value.
[ "Adds", "a", "method", "to", "the", "element", "which", "contains", "the", "sequence", "." ]
ccb78f9dd4b957ad5ac1ca349eaf24338c421e94
https://github.com/xmlet/XsdAsmFaster/blob/ccb78f9dd4b957ad5ac1ca349eaf24338c421e94/src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmInterfaces.java#L453-L457
155,708
xmlet/XsdAsmFaster
src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmInterfaces.java
XsdAsmInterfaces.getNextTypeName
private String getNextTypeName(String className, String groupName, String sequenceName, boolean isLast){ if (isLast) return groupName == null ? className + "Complete" : className; else return className + firstToUpper(sequenceName); }
java
private String getNextTypeName(String className, String groupName, String sequenceName, boolean isLast){ if (isLast) return groupName == null ? className + "Complete" : className; else return className + firstToUpper(sequenceName); }
[ "private", "String", "getNextTypeName", "(", "String", "className", ",", "String", "groupName", ",", "String", "sequenceName", ",", "boolean", "isLast", ")", "{", "if", "(", "isLast", ")", "return", "groupName", "==", "null", "?", "className", "+", "\"Complete\"", ":", "className", ";", "else", "return", "className", "+", "firstToUpper", "(", "sequenceName", ")", ";", "}" ]
Obtains the name of the next type of the sequence. @param className The name of the class which contains the sequence. @param groupName The groupName of this sequence, if any. @param sequenceName The sequence name. @param isLast Indication if the next type will be the last of the sequence. @return The next sequence type name.
[ "Obtains", "the", "name", "of", "the", "next", "type", "of", "the", "sequence", "." ]
ccb78f9dd4b957ad5ac1ca349eaf24338c421e94
https://github.com/xmlet/XsdAsmFaster/blob/ccb78f9dd4b957ad5ac1ca349eaf24338c421e94/src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmInterfaces.java#L466-L471
155,709
xmlet/XsdAsmFaster
src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmInterfaces.java
XsdAsmInterfaces.createElementsForSequence
private void createElementsForSequence(String className, String typeName, String nextTypeName, String apiName, List<XsdElement> sequenceElements) { ClassWriter classWriter = generateInnerSequenceClass(typeName, className, apiName); sequenceElements.forEach(sequenceElement -> generateSequenceMethod(classWriter, className, getJavaType(sequenceElement.getType()), getCleanName(sequenceElement.getName()), typeName, nextTypeName, apiName)); sequenceElements.forEach(element -> createElement(element, apiName)); addToCreateElements(typeName); writeClassToFile(typeName, classWriter, apiName); }
java
private void createElementsForSequence(String className, String typeName, String nextTypeName, String apiName, List<XsdElement> sequenceElements) { ClassWriter classWriter = generateInnerSequenceClass(typeName, className, apiName); sequenceElements.forEach(sequenceElement -> generateSequenceMethod(classWriter, className, getJavaType(sequenceElement.getType()), getCleanName(sequenceElement.getName()), typeName, nextTypeName, apiName)); sequenceElements.forEach(element -> createElement(element, apiName)); addToCreateElements(typeName); writeClassToFile(typeName, classWriter, apiName); }
[ "private", "void", "createElementsForSequence", "(", "String", "className", ",", "String", "typeName", ",", "String", "nextTypeName", ",", "String", "apiName", ",", "List", "<", "XsdElement", ">", "sequenceElements", ")", "{", "ClassWriter", "classWriter", "=", "generateInnerSequenceClass", "(", "typeName", ",", "className", ",", "apiName", ")", ";", "sequenceElements", ".", "forEach", "(", "sequenceElement", "->", "generateSequenceMethod", "(", "classWriter", ",", "className", ",", "getJavaType", "(", "sequenceElement", ".", "getType", "(", ")", ")", ",", "getCleanName", "(", "sequenceElement", ".", "getName", "(", ")", ")", ",", "typeName", ",", "nextTypeName", ",", "apiName", ")", ")", ";", "sequenceElements", ".", "forEach", "(", "element", "->", "createElement", "(", "element", ",", "apiName", ")", ")", ";", "addToCreateElements", "(", "typeName", ")", ";", "writeClassToFile", "(", "typeName", ",", "classWriter", ",", "apiName", ")", ";", "}" ]
Creates the inner classes that are used to support the sequence behaviour and the respective sequence methods. @param className The name of the class which contains the sequence. @param typeName The name of the next type to return. @param apiName The name of the generated fluent interface. @param nextTypeName The nextTypeName of the element that will implement the sequence. @param sequenceElements The elements that serves as base to create this interface.
[ "Creates", "the", "inner", "classes", "that", "are", "used", "to", "support", "the", "sequence", "behaviour", "and", "the", "respective", "sequence", "methods", "." ]
ccb78f9dd4b957ad5ac1ca349eaf24338c421e94
https://github.com/xmlet/XsdAsmFaster/blob/ccb78f9dd4b957ad5ac1ca349eaf24338c421e94/src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmInterfaces.java#L481-L492
155,710
xmlet/XsdAsmFaster
src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmInterfaces.java
XsdAsmInterfaces.generateInnerSequenceClass
private ClassWriter generateInnerSequenceClass(String typeName, String className, String apiName) { ClassWriter classWriter = generateClass(typeName, JAVA_OBJECT, new String[] {CUSTOM_ATTRIBUTE_GROUP}, getClassSignature(new String[]{CUSTOM_ATTRIBUTE_GROUP}, typeName, apiName), ACC_PUBLIC + ACC_SUPER, apiName); generateClassMethods(classWriter, typeName, className, apiName, false); return classWriter; }
java
private ClassWriter generateInnerSequenceClass(String typeName, String className, String apiName) { ClassWriter classWriter = generateClass(typeName, JAVA_OBJECT, new String[] {CUSTOM_ATTRIBUTE_GROUP}, getClassSignature(new String[]{CUSTOM_ATTRIBUTE_GROUP}, typeName, apiName), ACC_PUBLIC + ACC_SUPER, apiName); generateClassMethods(classWriter, typeName, className, apiName, false); return classWriter; }
[ "private", "ClassWriter", "generateInnerSequenceClass", "(", "String", "typeName", ",", "String", "className", ",", "String", "apiName", ")", "{", "ClassWriter", "classWriter", "=", "generateClass", "(", "typeName", ",", "JAVA_OBJECT", ",", "new", "String", "[", "]", "{", "CUSTOM_ATTRIBUTE_GROUP", "}", ",", "getClassSignature", "(", "new", "String", "[", "]", "{", "CUSTOM_ATTRIBUTE_GROUP", "}", ",", "typeName", ",", "apiName", ")", ",", "ACC_PUBLIC", "+", "ACC_SUPER", ",", "apiName", ")", ";", "generateClassMethods", "(", "classWriter", ",", "typeName", ",", "className", ",", "apiName", ",", "false", ")", ";", "return", "classWriter", ";", "}" ]
Creates the inner classes that are used to support the sequence behaviour. @param typeName The name of the next type to return. @param className The name of the class which contains the sequence. @param apiName The name of the generated fluent interface. @return The {@link ClassWriter} object which represents the inner class created to support sequence behaviour.
[ "Creates", "the", "inner", "classes", "that", "are", "used", "to", "support", "the", "sequence", "behaviour", "." ]
ccb78f9dd4b957ad5ac1ca349eaf24338c421e94
https://github.com/xmlet/XsdAsmFaster/blob/ccb78f9dd4b957ad5ac1ca349eaf24338c421e94/src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmInterfaces.java#L501-L507
155,711
xmlet/XsdAsmFaster
src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmInterfaces.java
XsdAsmInterfaces.getSequenceInfo
private SequenceMethodInfo getSequenceInfo(Stream<XsdAbstractElement> xsdElements, String className, int interfaceIndex, int unnamedIndex, String apiName, String groupName){ List<XsdAbstractElement> xsdElementsList = xsdElements.collect(Collectors.toList()); SequenceMethodInfo sequenceMethodInfo = new SequenceMethodInfo(xsdElementsList.stream().filter(element -> !(element instanceof XsdSequence)).collect(Collectors.toList()), interfaceIndex, unnamedIndex); for (XsdAbstractElement element : xsdElementsList) { if (element instanceof XsdElement){ String elementName = ((XsdElement) element).getName(); if (elementName != null){ sequenceMethodInfo.addElementName(elementName); } else { sequenceMethodInfo.addElementName(className + "SequenceUnnamed" + sequenceMethodInfo.getUnnamedIndex()); sequenceMethodInfo.incrementUnnamedIndex(); } } else { if (element instanceof XsdSequence){ sequenceMethodInfo.receiveChildSequence(getSequenceInfo(element.getXsdElements(), className, interfaceIndex, unnamedIndex, apiName, groupName)); } else { InterfaceInfo interfaceInfo = iterativeCreation(element, className, interfaceIndex + 1, apiName, groupName).get(0); sequenceMethodInfo.setInterfaceIndex(interfaceInfo.getInterfaceIndex()); sequenceMethodInfo.addElementName(interfaceInfo.getInterfaceName()); } } } return sequenceMethodInfo; }
java
private SequenceMethodInfo getSequenceInfo(Stream<XsdAbstractElement> xsdElements, String className, int interfaceIndex, int unnamedIndex, String apiName, String groupName){ List<XsdAbstractElement> xsdElementsList = xsdElements.collect(Collectors.toList()); SequenceMethodInfo sequenceMethodInfo = new SequenceMethodInfo(xsdElementsList.stream().filter(element -> !(element instanceof XsdSequence)).collect(Collectors.toList()), interfaceIndex, unnamedIndex); for (XsdAbstractElement element : xsdElementsList) { if (element instanceof XsdElement){ String elementName = ((XsdElement) element).getName(); if (elementName != null){ sequenceMethodInfo.addElementName(elementName); } else { sequenceMethodInfo.addElementName(className + "SequenceUnnamed" + sequenceMethodInfo.getUnnamedIndex()); sequenceMethodInfo.incrementUnnamedIndex(); } } else { if (element instanceof XsdSequence){ sequenceMethodInfo.receiveChildSequence(getSequenceInfo(element.getXsdElements(), className, interfaceIndex, unnamedIndex, apiName, groupName)); } else { InterfaceInfo interfaceInfo = iterativeCreation(element, className, interfaceIndex + 1, apiName, groupName).get(0); sequenceMethodInfo.setInterfaceIndex(interfaceInfo.getInterfaceIndex()); sequenceMethodInfo.addElementName(interfaceInfo.getInterfaceName()); } } } return sequenceMethodInfo; }
[ "private", "SequenceMethodInfo", "getSequenceInfo", "(", "Stream", "<", "XsdAbstractElement", ">", "xsdElements", ",", "String", "className", ",", "int", "interfaceIndex", ",", "int", "unnamedIndex", ",", "String", "apiName", ",", "String", "groupName", ")", "{", "List", "<", "XsdAbstractElement", ">", "xsdElementsList", "=", "xsdElements", ".", "collect", "(", "Collectors", ".", "toList", "(", ")", ")", ";", "SequenceMethodInfo", "sequenceMethodInfo", "=", "new", "SequenceMethodInfo", "(", "xsdElementsList", ".", "stream", "(", ")", ".", "filter", "(", "element", "->", "!", "(", "element", "instanceof", "XsdSequence", ")", ")", ".", "collect", "(", "Collectors", ".", "toList", "(", ")", ")", ",", "interfaceIndex", ",", "unnamedIndex", ")", ";", "for", "(", "XsdAbstractElement", "element", ":", "xsdElementsList", ")", "{", "if", "(", "element", "instanceof", "XsdElement", ")", "{", "String", "elementName", "=", "(", "(", "XsdElement", ")", "element", ")", ".", "getName", "(", ")", ";", "if", "(", "elementName", "!=", "null", ")", "{", "sequenceMethodInfo", ".", "addElementName", "(", "elementName", ")", ";", "}", "else", "{", "sequenceMethodInfo", ".", "addElementName", "(", "className", "+", "\"SequenceUnnamed\"", "+", "sequenceMethodInfo", ".", "getUnnamedIndex", "(", ")", ")", ";", "sequenceMethodInfo", ".", "incrementUnnamedIndex", "(", ")", ";", "}", "}", "else", "{", "if", "(", "element", "instanceof", "XsdSequence", ")", "{", "sequenceMethodInfo", ".", "receiveChildSequence", "(", "getSequenceInfo", "(", "element", ".", "getXsdElements", "(", ")", ",", "className", ",", "interfaceIndex", ",", "unnamedIndex", ",", "apiName", ",", "groupName", ")", ")", ";", "}", "else", "{", "InterfaceInfo", "interfaceInfo", "=", "iterativeCreation", "(", "element", ",", "className", ",", "interfaceIndex", "+", "1", ",", "apiName", ",", "groupName", ")", ".", "get", "(", "0", ")", ";", "sequenceMethodInfo", ".", "setInterfaceIndex", "(", "interfaceInfo", ".", "getInterfaceIndex", "(", ")", ")", ";", "sequenceMethodInfo", ".", "addElementName", "(", "interfaceInfo", ".", "getInterfaceName", "(", ")", ")", ";", "}", "}", "}", "return", "sequenceMethodInfo", ";", "}" ]
Obtains information about all the members that make up the sequence. @param xsdElements The members that make the sequence. @param className The name of the element that this sequence belongs to. @param interfaceIndex The current interface index. @param unnamedIndex A special index for elements that have no name, which will help distinguish them. @param apiName The name of the generated fluent interface. @param groupName The group name of the group that contains this sequence, if any. @return A {@link SequenceMethodInfo} object which contains relevant information regarding sequence methods.
[ "Obtains", "information", "about", "all", "the", "members", "that", "make", "up", "the", "sequence", "." ]
ccb78f9dd4b957ad5ac1ca349eaf24338c421e94
https://github.com/xmlet/XsdAsmFaster/blob/ccb78f9dd4b957ad5ac1ca349eaf24338c421e94/src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmInterfaces.java#L578-L605
155,712
xmlet/XsdAsmFaster
src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmInterfaces.java
XsdAsmInterfaces.iterativeCreation
@SuppressWarnings("MismatchedQueryAndUpdateOfCollection") private List<InterfaceInfo> iterativeCreation(XsdAbstractElement element, String className, int interfaceIndex, String apiName, String groupName){ List<XsdChoice> choiceElements = new ArrayList<>(); List<XsdGroup> groupElements = new ArrayList<>(); List<XsdAll> allElements = new ArrayList<>(); List<XsdSequence> sequenceElements = new ArrayList<>(); List<XsdElement> directElements = new ArrayList<>(); Map<Class, List> mapper = new HashMap<>(); mapper.put(XsdGroup.class, groupElements); mapper.put(XsdChoice.class, choiceElements); mapper.put(XsdAll.class, allElements); mapper.put(XsdSequence.class, sequenceElements); mapper.put(XsdElement.class, directElements); //noinspection unchecked element.getXsdElements() .forEach(elementChild -> mapper.get(elementChild.getClass()).add(elementChild) ); List<InterfaceInfo> interfaceInfoList = new ArrayList<>(); if (element instanceof XsdGroup){ XsdChoice choiceElement = choiceElements.size() == 1 ? choiceElements.get(0) : null; XsdSequence sequenceElement = sequenceElements.size() == 1 ? sequenceElements.get(0) : null; XsdAll allElement = allElements.size() == 1 ? allElements.get(0) : null; interfaceInfoList.add(groupMethod(((XsdGroup) element).getName(), choiceElement, allElement, sequenceElement, className, interfaceIndex, apiName)); } if (element instanceof XsdAll){ interfaceInfoList.add(allMethod(directElements, className, interfaceIndex, apiName, groupName)); } if (element instanceof XsdChoice){ interfaceInfoList = choiceMethod(groupElements, directElements, className, interfaceIndex, apiName, groupName); } if (element instanceof XsdSequence){ sequenceMethod(element.getXsdElements(), className, interfaceIndex, apiName, groupName); } interfaceInfoList.forEach(interfaceInfo -> createdInterfaces.put(interfaceInfo.getInterfaceName(), interfaceInfo)); return interfaceInfoList; }
java
@SuppressWarnings("MismatchedQueryAndUpdateOfCollection") private List<InterfaceInfo> iterativeCreation(XsdAbstractElement element, String className, int interfaceIndex, String apiName, String groupName){ List<XsdChoice> choiceElements = new ArrayList<>(); List<XsdGroup> groupElements = new ArrayList<>(); List<XsdAll> allElements = new ArrayList<>(); List<XsdSequence> sequenceElements = new ArrayList<>(); List<XsdElement> directElements = new ArrayList<>(); Map<Class, List> mapper = new HashMap<>(); mapper.put(XsdGroup.class, groupElements); mapper.put(XsdChoice.class, choiceElements); mapper.put(XsdAll.class, allElements); mapper.put(XsdSequence.class, sequenceElements); mapper.put(XsdElement.class, directElements); //noinspection unchecked element.getXsdElements() .forEach(elementChild -> mapper.get(elementChild.getClass()).add(elementChild) ); List<InterfaceInfo> interfaceInfoList = new ArrayList<>(); if (element instanceof XsdGroup){ XsdChoice choiceElement = choiceElements.size() == 1 ? choiceElements.get(0) : null; XsdSequence sequenceElement = sequenceElements.size() == 1 ? sequenceElements.get(0) : null; XsdAll allElement = allElements.size() == 1 ? allElements.get(0) : null; interfaceInfoList.add(groupMethod(((XsdGroup) element).getName(), choiceElement, allElement, sequenceElement, className, interfaceIndex, apiName)); } if (element instanceof XsdAll){ interfaceInfoList.add(allMethod(directElements, className, interfaceIndex, apiName, groupName)); } if (element instanceof XsdChoice){ interfaceInfoList = choiceMethod(groupElements, directElements, className, interfaceIndex, apiName, groupName); } if (element instanceof XsdSequence){ sequenceMethod(element.getXsdElements(), className, interfaceIndex, apiName, groupName); } interfaceInfoList.forEach(interfaceInfo -> createdInterfaces.put(interfaceInfo.getInterfaceName(), interfaceInfo)); return interfaceInfoList; }
[ "@", "SuppressWarnings", "(", "\"MismatchedQueryAndUpdateOfCollection\"", ")", "private", "List", "<", "InterfaceInfo", ">", "iterativeCreation", "(", "XsdAbstractElement", "element", ",", "String", "className", ",", "int", "interfaceIndex", ",", "String", "apiName", ",", "String", "groupName", ")", "{", "List", "<", "XsdChoice", ">", "choiceElements", "=", "new", "ArrayList", "<>", "(", ")", ";", "List", "<", "XsdGroup", ">", "groupElements", "=", "new", "ArrayList", "<>", "(", ")", ";", "List", "<", "XsdAll", ">", "allElements", "=", "new", "ArrayList", "<>", "(", ")", ";", "List", "<", "XsdSequence", ">", "sequenceElements", "=", "new", "ArrayList", "<>", "(", ")", ";", "List", "<", "XsdElement", ">", "directElements", "=", "new", "ArrayList", "<>", "(", ")", ";", "Map", "<", "Class", ",", "List", ">", "mapper", "=", "new", "HashMap", "<>", "(", ")", ";", "mapper", ".", "put", "(", "XsdGroup", ".", "class", ",", "groupElements", ")", ";", "mapper", ".", "put", "(", "XsdChoice", ".", "class", ",", "choiceElements", ")", ";", "mapper", ".", "put", "(", "XsdAll", ".", "class", ",", "allElements", ")", ";", "mapper", ".", "put", "(", "XsdSequence", ".", "class", ",", "sequenceElements", ")", ";", "mapper", ".", "put", "(", "XsdElement", ".", "class", ",", "directElements", ")", ";", "//noinspection unchecked", "element", ".", "getXsdElements", "(", ")", ".", "forEach", "(", "elementChild", "->", "mapper", ".", "get", "(", "elementChild", ".", "getClass", "(", ")", ")", ".", "add", "(", "elementChild", ")", ")", ";", "List", "<", "InterfaceInfo", ">", "interfaceInfoList", "=", "new", "ArrayList", "<>", "(", ")", ";", "if", "(", "element", "instanceof", "XsdGroup", ")", "{", "XsdChoice", "choiceElement", "=", "choiceElements", ".", "size", "(", ")", "==", "1", "?", "choiceElements", ".", "get", "(", "0", ")", ":", "null", ";", "XsdSequence", "sequenceElement", "=", "sequenceElements", ".", "size", "(", ")", "==", "1", "?", "sequenceElements", ".", "get", "(", "0", ")", ":", "null", ";", "XsdAll", "allElement", "=", "allElements", ".", "size", "(", ")", "==", "1", "?", "allElements", ".", "get", "(", "0", ")", ":", "null", ";", "interfaceInfoList", ".", "add", "(", "groupMethod", "(", "(", "(", "XsdGroup", ")", "element", ")", ".", "getName", "(", ")", ",", "choiceElement", ",", "allElement", ",", "sequenceElement", ",", "className", ",", "interfaceIndex", ",", "apiName", ")", ")", ";", "}", "if", "(", "element", "instanceof", "XsdAll", ")", "{", "interfaceInfoList", ".", "add", "(", "allMethod", "(", "directElements", ",", "className", ",", "interfaceIndex", ",", "apiName", ",", "groupName", ")", ")", ";", "}", "if", "(", "element", "instanceof", "XsdChoice", ")", "{", "interfaceInfoList", "=", "choiceMethod", "(", "groupElements", ",", "directElements", ",", "className", ",", "interfaceIndex", ",", "apiName", ",", "groupName", ")", ";", "}", "if", "(", "element", "instanceof", "XsdSequence", ")", "{", "sequenceMethod", "(", "element", ".", "getXsdElements", "(", ")", ",", "className", ",", "interfaceIndex", ",", "apiName", ",", "groupName", ")", ";", "}", "interfaceInfoList", ".", "forEach", "(", "interfaceInfo", "->", "createdInterfaces", ".", "put", "(", "interfaceInfo", ".", "getInterfaceName", "(", ")", ",", "interfaceInfo", ")", ")", ";", "return", "interfaceInfoList", ";", "}" ]
This method functions as an iterative process for interface creation. @param element The element which could have more interface information. @param className The name of the class which contains the interfaces. @param interfaceIndex The current interface index. @param apiName The name of the generated fluent interface. @param groupName The name of the group in which this {@link XsdChoice} element is contained, if any. @return A {@link List} of {@link InterfaceInfo} objects containing relevant interface information.
[ "This", "method", "functions", "as", "an", "iterative", "process", "for", "interface", "creation", "." ]
ccb78f9dd4b957ad5ac1ca349eaf24338c421e94
https://github.com/xmlet/XsdAsmFaster/blob/ccb78f9dd4b957ad5ac1ca349eaf24338c421e94/src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmInterfaces.java#L744-L791
155,713
xmlet/XsdAsmFaster
src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmInterfaces.java
XsdAsmInterfaces.checkForSequenceMethod
void checkForSequenceMethod(ClassWriter classWriter, String className) { Consumer<ClassWriter> sequenceMethodCreator = pendingSequenceMethods.get(className); if (sequenceMethodCreator != null){ sequenceMethodCreator.accept(classWriter); } }
java
void checkForSequenceMethod(ClassWriter classWriter, String className) { Consumer<ClassWriter> sequenceMethodCreator = pendingSequenceMethods.get(className); if (sequenceMethodCreator != null){ sequenceMethodCreator.accept(classWriter); } }
[ "void", "checkForSequenceMethod", "(", "ClassWriter", "classWriter", ",", "String", "className", ")", "{", "Consumer", "<", "ClassWriter", ">", "sequenceMethodCreator", "=", "pendingSequenceMethods", ".", "get", "(", "className", ")", ";", "if", "(", "sequenceMethodCreator", "!=", "null", ")", "{", "sequenceMethodCreator", ".", "accept", "(", "classWriter", ")", ";", "}", "}" ]
Verifies if there is any postponed sequence method creation in pendingSequenceMethods and performs the method if it exists. @param classWriter The {@link ClassWriter} object for the class that contains the postponed sequence method creation. @param className The name of the class that contains the sequence.
[ "Verifies", "if", "there", "is", "any", "postponed", "sequence", "method", "creation", "in", "pendingSequenceMethods", "and", "performs", "the", "method", "if", "it", "exists", "." ]
ccb78f9dd4b957ad5ac1ca349eaf24338c421e94
https://github.com/xmlet/XsdAsmFaster/blob/ccb78f9dd4b957ad5ac1ca349eaf24338c421e94/src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmInterfaces.java#L867-L873
155,714
james-hu/jabb-core
src/main/java/net/sf/jabb/spring/rest/AbstractRestClient.java
AbstractRestClient.buildAddHeadersRequestInterceptor
protected ClientHttpRequestInterceptor buildAddHeadersRequestInterceptor(String header1, String value1, String header2, String value2, String header3, String value3, String header4, String value4){ return new AddHeadersRequestInterceptor(new String[]{header1, header2, header3, header4}, new String[]{value1, value2, value3, value4}); }
java
protected ClientHttpRequestInterceptor buildAddHeadersRequestInterceptor(String header1, String value1, String header2, String value2, String header3, String value3, String header4, String value4){ return new AddHeadersRequestInterceptor(new String[]{header1, header2, header3, header4}, new String[]{value1, value2, value3, value4}); }
[ "protected", "ClientHttpRequestInterceptor", "buildAddHeadersRequestInterceptor", "(", "String", "header1", ",", "String", "value1", ",", "String", "header2", ",", "String", "value2", ",", "String", "header3", ",", "String", "value3", ",", "String", "header4", ",", "String", "value4", ")", "{", "return", "new", "AddHeadersRequestInterceptor", "(", "new", "String", "[", "]", "{", "header1", ",", "header2", ",", "header3", ",", "header4", "}", ",", "new", "String", "[", "]", "{", "value1", ",", "value2", ",", "value3", ",", "value4", "}", ")", ";", "}" ]
Build a ClientHttpRequestInterceptor that adds three request headers @param header1 name of header 1 @param value1 value of header 1 @param header2 name of header 2 @param value2 value of header 2 @param header3 name of header 3 @param value3 value of header 3 @param header4 name of the header 4 @param value4 value of the header 4 @return the ClientHttpRequestInterceptor built
[ "Build", "a", "ClientHttpRequestInterceptor", "that", "adds", "three", "request", "headers" ]
bceed441595c5e5195a7418795f03b69fa7b61e4
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/spring/rest/AbstractRestClient.java#L513-L515
155,715
james-hu/jabb-core
src/main/java/net/sf/jabb/spring/rest/AbstractRestClient.java
AbstractRestClient.buildAddBasicAuthHeaderRequestInterceptor
protected ClientHttpRequestInterceptor buildAddBasicAuthHeaderRequestInterceptor(String user, String password){ return new AddHeaderRequestInterceptor(HEADER_AUTHORIZATION, buildBasicAuthValue(user, password)); }
java
protected ClientHttpRequestInterceptor buildAddBasicAuthHeaderRequestInterceptor(String user, String password){ return new AddHeaderRequestInterceptor(HEADER_AUTHORIZATION, buildBasicAuthValue(user, password)); }
[ "protected", "ClientHttpRequestInterceptor", "buildAddBasicAuthHeaderRequestInterceptor", "(", "String", "user", ",", "String", "password", ")", "{", "return", "new", "AddHeaderRequestInterceptor", "(", "HEADER_AUTHORIZATION", ",", "buildBasicAuthValue", "(", "user", ",", "password", ")", ")", ";", "}" ]
Build a ClientHttpRequestInterceptor that adds BasicAuth header @param user the user name, may be null or empty @param password the password, may be null or empty @return the ClientHttpRequestInterceptor built
[ "Build", "a", "ClientHttpRequestInterceptor", "that", "adds", "BasicAuth", "header" ]
bceed441595c5e5195a7418795f03b69fa7b61e4
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/spring/rest/AbstractRestClient.java#L523-L525
155,716
james-hu/jabb-core
src/main/java/net/sf/jabb/spring/rest/AbstractRestClient.java
AbstractRestClient.copy
protected HttpHeaders copy(HttpHeaders headers){ HttpHeaders newHeaders = new HttpHeaders(); newHeaders.putAll(headers); return newHeaders; }
java
protected HttpHeaders copy(HttpHeaders headers){ HttpHeaders newHeaders = new HttpHeaders(); newHeaders.putAll(headers); return newHeaders; }
[ "protected", "HttpHeaders", "copy", "(", "HttpHeaders", "headers", ")", "{", "HttpHeaders", "newHeaders", "=", "new", "HttpHeaders", "(", ")", ";", "newHeaders", ".", "putAll", "(", "headers", ")", ";", "return", "newHeaders", ";", "}" ]
Make a writable copy of an existing HttpHeaders @param headers existing HttpHeaders to be copied @return a new HttpHeaders that contains all the entries from the existing HttpHeaders
[ "Make", "a", "writable", "copy", "of", "an", "existing", "HttpHeaders" ]
bceed441595c5e5195a7418795f03b69fa7b61e4
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/spring/rest/AbstractRestClient.java#L638-L642
155,717
app55/app55-java
src/support/java/org/apache/harmony/beans/Handler.java
Handler.startElement
@Override public void startElement(String namespaceURI, String localeName, String tagName, Attributes attrs) throws SAXException { Command.printAttrs(tabCount, tagName, attrs); Command cmd = tagName.equals("java") ? new Command(decoder, tagName, //$NON-NLS-1$ Command.parseAttrs(tagName, attrs)) : new Command(tagName, Command.parseAttrs(tagName, attrs)); stack.push(cmd); ++tabCount; }
java
@Override public void startElement(String namespaceURI, String localeName, String tagName, Attributes attrs) throws SAXException { Command.printAttrs(tabCount, tagName, attrs); Command cmd = tagName.equals("java") ? new Command(decoder, tagName, //$NON-NLS-1$ Command.parseAttrs(tagName, attrs)) : new Command(tagName, Command.parseAttrs(tagName, attrs)); stack.push(cmd); ++tabCount; }
[ "@", "Override", "public", "void", "startElement", "(", "String", "namespaceURI", ",", "String", "localeName", ",", "String", "tagName", ",", "Attributes", "attrs", ")", "throws", "SAXException", "{", "Command", ".", "printAttrs", "(", "tabCount", ",", "tagName", ",", "attrs", ")", ";", "Command", "cmd", "=", "tagName", ".", "equals", "(", "\"java\"", ")", "?", "new", "Command", "(", "decoder", ",", "tagName", ",", "//$NON-NLS-1$", "Command", ".", "parseAttrs", "(", "tagName", ",", "attrs", ")", ")", ":", "new", "Command", "(", "tagName", ",", "Command", ".", "parseAttrs", "(", "tagName", ",", "attrs", ")", ")", ";", "stack", ".", "push", "(", "cmd", ")", ";", "++", "tabCount", ";", "}" ]
create new command and put it on stack
[ "create", "new", "command", "and", "put", "it", "on", "stack" ]
73e51d0f3141a859dfbd37ca9becef98477e553e
https://github.com/app55/app55-java/blob/73e51d0f3141a859dfbd37ca9becef98477e553e/src/support/java/org/apache/harmony/beans/Handler.java#L65-L73
155,718
app55/app55-java
src/support/java/org/apache/harmony/beans/Handler.java
Handler.characters
@Override public void characters(char[] text, int start, int length) throws SAXException { if (length > 0) { String data = String.valueOf(text, start, length).replace('\n', ' ').replace('\t', ' ').trim(); if (data.length() > 0) { Command.prn(tabCount, tabCount + ">setting data=" + data //$NON-NLS-1$ + "<EOL>"); //$NON-NLS-1$ Command cmd = stack.peek(); cmd.setData(data); } } }
java
@Override public void characters(char[] text, int start, int length) throws SAXException { if (length > 0) { String data = String.valueOf(text, start, length).replace('\n', ' ').replace('\t', ' ').trim(); if (data.length() > 0) { Command.prn(tabCount, tabCount + ">setting data=" + data //$NON-NLS-1$ + "<EOL>"); //$NON-NLS-1$ Command cmd = stack.peek(); cmd.setData(data); } } }
[ "@", "Override", "public", "void", "characters", "(", "char", "[", "]", "text", ",", "int", "start", ",", "int", "length", ")", "throws", "SAXException", "{", "if", "(", "length", ">", "0", ")", "{", "String", "data", "=", "String", ".", "valueOf", "(", "text", ",", "start", ",", "length", ")", ".", "replace", "(", "'", "'", ",", "'", "'", ")", ".", "replace", "(", "'", "'", ",", "'", "'", ")", ".", "trim", "(", ")", ";", "if", "(", "data", ".", "length", "(", ")", ">", "0", ")", "{", "Command", ".", "prn", "(", "tabCount", ",", "tabCount", "+", "\">setting data=\"", "+", "data", "//$NON-NLS-1$", "+", "\"<EOL>\"", ")", ";", "//$NON-NLS-1$", "Command", "cmd", "=", "stack", ".", "peek", "(", ")", ";", "cmd", ".", "setData", "(", "data", ")", ";", "}", "}", "}" ]
add data to command
[ "add", "data", "to", "command" ]
73e51d0f3141a859dfbd37ca9becef98477e553e
https://github.com/app55/app55-java/blob/73e51d0f3141a859dfbd37ca9becef98477e553e/src/support/java/org/apache/harmony/beans/Handler.java#L76-L90
155,719
app55/app55-java
src/support/java/org/apache/harmony/beans/Handler.java
Handler.endElement
@Override public void endElement(String namespaceURI, String localeName, String tagName) throws SAXException { Command cmd = stack.pop(); // cmd.setTabCount(tabCount); // find if command works in context if (!stack.isEmpty()) { Command ctx = stack.peek(); ctx.addChild(cmd); } // upper level commands if (stack.size() == 1 && cmd.isExecutable()) { commands.add(cmd); } // store reference to command if (cmd.hasAttr("id")) { //$NON-NLS-1$ references.put(cmd.getAttr("id"), cmd); //$NON-NLS-1$ } try { cmd.exec(references); } catch (Exception e) { SAXException e2 = new SAXException(e.getMessage()); e2.initCause(e); throw e2; } if (--tabCount < 0) { tabCount = 0; } Command.prn(tabCount, tabCount + ">...<" + tagName + "> end"); //$NON-NLS-1$ //$NON-NLS-2$ }
java
@Override public void endElement(String namespaceURI, String localeName, String tagName) throws SAXException { Command cmd = stack.pop(); // cmd.setTabCount(tabCount); // find if command works in context if (!stack.isEmpty()) { Command ctx = stack.peek(); ctx.addChild(cmd); } // upper level commands if (stack.size() == 1 && cmd.isExecutable()) { commands.add(cmd); } // store reference to command if (cmd.hasAttr("id")) { //$NON-NLS-1$ references.put(cmd.getAttr("id"), cmd); //$NON-NLS-1$ } try { cmd.exec(references); } catch (Exception e) { SAXException e2 = new SAXException(e.getMessage()); e2.initCause(e); throw e2; } if (--tabCount < 0) { tabCount = 0; } Command.prn(tabCount, tabCount + ">...<" + tagName + "> end"); //$NON-NLS-1$ //$NON-NLS-2$ }
[ "@", "Override", "public", "void", "endElement", "(", "String", "namespaceURI", ",", "String", "localeName", ",", "String", "tagName", ")", "throws", "SAXException", "{", "Command", "cmd", "=", "stack", ".", "pop", "(", ")", ";", "// cmd.setTabCount(tabCount);", "// find if command works in context", "if", "(", "!", "stack", ".", "isEmpty", "(", ")", ")", "{", "Command", "ctx", "=", "stack", ".", "peek", "(", ")", ";", "ctx", ".", "addChild", "(", "cmd", ")", ";", "}", "// upper level commands", "if", "(", "stack", ".", "size", "(", ")", "==", "1", "&&", "cmd", ".", "isExecutable", "(", ")", ")", "{", "commands", ".", "add", "(", "cmd", ")", ";", "}", "// store reference to command", "if", "(", "cmd", ".", "hasAttr", "(", "\"id\"", ")", ")", "{", "//$NON-NLS-1$", "references", ".", "put", "(", "cmd", ".", "getAttr", "(", "\"id\"", ")", ",", "cmd", ")", ";", "//$NON-NLS-1$", "}", "try", "{", "cmd", ".", "exec", "(", "references", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "SAXException", "e2", "=", "new", "SAXException", "(", "e", ".", "getMessage", "(", ")", ")", ";", "e2", ".", "initCause", "(", "e", ")", ";", "throw", "e2", ";", "}", "if", "(", "--", "tabCount", "<", "0", ")", "{", "tabCount", "=", "0", ";", "}", "Command", ".", "prn", "(", "tabCount", ",", "tabCount", "+", "\">...<\"", "+", "tagName", "+", "\"> end\"", ")", ";", "//$NON-NLS-1$ //$NON-NLS-2$", "}" ]
pop command from stack and put it to one of collections
[ "pop", "command", "from", "stack", "and", "put", "it", "to", "one", "of", "collections" ]
73e51d0f3141a859dfbd37ca9becef98477e553e
https://github.com/app55/app55-java/blob/73e51d0f3141a859dfbd37ca9becef98477e553e/src/support/java/org/apache/harmony/beans/Handler.java#L93-L135
155,720
app55/app55-java
src/support/java/org/apache/harmony/beans/Handler.java
Handler.endDocument
@Override public void endDocument() throws SAXException { for (int i = 0; i < commands.size(); ++i) { Command cmd = commands.elementAt(i); try { cmd.backtrack(references); } catch (Exception e) { throw new SAXException(Messages.getString("beans.0B")); //$NON-NLS-1$ } // if(!backtracked) // throw new SAXException("Command " + cmd.getTagName() + // " is unresolved on second run() call."); } for (int i = 0; i < commands.size(); ++i) { Command cmd = commands.elementAt(i); result.add(cmd.getResultValue()); } }
java
@Override public void endDocument() throws SAXException { for (int i = 0; i < commands.size(); ++i) { Command cmd = commands.elementAt(i); try { cmd.backtrack(references); } catch (Exception e) { throw new SAXException(Messages.getString("beans.0B")); //$NON-NLS-1$ } // if(!backtracked) // throw new SAXException("Command " + cmd.getTagName() + // " is unresolved on second run() call."); } for (int i = 0; i < commands.size(); ++i) { Command cmd = commands.elementAt(i); result.add(cmd.getResultValue()); } }
[ "@", "Override", "public", "void", "endDocument", "(", ")", "throws", "SAXException", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "commands", ".", "size", "(", ")", ";", "++", "i", ")", "{", "Command", "cmd", "=", "commands", ".", "elementAt", "(", "i", ")", ";", "try", "{", "cmd", ".", "backtrack", "(", "references", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "SAXException", "(", "Messages", ".", "getString", "(", "\"beans.0B\"", ")", ")", ";", "//$NON-NLS-1$", "}", "// if(!backtracked)", "// throw new SAXException(\"Command \" + cmd.getTagName() +", "// \" is unresolved on second run() call.\");", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "commands", ".", "size", "(", ")", ";", "++", "i", ")", "{", "Command", "cmd", "=", "commands", ".", "elementAt", "(", "i", ")", ";", "result", ".", "add", "(", "cmd", ".", "getResultValue", "(", ")", ")", ";", "}", "}" ]
iterate over deferred commands and execute them again
[ "iterate", "over", "deferred", "commands", "and", "execute", "them", "again" ]
73e51d0f3141a859dfbd37ca9becef98477e553e
https://github.com/app55/app55-java/blob/73e51d0f3141a859dfbd37ca9becef98477e553e/src/support/java/org/apache/harmony/beans/Handler.java#L138-L162
155,721
gnagy/webhejj-commons
src/main/java/hu/webhejj/commons/text/StringUtils.java
StringUtils.join
public static void join(StringBuilder buf, Iterable<?> values, String separator) { for (Iterator<?> i = values.iterator(); i.hasNext();) { buf.append(i.next()); if (i.hasNext()) { buf.append(separator); } } }
java
public static void join(StringBuilder buf, Iterable<?> values, String separator) { for (Iterator<?> i = values.iterator(); i.hasNext();) { buf.append(i.next()); if (i.hasNext()) { buf.append(separator); } } }
[ "public", "static", "void", "join", "(", "StringBuilder", "buf", ",", "Iterable", "<", "?", ">", "values", ",", "String", "separator", ")", "{", "for", "(", "Iterator", "<", "?", ">", "i", "=", "values", ".", "iterator", "(", ")", ";", "i", ".", "hasNext", "(", ")", ";", ")", "{", "buf", ".", "append", "(", "i", ".", "next", "(", ")", ")", ";", "if", "(", "i", ".", "hasNext", "(", ")", ")", "{", "buf", ".", "append", "(", "separator", ")", ";", "}", "}", "}" ]
append values to buf separated with the specified separator
[ "append", "values", "to", "buf", "separated", "with", "the", "specified", "separator" ]
270bc6f111ec5761af31d39bd38c40fd914d2eba
https://github.com/gnagy/webhejj-commons/blob/270bc6f111ec5761af31d39bd38c40fd914d2eba/src/main/java/hu/webhejj/commons/text/StringUtils.java#L53-L60
155,722
foundation-runtime/service-directory
2.0/sd-core/src/main/java/com/cisco/oss/foundation/directory/utils/JsonSerializer.java
JsonSerializer.deserialize
public Object deserialize(byte[] input, TypeReference<?> typeRef) throws JsonParseException, JsonMappingException, IOException { return mapper.readValue(input, typeRef); }
java
public Object deserialize(byte[] input, TypeReference<?> typeRef) throws JsonParseException, JsonMappingException, IOException { return mapper.readValue(input, typeRef); }
[ "public", "Object", "deserialize", "(", "byte", "[", "]", "input", ",", "TypeReference", "<", "?", ">", "typeRef", ")", "throws", "JsonParseException", ",", "JsonMappingException", ",", "IOException", "{", "return", "mapper", ".", "readValue", "(", "input", ",", "typeRef", ")", ";", "}" ]
Deserialize from byte array, it always used in the generic type object. @param input the JSON String byte array. @param typeRef the target Object TypeReference. @return the target Object instance. @throws JsonParseException @throws JsonMappingException @throws IOException
[ "Deserialize", "from", "byte", "array", "it", "always", "used", "in", "the", "generic", "type", "object", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-core/src/main/java/com/cisco/oss/foundation/directory/utils/JsonSerializer.java#L82-L85
155,723
grails/grails-gdoc-engine
src/main/java/org/radeox/util/Encoder.java
Encoder.escape
public static String escape(String str) { StringBuffer result = new StringBuffer(); StringTokenizer tokenizer = new StringTokenizer(str, DELIMITER, true); while(tokenizer.hasMoreTokens()) { String currentToken = tokenizer.nextToken(); if(ESCAPED_CHARS.containsKey(currentToken)) { result.append(ESCAPED_CHARS.get(currentToken)); } else { result.append(currentToken); } } return result.toString(); }
java
public static String escape(String str) { StringBuffer result = new StringBuffer(); StringTokenizer tokenizer = new StringTokenizer(str, DELIMITER, true); while(tokenizer.hasMoreTokens()) { String currentToken = tokenizer.nextToken(); if(ESCAPED_CHARS.containsKey(currentToken)) { result.append(ESCAPED_CHARS.get(currentToken)); } else { result.append(currentToken); } } return result.toString(); }
[ "public", "static", "String", "escape", "(", "String", "str", ")", "{", "StringBuffer", "result", "=", "new", "StringBuffer", "(", ")", ";", "StringTokenizer", "tokenizer", "=", "new", "StringTokenizer", "(", "str", ",", "DELIMITER", ",", "true", ")", ";", "while", "(", "tokenizer", ".", "hasMoreTokens", "(", ")", ")", "{", "String", "currentToken", "=", "tokenizer", ".", "nextToken", "(", ")", ";", "if", "(", "ESCAPED_CHARS", ".", "containsKey", "(", "currentToken", ")", ")", "{", "result", ".", "append", "(", "ESCAPED_CHARS", ".", "get", "(", "currentToken", ")", ")", ";", "}", "else", "{", "result", ".", "append", "(", "currentToken", ")", ";", "}", "}", "return", "result", ".", "toString", "(", ")", ";", "}" ]
Encoder special characters that may occur in a HTML so it can be displayed safely. @param str the original string @return the escaped string
[ "Encoder", "special", "characters", "that", "may", "occur", "in", "a", "HTML", "so", "it", "can", "be", "displayed", "safely", "." ]
e52aa09eaa61510dc48b27603bd9ea116cd6531a
https://github.com/grails/grails-gdoc-engine/blob/e52aa09eaa61510dc48b27603bd9ea116cd6531a/src/main/java/org/radeox/util/Encoder.java#L59-L71
155,724
SimiaCryptus/utilities
java-util/src/main/java/com/simiacryptus/util/MonitoredObject.java
MonitoredObject.addConst
@javax.annotation.Nonnull public com.simiacryptus.util.MonitoredObject addConst(final String key, final Object item) { items.put(key, item); return this; }
java
@javax.annotation.Nonnull public com.simiacryptus.util.MonitoredObject addConst(final String key, final Object item) { items.put(key, item); return this; }
[ "@", "javax", ".", "annotation", ".", "Nonnull", "public", "com", ".", "simiacryptus", ".", "util", ".", "MonitoredObject", "addConst", "(", "final", "String", "key", ",", "final", "Object", "item", ")", "{", "items", ".", "put", "(", "key", ",", "item", ")", ";", "return", "this", ";", "}" ]
Add const monitored object. @param key the key @param item the item @return the monitored object
[ "Add", "const", "monitored", "object", "." ]
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/MonitoredObject.java#L41-L45
155,725
SimiaCryptus/utilities
java-util/src/main/java/com/simiacryptus/util/MonitoredObject.java
MonitoredObject.addObj
@javax.annotation.Nonnull public com.simiacryptus.util.MonitoredObject addObj(final String key, final MonitoredItem item) { items.put(key, item); return this; }
java
@javax.annotation.Nonnull public com.simiacryptus.util.MonitoredObject addObj(final String key, final MonitoredItem item) { items.put(key, item); return this; }
[ "@", "javax", ".", "annotation", ".", "Nonnull", "public", "com", ".", "simiacryptus", ".", "util", ".", "MonitoredObject", "addObj", "(", "final", "String", "key", ",", "final", "MonitoredItem", "item", ")", "{", "items", ".", "put", "(", "key", ",", "item", ")", ";", "return", "this", ";", "}" ]
Add obj monitored object. @param key the key @param item the item @return the monitored object
[ "Add", "obj", "monitored", "object", "." ]
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/MonitoredObject.java#L67-L71
155,726
SimiaCryptus/utilities
java-util/src/main/java/com/simiacryptus/util/MonitoredObject.java
MonitoredObject.clearConstants
@javax.annotation.Nonnull public com.simiacryptus.util.MonitoredObject clearConstants() { @javax.annotation.Nonnull final HashSet<String> keys = new HashSet<>(items.keySet()); for (final String k : keys) { final Object v = items.get(k); if (v instanceof com.simiacryptus.util.MonitoredObject) { ((com.simiacryptus.util.MonitoredObject) v).clearConstants(); } else if (!(v instanceof Supplier) && !(v instanceof MonitoredItem)) { items.remove(k); } } return this; }
java
@javax.annotation.Nonnull public com.simiacryptus.util.MonitoredObject clearConstants() { @javax.annotation.Nonnull final HashSet<String> keys = new HashSet<>(items.keySet()); for (final String k : keys) { final Object v = items.get(k); if (v instanceof com.simiacryptus.util.MonitoredObject) { ((com.simiacryptus.util.MonitoredObject) v).clearConstants(); } else if (!(v instanceof Supplier) && !(v instanceof MonitoredItem)) { items.remove(k); } } return this; }
[ "@", "javax", ".", "annotation", ".", "Nonnull", "public", "com", ".", "simiacryptus", ".", "util", ".", "MonitoredObject", "clearConstants", "(", ")", "{", "@", "javax", ".", "annotation", ".", "Nonnull", "final", "HashSet", "<", "String", ">", "keys", "=", "new", "HashSet", "<>", "(", "items", ".", "keySet", "(", ")", ")", ";", "for", "(", "final", "String", "k", ":", "keys", ")", "{", "final", "Object", "v", "=", "items", ".", "get", "(", "k", ")", ";", "if", "(", "v", "instanceof", "com", ".", "simiacryptus", ".", "util", ".", "MonitoredObject", ")", "{", "(", "(", "com", ".", "simiacryptus", ".", "util", ".", "MonitoredObject", ")", "v", ")", ".", "clearConstants", "(", ")", ";", "}", "else", "if", "(", "!", "(", "v", "instanceof", "Supplier", ")", "&&", "!", "(", "v", "instanceof", "MonitoredItem", ")", ")", "{", "items", ".", "remove", "(", "k", ")", ";", "}", "}", "return", "this", ";", "}" ]
Clear constants monitored object. @return the monitored object
[ "Clear", "constants", "monitored", "object", "." ]
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/MonitoredObject.java#L78-L91
155,727
grails/grails-gdoc-engine
src/main/java/org/radeox/filter/ListFilter.java
ListFilter.addList
private void addList(StringBuffer buffer, BufferedReader reader) throws IOException { char[] lastBullet = new char[0]; String line = null; while ((line = reader.readLine()) != null) { // no nested list handling, trim lines: line = line.trim(); if (line.length() == 0) { continue; } int bulletEnd = line.indexOf(' '); if (bulletEnd < 1) { continue; } if ( line.charAt(bulletEnd - 1) == '.') { bulletEnd--; } char[] bullet = line.substring(0, bulletEnd).toCharArray(); // Logger.log("found bullet: ('" + new String(lastBullet) + "') '" + new String(bullet) + "'"); // check whether we find a new list int sharedPrefixEnd; for (sharedPrefixEnd = 0; ; sharedPrefixEnd++) { if (bullet.length <= sharedPrefixEnd || lastBullet.length <= sharedPrefixEnd || +bullet[sharedPrefixEnd] != lastBullet[sharedPrefixEnd]) { break; } } for (int i = sharedPrefixEnd; i < lastBullet.length; i++) { //Logger.log("closing " + lastBullet[i]); buffer.append(closeList.get(new Character(lastBullet[i]))).append("\n"); } for (int i = sharedPrefixEnd; i < bullet.length; i++) { //Logger.log("opening " + bullet[i]); buffer.append(openList.get(new Character(bullet[i]))).append("\n"); } buffer.append("<li>"); buffer.append(line.substring(line.indexOf(' ') + 1)); buffer.append("</li>\n"); lastBullet = bullet; } for (int i = lastBullet.length - 1; i >= 0; i--) { //Logger.log("closing " + lastBullet[i]); buffer.append(closeList.get(new Character(lastBullet[i]))); } }
java
private void addList(StringBuffer buffer, BufferedReader reader) throws IOException { char[] lastBullet = new char[0]; String line = null; while ((line = reader.readLine()) != null) { // no nested list handling, trim lines: line = line.trim(); if (line.length() == 0) { continue; } int bulletEnd = line.indexOf(' '); if (bulletEnd < 1) { continue; } if ( line.charAt(bulletEnd - 1) == '.') { bulletEnd--; } char[] bullet = line.substring(0, bulletEnd).toCharArray(); // Logger.log("found bullet: ('" + new String(lastBullet) + "') '" + new String(bullet) + "'"); // check whether we find a new list int sharedPrefixEnd; for (sharedPrefixEnd = 0; ; sharedPrefixEnd++) { if (bullet.length <= sharedPrefixEnd || lastBullet.length <= sharedPrefixEnd || +bullet[sharedPrefixEnd] != lastBullet[sharedPrefixEnd]) { break; } } for (int i = sharedPrefixEnd; i < lastBullet.length; i++) { //Logger.log("closing " + lastBullet[i]); buffer.append(closeList.get(new Character(lastBullet[i]))).append("\n"); } for (int i = sharedPrefixEnd; i < bullet.length; i++) { //Logger.log("opening " + bullet[i]); buffer.append(openList.get(new Character(bullet[i]))).append("\n"); } buffer.append("<li>"); buffer.append(line.substring(line.indexOf(' ') + 1)); buffer.append("</li>\n"); lastBullet = bullet; } for (int i = lastBullet.length - 1; i >= 0; i--) { //Logger.log("closing " + lastBullet[i]); buffer.append(closeList.get(new Character(lastBullet[i]))); } }
[ "private", "void", "addList", "(", "StringBuffer", "buffer", ",", "BufferedReader", "reader", ")", "throws", "IOException", "{", "char", "[", "]", "lastBullet", "=", "new", "char", "[", "0", "]", ";", "String", "line", "=", "null", ";", "while", "(", "(", "line", "=", "reader", ".", "readLine", "(", ")", ")", "!=", "null", ")", "{", "// no nested list handling, trim lines:", "line", "=", "line", ".", "trim", "(", ")", ";", "if", "(", "line", ".", "length", "(", ")", "==", "0", ")", "{", "continue", ";", "}", "int", "bulletEnd", "=", "line", ".", "indexOf", "(", "'", "'", ")", ";", "if", "(", "bulletEnd", "<", "1", ")", "{", "continue", ";", "}", "if", "(", "line", ".", "charAt", "(", "bulletEnd", "-", "1", ")", "==", "'", "'", ")", "{", "bulletEnd", "--", ";", "}", "char", "[", "]", "bullet", "=", "line", ".", "substring", "(", "0", ",", "bulletEnd", ")", ".", "toCharArray", "(", ")", ";", "// Logger.log(\"found bullet: ('\" + new String(lastBullet) + \"') '\" + new String(bullet) + \"'\");", "// check whether we find a new list", "int", "sharedPrefixEnd", ";", "for", "(", "sharedPrefixEnd", "=", "0", ";", ";", "sharedPrefixEnd", "++", ")", "{", "if", "(", "bullet", ".", "length", "<=", "sharedPrefixEnd", "||", "lastBullet", ".", "length", "<=", "sharedPrefixEnd", "||", "+", "bullet", "[", "sharedPrefixEnd", "]", "!=", "lastBullet", "[", "sharedPrefixEnd", "]", ")", "{", "break", ";", "}", "}", "for", "(", "int", "i", "=", "sharedPrefixEnd", ";", "i", "<", "lastBullet", ".", "length", ";", "i", "++", ")", "{", "//Logger.log(\"closing \" + lastBullet[i]);", "buffer", ".", "append", "(", "closeList", ".", "get", "(", "new", "Character", "(", "lastBullet", "[", "i", "]", ")", ")", ")", ".", "append", "(", "\"\\n\"", ")", ";", "}", "for", "(", "int", "i", "=", "sharedPrefixEnd", ";", "i", "<", "bullet", ".", "length", ";", "i", "++", ")", "{", "//Logger.log(\"opening \" + bullet[i]);", "buffer", ".", "append", "(", "openList", ".", "get", "(", "new", "Character", "(", "bullet", "[", "i", "]", ")", ")", ")", ".", "append", "(", "\"\\n\"", ")", ";", "}", "buffer", ".", "append", "(", "\"<li>\"", ")", ";", "buffer", ".", "append", "(", "line", ".", "substring", "(", "line", ".", "indexOf", "(", "'", "'", ")", "+", "1", ")", ")", ";", "buffer", ".", "append", "(", "\"</li>\\n\"", ")", ";", "lastBullet", "=", "bullet", ";", "}", "for", "(", "int", "i", "=", "lastBullet", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "//Logger.log(\"closing \" + lastBullet[i]);", "buffer", ".", "append", "(", "closeList", ".", "get", "(", "new", "Character", "(", "lastBullet", "[", "i", "]", ")", ")", ")", ";", "}", "}" ]
Adds a list to a buffer @param buffer The buffer to write to @param reader Input is read from this Reader
[ "Adds", "a", "list", "to", "a", "buffer" ]
e52aa09eaa61510dc48b27603bd9ea116cd6531a
https://github.com/grails/grails-gdoc-engine/blob/e52aa09eaa61510dc48b27603bd9ea116cd6531a/src/main/java/org/radeox/filter/ListFilter.java#L109-L156
155,728
grails/grails-gdoc-engine
src/main/java/org/radeox/engine/BaseRenderEngine.java
BaseRenderEngine.render
public String render(Reader in, RenderContext context) throws IOException { StringBuffer buffer = new StringBuffer(); BufferedReader inputReader = new BufferedReader(in); String line; while ((line = inputReader.readLine()) != null) { buffer.append(line); } return render(buffer.toString(), context); }
java
public String render(Reader in, RenderContext context) throws IOException { StringBuffer buffer = new StringBuffer(); BufferedReader inputReader = new BufferedReader(in); String line; while ((line = inputReader.readLine()) != null) { buffer.append(line); } return render(buffer.toString(), context); }
[ "public", "String", "render", "(", "Reader", "in", ",", "RenderContext", "context", ")", "throws", "IOException", "{", "StringBuffer", "buffer", "=", "new", "StringBuffer", "(", ")", ";", "BufferedReader", "inputReader", "=", "new", "BufferedReader", "(", "in", ")", ";", "String", "line", ";", "while", "(", "(", "line", "=", "inputReader", ".", "readLine", "(", ")", ")", "!=", "null", ")", "{", "buffer", ".", "append", "(", "line", ")", ";", "}", "return", "render", "(", "buffer", ".", "toString", "(", ")", ",", "context", ")", ";", "}" ]
Render an input with text markup from a Reader and write the result to a writer @param in Reader to read the input from @param context Special context for the render engine, e.g. with configuration information
[ "Render", "an", "input", "with", "text", "markup", "from", "a", "Reader", "and", "write", "the", "result", "to", "a", "writer" ]
e52aa09eaa61510dc48b27603bd9ea116cd6531a
https://github.com/grails/grails-gdoc-engine/blob/e52aa09eaa61510dc48b27603bd9ea116cd6531a/src/main/java/org/radeox/engine/BaseRenderEngine.java#L119-L127
155,729
bushidowallet/bushido-java-service
bushido-service-lib/src/main/java/com/bccapi/bitlib/StandardTransactionBuilder.java
StandardTransactionBuilder.createOutput
private TransactionOutput createOutput(Address sendTo, long value) { ScriptOutput script; if (sendTo.isMultisig(_network)) { script = new ScriptOutputMultisig(sendTo.getTypeSpecificBytes()); } else { script = new ScriptOutputStandard(sendTo.getTypeSpecificBytes()); } TransactionOutput output = new TransactionOutput(value, script); return output; }
java
private TransactionOutput createOutput(Address sendTo, long value) { ScriptOutput script; if (sendTo.isMultisig(_network)) { script = new ScriptOutputMultisig(sendTo.getTypeSpecificBytes()); } else { script = new ScriptOutputStandard(sendTo.getTypeSpecificBytes()); } TransactionOutput output = new TransactionOutput(value, script); return output; }
[ "private", "TransactionOutput", "createOutput", "(", "Address", "sendTo", ",", "long", "value", ")", "{", "ScriptOutput", "script", ";", "if", "(", "sendTo", ".", "isMultisig", "(", "_network", ")", ")", "{", "script", "=", "new", "ScriptOutputMultisig", "(", "sendTo", ".", "getTypeSpecificBytes", "(", ")", ")", ";", "}", "else", "{", "script", "=", "new", "ScriptOutputStandard", "(", "sendTo", ".", "getTypeSpecificBytes", "(", ")", ")", ";", "}", "TransactionOutput", "output", "=", "new", "TransactionOutput", "(", "value", ",", "script", ")", ";", "return", "output", ";", "}" ]
XXX Should we support pubkey outputs?
[ "XXX", "Should", "we", "support", "pubkey", "outputs?" ]
e1a0157527e57459b509718044d2df44084876a2
https://github.com/bushidowallet/bushido-java-service/blob/e1a0157527e57459b509718044d2df44084876a2/bushido-service-lib/src/main/java/com/bccapi/bitlib/StandardTransactionBuilder.java#L171-L180
155,730
bushidowallet/bushido-java-service
bushido-service-lib/src/main/java/com/bccapi/bitlib/StandardTransactionBuilder.java
StandardTransactionBuilder.createUnsignedTransaction
public UnsignedTransaction createUnsignedTransaction(List<UnspentTransactionOutput> unspent, Address changeAddress, PublicKeyRing keyRing, NetworkParameters network) throws InsufficientFundsException { long fee = MIN_MINER_FEE; while (true) { UnsignedTransaction unsigned; try { unsigned = createUnsignedTransaction(unspent, changeAddress, fee, keyRing, network); } catch (InsufficientFundsException e) { // We did not even have enough funds to pay the minimum fee throw e; } int txSize = estimateTransacrionSize(unsigned); // fee is based on the size of the transaction, we have to pay for // every 1000 bytes long requiredFee = (1 + (txSize / 1000)) * MIN_MINER_FEE; if (fee >= requiredFee) { return unsigned; } // collect coins anew with an increased fee fee += MIN_MINER_FEE; } }
java
public UnsignedTransaction createUnsignedTransaction(List<UnspentTransactionOutput> unspent, Address changeAddress, PublicKeyRing keyRing, NetworkParameters network) throws InsufficientFundsException { long fee = MIN_MINER_FEE; while (true) { UnsignedTransaction unsigned; try { unsigned = createUnsignedTransaction(unspent, changeAddress, fee, keyRing, network); } catch (InsufficientFundsException e) { // We did not even have enough funds to pay the minimum fee throw e; } int txSize = estimateTransacrionSize(unsigned); // fee is based on the size of the transaction, we have to pay for // every 1000 bytes long requiredFee = (1 + (txSize / 1000)) * MIN_MINER_FEE; if (fee >= requiredFee) { return unsigned; } // collect coins anew with an increased fee fee += MIN_MINER_FEE; } }
[ "public", "UnsignedTransaction", "createUnsignedTransaction", "(", "List", "<", "UnspentTransactionOutput", ">", "unspent", ",", "Address", "changeAddress", ",", "PublicKeyRing", "keyRing", ",", "NetworkParameters", "network", ")", "throws", "InsufficientFundsException", "{", "long", "fee", "=", "MIN_MINER_FEE", ";", "while", "(", "true", ")", "{", "UnsignedTransaction", "unsigned", ";", "try", "{", "unsigned", "=", "createUnsignedTransaction", "(", "unspent", ",", "changeAddress", ",", "fee", ",", "keyRing", ",", "network", ")", ";", "}", "catch", "(", "InsufficientFundsException", "e", ")", "{", "// We did not even have enough funds to pay the minimum fee", "throw", "e", ";", "}", "int", "txSize", "=", "estimateTransacrionSize", "(", "unsigned", ")", ";", "// fee is based on the size of the transaction, we have to pay for", "// every 1000 bytes", "long", "requiredFee", "=", "(", "1", "+", "(", "txSize", "/", "1000", ")", ")", "*", "MIN_MINER_FEE", ";", "if", "(", "fee", ">=", "requiredFee", ")", "{", "return", "unsigned", ";", "}", "// collect coins anew with an increased fee", "fee", "+=", "MIN_MINER_FEE", ";", "}", "}" ]
Create an unsigned transaction without specifying a fee. The fee is automatically calculated to pass minimum relay and mining requirements. @param unspent The list of unspent transaction outputs that can be used as funding @param changeAddress The address to send any change to @param keyRing The public key ring matching the unspent outputs @param network The network we are working on @return An unsigned transaction or null if not enough funds were available @throws InsufficientFundsException if there is not enough funds available
[ "Create", "an", "unsigned", "transaction", "without", "specifying", "a", "fee", ".", "The", "fee", "is", "automatically", "calculated", "to", "pass", "minimum", "relay", "and", "mining", "requirements", "." ]
e1a0157527e57459b509718044d2df44084876a2
https://github.com/bushidowallet/bushido-java-service/blob/e1a0157527e57459b509718044d2df44084876a2/bushido-service-lib/src/main/java/com/bccapi/bitlib/StandardTransactionBuilder.java#L213-L234
155,731
bushidowallet/bushido-java-service
bushido-service-lib/src/main/java/com/bccapi/bitlib/StandardTransactionBuilder.java
StandardTransactionBuilder.createUnsignedTransaction
public UnsignedTransaction createUnsignedTransaction(List<UnspentTransactionOutput> unspent, Address changeAddress, long fee, PublicKeyRing keyRing, NetworkParameters network) throws InsufficientFundsException { // Make a copy so we can mutate the list unspent = new LinkedList<UnspentTransactionOutput>(unspent); List<UnspentTransactionOutput> funding = new LinkedList<UnspentTransactionOutput>(); long outputSum = outputSum(); long toSend = fee + outputSum; long found = 0; while (found < toSend) { UnspentTransactionOutput output = extractOldest(unspent); if (output == null) { // We do not have enough funds throw new InsufficientFundsException(outputSum, fee); } found += output.value; funding.add(output); } // We have our funding, calculate change long change = found - toSend; // Get a copy of all outputs List<TransactionOutput> outputs = new LinkedList<TransactionOutput>(_outputs); if (change > 0) { // We have more funds than needed, add an output to our change address outputs.add(createOutput(changeAddress, change)); } return new UnsignedTransaction(outputs, funding, keyRing, network); }
java
public UnsignedTransaction createUnsignedTransaction(List<UnspentTransactionOutput> unspent, Address changeAddress, long fee, PublicKeyRing keyRing, NetworkParameters network) throws InsufficientFundsException { // Make a copy so we can mutate the list unspent = new LinkedList<UnspentTransactionOutput>(unspent); List<UnspentTransactionOutput> funding = new LinkedList<UnspentTransactionOutput>(); long outputSum = outputSum(); long toSend = fee + outputSum; long found = 0; while (found < toSend) { UnspentTransactionOutput output = extractOldest(unspent); if (output == null) { // We do not have enough funds throw new InsufficientFundsException(outputSum, fee); } found += output.value; funding.add(output); } // We have our funding, calculate change long change = found - toSend; // Get a copy of all outputs List<TransactionOutput> outputs = new LinkedList<TransactionOutput>(_outputs); if (change > 0) { // We have more funds than needed, add an output to our change address outputs.add(createOutput(changeAddress, change)); } return new UnsignedTransaction(outputs, funding, keyRing, network); }
[ "public", "UnsignedTransaction", "createUnsignedTransaction", "(", "List", "<", "UnspentTransactionOutput", ">", "unspent", ",", "Address", "changeAddress", ",", "long", "fee", ",", "PublicKeyRing", "keyRing", ",", "NetworkParameters", "network", ")", "throws", "InsufficientFundsException", "{", "// Make a copy so we can mutate the list", "unspent", "=", "new", "LinkedList", "<", "UnspentTransactionOutput", ">", "(", "unspent", ")", ";", "List", "<", "UnspentTransactionOutput", ">", "funding", "=", "new", "LinkedList", "<", "UnspentTransactionOutput", ">", "(", ")", ";", "long", "outputSum", "=", "outputSum", "(", ")", ";", "long", "toSend", "=", "fee", "+", "outputSum", ";", "long", "found", "=", "0", ";", "while", "(", "found", "<", "toSend", ")", "{", "UnspentTransactionOutput", "output", "=", "extractOldest", "(", "unspent", ")", ";", "if", "(", "output", "==", "null", ")", "{", "// We do not have enough funds", "throw", "new", "InsufficientFundsException", "(", "outputSum", ",", "fee", ")", ";", "}", "found", "+=", "output", ".", "value", ";", "funding", ".", "add", "(", "output", ")", ";", "}", "// We have our funding, calculate change", "long", "change", "=", "found", "-", "toSend", ";", "// Get a copy of all outputs", "List", "<", "TransactionOutput", ">", "outputs", "=", "new", "LinkedList", "<", "TransactionOutput", ">", "(", "_outputs", ")", ";", "if", "(", "change", ">", "0", ")", "{", "// We have more funds than needed, add an output to our change address", "outputs", ".", "add", "(", "createOutput", "(", "changeAddress", ",", "change", ")", ")", ";", "}", "return", "new", "UnsignedTransaction", "(", "outputs", ",", "funding", ",", "keyRing", ",", "network", ")", ";", "}" ]
Create an unsigned transaction with a specific miner fee. Note that specifying a miner fee that is too low may result in hanging transactions that never confirm. @param unspent The list of unspent transaction outputs that can be used as funding @param changeAddress The address to send any change to @param fee The miner fee to pay. Specifying zero may result in hanging transactions. @param keyRing The public key ring matching the unspent outputs @param network The network we are working on @return An unsigned transaction or null if not enough funds were available @throws InsufficientFundsException
[ "Create", "an", "unsigned", "transaction", "with", "a", "specific", "miner", "fee", ".", "Note", "that", "specifying", "a", "miner", "fee", "that", "is", "too", "low", "may", "result", "in", "hanging", "transactions", "that", "never", "confirm", "." ]
e1a0157527e57459b509718044d2df44084876a2
https://github.com/bushidowallet/bushido-java-service/blob/e1a0157527e57459b509718044d2df44084876a2/bushido-service-lib/src/main/java/com/bccapi/bitlib/StandardTransactionBuilder.java#L256-L285
155,732
foundation-runtime/service-directory
1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java
DirectoryServiceClient.updateInstanceUri
public void updateInstanceUri(String serviceName, String instanceId, String uri, boolean isOwned){ String serviceUri = toInstanceUri(serviceName, instanceId) + "/uri" ; String body = null; try { body = "uri=" + URLEncoder.encode(uri, "UTF-8") + "&isOwned=" + isOwned; } catch (UnsupportedEncodingException e) { LOGGER.error("UTF-8 not supported. ", e); } Map<String, String> headers = new HashMap<String, String>(); headers.put("Content-Type", "application/x-www-form-urlencoded"); HttpResponse result = invoker.invoke(serviceUri, body, HttpMethod.PUT, headers); if (result.getHttpCode() != HTTP_OK) { throw new ServiceException(ErrorCode.REMOTE_DIRECTORY_SERVER_ERROR, "HTTP Code is not OK, code=%s", result.getHttpCode()); } }
java
public void updateInstanceUri(String serviceName, String instanceId, String uri, boolean isOwned){ String serviceUri = toInstanceUri(serviceName, instanceId) + "/uri" ; String body = null; try { body = "uri=" + URLEncoder.encode(uri, "UTF-8") + "&isOwned=" + isOwned; } catch (UnsupportedEncodingException e) { LOGGER.error("UTF-8 not supported. ", e); } Map<String, String> headers = new HashMap<String, String>(); headers.put("Content-Type", "application/x-www-form-urlencoded"); HttpResponse result = invoker.invoke(serviceUri, body, HttpMethod.PUT, headers); if (result.getHttpCode() != HTTP_OK) { throw new ServiceException(ErrorCode.REMOTE_DIRECTORY_SERVER_ERROR, "HTTP Code is not OK, code=%s", result.getHttpCode()); } }
[ "public", "void", "updateInstanceUri", "(", "String", "serviceName", ",", "String", "instanceId", ",", "String", "uri", ",", "boolean", "isOwned", ")", "{", "String", "serviceUri", "=", "toInstanceUri", "(", "serviceName", ",", "instanceId", ")", "+", "\"/uri\"", ";", "String", "body", "=", "null", ";", "try", "{", "body", "=", "\"uri=\"", "+", "URLEncoder", ".", "encode", "(", "uri", ",", "\"UTF-8\"", ")", "+", "\"&isOwned=\"", "+", "isOwned", ";", "}", "catch", "(", "UnsupportedEncodingException", "e", ")", "{", "LOGGER", ".", "error", "(", "\"UTF-8 not supported. \"", ",", "e", ")", ";", "}", "Map", "<", "String", ",", "String", ">", "headers", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "headers", ".", "put", "(", "\"Content-Type\"", ",", "\"application/x-www-form-urlencoded\"", ")", ";", "HttpResponse", "result", "=", "invoker", ".", "invoke", "(", "serviceUri", ",", "body", ",", "HttpMethod", ".", "PUT", ",", "headers", ")", ";", "if", "(", "result", ".", "getHttpCode", "(", ")", "!=", "HTTP_OK", ")", "{", "throw", "new", "ServiceException", "(", "ErrorCode", ".", "REMOTE_DIRECTORY_SERVER_ERROR", ",", "\"HTTP Code is not OK, code=%s\"", ",", "result", ".", "getHttpCode", "(", ")", ")", ";", "}", "}" ]
Update the ServiceInstance attribute "uri". @param serviceName the service name. @param instanceId the instance id. @param uri the ServiceInstance URI. @param isOwned whether the DirectoryAPI owns this ServiceProvider.
[ "Update", "the", "ServiceInstance", "attribute", "uri", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java#L196-L214
155,733
foundation-runtime/service-directory
1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java
DirectoryServiceClient.unregisterInstance
public void unregisterInstance(String serviceName, String instanceId, boolean isOwned){ String uri = toInstanceUri(serviceName, instanceId) + "/" + isOwned; HttpResponse result = invoker.invoke(uri, null, HttpMethod.DELETE); if (result.getHttpCode() != HTTP_OK) { throw new ServiceException(ErrorCode.REMOTE_DIRECTORY_SERVER_ERROR, "HTTP Code is not OK, code=%s", result.getHttpCode()); } }
java
public void unregisterInstance(String serviceName, String instanceId, boolean isOwned){ String uri = toInstanceUri(serviceName, instanceId) + "/" + isOwned; HttpResponse result = invoker.invoke(uri, null, HttpMethod.DELETE); if (result.getHttpCode() != HTTP_OK) { throw new ServiceException(ErrorCode.REMOTE_DIRECTORY_SERVER_ERROR, "HTTP Code is not OK, code=%s", result.getHttpCode()); } }
[ "public", "void", "unregisterInstance", "(", "String", "serviceName", ",", "String", "instanceId", ",", "boolean", "isOwned", ")", "{", "String", "uri", "=", "toInstanceUri", "(", "serviceName", ",", "instanceId", ")", "+", "\"/\"", "+", "isOwned", ";", "HttpResponse", "result", "=", "invoker", ".", "invoke", "(", "uri", ",", "null", ",", "HttpMethod", ".", "DELETE", ")", ";", "if", "(", "result", ".", "getHttpCode", "(", ")", "!=", "HTTP_OK", ")", "{", "throw", "new", "ServiceException", "(", "ErrorCode", ".", "REMOTE_DIRECTORY_SERVER_ERROR", ",", "\"HTTP Code is not OK, code=%s\"", ",", "result", ".", "getHttpCode", "(", ")", ")", ";", "}", "}" ]
Unregister a ServiceInstance. @param serviceName service name. @param instanceId the instance id. @param isOwned whether the DirectoryAPI owns this ServiceProvider.
[ "Unregister", "a", "ServiceInstance", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java#L226-L235
155,734
foundation-runtime/service-directory
1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java
DirectoryServiceClient.sendHeartBeat
public Map<String, OperationResult<String>> sendHeartBeat(Map<String, ServiceInstanceHeartbeat> heartbeatMap){ String body = _serialize(heartbeatMap); HttpResponse result = invoker.invoke("/service/heartbeat", body, HttpMethod.PUT); if (result.getHttpCode() != HTTP_OK) { throw new ServiceException(ErrorCode.REMOTE_DIRECTORY_SERVER_ERROR, "HTTP Code is not OK, code=%s", result.getHttpCode()); } Map<String, OperationResult<String>> operateResult = _deserialize( result.getRetBody(), new TypeReference<Map<String, OperationResult<String>>>(){}); return operateResult; }
java
public Map<String, OperationResult<String>> sendHeartBeat(Map<String, ServiceInstanceHeartbeat> heartbeatMap){ String body = _serialize(heartbeatMap); HttpResponse result = invoker.invoke("/service/heartbeat", body, HttpMethod.PUT); if (result.getHttpCode() != HTTP_OK) { throw new ServiceException(ErrorCode.REMOTE_DIRECTORY_SERVER_ERROR, "HTTP Code is not OK, code=%s", result.getHttpCode()); } Map<String, OperationResult<String>> operateResult = _deserialize( result.getRetBody(), new TypeReference<Map<String, OperationResult<String>>>(){}); return operateResult; }
[ "public", "Map", "<", "String", ",", "OperationResult", "<", "String", ">", ">", "sendHeartBeat", "(", "Map", "<", "String", ",", "ServiceInstanceHeartbeat", ">", "heartbeatMap", ")", "{", "String", "body", "=", "_serialize", "(", "heartbeatMap", ")", ";", "HttpResponse", "result", "=", "invoker", ".", "invoke", "(", "\"/service/heartbeat\"", ",", "body", ",", "HttpMethod", ".", "PUT", ")", ";", "if", "(", "result", ".", "getHttpCode", "(", ")", "!=", "HTTP_OK", ")", "{", "throw", "new", "ServiceException", "(", "ErrorCode", ".", "REMOTE_DIRECTORY_SERVER_ERROR", ",", "\"HTTP Code is not OK, code=%s\"", ",", "result", ".", "getHttpCode", "(", ")", ")", ";", "}", "Map", "<", "String", ",", "OperationResult", "<", "String", ">", ">", "operateResult", "=", "_deserialize", "(", "result", ".", "getRetBody", "(", ")", ",", "new", "TypeReference", "<", "Map", "<", "String", ",", "OperationResult", "<", "String", ">", ">", ">", "(", ")", "{", "}", ")", ";", "return", "operateResult", ";", "}" ]
Send ServiceInstance heartbeats. @param heartbeatMap the ServiceInstances heartbeat Map.
[ "Send", "ServiceInstance", "heartbeats", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java#L243-L257
155,735
foundation-runtime/service-directory
1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java
DirectoryServiceClient.lookupService
public ModelService lookupService(String serviceName){ HttpResponse result = invoker.invoke("/service/" + serviceName , null, HttpMethod.GET); if (result.getHttpCode() != HTTP_OK) { throw new ServiceException(ErrorCode.REMOTE_DIRECTORY_SERVER_ERROR, "HTTP Code is not OK, code=%s", result.getHttpCode()); } ModelService service = _deserialize(result.getRetBody(), ModelService.class); return service; }
java
public ModelService lookupService(String serviceName){ HttpResponse result = invoker.invoke("/service/" + serviceName , null, HttpMethod.GET); if (result.getHttpCode() != HTTP_OK) { throw new ServiceException(ErrorCode.REMOTE_DIRECTORY_SERVER_ERROR, "HTTP Code is not OK, code=%s", result.getHttpCode()); } ModelService service = _deserialize(result.getRetBody(), ModelService.class); return service; }
[ "public", "ModelService", "lookupService", "(", "String", "serviceName", ")", "{", "HttpResponse", "result", "=", "invoker", ".", "invoke", "(", "\"/service/\"", "+", "serviceName", ",", "null", ",", "HttpMethod", ".", "GET", ")", ";", "if", "(", "result", ".", "getHttpCode", "(", ")", "!=", "HTTP_OK", ")", "{", "throw", "new", "ServiceException", "(", "ErrorCode", ".", "REMOTE_DIRECTORY_SERVER_ERROR", ",", "\"HTTP Code is not OK, code=%s\"", ",", "result", ".", "getHttpCode", "(", ")", ")", ";", "}", "ModelService", "service", "=", "_deserialize", "(", "result", ".", "getRetBody", "(", ")", ",", "ModelService", ".", "class", ")", ";", "return", "service", ";", "}" ]
Lookup a Service by serviceName. @param serviceName the service name. @return the ModelService.
[ "Lookup", "a", "Service", "by", "serviceName", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java#L267-L277
155,736
foundation-runtime/service-directory
1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java
DirectoryServiceClient.getAllInstances
public List<ModelServiceInstance> getAllInstances(){ HttpResponse result = invoker.invoke("/service" , null, HttpMethod.GET); if (result.getHttpCode() != HTTP_OK) { throw new ServiceException(ErrorCode.REMOTE_DIRECTORY_SERVER_ERROR, "HTTP Code is not OK, code=%s", result.getHttpCode()); } List<ModelServiceInstance> allInstances = _deserialize(result.getRetBody(), new TypeReference<List<ModelServiceInstance>>(){}); return allInstances; }
java
public List<ModelServiceInstance> getAllInstances(){ HttpResponse result = invoker.invoke("/service" , null, HttpMethod.GET); if (result.getHttpCode() != HTTP_OK) { throw new ServiceException(ErrorCode.REMOTE_DIRECTORY_SERVER_ERROR, "HTTP Code is not OK, code=%s", result.getHttpCode()); } List<ModelServiceInstance> allInstances = _deserialize(result.getRetBody(), new TypeReference<List<ModelServiceInstance>>(){}); return allInstances; }
[ "public", "List", "<", "ModelServiceInstance", ">", "getAllInstances", "(", ")", "{", "HttpResponse", "result", "=", "invoker", ".", "invoke", "(", "\"/service\"", ",", "null", ",", "HttpMethod", ".", "GET", ")", ";", "if", "(", "result", ".", "getHttpCode", "(", ")", "!=", "HTTP_OK", ")", "{", "throw", "new", "ServiceException", "(", "ErrorCode", ".", "REMOTE_DIRECTORY_SERVER_ERROR", ",", "\"HTTP Code is not OK, code=%s\"", ",", "result", ".", "getHttpCode", "(", ")", ")", ";", "}", "List", "<", "ModelServiceInstance", ">", "allInstances", "=", "_deserialize", "(", "result", ".", "getRetBody", "(", ")", ",", "new", "TypeReference", "<", "List", "<", "ModelServiceInstance", ">", ">", "(", ")", "{", "}", ")", ";", "return", "allInstances", ";", "}" ]
Get all service instances. @return the ModelServiceInstance list.
[ "Get", "all", "service", "instances", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java#L285-L295
155,737
foundation-runtime/service-directory
1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java
DirectoryServiceClient.getChangedServices
public Map<String, OperationResult<ModelService>> getChangedServices(Map<String, ModelService> services){ String body = _serialize(services); HttpResponse result = invoker.invoke("/service/changing" , body, HttpMethod.POST); if (result.getHttpCode() != HTTP_OK) { throw new ServiceException(ErrorCode.REMOTE_DIRECTORY_SERVER_ERROR, "HTTP Code is not OK, code=%s", result.getHttpCode()); } Map<String, OperationResult<ModelService>> changedServices = _deserialize( result.getRetBody(), new TypeReference<Map<String, OperationResult<ModelService>>>(){}); return changedServices; }
java
public Map<String, OperationResult<ModelService>> getChangedServices(Map<String, ModelService> services){ String body = _serialize(services); HttpResponse result = invoker.invoke("/service/changing" , body, HttpMethod.POST); if (result.getHttpCode() != HTTP_OK) { throw new ServiceException(ErrorCode.REMOTE_DIRECTORY_SERVER_ERROR, "HTTP Code is not OK, code=%s", result.getHttpCode()); } Map<String, OperationResult<ModelService>> changedServices = _deserialize( result.getRetBody(), new TypeReference<Map<String, OperationResult<ModelService>>>(){}); return changedServices; }
[ "public", "Map", "<", "String", ",", "OperationResult", "<", "ModelService", ">", ">", "getChangedServices", "(", "Map", "<", "String", ",", "ModelService", ">", "services", ")", "{", "String", "body", "=", "_serialize", "(", "services", ")", ";", "HttpResponse", "result", "=", "invoker", ".", "invoke", "(", "\"/service/changing\"", ",", "body", ",", "HttpMethod", ".", "POST", ")", ";", "if", "(", "result", ".", "getHttpCode", "(", ")", "!=", "HTTP_OK", ")", "{", "throw", "new", "ServiceException", "(", "ErrorCode", ".", "REMOTE_DIRECTORY_SERVER_ERROR", ",", "\"HTTP Code is not OK, code=%s\"", ",", "result", ".", "getHttpCode", "(", ")", ")", ";", "}", "Map", "<", "String", ",", "OperationResult", "<", "ModelService", ">", ">", "changedServices", "=", "_deserialize", "(", "result", ".", "getRetBody", "(", ")", ",", "new", "TypeReference", "<", "Map", "<", "String", ",", "OperationResult", "<", "ModelService", ">", ">", ">", "(", ")", "{", "}", ")", ";", "return", "changedServices", ";", "}" ]
Get the changed services list. @param services the Service list. @return the list of Services that have been changed. @throws ServiceException
[ "Get", "the", "changed", "services", "list", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java#L329-L342
155,738
foundation-runtime/service-directory
1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java
DirectoryServiceClient.getChangedMetadataKeys
public Map<String, OperationResult<ModelMetadataKey>> getChangedMetadataKeys(Map<String, ModelMetadataKey> keys) { String body = _serialize(keys); HttpResponse result = invoker.invoke("/metadatakey/changing" , body, HttpMethod.POST); if (result.getHttpCode() != HTTP_OK) { throw new ServiceException(ErrorCode.REMOTE_DIRECTORY_SERVER_ERROR, "HTTP Code is not OK, code=%s", result.getHttpCode()); } Map<String, OperationResult<ModelMetadataKey>> changedKeys = _deserialize( result.getRetBody(), new TypeReference<Map<String, OperationResult<ModelMetadataKey>>>(){}); return changedKeys; }
java
public Map<String, OperationResult<ModelMetadataKey>> getChangedMetadataKeys(Map<String, ModelMetadataKey> keys) { String body = _serialize(keys); HttpResponse result = invoker.invoke("/metadatakey/changing" , body, HttpMethod.POST); if (result.getHttpCode() != HTTP_OK) { throw new ServiceException(ErrorCode.REMOTE_DIRECTORY_SERVER_ERROR, "HTTP Code is not OK, code=%s", result.getHttpCode()); } Map<String, OperationResult<ModelMetadataKey>> changedKeys = _deserialize( result.getRetBody(), new TypeReference<Map<String, OperationResult<ModelMetadataKey>>>(){}); return changedKeys; }
[ "public", "Map", "<", "String", ",", "OperationResult", "<", "ModelMetadataKey", ">", ">", "getChangedMetadataKeys", "(", "Map", "<", "String", ",", "ModelMetadataKey", ">", "keys", ")", "{", "String", "body", "=", "_serialize", "(", "keys", ")", ";", "HttpResponse", "result", "=", "invoker", ".", "invoke", "(", "\"/metadatakey/changing\"", ",", "body", ",", "HttpMethod", ".", "POST", ")", ";", "if", "(", "result", ".", "getHttpCode", "(", ")", "!=", "HTTP_OK", ")", "{", "throw", "new", "ServiceException", "(", "ErrorCode", ".", "REMOTE_DIRECTORY_SERVER_ERROR", ",", "\"HTTP Code is not OK, code=%s\"", ",", "result", ".", "getHttpCode", "(", ")", ")", ";", "}", "Map", "<", "String", ",", "OperationResult", "<", "ModelMetadataKey", ">", ">", "changedKeys", "=", "_deserialize", "(", "result", ".", "getRetBody", "(", ")", ",", "new", "TypeReference", "<", "Map", "<", "String", ",", "OperationResult", "<", "ModelMetadataKey", ">", ">", ">", "(", ")", "{", "}", ")", ";", "return", "changedKeys", ";", "}" ]
Get the changed MetadataKey list. @param keys the MetadataKey List. @return the list of ModelMetadataKeys that have been changed.
[ "Get", "the", "changed", "MetadataKey", "list", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.1/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/DirectoryServiceClient.java#L352-L365
155,739
xmlet/XsdAsmFaster
src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmAttributes.java
XsdAsmAttributes.loadRestrictionsToAttribute
private static void loadRestrictionsToAttribute(XsdAttribute attribute, MethodVisitor mVisitor, String javaType, boolean hasEnum) { getAttributeRestrictions(attribute).forEach(restriction -> loadRestrictionToAttribute(mVisitor, restriction, javaType, hasEnum ? 1 : 0)); mVisitor.visitInsn(RETURN); mVisitor.visitMaxs(4, hasEnum ? 2 : 1); mVisitor.visitEnd(); }
java
private static void loadRestrictionsToAttribute(XsdAttribute attribute, MethodVisitor mVisitor, String javaType, boolean hasEnum) { getAttributeRestrictions(attribute).forEach(restriction -> loadRestrictionToAttribute(mVisitor, restriction, javaType, hasEnum ? 1 : 0)); mVisitor.visitInsn(RETURN); mVisitor.visitMaxs(4, hasEnum ? 2 : 1); mVisitor.visitEnd(); }
[ "private", "static", "void", "loadRestrictionsToAttribute", "(", "XsdAttribute", "attribute", ",", "MethodVisitor", "mVisitor", ",", "String", "javaType", ",", "boolean", "hasEnum", ")", "{", "getAttributeRestrictions", "(", "attribute", ")", ".", "forEach", "(", "restriction", "->", "loadRestrictionToAttribute", "(", "mVisitor", ",", "restriction", ",", "javaType", ",", "hasEnum", "?", "1", ":", "0", ")", ")", ";", "mVisitor", ".", "visitInsn", "(", "RETURN", ")", ";", "mVisitor", ".", "visitMaxs", "(", "4", ",", "hasEnum", "?", "2", ":", "1", ")", ";", "mVisitor", ".", "visitEnd", "(", ")", ";", "}" ]
Loads all the existing restrictions to the attribute class.
[ "Loads", "all", "the", "existing", "restrictions", "to", "the", "attribute", "class", "." ]
ccb78f9dd4b957ad5ac1ca349eaf24338c421e94
https://github.com/xmlet/XsdAsmFaster/blob/ccb78f9dd4b957ad5ac1ca349eaf24338c421e94/src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmAttributes.java#L180-L186
155,740
xmlet/XsdAsmFaster
src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmAttributes.java
XsdAsmAttributes.numericAdjustment
private static void numericAdjustment(MethodVisitor mVisitor, String javaType) { adjustmentsMapper.getOrDefault(javaType, XsdAsmAttributes::doubleAdjustment).accept(mVisitor); }
java
private static void numericAdjustment(MethodVisitor mVisitor, String javaType) { adjustmentsMapper.getOrDefault(javaType, XsdAsmAttributes::doubleAdjustment).accept(mVisitor); }
[ "private", "static", "void", "numericAdjustment", "(", "MethodVisitor", "mVisitor", ",", "String", "javaType", ")", "{", "adjustmentsMapper", ".", "getOrDefault", "(", "javaType", ",", "XsdAsmAttributes", "::", "doubleAdjustment", ")", ".", "accept", "(", "mVisitor", ")", ";", "}" ]
Applies a cast to numeric types, i.e. int, short, long, to double. @param mVisitor The visitor of the attribute constructor. @param javaType The type of the argument received in the constructor.
[ "Applies", "a", "cast", "to", "numeric", "types", "i", ".", "e", ".", "int", "short", "long", "to", "double", "." ]
ccb78f9dd4b957ad5ac1ca349eaf24338c421e94
https://github.com/xmlet/XsdAsmFaster/blob/ccb78f9dd4b957ad5ac1ca349eaf24338c421e94/src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmAttributes.java#L280-L282
155,741
morimekta/utils
diff-util/src/main/java/net/morimekta/diff/DiffBase.java
DiffBase.prettyHtml
public String prettyHtml() { StringBuilder html = new StringBuilder(); for (Change aDiff : getChangeList()) { String text = aDiff.text.replace("&", "&amp;") .replace("<", "&lt;") .replace(">", "&gt;") .replace("\n", "&para;<br>"); switch (aDiff.operation) { case INSERT: html.append("<ins style=\"background:#e6ffe6;\">").append(text) .append("</ins>"); break; case DELETE: html.append("<del style=\"background:#ffe6e6;\">").append(text) .append("</del>"); break; case EQUAL: html.append("<span>").append(text).append("</span>"); break; } } return html.toString(); }
java
public String prettyHtml() { StringBuilder html = new StringBuilder(); for (Change aDiff : getChangeList()) { String text = aDiff.text.replace("&", "&amp;") .replace("<", "&lt;") .replace(">", "&gt;") .replace("\n", "&para;<br>"); switch (aDiff.operation) { case INSERT: html.append("<ins style=\"background:#e6ffe6;\">").append(text) .append("</ins>"); break; case DELETE: html.append("<del style=\"background:#ffe6e6;\">").append(text) .append("</del>"); break; case EQUAL: html.append("<span>").append(text).append("</span>"); break; } } return html.toString(); }
[ "public", "String", "prettyHtml", "(", ")", "{", "StringBuilder", "html", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "Change", "aDiff", ":", "getChangeList", "(", ")", ")", "{", "String", "text", "=", "aDiff", ".", "text", ".", "replace", "(", "\"&\"", ",", "\"&amp;\"", ")", ".", "replace", "(", "\"<\"", ",", "\"&lt;\"", ")", ".", "replace", "(", "\">\"", ",", "\"&gt;\"", ")", ".", "replace", "(", "\"\\n\"", ",", "\"&para;<br>\"", ")", ";", "switch", "(", "aDiff", ".", "operation", ")", "{", "case", "INSERT", ":", "html", ".", "append", "(", "\"<ins style=\\\"background:#e6ffe6;\\\">\"", ")", ".", "append", "(", "text", ")", ".", "append", "(", "\"</ins>\"", ")", ";", "break", ";", "case", "DELETE", ":", "html", ".", "append", "(", "\"<del style=\\\"background:#ffe6e6;\\\">\"", ")", ".", "append", "(", "text", ")", ".", "append", "(", "\"</del>\"", ")", ";", "break", ";", "case", "EQUAL", ":", "html", ".", "append", "(", "\"<span>\"", ")", ".", "append", "(", "text", ")", ".", "append", "(", "\"</span>\"", ")", ";", "break", ";", "}", "}", "return", "html", ".", "toString", "(", ")", ";", "}" ]
Convert a DiffBase list into a pretty HTML report. @return HTML representation.
[ "Convert", "a", "DiffBase", "list", "into", "a", "pretty", "HTML", "report", "." ]
dc987485902f1a7d58169c89c61db97425a6226d
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/diff-util/src/main/java/net/morimekta/diff/DiffBase.java#L91-L113
155,742
morimekta/utils
diff-util/src/main/java/net/morimekta/diff/DiffBase.java
DiffBase.toDelta
public String toDelta() { StringBuilder text = new StringBuilder(); for (Change aDiff : getChangeList()) { switch (aDiff.operation) { case INSERT: try { text.append("+").append(URLEncoder.encode(aDiff.text, "UTF-8") .replace('+', ' ')).append("\t"); } catch (UnsupportedEncodingException e) { // Not likely on modern system. throw new Error("This system does not support UTF-8.", e); } break; case DELETE: text.append("-").append(aDiff.text.length()).append("\t"); break; case EQUAL: text.append("=").append(aDiff.text.length()).append("\t"); break; } } String delta = text.toString(); if (delta.length() != 0) { // Strip off trailing tab character. delta = delta.substring(0, delta.length() - 1); delta = Strings.unescapeForEncodeUriCompatability(delta); } return delta; }
java
public String toDelta() { StringBuilder text = new StringBuilder(); for (Change aDiff : getChangeList()) { switch (aDiff.operation) { case INSERT: try { text.append("+").append(URLEncoder.encode(aDiff.text, "UTF-8") .replace('+', ' ')).append("\t"); } catch (UnsupportedEncodingException e) { // Not likely on modern system. throw new Error("This system does not support UTF-8.", e); } break; case DELETE: text.append("-").append(aDiff.text.length()).append("\t"); break; case EQUAL: text.append("=").append(aDiff.text.length()).append("\t"); break; } } String delta = text.toString(); if (delta.length() != 0) { // Strip off trailing tab character. delta = delta.substring(0, delta.length() - 1); delta = Strings.unescapeForEncodeUriCompatability(delta); } return delta; }
[ "public", "String", "toDelta", "(", ")", "{", "StringBuilder", "text", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "Change", "aDiff", ":", "getChangeList", "(", ")", ")", "{", "switch", "(", "aDiff", ".", "operation", ")", "{", "case", "INSERT", ":", "try", "{", "text", ".", "append", "(", "\"+\"", ")", ".", "append", "(", "URLEncoder", ".", "encode", "(", "aDiff", ".", "text", ",", "\"UTF-8\"", ")", ".", "replace", "(", "'", "'", ",", "'", "'", ")", ")", ".", "append", "(", "\"\\t\"", ")", ";", "}", "catch", "(", "UnsupportedEncodingException", "e", ")", "{", "// Not likely on modern system.", "throw", "new", "Error", "(", "\"This system does not support UTF-8.\"", ",", "e", ")", ";", "}", "break", ";", "case", "DELETE", ":", "text", ".", "append", "(", "\"-\"", ")", ".", "append", "(", "aDiff", ".", "text", ".", "length", "(", ")", ")", ".", "append", "(", "\"\\t\"", ")", ";", "break", ";", "case", "EQUAL", ":", "text", ".", "append", "(", "\"=\"", ")", ".", "append", "(", "aDiff", ".", "text", ".", "length", "(", ")", ")", ".", "append", "(", "\"\\t\"", ")", ";", "break", ";", "}", "}", "String", "delta", "=", "text", ".", "toString", "(", ")", ";", "if", "(", "delta", ".", "length", "(", ")", "!=", "0", ")", "{", "// Strip off trailing tab character.", "delta", "=", "delta", ".", "substring", "(", "0", ",", "delta", ".", "length", "(", ")", "-", "1", ")", ";", "delta", "=", "Strings", ".", "unescapeForEncodeUriCompatability", "(", "delta", ")", ";", "}", "return", "delta", ";", "}" ]
Crush the diff into an encoded string which describes the operations required to transform text1 into text2. E.g. "=3\t-2\t+ing" -&gt; Keep 3 chars, delete 2 chars, insert 'ing'. Operations are tab-separated. Inserted text is escaped using %xx notation. @return Delta text.
[ "Crush", "the", "diff", "into", "an", "encoded", "string", "which", "describes", "the", "operations", "required", "to", "transform", "text1", "into", "text2", ".", "E", ".", "g", ".", "=", "3", "\\", "t", "-", "2", "\\", "t", "+", "ing", "-", "&gt", ";", "Keep", "3", "chars", "delete", "2", "chars", "insert", "ing", ".", "Operations", "are", "tab", "-", "separated", ".", "Inserted", "text", "is", "escaped", "using", "%xx", "notation", "." ]
dc987485902f1a7d58169c89c61db97425a6226d
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/diff-util/src/main/java/net/morimekta/diff/DiffBase.java#L181-L209
155,743
morimekta/utils
diff-util/src/main/java/net/morimekta/diff/DiffBase.java
DiffBase.linesToCharsMunge
private String linesToCharsMunge(String text, List<String> lineArray, Map<String, Integer> lineHash) { int lineStart = 0; int lineEnd = -1; String line; StringBuilder chars = new StringBuilder(); // Walk the text, pulling out a substring for each line. // text.split('\n') would would temporarily double our memory footprint. // Modifying text would create many large strings to garbage collect. while (lineEnd < text.length() - 1) { lineEnd = text.indexOf('\n', lineStart); if (lineEnd == -1) { lineEnd = text.length() - 1; } line = text.substring(lineStart, lineEnd + 1); lineStart = lineEnd + 1; if (lineHash.containsKey(line)) { chars.append(String.valueOf((char) (int) lineHash.get(line))); } else { lineArray.add(line); lineHash.put(line, lineArray.size() - 1); chars.append(String.valueOf((char) (lineArray.size() - 1))); } } return chars.toString(); }
java
private String linesToCharsMunge(String text, List<String> lineArray, Map<String, Integer> lineHash) { int lineStart = 0; int lineEnd = -1; String line; StringBuilder chars = new StringBuilder(); // Walk the text, pulling out a substring for each line. // text.split('\n') would would temporarily double our memory footprint. // Modifying text would create many large strings to garbage collect. while (lineEnd < text.length() - 1) { lineEnd = text.indexOf('\n', lineStart); if (lineEnd == -1) { lineEnd = text.length() - 1; } line = text.substring(lineStart, lineEnd + 1); lineStart = lineEnd + 1; if (lineHash.containsKey(line)) { chars.append(String.valueOf((char) (int) lineHash.get(line))); } else { lineArray.add(line); lineHash.put(line, lineArray.size() - 1); chars.append(String.valueOf((char) (lineArray.size() - 1))); } } return chars.toString(); }
[ "private", "String", "linesToCharsMunge", "(", "String", "text", ",", "List", "<", "String", ">", "lineArray", ",", "Map", "<", "String", ",", "Integer", ">", "lineHash", ")", "{", "int", "lineStart", "=", "0", ";", "int", "lineEnd", "=", "-", "1", ";", "String", "line", ";", "StringBuilder", "chars", "=", "new", "StringBuilder", "(", ")", ";", "// Walk the text, pulling out a substring for each line.", "// text.split('\\n') would would temporarily double our memory footprint.", "// Modifying text would create many large strings to garbage collect.", "while", "(", "lineEnd", "<", "text", ".", "length", "(", ")", "-", "1", ")", "{", "lineEnd", "=", "text", ".", "indexOf", "(", "'", "'", ",", "lineStart", ")", ";", "if", "(", "lineEnd", "==", "-", "1", ")", "{", "lineEnd", "=", "text", ".", "length", "(", ")", "-", "1", ";", "}", "line", "=", "text", ".", "substring", "(", "lineStart", ",", "lineEnd", "+", "1", ")", ";", "lineStart", "=", "lineEnd", "+", "1", ";", "if", "(", "lineHash", ".", "containsKey", "(", "line", ")", ")", "{", "chars", ".", "append", "(", "String", ".", "valueOf", "(", "(", "char", ")", "(", "int", ")", "lineHash", ".", "get", "(", "line", ")", ")", ")", ";", "}", "else", "{", "lineArray", ".", "add", "(", "line", ")", ";", "lineHash", ".", "put", "(", "line", ",", "lineArray", ".", "size", "(", ")", "-", "1", ")", ";", "chars", ".", "append", "(", "String", ".", "valueOf", "(", "(", "char", ")", "(", "lineArray", ".", "size", "(", ")", "-", "1", ")", ")", ")", ";", "}", "}", "return", "chars", ".", "toString", "(", ")", ";", "}" ]
Split a text into a list of strings. Reduce the texts to a string of hashes where each Unicode character represents one line. @param text String to encode. @param lineArray List of unique strings. @param lineHash Map of strings to indices. @return Encoded string.
[ "Split", "a", "text", "into", "a", "list", "of", "strings", ".", "Reduce", "the", "texts", "to", "a", "string", "of", "hashes", "where", "each", "Unicode", "character", "represents", "one", "line", "." ]
dc987485902f1a7d58169c89c61db97425a6226d
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/diff-util/src/main/java/net/morimekta/diff/DiffBase.java#L680-L706
155,744
Sonoport/freesound-java
src/main/java/com/sonoport/freesound/query/search/TextSearch.java
TextSearch.filter
public TextSearch filter(final SearchFilter filter) { if (filters == null) { filters = new HashSet<SearchFilter>(); } filters.add(filter); return this; }
java
public TextSearch filter(final SearchFilter filter) { if (filters == null) { filters = new HashSet<SearchFilter>(); } filters.add(filter); return this; }
[ "public", "TextSearch", "filter", "(", "final", "SearchFilter", "filter", ")", "{", "if", "(", "filters", "==", "null", ")", "{", "filters", "=", "new", "HashSet", "<", "SearchFilter", ">", "(", ")", ";", "}", "filters", ".", "add", "(", "filter", ")", ";", "return", "this", ";", "}" ]
Add a filter to the query using the Fluent API approach. @param filter The filter to add @return The current query
[ "Add", "a", "filter", "to", "the", "query", "using", "the", "Fluent", "API", "approach", "." ]
ab029e25de068c6f8cc028bc7f916938fd97c036
https://github.com/Sonoport/freesound-java/blob/ab029e25de068c6f8cc028bc7f916938fd97c036/src/main/java/com/sonoport/freesound/query/search/TextSearch.java#L92-L99
155,745
foundation-runtime/service-directory
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/LookupManagerImpl.java
LookupManagerImpl.stop
@Override public void stop(){ if(isStarted){ synchronized (this) { if (isStarted) { if (getLookupService() instanceof Closable) { ((Closable) getLookupService()).stop(); } isStarted = false; } } } }
java
@Override public void stop(){ if(isStarted){ synchronized (this) { if (isStarted) { if (getLookupService() instanceof Closable) { ((Closable) getLookupService()).stop(); } isStarted = false; } } } }
[ "@", "Override", "public", "void", "stop", "(", ")", "{", "if", "(", "isStarted", ")", "{", "synchronized", "(", "this", ")", "{", "if", "(", "isStarted", ")", "{", "if", "(", "getLookupService", "(", ")", "instanceof", "Closable", ")", "{", "(", "(", "Closable", ")", "getLookupService", "(", ")", ")", ".", "stop", "(", ")", ";", "}", "isStarted", "=", "false", ";", "}", "}", "}", "}" ]
Stop the LookupManagerImpl it is idempotent, it can be invoked multiple times while in same state and is not thread safe.
[ "Stop", "the", "LookupManagerImpl" ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/LookupManagerImpl.java#L112-L124
155,746
foundation-runtime/service-directory
2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/LookupManagerImpl.java
LookupManagerImpl.getLookupService
private DirectoryLookupService getLookupService(){ if(lookupService == null){ synchronized(this){ if(lookupService == null){ boolean cacheEnabled = Configurations.getBoolean(SD_API_CACHE_ENABLED_PROPERTY, SD_API_CACHE_ENABLED_DEFAULT); if(cacheEnabled){ CachedDirectoryLookupService service = new CachedDirectoryLookupService(directoryServiceClientManager); service.start(); lookupService = service; LOGGER.info("Created the CachedDirectoryLookupService in LookupManager"); } else { lookupService = new DirectoryLookupService(directoryServiceClientManager); LOGGER.info("Created the DirectoryLookupService in LookupManager"); } } } } return lookupService; }
java
private DirectoryLookupService getLookupService(){ if(lookupService == null){ synchronized(this){ if(lookupService == null){ boolean cacheEnabled = Configurations.getBoolean(SD_API_CACHE_ENABLED_PROPERTY, SD_API_CACHE_ENABLED_DEFAULT); if(cacheEnabled){ CachedDirectoryLookupService service = new CachedDirectoryLookupService(directoryServiceClientManager); service.start(); lookupService = service; LOGGER.info("Created the CachedDirectoryLookupService in LookupManager"); } else { lookupService = new DirectoryLookupService(directoryServiceClientManager); LOGGER.info("Created the DirectoryLookupService in LookupManager"); } } } } return lookupService; }
[ "private", "DirectoryLookupService", "getLookupService", "(", ")", "{", "if", "(", "lookupService", "==", "null", ")", "{", "synchronized", "(", "this", ")", "{", "if", "(", "lookupService", "==", "null", ")", "{", "boolean", "cacheEnabled", "=", "Configurations", ".", "getBoolean", "(", "SD_API_CACHE_ENABLED_PROPERTY", ",", "SD_API_CACHE_ENABLED_DEFAULT", ")", ";", "if", "(", "cacheEnabled", ")", "{", "CachedDirectoryLookupService", "service", "=", "new", "CachedDirectoryLookupService", "(", "directoryServiceClientManager", ")", ";", "service", ".", "start", "(", ")", ";", "lookupService", "=", "service", ";", "LOGGER", ".", "info", "(", "\"Created the CachedDirectoryLookupService in LookupManager\"", ")", ";", "}", "else", "{", "lookupService", "=", "new", "DirectoryLookupService", "(", "directoryServiceClientManager", ")", ";", "LOGGER", ".", "info", "(", "\"Created the DirectoryLookupService in LookupManager\"", ")", ";", "}", "}", "}", "}", "return", "lookupService", ";", "}" ]
Get the DirectoryLookupService to do the lookup. It is thread safe and lazy initialized. @return the LookupService.
[ "Get", "the", "DirectoryLookupService", "to", "do", "the", "lookup", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/2.0/sd-api/src/main/java/com/cisco/oss/foundation/directory/impl/LookupManagerImpl.java#L470-L489
155,747
grails/grails-gdoc-engine
src/main/java/org/radeox/util/i18n/ResourceManager.java
ResourceManager.getResourceBundle
public ResourceBundle getResourceBundle(String baseName) { // System.out.println(this + " " + this.locale+" ("+resourceBundles.size()+")"); ResourceBundle bundle = (ResourceBundle) resourceBundles.get(baseName); if(null == bundle) { resourceBundles.put(baseName, bundle = findBundle(baseName)); } return bundle; }
java
public ResourceBundle getResourceBundle(String baseName) { // System.out.println(this + " " + this.locale+" ("+resourceBundles.size()+")"); ResourceBundle bundle = (ResourceBundle) resourceBundles.get(baseName); if(null == bundle) { resourceBundles.put(baseName, bundle = findBundle(baseName)); } return bundle; }
[ "public", "ResourceBundle", "getResourceBundle", "(", "String", "baseName", ")", "{", "// System.out.println(this + \" \" + this.locale+\" (\"+resourceBundles.size()+\")\");", "ResourceBundle", "bundle", "=", "(", "ResourceBundle", ")", "resourceBundles", ".", "get", "(", "baseName", ")", ";", "if", "(", "null", "==", "bundle", ")", "{", "resourceBundles", ".", "put", "(", "baseName", ",", "bundle", "=", "findBundle", "(", "baseName", ")", ")", ";", "}", "return", "bundle", ";", "}" ]
Get the bundle that is active for this thread. This is done by loading either the specified locale based resource bundle and, if that fails, by looping through the fallback locales to locate a usable bundle. @return the resource bundle
[ "Get", "the", "bundle", "that", "is", "active", "for", "this", "thread", ".", "This", "is", "done", "by", "loading", "either", "the", "specified", "locale", "based", "resource", "bundle", "and", "if", "that", "fails", "by", "looping", "through", "the", "fallback", "locales", "to", "locate", "a", "usable", "bundle", "." ]
e52aa09eaa61510dc48b27603bd9ea116cd6531a
https://github.com/grails/grails-gdoc-engine/blob/e52aa09eaa61510dc48b27603bd9ea116cd6531a/src/main/java/org/radeox/util/i18n/ResourceManager.java#L123-L130
155,748
grails/grails-gdoc-engine
src/main/java/org/radeox/util/i18n/ResourceManager.java
ResourceManager.findBundle
private ResourceBundle findBundle(String baseName) { ResourceBundle resourceBundle = null; // first try to load the resource bundle with the specified locale ClassLoader cl = Thread.currentThread().getContextClassLoader(); if (null != locale) { try { resourceBundle = ResourceBundle.getBundle(baseName, locale, cl); } catch (Exception e) { log.fatal("unable to load a default bundle: "+baseName+"_"+locale); } // check that the requested main locale matches the resource bundle's, // since we get the system fallback locale if no match is found if(!resourceBundle.getLocale().equals(locale)) { resourceBundle = null; } } // loop through the fall back locales until a bundle is found if (null == resourceBundle) { if(null != fallback) { while(fallback.hasMoreElements()) { Locale testLocale = (Locale) fallback.nextElement(); log.debug("looking up locale "+testLocale); ResourceBundle testBundle = ResourceBundle.getBundle(baseName, testLocale, cl); String language = testBundle.getLocale().getLanguage(); String country = testBundle.getLocale().getCountry(); if (testBundle.getLocale().equals(testLocale)) { resourceBundle = testBundle; log.debug("found bundle for locale " +baseName+"_"+ testBundle.getLocale()); break; } else if (testLocale.getLanguage().equals(language)) { if (testLocale.getCountry().equals(country)) { // language and country match which is good, keep looking for variant too resourceBundle = testBundle; log.debug("potential bundle: " + baseName + "_" + testBundle.getLocale()); continue; } else { // only accept this if there is no better previous lookup if (null == resourceBundle) { resourceBundle = testBundle; log.debug("potential bundle: " + baseName+"_"+testBundle.getLocale()); } continue; } } } } // make sure the resource bundle is loaded (should not happen) if (null == resourceBundle) { resourceBundle = ResourceBundle.getBundle(baseName); if (null != resourceBundle) { log.debug("system locale bundle taken: " + baseName + "_" + resourceBundle.getLocale()); } } } return resourceBundle; }
java
private ResourceBundle findBundle(String baseName) { ResourceBundle resourceBundle = null; // first try to load the resource bundle with the specified locale ClassLoader cl = Thread.currentThread().getContextClassLoader(); if (null != locale) { try { resourceBundle = ResourceBundle.getBundle(baseName, locale, cl); } catch (Exception e) { log.fatal("unable to load a default bundle: "+baseName+"_"+locale); } // check that the requested main locale matches the resource bundle's, // since we get the system fallback locale if no match is found if(!resourceBundle.getLocale().equals(locale)) { resourceBundle = null; } } // loop through the fall back locales until a bundle is found if (null == resourceBundle) { if(null != fallback) { while(fallback.hasMoreElements()) { Locale testLocale = (Locale) fallback.nextElement(); log.debug("looking up locale "+testLocale); ResourceBundle testBundle = ResourceBundle.getBundle(baseName, testLocale, cl); String language = testBundle.getLocale().getLanguage(); String country = testBundle.getLocale().getCountry(); if (testBundle.getLocale().equals(testLocale)) { resourceBundle = testBundle; log.debug("found bundle for locale " +baseName+"_"+ testBundle.getLocale()); break; } else if (testLocale.getLanguage().equals(language)) { if (testLocale.getCountry().equals(country)) { // language and country match which is good, keep looking for variant too resourceBundle = testBundle; log.debug("potential bundle: " + baseName + "_" + testBundle.getLocale()); continue; } else { // only accept this if there is no better previous lookup if (null == resourceBundle) { resourceBundle = testBundle; log.debug("potential bundle: " + baseName+"_"+testBundle.getLocale()); } continue; } } } } // make sure the resource bundle is loaded (should not happen) if (null == resourceBundle) { resourceBundle = ResourceBundle.getBundle(baseName); if (null != resourceBundle) { log.debug("system locale bundle taken: " + baseName + "_" + resourceBundle.getLocale()); } } } return resourceBundle; }
[ "private", "ResourceBundle", "findBundle", "(", "String", "baseName", ")", "{", "ResourceBundle", "resourceBundle", "=", "null", ";", "// first try to load the resource bundle with the specified locale", "ClassLoader", "cl", "=", "Thread", ".", "currentThread", "(", ")", ".", "getContextClassLoader", "(", ")", ";", "if", "(", "null", "!=", "locale", ")", "{", "try", "{", "resourceBundle", "=", "ResourceBundle", ".", "getBundle", "(", "baseName", ",", "locale", ",", "cl", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "log", ".", "fatal", "(", "\"unable to load a default bundle: \"", "+", "baseName", "+", "\"_\"", "+", "locale", ")", ";", "}", "// check that the requested main locale matches the resource bundle's,", "// since we get the system fallback locale if no match is found", "if", "(", "!", "resourceBundle", ".", "getLocale", "(", ")", ".", "equals", "(", "locale", ")", ")", "{", "resourceBundle", "=", "null", ";", "}", "}", "// loop through the fall back locales until a bundle is found", "if", "(", "null", "==", "resourceBundle", ")", "{", "if", "(", "null", "!=", "fallback", ")", "{", "while", "(", "fallback", ".", "hasMoreElements", "(", ")", ")", "{", "Locale", "testLocale", "=", "(", "Locale", ")", "fallback", ".", "nextElement", "(", ")", ";", "log", ".", "debug", "(", "\"looking up locale \"", "+", "testLocale", ")", ";", "ResourceBundle", "testBundle", "=", "ResourceBundle", ".", "getBundle", "(", "baseName", ",", "testLocale", ",", "cl", ")", ";", "String", "language", "=", "testBundle", ".", "getLocale", "(", ")", ".", "getLanguage", "(", ")", ";", "String", "country", "=", "testBundle", ".", "getLocale", "(", ")", ".", "getCountry", "(", ")", ";", "if", "(", "testBundle", ".", "getLocale", "(", ")", ".", "equals", "(", "testLocale", ")", ")", "{", "resourceBundle", "=", "testBundle", ";", "log", ".", "debug", "(", "\"found bundle for locale \"", "+", "baseName", "+", "\"_\"", "+", "testBundle", ".", "getLocale", "(", ")", ")", ";", "break", ";", "}", "else", "if", "(", "testLocale", ".", "getLanguage", "(", ")", ".", "equals", "(", "language", ")", ")", "{", "if", "(", "testLocale", ".", "getCountry", "(", ")", ".", "equals", "(", "country", ")", ")", "{", "// language and country match which is good, keep looking for variant too", "resourceBundle", "=", "testBundle", ";", "log", ".", "debug", "(", "\"potential bundle: \"", "+", "baseName", "+", "\"_\"", "+", "testBundle", ".", "getLocale", "(", ")", ")", ";", "continue", ";", "}", "else", "{", "// only accept this if there is no better previous lookup", "if", "(", "null", "==", "resourceBundle", ")", "{", "resourceBundle", "=", "testBundle", ";", "log", ".", "debug", "(", "\"potential bundle: \"", "+", "baseName", "+", "\"_\"", "+", "testBundle", ".", "getLocale", "(", ")", ")", ";", "}", "continue", ";", "}", "}", "}", "}", "// make sure the resource bundle is loaded (should not happen)", "if", "(", "null", "==", "resourceBundle", ")", "{", "resourceBundle", "=", "ResourceBundle", ".", "getBundle", "(", "baseName", ")", ";", "if", "(", "null", "!=", "resourceBundle", ")", "{", "log", ".", "debug", "(", "\"system locale bundle taken: \"", "+", "baseName", "+", "\"_\"", "+", "resourceBundle", ".", "getLocale", "(", ")", ")", ";", "}", "}", "}", "return", "resourceBundle", ";", "}" ]
Find a resource bundle by looking up using the locales. This is done by loading either the specified locale based resource bundle and, if that fails, by looping through the fallback locales to locate a usable bundle.
[ "Find", "a", "resource", "bundle", "by", "looking", "up", "using", "the", "locales", ".", "This", "is", "done", "by", "loading", "either", "the", "specified", "locale", "based", "resource", "bundle", "and", "if", "that", "fails", "by", "looping", "through", "the", "fallback", "locales", "to", "locate", "a", "usable", "bundle", "." ]
e52aa09eaa61510dc48b27603bd9ea116cd6531a
https://github.com/grails/grails-gdoc-engine/blob/e52aa09eaa61510dc48b27603bd9ea116cd6531a/src/main/java/org/radeox/util/i18n/ResourceManager.java#L137-L197
155,749
morimekta/utils
io-util/src/main/java/net/morimekta/util/CharSlice.java
CharSlice.substring
public final CharSlice substring(int start, int end) { if (start < 0 || end > len || end < -len) { throw new IllegalArgumentException( String.format("[%d,%d] of slice length %d is not valid.", start, end, len)); } int l = end < 0 ? (len - start) + end : end - start; if (l < 0 || l > (len - start)) { throw new IllegalArgumentException( String.format("[%d,%d] of slice length %d is not valid.", start, end, len)); } return new CharSlice(fb, off + start, l); }
java
public final CharSlice substring(int start, int end) { if (start < 0 || end > len || end < -len) { throw new IllegalArgumentException( String.format("[%d,%d] of slice length %d is not valid.", start, end, len)); } int l = end < 0 ? (len - start) + end : end - start; if (l < 0 || l > (len - start)) { throw new IllegalArgumentException( String.format("[%d,%d] of slice length %d is not valid.", start, end, len)); } return new CharSlice(fb, off + start, l); }
[ "public", "final", "CharSlice", "substring", "(", "int", "start", ",", "int", "end", ")", "{", "if", "(", "start", "<", "0", "||", "end", ">", "len", "||", "end", "<", "-", "len", ")", "{", "throw", "new", "IllegalArgumentException", "(", "String", ".", "format", "(", "\"[%d,%d] of slice length %d is not valid.\"", ",", "start", ",", "end", ",", "len", ")", ")", ";", "}", "int", "l", "=", "end", "<", "0", "?", "(", "len", "-", "start", ")", "+", "end", ":", "end", "-", "start", ";", "if", "(", "l", "<", "0", "||", "l", ">", "(", "len", "-", "start", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "String", ".", "format", "(", "\"[%d,%d] of slice length %d is not valid.\"", ",", "start", ",", "end", ",", "len", ")", ")", ";", "}", "return", "new", "CharSlice", "(", "fb", ",", "off", "+", "start", ",", "l", ")", ";", "}" ]
Create a substring slice based on the current slice. @param start The internal start position, relative to the slice's offset. @param end The internal end position, relative to the slice's offset. If end is negative, then it is relative to the slice's end position. @return The substring slice.
[ "Create", "a", "substring", "slice", "based", "on", "the", "current", "slice", "." ]
dc987485902f1a7d58169c89c61db97425a6226d
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/CharSlice.java#L98-L109
155,750
morimekta/utils
io-util/src/main/java/net/morimekta/util/CharSlice.java
CharSlice.charAt
@Override public final char charAt(int i) { if (i < -len || len <= i) { throw new IllegalArgumentException( String.format("position %d of slice length %d is not valid.", i, len)); } if (i < 0) { i = len + i; } return fb[off + i]; }
java
@Override public final char charAt(int i) { if (i < -len || len <= i) { throw new IllegalArgumentException( String.format("position %d of slice length %d is not valid.", i, len)); } if (i < 0) { i = len + i; } return fb[off + i]; }
[ "@", "Override", "public", "final", "char", "charAt", "(", "int", "i", ")", "{", "if", "(", "i", "<", "-", "len", "||", "len", "<=", "i", ")", "{", "throw", "new", "IllegalArgumentException", "(", "String", ".", "format", "(", "\"position %d of slice length %d is not valid.\"", ",", "i", ",", "len", ")", ")", ";", "}", "if", "(", "i", "<", "0", ")", "{", "i", "=", "len", "+", "i", ";", "}", "return", "fb", "[", "off", "+", "i", "]", ";", "}" ]
Get character at slice relative position. @param i The position to get. If negative is relative to the slice's end position. @return The char at given position.
[ "Get", "character", "at", "slice", "relative", "position", "." ]
dc987485902f1a7d58169c89c61db97425a6226d
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/CharSlice.java#L116-L126
155,751
morimekta/utils
io-util/src/main/java/net/morimekta/util/CharSlice.java
CharSlice.parseInteger
public final long parseInteger() { int pos = off, radix = 10; boolean neg = false; if (len > 2 && charAt(0) == '0' && charAt(1) == 'x') { pos += 2; radix = 16; } else if (len > 1 && charAt(0) == '0') { pos += 1; radix = 8; } else if (len > 1 && charAt(0) == '-') { neg = true; pos += 1; } long res = 0; for (; pos < off + len; ++pos) { res *= radix; res += validate(fb[pos], valueOfHex(fb[pos]), radix); } return neg ? -res : res; }
java
public final long parseInteger() { int pos = off, radix = 10; boolean neg = false; if (len > 2 && charAt(0) == '0' && charAt(1) == 'x') { pos += 2; radix = 16; } else if (len > 1 && charAt(0) == '0') { pos += 1; radix = 8; } else if (len > 1 && charAt(0) == '-') { neg = true; pos += 1; } long res = 0; for (; pos < off + len; ++pos) { res *= radix; res += validate(fb[pos], valueOfHex(fb[pos]), radix); } return neg ? -res : res; }
[ "public", "final", "long", "parseInteger", "(", ")", "{", "int", "pos", "=", "off", ",", "radix", "=", "10", ";", "boolean", "neg", "=", "false", ";", "if", "(", "len", ">", "2", "&&", "charAt", "(", "0", ")", "==", "'", "'", "&&", "charAt", "(", "1", ")", "==", "'", "'", ")", "{", "pos", "+=", "2", ";", "radix", "=", "16", ";", "}", "else", "if", "(", "len", ">", "1", "&&", "charAt", "(", "0", ")", "==", "'", "'", ")", "{", "pos", "+=", "1", ";", "radix", "=", "8", ";", "}", "else", "if", "(", "len", ">", "1", "&&", "charAt", "(", "0", ")", "==", "'", "'", ")", "{", "neg", "=", "true", ";", "pos", "+=", "1", ";", "}", "long", "res", "=", "0", ";", "for", "(", ";", "pos", "<", "off", "+", "len", ";", "++", "pos", ")", "{", "res", "*=", "radix", ";", "res", "+=", "validate", "(", "fb", "[", "pos", "]", ",", "valueOfHex", "(", "fb", "[", "pos", "]", ")", ",", "radix", ")", ";", "}", "return", "neg", "?", "-", "res", ":", "res", ";", "}" ]
Get the whole slice as a simple integer. @return Integer long value.
[ "Get", "the", "whole", "slice", "as", "a", "simple", "integer", "." ]
dc987485902f1a7d58169c89c61db97425a6226d
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/CharSlice.java#L133-L152
155,752
morimekta/utils
io-util/src/main/java/net/morimekta/util/CharSlice.java
CharSlice.containsAny
public final boolean containsAny(char... a) { for (int i = 0; i < len; ++i) { for (char b : a) { if (b == fb[off + i]) { return true; } } } return false; }
java
public final boolean containsAny(char... a) { for (int i = 0; i < len; ++i) { for (char b : a) { if (b == fb[off + i]) { return true; } } } return false; }
[ "public", "final", "boolean", "containsAny", "(", "char", "...", "a", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "len", ";", "++", "i", ")", "{", "for", "(", "char", "b", ":", "a", ")", "{", "if", "(", "b", "==", "fb", "[", "off", "+", "i", "]", ")", "{", "return", "true", ";", "}", "}", "}", "return", "false", ";", "}" ]
Checks if any of the provided bytes is contained in the slice. @param a Bytes to find in the slice. @return True if any of the bytes were found.
[ "Checks", "if", "any", "of", "the", "provided", "bytes", "is", "contained", "in", "the", "slice", "." ]
dc987485902f1a7d58169c89c61db97425a6226d
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/CharSlice.java#L199-L208
155,753
morimekta/utils
io-util/src/main/java/net/morimekta/util/CharSlice.java
CharSlice.contains
public final boolean contains(char[] a) { final int last_pos = off + len - a.length; outer: for (int pos = off; pos <= last_pos; ++pos) { for (int a_off = 0; a_off < a.length; ++a_off) { if (a[a_off] != fb[pos + a_off]) { continue outer; } } return true; } return false; }
java
public final boolean contains(char[] a) { final int last_pos = off + len - a.length; outer: for (int pos = off; pos <= last_pos; ++pos) { for (int a_off = 0; a_off < a.length; ++a_off) { if (a[a_off] != fb[pos + a_off]) { continue outer; } } return true; } return false; }
[ "public", "final", "boolean", "contains", "(", "char", "[", "]", "a", ")", "{", "final", "int", "last_pos", "=", "off", "+", "len", "-", "a", ".", "length", ";", "outer", ":", "for", "(", "int", "pos", "=", "off", ";", "pos", "<=", "last_pos", ";", "++", "pos", ")", "{", "for", "(", "int", "a_off", "=", "0", ";", "a_off", "<", "a", ".", "length", ";", "++", "a_off", ")", "{", "if", "(", "a", "[", "a_off", "]", "!=", "fb", "[", "pos", "+", "a_off", "]", ")", "{", "continue", "outer", ";", "}", "}", "return", "true", ";", "}", "return", "false", ";", "}" ]
Checks if the byte array is contained in the slice. @param a The byte array to find. @return True if the byte array was found.
[ "Checks", "if", "the", "byte", "array", "is", "contained", "in", "the", "slice", "." ]
dc987485902f1a7d58169c89c61db97425a6226d
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/CharSlice.java#L216-L228
155,754
morimekta/utils
io-util/src/main/java/net/morimekta/util/CharSlice.java
CharSlice.contains
public final boolean contains(char a) { for (int i = off; i < (off + len); ++i) { if (fb[i] == a) { return true; } } return false; }
java
public final boolean contains(char a) { for (int i = off; i < (off + len); ++i) { if (fb[i] == a) { return true; } } return false; }
[ "public", "final", "boolean", "contains", "(", "char", "a", ")", "{", "for", "(", "int", "i", "=", "off", ";", "i", "<", "(", "off", "+", "len", ")", ";", "++", "i", ")", "{", "if", "(", "fb", "[", "i", "]", "==", "a", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Checks if a single byte can be found in the slice. @param a The byte to find. @return True of the byte was found.
[ "Checks", "if", "a", "single", "byte", "can", "be", "found", "in", "the", "slice", "." ]
dc987485902f1a7d58169c89c61db97425a6226d
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/io-util/src/main/java/net/morimekta/util/CharSlice.java#L236-L243
155,755
james-hu/jabb-core
src/main/java/net/sf/jabb/util/prop/PropertiesLoader.java
PropertiesLoader.replacePlaceHolders
protected Properties replacePlaceHolders(Properties props){ if (replacePlaceHolders){ Properties result = new Properties(); for (Object keyObj: props.keySet()){ String key = (String) keyObj; String value = props.getProperty(key); key = PlaceHolderReplacer.replaceWithProperties(key); value = PlaceHolderReplacer.replaceWithProperties(value); result.put(key, value); } return result; }else{ return props; } }
java
protected Properties replacePlaceHolders(Properties props){ if (replacePlaceHolders){ Properties result = new Properties(); for (Object keyObj: props.keySet()){ String key = (String) keyObj; String value = props.getProperty(key); key = PlaceHolderReplacer.replaceWithProperties(key); value = PlaceHolderReplacer.replaceWithProperties(value); result.put(key, value); } return result; }else{ return props; } }
[ "protected", "Properties", "replacePlaceHolders", "(", "Properties", "props", ")", "{", "if", "(", "replacePlaceHolders", ")", "{", "Properties", "result", "=", "new", "Properties", "(", ")", ";", "for", "(", "Object", "keyObj", ":", "props", ".", "keySet", "(", ")", ")", "{", "String", "key", "=", "(", "String", ")", "keyObj", ";", "String", "value", "=", "props", ".", "getProperty", "(", "key", ")", ";", "key", "=", "PlaceHolderReplacer", ".", "replaceWithProperties", "(", "key", ")", ";", "value", "=", "PlaceHolderReplacer", ".", "replaceWithProperties", "(", "value", ")", ";", "result", ".", "put", "(", "key", ",", "value", ")", ";", "}", "return", "result", ";", "}", "else", "{", "return", "props", ";", "}", "}" ]
Replace place holders in both keys and values with values defined in system properties. @param props the input (before processing) which will not be altered during the processing. @return the output (after processing)
[ "Replace", "place", "holders", "in", "both", "keys", "and", "values", "with", "values", "defined", "in", "system", "properties", "." ]
bceed441595c5e5195a7418795f03b69fa7b61e4
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/util/prop/PropertiesLoader.java#L191-L205
155,756
SimiaCryptus/utilities
java-util/src/main/java/com/simiacryptus/util/data/DoubleStatistics.java
DoubleStatistics.accept
@Override public synchronized void accept(final double value) { super.accept(value); final double squareValue = value * value; simpleSumOfSquare += squareValue; sumOfSquareWithCompensation(squareValue); }
java
@Override public synchronized void accept(final double value) { super.accept(value); final double squareValue = value * value; simpleSumOfSquare += squareValue; sumOfSquareWithCompensation(squareValue); }
[ "@", "Override", "public", "synchronized", "void", "accept", "(", "final", "double", "value", ")", "{", "super", ".", "accept", "(", "value", ")", ";", "final", "double", "squareValue", "=", "value", "*", "value", ";", "simpleSumOfSquare", "+=", "squareValue", ";", "sumOfSquareWithCompensation", "(", "squareValue", ")", ";", "}" ]
Low order bits of sum
[ "Low", "order", "bits", "of", "sum" ]
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/data/DoubleStatistics.java#L57-L63
155,757
SimiaCryptus/utilities
java-util/src/main/java/com/simiacryptus/util/data/DoubleStatistics.java
DoubleStatistics.accept
@javax.annotation.Nonnull public com.simiacryptus.util.data.DoubleStatistics accept(@javax.annotation.Nonnull final double[] value) { Arrays.stream(value).forEach(this::accept); return this; }
java
@javax.annotation.Nonnull public com.simiacryptus.util.data.DoubleStatistics accept(@javax.annotation.Nonnull final double[] value) { Arrays.stream(value).forEach(this::accept); return this; }
[ "@", "javax", ".", "annotation", ".", "Nonnull", "public", "com", ".", "simiacryptus", ".", "util", ".", "data", ".", "DoubleStatistics", "accept", "(", "@", "javax", ".", "annotation", ".", "Nonnull", "final", "double", "[", "]", "value", ")", "{", "Arrays", ".", "stream", "(", "value", ")", ".", "forEach", "(", "this", "::", "accept", ")", ";", "return", "this", ";", "}" ]
Accept double statistics. @param value the value @return the double statistics
[ "Accept", "double", "statistics", "." ]
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/data/DoubleStatistics.java#L71-L75
155,758
SimiaCryptus/utilities
java-util/src/main/java/com/simiacryptus/util/data/DoubleStatistics.java
DoubleStatistics.combine
@javax.annotation.Nonnull public com.simiacryptus.util.data.DoubleStatistics combine(@javax.annotation.Nonnull final com.simiacryptus.util.data.DoubleStatistics other) { super.combine(other); simpleSumOfSquare += other.simpleSumOfSquare; sumOfSquareWithCompensation(other.sumOfSquare); sumOfSquareWithCompensation(other.sumOfSquareCompensation); return this; }
java
@javax.annotation.Nonnull public com.simiacryptus.util.data.DoubleStatistics combine(@javax.annotation.Nonnull final com.simiacryptus.util.data.DoubleStatistics other) { super.combine(other); simpleSumOfSquare += other.simpleSumOfSquare; sumOfSquareWithCompensation(other.sumOfSquare); sumOfSquareWithCompensation(other.sumOfSquareCompensation); return this; }
[ "@", "javax", ".", "annotation", ".", "Nonnull", "public", "com", ".", "simiacryptus", ".", "util", ".", "data", ".", "DoubleStatistics", "combine", "(", "@", "javax", ".", "annotation", ".", "Nonnull", "final", "com", ".", "simiacryptus", ".", "util", ".", "data", ".", "DoubleStatistics", "other", ")", "{", "super", ".", "combine", "(", "other", ")", ";", "simpleSumOfSquare", "+=", "other", ".", "simpleSumOfSquare", ";", "sumOfSquareWithCompensation", "(", "other", ".", "sumOfSquare", ")", ";", "sumOfSquareWithCompensation", "(", "other", ".", "sumOfSquareCompensation", ")", ";", "return", "this", ";", "}" ]
Combine double statistics. @param other the other @return the double statistics
[ "Combine", "double", "statistics", "." ]
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/data/DoubleStatistics.java#L83-L90
155,759
SimiaCryptus/utilities
java-util/src/main/java/com/simiacryptus/util/data/DoubleStatistics.java
DoubleStatistics.getSumOfSquare
public double getSumOfSquare() { final double tmp = sumOfSquare + sumOfSquareCompensation; if (Double.isNaN(tmp) && Double.isInfinite(simpleSumOfSquare)) { return simpleSumOfSquare; } return tmp; }
java
public double getSumOfSquare() { final double tmp = sumOfSquare + sumOfSquareCompensation; if (Double.isNaN(tmp) && Double.isInfinite(simpleSumOfSquare)) { return simpleSumOfSquare; } return tmp; }
[ "public", "double", "getSumOfSquare", "(", ")", "{", "final", "double", "tmp", "=", "sumOfSquare", "+", "sumOfSquareCompensation", ";", "if", "(", "Double", ".", "isNaN", "(", "tmp", ")", "&&", "Double", ".", "isInfinite", "(", "simpleSumOfSquare", ")", ")", "{", "return", "simpleSumOfSquare", ";", "}", "return", "tmp", ";", "}" ]
Gets sum of square. @return the sum of square
[ "Gets", "sum", "of", "square", "." ]
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/util/data/DoubleStatistics.java#L106-L112
155,760
bushidowallet/bushido-java-service
bushido-wallet-service/src/main/java/com/authy/api/Users.java
Users.createUser
public com.authy.api.User createUser(String email, String phone) { return createUser(email, phone, DEFAULT_COUNTRY_CODE); }
java
public com.authy.api.User createUser(String email, String phone) { return createUser(email, phone, DEFAULT_COUNTRY_CODE); }
[ "public", "com", ".", "authy", ".", "api", ".", "User", "createUser", "(", "String", "email", ",", "String", "phone", ")", "{", "return", "createUser", "(", "email", ",", "phone", ",", "DEFAULT_COUNTRY_CODE", ")", ";", "}" ]
Create a new user using his e-mail and phone. It uses USA country code by default. @param email @param phone @return a User instance
[ "Create", "a", "new", "user", "using", "his", "e", "-", "mail", "and", "phone", ".", "It", "uses", "USA", "country", "code", "by", "default", "." ]
e1a0157527e57459b509718044d2df44084876a2
https://github.com/bushidowallet/bushido-java-service/blob/e1a0157527e57459b509718044d2df44084876a2/bushido-wallet-service/src/main/java/com/authy/api/Users.java#L57-L59
155,761
pip-services3-java/pip-services3-commons-java
src/org/pipservices3/commons/reflect/MethodReflector.java
MethodReflector.hasMethod
public static boolean hasMethod(Object obj, String name) { if (obj == null) throw new NullPointerException("Object cannot be null"); if (name == null) throw new NullPointerException("Method name cannot be null"); Class<?> objClass = obj.getClass(); for (Method method : objClass.getMethods()) { if (matchMethod(method, name)) return true; } return false; }
java
public static boolean hasMethod(Object obj, String name) { if (obj == null) throw new NullPointerException("Object cannot be null"); if (name == null) throw new NullPointerException("Method name cannot be null"); Class<?> objClass = obj.getClass(); for (Method method : objClass.getMethods()) { if (matchMethod(method, name)) return true; } return false; }
[ "public", "static", "boolean", "hasMethod", "(", "Object", "obj", ",", "String", "name", ")", "{", "if", "(", "obj", "==", "null", ")", "throw", "new", "NullPointerException", "(", "\"Object cannot be null\"", ")", ";", "if", "(", "name", "==", "null", ")", "throw", "new", "NullPointerException", "(", "\"Method name cannot be null\"", ")", ";", "Class", "<", "?", ">", "objClass", "=", "obj", ".", "getClass", "(", ")", ";", "for", "(", "Method", "method", ":", "objClass", ".", "getMethods", "(", ")", ")", "{", "if", "(", "matchMethod", "(", "method", ",", "name", ")", ")", "return", "true", ";", "}", "return", "false", ";", "}" ]
Checks if object has a method with specified name.. @param obj an object to introspect. @param name a name of the method to check. @return true if the object has the method and false if it doesn't.
[ "Checks", "if", "object", "has", "a", "method", "with", "specified", "name", ".." ]
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/reflect/MethodReflector.java#L41-L55
155,762
pip-services3-java/pip-services3-commons-java
src/org/pipservices3/commons/reflect/MethodReflector.java
MethodReflector.invokeMethod
public static Object invokeMethod(Object obj, String name, Object... args) { if (obj == null) throw new NullPointerException("Object cannot be null"); if (name == null) throw new NullPointerException("Method name cannot be null"); Class<?> objClass = obj.getClass(); for (Method method : objClass.getMethods()) { try { if (matchMethod(method, name)) return method.invoke(obj, args); } catch (Throwable t) { // Ignore exceptions } } return null; }
java
public static Object invokeMethod(Object obj, String name, Object... args) { if (obj == null) throw new NullPointerException("Object cannot be null"); if (name == null) throw new NullPointerException("Method name cannot be null"); Class<?> objClass = obj.getClass(); for (Method method : objClass.getMethods()) { try { if (matchMethod(method, name)) return method.invoke(obj, args); } catch (Throwable t) { // Ignore exceptions } } return null; }
[ "public", "static", "Object", "invokeMethod", "(", "Object", "obj", ",", "String", "name", ",", "Object", "...", "args", ")", "{", "if", "(", "obj", "==", "null", ")", "throw", "new", "NullPointerException", "(", "\"Object cannot be null\"", ")", ";", "if", "(", "name", "==", "null", ")", "throw", "new", "NullPointerException", "(", "\"Method name cannot be null\"", ")", ";", "Class", "<", "?", ">", "objClass", "=", "obj", ".", "getClass", "(", ")", ";", "for", "(", "Method", "method", ":", "objClass", ".", "getMethods", "(", ")", ")", "{", "try", "{", "if", "(", "matchMethod", "(", "method", ",", "name", ")", ")", "return", "method", ".", "invoke", "(", "obj", ",", "args", ")", ";", "}", "catch", "(", "Throwable", "t", ")", "{", "// Ignore exceptions", "}", "}", "return", "null", ";", "}" ]
Invokes an object method by its name with specified parameters. @param obj an object to invoke. @param name a name of the method to invoke. @param args a list of method arguments. @return the result of the method invocation or null if method returns void.
[ "Invokes", "an", "object", "method", "by", "its", "name", "with", "specified", "parameters", "." ]
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/reflect/MethodReflector.java#L65-L83
155,763
pip-services3-java/pip-services3-commons-java
src/org/pipservices3/commons/reflect/MethodReflector.java
MethodReflector.getMethodNames
public static List<String> getMethodNames(Object obj) { List<String> methods = new ArrayList<String>(); Class<?> objClass = obj.getClass(); for (Method method : objClass.getMethods()) { if (matchMethod(method, method.getName())) { methods.add(method.getName()); } } return methods; }
java
public static List<String> getMethodNames(Object obj) { List<String> methods = new ArrayList<String>(); Class<?> objClass = obj.getClass(); for (Method method : objClass.getMethods()) { if (matchMethod(method, method.getName())) { methods.add(method.getName()); } } return methods; }
[ "public", "static", "List", "<", "String", ">", "getMethodNames", "(", "Object", "obj", ")", "{", "List", "<", "String", ">", "methods", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "Class", "<", "?", ">", "objClass", "=", "obj", ".", "getClass", "(", ")", ";", "for", "(", "Method", "method", ":", "objClass", ".", "getMethods", "(", ")", ")", "{", "if", "(", "matchMethod", "(", "method", ",", "method", ".", "getName", "(", ")", ")", ")", "{", "methods", ".", "add", "(", "method", ".", "getName", "(", ")", ")", ";", "}", "}", "return", "methods", ";", "}" ]
Gets names of all methods implemented in specified object. @param obj an objec to introspect. @return a list with method names.
[ "Gets", "names", "of", "all", "methods", "implemented", "in", "specified", "object", "." ]
a8a0c3e5ec58f0663c295aa855c6b3afad2af86a
https://github.com/pip-services3-java/pip-services3-commons-java/blob/a8a0c3e5ec58f0663c295aa855c6b3afad2af86a/src/org/pipservices3/commons/reflect/MethodReflector.java#L91-L103
155,764
xmlet/XsdAsmFaster
src/main/java/org/xmlet/xsdasmfaster/classes/XsdSupportingStructure.java
XsdSupportingStructure.createSupportingInfrastructure
static void createSupportingInfrastructure(String apiName){ elementType = getFullClassTypeName(ELEMENT, apiName); elementTypeDesc = getFullClassTypeNameDesc(ELEMENT, apiName); elementVisitorType = getFullClassTypeName(ELEMENT_VISITOR, apiName); elementVisitorTypeDesc = getFullClassTypeNameDesc(ELEMENT_VISITOR, apiName); textGroupType = getFullClassTypeName(TEXT_GROUP, apiName); customAttributeGroupType = getFullClassTypeName(CUSTOM_ATTRIBUTE_GROUP, apiName); textType = getFullClassTypeName(TEXT, apiName); textTypeDesc = getFullClassTypeNameDesc(TEXT, apiName); createElement(apiName); createTextGroup(apiName); createCustomAttributeGroup(apiName); createText(apiName); infrastructureVars.put(ELEMENT, elementType); infrastructureVars.put(ELEMENT_VISITOR, elementVisitorType); infrastructureVars.put(TEXT_GROUP, textGroupType); }
java
static void createSupportingInfrastructure(String apiName){ elementType = getFullClassTypeName(ELEMENT, apiName); elementTypeDesc = getFullClassTypeNameDesc(ELEMENT, apiName); elementVisitorType = getFullClassTypeName(ELEMENT_VISITOR, apiName); elementVisitorTypeDesc = getFullClassTypeNameDesc(ELEMENT_VISITOR, apiName); textGroupType = getFullClassTypeName(TEXT_GROUP, apiName); customAttributeGroupType = getFullClassTypeName(CUSTOM_ATTRIBUTE_GROUP, apiName); textType = getFullClassTypeName(TEXT, apiName); textTypeDesc = getFullClassTypeNameDesc(TEXT, apiName); createElement(apiName); createTextGroup(apiName); createCustomAttributeGroup(apiName); createText(apiName); infrastructureVars.put(ELEMENT, elementType); infrastructureVars.put(ELEMENT_VISITOR, elementVisitorType); infrastructureVars.put(TEXT_GROUP, textGroupType); }
[ "static", "void", "createSupportingInfrastructure", "(", "String", "apiName", ")", "{", "elementType", "=", "getFullClassTypeName", "(", "ELEMENT", ",", "apiName", ")", ";", "elementTypeDesc", "=", "getFullClassTypeNameDesc", "(", "ELEMENT", ",", "apiName", ")", ";", "elementVisitorType", "=", "getFullClassTypeName", "(", "ELEMENT_VISITOR", ",", "apiName", ")", ";", "elementVisitorTypeDesc", "=", "getFullClassTypeNameDesc", "(", "ELEMENT_VISITOR", ",", "apiName", ")", ";", "textGroupType", "=", "getFullClassTypeName", "(", "TEXT_GROUP", ",", "apiName", ")", ";", "customAttributeGroupType", "=", "getFullClassTypeName", "(", "CUSTOM_ATTRIBUTE_GROUP", ",", "apiName", ")", ";", "textType", "=", "getFullClassTypeName", "(", "TEXT", ",", "apiName", ")", ";", "textTypeDesc", "=", "getFullClassTypeNameDesc", "(", "TEXT", ",", "apiName", ")", ";", "createElement", "(", "apiName", ")", ";", "createTextGroup", "(", "apiName", ")", ";", "createCustomAttributeGroup", "(", "apiName", ")", ";", "createText", "(", "apiName", ")", ";", "infrastructureVars", ".", "put", "(", "ELEMENT", ",", "elementType", ")", ";", "infrastructureVars", ".", "put", "(", "ELEMENT_VISITOR", ",", "elementVisitorType", ")", ";", "infrastructureVars", ".", "put", "(", "TEXT_GROUP", ",", "textGroupType", ")", ";", "}" ]
Creates all the classes that belong to the fluent interface infrastructure and can't be defined the same way as the classes present in the infrastructure package of this solution. @param apiName The name of the generated fluent interface.
[ "Creates", "all", "the", "classes", "that", "belong", "to", "the", "fluent", "interface", "infrastructure", "and", "can", "t", "be", "defined", "the", "same", "way", "as", "the", "classes", "present", "in", "the", "infrastructure", "package", "of", "this", "solution", "." ]
ccb78f9dd4b957ad5ac1ca349eaf24338c421e94
https://github.com/xmlet/XsdAsmFaster/blob/ccb78f9dd4b957ad5ac1ca349eaf24338c421e94/src/main/java/org/xmlet/xsdasmfaster/classes/XsdSupportingStructure.java#L109-L127
155,765
JM-Lab/utils-java8
src/main/java/kr/jm/utils/collections/IndexAliasMap.java
IndexAliasMap.addAllWithAlias
public void addAllWithAlias(List<String> aliasList, List<V> dataList) { synchronized (dataList) { JMLambda.runByBoolean(aliasList.size() == dataList.size(), () -> JMStream.numberRangeWithCount(0, 1, dataList.size()) .forEach(i -> addWithAlias(aliasList.get(i), dataList.get(i))), () -> JMExceptionManager.logRuntimeException(log, "Wrong Key List Size !!! - " + "dataList Size = " + size() + " aliasList Size = " + aliasList.size(), "setKeyIndexMap", aliasList)); } }
java
public void addAllWithAlias(List<String> aliasList, List<V> dataList) { synchronized (dataList) { JMLambda.runByBoolean(aliasList.size() == dataList.size(), () -> JMStream.numberRangeWithCount(0, 1, dataList.size()) .forEach(i -> addWithAlias(aliasList.get(i), dataList.get(i))), () -> JMExceptionManager.logRuntimeException(log, "Wrong Key List Size !!! - " + "dataList Size = " + size() + " aliasList Size = " + aliasList.size(), "setKeyIndexMap", aliasList)); } }
[ "public", "void", "addAllWithAlias", "(", "List", "<", "String", ">", "aliasList", ",", "List", "<", "V", ">", "dataList", ")", "{", "synchronized", "(", "dataList", ")", "{", "JMLambda", ".", "runByBoolean", "(", "aliasList", ".", "size", "(", ")", "==", "dataList", ".", "size", "(", ")", ",", "(", ")", "->", "JMStream", ".", "numberRangeWithCount", "(", "0", ",", "1", ",", "dataList", ".", "size", "(", ")", ")", ".", "forEach", "(", "i", "->", "addWithAlias", "(", "aliasList", ".", "get", "(", "i", ")", ",", "dataList", ".", "get", "(", "i", ")", ")", ")", ",", "(", ")", "->", "JMExceptionManager", ".", "logRuntimeException", "(", "log", ",", "\"Wrong Key List Size !!! - \"", "+", "\"dataList Size = \"", "+", "size", "(", ")", "+", "\" aliasList Size = \"", "+", "aliasList", ".", "size", "(", ")", ",", "\"setKeyIndexMap\"", ",", "aliasList", ")", ")", ";", "}", "}" ]
Add all with alias. @param aliasList the alias list @param dataList the data list
[ "Add", "all", "with", "alias", "." ]
9e407b3f28a7990418a1e877229fa8344f4d78a5
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/collections/IndexAliasMap.java#L51-L64
155,766
JM-Lab/utils-java8
src/main/java/kr/jm/utils/collections/IndexAliasMap.java
IndexAliasMap.addWithAlias
public Integer addWithAlias(String alias, V value) { synchronized (dataList) { dataList.add(value); return aliasIndexMap.put(alias, dataList.size() - 1); } }
java
public Integer addWithAlias(String alias, V value) { synchronized (dataList) { dataList.add(value); return aliasIndexMap.put(alias, dataList.size() - 1); } }
[ "public", "Integer", "addWithAlias", "(", "String", "alias", ",", "V", "value", ")", "{", "synchronized", "(", "dataList", ")", "{", "dataList", ".", "add", "(", "value", ")", ";", "return", "aliasIndexMap", ".", "put", "(", "alias", ",", "dataList", ".", "size", "(", ")", "-", "1", ")", ";", "}", "}" ]
Add with alias integer. @param alias the alias @param value the value @return the integer
[ "Add", "with", "alias", "integer", "." ]
9e407b3f28a7990418a1e877229fa8344f4d78a5
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/collections/IndexAliasMap.java#L73-L78
155,767
JM-Lab/utils-java8
src/main/java/kr/jm/utils/collections/IndexAliasMap.java
IndexAliasMap.putAlias
synchronized public void putAlias(String alias, int index) { JMLambda.runByBoolean(index < size(), () -> aliasIndexMap.put(alias, index), () -> JMExceptionManager.logRuntimeException(log, "Wrong Index !!! - " + "dataList Size = " + dataList, "setKeyIndexMap", index)); }
java
synchronized public void putAlias(String alias, int index) { JMLambda.runByBoolean(index < size(), () -> aliasIndexMap.put(alias, index), () -> JMExceptionManager.logRuntimeException(log, "Wrong Index !!! - " + "dataList Size = " + dataList, "setKeyIndexMap", index)); }
[ "synchronized", "public", "void", "putAlias", "(", "String", "alias", ",", "int", "index", ")", "{", "JMLambda", ".", "runByBoolean", "(", "index", "<", "size", "(", ")", ",", "(", ")", "->", "aliasIndexMap", ".", "put", "(", "alias", ",", "index", ")", ",", "(", ")", "->", "JMExceptionManager", ".", "logRuntimeException", "(", "log", ",", "\"Wrong Index !!! - \"", "+", "\"dataList Size = \"", "+", "dataList", ",", "\"setKeyIndexMap\"", ",", "index", ")", ")", ";", "}" ]
Put alias. @param alias the alias @param index the index
[ "Put", "alias", "." ]
9e407b3f28a7990418a1e877229fa8344f4d78a5
https://github.com/JM-Lab/utils-java8/blob/9e407b3f28a7990418a1e877229fa8344f4d78a5/src/main/java/kr/jm/utils/collections/IndexAliasMap.java#L86-L92
155,768
foundation-runtime/service-directory
1.2/sd-api/src/main/java/com/cisco/oss/foundation/directory/lookup/DirectoryLookupService.java
DirectoryLookupService.getModelService
public ModelService getModelService(String serviceName) { ModelService service = null; try{ service = getDirectoryServiceClient().lookupService(serviceName); }catch(ServiceException se){ if (se.getErrorCode()==ErrorCode.SERVICE_DOES_NOT_EXIST){ LOGGER.error(se.getMessage()); }else { LOGGER.error("Error when getModelService", se); } throw se; } return service; }
java
public ModelService getModelService(String serviceName) { ModelService service = null; try{ service = getDirectoryServiceClient().lookupService(serviceName); }catch(ServiceException se){ if (se.getErrorCode()==ErrorCode.SERVICE_DOES_NOT_EXIST){ LOGGER.error(se.getMessage()); }else { LOGGER.error("Error when getModelService", se); } throw se; } return service; }
[ "public", "ModelService", "getModelService", "(", "String", "serviceName", ")", "{", "ModelService", "service", "=", "null", ";", "try", "{", "service", "=", "getDirectoryServiceClient", "(", ")", ".", "lookupService", "(", "serviceName", ")", ";", "}", "catch", "(", "ServiceException", "se", ")", "{", "if", "(", "se", ".", "getErrorCode", "(", ")", "==", "ErrorCode", ".", "SERVICE_DOES_NOT_EXIST", ")", "{", "LOGGER", ".", "error", "(", "se", ".", "getMessage", "(", ")", ")", ";", "}", "else", "{", "LOGGER", ".", "error", "(", "\"Error when getModelService\"", ",", "se", ")", ";", "}", "throw", "se", ";", "}", "return", "service", ";", "}" ]
Get the ModelService by service name. @param serviceName the Service name. @return the ModelService.
[ "Get", "the", "ModelService", "by", "service", "name", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.2/sd-api/src/main/java/com/cisco/oss/foundation/directory/lookup/DirectoryLookupService.java#L249-L262
155,769
foundation-runtime/service-directory
1.2/sd-api/src/main/java/com/cisco/oss/foundation/directory/lookup/DirectoryLookupService.java
DirectoryLookupService.getModelServiceInstanceByAddress
public ModelServiceInstance getModelServiceInstanceByAddress(String serviceName, String instanceAddress) { ModelService service = getModelService(serviceName); if (service != null && service.getServiceInstances() != null) { for (ModelServiceInstance instance : service.getServiceInstances()) { if (instance.getAddress().equals(instanceAddress)) { return instance; } } } return null; }
java
public ModelServiceInstance getModelServiceInstanceByAddress(String serviceName, String instanceAddress) { ModelService service = getModelService(serviceName); if (service != null && service.getServiceInstances() != null) { for (ModelServiceInstance instance : service.getServiceInstances()) { if (instance.getAddress().equals(instanceAddress)) { return instance; } } } return null; }
[ "public", "ModelServiceInstance", "getModelServiceInstanceByAddress", "(", "String", "serviceName", ",", "String", "instanceAddress", ")", "{", "ModelService", "service", "=", "getModelService", "(", "serviceName", ")", ";", "if", "(", "service", "!=", "null", "&&", "service", ".", "getServiceInstances", "(", ")", "!=", "null", ")", "{", "for", "(", "ModelServiceInstance", "instance", ":", "service", ".", "getServiceInstances", "(", ")", ")", "{", "if", "(", "instance", ".", "getAddress", "(", ")", ".", "equals", "(", "instanceAddress", ")", ")", "{", "return", "instance", ";", "}", "}", "}", "return", "null", ";", "}" ]
Get the ModelServiceInstance by serviceName and instanceAddress. @param serviceName the service name. @param instanceAddress the instanceAddress. @return the ModelServiceInstance. @since 1.2
[ "Get", "the", "ModelServiceInstance", "by", "serviceName", "and", "instanceAddress", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.2/sd-api/src/main/java/com/cisco/oss/foundation/directory/lookup/DirectoryLookupService.java#L313-L323
155,770
foundation-runtime/service-directory
1.2/sd-api/src/main/java/com/cisco/oss/foundation/directory/lookup/DirectoryLookupService.java
DirectoryLookupService.getUPModelInstancesByMetadataKey
public List<ModelServiceInstance> getUPModelInstancesByMetadataKey(String keyName) { List<ModelServiceInstance> list = new ArrayList<>(); for (ModelServiceInstance instance : getModelInstancesByMetadataKey(keyName)) { if (instance.getStatus().equals(OperationalStatus.UP)) { list.add(instance); } } return list; }
java
public List<ModelServiceInstance> getUPModelInstancesByMetadataKey(String keyName) { List<ModelServiceInstance> list = new ArrayList<>(); for (ModelServiceInstance instance : getModelInstancesByMetadataKey(keyName)) { if (instance.getStatus().equals(OperationalStatus.UP)) { list.add(instance); } } return list; }
[ "public", "List", "<", "ModelServiceInstance", ">", "getUPModelInstancesByMetadataKey", "(", "String", "keyName", ")", "{", "List", "<", "ModelServiceInstance", ">", "list", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "ModelServiceInstance", "instance", ":", "getModelInstancesByMetadataKey", "(", "keyName", ")", ")", "{", "if", "(", "instance", ".", "getStatus", "(", ")", ".", "equals", "(", "OperationalStatus", ".", "UP", ")", ")", "{", "list", ".", "add", "(", "instance", ")", ";", "}", "}", "return", "list", ";", "}" ]
Get the UP ModelServiceInstance list that contains the metadata key. @param keyName the metadata key name. @return the ModelServiceInstances that have the metadata key.
[ "Get", "the", "UP", "ModelServiceInstance", "list", "that", "contains", "the", "metadata", "key", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.2/sd-api/src/main/java/com/cisco/oss/foundation/directory/lookup/DirectoryLookupService.java#L346-L354
155,771
foundation-runtime/service-directory
1.2/sd-api/src/main/java/com/cisco/oss/foundation/directory/lookup/DirectoryLookupService.java
DirectoryLookupService.getAllInstances
public List<ModelServiceInstance> getAllInstances() { List<ModelServiceInstance> result = Collections.emptyList(); try { result = getDirectoryServiceClient().getAllInstances(); }catch (ServiceException se){ LOGGER.error("Error when getAllInstances()",se); } return result; }
java
public List<ModelServiceInstance> getAllInstances() { List<ModelServiceInstance> result = Collections.emptyList(); try { result = getDirectoryServiceClient().getAllInstances(); }catch (ServiceException se){ LOGGER.error("Error when getAllInstances()",se); } return result; }
[ "public", "List", "<", "ModelServiceInstance", ">", "getAllInstances", "(", ")", "{", "List", "<", "ModelServiceInstance", ">", "result", "=", "Collections", ".", "emptyList", "(", ")", ";", "try", "{", "result", "=", "getDirectoryServiceClient", "(", ")", ".", "getAllInstances", "(", ")", ";", "}", "catch", "(", "ServiceException", "se", ")", "{", "LOGGER", ".", "error", "(", "\"Error when getAllInstances()\"", ",", "se", ")", ";", "}", "return", "result", ";", "}" ]
Get All ModelServiceInstance on the Directory Server. @return the ModelServiceInstance List.
[ "Get", "All", "ModelServiceInstance", "on", "the", "Directory", "Server", "." ]
a7bdefe173dc99e75eff4a24e07e6407e62f2ed4
https://github.com/foundation-runtime/service-directory/blob/a7bdefe173dc99e75eff4a24e07e6407e62f2ed4/1.2/sd-api/src/main/java/com/cisco/oss/foundation/directory/lookup/DirectoryLookupService.java#L376-L384
155,772
james-hu/jabb-core
src/main/java/net/sf/jabb/util/state/StateMachine.java
StateMachine.setState
public void setState(S state){ Integer id = definition.getStateId(state); currentStateId.set(id); }
java
public void setState(S state){ Integer id = definition.getStateId(state); currentStateId.set(id); }
[ "public", "void", "setState", "(", "S", "state", ")", "{", "Integer", "id", "=", "definition", ".", "getStateId", "(", "state", ")", ";", "currentStateId", ".", "set", "(", "id", ")", ";", "}" ]
Set current state of the state machine. This method is multi-thread safe. @param state the current state to be, must have already been defined.
[ "Set", "current", "state", "of", "the", "state", "machine", ".", "This", "method", "is", "multi", "-", "thread", "safe", "." ]
bceed441595c5e5195a7418795f03b69fa7b61e4
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/util/state/StateMachine.java#L131-L134
155,773
james-hu/jabb-core
src/main/java/net/sf/jabb/util/state/StateMachine.java
StateMachine.transit
public boolean transit(T transition){ S currentState = definition.getState(currentStateId.get()); if (currentState != null){ try{ Transition<S> transitionDef = definition.getTransition(currentState, transition); return currentStateId.compareAndSet(transitionDef.fromStateId, transitionDef.toStateId); }catch(IllegalArgumentException iae){ return false; }catch(NullPointerException npe){ return false; } } return false; }
java
public boolean transit(T transition){ S currentState = definition.getState(currentStateId.get()); if (currentState != null){ try{ Transition<S> transitionDef = definition.getTransition(currentState, transition); return currentStateId.compareAndSet(transitionDef.fromStateId, transitionDef.toStateId); }catch(IllegalArgumentException iae){ return false; }catch(NullPointerException npe){ return false; } } return false; }
[ "public", "boolean", "transit", "(", "T", "transition", ")", "{", "S", "currentState", "=", "definition", ".", "getState", "(", "currentStateId", ".", "get", "(", ")", ")", ";", "if", "(", "currentState", "!=", "null", ")", "{", "try", "{", "Transition", "<", "S", ">", "transitionDef", "=", "definition", ".", "getTransition", "(", "currentState", ",", "transition", ")", ";", "return", "currentStateId", ".", "compareAndSet", "(", "transitionDef", ".", "fromStateId", ",", "transitionDef", ".", "toStateId", ")", ";", "}", "catch", "(", "IllegalArgumentException", "iae", ")", "{", "return", "false", ";", "}", "catch", "(", "NullPointerException", "npe", ")", "{", "return", "false", ";", "}", "}", "return", "false", ";", "}" ]
Transit from current state to another. The method is multi-thread safe. @param transition the transition, must have already been defined. @return true if successful. False return indicates that the specified transition does not apply to current state.
[ "Transit", "from", "current", "state", "to", "another", ".", "The", "method", "is", "multi", "-", "thread", "safe", "." ]
bceed441595c5e5195a7418795f03b69fa7b61e4
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/util/state/StateMachine.java#L141-L154
155,774
hudson3-plugins/warnings-plugin
src/main/java/hudson/plugins/warnings/ConsoleParser.java
ConsoleParser.filterExisting
public static ConsoleParser[] filterExisting(final Collection<? extends ConsoleParser> parsers) { List<ConsoleParser> existing = Lists.newArrayList(); for (ConsoleParser parser : parsers) { if (ParserRegistry.exists(parser.getParserName())) { existing.add(parser); } } return existing.toArray(new ConsoleParser[existing.size()]); }
java
public static ConsoleParser[] filterExisting(final Collection<? extends ConsoleParser> parsers) { List<ConsoleParser> existing = Lists.newArrayList(); for (ConsoleParser parser : parsers) { if (ParserRegistry.exists(parser.getParserName())) { existing.add(parser); } } return existing.toArray(new ConsoleParser[existing.size()]); }
[ "public", "static", "ConsoleParser", "[", "]", "filterExisting", "(", "final", "Collection", "<", "?", "extends", "ConsoleParser", ">", "parsers", ")", "{", "List", "<", "ConsoleParser", ">", "existing", "=", "Lists", ".", "newArrayList", "(", ")", ";", "for", "(", "ConsoleParser", "parser", ":", "parsers", ")", "{", "if", "(", "ParserRegistry", ".", "exists", "(", "parser", ".", "getParserName", "(", ")", ")", ")", "{", "existing", ".", "add", "(", "parser", ")", ";", "}", "}", "return", "existing", ".", "toArray", "(", "new", "ConsoleParser", "[", "existing", ".", "size", "(", ")", "]", ")", ";", "}" ]
Removes non-existing parsers from the specified list. @param parsers the parsers @return a new list containing the filtered parsers
[ "Removes", "non", "-", "existing", "parsers", "from", "the", "specified", "list", "." ]
462c9f3dffede9120173935567392b22520b0966
https://github.com/hudson3-plugins/warnings-plugin/blob/462c9f3dffede9120173935567392b22520b0966/src/main/java/hudson/plugins/warnings/ConsoleParser.java#L54-L62
155,775
xmlet/XsdAsmFaster
src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmUtils.java
XsdAsmUtils.createGeneratedFilesDirectory
static void createGeneratedFilesDirectory(String apiName) { File folder = new File(getDestinationDirectory(apiName)); if (!folder.exists()){ //noinspection ResultOfMethodCallIgnored folder.mkdirs(); } }
java
static void createGeneratedFilesDirectory(String apiName) { File folder = new File(getDestinationDirectory(apiName)); if (!folder.exists()){ //noinspection ResultOfMethodCallIgnored folder.mkdirs(); } }
[ "static", "void", "createGeneratedFilesDirectory", "(", "String", "apiName", ")", "{", "File", "folder", "=", "new", "File", "(", "getDestinationDirectory", "(", "apiName", ")", ")", ";", "if", "(", "!", "folder", ".", "exists", "(", ")", ")", "{", "//noinspection ResultOfMethodCallIgnored", "folder", ".", "mkdirs", "(", ")", ";", "}", "}" ]
Creates the destination directory of the generated files, if not exists.
[ "Creates", "the", "destination", "directory", "of", "the", "generated", "files", "if", "not", "exists", "." ]
ccb78f9dd4b957ad5ac1ca349eaf24338c421e94
https://github.com/xmlet/XsdAsmFaster/blob/ccb78f9dd4b957ad5ac1ca349eaf24338c421e94/src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmUtils.java#L209-L216
155,776
xmlet/XsdAsmFaster
src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmUtils.java
XsdAsmUtils.writeClassToFile
static void writeClassToFile(String className, ClassWriter classWriter, String apiName){ classWriter.visitEnd(); byte[] constructedClass = classWriter.toByteArray(); try (FileOutputStream os = new FileOutputStream(new File(getFinalPathPart(className, apiName)))){ os.write(constructedClass); } catch (IOException e) { throw new AsmException("Exception while writing generated classes to the .class files.", e); } }
java
static void writeClassToFile(String className, ClassWriter classWriter, String apiName){ classWriter.visitEnd(); byte[] constructedClass = classWriter.toByteArray(); try (FileOutputStream os = new FileOutputStream(new File(getFinalPathPart(className, apiName)))){ os.write(constructedClass); } catch (IOException e) { throw new AsmException("Exception while writing generated classes to the .class files.", e); } }
[ "static", "void", "writeClassToFile", "(", "String", "className", ",", "ClassWriter", "classWriter", ",", "String", "apiName", ")", "{", "classWriter", ".", "visitEnd", "(", ")", ";", "byte", "[", "]", "constructedClass", "=", "classWriter", ".", "toByteArray", "(", ")", ";", "try", "(", "FileOutputStream", "os", "=", "new", "FileOutputStream", "(", "new", "File", "(", "getFinalPathPart", "(", "className", ",", "apiName", ")", ")", ")", ")", "{", "os", ".", "write", "(", "constructedClass", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "AsmException", "(", "\"Exception while writing generated classes to the .class files.\"", ",", "e", ")", ";", "}", "}" ]
Writes a given class to a .class file. @param className The class name, needed to name the file. @param classWriter The classWriter, which contains all the class information.
[ "Writes", "a", "given", "class", "to", "a", ".", "class", "file", "." ]
ccb78f9dd4b957ad5ac1ca349eaf24338c421e94
https://github.com/xmlet/XsdAsmFaster/blob/ccb78f9dd4b957ad5ac1ca349eaf24338c421e94/src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmUtils.java#L223-L233
155,777
xmlet/XsdAsmFaster
src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmUtils.java
XsdAsmUtils.getFullJavaType
static String getFullJavaType(XsdAttribute attribute){ List<XsdRestriction> restrictions = getAttributeRestrictions(attribute); String javaType = xsdFullTypesToJava.getOrDefault(attribute.getType(), null); if (javaType == null){ if (!restrictions.isEmpty()){ return xsdFullTypesToJava.getOrDefault(restrictions.get(0).getBase(), JAVA_OBJECT_DESC); } return JAVA_OBJECT_DESC; } return javaType; }
java
static String getFullJavaType(XsdAttribute attribute){ List<XsdRestriction> restrictions = getAttributeRestrictions(attribute); String javaType = xsdFullTypesToJava.getOrDefault(attribute.getType(), null); if (javaType == null){ if (!restrictions.isEmpty()){ return xsdFullTypesToJava.getOrDefault(restrictions.get(0).getBase(), JAVA_OBJECT_DESC); } return JAVA_OBJECT_DESC; } return javaType; }
[ "static", "String", "getFullJavaType", "(", "XsdAttribute", "attribute", ")", "{", "List", "<", "XsdRestriction", ">", "restrictions", "=", "getAttributeRestrictions", "(", "attribute", ")", ";", "String", "javaType", "=", "xsdFullTypesToJava", ".", "getOrDefault", "(", "attribute", ".", "getType", "(", ")", ",", "null", ")", ";", "if", "(", "javaType", "==", "null", ")", "{", "if", "(", "!", "restrictions", ".", "isEmpty", "(", ")", ")", "{", "return", "xsdFullTypesToJava", ".", "getOrDefault", "(", "restrictions", ".", "get", "(", "0", ")", ".", "getBase", "(", ")", ",", "JAVA_OBJECT_DESC", ")", ";", "}", "return", "JAVA_OBJECT_DESC", ";", "}", "return", "javaType", ";", "}" ]
Obtains the java type descriptor based on the attribute type attribute. @param attribute The attribute from which the type will be obtained. @return The java descriptor of the attribute type.
[ "Obtains", "the", "java", "type", "descriptor", "based", "on", "the", "attribute", "type", "attribute", "." ]
ccb78f9dd4b957ad5ac1ca349eaf24338c421e94
https://github.com/xmlet/XsdAsmFaster/blob/ccb78f9dd4b957ad5ac1ca349eaf24338c421e94/src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmUtils.java#L258-L271
155,778
xmlet/XsdAsmFaster
src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmUtils.java
XsdAsmUtils.getAttributeRestrictions
static List<XsdRestriction> getAttributeRestrictions(XsdAttribute attribute) { try { return attribute.getAllRestrictions(); } catch (InvalidParameterException e){ throw new AsmException("The provided XSD file has contradictory restrictions.", e); } }
java
static List<XsdRestriction> getAttributeRestrictions(XsdAttribute attribute) { try { return attribute.getAllRestrictions(); } catch (InvalidParameterException e){ throw new AsmException("The provided XSD file has contradictory restrictions.", e); } }
[ "static", "List", "<", "XsdRestriction", ">", "getAttributeRestrictions", "(", "XsdAttribute", "attribute", ")", "{", "try", "{", "return", "attribute", ".", "getAllRestrictions", "(", ")", ";", "}", "catch", "(", "InvalidParameterException", "e", ")", "{", "throw", "new", "AsmException", "(", "\"The provided XSD file has contradictory restrictions.\"", ",", "e", ")", ";", "}", "}" ]
Obtains the attribute restrictions. @param attribute The received {@link XsdAttribute}. @return The restrictions of the received {@link XsdAttribute}.
[ "Obtains", "the", "attribute", "restrictions", "." ]
ccb78f9dd4b957ad5ac1ca349eaf24338c421e94
https://github.com/xmlet/XsdAsmFaster/blob/ccb78f9dd4b957ad5ac1ca349eaf24338c421e94/src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmUtils.java#L292-L298
155,779
xmlet/XsdAsmFaster
src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmUtils.java
XsdAsmUtils.generateMethodsAndCreateAttribute
static void generateMethodsAndCreateAttribute(Map<String, List<XsdAttribute>> createdAttributes, ClassWriter classWriter, XsdAttribute elementAttribute, String returnType, String className, String apiName) { XsdAsmAttributes.generateMethodsForAttribute(classWriter, elementAttribute, returnType, className,apiName); createAttribute(createdAttributes, elementAttribute); }
java
static void generateMethodsAndCreateAttribute(Map<String, List<XsdAttribute>> createdAttributes, ClassWriter classWriter, XsdAttribute elementAttribute, String returnType, String className, String apiName) { XsdAsmAttributes.generateMethodsForAttribute(classWriter, elementAttribute, returnType, className,apiName); createAttribute(createdAttributes, elementAttribute); }
[ "static", "void", "generateMethodsAndCreateAttribute", "(", "Map", "<", "String", ",", "List", "<", "XsdAttribute", ">", ">", "createdAttributes", ",", "ClassWriter", "classWriter", ",", "XsdAttribute", "elementAttribute", ",", "String", "returnType", ",", "String", "className", ",", "String", "apiName", ")", "{", "XsdAsmAttributes", ".", "generateMethodsForAttribute", "(", "classWriter", ",", "elementAttribute", ",", "returnType", ",", "className", ",", "apiName", ")", ";", "createAttribute", "(", "createdAttributes", ",", "elementAttribute", ")", ";", "}" ]
Generates the required methods for adding a given attribute and creates the respective class, if needed. @param createdAttributes Information about attributes that were already created. @param classWriter The {@link ClassWriter} to write the methods. @param elementAttribute The attribute element. @param returnType The method return type. @param className The name of the class which will contain the method to add the attribute. @param apiName The name of the generated fluent interface.
[ "Generates", "the", "required", "methods", "for", "adding", "a", "given", "attribute", "and", "creates", "the", "respective", "class", "if", "needed", "." ]
ccb78f9dd4b957ad5ac1ca349eaf24338c421e94
https://github.com/xmlet/XsdAsmFaster/blob/ccb78f9dd4b957ad5ac1ca349eaf24338c421e94/src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmUtils.java#L310-L313
155,780
xmlet/XsdAsmFaster
src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmUtils.java
XsdAsmUtils.getClassSignature
static String getClassSignature(String[] interfaces, String className, String apiName) { StringBuilder signature; signature = new StringBuilder("<Z::" + XsdSupportingStructure.elementTypeDesc + ">" + JAVA_OBJECT_DESC); if (interfaces != null){ for (String anInterface : interfaces) { signature.append("L") .append(getFullClassTypeName(anInterface, apiName)) .append("<L") .append(getFullClassTypeName(className, apiName)) .append("<TZ;>;TZ;>;"); } } return signature.toString(); }
java
static String getClassSignature(String[] interfaces, String className, String apiName) { StringBuilder signature; signature = new StringBuilder("<Z::" + XsdSupportingStructure.elementTypeDesc + ">" + JAVA_OBJECT_DESC); if (interfaces != null){ for (String anInterface : interfaces) { signature.append("L") .append(getFullClassTypeName(anInterface, apiName)) .append("<L") .append(getFullClassTypeName(className, apiName)) .append("<TZ;>;TZ;>;"); } } return signature.toString(); }
[ "static", "String", "getClassSignature", "(", "String", "[", "]", "interfaces", ",", "String", "className", ",", "String", "apiName", ")", "{", "StringBuilder", "signature", ";", "signature", "=", "new", "StringBuilder", "(", "\"<Z::\"", "+", "XsdSupportingStructure", ".", "elementTypeDesc", "+", "\">\"", "+", "JAVA_OBJECT_DESC", ")", ";", "if", "(", "interfaces", "!=", "null", ")", "{", "for", "(", "String", "anInterface", ":", "interfaces", ")", "{", "signature", ".", "append", "(", "\"L\"", ")", ".", "append", "(", "getFullClassTypeName", "(", "anInterface", ",", "apiName", ")", ")", ".", "append", "(", "\"<L\"", ")", ".", "append", "(", "getFullClassTypeName", "(", "className", ",", "apiName", ")", ")", ".", "append", "(", "\"<TZ;>;TZ;>;\"", ")", ";", "}", "}", "return", "signature", ".", "toString", "(", ")", ";", "}" ]
Obtains the signature for a class given the interface names. @param interfaces The implemented interfaces. @param className The class name. @param apiName The name of the generated fluent interface. @return The signature of the class.
[ "Obtains", "the", "signature", "for", "a", "class", "given", "the", "interface", "names", "." ]
ccb78f9dd4b957ad5ac1ca349eaf24338c421e94
https://github.com/xmlet/XsdAsmFaster/blob/ccb78f9dd4b957ad5ac1ca349eaf24338c421e94/src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmUtils.java#L468-L484
155,781
xmlet/XsdAsmFaster
src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmUtils.java
XsdAsmUtils.getInterfaceSignature
static String getInterfaceSignature(String[] interfaces, String apiName) { StringBuilder signature = new StringBuilder("<T::L" + XsdSupportingStructure.elementType + "<TT;TZ;>;Z::" + XsdSupportingStructure.elementTypeDesc + ">" + JAVA_OBJECT_DESC); if (interfaces != null){ for (String anInterface : interfaces) { signature.append("L") .append(getFullClassTypeName(anInterface, apiName)) .append("<TT;TZ;>;"); } } return signature.toString(); }
java
static String getInterfaceSignature(String[] interfaces, String apiName) { StringBuilder signature = new StringBuilder("<T::L" + XsdSupportingStructure.elementType + "<TT;TZ;>;Z::" + XsdSupportingStructure.elementTypeDesc + ">" + JAVA_OBJECT_DESC); if (interfaces != null){ for (String anInterface : interfaces) { signature.append("L") .append(getFullClassTypeName(anInterface, apiName)) .append("<TT;TZ;>;"); } } return signature.toString(); }
[ "static", "String", "getInterfaceSignature", "(", "String", "[", "]", "interfaces", ",", "String", "apiName", ")", "{", "StringBuilder", "signature", "=", "new", "StringBuilder", "(", "\"<T::L\"", "+", "XsdSupportingStructure", ".", "elementType", "+", "\"<TT;TZ;>;Z::\"", "+", "XsdSupportingStructure", ".", "elementTypeDesc", "+", "\">\"", "+", "JAVA_OBJECT_DESC", ")", ";", "if", "(", "interfaces", "!=", "null", ")", "{", "for", "(", "String", "anInterface", ":", "interfaces", ")", "{", "signature", ".", "append", "(", "\"L\"", ")", ".", "append", "(", "getFullClassTypeName", "(", "anInterface", ",", "apiName", ")", ")", ".", "append", "(", "\"<TT;TZ;>;\"", ")", ";", "}", "}", "return", "signature", ".", "toString", "(", ")", ";", "}" ]
Obtains the interface signature for a interface. @param interfaces The extended interfaces. @param apiName The name of the generated fluent interface. @return The interface signature.
[ "Obtains", "the", "interface", "signature", "for", "a", "interface", "." ]
ccb78f9dd4b957ad5ac1ca349eaf24338c421e94
https://github.com/xmlet/XsdAsmFaster/blob/ccb78f9dd4b957ad5ac1ca349eaf24338c421e94/src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmUtils.java#L492-L504
155,782
xmlet/XsdAsmFaster
src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmUtils.java
XsdAsmUtils.generateClass
static ClassWriter generateClass(String className, String superName, String[] interfaces, String signature, int classModifiers, String apiName) { ClassWriter classWriter = new ClassWriter(0); if (interfaces != null){ for (int i = 0; i < interfaces.length; i++) { interfaces[i] = getFullClassTypeName(interfaces[i], apiName); } } classWriter.visit(V1_8, classModifiers, getFullClassTypeName(className, apiName), signature, superName, interfaces); return classWriter; }
java
static ClassWriter generateClass(String className, String superName, String[] interfaces, String signature, int classModifiers, String apiName) { ClassWriter classWriter = new ClassWriter(0); if (interfaces != null){ for (int i = 0; i < interfaces.length; i++) { interfaces[i] = getFullClassTypeName(interfaces[i], apiName); } } classWriter.visit(V1_8, classModifiers, getFullClassTypeName(className, apiName), signature, superName, interfaces); return classWriter; }
[ "static", "ClassWriter", "generateClass", "(", "String", "className", ",", "String", "superName", ",", "String", "[", "]", "interfaces", ",", "String", "signature", ",", "int", "classModifiers", ",", "String", "apiName", ")", "{", "ClassWriter", "classWriter", "=", "new", "ClassWriter", "(", "0", ")", ";", "if", "(", "interfaces", "!=", "null", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "interfaces", ".", "length", ";", "i", "++", ")", "{", "interfaces", "[", "i", "]", "=", "getFullClassTypeName", "(", "interfaces", "[", "i", "]", ",", "apiName", ")", ";", "}", "}", "classWriter", ".", "visit", "(", "V1_8", ",", "classModifiers", ",", "getFullClassTypeName", "(", "className", ",", "apiName", ")", ",", "signature", ",", "superName", ",", "interfaces", ")", ";", "return", "classWriter", ";", "}" ]
Generates an empty class. @param className The classes name. @param superName The super object, which the class extends from. @param interfaces The name of the interfaces which this class implements. @param classModifiers The modifiers to the class. @return A class writer that will be used to write the remaining information of the class.
[ "Generates", "an", "empty", "class", "." ]
ccb78f9dd4b957ad5ac1ca349eaf24338c421e94
https://github.com/xmlet/XsdAsmFaster/blob/ccb78f9dd4b957ad5ac1ca349eaf24338c421e94/src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmUtils.java#L514-L526
155,783
xmlet/XsdAsmFaster
src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmUtils.java
XsdAsmUtils.getAllInterfaceMethodInfo
private static List<String> getAllInterfaceMethodInfo(List<InterfaceInfo> interfaceInfoList) { List<String> names = new ArrayList<>(); if (interfaceInfoList == null || interfaceInfoList.isEmpty()){ return names; } interfaceInfoList.forEach((InterfaceInfo interfaceInfo) -> { if (interfaceInfo.getMethodNames() != null && !interfaceInfo.getMethodNames().isEmpty()){ names.addAll(interfaceInfo.getMethodNames()); } names.addAll(getAllInterfaceMethodInfo(interfaceInfo.getExtendedInterfaces())); }); return names; }
java
private static List<String> getAllInterfaceMethodInfo(List<InterfaceInfo> interfaceInfoList) { List<String> names = new ArrayList<>(); if (interfaceInfoList == null || interfaceInfoList.isEmpty()){ return names; } interfaceInfoList.forEach((InterfaceInfo interfaceInfo) -> { if (interfaceInfo.getMethodNames() != null && !interfaceInfo.getMethodNames().isEmpty()){ names.addAll(interfaceInfo.getMethodNames()); } names.addAll(getAllInterfaceMethodInfo(interfaceInfo.getExtendedInterfaces())); }); return names; }
[ "private", "static", "List", "<", "String", ">", "getAllInterfaceMethodInfo", "(", "List", "<", "InterfaceInfo", ">", "interfaceInfoList", ")", "{", "List", "<", "String", ">", "names", "=", "new", "ArrayList", "<>", "(", ")", ";", "if", "(", "interfaceInfoList", "==", "null", "||", "interfaceInfoList", ".", "isEmpty", "(", ")", ")", "{", "return", "names", ";", "}", "interfaceInfoList", ".", "forEach", "(", "(", "InterfaceInfo", "interfaceInfo", ")", "->", "{", "if", "(", "interfaceInfo", ".", "getMethodNames", "(", ")", "!=", "null", "&&", "!", "interfaceInfo", ".", "getMethodNames", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "names", ".", "addAll", "(", "interfaceInfo", ".", "getMethodNames", "(", ")", ")", ";", "}", "names", ".", "addAll", "(", "getAllInterfaceMethodInfo", "(", "interfaceInfo", ".", "getExtendedInterfaces", "(", ")", ")", ")", ";", "}", ")", ";", "return", "names", ";", "}" ]
Obtain the names of all the methods in the current interface and all the extended interfaces. @param interfaceInfoList A {@link List} of {@link InterfaceInfo}. @return The names of all the methods in the current and extended interfaces.
[ "Obtain", "the", "names", "of", "all", "the", "methods", "in", "the", "current", "interface", "and", "all", "the", "extended", "interfaces", "." ]
ccb78f9dd4b957ad5ac1ca349eaf24338c421e94
https://github.com/xmlet/XsdAsmFaster/blob/ccb78f9dd4b957ad5ac1ca349eaf24338c421e94/src/main/java/org/xmlet/xsdasmfaster/classes/XsdAsmUtils.java#L588-L604
155,784
morimekta/utils
console-util/src/main/java/net/morimekta/console/args/ArgumentOptions.java
ArgumentOptions.withMaxUsageWidth
public ArgumentOptions withMaxUsageWidth(int maxWidth) { if (tty.isInteractive()) { this.usageWidth = Math.min(maxWidth, tty.getTerminalSize().cols); } else { this.usageWidth = maxWidth; } return this; }
java
public ArgumentOptions withMaxUsageWidth(int maxWidth) { if (tty.isInteractive()) { this.usageWidth = Math.min(maxWidth, tty.getTerminalSize().cols); } else { this.usageWidth = maxWidth; } return this; }
[ "public", "ArgumentOptions", "withMaxUsageWidth", "(", "int", "maxWidth", ")", "{", "if", "(", "tty", ".", "isInteractive", "(", ")", ")", "{", "this", ".", "usageWidth", "=", "Math", ".", "min", "(", "maxWidth", ",", "tty", ".", "getTerminalSize", "(", ")", ".", "cols", ")", ";", "}", "else", "{", "this", ".", "usageWidth", "=", "maxWidth", ";", "}", "return", "this", ";", "}" ]
Set the maximum usage width. The width is set as wide as possible based on the terminal column count, but maximum the maxWidth. @param maxWidth The maximum width. @return The Argument options.
[ "Set", "the", "maximum", "usage", "width", ".", "The", "width", "is", "set", "as", "wide", "as", "possible", "based", "on", "the", "terminal", "column", "count", "but", "maximum", "the", "maxWidth", "." ]
dc987485902f1a7d58169c89c61db97425a6226d
https://github.com/morimekta/utils/blob/dc987485902f1a7d58169c89c61db97425a6226d/console-util/src/main/java/net/morimekta/console/args/ArgumentOptions.java#L85-L92
155,785
james-hu/jabb-core
src/main/java/net/sf/jabb/util/bean/JQueryGridData.java
JQueryGridData.addRows
public void addRows(ResultSet rs) throws SQLException{ ResultSetMetaData rsmd = rs.getMetaData(); int columnCount = rsmd.getColumnCount(); while (rs.next()) { Map<String, Object> row = new HashMap<String, Object>(); for (int i = 1; i < columnCount + 1; i++) { String colName = rsmd.getColumnName(i); Object colObj = rs.getObject(i); if (colObj == null){ // avoid error if trying to convert data types row.put(colName, colObj); }else{ if (colObj instanceof oracle.sql.Datum){ colObj = ((oracle.sql.TIMESTAMP)colObj).toJdbc(); } if (colObj instanceof java.sql.Timestamp){ row.put(colName, new Date(((java.sql.Timestamp)colObj).getTime())); }else if (colObj instanceof java.sql.Date){ row.put(colName, new Date(((java.sql.Date)colObj).getTime())); }else{ row.put(colName, colObj); } } } addRow(row); } }
java
public void addRows(ResultSet rs) throws SQLException{ ResultSetMetaData rsmd = rs.getMetaData(); int columnCount = rsmd.getColumnCount(); while (rs.next()) { Map<String, Object> row = new HashMap<String, Object>(); for (int i = 1; i < columnCount + 1; i++) { String colName = rsmd.getColumnName(i); Object colObj = rs.getObject(i); if (colObj == null){ // avoid error if trying to convert data types row.put(colName, colObj); }else{ if (colObj instanceof oracle.sql.Datum){ colObj = ((oracle.sql.TIMESTAMP)colObj).toJdbc(); } if (colObj instanceof java.sql.Timestamp){ row.put(colName, new Date(((java.sql.Timestamp)colObj).getTime())); }else if (colObj instanceof java.sql.Date){ row.put(colName, new Date(((java.sql.Date)colObj).getTime())); }else{ row.put(colName, colObj); } } } addRow(row); } }
[ "public", "void", "addRows", "(", "ResultSet", "rs", ")", "throws", "SQLException", "{", "ResultSetMetaData", "rsmd", "=", "rs", ".", "getMetaData", "(", ")", ";", "int", "columnCount", "=", "rsmd", ".", "getColumnCount", "(", ")", ";", "while", "(", "rs", ".", "next", "(", ")", ")", "{", "Map", "<", "String", ",", "Object", ">", "row", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "columnCount", "+", "1", ";", "i", "++", ")", "{", "String", "colName", "=", "rsmd", ".", "getColumnName", "(", "i", ")", ";", "Object", "colObj", "=", "rs", ".", "getObject", "(", "i", ")", ";", "if", "(", "colObj", "==", "null", ")", "{", "// avoid error if trying to convert data types\r", "row", ".", "put", "(", "colName", ",", "colObj", ")", ";", "}", "else", "{", "if", "(", "colObj", "instanceof", "oracle", ".", "sql", ".", "Datum", ")", "{", "colObj", "=", "(", "(", "oracle", ".", "sql", ".", "TIMESTAMP", ")", "colObj", ")", ".", "toJdbc", "(", ")", ";", "}", "if", "(", "colObj", "instanceof", "java", ".", "sql", ".", "Timestamp", ")", "{", "row", ".", "put", "(", "colName", ",", "new", "Date", "(", "(", "(", "java", ".", "sql", ".", "Timestamp", ")", "colObj", ")", ".", "getTime", "(", ")", ")", ")", ";", "}", "else", "if", "(", "colObj", "instanceof", "java", ".", "sql", ".", "Date", ")", "{", "row", ".", "put", "(", "colName", ",", "new", "Date", "(", "(", "(", "java", ".", "sql", ".", "Date", ")", "colObj", ")", ".", "getTime", "(", ")", ")", ")", ";", "}", "else", "{", "row", ".", "put", "(", "colName", ",", "colObj", ")", ";", "}", "}", "}", "addRow", "(", "row", ")", ";", "}", "}" ]
Add rows from a JDBC ResultSet. Each row will be a HashMap mapped from a record of ResultSet. @param rs @throws SQLException
[ "Add", "rows", "from", "a", "JDBC", "ResultSet", ".", "Each", "row", "will", "be", "a", "HashMap", "mapped", "from", "a", "record", "of", "ResultSet", "." ]
bceed441595c5e5195a7418795f03b69fa7b61e4
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/util/bean/JQueryGridData.java#L87-L114
155,786
konvergeio/cofoja
src/main/java/com/google/java/contract/core/apt/AnnotationProcessor.java
AnnotationProcessor.setupPaths
private void setupPaths() { sourcePath = processingEnv.getOptions().get(OPT_SOURCEPATH); classPath = processingEnv.getOptions().get(OPT_CLASSPATH); outputDirectory = processingEnv.getOptions().get(OPT_CLASSOUTPUT); /* * Not using instanceof here because than in every case the JVM * tries to load the JavacProcessingEnvironment-class file which, * for instance, is not possible with an IBM JVM. * * TODO(lenh): This may not work; use reflection call instead. */ if (processingEnv.getClass().getName().equals( "com.sun.tools.javac.processing.JavacProcessingEnvironment")) { JavacProcessingEnvironment javacEnv = (JavacProcessingEnvironment) processingEnv; Options options = Options.instance(javacEnv.getContext()); if (sourcePath == null) { sourcePath = options.get(OptionName.SOURCEPATH); } if (classPath == null) { String classPath1 = options.get(OptionName.CP); String classPath2 = options.get(OptionName.CLASSPATH); if (classPath1 != null) { if (classPath2 != null) { classPath = classPath1 + File.pathSeparator + classPath2; } else { classPath = classPath1; } } else { classPath = classPath2; } } if (outputDirectory == null) { outputDirectory = options.get(OptionName.D); } } }
java
private void setupPaths() { sourcePath = processingEnv.getOptions().get(OPT_SOURCEPATH); classPath = processingEnv.getOptions().get(OPT_CLASSPATH); outputDirectory = processingEnv.getOptions().get(OPT_CLASSOUTPUT); /* * Not using instanceof here because than in every case the JVM * tries to load the JavacProcessingEnvironment-class file which, * for instance, is not possible with an IBM JVM. * * TODO(lenh): This may not work; use reflection call instead. */ if (processingEnv.getClass().getName().equals( "com.sun.tools.javac.processing.JavacProcessingEnvironment")) { JavacProcessingEnvironment javacEnv = (JavacProcessingEnvironment) processingEnv; Options options = Options.instance(javacEnv.getContext()); if (sourcePath == null) { sourcePath = options.get(OptionName.SOURCEPATH); } if (classPath == null) { String classPath1 = options.get(OptionName.CP); String classPath2 = options.get(OptionName.CLASSPATH); if (classPath1 != null) { if (classPath2 != null) { classPath = classPath1 + File.pathSeparator + classPath2; } else { classPath = classPath1; } } else { classPath = classPath2; } } if (outputDirectory == null) { outputDirectory = options.get(OptionName.D); } } }
[ "private", "void", "setupPaths", "(", ")", "{", "sourcePath", "=", "processingEnv", ".", "getOptions", "(", ")", ".", "get", "(", "OPT_SOURCEPATH", ")", ";", "classPath", "=", "processingEnv", ".", "getOptions", "(", ")", ".", "get", "(", "OPT_CLASSPATH", ")", ";", "outputDirectory", "=", "processingEnv", ".", "getOptions", "(", ")", ".", "get", "(", "OPT_CLASSOUTPUT", ")", ";", "/*\n * Not using instanceof here because than in every case the JVM\n * tries to load the JavacProcessingEnvironment-class file which,\n * for instance, is not possible with an IBM JVM.\n *\n * TODO(lenh): This may not work; use reflection call instead.\n */", "if", "(", "processingEnv", ".", "getClass", "(", ")", ".", "getName", "(", ")", ".", "equals", "(", "\"com.sun.tools.javac.processing.JavacProcessingEnvironment\"", ")", ")", "{", "JavacProcessingEnvironment", "javacEnv", "=", "(", "JavacProcessingEnvironment", ")", "processingEnv", ";", "Options", "options", "=", "Options", ".", "instance", "(", "javacEnv", ".", "getContext", "(", ")", ")", ";", "if", "(", "sourcePath", "==", "null", ")", "{", "sourcePath", "=", "options", ".", "get", "(", "OptionName", ".", "SOURCEPATH", ")", ";", "}", "if", "(", "classPath", "==", "null", ")", "{", "String", "classPath1", "=", "options", ".", "get", "(", "OptionName", ".", "CP", ")", ";", "String", "classPath2", "=", "options", ".", "get", "(", "OptionName", ".", "CLASSPATH", ")", ";", "if", "(", "classPath1", "!=", "null", ")", "{", "if", "(", "classPath2", "!=", "null", ")", "{", "classPath", "=", "classPath1", "+", "File", ".", "pathSeparator", "+", "classPath2", ";", "}", "else", "{", "classPath", "=", "classPath1", ";", "}", "}", "else", "{", "classPath", "=", "classPath2", ";", "}", "}", "if", "(", "outputDirectory", "==", "null", ")", "{", "outputDirectory", "=", "options", ".", "get", "(", "OptionName", ".", "D", ")", ";", "}", "}", "}" ]
Sets class and output paths from command-line options.
[ "Sets", "class", "and", "output", "paths", "from", "command", "-", "line", "options", "." ]
6ded58fa05eb5bf85f16353c8dd4c70bee59121a
https://github.com/konvergeio/cofoja/blob/6ded58fa05eb5bf85f16353c8dd4c70bee59121a/src/main/java/com/google/java/contract/core/apt/AnnotationProcessor.java#L205-L245
155,787
konvergeio/cofoja
src/main/java/com/google/java/contract/core/apt/AnnotationProcessor.java
AnnotationProcessor.dumpSources
@Requires({ "types != null", "sources != null", "types.size() == sources.size()" }) protected void dumpSources(List<TypeModel> types, List<SyntheticJavaFile> sources) { Iterator<TypeModel> itType = types.iterator(); Iterator<SyntheticJavaFile> itFile = sources.iterator(); while (itType.hasNext() && itFile.hasNext()) { TypeModel type = itType.next(); SyntheticJavaFile file = itFile.next(); DebugUtils.dump(type.getName().getBinaryName(), file.getCharContent(true).toString().getBytes(), Kind.SOURCE); } }
java
@Requires({ "types != null", "sources != null", "types.size() == sources.size()" }) protected void dumpSources(List<TypeModel> types, List<SyntheticJavaFile> sources) { Iterator<TypeModel> itType = types.iterator(); Iterator<SyntheticJavaFile> itFile = sources.iterator(); while (itType.hasNext() && itFile.hasNext()) { TypeModel type = itType.next(); SyntheticJavaFile file = itFile.next(); DebugUtils.dump(type.getName().getBinaryName(), file.getCharContent(true).toString().getBytes(), Kind.SOURCE); } }
[ "@", "Requires", "(", "{", "\"types != null\"", ",", "\"sources != null\"", ",", "\"types.size() == sources.size()\"", "}", ")", "protected", "void", "dumpSources", "(", "List", "<", "TypeModel", ">", "types", ",", "List", "<", "SyntheticJavaFile", ">", "sources", ")", "{", "Iterator", "<", "TypeModel", ">", "itType", "=", "types", ".", "iterator", "(", ")", ";", "Iterator", "<", "SyntheticJavaFile", ">", "itFile", "=", "sources", ".", "iterator", "(", ")", ";", "while", "(", "itType", ".", "hasNext", "(", ")", "&&", "itFile", ".", "hasNext", "(", ")", ")", "{", "TypeModel", "type", "=", "itType", ".", "next", "(", ")", ";", "SyntheticJavaFile", "file", "=", "itFile", ".", "next", "(", ")", ";", "DebugUtils", ".", "dump", "(", "type", ".", "getName", "(", ")", ".", "getBinaryName", "(", ")", ",", "file", ".", "getCharContent", "(", "true", ")", ".", "toString", "(", ")", ".", "getBytes", "(", ")", ",", "Kind", ".", "SOURCE", ")", ";", "}", "}" ]
Dumps the computed Java source files in the dump directory of Contracts for Java.
[ "Dumps", "the", "computed", "Java", "source", "files", "in", "the", "dump", "directory", "of", "Contracts", "for", "Java", "." ]
6ded58fa05eb5bf85f16353c8dd4c70bee59121a
https://github.com/konvergeio/cofoja/blob/6ded58fa05eb5bf85f16353c8dd4c70bee59121a/src/main/java/com/google/java/contract/core/apt/AnnotationProcessor.java#L266-L282
155,788
konvergeio/cofoja
src/main/java/com/google/java/contract/core/apt/AnnotationProcessor.java
AnnotationProcessor.getContractedRootElements
@Requires("roundEnv != null") @Ensures("result != null") protected Set<TypeElement> getContractedRootElements( RoundEnvironment roundEnv) { Set<? extends Element> allElements = roundEnv.getRootElements(); Set<TypeElement> contractedRootElements = new HashSet<TypeElement>(allElements.size()); ContractFinder cf = new ContractFinder(utils); for (Element e : allElements) { if (e.accept(cf, null)) { contractedRootElements.add(getRootElement(e)); } } return contractedRootElements; }
java
@Requires("roundEnv != null") @Ensures("result != null") protected Set<TypeElement> getContractedRootElements( RoundEnvironment roundEnv) { Set<? extends Element> allElements = roundEnv.getRootElements(); Set<TypeElement> contractedRootElements = new HashSet<TypeElement>(allElements.size()); ContractFinder cf = new ContractFinder(utils); for (Element e : allElements) { if (e.accept(cf, null)) { contractedRootElements.add(getRootElement(e)); } } return contractedRootElements; }
[ "@", "Requires", "(", "\"roundEnv != null\"", ")", "@", "Ensures", "(", "\"result != null\"", ")", "protected", "Set", "<", "TypeElement", ">", "getContractedRootElements", "(", "RoundEnvironment", "roundEnv", ")", "{", "Set", "<", "?", "extends", "Element", ">", "allElements", "=", "roundEnv", ".", "getRootElements", "(", ")", ";", "Set", "<", "TypeElement", ">", "contractedRootElements", "=", "new", "HashSet", "<", "TypeElement", ">", "(", "allElements", ".", "size", "(", ")", ")", ";", "ContractFinder", "cf", "=", "new", "ContractFinder", "(", "utils", ")", ";", "for", "(", "Element", "e", ":", "allElements", ")", "{", "if", "(", "e", ".", "accept", "(", "cf", ",", "null", ")", ")", "{", "contractedRootElements", ".", "add", "(", "getRootElement", "(", "e", ")", ")", ";", "}", "}", "return", "contractedRootElements", ";", "}" ]
Returns the set of root elements that contain contracts. Contracts can have been directly declared as annotations or inherited through the hierarchy. @param annotations the set of annotations to look for @param roundEnv the environment to get elements from
[ "Returns", "the", "set", "of", "root", "elements", "that", "contain", "contracts", ".", "Contracts", "can", "have", "been", "directly", "declared", "as", "annotations", "or", "inherited", "through", "the", "hierarchy", "." ]
6ded58fa05eb5bf85f16353c8dd4c70bee59121a
https://github.com/konvergeio/cofoja/blob/6ded58fa05eb5bf85f16353c8dd4c70bee59121a/src/main/java/com/google/java/contract/core/apt/AnnotationProcessor.java#L370-L386
155,789
SimiaCryptus/utilities
java-util/src/main/java/com/simiacryptus/text/NodewalkerCodec.java
NodewalkerCodec.writeForward
protected void writeForward(Encoder encoder) throws IOException { if (encoder.node.index != encoder.fromNode.index) { Bits bits = encoder.fromNode.bitsTo(encoder.node); short count = (short) (encoder.node.getDepth() - encoder.fromNode.getDepth()); if (verbose != null) { verbose.println(String.format("Writing %s forward from %s to %s = %s", count, encoder.fromNode.getDebugString(), encoder.node.getDebugString(), bits)); } encoder.out.writeVarShort(count, 3); encoder.out.write(bits); } else { assert (0 == encoder.node.index); encoder.out.writeVarShort((short) 0, 3); } }
java
protected void writeForward(Encoder encoder) throws IOException { if (encoder.node.index != encoder.fromNode.index) { Bits bits = encoder.fromNode.bitsTo(encoder.node); short count = (short) (encoder.node.getDepth() - encoder.fromNode.getDepth()); if (verbose != null) { verbose.println(String.format("Writing %s forward from %s to %s = %s", count, encoder.fromNode.getDebugString(), encoder.node.getDebugString(), bits)); } encoder.out.writeVarShort(count, 3); encoder.out.write(bits); } else { assert (0 == encoder.node.index); encoder.out.writeVarShort((short) 0, 3); } }
[ "protected", "void", "writeForward", "(", "Encoder", "encoder", ")", "throws", "IOException", "{", "if", "(", "encoder", ".", "node", ".", "index", "!=", "encoder", ".", "fromNode", ".", "index", ")", "{", "Bits", "bits", "=", "encoder", ".", "fromNode", ".", "bitsTo", "(", "encoder", ".", "node", ")", ";", "short", "count", "=", "(", "short", ")", "(", "encoder", ".", "node", ".", "getDepth", "(", ")", "-", "encoder", ".", "fromNode", ".", "getDepth", "(", ")", ")", ";", "if", "(", "verbose", "!=", "null", ")", "{", "verbose", ".", "println", "(", "String", ".", "format", "(", "\"Writing %s forward from %s to %s = %s\"", ",", "count", ",", "encoder", ".", "fromNode", ".", "getDebugString", "(", ")", ",", "encoder", ".", "node", ".", "getDebugString", "(", ")", ",", "bits", ")", ")", ";", "}", "encoder", ".", "out", ".", "writeVarShort", "(", "count", ",", "3", ")", ";", "encoder", ".", "out", ".", "write", "(", "bits", ")", ";", "}", "else", "{", "assert", "(", "0", "==", "encoder", ".", "node", ".", "index", ")", ";", "encoder", ".", "out", ".", "writeVarShort", "(", "(", "short", ")", "0", ",", "3", ")", ";", "}", "}" ]
Write forward. @param encoder the encoder @throws IOException the io exception
[ "Write", "forward", "." ]
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/text/NodewalkerCodec.java#L108-L122
155,790
SimiaCryptus/utilities
java-util/src/main/java/com/simiacryptus/text/NodewalkerCodec.java
NodewalkerCodec.readForward
protected void readForward(Decoder decoder) throws IOException { short numberOfTokens = decoder.in.readVarShort(3); if (0 < numberOfTokens) { long seek = decoder.in.peekLongCoord(decoder.node.getCursorCount()); TrieNode toNode = decoder.node.traverse(seek + decoder.node.getCursorIndex()); while (toNode.getDepth() > decoder.node.getDepth() + numberOfTokens) toNode = toNode.getParent(); Interval interval = decoder.node.intervalTo(toNode); String str = toNode.getString(decoder.node); Bits bits = interval.toBits(); if (verbose != null) { verbose.println(String.format("Read %s forward from %s to %s = %s", numberOfTokens, decoder.node.getDebugString(), toNode.getDebugString(), bits)); } decoder.in.expect(bits); decoder.out.append(str); decoder.node = toNode; } else { assert (0 == decoder.node.index); } }
java
protected void readForward(Decoder decoder) throws IOException { short numberOfTokens = decoder.in.readVarShort(3); if (0 < numberOfTokens) { long seek = decoder.in.peekLongCoord(decoder.node.getCursorCount()); TrieNode toNode = decoder.node.traverse(seek + decoder.node.getCursorIndex()); while (toNode.getDepth() > decoder.node.getDepth() + numberOfTokens) toNode = toNode.getParent(); Interval interval = decoder.node.intervalTo(toNode); String str = toNode.getString(decoder.node); Bits bits = interval.toBits(); if (verbose != null) { verbose.println(String.format("Read %s forward from %s to %s = %s", numberOfTokens, decoder.node.getDebugString(), toNode.getDebugString(), bits)); } decoder.in.expect(bits); decoder.out.append(str); decoder.node = toNode; } else { assert (0 == decoder.node.index); } }
[ "protected", "void", "readForward", "(", "Decoder", "decoder", ")", "throws", "IOException", "{", "short", "numberOfTokens", "=", "decoder", ".", "in", ".", "readVarShort", "(", "3", ")", ";", "if", "(", "0", "<", "numberOfTokens", ")", "{", "long", "seek", "=", "decoder", ".", "in", ".", "peekLongCoord", "(", "decoder", ".", "node", ".", "getCursorCount", "(", ")", ")", ";", "TrieNode", "toNode", "=", "decoder", ".", "node", ".", "traverse", "(", "seek", "+", "decoder", ".", "node", ".", "getCursorIndex", "(", ")", ")", ";", "while", "(", "toNode", ".", "getDepth", "(", ")", ">", "decoder", ".", "node", ".", "getDepth", "(", ")", "+", "numberOfTokens", ")", "toNode", "=", "toNode", ".", "getParent", "(", ")", ";", "Interval", "interval", "=", "decoder", ".", "node", ".", "intervalTo", "(", "toNode", ")", ";", "String", "str", "=", "toNode", ".", "getString", "(", "decoder", ".", "node", ")", ";", "Bits", "bits", "=", "interval", ".", "toBits", "(", ")", ";", "if", "(", "verbose", "!=", "null", ")", "{", "verbose", ".", "println", "(", "String", ".", "format", "(", "\"Read %s forward from %s to %s = %s\"", ",", "numberOfTokens", ",", "decoder", ".", "node", ".", "getDebugString", "(", ")", ",", "toNode", ".", "getDebugString", "(", ")", ",", "bits", ")", ")", ";", "}", "decoder", ".", "in", ".", "expect", "(", "bits", ")", ";", "decoder", ".", "out", ".", "append", "(", "str", ")", ";", "decoder", ".", "node", "=", "toNode", ";", "}", "else", "{", "assert", "(", "0", "==", "decoder", ".", "node", ".", "index", ")", ";", "}", "}" ]
Read forward. @param decoder the decoder @throws IOException the io exception
[ "Read", "forward", "." ]
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/text/NodewalkerCodec.java#L130-L149
155,791
SimiaCryptus/utilities
java-util/src/main/java/com/simiacryptus/text/NodewalkerCodec.java
NodewalkerCodec.writeBackup
protected Optional<TrieNode> writeBackup(Encoder encoder, char token) throws IOException { Optional<TrieNode> child = Optional.empty(); while (!child.isPresent()) { encoder.node = encoder.node.godparent(); if (encoder.node == null) break; child = (Optional<TrieNode>) encoder.node.getChild(token); } assert (null == encoder.node || child.isPresent()); if (null != encoder.node) { for (int i = 0; i < 2; i++) { if (0 != encoder.node.index) encoder.node = encoder.node.godparent(); } child = (Optional<TrieNode>) encoder.node.getChild(token); while (!child.isPresent()) { encoder.node = encoder.node.godparent(); if (encoder.node == null) break; child = (Optional<TrieNode>) encoder.node.getChild(token); } assert (null == encoder.node || child.isPresent()); } short backupSteps = (short) (encoder.fromNode.getDepth() - (null == encoder.node ? -1 : encoder.node.getDepth())); assert (backupSteps >= 0); if (verbose != null) { verbose.println(String.format("Backing up %s from from %s to %s", backupSteps, encoder.fromNode.getDebugString(), null == encoder.node ? null : encoder.node.getDebugString())); } encoder.out.writeVarShort(backupSteps, 3); return child; }
java
protected Optional<TrieNode> writeBackup(Encoder encoder, char token) throws IOException { Optional<TrieNode> child = Optional.empty(); while (!child.isPresent()) { encoder.node = encoder.node.godparent(); if (encoder.node == null) break; child = (Optional<TrieNode>) encoder.node.getChild(token); } assert (null == encoder.node || child.isPresent()); if (null != encoder.node) { for (int i = 0; i < 2; i++) { if (0 != encoder.node.index) encoder.node = encoder.node.godparent(); } child = (Optional<TrieNode>) encoder.node.getChild(token); while (!child.isPresent()) { encoder.node = encoder.node.godparent(); if (encoder.node == null) break; child = (Optional<TrieNode>) encoder.node.getChild(token); } assert (null == encoder.node || child.isPresent()); } short backupSteps = (short) (encoder.fromNode.getDepth() - (null == encoder.node ? -1 : encoder.node.getDepth())); assert (backupSteps >= 0); if (verbose != null) { verbose.println(String.format("Backing up %s from from %s to %s", backupSteps, encoder.fromNode.getDebugString(), null == encoder.node ? null : encoder.node.getDebugString())); } encoder.out.writeVarShort(backupSteps, 3); return child; }
[ "protected", "Optional", "<", "TrieNode", ">", "writeBackup", "(", "Encoder", "encoder", ",", "char", "token", ")", "throws", "IOException", "{", "Optional", "<", "TrieNode", ">", "child", "=", "Optional", ".", "empty", "(", ")", ";", "while", "(", "!", "child", ".", "isPresent", "(", ")", ")", "{", "encoder", ".", "node", "=", "encoder", ".", "node", ".", "godparent", "(", ")", ";", "if", "(", "encoder", ".", "node", "==", "null", ")", "break", ";", "child", "=", "(", "Optional", "<", "TrieNode", ">", ")", "encoder", ".", "node", ".", "getChild", "(", "token", ")", ";", "}", "assert", "(", "null", "==", "encoder", ".", "node", "||", "child", ".", "isPresent", "(", ")", ")", ";", "if", "(", "null", "!=", "encoder", ".", "node", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "2", ";", "i", "++", ")", "{", "if", "(", "0", "!=", "encoder", ".", "node", ".", "index", ")", "encoder", ".", "node", "=", "encoder", ".", "node", ".", "godparent", "(", ")", ";", "}", "child", "=", "(", "Optional", "<", "TrieNode", ">", ")", "encoder", ".", "node", ".", "getChild", "(", "token", ")", ";", "while", "(", "!", "child", ".", "isPresent", "(", ")", ")", "{", "encoder", ".", "node", "=", "encoder", ".", "node", ".", "godparent", "(", ")", ";", "if", "(", "encoder", ".", "node", "==", "null", ")", "break", ";", "child", "=", "(", "Optional", "<", "TrieNode", ">", ")", "encoder", ".", "node", ".", "getChild", "(", "token", ")", ";", "}", "assert", "(", "null", "==", "encoder", ".", "node", "||", "child", ".", "isPresent", "(", ")", ")", ";", "}", "short", "backupSteps", "=", "(", "short", ")", "(", "encoder", ".", "fromNode", ".", "getDepth", "(", ")", "-", "(", "null", "==", "encoder", ".", "node", "?", "-", "1", ":", "encoder", ".", "node", ".", "getDepth", "(", ")", ")", ")", ";", "assert", "(", "backupSteps", ">=", "0", ")", ";", "if", "(", "verbose", "!=", "null", ")", "{", "verbose", ".", "println", "(", "String", ".", "format", "(", "\"Backing up %s from from %s to %s\"", ",", "backupSteps", ",", "encoder", ".", "fromNode", ".", "getDebugString", "(", ")", ",", "null", "==", "encoder", ".", "node", "?", "null", ":", "encoder", ".", "node", ".", "getDebugString", "(", ")", ")", ")", ";", "}", "encoder", ".", "out", ".", "writeVarShort", "(", "backupSteps", ",", "3", ")", ";", "return", "child", ";", "}" ]
Write backup optional. @param encoder the encoder @param token the token @return the optional @throws IOException the io exception
[ "Write", "backup", "optional", "." ]
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/text/NodewalkerCodec.java#L159-L186
155,792
SimiaCryptus/utilities
java-util/src/main/java/com/simiacryptus/text/NodewalkerCodec.java
NodewalkerCodec.readBackup
protected boolean readBackup(Decoder decoder) throws IOException { short numberOfBackupSteps = decoder.in.readVarShort(3); TrieNode fromNode = decoder.node; if (0 == numberOfBackupSteps) return true; for (int i = 0; i < numberOfBackupSteps; i++) { decoder.node = decoder.node.godparent(); } if (verbose != null) { verbose.println(String.format("Backing up %s from from %s to %s", numberOfBackupSteps, fromNode.getDebugString(), decoder.node.getDebugString())); } return false; }
java
protected boolean readBackup(Decoder decoder) throws IOException { short numberOfBackupSteps = decoder.in.readVarShort(3); TrieNode fromNode = decoder.node; if (0 == numberOfBackupSteps) return true; for (int i = 0; i < numberOfBackupSteps; i++) { decoder.node = decoder.node.godparent(); } if (verbose != null) { verbose.println(String.format("Backing up %s from from %s to %s", numberOfBackupSteps, fromNode.getDebugString(), decoder.node.getDebugString())); } return false; }
[ "protected", "boolean", "readBackup", "(", "Decoder", "decoder", ")", "throws", "IOException", "{", "short", "numberOfBackupSteps", "=", "decoder", ".", "in", ".", "readVarShort", "(", "3", ")", ";", "TrieNode", "fromNode", "=", "decoder", ".", "node", ";", "if", "(", "0", "==", "numberOfBackupSteps", ")", "return", "true", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "numberOfBackupSteps", ";", "i", "++", ")", "{", "decoder", ".", "node", "=", "decoder", ".", "node", ".", "godparent", "(", ")", ";", "}", "if", "(", "verbose", "!=", "null", ")", "{", "verbose", ".", "println", "(", "String", ".", "format", "(", "\"Backing up %s from from %s to %s\"", ",", "numberOfBackupSteps", ",", "fromNode", ".", "getDebugString", "(", ")", ",", "decoder", ".", "node", ".", "getDebugString", "(", ")", ")", ")", ";", "}", "return", "false", ";", "}" ]
Read backup boolean. @param decoder the decoder @return the boolean @throws IOException the io exception
[ "Read", "backup", "boolean", "." ]
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/text/NodewalkerCodec.java#L195-L206
155,793
SimiaCryptus/utilities
java-util/src/main/java/com/simiacryptus/text/NodewalkerCodec.java
NodewalkerCodec.writeTerminal
protected void writeTerminal(Encoder encoder) throws IOException { if (verbose != null) { verbose.println(String.format("Writing forward to end from %s to %s", encoder.fromNode.getDebugString(), encoder.node.getDebugString())); } encoder.out.writeVarShort((short) (encoder.node.getDepth() - encoder.fromNode.getDepth()), 3); encoder.out.write(encoder.fromNode.bitsTo(encoder.node)); encoder.out.writeVarShort((short) 0, 3); }
java
protected void writeTerminal(Encoder encoder) throws IOException { if (verbose != null) { verbose.println(String.format("Writing forward to end from %s to %s", encoder.fromNode.getDebugString(), encoder.node.getDebugString())); } encoder.out.writeVarShort((short) (encoder.node.getDepth() - encoder.fromNode.getDepth()), 3); encoder.out.write(encoder.fromNode.bitsTo(encoder.node)); encoder.out.writeVarShort((short) 0, 3); }
[ "protected", "void", "writeTerminal", "(", "Encoder", "encoder", ")", "throws", "IOException", "{", "if", "(", "verbose", "!=", "null", ")", "{", "verbose", ".", "println", "(", "String", ".", "format", "(", "\"Writing forward to end from %s to %s\"", ",", "encoder", ".", "fromNode", ".", "getDebugString", "(", ")", ",", "encoder", ".", "node", ".", "getDebugString", "(", ")", ")", ")", ";", "}", "encoder", ".", "out", ".", "writeVarShort", "(", "(", "short", ")", "(", "encoder", ".", "node", ".", "getDepth", "(", ")", "-", "encoder", ".", "fromNode", ".", "getDepth", "(", ")", ")", ",", "3", ")", ";", "encoder", ".", "out", ".", "write", "(", "encoder", ".", "fromNode", ".", "bitsTo", "(", "encoder", ".", "node", ")", ")", ";", "encoder", ".", "out", ".", "writeVarShort", "(", "(", "short", ")", "0", ",", "3", ")", ";", "}" ]
Write terminal. @param encoder the encoder @throws IOException the io exception
[ "Write", "terminal", "." ]
b5a5e73449aae57de7dbfca2ed7a074432c5b17e
https://github.com/SimiaCryptus/utilities/blob/b5a5e73449aae57de7dbfca2ed7a074432c5b17e/java-util/src/main/java/com/simiacryptus/text/NodewalkerCodec.java#L214-L221
155,794
app55/app55-java
src/support/java/com/googlecode/openbeans/XMLEncoder.java
XMLEncoder.checkDeadLoop
private boolean checkDeadLoop(Object value) { int n = 0; Object obj = value; while (obj != null) { Record rec = objRecordMap.get(obj); if (rec != null && rec.exp != null) { obj = rec.exp.getTarget(); } else { break; } if (obj != null && (obj.getClass().isAssignableFrom(value.getClass())) && obj.equals(value)) { n++; if (n >= DEADLOCK_THRESHOLD) { // System.out.println("Dead loop hit!"); return true; } } } return false; }
java
private boolean checkDeadLoop(Object value) { int n = 0; Object obj = value; while (obj != null) { Record rec = objRecordMap.get(obj); if (rec != null && rec.exp != null) { obj = rec.exp.getTarget(); } else { break; } if (obj != null && (obj.getClass().isAssignableFrom(value.getClass())) && obj.equals(value)) { n++; if (n >= DEADLOCK_THRESHOLD) { // System.out.println("Dead loop hit!"); return true; } } } return false; }
[ "private", "boolean", "checkDeadLoop", "(", "Object", "value", ")", "{", "int", "n", "=", "0", ";", "Object", "obj", "=", "value", ";", "while", "(", "obj", "!=", "null", ")", "{", "Record", "rec", "=", "objRecordMap", ".", "get", "(", "obj", ")", ";", "if", "(", "rec", "!=", "null", "&&", "rec", ".", "exp", "!=", "null", ")", "{", "obj", "=", "rec", ".", "exp", ".", "getTarget", "(", ")", ";", "}", "else", "{", "break", ";", "}", "if", "(", "obj", "!=", "null", "&&", "(", "obj", ".", "getClass", "(", ")", ".", "isAssignableFrom", "(", "value", ".", "getClass", "(", ")", ")", ")", "&&", "obj", ".", "equals", "(", "value", ")", ")", "{", "n", "++", ";", "if", "(", "n", ">=", "DEADLOCK_THRESHOLD", ")", "{", "// System.out.println(\"Dead loop hit!\");", "return", "true", ";", "}", "}", "}", "return", "false", ";", "}" ]
Imperfect attempt to detect a dead loop. This works with specific patterns that can be found in our AWT implementation. See HARMONY-5707 for details. @param value the object to check dupes for @return true if a dead loop detected; false otherwise FIXME
[ "Imperfect", "attempt", "to", "detect", "a", "dead", "loop", ".", "This", "works", "with", "specific", "patterns", "that", "can", "be", "found", "in", "our", "AWT", "implementation", ".", "See", "HARMONY", "-", "5707", "for", "details", "." ]
73e51d0f3141a859dfbd37ca9becef98477e553e
https://github.com/app55/app55-java/blob/73e51d0f3141a859dfbd37ca9becef98477e553e/src/support/java/com/googlecode/openbeans/XMLEncoder.java#L973-L1003
155,795
app55/app55-java
src/support/java/com/googlecode/openbeans/XMLEncoder.java
XMLEncoder.writeExpression
@Override public void writeExpression(Expression oldExp) { if (null == oldExp) { throw new NullPointerException(); } boolean oldWritingObject = writingObject; writingObject = true; // get expression value Object oldValue = expressionValue(oldExp); // check existence if (oldValue == null || get(oldValue) != null && (oldWritingObject || oldValue.getClass() != String.class)) { return; } // record how the object is obtained if (!isBasicType(oldValue) || (!oldWritingObject && oldValue.getClass() == String.class)) { recordExpression(oldValue, oldExp); } // try to detect if we run into a dead loop if (checkDeadLoop(oldValue)) { return; } super.writeExpression(oldExp); writingObject = oldWritingObject; }
java
@Override public void writeExpression(Expression oldExp) { if (null == oldExp) { throw new NullPointerException(); } boolean oldWritingObject = writingObject; writingObject = true; // get expression value Object oldValue = expressionValue(oldExp); // check existence if (oldValue == null || get(oldValue) != null && (oldWritingObject || oldValue.getClass() != String.class)) { return; } // record how the object is obtained if (!isBasicType(oldValue) || (!oldWritingObject && oldValue.getClass() == String.class)) { recordExpression(oldValue, oldExp); } // try to detect if we run into a dead loop if (checkDeadLoop(oldValue)) { return; } super.writeExpression(oldExp); writingObject = oldWritingObject; }
[ "@", "Override", "public", "void", "writeExpression", "(", "Expression", "oldExp", ")", "{", "if", "(", "null", "==", "oldExp", ")", "{", "throw", "new", "NullPointerException", "(", ")", ";", "}", "boolean", "oldWritingObject", "=", "writingObject", ";", "writingObject", "=", "true", ";", "// get expression value", "Object", "oldValue", "=", "expressionValue", "(", "oldExp", ")", ";", "// check existence", "if", "(", "oldValue", "==", "null", "||", "get", "(", "oldValue", ")", "!=", "null", "&&", "(", "oldWritingObject", "||", "oldValue", ".", "getClass", "(", ")", "!=", "String", ".", "class", ")", ")", "{", "return", ";", "}", "// record how the object is obtained", "if", "(", "!", "isBasicType", "(", "oldValue", ")", "||", "(", "!", "oldWritingObject", "&&", "oldValue", ".", "getClass", "(", ")", "==", "String", ".", "class", ")", ")", "{", "recordExpression", "(", "oldValue", ",", "oldExp", ")", ";", "}", "// try to detect if we run into a dead loop", "if", "(", "checkDeadLoop", "(", "oldValue", ")", ")", "{", "return", ";", "}", "super", ".", "writeExpression", "(", "oldExp", ")", ";", "writingObject", "=", "oldWritingObject", ";", "}" ]
Records the expression so that it can be written out later, then calls super implementation.
[ "Records", "the", "expression", "so", "that", "it", "can", "be", "written", "out", "later", "then", "calls", "super", "implementation", "." ]
73e51d0f3141a859dfbd37ca9becef98477e553e
https://github.com/app55/app55-java/blob/73e51d0f3141a859dfbd37ca9becef98477e553e/src/support/java/com/googlecode/openbeans/XMLEncoder.java#L1019-L1049
155,796
app55/app55-java
src/support/java/com/googlecode/openbeans/XMLEncoder.java
XMLEncoder.writeObject
@Override public void writeObject(Object o) { synchronized (this) { ArrayList<Object> prePending = objPrePendingCache.get(o); if (prePending == null) { boolean oldWritingObject = writingObject; writingObject = true; try { super.writeObject(o); } finally { writingObject = oldWritingObject; } } else { flushPrePending.clear(); flushPrePending.addAll(prePending); } // root object if (!writingObject) { boolean isNotCached = prePending == null; // is not cached, add to cache if (isNotCached && o != null) { prePending = new ArrayList<Object>(); prePending.addAll(flushPrePending); objPrePendingCache.put(o, prePending); } // add to pending flushPending.addAll(flushPrePending); flushPendingStat.addAll(flushPrePending); flushPrePending.clear(); if (isNotCached && flushPending.contains(o)) { flushPendingStat.remove(o); } else { flushPending.add(o); } if (needOwner) { this.flushPending.remove(owner); this.flushPending.add(0, owner); } } } }
java
@Override public void writeObject(Object o) { synchronized (this) { ArrayList<Object> prePending = objPrePendingCache.get(o); if (prePending == null) { boolean oldWritingObject = writingObject; writingObject = true; try { super.writeObject(o); } finally { writingObject = oldWritingObject; } } else { flushPrePending.clear(); flushPrePending.addAll(prePending); } // root object if (!writingObject) { boolean isNotCached = prePending == null; // is not cached, add to cache if (isNotCached && o != null) { prePending = new ArrayList<Object>(); prePending.addAll(flushPrePending); objPrePendingCache.put(o, prePending); } // add to pending flushPending.addAll(flushPrePending); flushPendingStat.addAll(flushPrePending); flushPrePending.clear(); if (isNotCached && flushPending.contains(o)) { flushPendingStat.remove(o); } else { flushPending.add(o); } if (needOwner) { this.flushPending.remove(owner); this.flushPending.add(0, owner); } } } }
[ "@", "Override", "public", "void", "writeObject", "(", "Object", "o", ")", "{", "synchronized", "(", "this", ")", "{", "ArrayList", "<", "Object", ">", "prePending", "=", "objPrePendingCache", ".", "get", "(", "o", ")", ";", "if", "(", "prePending", "==", "null", ")", "{", "boolean", "oldWritingObject", "=", "writingObject", ";", "writingObject", "=", "true", ";", "try", "{", "super", ".", "writeObject", "(", "o", ")", ";", "}", "finally", "{", "writingObject", "=", "oldWritingObject", ";", "}", "}", "else", "{", "flushPrePending", ".", "clear", "(", ")", ";", "flushPrePending", ".", "addAll", "(", "prePending", ")", ";", "}", "// root object", "if", "(", "!", "writingObject", ")", "{", "boolean", "isNotCached", "=", "prePending", "==", "null", ";", "// is not cached, add to cache", "if", "(", "isNotCached", "&&", "o", "!=", "null", ")", "{", "prePending", "=", "new", "ArrayList", "<", "Object", ">", "(", ")", ";", "prePending", ".", "addAll", "(", "flushPrePending", ")", ";", "objPrePendingCache", ".", "put", "(", "o", ",", "prePending", ")", ";", "}", "// add to pending", "flushPending", ".", "addAll", "(", "flushPrePending", ")", ";", "flushPendingStat", ".", "addAll", "(", "flushPrePending", ")", ";", "flushPrePending", ".", "clear", "(", ")", ";", "if", "(", "isNotCached", "&&", "flushPending", ".", "contains", "(", "o", ")", ")", "{", "flushPendingStat", ".", "remove", "(", "o", ")", ";", "}", "else", "{", "flushPending", ".", "add", "(", "o", ")", ";", "}", "if", "(", "needOwner", ")", "{", "this", ".", "flushPending", ".", "remove", "(", "owner", ")", ";", "this", ".", "flushPending", ".", "add", "(", "0", ",", "owner", ")", ";", "}", "}", "}", "}" ]
Records the object so that it can be written out later, then calls super implementation.
[ "Records", "the", "object", "so", "that", "it", "can", "be", "written", "out", "later", "then", "calls", "super", "implementation", "." ]
73e51d0f3141a859dfbd37ca9becef98477e553e
https://github.com/app55/app55-java/blob/73e51d0f3141a859dfbd37ca9becef98477e553e/src/support/java/com/googlecode/openbeans/XMLEncoder.java#L1054-L1111
155,797
app55/app55-java
src/support/java/com/googlecode/openbeans/XMLEncoder.java
XMLEncoder.writeStatement
@Override public void writeStatement(Statement oldStat) { if (null == oldStat) { System.err.println("java.lang.Exception: XMLEncoder: discarding statement null"); System.err.println("Continuing..."); return; } // record how the object is changed recordStatement(oldStat); super.writeStatement(oldStat); }
java
@Override public void writeStatement(Statement oldStat) { if (null == oldStat) { System.err.println("java.lang.Exception: XMLEncoder: discarding statement null"); System.err.println("Continuing..."); return; } // record how the object is changed recordStatement(oldStat); super.writeStatement(oldStat); }
[ "@", "Override", "public", "void", "writeStatement", "(", "Statement", "oldStat", ")", "{", "if", "(", "null", "==", "oldStat", ")", "{", "System", ".", "err", ".", "println", "(", "\"java.lang.Exception: XMLEncoder: discarding statement null\"", ")", ";", "System", ".", "err", ".", "println", "(", "\"Continuing...\"", ")", ";", "return", ";", "}", "// record how the object is changed", "recordStatement", "(", "oldStat", ")", ";", "super", ".", "writeStatement", "(", "oldStat", ")", ";", "}" ]
Records the statement so that it can be written out later, then calls super implementation.
[ "Records", "the", "statement", "so", "that", "it", "can", "be", "written", "out", "later", "then", "calls", "super", "implementation", "." ]
73e51d0f3141a859dfbd37ca9becef98477e553e
https://github.com/app55/app55-java/blob/73e51d0f3141a859dfbd37ca9becef98477e553e/src/support/java/com/googlecode/openbeans/XMLEncoder.java#L1116-L1129
155,798
pierre/eventtracker
common/src/main/java/com/ning/metrics/eventtracker/CollectorController.java
CollectorController.offerEvent
public void offerEvent(final Event event) throws IOException { if (!acceptEvents.get()) { // TODO shouldn't we increment eventsLost here? return; } eventsReceived.incrementAndGet(); try { log.debug("Writing event: {}", event); eventWriter.write(event); } catch (IOException e) { log.error(String.format("Failed to write event: %s", event), e); eventsLost.incrementAndGet(); throw e; } }
java
public void offerEvent(final Event event) throws IOException { if (!acceptEvents.get()) { // TODO shouldn't we increment eventsLost here? return; } eventsReceived.incrementAndGet(); try { log.debug("Writing event: {}", event); eventWriter.write(event); } catch (IOException e) { log.error(String.format("Failed to write event: %s", event), e); eventsLost.incrementAndGet(); throw e; } }
[ "public", "void", "offerEvent", "(", "final", "Event", "event", ")", "throws", "IOException", "{", "if", "(", "!", "acceptEvents", ".", "get", "(", ")", ")", "{", "// TODO shouldn't we increment eventsLost here?", "return", ";", "}", "eventsReceived", ".", "incrementAndGet", "(", ")", ";", "try", "{", "log", ".", "debug", "(", "\"Writing event: {}\"", ",", "event", ")", ";", "eventWriter", ".", "write", "(", "event", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "log", ".", "error", "(", "String", ".", "format", "(", "\"Failed to write event: %s\"", ",", "event", ")", ",", "e", ")", ";", "eventsLost", ".", "incrementAndGet", "(", ")", ";", "throw", "e", ";", "}", "}" ]
Offer an event to the queue. @param event an event to collect @throws IOException if a serialization exception (to disk) occurs
[ "Offer", "an", "event", "to", "the", "queue", "." ]
d47e74f11b05500fc31eeb43448aa6316a1318f6
https://github.com/pierre/eventtracker/blob/d47e74f11b05500fc31eeb43448aa6316a1318f6/common/src/main/java/com/ning/metrics/eventtracker/CollectorController.java#L56-L75
155,799
james-hu/jabb-core
src/main/java/net/sf/jabb/stdr/StdrUtil.java
StdrUtil.getParameters
@SuppressWarnings("unchecked") static public Map<String, Object> getParameters(ServletRequest request){ Map<String, Object> params = (Map<String, Object>) request.getAttribute(TEMPLATE_PARAMETER_MAP); if (params == null){ // no need to check thread-safe? params = new HashMap<String, Object>(); request.setAttribute(TEMPLATE_PARAMETER_MAP, params); } return params; }
java
@SuppressWarnings("unchecked") static public Map<String, Object> getParameters(ServletRequest request){ Map<String, Object> params = (Map<String, Object>) request.getAttribute(TEMPLATE_PARAMETER_MAP); if (params == null){ // no need to check thread-safe? params = new HashMap<String, Object>(); request.setAttribute(TEMPLATE_PARAMETER_MAP, params); } return params; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "static", "public", "Map", "<", "String", ",", "Object", ">", "getParameters", "(", "ServletRequest", "request", ")", "{", "Map", "<", "String", ",", "Object", ">", "params", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "request", ".", "getAttribute", "(", "TEMPLATE_PARAMETER_MAP", ")", ";", "if", "(", "params", "==", "null", ")", "{", "// no need to check thread-safe?", "params", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "request", ".", "setAttribute", "(", "TEMPLATE_PARAMETER_MAP", ",", "params", ")", ";", "}", "return", "params", ";", "}" ]
Get parameters from the attribute of servlet request. @param request the servlet request @return StdrUtil template parameters retrieved from request context
[ "Get", "parameters", "from", "the", "attribute", "of", "servlet", "request", "." ]
bceed441595c5e5195a7418795f03b69fa7b61e4
https://github.com/james-hu/jabb-core/blob/bceed441595c5e5195a7418795f03b69fa7b61e4/src/main/java/net/sf/jabb/stdr/StdrUtil.java#L34-L42