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
144,200
jmapper-framework/jmapper-core
JMapper Framework/src/main/java/com/googlecode/jmapper/JMapper.java
JMapper.destinationFactory
public JMapper<D, S> destinationFactory(DestinationFactory<D> factory){ this.mapper.setDestinationFactory(factory); return this; }
java
public JMapper<D, S> destinationFactory(DestinationFactory<D> factory){ this.mapper.setDestinationFactory(factory); return this; }
[ "public", "JMapper", "<", "D", ",", "S", ">", "destinationFactory", "(", "DestinationFactory", "<", "D", ">", "factory", ")", "{", "this", ".", "mapper", ".", "setDestinationFactory", "(", "factory", ")", ";", "return", "this", ";", "}" ]
Permits to define a destination factory, this is usefull in case of immutable objects. @param factory destination factory @return this instance of JMapper
[ "Permits", "to", "define", "a", "destination", "factory", "this", "is", "usefull", "in", "case", "of", "immutable", "objects", "." ]
b48fd3527f35055b8b4a30f53a51136f183acc90
https://github.com/jmapper-framework/jmapper-core/blob/b48fd3527f35055b8b4a30f53a51136f183acc90/JMapper Framework/src/main/java/com/googlecode/jmapper/JMapper.java#L475-L478
144,201
jmapper-framework/jmapper-core
JMapper Framework/src/main/java/com/googlecode/jmapper/util/ClassesManager.java
ClassesManager.isAssignableFrom
public static boolean isAssignableFrom(Class<?> destination,Class<?> source){ return destination.isAssignableFrom(source) || isBoxing(destination,source) || isUnBoxing(destination,source); }
java
public static boolean isAssignableFrom(Class<?> destination,Class<?> source){ return destination.isAssignableFrom(source) || isBoxing(destination,source) || isUnBoxing(destination,source); }
[ "public", "static", "boolean", "isAssignableFrom", "(", "Class", "<", "?", ">", "destination", ",", "Class", "<", "?", ">", "source", ")", "{", "return", "destination", ".", "isAssignableFrom", "(", "source", ")", "||", "isBoxing", "(", "destination", ",", "source", ")", "||", "isUnBoxing", "(", "destination", ",", "source", ")", ";", "}" ]
Returns true if destination is assignable from source analyzing autoboxing also. @param destination destination class @param source source class @return true if destination is assignable from source analyzing autoboxing also.
[ "Returns", "true", "if", "destination", "is", "assignable", "from", "source", "analyzing", "autoboxing", "also", "." ]
b48fd3527f35055b8b4a30f53a51136f183acc90
https://github.com/jmapper-framework/jmapper-core/blob/b48fd3527f35055b8b4a30f53a51136f183acc90/JMapper Framework/src/main/java/com/googlecode/jmapper/util/ClassesManager.java#L125-L127
144,202
jmapper-framework/jmapper-core
JMapper Framework/src/main/java/com/googlecode/jmapper/util/ClassesManager.java
ClassesManager.functionsAreAllowed
private static boolean functionsAreAllowed(boolean isAddAllFunction, boolean isPutAllFunction,Class<?> classD,Class<?> classS) { if(isAddAllFunction) return collectionIsAssignableFrom(classD) && collectionIsAssignableFrom(classS); if(isPutAllFunction) return mapIsAssignableFrom(classD) && mapIsAssignableFrom(classS); return isAssignableFrom(classD,classS); }
java
private static boolean functionsAreAllowed(boolean isAddAllFunction, boolean isPutAllFunction,Class<?> classD,Class<?> classS) { if(isAddAllFunction) return collectionIsAssignableFrom(classD) && collectionIsAssignableFrom(classS); if(isPutAllFunction) return mapIsAssignableFrom(classD) && mapIsAssignableFrom(classS); return isAssignableFrom(classD,classS); }
[ "private", "static", "boolean", "functionsAreAllowed", "(", "boolean", "isAddAllFunction", ",", "boolean", "isPutAllFunction", ",", "Class", "<", "?", ">", "classD", ",", "Class", "<", "?", ">", "classS", ")", "{", "if", "(", "isAddAllFunction", ")", "return", "collectionIsAssignableFrom", "(", "classD", ")", "&&", "collectionIsAssignableFrom", "(", "classS", ")", ";", "if", "(", "isPutAllFunction", ")", "return", "mapIsAssignableFrom", "(", "classD", ")", "&&", "mapIsAssignableFrom", "(", "classS", ")", ";", "return", "isAssignableFrom", "(", "classD", ",", "classS", ")", ";", "}" ]
Returns true if the function to check is allowed. @param isAddAllFunction true if addAll method is to check @param isPutAllFunction true if putAll method is to check @param classD destination class @param classS source class @return true if the function to check is allowed
[ "Returns", "true", "if", "the", "function", "to", "check", "is", "allowed", "." ]
b48fd3527f35055b8b4a30f53a51136f183acc90
https://github.com/jmapper-framework/jmapper-core/blob/b48fd3527f35055b8b4a30f53a51136f183acc90/JMapper Framework/src/main/java/com/googlecode/jmapper/util/ClassesManager.java#L232-L242
144,203
jmapper-framework/jmapper-core
JMapper Framework/src/main/java/com/googlecode/jmapper/util/ClassesManager.java
ClassesManager.getGenericString
public static String getGenericString(Field field){ String fieldDescription = field.toGenericString(); List<String> splitResult = new ArrayList<String>(); char[] charResult = fieldDescription.toCharArray(); boolean isFinished = false; int separatorIndex = fieldDescription.indexOf(" "); int previousIndex = 0; while(!isFinished){ // if previous character is "," don't cut the string int position = separatorIndex-1; char specialChar = charResult[position]; boolean isSpecialChar = true; if(specialChar!=',' && specialChar != '?'){ if(specialChar == 's'){ String specialString = null; try{ specialString = fieldDescription.substring(position - "extends".length(), position+1); if(isNull(specialString) || !" extends".equals(specialString)) isSpecialChar = false; }catch(IndexOutOfBoundsException e){ isSpecialChar = false; } }else isSpecialChar = false; } if(!isSpecialChar){ splitResult.add(fieldDescription.substring(previousIndex, separatorIndex)); previousIndex = separatorIndex+1; } separatorIndex = fieldDescription.indexOf(" ",separatorIndex+1); if(separatorIndex == -1)isFinished = true; } for (String description : splitResult) if(!isAccessModifier(description)) return description; return null; }
java
public static String getGenericString(Field field){ String fieldDescription = field.toGenericString(); List<String> splitResult = new ArrayList<String>(); char[] charResult = fieldDescription.toCharArray(); boolean isFinished = false; int separatorIndex = fieldDescription.indexOf(" "); int previousIndex = 0; while(!isFinished){ // if previous character is "," don't cut the string int position = separatorIndex-1; char specialChar = charResult[position]; boolean isSpecialChar = true; if(specialChar!=',' && specialChar != '?'){ if(specialChar == 's'){ String specialString = null; try{ specialString = fieldDescription.substring(position - "extends".length(), position+1); if(isNull(specialString) || !" extends".equals(specialString)) isSpecialChar = false; }catch(IndexOutOfBoundsException e){ isSpecialChar = false; } }else isSpecialChar = false; } if(!isSpecialChar){ splitResult.add(fieldDescription.substring(previousIndex, separatorIndex)); previousIndex = separatorIndex+1; } separatorIndex = fieldDescription.indexOf(" ",separatorIndex+1); if(separatorIndex == -1)isFinished = true; } for (String description : splitResult) if(!isAccessModifier(description)) return description; return null; }
[ "public", "static", "String", "getGenericString", "(", "Field", "field", ")", "{", "String", "fieldDescription", "=", "field", ".", "toGenericString", "(", ")", ";", "List", "<", "String", ">", "splitResult", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "char", "[", "]", "charResult", "=", "fieldDescription", ".", "toCharArray", "(", ")", ";", "boolean", "isFinished", "=", "false", ";", "int", "separatorIndex", "=", "fieldDescription", ".", "indexOf", "(", "\" \"", ")", ";", "int", "previousIndex", "=", "0", ";", "while", "(", "!", "isFinished", ")", "{", "// if previous character is \",\" don't cut the string\r", "int", "position", "=", "separatorIndex", "-", "1", ";", "char", "specialChar", "=", "charResult", "[", "position", "]", ";", "boolean", "isSpecialChar", "=", "true", ";", "if", "(", "specialChar", "!=", "'", "'", "&&", "specialChar", "!=", "'", "'", ")", "{", "if", "(", "specialChar", "==", "'", "'", ")", "{", "String", "specialString", "=", "null", ";", "try", "{", "specialString", "=", "fieldDescription", ".", "substring", "(", "position", "-", "\"extends\"", ".", "length", "(", ")", ",", "position", "+", "1", ")", ";", "if", "(", "isNull", "(", "specialString", ")", "||", "!", "\" extends\"", ".", "equals", "(", "specialString", ")", ")", "isSpecialChar", "=", "false", ";", "}", "catch", "(", "IndexOutOfBoundsException", "e", ")", "{", "isSpecialChar", "=", "false", ";", "}", "}", "else", "isSpecialChar", "=", "false", ";", "}", "if", "(", "!", "isSpecialChar", ")", "{", "splitResult", ".", "add", "(", "fieldDescription", ".", "substring", "(", "previousIndex", ",", "separatorIndex", ")", ")", ";", "previousIndex", "=", "separatorIndex", "+", "1", ";", "}", "separatorIndex", "=", "fieldDescription", ".", "indexOf", "(", "\" \"", ",", "separatorIndex", "+", "1", ")", ";", "if", "(", "separatorIndex", "==", "-", "1", ")", "isFinished", "=", "true", ";", "}", "for", "(", "String", "description", ":", "splitResult", ")", "if", "(", "!", "isAccessModifier", "(", "description", ")", ")", "return", "description", ";", "return", "null", ";", "}" ]
Splits the fieldDescription to obtain his class type,generics inclusive. @param field field to check @return returns a string that specified the structure of the field, including its generic
[ "Splits", "the", "fieldDescription", "to", "obtain", "his", "class", "type", "generics", "inclusive", "." ]
b48fd3527f35055b8b4a30f53a51136f183acc90
https://github.com/jmapper-framework/jmapper-core/blob/b48fd3527f35055b8b4a30f53a51136f183acc90/JMapper Framework/src/main/java/com/googlecode/jmapper/util/ClassesManager.java#L305-L351
144,204
jmapper-framework/jmapper-core
JMapper Framework/src/main/java/com/googlecode/jmapper/util/ClassesManager.java
ClassesManager.areEqual
public static boolean areEqual(Field destination,Field source){ return getGenericString(destination).equals(getGenericString(source)); }
java
public static boolean areEqual(Field destination,Field source){ return getGenericString(destination).equals(getGenericString(source)); }
[ "public", "static", "boolean", "areEqual", "(", "Field", "destination", ",", "Field", "source", ")", "{", "return", "getGenericString", "(", "destination", ")", ".", "equals", "(", "getGenericString", "(", "source", ")", ")", ";", "}" ]
Returns true if destination and source have the same structure. @param destination destination field @param source source field @return returns true if destination and source have the same structure
[ "Returns", "true", "if", "destination", "and", "source", "have", "the", "same", "structure", "." ]
b48fd3527f35055b8b4a30f53a51136f183acc90
https://github.com/jmapper-framework/jmapper-core/blob/b48fd3527f35055b8b4a30f53a51136f183acc90/JMapper Framework/src/main/java/com/googlecode/jmapper/util/ClassesManager.java#L359-L361
144,205
jmapper-framework/jmapper-core
JMapper Framework/src/main/java/com/googlecode/jmapper/util/ClassesManager.java
ClassesManager.mapperClassName
public static String mapperClassName(Class<?> destination, Class<?> source, String resource){ String className = destination.getName().replaceAll("\\.","") + source.getName().replaceAll("\\.",""); if(isEmpty(resource)) return className; if(!isPath(resource)) return write(className, String.valueOf(resource.hashCode())); String[]dep = resource.split("\\\\"); if(dep.length<=1)dep = resource.split("/"); String xml = dep[dep.length-1]; return write(className, xml.replaceAll("\\.","").replaceAll(" ","")); }
java
public static String mapperClassName(Class<?> destination, Class<?> source, String resource){ String className = destination.getName().replaceAll("\\.","") + source.getName().replaceAll("\\.",""); if(isEmpty(resource)) return className; if(!isPath(resource)) return write(className, String.valueOf(resource.hashCode())); String[]dep = resource.split("\\\\"); if(dep.length<=1)dep = resource.split("/"); String xml = dep[dep.length-1]; return write(className, xml.replaceAll("\\.","").replaceAll(" ","")); }
[ "public", "static", "String", "mapperClassName", "(", "Class", "<", "?", ">", "destination", ",", "Class", "<", "?", ">", "source", ",", "String", "resource", ")", "{", "String", "className", "=", "destination", ".", "getName", "(", ")", ".", "replaceAll", "(", "\"\\\\.\"", ",", "\"\"", ")", "+", "source", ".", "getName", "(", ")", ".", "replaceAll", "(", "\"\\\\.\"", ",", "\"\"", ")", ";", "if", "(", "isEmpty", "(", "resource", ")", ")", "return", "className", ";", "if", "(", "!", "isPath", "(", "resource", ")", ")", "return", "write", "(", "className", ",", "String", ".", "valueOf", "(", "resource", ".", "hashCode", "(", ")", ")", ")", ";", "String", "[", "]", "dep", "=", "resource", ".", "split", "(", "\"\\\\\\\\\"", ")", ";", "if", "(", "dep", ".", "length", "<=", "1", ")", "dep", "=", "resource", ".", "split", "(", "\"/\"", ")", ";", "String", "xml", "=", "dep", "[", "dep", ".", "length", "-", "1", "]", ";", "return", "write", "(", "className", ",", "xml", ".", "replaceAll", "(", "\"\\\\.\"", ",", "\"\"", ")", ".", "replaceAll", "(", "\" \"", ",", "\"\"", ")", ")", ";", "}" ]
Returns the name of mapper that identifies the destination and source classes. @param destination class of Destination @param source class of Source @param resource a resource that represents an xml path or a content @return Returns a string containing the names of the classes passed as input
[ "Returns", "the", "name", "of", "mapper", "that", "identifies", "the", "destination", "and", "source", "classes", "." ]
b48fd3527f35055b8b4a30f53a51136f183acc90
https://github.com/jmapper-framework/jmapper-core/blob/b48fd3527f35055b8b4a30f53a51136f183acc90/JMapper Framework/src/main/java/com/googlecode/jmapper/util/ClassesManager.java#L371-L385
144,206
jmapper-framework/jmapper-core
JMapper Framework/src/main/java/com/googlecode/jmapper/util/ClassesManager.java
ClassesManager.areMappedObjects
public static boolean areMappedObjects(Class<?> dClass,Class<?> sClass,XML xml){ return isMapped(dClass,xml) || isMapped(sClass,xml); }
java
public static boolean areMappedObjects(Class<?> dClass,Class<?> sClass,XML xml){ return isMapped(dClass,xml) || isMapped(sClass,xml); }
[ "public", "static", "boolean", "areMappedObjects", "(", "Class", "<", "?", ">", "dClass", ",", "Class", "<", "?", ">", "sClass", ",", "XML", "xml", ")", "{", "return", "isMapped", "(", "dClass", ",", "xml", ")", "||", "isMapped", "(", "sClass", ",", "xml", ")", ";", "}" ]
returns true if almost one class is configured, false otherwise. @param dClass class to verify @param sClass class to verify @param xml xml to check @return true if almost one class is configured, false otherwise.
[ "returns", "true", "if", "almost", "one", "class", "is", "configured", "false", "otherwise", "." ]
b48fd3527f35055b8b4a30f53a51136f183acc90
https://github.com/jmapper-framework/jmapper-core/blob/b48fd3527f35055b8b4a30f53a51136f183acc90/JMapper Framework/src/main/java/com/googlecode/jmapper/util/ClassesManager.java#L428-L430
144,207
jmapper-framework/jmapper-core
JMapper Framework/src/main/java/com/googlecode/jmapper/util/ClassesManager.java
ClassesManager.isMapped
private static boolean isMapped(Class<?> aClass,XML xml){ return xml.isInheritedMapped(aClass) || Annotation.isInheritedMapped(aClass); }
java
private static boolean isMapped(Class<?> aClass,XML xml){ return xml.isInheritedMapped(aClass) || Annotation.isInheritedMapped(aClass); }
[ "private", "static", "boolean", "isMapped", "(", "Class", "<", "?", ">", "aClass", ",", "XML", "xml", ")", "{", "return", "xml", ".", "isInheritedMapped", "(", "aClass", ")", "||", "Annotation", ".", "isInheritedMapped", "(", "aClass", ")", ";", "}" ]
Returns true if the class is configured in annotation or xml, false otherwise. @param aClass a class @param xml xml to check @return true if the class is configured in annotation or xml, false otherwise
[ "Returns", "true", "if", "the", "class", "is", "configured", "in", "annotation", "or", "xml", "false", "otherwise", "." ]
b48fd3527f35055b8b4a30f53a51136f183acc90
https://github.com/jmapper-framework/jmapper-core/blob/b48fd3527f35055b8b4a30f53a51136f183acc90/JMapper Framework/src/main/java/com/googlecode/jmapper/util/ClassesManager.java#L438-L440
144,208
jmapper-framework/jmapper-core
JMapper Framework/src/main/java/com/googlecode/jmapper/util/ClassesManager.java
ClassesManager.getAllsuperClasses
public static List<Class<?>> getAllsuperClasses(Class<?> aClass){ List<Class<?>> result = new ArrayList<Class<?>>(); result.add(aClass); Class<?> superclass = aClass.getSuperclass(); while(!isNull(superclass) && superclass != Object.class){ result.add(superclass); superclass = superclass.getSuperclass(); } return result; }
java
public static List<Class<?>> getAllsuperClasses(Class<?> aClass){ List<Class<?>> result = new ArrayList<Class<?>>(); result.add(aClass); Class<?> superclass = aClass.getSuperclass(); while(!isNull(superclass) && superclass != Object.class){ result.add(superclass); superclass = superclass.getSuperclass(); } return result; }
[ "public", "static", "List", "<", "Class", "<", "?", ">", ">", "getAllsuperClasses", "(", "Class", "<", "?", ">", "aClass", ")", "{", "List", "<", "Class", "<", "?", ">", ">", "result", "=", "new", "ArrayList", "<", "Class", "<", "?", ">", ">", "(", ")", ";", "result", ".", "add", "(", "aClass", ")", ";", "Class", "<", "?", ">", "superclass", "=", "aClass", ".", "getSuperclass", "(", ")", ";", "while", "(", "!", "isNull", "(", "superclass", ")", "&&", "superclass", "!=", "Object", ".", "class", ")", "{", "result", ".", "add", "(", "superclass", ")", ";", "superclass", "=", "superclass", ".", "getSuperclass", "(", ")", ";", "}", "return", "result", ";", "}" ]
Returns a list with the class passed in input plus his superclasses. @param aClass class to check @return a classes list
[ "Returns", "a", "list", "with", "the", "class", "passed", "in", "input", "plus", "his", "superclasses", "." ]
b48fd3527f35055b8b4a30f53a51136f183acc90
https://github.com/jmapper-framework/jmapper-core/blob/b48fd3527f35055b8b4a30f53a51136f183acc90/JMapper Framework/src/main/java/com/googlecode/jmapper/util/ClassesManager.java#L447-L456
144,209
jmapper-framework/jmapper-core
JMapper Framework/src/main/java/com/googlecode/jmapper/operations/analyzer/ArrayListAnalyzer.java
ArrayListAnalyzer.getInfoOperation
public InfoOperation getInfoOperation(final Field destination, final Field source) { Class<?> dClass = destination.getType(); Class<?> sClass = source.getType(); Class<?> dItem = null; Class<?> sItem = null; InfoOperation operation = new InfoOperation().setConversionType(UNDEFINED); // Array[] = Collection<> if(dClass.isArray() && collectionIsAssignableFrom(sClass)){ dItem = dClass.getComponentType(); sItem = getCollectionItemClass(source); operation.setInstructionType(ARRAY_LIST); if(areMappedObjects(dItem,sItem,xml)) return operation.setInstructionType(ARRAY_LIST_WITH_MAPPED_ITEMS) .setConfigChosen(configChosen(dItem,sItem,xml)); } // Collection<> = Array[] if(collectionIsAssignableFrom(dClass) && sClass.isArray()){ dItem = getCollectionItemClass(destination); sItem = sClass.getComponentType(); operation.setInstructionType(LIST_ARRAY); if(areMappedObjects(dItem,sItem,xml)) return operation.setInstructionType(LIST_ARRAY_WITH_MAPPED_ITEMS) .setConfigChosen(configChosen(dItem,sItem,xml)); } if(isAssignableFrom(dItem,sItem)) return operation.setConversionType(ABSENT); // if components are primitive or wrapper types, apply implicit conversion if(areBasic(dItem,sItem)) return operation.setConversionType(getConversionType(dItem, sItem)); return operation; }
java
public InfoOperation getInfoOperation(final Field destination, final Field source) { Class<?> dClass = destination.getType(); Class<?> sClass = source.getType(); Class<?> dItem = null; Class<?> sItem = null; InfoOperation operation = new InfoOperation().setConversionType(UNDEFINED); // Array[] = Collection<> if(dClass.isArray() && collectionIsAssignableFrom(sClass)){ dItem = dClass.getComponentType(); sItem = getCollectionItemClass(source); operation.setInstructionType(ARRAY_LIST); if(areMappedObjects(dItem,sItem,xml)) return operation.setInstructionType(ARRAY_LIST_WITH_MAPPED_ITEMS) .setConfigChosen(configChosen(dItem,sItem,xml)); } // Collection<> = Array[] if(collectionIsAssignableFrom(dClass) && sClass.isArray()){ dItem = getCollectionItemClass(destination); sItem = sClass.getComponentType(); operation.setInstructionType(LIST_ARRAY); if(areMappedObjects(dItem,sItem,xml)) return operation.setInstructionType(LIST_ARRAY_WITH_MAPPED_ITEMS) .setConfigChosen(configChosen(dItem,sItem,xml)); } if(isAssignableFrom(dItem,sItem)) return operation.setConversionType(ABSENT); // if components are primitive or wrapper types, apply implicit conversion if(areBasic(dItem,sItem)) return operation.setConversionType(getConversionType(dItem, sItem)); return operation; }
[ "public", "InfoOperation", "getInfoOperation", "(", "final", "Field", "destination", ",", "final", "Field", "source", ")", "{", "Class", "<", "?", ">", "dClass", "=", "destination", ".", "getType", "(", ")", ";", "Class", "<", "?", ">", "sClass", "=", "source", ".", "getType", "(", ")", ";", "Class", "<", "?", ">", "dItem", "=", "null", ";", "Class", "<", "?", ">", "sItem", "=", "null", ";", "InfoOperation", "operation", "=", "new", "InfoOperation", "(", ")", ".", "setConversionType", "(", "UNDEFINED", ")", ";", "// Array[] = Collection<>\r", "if", "(", "dClass", ".", "isArray", "(", ")", "&&", "collectionIsAssignableFrom", "(", "sClass", ")", ")", "{", "dItem", "=", "dClass", ".", "getComponentType", "(", ")", ";", "sItem", "=", "getCollectionItemClass", "(", "source", ")", ";", "operation", ".", "setInstructionType", "(", "ARRAY_LIST", ")", ";", "if", "(", "areMappedObjects", "(", "dItem", ",", "sItem", ",", "xml", ")", ")", "return", "operation", ".", "setInstructionType", "(", "ARRAY_LIST_WITH_MAPPED_ITEMS", ")", ".", "setConfigChosen", "(", "configChosen", "(", "dItem", ",", "sItem", ",", "xml", ")", ")", ";", "}", "// Collection<> = Array[]\r", "if", "(", "collectionIsAssignableFrom", "(", "dClass", ")", "&&", "sClass", ".", "isArray", "(", ")", ")", "{", "dItem", "=", "getCollectionItemClass", "(", "destination", ")", ";", "sItem", "=", "sClass", ".", "getComponentType", "(", ")", ";", "operation", ".", "setInstructionType", "(", "LIST_ARRAY", ")", ";", "if", "(", "areMappedObjects", "(", "dItem", ",", "sItem", ",", "xml", ")", ")", "return", "operation", ".", "setInstructionType", "(", "LIST_ARRAY_WITH_MAPPED_ITEMS", ")", ".", "setConfigChosen", "(", "configChosen", "(", "dItem", ",", "sItem", ",", "xml", ")", ")", ";", "}", "if", "(", "isAssignableFrom", "(", "dItem", ",", "sItem", ")", ")", "return", "operation", ".", "setConversionType", "(", "ABSENT", ")", ";", "// if components are primitive or wrapper types, apply implicit conversion\r", "if", "(", "areBasic", "(", "dItem", ",", "sItem", ")", ")", "return", "operation", ".", "setConversionType", "(", "getConversionType", "(", "dItem", ",", "sItem", ")", ")", ";", "return", "operation", ";", "}" ]
This method calculates and returns information relating the operation to be performed. @param destination destination field to be analyzed @param source source field to be analyzed @return all information relating the operation to be performed
[ "This", "method", "calculates", "and", "returns", "information", "relating", "the", "operation", "to", "be", "performed", "." ]
b48fd3527f35055b8b4a30f53a51136f183acc90
https://github.com/jmapper-framework/jmapper-core/blob/b48fd3527f35055b8b4a30f53a51136f183acc90/JMapper Framework/src/main/java/com/googlecode/jmapper/operations/analyzer/ArrayListAnalyzer.java#L62-L101
144,210
jmapper-framework/jmapper-core
JMapper Framework/src/main/java/com/googlecode/jmapper/operations/recursive/ObjectOperation.java
ObjectOperation.getMapper
private MapperConstructor getMapper(String dName){ return new MapperConstructor(destinationType(), sourceType(), dName, dName, getSName(), configChosen, xml,methodsToGenerate); }
java
private MapperConstructor getMapper(String dName){ return new MapperConstructor(destinationType(), sourceType(), dName, dName, getSName(), configChosen, xml,methodsToGenerate); }
[ "private", "MapperConstructor", "getMapper", "(", "String", "dName", ")", "{", "return", "new", "MapperConstructor", "(", "destinationType", "(", ")", ",", "sourceType", "(", ")", ",", "dName", ",", "dName", ",", "getSName", "(", ")", ",", "configChosen", ",", "xml", ",", "methodsToGenerate", ")", ";", "}" ]
Returns a new instance of MapperConstructor @param dName destination name @return the mapper
[ "Returns", "a", "new", "instance", "of", "MapperConstructor" ]
b48fd3527f35055b8b4a30f53a51136f183acc90
https://github.com/jmapper-framework/jmapper-core/blob/b48fd3527f35055b8b4a30f53a51136f183acc90/JMapper Framework/src/main/java/com/googlecode/jmapper/operations/recursive/ObjectOperation.java#L54-L56
144,211
jmapper-framework/jmapper-core
JMapper Framework/src/main/java/com/googlecode/jmapper/generation/MapperConstructor.java
MapperConstructor.getMappings
public Map<String,String> getMappings(){ HashMap<String, String> mappings = new HashMap<String, String> (); HashMap<String, Boolean> destInstance = new HashMap<String, Boolean>(); String s = "V"; destInstance.put("null", true ); destInstance.put("v" , false ); HashMap<String, NullPointerControl> nullPointer = new HashMap<String, NullPointerControl>(); nullPointer.put("Not", NOT_ANY ); nullPointer.put("All", ALL ); nullPointer.put("Des", DESTINATION ); nullPointer.put("Sou", SOURCE ); HashMap<String, MappingType> mapping = new HashMap<String, MappingType>(); mapping.put("All" , ALL_FIELDS ); mapping.put("Valued", ONLY_VALUED_FIELDS ); mapping.put("Null" , ONLY_NULL_FIELDS ); java.lang.reflect.Method[] methods = IMapper.class.getDeclaredMethods(); for (Entry<String, Boolean> d : destInstance.entrySet()) for (Entry<String, NullPointerControl> npc : nullPointer.entrySet()) for (Entry<String, MappingType> mtd : mapping.entrySet()) for (Entry<String, MappingType> mts : mapping.entrySet()) { String methodName = d.getKey()+s+npc.getKey()+mtd.getKey()+mts.getKey(); for (java.lang.reflect.Method method : methods) if(method.getName().equals(methodName)) mappings.put(methodName, wrappedMapping(d.getValue(),npc.getValue(),mtd.getValue(),mts.getValue()));} mappings.put("get", "return null;"+newLine); return mappings; }
java
public Map<String,String> getMappings(){ HashMap<String, String> mappings = new HashMap<String, String> (); HashMap<String, Boolean> destInstance = new HashMap<String, Boolean>(); String s = "V"; destInstance.put("null", true ); destInstance.put("v" , false ); HashMap<String, NullPointerControl> nullPointer = new HashMap<String, NullPointerControl>(); nullPointer.put("Not", NOT_ANY ); nullPointer.put("All", ALL ); nullPointer.put("Des", DESTINATION ); nullPointer.put("Sou", SOURCE ); HashMap<String, MappingType> mapping = new HashMap<String, MappingType>(); mapping.put("All" , ALL_FIELDS ); mapping.put("Valued", ONLY_VALUED_FIELDS ); mapping.put("Null" , ONLY_NULL_FIELDS ); java.lang.reflect.Method[] methods = IMapper.class.getDeclaredMethods(); for (Entry<String, Boolean> d : destInstance.entrySet()) for (Entry<String, NullPointerControl> npc : nullPointer.entrySet()) for (Entry<String, MappingType> mtd : mapping.entrySet()) for (Entry<String, MappingType> mts : mapping.entrySet()) { String methodName = d.getKey()+s+npc.getKey()+mtd.getKey()+mts.getKey(); for (java.lang.reflect.Method method : methods) if(method.getName().equals(methodName)) mappings.put(methodName, wrappedMapping(d.getValue(),npc.getValue(),mtd.getValue(),mts.getValue()));} mappings.put("get", "return null;"+newLine); return mappings; }
[ "public", "Map", "<", "String", ",", "String", ">", "getMappings", "(", ")", "{", "HashMap", "<", "String", ",", "String", ">", "mappings", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "HashMap", "<", "String", ",", "Boolean", ">", "destInstance", "=", "new", "HashMap", "<", "String", ",", "Boolean", ">", "(", ")", ";", "String", "s", "=", "\"V\"", ";", "destInstance", ".", "put", "(", "\"null\"", ",", "true", ")", ";", "destInstance", ".", "put", "(", "\"v\"", ",", "false", ")", ";", "HashMap", "<", "String", ",", "NullPointerControl", ">", "nullPointer", "=", "new", "HashMap", "<", "String", ",", "NullPointerControl", ">", "(", ")", ";", "nullPointer", ".", "put", "(", "\"Not\"", ",", "NOT_ANY", ")", ";", "nullPointer", ".", "put", "(", "\"All\"", ",", "ALL", ")", ";", "nullPointer", ".", "put", "(", "\"Des\"", ",", "DESTINATION", ")", ";", "nullPointer", ".", "put", "(", "\"Sou\"", ",", "SOURCE", ")", ";", "HashMap", "<", "String", ",", "MappingType", ">", "mapping", "=", "new", "HashMap", "<", "String", ",", "MappingType", ">", "(", ")", ";", "mapping", ".", "put", "(", "\"All\"", ",", "ALL_FIELDS", ")", ";", "mapping", ".", "put", "(", "\"Valued\"", ",", "ONLY_VALUED_FIELDS", ")", ";", "mapping", ".", "put", "(", "\"Null\"", ",", "ONLY_NULL_FIELDS", ")", ";", "java", ".", "lang", ".", "reflect", ".", "Method", "[", "]", "methods", "=", "IMapper", ".", "class", ".", "getDeclaredMethods", "(", ")", ";", "for", "(", "Entry", "<", "String", ",", "Boolean", ">", "d", ":", "destInstance", ".", "entrySet", "(", ")", ")", "for", "(", "Entry", "<", "String", ",", "NullPointerControl", ">", "npc", ":", "nullPointer", ".", "entrySet", "(", ")", ")", "for", "(", "Entry", "<", "String", ",", "MappingType", ">", "mtd", ":", "mapping", ".", "entrySet", "(", ")", ")", "for", "(", "Entry", "<", "String", ",", "MappingType", ">", "mts", ":", "mapping", ".", "entrySet", "(", ")", ")", "{", "String", "methodName", "=", "d", ".", "getKey", "(", ")", "+", "s", "+", "npc", ".", "getKey", "(", ")", "+", "mtd", ".", "getKey", "(", ")", "+", "mts", ".", "getKey", "(", ")", ";", "for", "(", "java", ".", "lang", ".", "reflect", ".", "Method", "method", ":", "methods", ")", "if", "(", "method", ".", "getName", "(", ")", ".", "equals", "(", "methodName", ")", ")", "mappings", ".", "put", "(", "methodName", ",", "wrappedMapping", "(", "d", ".", "getValue", "(", ")", ",", "npc", ".", "getValue", "(", ")", ",", "mtd", ".", "getValue", "(", ")", ",", "mts", ".", "getValue", "(", ")", ")", ")", ";", "}", "mappings", ".", "put", "(", "\"get\"", ",", "\"return null;\"", "+", "newLine", ")", ";", "return", "mappings", ";", "}" ]
Returns a Map where the keys are the mappings names and relative values are the mappings. @return a Map with all mapping combinations
[ "Returns", "a", "Map", "where", "the", "keys", "are", "the", "mappings", "names", "and", "relative", "values", "are", "the", "mappings", "." ]
b48fd3527f35055b8b4a30f53a51136f183acc90
https://github.com/jmapper-framework/jmapper-core/blob/b48fd3527f35055b8b4a30f53a51136f183acc90/JMapper Framework/src/main/java/com/googlecode/jmapper/generation/MapperConstructor.java#L58-L94
144,212
jmapper-framework/jmapper-core
JMapper Framework/src/main/java/com/googlecode/jmapper/generation/MapperConstructor.java
MapperConstructor.wrappedMapping
private String wrappedMapping(boolean makeDest,NullPointerControl npc,MappingType mtd,MappingType mts){ String sClass = source.getName(); String dClass = destination.getName(); String str = (makeDest?" "+sClass+" "+stringOfGetSource +" = ("+sClass+") $1;" :" "+dClass+" "+stringOfGetDestination+" = ("+dClass+") $1;"+newLine+ " "+sClass+" "+stringOfGetSource +" = ("+sClass+") $2;")+newLine; switch(npc){ case SOURCE: str +="if("+stringOfGetSource+"!=null){" +newLine; break; case DESTINATION: str +="if("+stringOfGetDestination+"!=null){"+newLine; break; case ALL: str +="if("+stringOfGetSource+"!=null && "+stringOfGetDestination+"!=null){"+newLine;break; default: break; } str += mapping(makeDest,mtd,mts) + newLine + " return "+stringOfSetDestination+";"+ newLine; return (npc != NOT_ANY) ? str += "}" + newLine + " return null;" + newLine : str; }
java
private String wrappedMapping(boolean makeDest,NullPointerControl npc,MappingType mtd,MappingType mts){ String sClass = source.getName(); String dClass = destination.getName(); String str = (makeDest?" "+sClass+" "+stringOfGetSource +" = ("+sClass+") $1;" :" "+dClass+" "+stringOfGetDestination+" = ("+dClass+") $1;"+newLine+ " "+sClass+" "+stringOfGetSource +" = ("+sClass+") $2;")+newLine; switch(npc){ case SOURCE: str +="if("+stringOfGetSource+"!=null){" +newLine; break; case DESTINATION: str +="if("+stringOfGetDestination+"!=null){"+newLine; break; case ALL: str +="if("+stringOfGetSource+"!=null && "+stringOfGetDestination+"!=null){"+newLine;break; default: break; } str += mapping(makeDest,mtd,mts) + newLine + " return "+stringOfSetDestination+";"+ newLine; return (npc != NOT_ANY) ? str += "}" + newLine + " return null;" + newLine : str; }
[ "private", "String", "wrappedMapping", "(", "boolean", "makeDest", ",", "NullPointerControl", "npc", ",", "MappingType", "mtd", ",", "MappingType", "mts", ")", "{", "String", "sClass", "=", "source", ".", "getName", "(", ")", ";", "String", "dClass", "=", "destination", ".", "getName", "(", ")", ";", "String", "str", "=", "(", "makeDest", "?", "\" \"", "+", "sClass", "+", "\" \"", "+", "stringOfGetSource", "+", "\" = (\"", "+", "sClass", "+", "\") $1;\"", ":", "\" \"", "+", "dClass", "+", "\" \"", "+", "stringOfGetDestination", "+", "\" = (\"", "+", "dClass", "+", "\") $1;\"", "+", "newLine", "+", "\" \"", "+", "sClass", "+", "\" \"", "+", "stringOfGetSource", "+", "\" = (\"", "+", "sClass", "+", "\") $2;\"", ")", "+", "newLine", ";", "switch", "(", "npc", ")", "{", "case", "SOURCE", ":", "str", "+=", "\"if(\"", "+", "stringOfGetSource", "+", "\"!=null){\"", "+", "newLine", ";", "break", ";", "case", "DESTINATION", ":", "str", "+=", "\"if(\"", "+", "stringOfGetDestination", "+", "\"!=null){\"", "+", "newLine", ";", "break", ";", "case", "ALL", ":", "str", "+=", "\"if(\"", "+", "stringOfGetSource", "+", "\"!=null && \"", "+", "stringOfGetDestination", "+", "\"!=null){\"", "+", "newLine", ";", "break", ";", "default", ":", "break", ";", "}", "str", "+=", "mapping", "(", "makeDest", ",", "mtd", ",", "mts", ")", "+", "newLine", "+", "\" return \"", "+", "stringOfSetDestination", "+", "\";\"", "+", "newLine", ";", "return", "(", "npc", "!=", "NOT_ANY", ")", "?", "str", "+=", "\"}\"", "+", "newLine", "+", "\" return null;\"", "+", "newLine", ":", "str", ";", "}" ]
This method adds the Null Pointer Control to mapping created by the mapping method. wrapMapping is used to wrap the mapping returned by mapping method. @param makeDest true if destination is a new instance, false otherwise @param npc a NullPointerControl chosen @param mtd Mapping Type of destination @param mts Mapping Type of source @return a String that contains the mapping @see MapperConstructor#write @see NullPointerControl @see MappingType
[ "This", "method", "adds", "the", "Null", "Pointer", "Control", "to", "mapping", "created", "by", "the", "mapping", "method", ".", "wrapMapping", "is", "used", "to", "wrap", "the", "mapping", "returned", "by", "mapping", "method", "." ]
b48fd3527f35055b8b4a30f53a51136f183acc90
https://github.com/jmapper-framework/jmapper-core/blob/b48fd3527f35055b8b4a30f53a51136f183acc90/JMapper Framework/src/main/java/com/googlecode/jmapper/generation/MapperConstructor.java#L109-L130
144,213
jmapper-framework/jmapper-core
JMapper Framework/src/main/java/com/googlecode/jmapper/generation/MapperConstructor.java
MapperConstructor.mapping
public StringBuilder mapping(boolean makeDest,MappingType mtd,MappingType mts){ StringBuilder sb = new StringBuilder(); if(isNullSetting(makeDest, mtd, mts, sb)) return sb; if(makeDest) sb.append(newInstance(destination, stringOfSetDestination)); for (ASimpleOperation simpleOperation : simpleOperations) sb.append(setOperation(simpleOperation,mtd,mts).write()); for (AComplexOperation complexOperation : complexOperations) sb.append(setOperation(complexOperation,mtd,mts).write(makeDest)); return sb; }
java
public StringBuilder mapping(boolean makeDest,MappingType mtd,MappingType mts){ StringBuilder sb = new StringBuilder(); if(isNullSetting(makeDest, mtd, mts, sb)) return sb; if(makeDest) sb.append(newInstance(destination, stringOfSetDestination)); for (ASimpleOperation simpleOperation : simpleOperations) sb.append(setOperation(simpleOperation,mtd,mts).write()); for (AComplexOperation complexOperation : complexOperations) sb.append(setOperation(complexOperation,mtd,mts).write(makeDest)); return sb; }
[ "public", "StringBuilder", "mapping", "(", "boolean", "makeDest", ",", "MappingType", "mtd", ",", "MappingType", "mts", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "if", "(", "isNullSetting", "(", "makeDest", ",", "mtd", ",", "mts", ",", "sb", ")", ")", "return", "sb", ";", "if", "(", "makeDest", ")", "sb", ".", "append", "(", "newInstance", "(", "destination", ",", "stringOfSetDestination", ")", ")", ";", "for", "(", "ASimpleOperation", "simpleOperation", ":", "simpleOperations", ")", "sb", ".", "append", "(", "setOperation", "(", "simpleOperation", ",", "mtd", ",", "mts", ")", ".", "write", "(", ")", ")", ";", "for", "(", "AComplexOperation", "complexOperation", ":", "complexOperations", ")", "sb", ".", "append", "(", "setOperation", "(", "complexOperation", ",", "mtd", ",", "mts", ")", ".", "write", "(", "makeDest", ")", ")", ";", "return", "sb", ";", "}" ]
This method writes the mapping based on the value of the three MappingType taken in input. @param makeDest true if destination is a new instance, false otherwise @param mtd mapping type of destination @param mts mapping type of source @return a String that contains the mapping
[ "This", "method", "writes", "the", "mapping", "based", "on", "the", "value", "of", "the", "three", "MappingType", "taken", "in", "input", "." ]
b48fd3527f35055b8b4a30f53a51136f183acc90
https://github.com/jmapper-framework/jmapper-core/blob/b48fd3527f35055b8b4a30f53a51136f183acc90/JMapper Framework/src/main/java/com/googlecode/jmapper/generation/MapperConstructor.java#L163-L179
144,214
jmapper-framework/jmapper-core
JMapper Framework/src/main/java/com/googlecode/jmapper/generation/MapperConstructor.java
MapperConstructor.setOperation
private <T extends AGeneralOperation>T setOperation(T operation,MappingType mtd,MappingType mts){ operation.setMtd(mtd).setMts(mts) .initialDSetPath(stringOfSetDestination) .initialDGetPath(stringOfGetDestination) .initialSGetPath(stringOfGetSource); return operation; }
java
private <T extends AGeneralOperation>T setOperation(T operation,MappingType mtd,MappingType mts){ operation.setMtd(mtd).setMts(mts) .initialDSetPath(stringOfSetDestination) .initialDGetPath(stringOfGetDestination) .initialSGetPath(stringOfGetSource); return operation; }
[ "private", "<", "T", "extends", "AGeneralOperation", ">", "T", "setOperation", "(", "T", "operation", ",", "MappingType", "mtd", ",", "MappingType", "mts", ")", "{", "operation", ".", "setMtd", "(", "mtd", ")", ".", "setMts", "(", "mts", ")", ".", "initialDSetPath", "(", "stringOfSetDestination", ")", ".", "initialDGetPath", "(", "stringOfGetDestination", ")", ".", "initialSGetPath", "(", "stringOfGetSource", ")", ";", "return", "operation", ";", "}" ]
Setting common to all operations. @param operation operation to configure @param mtd mapping type of destination @param mts mapping type of source @return operation configured
[ "Setting", "common", "to", "all", "operations", "." ]
b48fd3527f35055b8b4a30f53a51136f183acc90
https://github.com/jmapper-framework/jmapper-core/blob/b48fd3527f35055b8b4a30f53a51136f183acc90/JMapper Framework/src/main/java/com/googlecode/jmapper/generation/MapperConstructor.java#L189-L196
144,215
jmapper-framework/jmapper-core
JMapper Framework/src/main/java/com/googlecode/jmapper/generation/MapperConstructor.java
MapperConstructor.isNullSetting
private boolean isNullSetting(boolean makeDest,MappingType mtd,MappingType mts,StringBuilder result){ if( makeDest && (mtd == ALL_FIELDS||mtd == ONLY_VALUED_FIELDS) && mts == ONLY_NULL_FIELDS){ result.append(" "+stringOfSetDestination+"(null);"+newLine); return true; } return false; }
java
private boolean isNullSetting(boolean makeDest,MappingType mtd,MappingType mts,StringBuilder result){ if( makeDest && (mtd == ALL_FIELDS||mtd == ONLY_VALUED_FIELDS) && mts == ONLY_NULL_FIELDS){ result.append(" "+stringOfSetDestination+"(null);"+newLine); return true; } return false; }
[ "private", "boolean", "isNullSetting", "(", "boolean", "makeDest", ",", "MappingType", "mtd", ",", "MappingType", "mts", ",", "StringBuilder", "result", ")", "{", "if", "(", "makeDest", "&&", "(", "mtd", "==", "ALL_FIELDS", "||", "mtd", "==", "ONLY_VALUED_FIELDS", ")", "&&", "mts", "==", "ONLY_NULL_FIELDS", ")", "{", "result", ".", "append", "(", "\" \"", "+", "stringOfSetDestination", "+", "\"(null);\"", "+", "newLine", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
if it is a null setting returns the null mapping @param makeDest true if destination is a new instance @param mtd mapping type of destination @param mts mapping type of source @param result StringBuilder used for mapping @return true if operation is a null setting, false otherwise
[ "if", "it", "is", "a", "null", "setting", "returns", "the", "null", "mapping" ]
b48fd3527f35055b8b4a30f53a51136f183acc90
https://github.com/jmapper-framework/jmapper-core/blob/b48fd3527f35055b8b4a30f53a51136f183acc90/JMapper Framework/src/main/java/com/googlecode/jmapper/generation/MapperConstructor.java#L206-L214
144,216
jmapper-framework/jmapper-core
JMapper Framework/src/main/java/com/googlecode/jmapper/operations/complex/AComplexOperation.java
AComplexOperation.genericFlow
private final StringBuilder genericFlow(boolean newInstance){ // if newInstance is true or mapping type of newField is ONLY_NULL_FIELDS // write the mapping for the new field if(newInstance || getMtd() == ONLY_NULL_FIELDS) return sourceControl(fieldToCreate()); // if is enrichment case and mapping type of destination is ALL_FIELDS if(getMtd() == ALL_FIELDS && !destinationType().isPrimitive()) return write( " if(",getDestination(),"!=null){",newLine ,sourceControl(existingField()), " }else{" ,newLine ,sourceControl(fieldToCreate()), " }" ,newLine); // other cases return sourceControl(existingField()); }
java
private final StringBuilder genericFlow(boolean newInstance){ // if newInstance is true or mapping type of newField is ONLY_NULL_FIELDS // write the mapping for the new field if(newInstance || getMtd() == ONLY_NULL_FIELDS) return sourceControl(fieldToCreate()); // if is enrichment case and mapping type of destination is ALL_FIELDS if(getMtd() == ALL_FIELDS && !destinationType().isPrimitive()) return write( " if(",getDestination(),"!=null){",newLine ,sourceControl(existingField()), " }else{" ,newLine ,sourceControl(fieldToCreate()), " }" ,newLine); // other cases return sourceControl(existingField()); }
[ "private", "final", "StringBuilder", "genericFlow", "(", "boolean", "newInstance", ")", "{", "// if newInstance is true or mapping type of newField is ONLY_NULL_FIELDS\r", "// write the mapping for the new field\r", "if", "(", "newInstance", "||", "getMtd", "(", ")", "==", "ONLY_NULL_FIELDS", ")", "return", "sourceControl", "(", "fieldToCreate", "(", ")", ")", ";", "// if is enrichment case and mapping type of destination is ALL_FIELDS\r", "if", "(", "getMtd", "(", ")", "==", "ALL_FIELDS", "&&", "!", "destinationType", "(", ")", ".", "isPrimitive", "(", ")", ")", "return", "write", "(", "\" if(\"", ",", "getDestination", "(", ")", ",", "\"!=null){\"", ",", "newLine", ",", "sourceControl", "(", "existingField", "(", ")", ")", ",", "\" }else{\"", ",", "newLine", ",", "sourceControl", "(", "fieldToCreate", "(", ")", ")", ",", "\" }\"", ",", "newLine", ")", ";", "// other cases\r", "return", "sourceControl", "(", "existingField", "(", ")", ")", ";", "}" ]
This method specifies the general flow of the complex mapping. @param newInstance true if you need to create a new instance, false otherwise @return a StringBuilder containing the mapping
[ "This", "method", "specifies", "the", "general", "flow", "of", "the", "complex", "mapping", "." ]
b48fd3527f35055b8b4a30f53a51136f183acc90
https://github.com/jmapper-framework/jmapper-core/blob/b48fd3527f35055b8b4a30f53a51136f183acc90/JMapper Framework/src/main/java/com/googlecode/jmapper/operations/complex/AComplexOperation.java#L117-L134
144,217
jmapper-framework/jmapper-core
JMapper Framework/src/main/java/com/googlecode/jmapper/operations/complex/AComplexOperation.java
AComplexOperation.sourceControl
private StringBuilder sourceControl(StringBuilder mapping){ if(getMts() == ALL_FIELDS && !sourceType().isPrimitive()){ StringBuilder write = write(" if(",getSource(),"!=null){",newLine, sharedCode(mapping) ,newLine, " }"); if(!destinationType().isPrimitive() && !avoidSet) write.append(write("else{" ,newLine, setDestination("null") ,newLine, " }" ,newLine)); else write.append(newLine); return write; } else return write(sharedCode(mapping),newLine); }
java
private StringBuilder sourceControl(StringBuilder mapping){ if(getMts() == ALL_FIELDS && !sourceType().isPrimitive()){ StringBuilder write = write(" if(",getSource(),"!=null){",newLine, sharedCode(mapping) ,newLine, " }"); if(!destinationType().isPrimitive() && !avoidSet) write.append(write("else{" ,newLine, setDestination("null") ,newLine, " }" ,newLine)); else write.append(newLine); return write; } else return write(sharedCode(mapping),newLine); }
[ "private", "StringBuilder", "sourceControl", "(", "StringBuilder", "mapping", ")", "{", "if", "(", "getMts", "(", ")", "==", "ALL_FIELDS", "&&", "!", "sourceType", "(", ")", ".", "isPrimitive", "(", ")", ")", "{", "StringBuilder", "write", "=", "write", "(", "\" if(\"", ",", "getSource", "(", ")", ",", "\"!=null){\"", ",", "newLine", ",", "sharedCode", "(", "mapping", ")", ",", "newLine", ",", "\" }\"", ")", ";", "if", "(", "!", "destinationType", "(", ")", ".", "isPrimitive", "(", ")", "&&", "!", "avoidSet", ")", "write", ".", "append", "(", "write", "(", "\"else{\"", ",", "newLine", ",", "setDestination", "(", "\"null\"", ")", ",", "newLine", ",", "\" }\"", ",", "newLine", ")", ")", ";", "else", "write", ".", "append", "(", "newLine", ")", ";", "return", "write", ";", "}", "else", "return", "write", "(", "sharedCode", "(", "mapping", ")", ",", "newLine", ")", ";", "}" ]
This method is used when the MappingType of Source is setting to ALL. @param mapping @return a StringBuilder that contains the mapping enriched with source controls
[ "This", "method", "is", "used", "when", "the", "MappingType", "of", "Source", "is", "setting", "to", "ALL", "." ]
b48fd3527f35055b8b4a30f53a51136f183acc90
https://github.com/jmapper-framework/jmapper-core/blob/b48fd3527f35055b8b4a30f53a51136f183acc90/JMapper Framework/src/main/java/com/googlecode/jmapper/operations/complex/AComplexOperation.java#L141-L157
144,218
osglworks/java-mvc
src/main/java/org/osgl/mvc/result/Redirect.java
Redirect.moved
@Deprecated public static Redirect moved(String url, Object... args) { touchPayload().message(url, args); return _INSTANCE; }
java
@Deprecated public static Redirect moved(String url, Object... args) { touchPayload().message(url, args); return _INSTANCE; }
[ "@", "Deprecated", "public", "static", "Redirect", "moved", "(", "String", "url", ",", "Object", "...", "args", ")", "{", "touchPayload", "(", ")", ".", "message", "(", "url", ",", "args", ")", ";", "return", "_INSTANCE", ";", "}" ]
This method is deprecated
[ "This", "method", "is", "deprecated" ]
4d2b2ec40498ac6ee7040c0424377cbeacab124b
https://github.com/osglworks/java-mvc/blob/4d2b2ec40498ac6ee7040c0424377cbeacab124b/src/main/java/org/osgl/mvc/result/Redirect.java#L125-L129
144,219
osglworks/java-mvc
src/main/java/org/osgl/mvc/util/Binder.java
Binder.attribute
public Binder<T> attribute(String key, Object value) { if (null == value) { attributes.remove(value); } else { attributes.put(key, value); } return this; }
java
public Binder<T> attribute(String key, Object value) { if (null == value) { attributes.remove(value); } else { attributes.put(key, value); } return this; }
[ "public", "Binder", "<", "T", ">", "attribute", "(", "String", "key", ",", "Object", "value", ")", "{", "if", "(", "null", "==", "value", ")", "{", "attributes", ".", "remove", "(", "value", ")", ";", "}", "else", "{", "attributes", ".", "put", "(", "key", ",", "value", ")", ";", "}", "return", "this", ";", "}" ]
Set attribute of this binder. Note use this method only on new resolver instance instead of shared instance @param key the attribute key @param value the attribute value @return this binder instance
[ "Set", "attribute", "of", "this", "binder", "." ]
4d2b2ec40498ac6ee7040c0424377cbeacab124b
https://github.com/osglworks/java-mvc/blob/4d2b2ec40498ac6ee7040c0424377cbeacab124b/src/main/java/org/osgl/mvc/util/Binder.java#L78-L85
144,220
osglworks/java-mvc
src/main/java/org/osgl/mvc/util/Binder.java
Binder.attributes
public Binder<T> attributes(Map<String, Object> attributes) { this.attributes.putAll(attributes); return this; }
java
public Binder<T> attributes(Map<String, Object> attributes) { this.attributes.putAll(attributes); return this; }
[ "public", "Binder", "<", "T", ">", "attributes", "(", "Map", "<", "String", ",", "Object", ">", "attributes", ")", "{", "this", ".", "attributes", ".", "putAll", "(", "attributes", ")", ";", "return", "this", ";", "}" ]
Set attributes to this binder Note use this method only on new resolver instance instead of shared instance @param attributes the attributes map @return this binder instance
[ "Set", "attributes", "to", "this", "binder" ]
4d2b2ec40498ac6ee7040c0424377cbeacab124b
https://github.com/osglworks/java-mvc/blob/4d2b2ec40498ac6ee7040c0424377cbeacab124b/src/main/java/org/osgl/mvc/util/Binder.java#L95-L98
144,221
Indoqa/indoqa-boot
src/main/java/com/indoqa/boot/spark/PortUtils.java
PortUtils.isPortAvailable
static boolean isPortAvailable(int port) { ServerSocket ss = null; try { ss = new ServerSocket(port); ss.setReuseAddress(true); return true; } catch (IOException ioe) { // NOSONAR return false; } finally { closeQuietly(ss); } }
java
static boolean isPortAvailable(int port) { ServerSocket ss = null; try { ss = new ServerSocket(port); ss.setReuseAddress(true); return true; } catch (IOException ioe) { // NOSONAR return false; } finally { closeQuietly(ss); } }
[ "static", "boolean", "isPortAvailable", "(", "int", "port", ")", "{", "ServerSocket", "ss", "=", "null", ";", "try", "{", "ss", "=", "new", "ServerSocket", "(", "port", ")", ";", "ss", ".", "setReuseAddress", "(", "true", ")", ";", "return", "true", ";", "}", "catch", "(", "IOException", "ioe", ")", "{", "// NOSONAR", "return", "false", ";", "}", "finally", "{", "closeQuietly", "(", "ss", ")", ";", "}", "}" ]
Find out if the provided port is available. @param port The port to be inspected. @return true if the port is avaiable.
[ "Find", "out", "if", "the", "provided", "port", "is", "available", "." ]
a4c6a6517308f5fc6f1eb4e4f5b9994122c268e6
https://github.com/Indoqa/indoqa-boot/blob/a4c6a6517308f5fc6f1eb4e4f5b9994122c268e6/src/main/java/com/indoqa/boot/spark/PortUtils.java#L42-L53
144,222
osglworks/java-mvc
src/main/java/org/osgl/mvc/result/RenderBinary.java
RenderBinary.name
public RenderBinary name(String attachmentName) { this.name = attachmentName; this.disposition = Disposition.of(S.notBlank(attachmentName)); return this; }
java
public RenderBinary name(String attachmentName) { this.name = attachmentName; this.disposition = Disposition.of(S.notBlank(attachmentName)); return this; }
[ "public", "RenderBinary", "name", "(", "String", "attachmentName", ")", "{", "this", ".", "name", "=", "attachmentName", ";", "this", ".", "disposition", "=", "Disposition", ".", "of", "(", "S", ".", "notBlank", "(", "attachmentName", ")", ")", ";", "return", "this", ";", "}" ]
Set the attachment name. If the attachment name is not `null` and not empty, then it will set the disposition to attachment; otherwise it will set the disposition to inline @param attachmentName the attachment name @return this RenderBinary instance
[ "Set", "the", "attachment", "name", "." ]
4d2b2ec40498ac6ee7040c0424377cbeacab124b
https://github.com/osglworks/java-mvc/blob/4d2b2ec40498ac6ee7040c0424377cbeacab124b/src/main/java/org/osgl/mvc/result/RenderBinary.java#L211-L215
144,223
Indoqa/indoqa-boot
src/main/java/com/indoqa/boot/actuate/metrics/SystemPublicMetrics.java
SystemPublicMetrics.addNonHeapMetrics
private static void addNonHeapMetrics(Collection<Metric<?>> result) { MemoryUsage memoryUsage = ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage(); result.add(newMemoryMetric("nonheap.committed", memoryUsage.getCommitted())); result.add(newMemoryMetric("nonheap.init", memoryUsage.getInit())); result.add(newMemoryMetric("nonheap.used", memoryUsage.getUsed())); result.add(newMemoryMetric("nonheap", memoryUsage.getMax())); }
java
private static void addNonHeapMetrics(Collection<Metric<?>> result) { MemoryUsage memoryUsage = ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage(); result.add(newMemoryMetric("nonheap.committed", memoryUsage.getCommitted())); result.add(newMemoryMetric("nonheap.init", memoryUsage.getInit())); result.add(newMemoryMetric("nonheap.used", memoryUsage.getUsed())); result.add(newMemoryMetric("nonheap", memoryUsage.getMax())); }
[ "private", "static", "void", "addNonHeapMetrics", "(", "Collection", "<", "Metric", "<", "?", ">", ">", "result", ")", "{", "MemoryUsage", "memoryUsage", "=", "ManagementFactory", ".", "getMemoryMXBean", "(", ")", ".", "getNonHeapMemoryUsage", "(", ")", ";", "result", ".", "add", "(", "newMemoryMetric", "(", "\"nonheap.committed\"", ",", "memoryUsage", ".", "getCommitted", "(", ")", ")", ")", ";", "result", ".", "add", "(", "newMemoryMetric", "(", "\"nonheap.init\"", ",", "memoryUsage", ".", "getInit", "(", ")", ")", ")", ";", "result", ".", "add", "(", "newMemoryMetric", "(", "\"nonheap.used\"", ",", "memoryUsage", ".", "getUsed", "(", ")", ")", ")", ";", "result", ".", "add", "(", "newMemoryMetric", "(", "\"nonheap\"", ",", "memoryUsage", ".", "getMax", "(", ")", ")", ")", ";", "}" ]
Add JVM non-heap metrics. @param result the result
[ "Add", "JVM", "non", "-", "heap", "metrics", "." ]
a4c6a6517308f5fc6f1eb4e4f5b9994122c268e6
https://github.com/Indoqa/indoqa-boot/blob/a4c6a6517308f5fc6f1eb4e4f5b9994122c268e6/src/main/java/com/indoqa/boot/actuate/metrics/SystemPublicMetrics.java#L46-L52
144,224
Indoqa/indoqa-boot
src/main/java/com/indoqa/boot/actuate/metrics/SystemPublicMetrics.java
SystemPublicMetrics.addBasicMetrics
protected void addBasicMetrics(Collection<Metric<?>> result) { // NOTE: ManagementFactory must not be used here since it fails on GAE Runtime runtime = Runtime.getRuntime(); result.add(newMemoryMetric("mem", runtime.totalMemory() + getTotalNonHeapMemoryIfPossible())); result.add(newMemoryMetric("mem.free", runtime.freeMemory())); result.add(new Metric<>("processors", runtime.availableProcessors())); result.add(new Metric<>("instance.uptime", System.currentTimeMillis() - this.timestamp)); }
java
protected void addBasicMetrics(Collection<Metric<?>> result) { // NOTE: ManagementFactory must not be used here since it fails on GAE Runtime runtime = Runtime.getRuntime(); result.add(newMemoryMetric("mem", runtime.totalMemory() + getTotalNonHeapMemoryIfPossible())); result.add(newMemoryMetric("mem.free", runtime.freeMemory())); result.add(new Metric<>("processors", runtime.availableProcessors())); result.add(new Metric<>("instance.uptime", System.currentTimeMillis() - this.timestamp)); }
[ "protected", "void", "addBasicMetrics", "(", "Collection", "<", "Metric", "<", "?", ">", ">", "result", ")", "{", "// NOTE: ManagementFactory must not be used here since it fails on GAE", "Runtime", "runtime", "=", "Runtime", ".", "getRuntime", "(", ")", ";", "result", ".", "add", "(", "newMemoryMetric", "(", "\"mem\"", ",", "runtime", ".", "totalMemory", "(", ")", "+", "getTotalNonHeapMemoryIfPossible", "(", ")", ")", ")", ";", "result", ".", "add", "(", "newMemoryMetric", "(", "\"mem.free\"", ",", "runtime", ".", "freeMemory", "(", ")", ")", ")", ";", "result", ".", "add", "(", "new", "Metric", "<>", "(", "\"processors\"", ",", "runtime", ".", "availableProcessors", "(", ")", ")", ")", ";", "result", ".", "add", "(", "new", "Metric", "<>", "(", "\"instance.uptime\"", ",", "System", ".", "currentTimeMillis", "(", ")", "-", "this", ".", "timestamp", ")", ")", ";", "}" ]
Add basic system metrics. @param result the result
[ "Add", "basic", "system", "metrics", "." ]
a4c6a6517308f5fc6f1eb4e4f5b9994122c268e6
https://github.com/Indoqa/indoqa-boot/blob/a4c6a6517308f5fc6f1eb4e4f5b9994122c268e6/src/main/java/com/indoqa/boot/actuate/metrics/SystemPublicMetrics.java#L89-L96
144,225
Indoqa/indoqa-boot
src/main/java/com/indoqa/boot/actuate/metrics/SystemPublicMetrics.java
SystemPublicMetrics.addClassLoadingMetrics
protected void addClassLoadingMetrics(Collection<Metric<?>> result) { ClassLoadingMXBean classLoadingMxBean = ManagementFactory.getClassLoadingMXBean(); result.add(new Metric<>("classes", (long) classLoadingMxBean.getLoadedClassCount())); result.add(new Metric<>("classes.loaded", classLoadingMxBean.getTotalLoadedClassCount())); result.add(new Metric<>("classes.unloaded", classLoadingMxBean.getUnloadedClassCount())); }
java
protected void addClassLoadingMetrics(Collection<Metric<?>> result) { ClassLoadingMXBean classLoadingMxBean = ManagementFactory.getClassLoadingMXBean(); result.add(new Metric<>("classes", (long) classLoadingMxBean.getLoadedClassCount())); result.add(new Metric<>("classes.loaded", classLoadingMxBean.getTotalLoadedClassCount())); result.add(new Metric<>("classes.unloaded", classLoadingMxBean.getUnloadedClassCount())); }
[ "protected", "void", "addClassLoadingMetrics", "(", "Collection", "<", "Metric", "<", "?", ">", ">", "result", ")", "{", "ClassLoadingMXBean", "classLoadingMxBean", "=", "ManagementFactory", ".", "getClassLoadingMXBean", "(", ")", ";", "result", ".", "add", "(", "new", "Metric", "<>", "(", "\"classes\"", ",", "(", "long", ")", "classLoadingMxBean", ".", "getLoadedClassCount", "(", ")", ")", ")", ";", "result", ".", "add", "(", "new", "Metric", "<>", "(", "\"classes.loaded\"", ",", "classLoadingMxBean", ".", "getTotalLoadedClassCount", "(", ")", ")", ")", ";", "result", ".", "add", "(", "new", "Metric", "<>", "(", "\"classes.unloaded\"", ",", "classLoadingMxBean", ".", "getUnloadedClassCount", "(", ")", ")", ")", ";", "}" ]
Add class loading metrics. @param result the result
[ "Add", "class", "loading", "metrics", "." ]
a4c6a6517308f5fc6f1eb4e4f5b9994122c268e6
https://github.com/Indoqa/indoqa-boot/blob/a4c6a6517308f5fc6f1eb4e4f5b9994122c268e6/src/main/java/com/indoqa/boot/actuate/metrics/SystemPublicMetrics.java#L103-L108
144,226
Indoqa/indoqa-boot
src/main/java/com/indoqa/boot/actuate/metrics/SystemPublicMetrics.java
SystemPublicMetrics.addGarbageCollectionMetrics
protected void addGarbageCollectionMetrics(Collection<Metric<?>> result) { List<GarbageCollectorMXBean> garbageCollectorMxBeans = ManagementFactory.getGarbageCollectorMXBeans(); for (GarbageCollectorMXBean garbageCollectorMXBean : garbageCollectorMxBeans) { String name = beautifyGcName(garbageCollectorMXBean.getName()); result.add(new Metric<>("gc." + name + ".count", garbageCollectorMXBean.getCollectionCount())); result.add(new Metric<>("gc." + name + ".time", garbageCollectorMXBean.getCollectionTime())); } }
java
protected void addGarbageCollectionMetrics(Collection<Metric<?>> result) { List<GarbageCollectorMXBean> garbageCollectorMxBeans = ManagementFactory.getGarbageCollectorMXBeans(); for (GarbageCollectorMXBean garbageCollectorMXBean : garbageCollectorMxBeans) { String name = beautifyGcName(garbageCollectorMXBean.getName()); result.add(new Metric<>("gc." + name + ".count", garbageCollectorMXBean.getCollectionCount())); result.add(new Metric<>("gc." + name + ".time", garbageCollectorMXBean.getCollectionTime())); } }
[ "protected", "void", "addGarbageCollectionMetrics", "(", "Collection", "<", "Metric", "<", "?", ">", ">", "result", ")", "{", "List", "<", "GarbageCollectorMXBean", ">", "garbageCollectorMxBeans", "=", "ManagementFactory", ".", "getGarbageCollectorMXBeans", "(", ")", ";", "for", "(", "GarbageCollectorMXBean", "garbageCollectorMXBean", ":", "garbageCollectorMxBeans", ")", "{", "String", "name", "=", "beautifyGcName", "(", "garbageCollectorMXBean", ".", "getName", "(", ")", ")", ";", "result", ".", "add", "(", "new", "Metric", "<>", "(", "\"gc.\"", "+", "name", "+", "\".count\"", ",", "garbageCollectorMXBean", ".", "getCollectionCount", "(", ")", ")", ")", ";", "result", ".", "add", "(", "new", "Metric", "<>", "(", "\"gc.\"", "+", "name", "+", "\".time\"", ",", "garbageCollectorMXBean", ".", "getCollectionTime", "(", ")", ")", ")", ";", "}", "}" ]
Add garbage collection metrics. @param result the result
[ "Add", "garbage", "collection", "metrics", "." ]
a4c6a6517308f5fc6f1eb4e4f5b9994122c268e6
https://github.com/Indoqa/indoqa-boot/blob/a4c6a6517308f5fc6f1eb4e4f5b9994122c268e6/src/main/java/com/indoqa/boot/actuate/metrics/SystemPublicMetrics.java#L115-L122
144,227
Indoqa/indoqa-boot
src/main/java/com/indoqa/boot/actuate/metrics/SystemPublicMetrics.java
SystemPublicMetrics.addHeapMetrics
protected void addHeapMetrics(Collection<Metric<?>> result) { MemoryUsage memoryUsage = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage(); result.add(newMemoryMetric("heap.committed", memoryUsage.getCommitted())); result.add(newMemoryMetric("heap.init", memoryUsage.getInit())); result.add(newMemoryMetric("heap.used", memoryUsage.getUsed())); result.add(newMemoryMetric("heap", memoryUsage.getMax())); }
java
protected void addHeapMetrics(Collection<Metric<?>> result) { MemoryUsage memoryUsage = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage(); result.add(newMemoryMetric("heap.committed", memoryUsage.getCommitted())); result.add(newMemoryMetric("heap.init", memoryUsage.getInit())); result.add(newMemoryMetric("heap.used", memoryUsage.getUsed())); result.add(newMemoryMetric("heap", memoryUsage.getMax())); }
[ "protected", "void", "addHeapMetrics", "(", "Collection", "<", "Metric", "<", "?", ">", ">", "result", ")", "{", "MemoryUsage", "memoryUsage", "=", "ManagementFactory", ".", "getMemoryMXBean", "(", ")", ".", "getHeapMemoryUsage", "(", ")", ";", "result", ".", "add", "(", "newMemoryMetric", "(", "\"heap.committed\"", ",", "memoryUsage", ".", "getCommitted", "(", ")", ")", ")", ";", "result", ".", "add", "(", "newMemoryMetric", "(", "\"heap.init\"", ",", "memoryUsage", ".", "getInit", "(", ")", ")", ")", ";", "result", ".", "add", "(", "newMemoryMetric", "(", "\"heap.used\"", ",", "memoryUsage", ".", "getUsed", "(", ")", ")", ")", ";", "result", ".", "add", "(", "newMemoryMetric", "(", "\"heap\"", ",", "memoryUsage", ".", "getMax", "(", ")", ")", ")", ";", "}" ]
Add JVM heap metrics. @param result the result
[ "Add", "JVM", "heap", "metrics", "." ]
a4c6a6517308f5fc6f1eb4e4f5b9994122c268e6
https://github.com/Indoqa/indoqa-boot/blob/a4c6a6517308f5fc6f1eb4e4f5b9994122c268e6/src/main/java/com/indoqa/boot/actuate/metrics/SystemPublicMetrics.java#L129-L135
144,228
Indoqa/indoqa-boot
src/main/java/com/indoqa/boot/actuate/metrics/SystemPublicMetrics.java
SystemPublicMetrics.addThreadMetrics
protected void addThreadMetrics(Collection<Metric<?>> result) { ThreadMXBean threadMxBean = ManagementFactory.getThreadMXBean(); result.add(new Metric<>("threads.peak", (long) threadMxBean.getPeakThreadCount())); result.add(new Metric<>("threads.daemon", (long) threadMxBean.getDaemonThreadCount())); result.add(new Metric<>("threads.totalStarted", threadMxBean.getTotalStartedThreadCount())); result.add(new Metric<>("threads", (long) threadMxBean.getThreadCount())); }
java
protected void addThreadMetrics(Collection<Metric<?>> result) { ThreadMXBean threadMxBean = ManagementFactory.getThreadMXBean(); result.add(new Metric<>("threads.peak", (long) threadMxBean.getPeakThreadCount())); result.add(new Metric<>("threads.daemon", (long) threadMxBean.getDaemonThreadCount())); result.add(new Metric<>("threads.totalStarted", threadMxBean.getTotalStartedThreadCount())); result.add(new Metric<>("threads", (long) threadMxBean.getThreadCount())); }
[ "protected", "void", "addThreadMetrics", "(", "Collection", "<", "Metric", "<", "?", ">", ">", "result", ")", "{", "ThreadMXBean", "threadMxBean", "=", "ManagementFactory", ".", "getThreadMXBean", "(", ")", ";", "result", ".", "add", "(", "new", "Metric", "<>", "(", "\"threads.peak\"", ",", "(", "long", ")", "threadMxBean", ".", "getPeakThreadCount", "(", ")", ")", ")", ";", "result", ".", "add", "(", "new", "Metric", "<>", "(", "\"threads.daemon\"", ",", "(", "long", ")", "threadMxBean", ".", "getDaemonThreadCount", "(", ")", ")", ")", ";", "result", ".", "add", "(", "new", "Metric", "<>", "(", "\"threads.totalStarted\"", ",", "threadMxBean", ".", "getTotalStartedThreadCount", "(", ")", ")", ")", ";", "result", ".", "add", "(", "new", "Metric", "<>", "(", "\"threads\"", ",", "(", "long", ")", "threadMxBean", ".", "getThreadCount", "(", ")", ")", ")", ";", "}" ]
Add thread metrics. @param result the result
[ "Add", "thread", "metrics", "." ]
a4c6a6517308f5fc6f1eb4e4f5b9994122c268e6
https://github.com/Indoqa/indoqa-boot/blob/a4c6a6517308f5fc6f1eb4e4f5b9994122c268e6/src/main/java/com/indoqa/boot/actuate/metrics/SystemPublicMetrics.java#L142-L148
144,229
Indoqa/indoqa-boot
src/main/java/com/indoqa/boot/actuate/metrics/SystemPublicMetrics.java
SystemPublicMetrics.addManagementMetrics
private void addManagementMetrics(Collection<Metric<?>> result) { try { // Add JVM up time in ms result.add(new Metric<>("uptime", ManagementFactory.getRuntimeMXBean().getUptime())); result.add(new Metric<>("systemload.average", ManagementFactory.getOperatingSystemMXBean().getSystemLoadAverage())); this.addHeapMetrics(result); addNonHeapMetrics(result); this.addThreadMetrics(result); this.addClassLoadingMetrics(result); this.addGarbageCollectionMetrics(result); } catch (NoClassDefFoundError ex) { // Expected on Google App Engine } }
java
private void addManagementMetrics(Collection<Metric<?>> result) { try { // Add JVM up time in ms result.add(new Metric<>("uptime", ManagementFactory.getRuntimeMXBean().getUptime())); result.add(new Metric<>("systemload.average", ManagementFactory.getOperatingSystemMXBean().getSystemLoadAverage())); this.addHeapMetrics(result); addNonHeapMetrics(result); this.addThreadMetrics(result); this.addClassLoadingMetrics(result); this.addGarbageCollectionMetrics(result); } catch (NoClassDefFoundError ex) { // Expected on Google App Engine } }
[ "private", "void", "addManagementMetrics", "(", "Collection", "<", "Metric", "<", "?", ">", ">", "result", ")", "{", "try", "{", "// Add JVM up time in ms", "result", ".", "add", "(", "new", "Metric", "<>", "(", "\"uptime\"", ",", "ManagementFactory", ".", "getRuntimeMXBean", "(", ")", ".", "getUptime", "(", ")", ")", ")", ";", "result", ".", "add", "(", "new", "Metric", "<>", "(", "\"systemload.average\"", ",", "ManagementFactory", ".", "getOperatingSystemMXBean", "(", ")", ".", "getSystemLoadAverage", "(", ")", ")", ")", ";", "this", ".", "addHeapMetrics", "(", "result", ")", ";", "addNonHeapMetrics", "(", "result", ")", ";", "this", ".", "addThreadMetrics", "(", "result", ")", ";", "this", ".", "addClassLoadingMetrics", "(", "result", ")", ";", "this", ".", "addGarbageCollectionMetrics", "(", "result", ")", ";", "}", "catch", "(", "NoClassDefFoundError", "ex", ")", "{", "// Expected on Google App Engine", "}", "}" ]
Add metrics from ManagementFactory if possible. Note that ManagementFactory is not available on Google App Engine. @param result the result
[ "Add", "metrics", "from", "ManagementFactory", "if", "possible", ".", "Note", "that", "ManagementFactory", "is", "not", "available", "on", "Google", "App", "Engine", "." ]
a4c6a6517308f5fc6f1eb4e4f5b9994122c268e6
https://github.com/Indoqa/indoqa-boot/blob/a4c6a6517308f5fc6f1eb4e4f5b9994122c268e6/src/main/java/com/indoqa/boot/actuate/metrics/SystemPublicMetrics.java#L155-L168
144,230
Indoqa/indoqa-boot
src/main/java/com/indoqa/boot/application/AbstractIndoqaBootApplication.java
AbstractIndoqaBootApplication.invoke
public void invoke(StartupLifecycle lifecycle) { this.initializeAsciiLogo(); this.printLogo(); lifecycle.willInitialize(); this.logInitializationStart(); lifecycle.willCreateSpringContext(); this.initializeApplicationContext(); lifecycle.didCreateSpringContext(this.context); this.initializeVersionProvider(); this.initializeSystemInfo(); this.initializeProfile(); this.initializeExternalProperties(); this.initializePropertyPlaceholderConfigurer(); this.initializeSpark(); lifecycle.willCreateDefaultSparkRoutes(this.context); this.initializeJsonTransformer(); this.initializeDefaultResources(); this.initializeActuators(); lifecycle.willScanForComponents(this.context); this.initializeSpringComponentScan(); lifecycle.willRefreshSpringContext(this.context); this.refreshApplicationContext(); this.completeSystemInfoInitialization(); lifecycle.didInitializeSpring(this.context); this.enableApplicationReloading(); Optional<CharSequence> statusMessages = lifecycle.didInitialize(); this.logInitializationFinished(statusMessages); }
java
public void invoke(StartupLifecycle lifecycle) { this.initializeAsciiLogo(); this.printLogo(); lifecycle.willInitialize(); this.logInitializationStart(); lifecycle.willCreateSpringContext(); this.initializeApplicationContext(); lifecycle.didCreateSpringContext(this.context); this.initializeVersionProvider(); this.initializeSystemInfo(); this.initializeProfile(); this.initializeExternalProperties(); this.initializePropertyPlaceholderConfigurer(); this.initializeSpark(); lifecycle.willCreateDefaultSparkRoutes(this.context); this.initializeJsonTransformer(); this.initializeDefaultResources(); this.initializeActuators(); lifecycle.willScanForComponents(this.context); this.initializeSpringComponentScan(); lifecycle.willRefreshSpringContext(this.context); this.refreshApplicationContext(); this.completeSystemInfoInitialization(); lifecycle.didInitializeSpring(this.context); this.enableApplicationReloading(); Optional<CharSequence> statusMessages = lifecycle.didInitialize(); this.logInitializationFinished(statusMessages); }
[ "public", "void", "invoke", "(", "StartupLifecycle", "lifecycle", ")", "{", "this", ".", "initializeAsciiLogo", "(", ")", ";", "this", ".", "printLogo", "(", ")", ";", "lifecycle", ".", "willInitialize", "(", ")", ";", "this", ".", "logInitializationStart", "(", ")", ";", "lifecycle", ".", "willCreateSpringContext", "(", ")", ";", "this", ".", "initializeApplicationContext", "(", ")", ";", "lifecycle", ".", "didCreateSpringContext", "(", "this", ".", "context", ")", ";", "this", ".", "initializeVersionProvider", "(", ")", ";", "this", ".", "initializeSystemInfo", "(", ")", ";", "this", ".", "initializeProfile", "(", ")", ";", "this", ".", "initializeExternalProperties", "(", ")", ";", "this", ".", "initializePropertyPlaceholderConfigurer", "(", ")", ";", "this", ".", "initializeSpark", "(", ")", ";", "lifecycle", ".", "willCreateDefaultSparkRoutes", "(", "this", ".", "context", ")", ";", "this", ".", "initializeJsonTransformer", "(", ")", ";", "this", ".", "initializeDefaultResources", "(", ")", ";", "this", ".", "initializeActuators", "(", ")", ";", "lifecycle", ".", "willScanForComponents", "(", "this", ".", "context", ")", ";", "this", ".", "initializeSpringComponentScan", "(", ")", ";", "lifecycle", ".", "willRefreshSpringContext", "(", "this", ".", "context", ")", ";", "this", ".", "refreshApplicationContext", "(", ")", ";", "this", ".", "completeSystemInfoInitialization", "(", ")", ";", "lifecycle", ".", "didInitializeSpring", "(", "this", ".", "context", ")", ";", "this", ".", "enableApplicationReloading", "(", ")", ";", "Optional", "<", "CharSequence", ">", "statusMessages", "=", "lifecycle", ".", "didInitialize", "(", ")", ";", "this", ".", "logInitializationFinished", "(", "statusMessages", ")", ";", "}" ]
Start the Indoqa-Boot application and hook into the startup lifecycle. @param lifecycle Provide an implementation of the callback interface.
[ "Start", "the", "Indoqa", "-", "Boot", "application", "and", "hook", "into", "the", "startup", "lifecycle", "." ]
a4c6a6517308f5fc6f1eb4e4f5b9994122c268e6
https://github.com/Indoqa/indoqa-boot/blob/a4c6a6517308f5fc6f1eb4e4f5b9994122c268e6/src/main/java/com/indoqa/boot/application/AbstractIndoqaBootApplication.java#L97-L132
144,231
osglworks/java-mvc
src/main/java/org/osgl/mvc/HttpContextManager.java
HttpContextManager.save
public static void save() { H.Response resp = H.Response.current(); H.Session session = H.Session.current(); serialize(session); H.Flash flash = H.Flash.current(); serialize(flash); }
java
public static void save() { H.Response resp = H.Response.current(); H.Session session = H.Session.current(); serialize(session); H.Flash flash = H.Flash.current(); serialize(flash); }
[ "public", "static", "void", "save", "(", ")", "{", "H", ".", "Response", "resp", "=", "H", ".", "Response", ".", "current", "(", ")", ";", "H", ".", "Session", "session", "=", "H", ".", "Session", ".", "current", "(", ")", ";", "serialize", "(", "session", ")", ";", "H", ".", "Flash", "flash", "=", "H", ".", "Flash", ".", "current", "(", ")", ";", "serialize", "(", "flash", ")", ";", "}" ]
Persist session and flash to cookie, write all cookies to http response
[ "Persist", "session", "and", "flash", "to", "cookie", "write", "all", "cookies", "to", "http", "response" ]
4d2b2ec40498ac6ee7040c0424377cbeacab124b
https://github.com/osglworks/java-mvc/blob/4d2b2ec40498ac6ee7040c0424377cbeacab124b/src/main/java/org/osgl/mvc/HttpContextManager.java#L70-L78
144,232
Tirasa/ConnIdSOAPBundle
wssample/src/main/java/net/tirasa/connid/bundles/soap/wssample/ProvisioningImpl.java
ProvisioningImpl.connect
private Connection connect() throws SQLException { if (DefaultContentLoader.localDataSource == null) { LOG.error("Data Source is null"); return null; } final Connection conn = DataSourceUtils.getConnection(DefaultContentLoader.localDataSource); if (conn == null) { LOG.error("Connection is null"); } return conn; }
java
private Connection connect() throws SQLException { if (DefaultContentLoader.localDataSource == null) { LOG.error("Data Source is null"); return null; } final Connection conn = DataSourceUtils.getConnection(DefaultContentLoader.localDataSource); if (conn == null) { LOG.error("Connection is null"); } return conn; }
[ "private", "Connection", "connect", "(", ")", "throws", "SQLException", "{", "if", "(", "DefaultContentLoader", ".", "localDataSource", "==", "null", ")", "{", "LOG", ".", "error", "(", "\"Data Source is null\"", ")", ";", "return", "null", ";", "}", "final", "Connection", "conn", "=", "DataSourceUtils", ".", "getConnection", "(", "DefaultContentLoader", ".", "localDataSource", ")", ";", "if", "(", "conn", "==", "null", ")", "{", "LOG", ".", "error", "(", "\"Connection is null\"", ")", ";", "}", "return", "conn", ";", "}" ]
Establish a connection to underlying db. @return @throws ClassNotFoundException @throws SQLException
[ "Establish", "a", "connection", "to", "underlying", "db", "." ]
d6521885e109d66e76193e62fb66647b3f386cae
https://github.com/Tirasa/ConnIdSOAPBundle/blob/d6521885e109d66e76193e62fb66647b3f386cae/wssample/src/main/java/net/tirasa/connid/bundles/soap/wssample/ProvisioningImpl.java#L619-L633
144,233
digipost/sdp-shared
api-commons/src/main/java/no/digipost/api/interceptors/Wss4jInterceptor.java
Wss4jInterceptor.initializeRequestData
protected RequestData initializeRequestData(final MessageContext messageContext) { RequestData requestData = new RequestData(); requestData.setMsgContext(messageContext); // reads securementUsername first from the context then from the property String contextUsername = (String) messageContext.getProperty(SECUREMENT_USER_PROPERTY_NAME); if (StringUtils.hasLength(contextUsername)) { requestData.setUsername(contextUsername); } else { requestData.setUsername(securementUsername); } requestData.setAppendSignatureAfterTimestamp(true); requestData.setTimeStampTTL(securementTimeToLive); requestData.setWssConfig(wssConfig); return requestData; }
java
protected RequestData initializeRequestData(final MessageContext messageContext) { RequestData requestData = new RequestData(); requestData.setMsgContext(messageContext); // reads securementUsername first from the context then from the property String contextUsername = (String) messageContext.getProperty(SECUREMENT_USER_PROPERTY_NAME); if (StringUtils.hasLength(contextUsername)) { requestData.setUsername(contextUsername); } else { requestData.setUsername(securementUsername); } requestData.setAppendSignatureAfterTimestamp(true); requestData.setTimeStampTTL(securementTimeToLive); requestData.setWssConfig(wssConfig); return requestData; }
[ "protected", "RequestData", "initializeRequestData", "(", "final", "MessageContext", "messageContext", ")", "{", "RequestData", "requestData", "=", "new", "RequestData", "(", ")", ";", "requestData", ".", "setMsgContext", "(", "messageContext", ")", ";", "// reads securementUsername first from the context then from the property", "String", "contextUsername", "=", "(", "String", ")", "messageContext", ".", "getProperty", "(", "SECUREMENT_USER_PROPERTY_NAME", ")", ";", "if", "(", "StringUtils", ".", "hasLength", "(", "contextUsername", ")", ")", "{", "requestData", ".", "setUsername", "(", "contextUsername", ")", ";", "}", "else", "{", "requestData", ".", "setUsername", "(", "securementUsername", ")", ";", "}", "requestData", ".", "setAppendSignatureAfterTimestamp", "(", "true", ")", ";", "requestData", ".", "setTimeStampTTL", "(", "securementTimeToLive", ")", ";", "requestData", ".", "setWssConfig", "(", "wssConfig", ")", ";", "return", "requestData", ";", "}" ]
Creates and initializes a request data for the given message context. @param messageContext the message context @return the request data
[ "Creates", "and", "initializes", "a", "request", "data", "for", "the", "given", "message", "context", "." ]
c34920a993b65ff0908dab9d9c92140ded7312bc
https://github.com/digipost/sdp-shared/blob/c34920a993b65ff0908dab9d9c92140ded7312bc/api-commons/src/main/java/no/digipost/api/interceptors/Wss4jInterceptor.java#L268-L284
144,234
digipost/sdp-shared
api-commons/src/main/java/no/digipost/api/interceptors/Wss4jInterceptor.java
Wss4jInterceptor.checkResults
protected void checkResults(final List<WSSecurityEngineResult> results, final List<Integer> validationActions) throws Wss4jSecurityValidationException { if (!handler.checkReceiverResultsAnyOrder(results, validationActions)) { throw new Wss4jSecurityValidationException("Security processing failed (actions mismatch)"); } }
java
protected void checkResults(final List<WSSecurityEngineResult> results, final List<Integer> validationActions) throws Wss4jSecurityValidationException { if (!handler.checkReceiverResultsAnyOrder(results, validationActions)) { throw new Wss4jSecurityValidationException("Security processing failed (actions mismatch)"); } }
[ "protected", "void", "checkResults", "(", "final", "List", "<", "WSSecurityEngineResult", ">", "results", ",", "final", "List", "<", "Integer", ">", "validationActions", ")", "throws", "Wss4jSecurityValidationException", "{", "if", "(", "!", "handler", ".", "checkReceiverResultsAnyOrder", "(", "results", ",", "validationActions", ")", ")", "{", "throw", "new", "Wss4jSecurityValidationException", "(", "\"Security processing failed (actions mismatch)\"", ")", ";", "}", "}" ]
Checks whether the received headers match the configured validation actions. Subclasses could override this method for custom verification behavior. @param results the results of the validation function @param validationActions the decoded validation actions @throws Wss4jSecurityValidationException if the results are deemed invalid
[ "Checks", "whether", "the", "received", "headers", "match", "the", "configured", "validation", "actions", ".", "Subclasses", "could", "override", "this", "method", "for", "custom", "verification", "behavior", "." ]
c34920a993b65ff0908dab9d9c92140ded7312bc
https://github.com/digipost/sdp-shared/blob/c34920a993b65ff0908dab9d9c92140ded7312bc/api-commons/src/main/java/no/digipost/api/interceptors/Wss4jInterceptor.java#L409-L413
144,235
digipost/sdp-shared
api-commons/src/main/java/no/digipost/api/interceptors/Wss4jInterceptor.java
Wss4jInterceptor.updateContextWithResults
@SuppressWarnings("unchecked") private void updateContextWithResults(final MessageContext messageContext, final WSHandlerResult result) { List<WSHandlerResult> handlerResults; if ((handlerResults = (List<WSHandlerResult>) messageContext.getProperty(WSHandlerConstants.RECV_RESULTS)) == null) { handlerResults = new ArrayList<WSHandlerResult>(); messageContext.setProperty(WSHandlerConstants.RECV_RESULTS, handlerResults); } handlerResults.add(0, result); messageContext.setProperty(WSHandlerConstants.RECV_RESULTS, handlerResults); }
java
@SuppressWarnings("unchecked") private void updateContextWithResults(final MessageContext messageContext, final WSHandlerResult result) { List<WSHandlerResult> handlerResults; if ((handlerResults = (List<WSHandlerResult>) messageContext.getProperty(WSHandlerConstants.RECV_RESULTS)) == null) { handlerResults = new ArrayList<WSHandlerResult>(); messageContext.setProperty(WSHandlerConstants.RECV_RESULTS, handlerResults); } handlerResults.add(0, result); messageContext.setProperty(WSHandlerConstants.RECV_RESULTS, handlerResults); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "void", "updateContextWithResults", "(", "final", "MessageContext", "messageContext", ",", "final", "WSHandlerResult", "result", ")", "{", "List", "<", "WSHandlerResult", ">", "handlerResults", ";", "if", "(", "(", "handlerResults", "=", "(", "List", "<", "WSHandlerResult", ">", ")", "messageContext", ".", "getProperty", "(", "WSHandlerConstants", ".", "RECV_RESULTS", ")", ")", "==", "null", ")", "{", "handlerResults", "=", "new", "ArrayList", "<", "WSHandlerResult", ">", "(", ")", ";", "messageContext", ".", "setProperty", "(", "WSHandlerConstants", ".", "RECV_RESULTS", ",", "handlerResults", ")", ";", "}", "handlerResults", ".", "add", "(", "0", ",", "result", ")", ";", "messageContext", ".", "setProperty", "(", "WSHandlerConstants", ".", "RECV_RESULTS", ",", "handlerResults", ")", ";", "}" ]
Puts the results of WS-Security headers processing in the message context. Some actions like Signature Confirmation require this.
[ "Puts", "the", "results", "of", "WS", "-", "Security", "headers", "processing", "in", "the", "message", "context", ".", "Some", "actions", "like", "Signature", "Confirmation", "require", "this", "." ]
c34920a993b65ff0908dab9d9c92140ded7312bc
https://github.com/digipost/sdp-shared/blob/c34920a993b65ff0908dab9d9c92140ded7312bc/api-commons/src/main/java/no/digipost/api/interceptors/Wss4jInterceptor.java#L419-L428
144,236
digipost/sdp-shared
api-commons/src/main/java/no/digipost/api/interceptors/Wss4jInterceptor.java
Wss4jInterceptor.verifyCertificateTrust
protected void verifyCertificateTrust(WSHandlerResult result) throws WSSecurityException { List<WSSecurityEngineResult> signResults = result.getActionResults().getOrDefault(WSConstants.SIGN, emptyList()); if (signResults.isEmpty()) { throw new Wss4jSecurityValidationException("No action results for 'Perform Signature' found"); } else if (signResults.size() > 1) { throw new Wss4jSecurityValidationException("Multiple action results for 'Perform Signature' found. Expected only 1."); } WSSecurityEngineResult signResult = signResults.get(0); if (signResult != null) { X509Certificate returnCert = (X509Certificate) signResult.get(WSSecurityEngineResult.TAG_X509_CERTIFICATE); Credential credential = new Credential(); credential.setCertificates(new X509Certificate[]{returnCert}); RequestData requestData = new RequestData(); requestData.setSigVerCrypto(validationSignatureCrypto); requestData.setEnableRevocation(enableRevocation); requestData.setSubjectCertConstraints(OrgnummerExtractor.PATTERNS); SignatureTrustValidator validator = new SignatureTrustValidator(); validator.validate(credential, requestData); } }
java
protected void verifyCertificateTrust(WSHandlerResult result) throws WSSecurityException { List<WSSecurityEngineResult> signResults = result.getActionResults().getOrDefault(WSConstants.SIGN, emptyList()); if (signResults.isEmpty()) { throw new Wss4jSecurityValidationException("No action results for 'Perform Signature' found"); } else if (signResults.size() > 1) { throw new Wss4jSecurityValidationException("Multiple action results for 'Perform Signature' found. Expected only 1."); } WSSecurityEngineResult signResult = signResults.get(0); if (signResult != null) { X509Certificate returnCert = (X509Certificate) signResult.get(WSSecurityEngineResult.TAG_X509_CERTIFICATE); Credential credential = new Credential(); credential.setCertificates(new X509Certificate[]{returnCert}); RequestData requestData = new RequestData(); requestData.setSigVerCrypto(validationSignatureCrypto); requestData.setEnableRevocation(enableRevocation); requestData.setSubjectCertConstraints(OrgnummerExtractor.PATTERNS); SignatureTrustValidator validator = new SignatureTrustValidator(); validator.validate(credential, requestData); } }
[ "protected", "void", "verifyCertificateTrust", "(", "WSHandlerResult", "result", ")", "throws", "WSSecurityException", "{", "List", "<", "WSSecurityEngineResult", ">", "signResults", "=", "result", ".", "getActionResults", "(", ")", ".", "getOrDefault", "(", "WSConstants", ".", "SIGN", ",", "emptyList", "(", ")", ")", ";", "if", "(", "signResults", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "Wss4jSecurityValidationException", "(", "\"No action results for 'Perform Signature' found\"", ")", ";", "}", "else", "if", "(", "signResults", ".", "size", "(", ")", ">", "1", ")", "{", "throw", "new", "Wss4jSecurityValidationException", "(", "\"Multiple action results for 'Perform Signature' found. Expected only 1.\"", ")", ";", "}", "WSSecurityEngineResult", "signResult", "=", "signResults", ".", "get", "(", "0", ")", ";", "if", "(", "signResult", "!=", "null", ")", "{", "X509Certificate", "returnCert", "=", "(", "X509Certificate", ")", "signResult", ".", "get", "(", "WSSecurityEngineResult", ".", "TAG_X509_CERTIFICATE", ")", ";", "Credential", "credential", "=", "new", "Credential", "(", ")", ";", "credential", ".", "setCertificates", "(", "new", "X509Certificate", "[", "]", "{", "returnCert", "}", ")", ";", "RequestData", "requestData", "=", "new", "RequestData", "(", ")", ";", "requestData", ".", "setSigVerCrypto", "(", "validationSignatureCrypto", ")", ";", "requestData", ".", "setEnableRevocation", "(", "enableRevocation", ")", ";", "requestData", ".", "setSubjectCertConstraints", "(", "OrgnummerExtractor", ".", "PATTERNS", ")", ";", "SignatureTrustValidator", "validator", "=", "new", "SignatureTrustValidator", "(", ")", ";", "validator", ".", "validate", "(", "credential", ",", "requestData", ")", ";", "}", "}" ]
Verifies the trust of a certificate.
[ "Verifies", "the", "trust", "of", "a", "certificate", "." ]
c34920a993b65ff0908dab9d9c92140ded7312bc
https://github.com/digipost/sdp-shared/blob/c34920a993b65ff0908dab9d9c92140ded7312bc/api-commons/src/main/java/no/digipost/api/interceptors/Wss4jInterceptor.java#L433-L456
144,237
digipost/sdp-shared
api-commons/src/main/java/no/digipost/api/interceptors/Wss4jInterceptor.java
Wss4jInterceptor.verifyTimestamp
protected void verifyTimestamp(WSHandlerResult result) throws WSSecurityException { List<WSSecurityEngineResult> insertTimestampResults = result.getActionResults().getOrDefault(WSConstants.TS, emptyList()); if (insertTimestampResults.isEmpty()) { throw new Wss4jSecurityValidationException("No action results for 'Insert timestamp' found"); } else if (insertTimestampResults.size() > 1) { throw new Wss4jSecurityValidationException("Multiple action results for 'Insert timestamp' found. Expected only 1."); } WSSecurityEngineResult actionResult = insertTimestampResults.get(0); if (actionResult != null) { Timestamp timestamp = (Timestamp) actionResult.get(WSSecurityEngineResult.TAG_TIMESTAMP); if (timestamp != null && timestampStrict) { Credential credential = new Credential(); credential.setTimestamp(timestamp); RequestData requestData = new RequestData(); requestData.setWssConfig(WSSConfig.getNewInstance()); requestData.setTimeStampTTL(validationTimeToLive); requestData.setTimeStampStrict(timestampStrict); TimestampValidator validator = new TimestampValidator(); validator.validate(credential, requestData); } } }
java
protected void verifyTimestamp(WSHandlerResult result) throws WSSecurityException { List<WSSecurityEngineResult> insertTimestampResults = result.getActionResults().getOrDefault(WSConstants.TS, emptyList()); if (insertTimestampResults.isEmpty()) { throw new Wss4jSecurityValidationException("No action results for 'Insert timestamp' found"); } else if (insertTimestampResults.size() > 1) { throw new Wss4jSecurityValidationException("Multiple action results for 'Insert timestamp' found. Expected only 1."); } WSSecurityEngineResult actionResult = insertTimestampResults.get(0); if (actionResult != null) { Timestamp timestamp = (Timestamp) actionResult.get(WSSecurityEngineResult.TAG_TIMESTAMP); if (timestamp != null && timestampStrict) { Credential credential = new Credential(); credential.setTimestamp(timestamp); RequestData requestData = new RequestData(); requestData.setWssConfig(WSSConfig.getNewInstance()); requestData.setTimeStampTTL(validationTimeToLive); requestData.setTimeStampStrict(timestampStrict); TimestampValidator validator = new TimestampValidator(); validator.validate(credential, requestData); } } }
[ "protected", "void", "verifyTimestamp", "(", "WSHandlerResult", "result", ")", "throws", "WSSecurityException", "{", "List", "<", "WSSecurityEngineResult", ">", "insertTimestampResults", "=", "result", ".", "getActionResults", "(", ")", ".", "getOrDefault", "(", "WSConstants", ".", "TS", ",", "emptyList", "(", ")", ")", ";", "if", "(", "insertTimestampResults", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "Wss4jSecurityValidationException", "(", "\"No action results for 'Insert timestamp' found\"", ")", ";", "}", "else", "if", "(", "insertTimestampResults", ".", "size", "(", ")", ">", "1", ")", "{", "throw", "new", "Wss4jSecurityValidationException", "(", "\"Multiple action results for 'Insert timestamp' found. Expected only 1.\"", ")", ";", "}", "WSSecurityEngineResult", "actionResult", "=", "insertTimestampResults", ".", "get", "(", "0", ")", ";", "if", "(", "actionResult", "!=", "null", ")", "{", "Timestamp", "timestamp", "=", "(", "Timestamp", ")", "actionResult", ".", "get", "(", "WSSecurityEngineResult", ".", "TAG_TIMESTAMP", ")", ";", "if", "(", "timestamp", "!=", "null", "&&", "timestampStrict", ")", "{", "Credential", "credential", "=", "new", "Credential", "(", ")", ";", "credential", ".", "setTimestamp", "(", "timestamp", ")", ";", "RequestData", "requestData", "=", "new", "RequestData", "(", ")", ";", "requestData", ".", "setWssConfig", "(", "WSSConfig", ".", "getNewInstance", "(", ")", ")", ";", "requestData", ".", "setTimeStampTTL", "(", "validationTimeToLive", ")", ";", "requestData", ".", "setTimeStampStrict", "(", "timestampStrict", ")", ";", "TimestampValidator", "validator", "=", "new", "TimestampValidator", "(", ")", ";", "validator", ".", "validate", "(", "credential", ",", "requestData", ")", ";", "}", "}", "}" ]
Verifies the timestamp.
[ "Verifies", "the", "timestamp", "." ]
c34920a993b65ff0908dab9d9c92140ded7312bc
https://github.com/digipost/sdp-shared/blob/c34920a993b65ff0908dab9d9c92140ded7312bc/api-commons/src/main/java/no/digipost/api/interceptors/Wss4jInterceptor.java#L461-L485
144,238
TimotheeJeannin/ProviGen
ProviGenLib/src/com/tjeannin/provigen/helper/TableUpdater.java
TableUpdater.addMissingColumns
public static void addMissingColumns(SQLiteDatabase database, Class contractClass) { Contract contract = new Contract(contractClass); Cursor cursor = database.rawQuery("PRAGMA table_info(" + contract.getTable() + ")", null); for (ContractField field : contract.getFields()) { if (!fieldExistAsColumn(field.name, cursor)) { database.execSQL("ALTER TABLE " + contract.getTable() + " ADD COLUMN " + field.name + " " + field.type + ";"); } } }
java
public static void addMissingColumns(SQLiteDatabase database, Class contractClass) { Contract contract = new Contract(contractClass); Cursor cursor = database.rawQuery("PRAGMA table_info(" + contract.getTable() + ")", null); for (ContractField field : contract.getFields()) { if (!fieldExistAsColumn(field.name, cursor)) { database.execSQL("ALTER TABLE " + contract.getTable() + " ADD COLUMN " + field.name + " " + field.type + ";"); } } }
[ "public", "static", "void", "addMissingColumns", "(", "SQLiteDatabase", "database", ",", "Class", "contractClass", ")", "{", "Contract", "contract", "=", "new", "Contract", "(", "contractClass", ")", ";", "Cursor", "cursor", "=", "database", ".", "rawQuery", "(", "\"PRAGMA table_info(\"", "+", "contract", ".", "getTable", "(", ")", "+", "\")\"", ",", "null", ")", ";", "for", "(", "ContractField", "field", ":", "contract", ".", "getFields", "(", ")", ")", "{", "if", "(", "!", "fieldExistAsColumn", "(", "field", ".", "name", ",", "cursor", ")", ")", "{", "database", ".", "execSQL", "(", "\"ALTER TABLE \"", "+", "contract", ".", "getTable", "(", ")", "+", "\" ADD COLUMN \"", "+", "field", ".", "name", "+", "\" \"", "+", "field", ".", "type", "+", "\";\"", ")", ";", "}", "}", "}" ]
Adds missing table columns for the given contract class. @param database The database in which the updated table is. @param contractClass The contract class to work with.
[ "Adds", "missing", "table", "columns", "for", "the", "given", "contract", "class", "." ]
80c8a2021434a44e8d38c69407e3e6abf70cf21e
https://github.com/TimotheeJeannin/ProviGen/blob/80c8a2021434a44e8d38c69407e3e6abf70cf21e/ProviGenLib/src/com/tjeannin/provigen/helper/TableUpdater.java#L19-L29
144,239
TimotheeJeannin/ProviGen
ProviGenLib/src/com/tjeannin/provigen/helper/TableBuilder.java
TableBuilder.addConstraint
public TableBuilder addConstraint(String columnName, String constraintType, String constraintConflictClause) { constraints.add(new Constraint(columnName, constraintType, constraintConflictClause)); return this; }
java
public TableBuilder addConstraint(String columnName, String constraintType, String constraintConflictClause) { constraints.add(new Constraint(columnName, constraintType, constraintConflictClause)); return this; }
[ "public", "TableBuilder", "addConstraint", "(", "String", "columnName", ",", "String", "constraintType", ",", "String", "constraintConflictClause", ")", "{", "constraints", ".", "add", "(", "new", "Constraint", "(", "columnName", ",", "constraintType", ",", "constraintConflictClause", ")", ")", ";", "return", "this", ";", "}" ]
Adds the specified constraint to the created table. @param columnName The name of the column on which the constraint is applied. @param constraintType The type of constraint to apply. One of <ul> <li>{@link com.tjeannin.provigen.model.Constraint#UNIQUE}</li> <li>{@link com.tjeannin.provigen.model.Constraint#NOT_NULL}</li> </ul> @param constraintConflictClause The conflict clause to apply in case of constraint violation. One of <ul> <li>{@link com.tjeannin.provigen.model.Constraint.OnConflict#ABORT}</li> <li>{@link com.tjeannin.provigen.model.Constraint.OnConflict#FAIL}</li> <li>{@link com.tjeannin.provigen.model.Constraint.OnConflict#IGNORE}</li> <li>{@link com.tjeannin.provigen.model.Constraint.OnConflict#REPLACE}</li> <li>{@link com.tjeannin.provigen.model.Constraint.OnConflict#ROLLBACK}</li> </ul> @return The {@link com.tjeannin.provigen.helper.TableBuilder} instance to allow chaining.
[ "Adds", "the", "specified", "constraint", "to", "the", "created", "table", "." ]
80c8a2021434a44e8d38c69407e3e6abf70cf21e
https://github.com/TimotheeJeannin/ProviGen/blob/80c8a2021434a44e8d38c69407e3e6abf70cf21e/ProviGenLib/src/com/tjeannin/provigen/helper/TableBuilder.java#L48-L51
144,240
btc-ag/redg
redg-runtime/src/main/java/com/btc/redg/runtime/defaultvalues/pluggable/buildermatchers/Matchers.java
Matchers.allOf
@Deprecated public static Predicate<ColumnModel> allOf(final Predicate<ColumnModel>... conditions) { return (cM) -> Arrays.stream(conditions) .allMatch(c -> c.test(cM)); }
java
@Deprecated public static Predicate<ColumnModel> allOf(final Predicate<ColumnModel>... conditions) { return (cM) -> Arrays.stream(conditions) .allMatch(c -> c.test(cM)); }
[ "@", "Deprecated", "public", "static", "Predicate", "<", "ColumnModel", ">", "allOf", "(", "final", "Predicate", "<", "ColumnModel", ">", "...", "conditions", ")", "{", "return", "(", "cM", ")", "-", ">", "Arrays", ".", "stream", "(", "conditions", ")", ".", "allMatch", "(", "c", "->", "c", ".", "test", "(", "cM", ")", ")", ";", "}" ]
A condition that returns true if all of the provided conditions return true. Equivalent to logical AND operator. @param conditions The conditions to be checked @return A condition that returns true if all passed conditions return true @deprecated Use {@link Predicate#and(Predicate)} instead
[ "A", "condition", "that", "returns", "true", "if", "all", "of", "the", "provided", "conditions", "return", "true", ".", "Equivalent", "to", "logical", "AND", "operator", "." ]
416a68639d002512cabfebff09afd2e1909e27df
https://github.com/btc-ag/redg/blob/416a68639d002512cabfebff09afd2e1909e27df/redg-runtime/src/main/java/com/btc/redg/runtime/defaultvalues/pluggable/buildermatchers/Matchers.java#L69-L73
144,241
btc-ag/redg
redg-runtime/src/main/java/com/btc/redg/runtime/defaultvalues/pluggable/buildermatchers/Matchers.java
Matchers.anyOf
@Deprecated public static Predicate<ColumnModel> anyOf(final Predicate<ColumnModel>... conditions) { return (cM) -> Arrays.stream(conditions) .anyMatch(c -> c.test(cM)); }
java
@Deprecated public static Predicate<ColumnModel> anyOf(final Predicate<ColumnModel>... conditions) { return (cM) -> Arrays.stream(conditions) .anyMatch(c -> c.test(cM)); }
[ "@", "Deprecated", "public", "static", "Predicate", "<", "ColumnModel", ">", "anyOf", "(", "final", "Predicate", "<", "ColumnModel", ">", "...", "conditions", ")", "{", "return", "(", "cM", ")", "-", ">", "Arrays", ".", "stream", "(", "conditions", ")", ".", "anyMatch", "(", "c", "->", "c", ".", "test", "(", "cM", ")", ")", ";", "}" ]
A condition that returns true if any of the provided conditions return true. Equivalent to logical OR operator. @param conditions The conditions to be checked @return A condition that returns true if any of the passed conditions return true @deprecated Use {@link Predicate#or(Predicate)} instead
[ "A", "condition", "that", "returns", "true", "if", "any", "of", "the", "provided", "conditions", "return", "true", ".", "Equivalent", "to", "logical", "OR", "operator", "." ]
416a68639d002512cabfebff09afd2e1909e27df
https://github.com/btc-ag/redg/blob/416a68639d002512cabfebff09afd2e1909e27df/redg-runtime/src/main/java/com/btc/redg/runtime/defaultvalues/pluggable/buildermatchers/Matchers.java#L82-L86
144,242
btc-ag/redg
redg-runtime/src/main/java/com/btc/redg/runtime/defaultvalues/pluggable/buildermatchers/Matchers.java
Matchers.oneOf
public static Predicate<ColumnModel> oneOf(final Predicate<ColumnModel>... conditions) { return (cM) -> Arrays.stream(conditions) .map(c -> c.test(cM)).filter(b -> b).count() == 1; }
java
public static Predicate<ColumnModel> oneOf(final Predicate<ColumnModel>... conditions) { return (cM) -> Arrays.stream(conditions) .map(c -> c.test(cM)).filter(b -> b).count() == 1; }
[ "public", "static", "Predicate", "<", "ColumnModel", ">", "oneOf", "(", "final", "Predicate", "<", "ColumnModel", ">", "...", "conditions", ")", "{", "return", "(", "cM", ")", "-", ">", "Arrays", ".", "stream", "(", "conditions", ")", ".", "map", "(", "c", "->", "c", ".", "test", "(", "cM", ")", ")", ".", "filter", "(", "b", "->", "b", ")", ".", "count", "(", ")", "==", "1", ";", "}" ]
A condition that returns true if exactly one of the provided conditions return true. Equivalent to logical XOR operator. @param conditions The conditions to be checked @return A condition that returns true if exactly one of the passed conditions return true
[ "A", "condition", "that", "returns", "true", "if", "exactly", "one", "of", "the", "provided", "conditions", "return", "true", ".", "Equivalent", "to", "logical", "XOR", "operator", "." ]
416a68639d002512cabfebff09afd2e1909e27df
https://github.com/btc-ag/redg/blob/416a68639d002512cabfebff09afd2e1909e27df/redg-runtime/src/main/java/com/btc/redg/runtime/defaultvalues/pluggable/buildermatchers/Matchers.java#L94-L97
144,243
btc-ag/redg
redg-runtime/src/main/java/com/btc/redg/runtime/dummy/DefaultDummyFactory.java
DefaultDummyFactory.getDummy
@Override public <T extends RedGEntity> T getDummy(final AbstractRedG redG, final Class<T> dummyClass) { // check if a dummy for this type already exists in cache if (this.dummyCache.containsKey(dummyClass)) { return dummyClass.cast(this.dummyCache.get(dummyClass)); } final T obj = createNewDummy(redG, dummyClass); // if no one is found, create new this.dummyCache.put(dummyClass, obj); return obj; }
java
@Override public <T extends RedGEntity> T getDummy(final AbstractRedG redG, final Class<T> dummyClass) { // check if a dummy for this type already exists in cache if (this.dummyCache.containsKey(dummyClass)) { return dummyClass.cast(this.dummyCache.get(dummyClass)); } final T obj = createNewDummy(redG, dummyClass); // if no one is found, create new this.dummyCache.put(dummyClass, obj); return obj; }
[ "@", "Override", "public", "<", "T", "extends", "RedGEntity", ">", "T", "getDummy", "(", "final", "AbstractRedG", "redG", ",", "final", "Class", "<", "T", ">", "dummyClass", ")", "{", "// check if a dummy for this type already exists in cache\r", "if", "(", "this", ".", "dummyCache", ".", "containsKey", "(", "dummyClass", ")", ")", "{", "return", "dummyClass", ".", "cast", "(", "this", ".", "dummyCache", ".", "get", "(", "dummyClass", ")", ")", ";", "}", "final", "T", "obj", "=", "createNewDummy", "(", "redG", ",", "dummyClass", ")", ";", "// if no one is found, create new\r", "this", ".", "dummyCache", ".", "put", "(", "dummyClass", ",", "obj", ")", ";", "return", "obj", ";", "}" ]
Returns a dummy entity for the requested type. All this method guarantees is that the returned entity is a valid entity with all non null foreign key relations filled in, it does not guarantee useful or even semantically correct data. The dummy objects get taken either from the list of objects to insert from the redG object or are created on the fly. The results are cached and the same entity will be returned for consecutive calls for an entity of the same type. @param redG The redG instance @param dummyClass The class specifying the wanted entity type @param <T> The wanted entity type @return a dummy object of thew required type @throws DummyCreationException When a new dummy has to be created but this creation fails
[ "Returns", "a", "dummy", "entity", "for", "the", "requested", "type", ".", "All", "this", "method", "guarantees", "is", "that", "the", "returned", "entity", "is", "a", "valid", "entity", "with", "all", "non", "null", "foreign", "key", "relations", "filled", "in", "it", "does", "not", "guarantee", "useful", "or", "even", "semantically", "correct", "data", ".", "The", "dummy", "objects", "get", "taken", "either", "from", "the", "list", "of", "objects", "to", "insert", "from", "the", "redG", "object", "or", "are", "created", "on", "the", "fly", ".", "The", "results", "are", "cached", "and", "the", "same", "entity", "will", "be", "returned", "for", "consecutive", "calls", "for", "an", "entity", "of", "the", "same", "type", "." ]
416a68639d002512cabfebff09afd2e1909e27df
https://github.com/btc-ag/redg/blob/416a68639d002512cabfebff09afd2e1909e27df/redg-runtime/src/main/java/com/btc/redg/runtime/dummy/DefaultDummyFactory.java#L47-L56
144,244
HalBuilder/halbuilder-api
src/main/java/com/theoryinpractise/halbuilder/api/Link.java
Link.hasTemplate
private boolean hasTemplate(String href) { if (href == null) { return false; } return URI_TEMPLATE_PATTERN.matcher(href).find(); }
java
private boolean hasTemplate(String href) { if (href == null) { return false; } return URI_TEMPLATE_PATTERN.matcher(href).find(); }
[ "private", "boolean", "hasTemplate", "(", "String", "href", ")", "{", "if", "(", "href", "==", "null", ")", "{", "return", "false", ";", "}", "return", "URI_TEMPLATE_PATTERN", ".", "matcher", "(", "href", ")", ".", "find", "(", ")", ";", "}" ]
Determine whether the argument href contains at least one URI template, as defined in RFC 6570. @param href Href to check. @return True if the href contains a template, false if not (or if the argument is null).
[ "Determine", "whether", "the", "argument", "href", "contains", "at", "least", "one", "URI", "template", "as", "defined", "in", "RFC", "6570", "." ]
b595b0af8b033ae4a51dba9c3deb411d25bb54d7
https://github.com/HalBuilder/halbuilder-api/blob/b595b0af8b033ae4a51dba9c3deb411d25bb54d7/src/main/java/com/theoryinpractise/halbuilder/api/Link.java#L54-L59
144,245
btc-ag/redg
redg-generator/src/main/java/com/btc/redg/generator/extractor/MetadataExtractor.java
MetadataExtractor.processJoinTables
private static void processJoinTables(final List<TableModel> result, final Map<String, Map<Table, List<String>>> joinTableMetadata) { joinTableMetadata.entrySet().forEach(entry -> { LOG.debug("Processing join tables for {}. Found {} join tables to process", entry.getKey(), entry.getValue().size()); final TableModel model = getModelBySQLName(result, entry.getKey()); if (model == null) { LOG.error("Could not find table {} in the already generated models! This should not happen!", entry.getKey()); throw new NullPointerException("Table model not found"); } entry.getValue().entrySet().forEach(tableListEntry -> { LOG.debug("Processing join table {}", tableListEntry.getKey().getFullName()); final TableModel joinTable = getModelBySQLName(result, tableListEntry.getKey().getFullName()); if (joinTable == null) { LOG.error("Could not find join table {} in the already generated models! This should not happen!", entry.getKey()); throw new NullPointerException("Table model not found"); } JoinTableSimplifierModel jtsModel = new JoinTableSimplifierModel(); jtsModel.setName(joinTable.getName()); for (ForeignKeyModel fKModel : joinTable.getForeignKeys()) { if (fKModel.getJavaTypeName().equals(model.getClassName())) { jtsModel.getConstructorParams().add("this"); } else { jtsModel.getConstructorParams().add(fKModel.getName()); jtsModel.getMethodParams().put(fKModel.getJavaTypeName(), fKModel.getName()); } } model.getJoinTableSimplifierData().put(joinTable.getClassName(), jtsModel); }); }); }
java
private static void processJoinTables(final List<TableModel> result, final Map<String, Map<Table, List<String>>> joinTableMetadata) { joinTableMetadata.entrySet().forEach(entry -> { LOG.debug("Processing join tables for {}. Found {} join tables to process", entry.getKey(), entry.getValue().size()); final TableModel model = getModelBySQLName(result, entry.getKey()); if (model == null) { LOG.error("Could not find table {} in the already generated models! This should not happen!", entry.getKey()); throw new NullPointerException("Table model not found"); } entry.getValue().entrySet().forEach(tableListEntry -> { LOG.debug("Processing join table {}", tableListEntry.getKey().getFullName()); final TableModel joinTable = getModelBySQLName(result, tableListEntry.getKey().getFullName()); if (joinTable == null) { LOG.error("Could not find join table {} in the already generated models! This should not happen!", entry.getKey()); throw new NullPointerException("Table model not found"); } JoinTableSimplifierModel jtsModel = new JoinTableSimplifierModel(); jtsModel.setName(joinTable.getName()); for (ForeignKeyModel fKModel : joinTable.getForeignKeys()) { if (fKModel.getJavaTypeName().equals(model.getClassName())) { jtsModel.getConstructorParams().add("this"); } else { jtsModel.getConstructorParams().add(fKModel.getName()); jtsModel.getMethodParams().put(fKModel.getJavaTypeName(), fKModel.getName()); } } model.getJoinTableSimplifierData().put(joinTable.getClassName(), jtsModel); }); }); }
[ "private", "static", "void", "processJoinTables", "(", "final", "List", "<", "TableModel", ">", "result", ",", "final", "Map", "<", "String", ",", "Map", "<", "Table", ",", "List", "<", "String", ">", ">", ">", "joinTableMetadata", ")", "{", "joinTableMetadata", ".", "entrySet", "(", ")", ".", "forEach", "(", "entry", "->", "{", "LOG", ".", "debug", "(", "\"Processing join tables for {}. Found {} join tables to process\"", ",", "entry", ".", "getKey", "(", ")", ",", "entry", ".", "getValue", "(", ")", ".", "size", "(", ")", ")", ";", "final", "TableModel", "model", "=", "getModelBySQLName", "(", "result", ",", "entry", ".", "getKey", "(", ")", ")", ";", "if", "(", "model", "==", "null", ")", "{", "LOG", ".", "error", "(", "\"Could not find table {} in the already generated models! This should not happen!\"", ",", "entry", ".", "getKey", "(", ")", ")", ";", "throw", "new", "NullPointerException", "(", "\"Table model not found\"", ")", ";", "}", "entry", ".", "getValue", "(", ")", ".", "entrySet", "(", ")", ".", "forEach", "(", "tableListEntry", "->", "{", "LOG", ".", "debug", "(", "\"Processing join table {}\"", ",", "tableListEntry", ".", "getKey", "(", ")", ".", "getFullName", "(", ")", ")", ";", "final", "TableModel", "joinTable", "=", "getModelBySQLName", "(", "result", ",", "tableListEntry", ".", "getKey", "(", ")", ".", "getFullName", "(", ")", ")", ";", "if", "(", "joinTable", "==", "null", ")", "{", "LOG", ".", "error", "(", "\"Could not find join table {} in the already generated models! This should not happen!\"", ",", "entry", ".", "getKey", "(", ")", ")", ";", "throw", "new", "NullPointerException", "(", "\"Table model not found\"", ")", ";", "}", "JoinTableSimplifierModel", "jtsModel", "=", "new", "JoinTableSimplifierModel", "(", ")", ";", "jtsModel", ".", "setName", "(", "joinTable", ".", "getName", "(", ")", ")", ";", "for", "(", "ForeignKeyModel", "fKModel", ":", "joinTable", ".", "getForeignKeys", "(", ")", ")", "{", "if", "(", "fKModel", ".", "getJavaTypeName", "(", ")", ".", "equals", "(", "model", ".", "getClassName", "(", ")", ")", ")", "{", "jtsModel", ".", "getConstructorParams", "(", ")", ".", "add", "(", "\"this\"", ")", ";", "}", "else", "{", "jtsModel", ".", "getConstructorParams", "(", ")", ".", "add", "(", "fKModel", ".", "getName", "(", ")", ")", ";", "jtsModel", ".", "getMethodParams", "(", ")", ".", "put", "(", "fKModel", ".", "getJavaTypeName", "(", ")", ",", "fKModel", ".", "getName", "(", ")", ")", ";", "}", "}", "model", ".", "getJoinTableSimplifierData", "(", ")", ".", "put", "(", "joinTable", ".", "getClassName", "(", ")", ",", "jtsModel", ")", ";", "}", ")", ";", "}", ")", ";", "}" ]
Processes the information about the join tables that were collected during table model extraction. @param result The already processed tables @param joinTableMetadata The metadata about the join tables
[ "Processes", "the", "information", "about", "the", "join", "tables", "that", "were", "collected", "during", "table", "model", "extraction", "." ]
416a68639d002512cabfebff09afd2e1909e27df
https://github.com/btc-ag/redg/blob/416a68639d002512cabfebff09afd2e1909e27df/redg-generator/src/main/java/com/btc/redg/generator/extractor/MetadataExtractor.java#L84-L113
144,246
btc-ag/redg
redg-generator/src/main/java/com/btc/redg/generator/extractor/MetadataExtractor.java
MetadataExtractor.mergeJoinTableMetadata
private static Map<String, Map<Table, List<String>>> mergeJoinTableMetadata(Map<String, Map<Table, List<String>>> data, Map<String, Map<Table, List<String>>> extension) { for (String key : extension.keySet()) { Map<Table, List<String>> dataForTable = data.get(key); if (dataForTable == null) { data.put(key, extension.get(key)); continue; } for (Table t : extension.get(key).keySet()) { dataForTable.put(t, extension.get(key).get(t)); } data.put(key, dataForTable); } return data; }
java
private static Map<String, Map<Table, List<String>>> mergeJoinTableMetadata(Map<String, Map<Table, List<String>>> data, Map<String, Map<Table, List<String>>> extension) { for (String key : extension.keySet()) { Map<Table, List<String>> dataForTable = data.get(key); if (dataForTable == null) { data.put(key, extension.get(key)); continue; } for (Table t : extension.get(key).keySet()) { dataForTable.put(t, extension.get(key).get(t)); } data.put(key, dataForTable); } return data; }
[ "private", "static", "Map", "<", "String", ",", "Map", "<", "Table", ",", "List", "<", "String", ">", ">", ">", "mergeJoinTableMetadata", "(", "Map", "<", "String", ",", "Map", "<", "Table", ",", "List", "<", "String", ">", ">", ">", "data", ",", "Map", "<", "String", ",", "Map", "<", "Table", ",", "List", "<", "String", ">", ">", ">", "extension", ")", "{", "for", "(", "String", "key", ":", "extension", ".", "keySet", "(", ")", ")", "{", "Map", "<", "Table", ",", "List", "<", "String", ">", ">", "dataForTable", "=", "data", ".", "get", "(", "key", ")", ";", "if", "(", "dataForTable", "==", "null", ")", "{", "data", ".", "put", "(", "key", ",", "extension", ".", "get", "(", "key", ")", ")", ";", "continue", ";", "}", "for", "(", "Table", "t", ":", "extension", ".", "get", "(", "key", ")", ".", "keySet", "(", ")", ")", "{", "dataForTable", ".", "put", "(", "t", ",", "extension", ".", "get", "(", "key", ")", ".", "get", "(", "t", ")", ")", ";", "}", "data", ".", "put", "(", "key", ",", "dataForTable", ")", ";", "}", "return", "data", ";", "}" ]
Performs a deep-merge on the two provided maps, integrating everything from the second map into the first and returning the first map. @param data The first map. Will be modified @param extension The second map, which will be integrated into the first one. Will not be modified @return The resulting map, a reference to the same object that was passed as the first parameter
[ "Performs", "a", "deep", "-", "merge", "on", "the", "two", "provided", "maps", "integrating", "everything", "from", "the", "second", "map", "into", "the", "first", "and", "returning", "the", "first", "map", "." ]
416a68639d002512cabfebff09afd2e1909e27df
https://github.com/btc-ag/redg/blob/416a68639d002512cabfebff09afd2e1909e27df/redg-generator/src/main/java/com/btc/redg/generator/extractor/MetadataExtractor.java#L140-L154
144,247
elibom/jogger
src/main/java/com/elibom/jogger/middleware/router/loader/AbstractFileRoutesLoader.java
AbstractFileRoutesLoader.validatePath
private String validatePath(String path, int line) throws ParseException { if (!path.startsWith("/")) { throw new ParseException("Path must start with '/'", line); } boolean openedKey = false; for (int i=0; i < path.length(); i++) { boolean validChar = isValidCharForPath(path.charAt(i), openedKey); if (!validChar) { throw new ParseException(path, i); } if (path.charAt(i) == '{') { openedKey = true; } if (path.charAt(i) == '}') { openedKey = false; } } return path; }
java
private String validatePath(String path, int line) throws ParseException { if (!path.startsWith("/")) { throw new ParseException("Path must start with '/'", line); } boolean openedKey = false; for (int i=0; i < path.length(); i++) { boolean validChar = isValidCharForPath(path.charAt(i), openedKey); if (!validChar) { throw new ParseException(path, i); } if (path.charAt(i) == '{') { openedKey = true; } if (path.charAt(i) == '}') { openedKey = false; } } return path; }
[ "private", "String", "validatePath", "(", "String", "path", ",", "int", "line", ")", "throws", "ParseException", "{", "if", "(", "!", "path", ".", "startsWith", "(", "\"/\"", ")", ")", "{", "throw", "new", "ParseException", "(", "\"Path must start with '/'\"", ",", "line", ")", ";", "}", "boolean", "openedKey", "=", "false", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "path", ".", "length", "(", ")", ";", "i", "++", ")", "{", "boolean", "validChar", "=", "isValidCharForPath", "(", "path", ".", "charAt", "(", "i", ")", ",", "openedKey", ")", ";", "if", "(", "!", "validChar", ")", "{", "throw", "new", "ParseException", "(", "path", ",", "i", ")", ";", "}", "if", "(", "path", ".", "charAt", "(", "i", ")", "==", "'", "'", ")", "{", "openedKey", "=", "true", ";", "}", "if", "(", "path", ".", "charAt", "(", "i", ")", "==", "'", "'", ")", "{", "openedKey", "=", "false", ";", "}", "}", "return", "path", ";", "}" ]
Helper method. It validates if the path is valid. @param path the path to be validated @return the same path that was received as an argument. @throws ParseException if the path is not valid.
[ "Helper", "method", ".", "It", "validates", "if", "the", "path", "is", "valid", "." ]
d5892ff45e76328d444a68b5a38c26e7bdd0692b
https://github.com/elibom/jogger/blob/d5892ff45e76328d444a68b5a38c26e7bdd0692b/src/main/java/com/elibom/jogger/middleware/router/loader/AbstractFileRoutesLoader.java#L167-L191
144,248
elibom/jogger
src/main/java/com/elibom/jogger/middleware/router/loader/AbstractFileRoutesLoader.java
AbstractFileRoutesLoader.isValidCharForPath
private boolean isValidCharForPath(char c, boolean openedKey) { char[] invalidChars = { '?', '#', ' ' }; for (char invalidChar : invalidChars) { if (c == invalidChar) { return false; } } if (openedKey) { char[] moreInvalidChars = { '/', '{' }; for (char invalidChar : moreInvalidChars) { if (c == invalidChar) { return false; } } } return true; }
java
private boolean isValidCharForPath(char c, boolean openedKey) { char[] invalidChars = { '?', '#', ' ' }; for (char invalidChar : invalidChars) { if (c == invalidChar) { return false; } } if (openedKey) { char[] moreInvalidChars = { '/', '{' }; for (char invalidChar : moreInvalidChars) { if (c == invalidChar) { return false; } } } return true; }
[ "private", "boolean", "isValidCharForPath", "(", "char", "c", ",", "boolean", "openedKey", ")", "{", "char", "[", "]", "invalidChars", "=", "{", "'", "'", ",", "'", "'", ",", "'", "'", "}", ";", "for", "(", "char", "invalidChar", ":", "invalidChars", ")", "{", "if", "(", "c", "==", "invalidChar", ")", "{", "return", "false", ";", "}", "}", "if", "(", "openedKey", ")", "{", "char", "[", "]", "moreInvalidChars", "=", "{", "'", "'", ",", "'", "'", "}", ";", "for", "(", "char", "invalidChar", ":", "moreInvalidChars", ")", "{", "if", "(", "c", "==", "invalidChar", ")", "{", "return", "false", ";", "}", "}", "}", "return", "true", ";", "}" ]
Helper method. Tells if a char is valid in a the path of a route line. @param c the char that we are validating. @param openedKey if there is already an opened key ({) char before. @return true if the char is valid, false otherwise.
[ "Helper", "method", ".", "Tells", "if", "a", "char", "is", "valid", "in", "a", "the", "path", "of", "a", "route", "line", "." ]
d5892ff45e76328d444a68b5a38c26e7bdd0692b
https://github.com/elibom/jogger/blob/d5892ff45e76328d444a68b5a38c26e7bdd0692b/src/main/java/com/elibom/jogger/middleware/router/loader/AbstractFileRoutesLoader.java#L201-L219
144,249
elibom/jogger
src/main/java/com/elibom/jogger/util/Preconditions.java
Preconditions.notEmpty
public static void notEmpty(String value, String message) throws IllegalArgumentException { if (value == null || "".equals(value.trim())) { throw new IllegalArgumentException("A precondition failed: " + message); } }
java
public static void notEmpty(String value, String message) throws IllegalArgumentException { if (value == null || "".equals(value.trim())) { throw new IllegalArgumentException("A precondition failed: " + message); } }
[ "public", "static", "void", "notEmpty", "(", "String", "value", ",", "String", "message", ")", "throws", "IllegalArgumentException", "{", "if", "(", "value", "==", "null", "||", "\"\"", ".", "equals", "(", "value", ".", "trim", "(", ")", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"A precondition failed: \"", "+", "message", ")", ";", "}", "}" ]
Checks that a string is not null or empty. @param value the string to be tested. @param message the message for the exception in case the string is empty. @throws IllegalArgumentException if the string is empty.
[ "Checks", "that", "a", "string", "is", "not", "null", "or", "empty", "." ]
d5892ff45e76328d444a68b5a38c26e7bdd0692b
https://github.com/elibom/jogger/blob/d5892ff45e76328d444a68b5a38c26e7bdd0692b/src/main/java/com/elibom/jogger/util/Preconditions.java#L37-L41
144,250
elibom/jogger
src/main/java/com/elibom/jogger/http/AbstractRequest.java
AbstractRequest.initPathVariables
protected void initPathVariables(String routePath) { pathVariables.clear(); List<String> variables = getVariables(routePath); String regexPath = routePath.replaceAll(Path.VAR_REGEXP, Path.VAR_REPLACE); Matcher matcher = Pattern.compile("(?i)" + regexPath).matcher(getPath()); matcher.matches(); // start index at 1 as group(0) always stands for the entire expression for (int i=1; i <= variables.size(); i++) { String value = matcher.group(i); pathVariables.put(variables.get(i-1), value); } }
java
protected void initPathVariables(String routePath) { pathVariables.clear(); List<String> variables = getVariables(routePath); String regexPath = routePath.replaceAll(Path.VAR_REGEXP, Path.VAR_REPLACE); Matcher matcher = Pattern.compile("(?i)" + regexPath).matcher(getPath()); matcher.matches(); // start index at 1 as group(0) always stands for the entire expression for (int i=1; i <= variables.size(); i++) { String value = matcher.group(i); pathVariables.put(variables.get(i-1), value); } }
[ "protected", "void", "initPathVariables", "(", "String", "routePath", ")", "{", "pathVariables", ".", "clear", "(", ")", ";", "List", "<", "String", ">", "variables", "=", "getVariables", "(", "routePath", ")", ";", "String", "regexPath", "=", "routePath", ".", "replaceAll", "(", "Path", ".", "VAR_REGEXP", ",", "Path", ".", "VAR_REPLACE", ")", ";", "Matcher", "matcher", "=", "Pattern", ".", "compile", "(", "\"(?i)\"", "+", "regexPath", ")", ".", "matcher", "(", "getPath", "(", ")", ")", ";", "matcher", ".", "matches", "(", ")", ";", "// start index at 1 as group(0) always stands for the entire expression", "for", "(", "int", "i", "=", "1", ";", "i", "<=", "variables", ".", "size", "(", ")", ";", "i", "++", ")", "{", "String", "value", "=", "matcher", ".", "group", "(", "i", ")", ";", "pathVariables", ".", "put", "(", "variables", ".", "get", "(", "i", "-", "1", ")", ",", "value", ")", ";", "}", "}" ]
Helper method. Initializes the pathVariables property of this class. @param routePath the route path as defined in the routes.config file.
[ "Helper", "method", ".", "Initializes", "the", "pathVariables", "property", "of", "this", "class", "." ]
d5892ff45e76328d444a68b5a38c26e7bdd0692b
https://github.com/elibom/jogger/blob/d5892ff45e76328d444a68b5a38c26e7bdd0692b/src/main/java/com/elibom/jogger/http/AbstractRequest.java#L43-L57
144,251
elibom/jogger
src/main/java/com/elibom/jogger/http/AbstractRequest.java
AbstractRequest.getVariables
private List<String> getVariables(String routePath) { List<String> variables = new ArrayList<String>(); Matcher matcher = Pattern.compile(Path.VAR_REGEXP).matcher(routePath); while (matcher.find()) { // group(0) always stands for the entire expression and we only want what is inside the {} variables.add(matcher.group(1)); } return variables; }
java
private List<String> getVariables(String routePath) { List<String> variables = new ArrayList<String>(); Matcher matcher = Pattern.compile(Path.VAR_REGEXP).matcher(routePath); while (matcher.find()) { // group(0) always stands for the entire expression and we only want what is inside the {} variables.add(matcher.group(1)); } return variables; }
[ "private", "List", "<", "String", ">", "getVariables", "(", "String", "routePath", ")", "{", "List", "<", "String", ">", "variables", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "Matcher", "matcher", "=", "Pattern", ".", "compile", "(", "Path", ".", "VAR_REGEXP", ")", ".", "matcher", "(", "routePath", ")", ";", "while", "(", "matcher", ".", "find", "(", ")", ")", "{", "// group(0) always stands for the entire expression and we only want what is inside the {}", "variables", ".", "add", "(", "matcher", ".", "group", "(", "1", ")", ")", ";", "}", "return", "variables", ";", "}" ]
Helper method. Retrieves all the variables defined in the path. @param routePath the route path as defined in the routes.config file. @return a List object with the names of the variables.
[ "Helper", "method", ".", "Retrieves", "all", "the", "variables", "defined", "in", "the", "path", "." ]
d5892ff45e76328d444a68b5a38c26e7bdd0692b
https://github.com/elibom/jogger/blob/d5892ff45e76328d444a68b5a38c26e7bdd0692b/src/main/java/com/elibom/jogger/http/AbstractRequest.java#L66-L76
144,252
kmbulebu/dsc-it100-java
src/main/java/com/github/kmbulebu/dsc/it100/ConfigurationBuilder.java
ConfigurationBuilder.withRemoteSocket
public ConfigurationBuilder withRemoteSocket(String host, int port) { configuration.connector = new NioSocketConnector(); configuration.address = new InetSocketAddress(host, port); return this; }
java
public ConfigurationBuilder withRemoteSocket(String host, int port) { configuration.connector = new NioSocketConnector(); configuration.address = new InetSocketAddress(host, port); return this; }
[ "public", "ConfigurationBuilder", "withRemoteSocket", "(", "String", "host", ",", "int", "port", ")", "{", "configuration", ".", "connector", "=", "new", "NioSocketConnector", "(", ")", ";", "configuration", ".", "address", "=", "new", "InetSocketAddress", "(", "host", ",", "port", ")", ";", "return", "this", ";", "}" ]
Use a TCP connection for remotely connecting to the IT-100. Typically used with a utility such as ser2net for connecting to a remote serial port. @param host Hostname or IP address of the remote device. @param port TCP port of the remote device. @return This builder instance.
[ "Use", "a", "TCP", "connection", "for", "remotely", "connecting", "to", "the", "IT", "-", "100", "." ]
69c170ba50c870cce6dbbe04b488c6b1c6a0e10f
https://github.com/kmbulebu/dsc-it100-java/blob/69c170ba50c870cce6dbbe04b488c6b1c6a0e10f/src/main/java/com/github/kmbulebu/dsc/it100/ConfigurationBuilder.java#L38-L42
144,253
kmbulebu/dsc-it100-java
src/main/java/com/github/kmbulebu/dsc/it100/ConfigurationBuilder.java
ConfigurationBuilder.withSerialPort
public ConfigurationBuilder withSerialPort(String serialPort, int baudRate) { configuration.connector = new SerialConnector(); configuration.address = new SerialAddress(serialPort, baudRate, DataBits.DATABITS_8, StopBits.BITS_1, Parity.NONE, FlowControl.NONE ); return this; }
java
public ConfigurationBuilder withSerialPort(String serialPort, int baudRate) { configuration.connector = new SerialConnector(); configuration.address = new SerialAddress(serialPort, baudRate, DataBits.DATABITS_8, StopBits.BITS_1, Parity.NONE, FlowControl.NONE ); return this; }
[ "public", "ConfigurationBuilder", "withSerialPort", "(", "String", "serialPort", ",", "int", "baudRate", ")", "{", "configuration", ".", "connector", "=", "new", "SerialConnector", "(", ")", ";", "configuration", ".", "address", "=", "new", "SerialAddress", "(", "serialPort", ",", "baudRate", ",", "DataBits", ".", "DATABITS_8", ",", "StopBits", ".", "BITS_1", ",", "Parity", ".", "NONE", ",", "FlowControl", ".", "NONE", ")", ";", "return", "this", ";", "}" ]
Use a local serial port for communicating with the IT-100. @param serialPort The serial port name. (/dev/ttyUSB0, COM1:, etc). @param baudRate The baud rate to use while communicating with the IT-100. IT-100 default is 19200. @return This builder instance.
[ "Use", "a", "local", "serial", "port", "for", "communicating", "with", "the", "IT", "-", "100", "." ]
69c170ba50c870cce6dbbe04b488c6b1c6a0e10f
https://github.com/kmbulebu/dsc-it100-java/blob/69c170ba50c870cce6dbbe04b488c6b1c6a0e10f/src/main/java/com/github/kmbulebu/dsc/it100/ConfigurationBuilder.java#L50-L54
144,254
kmbulebu/dsc-it100-java
src/main/java/com/github/kmbulebu/dsc/it100/ConfigurationBuilder.java
ConfigurationBuilder.build
public Configuration build() { if (configuration.connector == null || configuration.address == null) { throw new IllegalArgumentException("You must call either withRemoteSocket or withSerialPort."); } return configuration; }
java
public Configuration build() { if (configuration.connector == null || configuration.address == null) { throw new IllegalArgumentException("You must call either withRemoteSocket or withSerialPort."); } return configuration; }
[ "public", "Configuration", "build", "(", ")", "{", "if", "(", "configuration", ".", "connector", "==", "null", "||", "configuration", ".", "address", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"You must call either withRemoteSocket or withSerialPort.\"", ")", ";", "}", "return", "configuration", ";", "}" ]
Create an immutable Configuration instance. @return Configuration Immutable configuration instance.
[ "Create", "an", "immutable", "Configuration", "instance", "." ]
69c170ba50c870cce6dbbe04b488c6b1c6a0e10f
https://github.com/kmbulebu/dsc-it100-java/blob/69c170ba50c870cce6dbbe04b488c6b1c6a0e10f/src/main/java/com/github/kmbulebu/dsc/it100/ConfigurationBuilder.java#L91-L96
144,255
btc-ag/redg
redg-generator/src/main/java/com/btc/redg/generator/extractor/DatabaseManager.java
DatabaseManager.crawlDatabase
public static Catalog crawlDatabase(final Connection connection, final InclusionRule schemaRule, final InclusionRule tableRule) throws SchemaCrawlerException { final SchemaCrawlerOptions options = SchemaCrawlerOptionsBuilder.builder() .withSchemaInfoLevel(SchemaInfoLevelBuilder.standard().setRetrieveIndexes(false)) .routineTypes(Arrays.asList(RoutineType.procedure, RoutineType.unknown)) .includeSchemas(schemaRule == null ? new IncludeAll() : schemaRule) .includeTables(tableRule == null ? new IncludeAll() : tableRule) .toOptions(); try { return SchemaCrawlerUtility.getCatalog(connection, options); } catch (SchemaCrawlerException e) { LOG.error("Schema crawling failed with exception", e); throw e; } }
java
public static Catalog crawlDatabase(final Connection connection, final InclusionRule schemaRule, final InclusionRule tableRule) throws SchemaCrawlerException { final SchemaCrawlerOptions options = SchemaCrawlerOptionsBuilder.builder() .withSchemaInfoLevel(SchemaInfoLevelBuilder.standard().setRetrieveIndexes(false)) .routineTypes(Arrays.asList(RoutineType.procedure, RoutineType.unknown)) .includeSchemas(schemaRule == null ? new IncludeAll() : schemaRule) .includeTables(tableRule == null ? new IncludeAll() : tableRule) .toOptions(); try { return SchemaCrawlerUtility.getCatalog(connection, options); } catch (SchemaCrawlerException e) { LOG.error("Schema crawling failed with exception", e); throw e; } }
[ "public", "static", "Catalog", "crawlDatabase", "(", "final", "Connection", "connection", ",", "final", "InclusionRule", "schemaRule", ",", "final", "InclusionRule", "tableRule", ")", "throws", "SchemaCrawlerException", "{", "final", "SchemaCrawlerOptions", "options", "=", "SchemaCrawlerOptionsBuilder", ".", "builder", "(", ")", ".", "withSchemaInfoLevel", "(", "SchemaInfoLevelBuilder", ".", "standard", "(", ")", ".", "setRetrieveIndexes", "(", "false", ")", ")", ".", "routineTypes", "(", "Arrays", ".", "asList", "(", "RoutineType", ".", "procedure", ",", "RoutineType", ".", "unknown", ")", ")", ".", "includeSchemas", "(", "schemaRule", "==", "null", "?", "new", "IncludeAll", "(", ")", ":", "schemaRule", ")", ".", "includeTables", "(", "tableRule", "==", "null", "?", "new", "IncludeAll", "(", ")", ":", "tableRule", ")", ".", "toOptions", "(", ")", ";", "try", "{", "return", "SchemaCrawlerUtility", ".", "getCatalog", "(", "connection", ",", "options", ")", ";", "}", "catch", "(", "SchemaCrawlerException", "e", ")", "{", "LOG", ".", "error", "(", "\"Schema crawling failed with exception\"", ",", "e", ")", ";", "throw", "e", ";", "}", "}" ]
Starts the schema crawler and lets it crawl the given JDBC connection. @param connection The JDBC connection @param schemaRule The {@link InclusionRule} to be passed to SchemaCrawler that specifies which schemas should be analyzed @param tableRule The {@link InclusionRule} to be passed to SchemaCrawler that specifies which tables should be analyzed. If a table is included by the {@code tableRule} but excluded by the {@code schemaRule} it will not be analyzed. @return The populated {@link Catalog} object containing the metadata for the extractor @throws SchemaCrawlerException Gets thrown when the database could not be crawled successfully
[ "Starts", "the", "schema", "crawler", "and", "lets", "it", "crawl", "the", "given", "JDBC", "connection", "." ]
416a68639d002512cabfebff09afd2e1909e27df
https://github.com/btc-ag/redg/blob/416a68639d002512cabfebff09afd2e1909e27df/redg-generator/src/main/java/com/btc/redg/generator/extractor/DatabaseManager.java#L146-L160
144,256
btc-ag/redg
redg-generator/src/main/java/com/btc/redg/generator/CodeGenerator.java
CodeGenerator.generateMainClass
public String generateMainClass(final Collection<TableModel> tables, final boolean enableVisualizationSupport) { Objects.requireNonNull(tables); //get package from the table models final String targetPackage = ((TableModel) tables.toArray()[0]).getPackageName(); final ST template = this.stGroup.getInstanceOf("mainClass"); LOG.debug("Filling main class template containing helpers for {} classes...", tables.size()); template.add("package", targetPackage); // TODO: make prefix usable template.add("prefix", ""); template.add("enableVisualizationSupport", enableVisualizationSupport); LOG.debug("Package is {} | Prefix is {}", targetPackage, ""); template.add("tables", tables); return template.render(); }
java
public String generateMainClass(final Collection<TableModel> tables, final boolean enableVisualizationSupport) { Objects.requireNonNull(tables); //get package from the table models final String targetPackage = ((TableModel) tables.toArray()[0]).getPackageName(); final ST template = this.stGroup.getInstanceOf("mainClass"); LOG.debug("Filling main class template containing helpers for {} classes...", tables.size()); template.add("package", targetPackage); // TODO: make prefix usable template.add("prefix", ""); template.add("enableVisualizationSupport", enableVisualizationSupport); LOG.debug("Package is {} | Prefix is {}", targetPackage, ""); template.add("tables", tables); return template.render(); }
[ "public", "String", "generateMainClass", "(", "final", "Collection", "<", "TableModel", ">", "tables", ",", "final", "boolean", "enableVisualizationSupport", ")", "{", "Objects", ".", "requireNonNull", "(", "tables", ")", ";", "//get package from the table models\r", "final", "String", "targetPackage", "=", "(", "(", "TableModel", ")", "tables", ".", "toArray", "(", ")", "[", "0", "]", ")", ".", "getPackageName", "(", ")", ";", "final", "ST", "template", "=", "this", ".", "stGroup", ".", "getInstanceOf", "(", "\"mainClass\"", ")", ";", "LOG", ".", "debug", "(", "\"Filling main class template containing helpers for {} classes...\"", ",", "tables", ".", "size", "(", ")", ")", ";", "template", ".", "add", "(", "\"package\"", ",", "targetPackage", ")", ";", "// TODO: make prefix usable\r", "template", ".", "add", "(", "\"prefix\"", ",", "\"\"", ")", ";", "template", ".", "add", "(", "\"enableVisualizationSupport\"", ",", "enableVisualizationSupport", ")", ";", "LOG", ".", "debug", "(", "\"Package is {} | Prefix is {}\"", ",", "targetPackage", ",", "\"\"", ")", ";", "template", ".", "add", "(", "\"tables\"", ",", "tables", ")", ";", "return", "template", ".", "render", "(", ")", ";", "}" ]
Generates the main class used for creating the extractor objects and later generating the insert statements. For each passed table a appropriate creation method will be generated that will return the new object and internally add it to the list of objects that will be used to generate the insert strings @param tables All tables that should get a creation method in the main class @param enableVisualizationSupport If {@code true}, the RedG visualization features will be enabled for the generated code. This will result in a small performance hit and slightly more memory usage if activated. @return The generated source code
[ "Generates", "the", "main", "class", "used", "for", "creating", "the", "extractor", "objects", "and", "later", "generating", "the", "insert", "statements", ".", "For", "each", "passed", "table", "a", "appropriate", "creation", "method", "will", "be", "generated", "that", "will", "return", "the", "new", "object", "and", "internally", "add", "it", "to", "the", "list", "of", "objects", "that", "will", "be", "used", "to", "generate", "the", "insert", "strings" ]
416a68639d002512cabfebff09afd2e1909e27df
https://github.com/btc-ag/redg/blob/416a68639d002512cabfebff09afd2e1909e27df/redg-generator/src/main/java/com/btc/redg/generator/CodeGenerator.java#L223-L239
144,257
btc-ag/redg
redg-runtime/src/main/java/com/btc/redg/runtime/RedGBuilder.java
RedGBuilder.withDefaultValueStrategy
public RedGBuilder<T> withDefaultValueStrategy(final DefaultValueStrategy strategy) { if (instance == null) { throw new IllegalStateException("Using the builder after build() was called is not allowed!"); } instance.setDefaultValueStrategy(strategy); return this; }
java
public RedGBuilder<T> withDefaultValueStrategy(final DefaultValueStrategy strategy) { if (instance == null) { throw new IllegalStateException("Using the builder after build() was called is not allowed!"); } instance.setDefaultValueStrategy(strategy); return this; }
[ "public", "RedGBuilder", "<", "T", ">", "withDefaultValueStrategy", "(", "final", "DefaultValueStrategy", "strategy", ")", "{", "if", "(", "instance", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Using the builder after build() was called is not allowed!\"", ")", ";", "}", "instance", ".", "setDefaultValueStrategy", "(", "strategy", ")", ";", "return", "this", ";", "}" ]
Sets the default value strategy @param strategy The default value strategy @return The builder itself @see AbstractRedG#setDefaultValueStrategy(DefaultValueStrategy)
[ "Sets", "the", "default", "value", "strategy" ]
416a68639d002512cabfebff09afd2e1909e27df
https://github.com/btc-ag/redg/blob/416a68639d002512cabfebff09afd2e1909e27df/redg-runtime/src/main/java/com/btc/redg/runtime/RedGBuilder.java#L70-L76
144,258
btc-ag/redg
redg-runtime/src/main/java/com/btc/redg/runtime/RedGBuilder.java
RedGBuilder.withPreparedStatementParameterSetter
public RedGBuilder<T> withPreparedStatementParameterSetter(final PreparedStatementParameterSetter setter) { if (instance == null) { throw new IllegalStateException("Using the builder after build() was called is not allowed!"); } instance.setPreparedStatementParameterSetter(setter); return this; }
java
public RedGBuilder<T> withPreparedStatementParameterSetter(final PreparedStatementParameterSetter setter) { if (instance == null) { throw new IllegalStateException("Using the builder after build() was called is not allowed!"); } instance.setPreparedStatementParameterSetter(setter); return this; }
[ "public", "RedGBuilder", "<", "T", ">", "withPreparedStatementParameterSetter", "(", "final", "PreparedStatementParameterSetter", "setter", ")", "{", "if", "(", "instance", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Using the builder after build() was called is not allowed!\"", ")", ";", "}", "instance", ".", "setPreparedStatementParameterSetter", "(", "setter", ")", ";", "return", "this", ";", "}" ]
Sets the PreparedStatement parameter setter @param setter The PreparedStatement parameter setter @return The builder itself @see AbstractRedG#setPreparedStatementParameterSetter(PreparedStatementParameterSetter)
[ "Sets", "the", "PreparedStatement", "parameter", "setter" ]
416a68639d002512cabfebff09afd2e1909e27df
https://github.com/btc-ag/redg/blob/416a68639d002512cabfebff09afd2e1909e27df/redg-runtime/src/main/java/com/btc/redg/runtime/RedGBuilder.java#L84-L90
144,259
btc-ag/redg
redg-runtime/src/main/java/com/btc/redg/runtime/RedGBuilder.java
RedGBuilder.withSqlValuesFormatter
public RedGBuilder<T> withSqlValuesFormatter(final SQLValuesFormatter formatter) { if (instance == null) { throw new IllegalStateException("Using the builder after build() was called is not allowed!"); } instance.setSqlValuesFormatter(formatter); return this; }
java
public RedGBuilder<T> withSqlValuesFormatter(final SQLValuesFormatter formatter) { if (instance == null) { throw new IllegalStateException("Using the builder after build() was called is not allowed!"); } instance.setSqlValuesFormatter(formatter); return this; }
[ "public", "RedGBuilder", "<", "T", ">", "withSqlValuesFormatter", "(", "final", "SQLValuesFormatter", "formatter", ")", "{", "if", "(", "instance", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Using the builder after build() was called is not allowed!\"", ")", ";", "}", "instance", ".", "setSqlValuesFormatter", "(", "formatter", ")", ";", "return", "this", ";", "}" ]
Sets the SQL values formatter @param formatter The SQL values formatter @return The builder itself @see AbstractRedG#setSqlValuesFormatter(SQLValuesFormatter)
[ "Sets", "the", "SQL", "values", "formatter" ]
416a68639d002512cabfebff09afd2e1909e27df
https://github.com/btc-ag/redg/blob/416a68639d002512cabfebff09afd2e1909e27df/redg-runtime/src/main/java/com/btc/redg/runtime/RedGBuilder.java#L98-L104
144,260
btc-ag/redg
redg-runtime/src/main/java/com/btc/redg/runtime/RedGBuilder.java
RedGBuilder.withDummyFactory
public RedGBuilder<T> withDummyFactory(final DummyFactory dummyFactory) { if (instance == null) { throw new IllegalStateException("Using the builder after build() was called is not allowed!"); } instance.setDummyFactory(dummyFactory); return this; }
java
public RedGBuilder<T> withDummyFactory(final DummyFactory dummyFactory) { if (instance == null) { throw new IllegalStateException("Using the builder after build() was called is not allowed!"); } instance.setDummyFactory(dummyFactory); return this; }
[ "public", "RedGBuilder", "<", "T", ">", "withDummyFactory", "(", "final", "DummyFactory", "dummyFactory", ")", "{", "if", "(", "instance", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Using the builder after build() was called is not allowed!\"", ")", ";", "}", "instance", ".", "setDummyFactory", "(", "dummyFactory", ")", ";", "return", "this", ";", "}" ]
Sets the dummy factory @param dummyFactory The dummy factory @return The builder itself @see AbstractRedG#setDummyFactory(DummyFactory)
[ "Sets", "the", "dummy", "factory" ]
416a68639d002512cabfebff09afd2e1909e27df
https://github.com/btc-ag/redg/blob/416a68639d002512cabfebff09afd2e1909e27df/redg-runtime/src/main/java/com/btc/redg/runtime/RedGBuilder.java#L112-L118
144,261
elibom/jogger
src/main/java/com/elibom/jogger/http/servlet/multipart/ParameterParser.java
ParameterParser.isOneOf
private boolean isOneOf(char ch, final char[] charray) { boolean result = false; for (int i = 0; i < charray.length; i++) { if (ch == charray[i]) { result = true; break; } } return result; }
java
private boolean isOneOf(char ch, final char[] charray) { boolean result = false; for (int i = 0; i < charray.length; i++) { if (ch == charray[i]) { result = true; break; } } return result; }
[ "private", "boolean", "isOneOf", "(", "char", "ch", ",", "final", "char", "[", "]", "charray", ")", "{", "boolean", "result", "=", "false", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "charray", ".", "length", ";", "i", "++", ")", "{", "if", "(", "ch", "==", "charray", "[", "i", "]", ")", "{", "result", "=", "true", ";", "break", ";", "}", "}", "return", "result", ";", "}" ]
Tests if the given character is present in the array of characters. @param ch the character to test for presense in the array of characters @param charray the array of characters to test against @return <tt>true</tt> if the character is present in the array of characters, <tt>false</tt> otherwise.
[ "Tests", "if", "the", "given", "character", "is", "present", "in", "the", "array", "of", "characters", "." ]
d5892ff45e76328d444a68b5a38c26e7bdd0692b
https://github.com/elibom/jogger/blob/d5892ff45e76328d444a68b5a38c26e7bdd0692b/src/main/java/com/elibom/jogger/http/servlet/multipart/ParameterParser.java#L115-L124
144,262
elibom/jogger
src/main/java/com/elibom/jogger/Environment.java
Environment.get
public static String get() { String env = System.getProperty("JOGGER_ENV"); if (env == null) { env = System.getenv("JOGGER_ENV"); } if (env == null) { return "dev"; } return env; }
java
public static String get() { String env = System.getProperty("JOGGER_ENV"); if (env == null) { env = System.getenv("JOGGER_ENV"); } if (env == null) { return "dev"; } return env; }
[ "public", "static", "String", "get", "(", ")", "{", "String", "env", "=", "System", ".", "getProperty", "(", "\"JOGGER_ENV\"", ")", ";", "if", "(", "env", "==", "null", ")", "{", "env", "=", "System", ".", "getenv", "(", "\"JOGGER_ENV\"", ")", ";", "}", "if", "(", "env", "==", "null", ")", "{", "return", "\"dev\"", ";", "}", "return", "env", ";", "}" ]
Retrieves the environment in which Jogger is working. @return a String object representing the environment.
[ "Retrieves", "the", "environment", "in", "which", "Jogger", "is", "working", "." ]
d5892ff45e76328d444a68b5a38c26e7bdd0692b
https://github.com/elibom/jogger/blob/d5892ff45e76328d444a68b5a38c26e7bdd0692b/src/main/java/com/elibom/jogger/Environment.java#L19-L30
144,263
btc-ag/redg
redg-runtime/src/main/java/com/btc/redg/runtime/AbstractRedG.java
AbstractRedG.generateSQLStatements
public List<String> generateSQLStatements() { return getEntitiesSortedForInsert().stream() .map(RedGEntity::getSQLString) .collect(Collectors.toList()); }
java
public List<String> generateSQLStatements() { return getEntitiesSortedForInsert().stream() .map(RedGEntity::getSQLString) .collect(Collectors.toList()); }
[ "public", "List", "<", "String", ">", "generateSQLStatements", "(", ")", "{", "return", "getEntitiesSortedForInsert", "(", ")", ".", "stream", "(", ")", ".", "map", "(", "RedGEntity", "::", "getSQLString", ")", ".", "collect", "(", "Collectors", ".", "toList", "(", ")", ")", ";", "}" ]
Returns a list of insert statements, one for each added entity in the respective order they were added. @return The SQL Insert strings
[ "Returns", "a", "list", "of", "insert", "statements", "one", "for", "each", "added", "entity", "in", "the", "respective", "order", "they", "were", "added", "." ]
416a68639d002512cabfebff09afd2e1909e27df
https://github.com/btc-ag/redg/blob/416a68639d002512cabfebff09afd2e1909e27df/redg-runtime/src/main/java/com/btc/redg/runtime/AbstractRedG.java#L169-L173
144,264
btc-ag/redg
redg-generator/src/main/java/com/btc/redg/generator/extractor/nameprovider/DefaultNameProvider.java
DefaultNameProvider.getMethodNameForReference
@Override public String getMethodNameForReference(final ForeignKey foreignKey) { final Column c = foreignKey.getColumnReferences().get(0).getForeignKeyColumn(); // check if only one-column fk if (foreignKey.getColumnReferences().size() == 1) { return getMethodNameForColumn(c) + getClassNameForTable(c.getReferencedColumn().getParent()); } final StringBuilder nameBuilder = new StringBuilder(); final List<String> words = new ArrayList<>(Arrays.asList(foreignKey.getName() .toLowerCase() .replaceAll("(^[0-9]+|[^a-z0-9_-])", "") // Delete every not-alphanumeric or _/- character and numbers at beginning .split("_"))); words.removeAll(Arrays.asList("fk", "", null)); // removes FK_ prefix and empty entries final List<String> tableWords = new ArrayList<>(Arrays.asList(c.getParent().getName() .toLowerCase() .replaceAll("(^[0-9]+|[^a-z0-9_-])", "") // Delete every not-alphanumeric or _/- character and numbers at beginning .split("_"))); words.removeAll(tableWords); nameBuilder.append(words.get(0)); for (int i = 1; i < words.size(); i++) { String word = words.get(i); nameBuilder.append(word.substring(0, 1).toUpperCase()); nameBuilder.append(word.substring(1)); } return nameBuilder.toString(); }
java
@Override public String getMethodNameForReference(final ForeignKey foreignKey) { final Column c = foreignKey.getColumnReferences().get(0).getForeignKeyColumn(); // check if only one-column fk if (foreignKey.getColumnReferences().size() == 1) { return getMethodNameForColumn(c) + getClassNameForTable(c.getReferencedColumn().getParent()); } final StringBuilder nameBuilder = new StringBuilder(); final List<String> words = new ArrayList<>(Arrays.asList(foreignKey.getName() .toLowerCase() .replaceAll("(^[0-9]+|[^a-z0-9_-])", "") // Delete every not-alphanumeric or _/- character and numbers at beginning .split("_"))); words.removeAll(Arrays.asList("fk", "", null)); // removes FK_ prefix and empty entries final List<String> tableWords = new ArrayList<>(Arrays.asList(c.getParent().getName() .toLowerCase() .replaceAll("(^[0-9]+|[^a-z0-9_-])", "") // Delete every not-alphanumeric or _/- character and numbers at beginning .split("_"))); words.removeAll(tableWords); nameBuilder.append(words.get(0)); for (int i = 1; i < words.size(); i++) { String word = words.get(i); nameBuilder.append(word.substring(0, 1).toUpperCase()); nameBuilder.append(word.substring(1)); } return nameBuilder.toString(); }
[ "@", "Override", "public", "String", "getMethodNameForReference", "(", "final", "ForeignKey", "foreignKey", ")", "{", "final", "Column", "c", "=", "foreignKey", ".", "getColumnReferences", "(", ")", ".", "get", "(", "0", ")", ".", "getForeignKeyColumn", "(", ")", ";", "// check if only one-column fk\r", "if", "(", "foreignKey", ".", "getColumnReferences", "(", ")", ".", "size", "(", ")", "==", "1", ")", "{", "return", "getMethodNameForColumn", "(", "c", ")", "+", "getClassNameForTable", "(", "c", ".", "getReferencedColumn", "(", ")", ".", "getParent", "(", ")", ")", ";", "}", "final", "StringBuilder", "nameBuilder", "=", "new", "StringBuilder", "(", ")", ";", "final", "List", "<", "String", ">", "words", "=", "new", "ArrayList", "<>", "(", "Arrays", ".", "asList", "(", "foreignKey", ".", "getName", "(", ")", ".", "toLowerCase", "(", ")", ".", "replaceAll", "(", "\"(^[0-9]+|[^a-z0-9_-])\"", ",", "\"\"", ")", "// Delete every not-alphanumeric or _/- character and numbers at beginning\r", ".", "split", "(", "\"_\"", ")", ")", ")", ";", "words", ".", "removeAll", "(", "Arrays", ".", "asList", "(", "\"fk\"", ",", "\"\"", ",", "null", ")", ")", ";", "// removes FK_ prefix and empty entries\r", "final", "List", "<", "String", ">", "tableWords", "=", "new", "ArrayList", "<>", "(", "Arrays", ".", "asList", "(", "c", ".", "getParent", "(", ")", ".", "getName", "(", ")", ".", "toLowerCase", "(", ")", ".", "replaceAll", "(", "\"(^[0-9]+|[^a-z0-9_-])\"", ",", "\"\"", ")", "// Delete every not-alphanumeric or _/- character and numbers at beginning\r", ".", "split", "(", "\"_\"", ")", ")", ")", ";", "words", ".", "removeAll", "(", "tableWords", ")", ";", "nameBuilder", ".", "append", "(", "words", ".", "get", "(", "0", ")", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "words", ".", "size", "(", ")", ";", "i", "++", ")", "{", "String", "word", "=", "words", ".", "get", "(", "i", ")", ";", "nameBuilder", ".", "append", "(", "word", ".", "substring", "(", "0", ",", "1", ")", ".", "toUpperCase", "(", ")", ")", ";", "nameBuilder", ".", "append", "(", "word", ".", "substring", "(", "1", ")", ")", ";", "}", "return", "nameBuilder", ".", "toString", "(", ")", ";", "}" ]
Generates an appropriate method name for a foreign key @param foreignKey The database foreign key @return The generated name
[ "Generates", "an", "appropriate", "method", "name", "for", "a", "foreign", "key" ]
416a68639d002512cabfebff09afd2e1909e27df
https://github.com/btc-ag/redg/blob/416a68639d002512cabfebff09afd2e1909e27df/redg-generator/src/main/java/com/btc/redg/generator/extractor/nameprovider/DefaultNameProvider.java#L97-L124
144,265
elibom/jogger
src/main/java/com/elibom/jogger/Jogger.java
Jogger.handle
public void handle(Request request, Response response) throws Exception { if (Environment.isDevelopment()) { this.middlewares = this.middlewareFactory.create(); } try { handle(request, response, new ArrayList<Middleware>(Arrays.asList(middlewares))); } catch (Exception e) { if (exceptionHandler != null) { exceptionHandler.handle(e, request, response); } else { throw e; } } }
java
public void handle(Request request, Response response) throws Exception { if (Environment.isDevelopment()) { this.middlewares = this.middlewareFactory.create(); } try { handle(request, response, new ArrayList<Middleware>(Arrays.asList(middlewares))); } catch (Exception e) { if (exceptionHandler != null) { exceptionHandler.handle(e, request, response); } else { throw e; } } }
[ "public", "void", "handle", "(", "Request", "request", ",", "Response", "response", ")", "throws", "Exception", "{", "if", "(", "Environment", ".", "isDevelopment", "(", ")", ")", "{", "this", ".", "middlewares", "=", "this", ".", "middlewareFactory", ".", "create", "(", ")", ";", "}", "try", "{", "handle", "(", "request", ",", "response", ",", "new", "ArrayList", "<", "Middleware", ">", "(", "Arrays", ".", "asList", "(", "middlewares", ")", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "if", "(", "exceptionHandler", "!=", "null", ")", "{", "exceptionHandler", ".", "handle", "(", "e", ",", "request", ",", "response", ")", ";", "}", "else", "{", "throw", "e", ";", "}", "}", "}" ]
Handles an HTTP request by delgating the call to the middlewares. @param request the Jogger HTTP request. @param response the Jogger HTTP response. @throws Exception
[ "Handles", "an", "HTTP", "request", "by", "delgating", "the", "call", "to", "the", "middlewares", "." ]
d5892ff45e76328d444a68b5a38c26e7bdd0692b
https://github.com/elibom/jogger/blob/d5892ff45e76328d444a68b5a38c26e7bdd0692b/src/main/java/com/elibom/jogger/Jogger.java#L107-L121
144,266
mesosphere/mesos-http-adapter
src/main/java/com/mesosphere/mesos/http-adapter/MesosToSchedulerDriverAdapter.java
MesosToSchedulerDriverAdapter.performReliableSubscription
private synchronized void performReliableSubscription() { // If timer is not running, initialize it. if (subscriberTimer == null) { LOGGER.info("Initializing reliable subscriber"); subscriberTimer = createTimerInternal(); ExponentialBackOff backOff = new ExponentialBackOff.Builder() .setMaxElapsedTimeMillis(Integer.MAX_VALUE /* Try forever */) .setMaxIntervalMillis(MAX_BACKOFF_MS) .setMultiplier(MULTIPLIER) .setRandomizationFactor(0.5) .setInitialIntervalMillis(SEED_BACKOFF_MS) .build(); subscriberTimer.schedule(new SubscriberTask(backOff), SEED_BACKOFF_MS, TimeUnit.MILLISECONDS); } }
java
private synchronized void performReliableSubscription() { // If timer is not running, initialize it. if (subscriberTimer == null) { LOGGER.info("Initializing reliable subscriber"); subscriberTimer = createTimerInternal(); ExponentialBackOff backOff = new ExponentialBackOff.Builder() .setMaxElapsedTimeMillis(Integer.MAX_VALUE /* Try forever */) .setMaxIntervalMillis(MAX_BACKOFF_MS) .setMultiplier(MULTIPLIER) .setRandomizationFactor(0.5) .setInitialIntervalMillis(SEED_BACKOFF_MS) .build(); subscriberTimer.schedule(new SubscriberTask(backOff), SEED_BACKOFF_MS, TimeUnit.MILLISECONDS); } }
[ "private", "synchronized", "void", "performReliableSubscription", "(", ")", "{", "// If timer is not running, initialize it.", "if", "(", "subscriberTimer", "==", "null", ")", "{", "LOGGER", ".", "info", "(", "\"Initializing reliable subscriber\"", ")", ";", "subscriberTimer", "=", "createTimerInternal", "(", ")", ";", "ExponentialBackOff", "backOff", "=", "new", "ExponentialBackOff", ".", "Builder", "(", ")", ".", "setMaxElapsedTimeMillis", "(", "Integer", ".", "MAX_VALUE", "/* Try forever */", ")", ".", "setMaxIntervalMillis", "(", "MAX_BACKOFF_MS", ")", ".", "setMultiplier", "(", "MULTIPLIER", ")", ".", "setRandomizationFactor", "(", "0.5", ")", ".", "setInitialIntervalMillis", "(", "SEED_BACKOFF_MS", ")", ".", "build", "(", ")", ";", "subscriberTimer", ".", "schedule", "(", "new", "SubscriberTask", "(", "backOff", ")", ",", "SEED_BACKOFF_MS", ",", "TimeUnit", ".", "MILLISECONDS", ")", ";", "}", "}" ]
Task that performs Subscription.
[ "Task", "that", "performs", "Subscription", "." ]
5965d467c86ce7a1092bda5624dd2da9b0776334
https://github.com/mesosphere/mesos-http-adapter/blob/5965d467c86ce7a1092bda5624dd2da9b0776334/src/main/java/com/mesosphere/mesos/http-adapter/MesosToSchedulerDriverAdapter.java#L141-L155
144,267
mesosphere/mesos-http-adapter
src/main/java/com/mesosphere/mesos/http-adapter/MesosToSchedulerDriverAdapter.java
MesosToSchedulerDriverAdapter.startInternal
@VisibleForTesting protected Mesos startInternal() { String version = System.getenv("MESOS_API_VERSION"); if (version == null) { version = "V0"; } LOGGER.info("Using Mesos API version: {}", version); if (version.equals("V0")) { if (credential == null) { return new V0Mesos(this, frameworkInfo, master); } else { return new V0Mesos(this, frameworkInfo, master, credential); } } else if (version.equals("V1")) { if (credential == null) { return new V1Mesos(this, master); } else { return new V1Mesos(this, master, credential); } } else { throw new IllegalArgumentException("Unsupported API version: " + version); } }
java
@VisibleForTesting protected Mesos startInternal() { String version = System.getenv("MESOS_API_VERSION"); if (version == null) { version = "V0"; } LOGGER.info("Using Mesos API version: {}", version); if (version.equals("V0")) { if (credential == null) { return new V0Mesos(this, frameworkInfo, master); } else { return new V0Mesos(this, frameworkInfo, master, credential); } } else if (version.equals("V1")) { if (credential == null) { return new V1Mesos(this, master); } else { return new V1Mesos(this, master, credential); } } else { throw new IllegalArgumentException("Unsupported API version: " + version); } }
[ "@", "VisibleForTesting", "protected", "Mesos", "startInternal", "(", ")", "{", "String", "version", "=", "System", ".", "getenv", "(", "\"MESOS_API_VERSION\"", ")", ";", "if", "(", "version", "==", "null", ")", "{", "version", "=", "\"V0\"", ";", "}", "LOGGER", ".", "info", "(", "\"Using Mesos API version: {}\"", ",", "version", ")", ";", "if", "(", "version", ".", "equals", "(", "\"V0\"", ")", ")", "{", "if", "(", "credential", "==", "null", ")", "{", "return", "new", "V0Mesos", "(", "this", ",", "frameworkInfo", ",", "master", ")", ";", "}", "else", "{", "return", "new", "V0Mesos", "(", "this", ",", "frameworkInfo", ",", "master", ",", "credential", ")", ";", "}", "}", "else", "if", "(", "version", ".", "equals", "(", "\"V1\"", ")", ")", "{", "if", "(", "credential", "==", "null", ")", "{", "return", "new", "V1Mesos", "(", "this", ",", "master", ")", ";", "}", "else", "{", "return", "new", "V1Mesos", "(", "this", ",", "master", ",", "credential", ")", ";", "}", "}", "else", "{", "throw", "new", "IllegalArgumentException", "(", "\"Unsupported API version: \"", "+", "version", ")", ";", "}", "}" ]
Broken out into a separate function to allow testing with custom `Mesos` implementations.
[ "Broken", "out", "into", "a", "separate", "function", "to", "allow", "testing", "with", "custom", "Mesos", "implementations", "." ]
5965d467c86ce7a1092bda5624dd2da9b0776334
https://github.com/mesosphere/mesos-http-adapter/blob/5965d467c86ce7a1092bda5624dd2da9b0776334/src/main/java/com/mesosphere/mesos/http-adapter/MesosToSchedulerDriverAdapter.java#L314-L338
144,268
btc-ag/redg
redg-generator/src/main/java/com/btc/redg/generator/extractor/TableExtractor.java
TableExtractor.extractTableModel
public TableModel extractTableModel(final Table table) { Objects.requireNonNull(table); final TableModel model = new TableModel(); model.setClassName(this.classPrefix + this.nameProvider.getClassNameForTable(table)); model.setName(this.nameProvider.getClassNameForTable(table)); model.setSqlFullName(table.getFullName()); model.setSqlName(table.getName()); model.setPackageName(this.targetPackage); model.setColumns(table.getColumns().stream() //.filter(c -> !c.isPartOfForeignKey()) // no longer filter due to #12 .map(this.columnExtractor::extractColumnModel) .collect(Collectors.toList())); Set<Set<String>> seenForeignKeyColumnNameTuples = new HashSet<>(); // TODO unit test removing duplicates model.setForeignKeys(table.getImportedForeignKeys().stream() // only get data about "outgoing" foreign keys .filter(foreignKeyColumnReferences -> { Set<String> foreignKeyColumnNames = foreignKeyColumnReferences.getColumnReferences().stream() .map(foreignKeyColumnReference -> foreignKeyColumnReference.getForeignKeyColumn().getFullName()) .collect(Collectors.toSet()); return seenForeignKeyColumnNameTuples.add(foreignKeyColumnNames); }) .map(this.foreignKeyExtractor::extractForeignKeyModel) .collect(Collectors.toList())); Set<Set<String>> seenForeignKeyColumnNameTuples2 = new HashSet<>(); // TODO unit test removing duplicates model.setIncomingForeignKeys(table.getExportedForeignKeys().stream() .filter(foreignKeyColumnReferences -> { Set<String> foreignKeyColumnNames = foreignKeyColumnReferences.getColumnReferences().stream() .map(foreignKeyColumnReference -> foreignKeyColumnReference.getForeignKeyColumn().getFullName()) .collect(Collectors.toSet()); return seenForeignKeyColumnNameTuples2.add(foreignKeyColumnNames); }) .map(this.foreignKeyExtractor::extractIncomingForeignKeyModel) .collect(Collectors.toList())); model.setHasColumnsAndForeignKeys(!model.getNonForeignKeyColumns().isEmpty() && !model.getForeignKeys().isEmpty()); return model; }
java
public TableModel extractTableModel(final Table table) { Objects.requireNonNull(table); final TableModel model = new TableModel(); model.setClassName(this.classPrefix + this.nameProvider.getClassNameForTable(table)); model.setName(this.nameProvider.getClassNameForTable(table)); model.setSqlFullName(table.getFullName()); model.setSqlName(table.getName()); model.setPackageName(this.targetPackage); model.setColumns(table.getColumns().stream() //.filter(c -> !c.isPartOfForeignKey()) // no longer filter due to #12 .map(this.columnExtractor::extractColumnModel) .collect(Collectors.toList())); Set<Set<String>> seenForeignKeyColumnNameTuples = new HashSet<>(); // TODO unit test removing duplicates model.setForeignKeys(table.getImportedForeignKeys().stream() // only get data about "outgoing" foreign keys .filter(foreignKeyColumnReferences -> { Set<String> foreignKeyColumnNames = foreignKeyColumnReferences.getColumnReferences().stream() .map(foreignKeyColumnReference -> foreignKeyColumnReference.getForeignKeyColumn().getFullName()) .collect(Collectors.toSet()); return seenForeignKeyColumnNameTuples.add(foreignKeyColumnNames); }) .map(this.foreignKeyExtractor::extractForeignKeyModel) .collect(Collectors.toList())); Set<Set<String>> seenForeignKeyColumnNameTuples2 = new HashSet<>(); // TODO unit test removing duplicates model.setIncomingForeignKeys(table.getExportedForeignKeys().stream() .filter(foreignKeyColumnReferences -> { Set<String> foreignKeyColumnNames = foreignKeyColumnReferences.getColumnReferences().stream() .map(foreignKeyColumnReference -> foreignKeyColumnReference.getForeignKeyColumn().getFullName()) .collect(Collectors.toSet()); return seenForeignKeyColumnNameTuples2.add(foreignKeyColumnNames); }) .map(this.foreignKeyExtractor::extractIncomingForeignKeyModel) .collect(Collectors.toList())); model.setHasColumnsAndForeignKeys(!model.getNonForeignKeyColumns().isEmpty() && !model.getForeignKeys().isEmpty()); return model; }
[ "public", "TableModel", "extractTableModel", "(", "final", "Table", "table", ")", "{", "Objects", ".", "requireNonNull", "(", "table", ")", ";", "final", "TableModel", "model", "=", "new", "TableModel", "(", ")", ";", "model", ".", "setClassName", "(", "this", ".", "classPrefix", "+", "this", ".", "nameProvider", ".", "getClassNameForTable", "(", "table", ")", ")", ";", "model", ".", "setName", "(", "this", ".", "nameProvider", ".", "getClassNameForTable", "(", "table", ")", ")", ";", "model", ".", "setSqlFullName", "(", "table", ".", "getFullName", "(", ")", ")", ";", "model", ".", "setSqlName", "(", "table", ".", "getName", "(", ")", ")", ";", "model", ".", "setPackageName", "(", "this", ".", "targetPackage", ")", ";", "model", ".", "setColumns", "(", "table", ".", "getColumns", "(", ")", ".", "stream", "(", ")", "//.filter(c -> !c.isPartOfForeignKey()) // no longer filter due to #12\r", ".", "map", "(", "this", ".", "columnExtractor", "::", "extractColumnModel", ")", ".", "collect", "(", "Collectors", ".", "toList", "(", ")", ")", ")", ";", "Set", "<", "Set", "<", "String", ">", ">", "seenForeignKeyColumnNameTuples", "=", "new", "HashSet", "<>", "(", ")", ";", "// TODO unit test removing duplicates\r", "model", ".", "setForeignKeys", "(", "table", ".", "getImportedForeignKeys", "(", ")", ".", "stream", "(", ")", "// only get data about \"outgoing\" foreign keys\r", ".", "filter", "(", "foreignKeyColumnReferences", "->", "{", "Set", "<", "String", ">", "foreignKeyColumnNames", "=", "foreignKeyColumnReferences", ".", "getColumnReferences", "(", ")", ".", "stream", "(", ")", ".", "map", "(", "foreignKeyColumnReference", "->", "foreignKeyColumnReference", ".", "getForeignKeyColumn", "(", ")", ".", "getFullName", "(", ")", ")", ".", "collect", "(", "Collectors", ".", "toSet", "(", ")", ")", ";", "return", "seenForeignKeyColumnNameTuples", ".", "add", "(", "foreignKeyColumnNames", ")", ";", "}", ")", ".", "map", "(", "this", ".", "foreignKeyExtractor", "::", "extractForeignKeyModel", ")", ".", "collect", "(", "Collectors", ".", "toList", "(", ")", ")", ")", ";", "Set", "<", "Set", "<", "String", ">", ">", "seenForeignKeyColumnNameTuples2", "=", "new", "HashSet", "<>", "(", ")", ";", "// TODO unit test removing duplicates\r", "model", ".", "setIncomingForeignKeys", "(", "table", ".", "getExportedForeignKeys", "(", ")", ".", "stream", "(", ")", ".", "filter", "(", "foreignKeyColumnReferences", "->", "{", "Set", "<", "String", ">", "foreignKeyColumnNames", "=", "foreignKeyColumnReferences", ".", "getColumnReferences", "(", ")", ".", "stream", "(", ")", ".", "map", "(", "foreignKeyColumnReference", "->", "foreignKeyColumnReference", ".", "getForeignKeyColumn", "(", ")", ".", "getFullName", "(", ")", ")", ".", "collect", "(", "Collectors", ".", "toSet", "(", ")", ")", ";", "return", "seenForeignKeyColumnNameTuples2", ".", "add", "(", "foreignKeyColumnNames", ")", ";", "}", ")", ".", "map", "(", "this", ".", "foreignKeyExtractor", "::", "extractIncomingForeignKeyModel", ")", ".", "collect", "(", "Collectors", ".", "toList", "(", ")", ")", ")", ";", "model", ".", "setHasColumnsAndForeignKeys", "(", "!", "model", ".", "getNonForeignKeyColumns", "(", ")", ".", "isEmpty", "(", ")", "&&", "!", "model", ".", "getForeignKeys", "(", ")", ".", "isEmpty", "(", ")", ")", ";", "return", "model", ";", "}" ]
Extracts the table model from a single table. Every table this table references via foreign keys must be fully loaded, otherwise an exception will be thrown. @param table The table to extract the model from @return The extracted model with all information needed for code generation
[ "Extracts", "the", "table", "model", "from", "a", "single", "table", ".", "Every", "table", "this", "table", "references", "via", "foreign", "keys", "must", "be", "fully", "loaded", "otherwise", "an", "exception", "will", "be", "thrown", "." ]
416a68639d002512cabfebff09afd2e1909e27df
https://github.com/btc-ag/redg/blob/416a68639d002512cabfebff09afd2e1909e27df/redg-generator/src/main/java/com/btc/redg/generator/extractor/TableExtractor.java#L126-L167
144,269
elibom/jogger
src/main/java/com/elibom/jogger/http/servlet/ServletRequest.java
ServletRequest.init
private ServletRequest init() throws MultipartException, IOException { // retrieve multipart/form-data parameters if (Multipart.isMultipartContent(request)) { Multipart multipart = new Multipart(); multipart.parse(request, new PartHandler() { @Override public void handleFormItem(String name, String value) { multipartParams.put( name, value ); } @Override public void handleFileItem(String name, FileItem fileItem) { files.add(fileItem); } }); } return this; }
java
private ServletRequest init() throws MultipartException, IOException { // retrieve multipart/form-data parameters if (Multipart.isMultipartContent(request)) { Multipart multipart = new Multipart(); multipart.parse(request, new PartHandler() { @Override public void handleFormItem(String name, String value) { multipartParams.put( name, value ); } @Override public void handleFileItem(String name, FileItem fileItem) { files.add(fileItem); } }); } return this; }
[ "private", "ServletRequest", "init", "(", ")", "throws", "MultipartException", ",", "IOException", "{", "// retrieve multipart/form-data parameters", "if", "(", "Multipart", ".", "isMultipartContent", "(", "request", ")", ")", "{", "Multipart", "multipart", "=", "new", "Multipart", "(", ")", ";", "multipart", ".", "parse", "(", "request", ",", "new", "PartHandler", "(", ")", "{", "@", "Override", "public", "void", "handleFormItem", "(", "String", "name", ",", "String", "value", ")", "{", "multipartParams", ".", "put", "(", "name", ",", "value", ")", ";", "}", "@", "Override", "public", "void", "handleFileItem", "(", "String", "name", ",", "FileItem", "fileItem", ")", "{", "files", ".", "add", "(", "fileItem", ")", ";", "}", "}", ")", ";", "}", "return", "this", ";", "}" ]
Initializes the path variables and the multipart content. @throws MultipartException if there is a problem parsing the multipart/form-data. @throws IOException if there is a problem parsing the multipart/form-data.
[ "Initializes", "the", "path", "variables", "and", "the", "multipart", "content", "." ]
d5892ff45e76328d444a68b5a38c26e7bdd0692b
https://github.com/elibom/jogger/blob/d5892ff45e76328d444a68b5a38c26e7bdd0692b/src/main/java/com/elibom/jogger/http/servlet/ServletRequest.java#L64-L84
144,270
elibom/jogger
src/main/java/com/elibom/jogger/middleware/statik/StaticMiddleware.java
StaticMiddleware.fixRequestPath
private String fixRequestPath(String path) { return path.endsWith("/") ? path.substring(0, path.length() - 1) : path; }
java
private String fixRequestPath(String path) { return path.endsWith("/") ? path.substring(0, path.length() - 1) : path; }
[ "private", "String", "fixRequestPath", "(", "String", "path", ")", "{", "return", "path", ".", "endsWith", "(", "\"/\"", ")", "?", "path", ".", "substring", "(", "0", ",", "path", ".", "length", "(", ")", "-", "1", ")", ":", "path", ";", "}" ]
Helper method. The request path shouldn't have a trailing slash. @param path the path to fix. @return the path with its trailing slash
[ "Helper", "method", ".", "The", "request", "path", "shouldn", "t", "have", "a", "trailing", "slash", "." ]
d5892ff45e76328d444a68b5a38c26e7bdd0692b
https://github.com/elibom/jogger/blob/d5892ff45e76328d444a68b5a38c26e7bdd0692b/src/main/java/com/elibom/jogger/middleware/statik/StaticMiddleware.java#L136-L138
144,271
elibom/jogger
src/main/java/com/elibom/jogger/middleware/router/RouterMiddleware.java
RouterMiddleware.getInterceptors
private List<Interceptor> getInterceptors(String path) { List<Interceptor> ret = new ArrayList<Interceptor>(); for (InterceptorEntry entry : getInterceptors()) { if (matches(path, entry.getPaths())) { ret.add(entry.getInterceptor()); } } return ret; }
java
private List<Interceptor> getInterceptors(String path) { List<Interceptor> ret = new ArrayList<Interceptor>(); for (InterceptorEntry entry : getInterceptors()) { if (matches(path, entry.getPaths())) { ret.add(entry.getInterceptor()); } } return ret; }
[ "private", "List", "<", "Interceptor", ">", "getInterceptors", "(", "String", "path", ")", "{", "List", "<", "Interceptor", ">", "ret", "=", "new", "ArrayList", "<", "Interceptor", ">", "(", ")", ";", "for", "(", "InterceptorEntry", "entry", ":", "getInterceptors", "(", ")", ")", "{", "if", "(", "matches", "(", "path", ",", "entry", ".", "getPaths", "(", ")", ")", ")", "{", "ret", ".", "add", "(", "entry", ".", "getInterceptor", "(", ")", ")", ";", "}", "}", "return", "ret", ";", "}" ]
Returns a list of interceptors that match a path @param path @return a list of {@link Interceptor} objects.
[ "Returns", "a", "list", "of", "interceptors", "that", "match", "a", "path" ]
d5892ff45e76328d444a68b5a38c26e7bdd0692b
https://github.com/elibom/jogger/blob/d5892ff45e76328d444a68b5a38c26e7bdd0692b/src/main/java/com/elibom/jogger/middleware/router/RouterMiddleware.java#L68-L78
144,272
elibom/jogger
src/main/java/com/elibom/jogger/middleware/router/RouterMiddleware.java
RouterMiddleware.matchesPath
private boolean matchesPath(String routePath, String pathToMatch) { routePath = routePath.replaceAll(Path.VAR_REGEXP, Path.VAR_REPLACE); return pathToMatch.matches("(?i)" + routePath); }
java
private boolean matchesPath(String routePath, String pathToMatch) { routePath = routePath.replaceAll(Path.VAR_REGEXP, Path.VAR_REPLACE); return pathToMatch.matches("(?i)" + routePath); }
[ "private", "boolean", "matchesPath", "(", "String", "routePath", ",", "String", "pathToMatch", ")", "{", "routePath", "=", "routePath", ".", "replaceAll", "(", "Path", ".", "VAR_REGEXP", ",", "Path", ".", "VAR_REPLACE", ")", ";", "return", "pathToMatch", ".", "matches", "(", "\"(?i)\"", "+", "routePath", ")", ";", "}" ]
Helper method. Tells if the the HTTP path matches the route path. @param routePath the path defined for the route. @param pathToMatch the path from the HTTP request. @return true if the path matches, false otherwise.
[ "Helper", "method", ".", "Tells", "if", "the", "the", "HTTP", "path", "matches", "the", "route", "path", "." ]
d5892ff45e76328d444a68b5a38c26e7bdd0692b
https://github.com/elibom/jogger/blob/d5892ff45e76328d444a68b5a38c26e7bdd0692b/src/main/java/com/elibom/jogger/middleware/router/RouterMiddleware.java#L145-L148
144,273
elibom/jogger
src/main/java/com/elibom/jogger/http/servlet/multipart/Multipart.java
Multipart.isMultipartContent
public static boolean isMultipartContent(HttpServletRequest request) { if (!"post".equals(request.getMethod().toLowerCase())) { return false; } String contentType = request.getContentType(); if (contentType == null) { return false; } if (contentType.toLowerCase().startsWith(MULTIPART)) { return true; } return false; }
java
public static boolean isMultipartContent(HttpServletRequest request) { if (!"post".equals(request.getMethod().toLowerCase())) { return false; } String contentType = request.getContentType(); if (contentType == null) { return false; } if (contentType.toLowerCase().startsWith(MULTIPART)) { return true; } return false; }
[ "public", "static", "boolean", "isMultipartContent", "(", "HttpServletRequest", "request", ")", "{", "if", "(", "!", "\"post\"", ".", "equals", "(", "request", ".", "getMethod", "(", ")", ".", "toLowerCase", "(", ")", ")", ")", "{", "return", "false", ";", "}", "String", "contentType", "=", "request", ".", "getContentType", "(", ")", ";", "if", "(", "contentType", "==", "null", ")", "{", "return", "false", ";", "}", "if", "(", "contentType", ".", "toLowerCase", "(", ")", ".", "startsWith", "(", "MULTIPART", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Tells if a request is multipart or not. @param request the javax.servlet.http.HttpServletRequest that we are going to check. @return true if the request is multipart, false otherwise.
[ "Tells", "if", "a", "request", "is", "multipart", "or", "not", "." ]
d5892ff45e76328d444a68b5a38c26e7bdd0692b
https://github.com/elibom/jogger/blob/d5892ff45e76328d444a68b5a38c26e7bdd0692b/src/main/java/com/elibom/jogger/http/servlet/multipart/Multipart.java#L65-L79
144,274
elibom/jogger
src/main/java/com/elibom/jogger/http/servlet/multipart/Multipart.java
Multipart.getHeadersMap
protected Map<String,String> getHeadersMap(String headerPart) { final int len = headerPart.length(); final Map<String,String> headers = new HashMap<String,String>(); int start = 0; for (;;) { int end = parseEndOfLine(headerPart, start); if (start == end) { break; } String header = headerPart.substring(start, end); start = end + 2; while (start < len) { int nonWs = start; while (nonWs < len) { char c = headerPart.charAt(nonWs); if (c != ' ' && c != '\t') { break; } ++nonWs; } if (nonWs == start) { break; } // continuation line found end = parseEndOfLine(headerPart, nonWs); header += " " + headerPart.substring(nonWs, end); start = end + 2; } // parse header line final int colonOffset = header.indexOf(':'); if (colonOffset == -1) { // this header line is malformed, skip it. continue; } String headerName = header.substring(0, colonOffset).trim(); String headerValue = header.substring(header.indexOf(':') + 1).trim(); if (headers.containsKey(headerName)) { headers.put( headerName, headers.get(headerName) + "," + headerValue ); } else { headers.put(headerName, headerValue); } } return headers; }
java
protected Map<String,String> getHeadersMap(String headerPart) { final int len = headerPart.length(); final Map<String,String> headers = new HashMap<String,String>(); int start = 0; for (;;) { int end = parseEndOfLine(headerPart, start); if (start == end) { break; } String header = headerPart.substring(start, end); start = end + 2; while (start < len) { int nonWs = start; while (nonWs < len) { char c = headerPart.charAt(nonWs); if (c != ' ' && c != '\t') { break; } ++nonWs; } if (nonWs == start) { break; } // continuation line found end = parseEndOfLine(headerPart, nonWs); header += " " + headerPart.substring(nonWs, end); start = end + 2; } // parse header line final int colonOffset = header.indexOf(':'); if (colonOffset == -1) { // this header line is malformed, skip it. continue; } String headerName = header.substring(0, colonOffset).trim(); String headerValue = header.substring(header.indexOf(':') + 1).trim(); if (headers.containsKey(headerName)) { headers.put( headerName, headers.get(headerName) + "," + headerValue ); } else { headers.put(headerName, headerValue); } } return headers; }
[ "protected", "Map", "<", "String", ",", "String", ">", "getHeadersMap", "(", "String", "headerPart", ")", "{", "final", "int", "len", "=", "headerPart", ".", "length", "(", ")", ";", "final", "Map", "<", "String", ",", "String", ">", "headers", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "int", "start", "=", "0", ";", "for", "(", ";", ";", ")", "{", "int", "end", "=", "parseEndOfLine", "(", "headerPart", ",", "start", ")", ";", "if", "(", "start", "==", "end", ")", "{", "break", ";", "}", "String", "header", "=", "headerPart", ".", "substring", "(", "start", ",", "end", ")", ";", "start", "=", "end", "+", "2", ";", "while", "(", "start", "<", "len", ")", "{", "int", "nonWs", "=", "start", ";", "while", "(", "nonWs", "<", "len", ")", "{", "char", "c", "=", "headerPart", ".", "charAt", "(", "nonWs", ")", ";", "if", "(", "c", "!=", "'", "'", "&&", "c", "!=", "'", "'", ")", "{", "break", ";", "}", "++", "nonWs", ";", "}", "if", "(", "nonWs", "==", "start", ")", "{", "break", ";", "}", "// continuation line found", "end", "=", "parseEndOfLine", "(", "headerPart", ",", "nonWs", ")", ";", "header", "+=", "\" \"", "+", "headerPart", ".", "substring", "(", "nonWs", ",", "end", ")", ";", "start", "=", "end", "+", "2", ";", "}", "// parse header line", "final", "int", "colonOffset", "=", "header", ".", "indexOf", "(", "'", "'", ")", ";", "if", "(", "colonOffset", "==", "-", "1", ")", "{", "// this header line is malformed, skip it.", "continue", ";", "}", "String", "headerName", "=", "header", ".", "substring", "(", "0", ",", "colonOffset", ")", ".", "trim", "(", ")", ";", "String", "headerValue", "=", "header", ".", "substring", "(", "header", ".", "indexOf", "(", "'", "'", ")", "+", "1", ")", ".", "trim", "(", ")", ";", "if", "(", "headers", ".", "containsKey", "(", "headerName", ")", ")", "{", "headers", ".", "put", "(", "headerName", ",", "headers", ".", "get", "(", "headerName", ")", "+", "\",\"", "+", "headerValue", ")", ";", "}", "else", "{", "headers", ".", "put", "(", "headerName", ",", "headerValue", ")", ";", "}", "}", "return", "headers", ";", "}" ]
Retreives a map with the headers of a part. @param headerPart a String object with the contents of the part header. @return a Map<String,String> object with the headers of the part.
[ "Retreives", "a", "map", "with", "the", "headers", "of", "a", "part", "." ]
d5892ff45e76328d444a68b5a38c26e7bdd0692b
https://github.com/elibom/jogger/blob/d5892ff45e76328d444a68b5a38c26e7bdd0692b/src/main/java/com/elibom/jogger/http/servlet/multipart/Multipart.java#L225-L272
144,275
elibom/jogger
src/main/java/com/elibom/jogger/http/servlet/multipart/Multipart.java
Multipart.getFieldName
private String getFieldName(String contentDisposition) { String fieldName = null; if (contentDisposition != null && contentDisposition.toLowerCase().startsWith(FORM_DATA)) { ParameterParser parser = new ParameterParser(); parser.setLowerCaseNames(true); // parameter parser can handle null input Map<String,String> params = parser.parse(contentDisposition, ';'); fieldName = (String) params.get("name"); if (fieldName != null) { fieldName = fieldName.trim(); } } return fieldName; }
java
private String getFieldName(String contentDisposition) { String fieldName = null; if (contentDisposition != null && contentDisposition.toLowerCase().startsWith(FORM_DATA)) { ParameterParser parser = new ParameterParser(); parser.setLowerCaseNames(true); // parameter parser can handle null input Map<String,String> params = parser.parse(contentDisposition, ';'); fieldName = (String) params.get("name"); if (fieldName != null) { fieldName = fieldName.trim(); } } return fieldName; }
[ "private", "String", "getFieldName", "(", "String", "contentDisposition", ")", "{", "String", "fieldName", "=", "null", ";", "if", "(", "contentDisposition", "!=", "null", "&&", "contentDisposition", ".", "toLowerCase", "(", ")", ".", "startsWith", "(", "FORM_DATA", ")", ")", "{", "ParameterParser", "parser", "=", "new", "ParameterParser", "(", ")", ";", "parser", ".", "setLowerCaseNames", "(", "true", ")", ";", "// parameter parser can handle null input", "Map", "<", "String", ",", "String", ">", "params", "=", "parser", ".", "parse", "(", "contentDisposition", ",", "'", "'", ")", ";", "fieldName", "=", "(", "String", ")", "params", ".", "get", "(", "\"name\"", ")", ";", "if", "(", "fieldName", "!=", "null", ")", "{", "fieldName", "=", "fieldName", ".", "trim", "(", ")", ";", "}", "}", "return", "fieldName", ";", "}" ]
Retrieves the name of the field from the Content-Disposition header of the part. @param contentDisposition the value of the Content-Disposition header. @return a String object that holds the name of the field to which this part is associated.
[ "Retrieves", "the", "name", "of", "the", "field", "from", "the", "Content", "-", "Disposition", "header", "of", "the", "part", "." ]
d5892ff45e76328d444a68b5a38c26e7bdd0692b
https://github.com/elibom/jogger/blob/d5892ff45e76328d444a68b5a38c26e7bdd0692b/src/main/java/com/elibom/jogger/http/servlet/multipart/Multipart.java#L303-L319
144,276
elibom/jogger
src/main/java/com/elibom/jogger/http/servlet/multipart/Multipart.java
Multipart.getBoundary
protected byte[] getBoundary(String contentType) { ParameterParser parser = new ParameterParser(); parser.setLowerCaseNames(true); // Parameter parser can handle null input Map<String,String> params = parser.parse(contentType, new char[] {';', ','}); String boundaryStr = (String) params.get("boundary"); if (boundaryStr == null) { return null; } byte[] boundary; try { boundary = boundaryStr.getBytes("ISO-8859-1"); } catch (UnsupportedEncodingException e) { boundary = boundaryStr.getBytes(); } return boundary; }
java
protected byte[] getBoundary(String contentType) { ParameterParser parser = new ParameterParser(); parser.setLowerCaseNames(true); // Parameter parser can handle null input Map<String,String> params = parser.parse(contentType, new char[] {';', ','}); String boundaryStr = (String) params.get("boundary"); if (boundaryStr == null) { return null; } byte[] boundary; try { boundary = boundaryStr.getBytes("ISO-8859-1"); } catch (UnsupportedEncodingException e) { boundary = boundaryStr.getBytes(); } return boundary; }
[ "protected", "byte", "[", "]", "getBoundary", "(", "String", "contentType", ")", "{", "ParameterParser", "parser", "=", "new", "ParameterParser", "(", ")", ";", "parser", ".", "setLowerCaseNames", "(", "true", ")", ";", "// Parameter parser can handle null input", "Map", "<", "String", ",", "String", ">", "params", "=", "parser", ".", "parse", "(", "contentType", ",", "new", "char", "[", "]", "{", "'", "'", ",", "'", "'", "}", ")", ";", "String", "boundaryStr", "=", "(", "String", ")", "params", ".", "get", "(", "\"boundary\"", ")", ";", "if", "(", "boundaryStr", "==", "null", ")", "{", "return", "null", ";", "}", "byte", "[", "]", "boundary", ";", "try", "{", "boundary", "=", "boundaryStr", ".", "getBytes", "(", "\"ISO-8859-1\"", ")", ";", "}", "catch", "(", "UnsupportedEncodingException", "e", ")", "{", "boundary", "=", "boundaryStr", ".", "getBytes", "(", ")", ";", "}", "return", "boundary", ";", "}" ]
Retrieves the boundary that is used to separate the request parts from the Content-Type header. @param contentType the value of the Content-Type header. @return a byte array with the boundary.
[ "Retrieves", "the", "boundary", "that", "is", "used", "to", "separate", "the", "request", "parts", "from", "the", "Content", "-", "Type", "header", "." ]
d5892ff45e76328d444a68b5a38c26e7bdd0692b
https://github.com/elibom/jogger/blob/d5892ff45e76328d444a68b5a38c26e7bdd0692b/src/main/java/com/elibom/jogger/http/servlet/multipart/Multipart.java#L328-L346
144,277
elibom/jogger
src/main/java/com/elibom/jogger/http/servlet/multipart/Multipart.java
Multipart.getFileName
private String getFileName(String contentDisposition) { String fileName = null; if (contentDisposition != null) { String cdl = contentDisposition.toLowerCase(); if (cdl.startsWith(FORM_DATA) || cdl.startsWith(ATTACHMENT)) { ParameterParser parser = new ParameterParser(); parser.setLowerCaseNames(true); // parameter parser can handle null input Map<String,String> params = parser.parse(contentDisposition, ';'); if (params.containsKey("filename")) { fileName = (String) params.get("filename"); if (fileName != null) { fileName = fileName.trim(); } else { // even if there is no value, the parameter is present, // so we return an empty file name rather than no file // name. fileName = ""; } } } } return fileName; }
java
private String getFileName(String contentDisposition) { String fileName = null; if (contentDisposition != null) { String cdl = contentDisposition.toLowerCase(); if (cdl.startsWith(FORM_DATA) || cdl.startsWith(ATTACHMENT)) { ParameterParser parser = new ParameterParser(); parser.setLowerCaseNames(true); // parameter parser can handle null input Map<String,String> params = parser.parse(contentDisposition, ';'); if (params.containsKey("filename")) { fileName = (String) params.get("filename"); if (fileName != null) { fileName = fileName.trim(); } else { // even if there is no value, the parameter is present, // so we return an empty file name rather than no file // name. fileName = ""; } } } } return fileName; }
[ "private", "String", "getFileName", "(", "String", "contentDisposition", ")", "{", "String", "fileName", "=", "null", ";", "if", "(", "contentDisposition", "!=", "null", ")", "{", "String", "cdl", "=", "contentDisposition", ".", "toLowerCase", "(", ")", ";", "if", "(", "cdl", ".", "startsWith", "(", "FORM_DATA", ")", "||", "cdl", ".", "startsWith", "(", "ATTACHMENT", ")", ")", "{", "ParameterParser", "parser", "=", "new", "ParameterParser", "(", ")", ";", "parser", ".", "setLowerCaseNames", "(", "true", ")", ";", "// parameter parser can handle null input", "Map", "<", "String", ",", "String", ">", "params", "=", "parser", ".", "parse", "(", "contentDisposition", ",", "'", "'", ")", ";", "if", "(", "params", ".", "containsKey", "(", "\"filename\"", ")", ")", "{", "fileName", "=", "(", "String", ")", "params", ".", "get", "(", "\"filename\"", ")", ";", "if", "(", "fileName", "!=", "null", ")", "{", "fileName", "=", "fileName", ".", "trim", "(", ")", ";", "}", "else", "{", "// even if there is no value, the parameter is present,", "// so we return an empty file name rather than no file", "// name.", "fileName", "=", "\"\"", ";", "}", "}", "}", "}", "return", "fileName", ";", "}" ]
Retrieves the file name of a file from the filename attribute of the Content-Disposition header of the part. @param contentDisposition the value of the Content-Disposition header. @return a String object that holds the name of the file.
[ "Retrieves", "the", "file", "name", "of", "a", "file", "from", "the", "filename", "attribute", "of", "the", "Content", "-", "Disposition", "header", "of", "the", "part", "." ]
d5892ff45e76328d444a68b5a38c26e7bdd0692b
https://github.com/elibom/jogger/blob/d5892ff45e76328d444a68b5a38c26e7bdd0692b/src/main/java/com/elibom/jogger/http/servlet/multipart/Multipart.java#L355-L383
144,278
kmbulebu/dsc-it100-java
src/main/java/com/github/kmbulebu/dsc/it100/IT100.java
IT100.connect
public void connect() throws Exception { // Start up our MINA stuff // Setup MINA codecs final IT100CodecFactory it100CodecFactory = new IT100CodecFactory(); final ProtocolCodecFilter protocolCodecFilter = new ProtocolCodecFilter(it100CodecFactory); final CommandLogFilter loggingFilter = new CommandLogFilter(LOGGER, Level.DEBUG); final PollKeepAliveFilter pollKeepAliveFilter = new PollKeepAliveFilter(KeepAliveRequestTimeoutHandler.EXCEPTION); // Connect to system serial port. connector = configuration.getConnector(); // Typical configuration connector.setConnectTimeoutMillis(configuration.getConnectTimeout()); connector.getSessionConfig().setUseReadOperation(true); // Add IT100 codec to MINA filter chain to interpret messages. connector.getFilterChain().addLast("codec", protocolCodecFilter); connector.getFilterChain().addLast("logger", loggingFilter); connector.getFilterChain().addLast("keepalive", pollKeepAliveFilter); if (configuration.getStatusPollingInterval() != -1) { connector.getFilterChain().addLast("statusrequest", new StatusRequestFilter(configuration.getStatusPollingInterval())); } final DemuxingIoHandler demuxIoHandler = new DemuxingIoHandler(); // Setup a read message handler // OnSubscribe will allow us to create an Observable to received messages. final ReadCommandOnSubscribe readCommandObservable = new ReadCommandOnSubscribe(); demuxIoHandler.addReceivedMessageHandler(ReadCommand.class, readCommandObservable); demuxIoHandler.addExceptionHandler(Exception.class, readCommandObservable); // Handle Envisalink 505 request for password events if (configuration.getEnvisalinkPassword() != null) { final EnvisalinkLoginHandler envisalinkLoginHandler = new EnvisalinkLoginHandler(configuration.getEnvisalinkPassword()); demuxIoHandler.addReceivedMessageHandler(EnvisalinkLoginInteractionCommand.class, envisalinkLoginHandler); } // We don't need to subscribe to the messages we sent. demuxIoHandler.addSentMessageHandler(Object.class, MessageHandler.NOOP); connector.setHandler(demuxIoHandler); // Connect now final ConnectFuture future = connector.connect(configuration.getAddress()); future.awaitUninterruptibly(); // Get a reference to the session session = future.getSession(); // Create and return our Observable for received IT-100 commands. final ConnectableObservable<ReadCommand> connectableReadObservable = Observable.create(readCommandObservable).publish(); connectableReadObservable.connect(); readObservable = connectableReadObservable.share().asObservable(); // Create a write observer. writeObservable = PublishSubject.create(); writeObservable.subscribe(new Observer<WriteCommand>() { @Override public void onCompleted() { } @Override public void onError(Throwable e) { } @Override public void onNext(WriteCommand command) { session.write(command); } }); }
java
public void connect() throws Exception { // Start up our MINA stuff // Setup MINA codecs final IT100CodecFactory it100CodecFactory = new IT100CodecFactory(); final ProtocolCodecFilter protocolCodecFilter = new ProtocolCodecFilter(it100CodecFactory); final CommandLogFilter loggingFilter = new CommandLogFilter(LOGGER, Level.DEBUG); final PollKeepAliveFilter pollKeepAliveFilter = new PollKeepAliveFilter(KeepAliveRequestTimeoutHandler.EXCEPTION); // Connect to system serial port. connector = configuration.getConnector(); // Typical configuration connector.setConnectTimeoutMillis(configuration.getConnectTimeout()); connector.getSessionConfig().setUseReadOperation(true); // Add IT100 codec to MINA filter chain to interpret messages. connector.getFilterChain().addLast("codec", protocolCodecFilter); connector.getFilterChain().addLast("logger", loggingFilter); connector.getFilterChain().addLast("keepalive", pollKeepAliveFilter); if (configuration.getStatusPollingInterval() != -1) { connector.getFilterChain().addLast("statusrequest", new StatusRequestFilter(configuration.getStatusPollingInterval())); } final DemuxingIoHandler demuxIoHandler = new DemuxingIoHandler(); // Setup a read message handler // OnSubscribe will allow us to create an Observable to received messages. final ReadCommandOnSubscribe readCommandObservable = new ReadCommandOnSubscribe(); demuxIoHandler.addReceivedMessageHandler(ReadCommand.class, readCommandObservable); demuxIoHandler.addExceptionHandler(Exception.class, readCommandObservable); // Handle Envisalink 505 request for password events if (configuration.getEnvisalinkPassword() != null) { final EnvisalinkLoginHandler envisalinkLoginHandler = new EnvisalinkLoginHandler(configuration.getEnvisalinkPassword()); demuxIoHandler.addReceivedMessageHandler(EnvisalinkLoginInteractionCommand.class, envisalinkLoginHandler); } // We don't need to subscribe to the messages we sent. demuxIoHandler.addSentMessageHandler(Object.class, MessageHandler.NOOP); connector.setHandler(demuxIoHandler); // Connect now final ConnectFuture future = connector.connect(configuration.getAddress()); future.awaitUninterruptibly(); // Get a reference to the session session = future.getSession(); // Create and return our Observable for received IT-100 commands. final ConnectableObservable<ReadCommand> connectableReadObservable = Observable.create(readCommandObservable).publish(); connectableReadObservable.connect(); readObservable = connectableReadObservable.share().asObservable(); // Create a write observer. writeObservable = PublishSubject.create(); writeObservable.subscribe(new Observer<WriteCommand>() { @Override public void onCompleted() { } @Override public void onError(Throwable e) { } @Override public void onNext(WriteCommand command) { session.write(command); } }); }
[ "public", "void", "connect", "(", ")", "throws", "Exception", "{", "// Start up our MINA stuff ", "// Setup MINA codecs", "final", "IT100CodecFactory", "it100CodecFactory", "=", "new", "IT100CodecFactory", "(", ")", ";", "final", "ProtocolCodecFilter", "protocolCodecFilter", "=", "new", "ProtocolCodecFilter", "(", "it100CodecFactory", ")", ";", "final", "CommandLogFilter", "loggingFilter", "=", "new", "CommandLogFilter", "(", "LOGGER", ",", "Level", ".", "DEBUG", ")", ";", "final", "PollKeepAliveFilter", "pollKeepAliveFilter", "=", "new", "PollKeepAliveFilter", "(", "KeepAliveRequestTimeoutHandler", ".", "EXCEPTION", ")", ";", "// Connect to system serial port.", "connector", "=", "configuration", ".", "getConnector", "(", ")", ";", "// Typical configuration", "connector", ".", "setConnectTimeoutMillis", "(", "configuration", ".", "getConnectTimeout", "(", ")", ")", ";", "connector", ".", "getSessionConfig", "(", ")", ".", "setUseReadOperation", "(", "true", ")", ";", "// Add IT100 codec to MINA filter chain to interpret messages.", "connector", ".", "getFilterChain", "(", ")", ".", "addLast", "(", "\"codec\"", ",", "protocolCodecFilter", ")", ";", "connector", ".", "getFilterChain", "(", ")", ".", "addLast", "(", "\"logger\"", ",", "loggingFilter", ")", ";", "connector", ".", "getFilterChain", "(", ")", ".", "addLast", "(", "\"keepalive\"", ",", "pollKeepAliveFilter", ")", ";", "if", "(", "configuration", ".", "getStatusPollingInterval", "(", ")", "!=", "-", "1", ")", "{", "connector", ".", "getFilterChain", "(", ")", ".", "addLast", "(", "\"statusrequest\"", ",", "new", "StatusRequestFilter", "(", "configuration", ".", "getStatusPollingInterval", "(", ")", ")", ")", ";", "}", "final", "DemuxingIoHandler", "demuxIoHandler", "=", "new", "DemuxingIoHandler", "(", ")", ";", "// Setup a read message handler", "// OnSubscribe will allow us to create an Observable to received messages.", "final", "ReadCommandOnSubscribe", "readCommandObservable", "=", "new", "ReadCommandOnSubscribe", "(", ")", ";", "demuxIoHandler", ".", "addReceivedMessageHandler", "(", "ReadCommand", ".", "class", ",", "readCommandObservable", ")", ";", "demuxIoHandler", ".", "addExceptionHandler", "(", "Exception", ".", "class", ",", "readCommandObservable", ")", ";", "// Handle Envisalink 505 request for password events", "if", "(", "configuration", ".", "getEnvisalinkPassword", "(", ")", "!=", "null", ")", "{", "final", "EnvisalinkLoginHandler", "envisalinkLoginHandler", "=", "new", "EnvisalinkLoginHandler", "(", "configuration", ".", "getEnvisalinkPassword", "(", ")", ")", ";", "demuxIoHandler", ".", "addReceivedMessageHandler", "(", "EnvisalinkLoginInteractionCommand", ".", "class", ",", "envisalinkLoginHandler", ")", ";", "}", "// We don't need to subscribe to the messages we sent.", "demuxIoHandler", ".", "addSentMessageHandler", "(", "Object", ".", "class", ",", "MessageHandler", ".", "NOOP", ")", ";", "connector", ".", "setHandler", "(", "demuxIoHandler", ")", ";", "// Connect now", "final", "ConnectFuture", "future", "=", "connector", ".", "connect", "(", "configuration", ".", "getAddress", "(", ")", ")", ";", "future", ".", "awaitUninterruptibly", "(", ")", ";", "// Get a reference to the session", "session", "=", "future", ".", "getSession", "(", ")", ";", "// Create and return our Observable for received IT-100 commands.", "final", "ConnectableObservable", "<", "ReadCommand", ">", "connectableReadObservable", "=", "Observable", ".", "create", "(", "readCommandObservable", ")", ".", "publish", "(", ")", ";", "connectableReadObservable", ".", "connect", "(", ")", ";", "readObservable", "=", "connectableReadObservable", ".", "share", "(", ")", ".", "asObservable", "(", ")", ";", "// Create a write observer.", "writeObservable", "=", "PublishSubject", ".", "create", "(", ")", ";", "writeObservable", ".", "subscribe", "(", "new", "Observer", "<", "WriteCommand", ">", "(", ")", "{", "@", "Override", "public", "void", "onCompleted", "(", ")", "{", "}", "@", "Override", "public", "void", "onError", "(", "Throwable", "e", ")", "{", "}", "@", "Override", "public", "void", "onNext", "(", "WriteCommand", "command", ")", "{", "session", ".", "write", "(", "command", ")", ";", "}", "}", ")", ";", "}" ]
Begin communicating with the IT-100. @throws Exception If an error occurs while connecting to the IT-100
[ "Begin", "communicating", "with", "the", "IT", "-", "100", "." ]
69c170ba50c870cce6dbbe04b488c6b1c6a0e10f
https://github.com/kmbulebu/dsc-it100-java/blob/69c170ba50c870cce6dbbe04b488c6b1c6a0e10f/src/main/java/com/github/kmbulebu/dsc/it100/IT100.java#L65-L140
144,279
kmbulebu/dsc-it100-java
src/main/java/com/github/kmbulebu/dsc/it100/IT100.java
IT100.disconnect
public void disconnect() throws Exception { if (session != null) { session.getCloseFuture().awaitUninterruptibly(); } if (connector != null) { connector.dispose(); } }
java
public void disconnect() throws Exception { if (session != null) { session.getCloseFuture().awaitUninterruptibly(); } if (connector != null) { connector.dispose(); } }
[ "public", "void", "disconnect", "(", ")", "throws", "Exception", "{", "if", "(", "session", "!=", "null", ")", "{", "session", ".", "getCloseFuture", "(", ")", ".", "awaitUninterruptibly", "(", ")", ";", "}", "if", "(", "connector", "!=", "null", ")", "{", "connector", ".", "dispose", "(", ")", ";", "}", "}" ]
Stop communicating with the IT-100 and release the port. @throws Exception If there is an error while trying to close the port.
[ "Stop", "communicating", "with", "the", "IT", "-", "100", "and", "release", "the", "port", "." ]
69c170ba50c870cce6dbbe04b488c6b1c6a0e10f
https://github.com/kmbulebu/dsc-it100-java/blob/69c170ba50c870cce6dbbe04b488c6b1c6a0e10f/src/main/java/com/github/kmbulebu/dsc/it100/IT100.java#L170-L177
144,280
aggregateknowledge/java-hll
src/main/java/net/agkn/hll/util/HLLUtil.java
HLLUtil.registerBitSize
public static int registerBitSize(final long expectedUniqueElements) { return Math.max(HLL.MINIMUM_REGWIDTH_PARAM, (int)Math.ceil(NumberUtil.log2(NumberUtil.log2(expectedUniqueElements)))); }
java
public static int registerBitSize(final long expectedUniqueElements) { return Math.max(HLL.MINIMUM_REGWIDTH_PARAM, (int)Math.ceil(NumberUtil.log2(NumberUtil.log2(expectedUniqueElements)))); }
[ "public", "static", "int", "registerBitSize", "(", "final", "long", "expectedUniqueElements", ")", "{", "return", "Math", ".", "max", "(", "HLL", ".", "MINIMUM_REGWIDTH_PARAM", ",", "(", "int", ")", "Math", ".", "ceil", "(", "NumberUtil", ".", "log2", "(", "NumberUtil", ".", "log2", "(", "expectedUniqueElements", ")", ")", ")", ")", ";", "}" ]
Computes the bit-width of HLL registers necessary to estimate a set of the specified cardinality. @param expectedUniqueElements an upper bound on the number of unique elements that are expected. This must be greater than zero. @return a register size in bits (i.e. <code>log2(log2(n))</code>)
[ "Computes", "the", "bit", "-", "width", "of", "HLL", "registers", "necessary", "to", "estimate", "a", "set", "of", "the", "specified", "cardinality", "." ]
1f4126e79a85b79581460c75bf1c1634b8a7402d
https://github.com/aggregateknowledge/java-hll/blob/1f4126e79a85b79581460c75bf1c1634b8a7402d/src/main/java/net/agkn/hll/util/HLLUtil.java#L96-L99
144,281
aggregateknowledge/java-hll
src/main/java/net/agkn/hll/util/HLLUtil.java
HLLUtil.alphaMSquared
public static double alphaMSquared(final int m) { switch(m) { case 1/*2^0*/: case 2/*2^1*/: case 4/*2^2*/: case 8/*2^3*/: throw new IllegalArgumentException("'m' cannot be less than 16 (" + m + " < 16)."); case 16/*2^4*/: return 0.673 * m * m; case 32/*2^5*/: return 0.697 * m * m; case 64/*2^6*/: return 0.709 * m * m; default/*>2^6*/: return (0.7213 / (1.0 + 1.079 / m)) * m * m; } }
java
public static double alphaMSquared(final int m) { switch(m) { case 1/*2^0*/: case 2/*2^1*/: case 4/*2^2*/: case 8/*2^3*/: throw new IllegalArgumentException("'m' cannot be less than 16 (" + m + " < 16)."); case 16/*2^4*/: return 0.673 * m * m; case 32/*2^5*/: return 0.697 * m * m; case 64/*2^6*/: return 0.709 * m * m; default/*>2^6*/: return (0.7213 / (1.0 + 1.079 / m)) * m * m; } }
[ "public", "static", "double", "alphaMSquared", "(", "final", "int", "m", ")", "{", "switch", "(", "m", ")", "{", "case", "1", "/*2^0*/", ":", "case", "2", "/*2^1*/", ":", "case", "4", "/*2^2*/", ":", "case", "8", "/*2^3*/", ":", "throw", "new", "IllegalArgumentException", "(", "\"'m' cannot be less than 16 (\"", "+", "m", "+", "\" < 16).\"", ")", ";", "case", "16", "/*2^4*/", ":", "return", "0.673", "*", "m", "*", "m", ";", "case", "32", "/*2^5*/", ":", "return", "0.697", "*", "m", "*", "m", ";", "case", "64", "/*2^6*/", ":", "return", "0.709", "*", "m", "*", "m", ";", "default", "/*>2^6*/", ":", "return", "(", "0.7213", "/", "(", "1.0", "+", "1.079", "/", "m", ")", ")", "*", "m", "*", "m", ";", "}", "}" ]
Computes the 'alpha-m-squared' constant used by the HyperLogLog algorithm. @param m this must be a power of two, cannot be less than 16 (2<sup>4</sup>), and cannot be greater than 65536 (2<sup>16</sup>). @return gamma times <code>registerCount</code> squared where gamma is based on the value of <code>registerCount</code>. @throws IllegalArgumentException if <code>registerCount</code> is less than 16.
[ "Computes", "the", "alpha", "-", "m", "-", "squared", "constant", "used", "by", "the", "HyperLogLog", "algorithm", "." ]
1f4126e79a85b79581460c75bf1c1634b8a7402d
https://github.com/aggregateknowledge/java-hll/blob/1f4126e79a85b79581460c75bf1c1634b8a7402d/src/main/java/net/agkn/hll/util/HLLUtil.java#L112-L132
144,282
aggregateknowledge/java-hll
src/main/java/net/agkn/hll/HLL.java
HLL.cardinality
public long cardinality() { switch(type) { case EMPTY: return 0/*by definition*/; case EXPLICIT: return explicitStorage.size(); case SPARSE: return (long)Math.ceil(sparseProbabilisticAlgorithmCardinality()); case FULL: return (long)Math.ceil(fullProbabilisticAlgorithmCardinality()); default: throw new RuntimeException("Unsupported HLL type " + type); } }
java
public long cardinality() { switch(type) { case EMPTY: return 0/*by definition*/; case EXPLICIT: return explicitStorage.size(); case SPARSE: return (long)Math.ceil(sparseProbabilisticAlgorithmCardinality()); case FULL: return (long)Math.ceil(fullProbabilisticAlgorithmCardinality()); default: throw new RuntimeException("Unsupported HLL type " + type); } }
[ "public", "long", "cardinality", "(", ")", "{", "switch", "(", "type", ")", "{", "case", "EMPTY", ":", "return", "0", "/*by definition*/", ";", "case", "EXPLICIT", ":", "return", "explicitStorage", ".", "size", "(", ")", ";", "case", "SPARSE", ":", "return", "(", "long", ")", "Math", ".", "ceil", "(", "sparseProbabilisticAlgorithmCardinality", "(", ")", ")", ";", "case", "FULL", ":", "return", "(", "long", ")", "Math", ".", "ceil", "(", "fullProbabilisticAlgorithmCardinality", "(", ")", ")", ";", "default", ":", "throw", "new", "RuntimeException", "(", "\"Unsupported HLL type \"", "+", "type", ")", ";", "}", "}" ]
Computes the cardinality of the HLL. @return the cardinality of HLL. This will never be negative.
[ "Computes", "the", "cardinality", "of", "the", "HLL", "." ]
1f4126e79a85b79581460c75bf1c1634b8a7402d
https://github.com/aggregateknowledge/java-hll/blob/1f4126e79a85b79581460c75bf1c1634b8a7402d/src/main/java/net/agkn/hll/HLL.java#L511-L524
144,283
aggregateknowledge/java-hll
src/main/java/net/agkn/hll/HLL.java
HLL.union
public void union(final HLL other) { // TODO: verify HLLs are compatible final HLLType otherType = other.getType(); if(type.equals(otherType)) { homogeneousUnion(other); return; } else { heterogenousUnion(other); return; } }
java
public void union(final HLL other) { // TODO: verify HLLs are compatible final HLLType otherType = other.getType(); if(type.equals(otherType)) { homogeneousUnion(other); return; } else { heterogenousUnion(other); return; } }
[ "public", "void", "union", "(", "final", "HLL", "other", ")", "{", "// TODO: verify HLLs are compatible", "final", "HLLType", "otherType", "=", "other", ".", "getType", "(", ")", ";", "if", "(", "type", ".", "equals", "(", "otherType", ")", ")", "{", "homogeneousUnion", "(", "other", ")", ";", "return", ";", "}", "else", "{", "heterogenousUnion", "(", "other", ")", ";", "return", ";", "}", "}" ]
Computes the union of HLLs and stores the result in this instance. @param other the other {@link HLL} instance to union into this one. This cannot be <code>null</code>.
[ "Computes", "the", "union", "of", "HLLs", "and", "stores", "the", "result", "in", "this", "instance", "." ]
1f4126e79a85b79581460c75bf1c1634b8a7402d
https://github.com/aggregateknowledge/java-hll/blob/1f4126e79a85b79581460c75bf1c1634b8a7402d/src/main/java/net/agkn/hll/HLL.java#L631-L642
144,284
aggregateknowledge/java-hll
src/main/java/net/agkn/hll/HLL.java
HLL.homogeneousUnion
private void homogeneousUnion(final HLL other) { switch(type) { case EMPTY: // union of empty and empty is empty return; case EXPLICIT: for(final long value : other.explicitStorage) { addRaw(value); } // NOTE: #addRaw() will handle promotion, if necessary return; case SPARSE: for(final int registerIndex : other.sparseProbabilisticStorage.keySet()) { final byte registerValue = other.sparseProbabilisticStorage.get(registerIndex); final byte currentRegisterValue = sparseProbabilisticStorage.get(registerIndex); if(registerValue > currentRegisterValue) { sparseProbabilisticStorage.put(registerIndex, registerValue); } } // promotion, if necessary if(sparseProbabilisticStorage.size() > sparseThreshold) { initializeStorage(HLLType.FULL); for(final int registerIndex : sparseProbabilisticStorage.keySet()) { final byte registerValue = sparseProbabilisticStorage.get(registerIndex); probabilisticStorage.setMaxRegister(registerIndex, registerValue); } sparseProbabilisticStorage = null; } return; case FULL: for(int i=0; i<m; i++) { final long registerValue = other.probabilisticStorage.getRegister(i); probabilisticStorage.setMaxRegister(i, registerValue); } return; default: throw new RuntimeException("Unsupported HLL type " + type); } }
java
private void homogeneousUnion(final HLL other) { switch(type) { case EMPTY: // union of empty and empty is empty return; case EXPLICIT: for(final long value : other.explicitStorage) { addRaw(value); } // NOTE: #addRaw() will handle promotion, if necessary return; case SPARSE: for(final int registerIndex : other.sparseProbabilisticStorage.keySet()) { final byte registerValue = other.sparseProbabilisticStorage.get(registerIndex); final byte currentRegisterValue = sparseProbabilisticStorage.get(registerIndex); if(registerValue > currentRegisterValue) { sparseProbabilisticStorage.put(registerIndex, registerValue); } } // promotion, if necessary if(sparseProbabilisticStorage.size() > sparseThreshold) { initializeStorage(HLLType.FULL); for(final int registerIndex : sparseProbabilisticStorage.keySet()) { final byte registerValue = sparseProbabilisticStorage.get(registerIndex); probabilisticStorage.setMaxRegister(registerIndex, registerValue); } sparseProbabilisticStorage = null; } return; case FULL: for(int i=0; i<m; i++) { final long registerValue = other.probabilisticStorage.getRegister(i); probabilisticStorage.setMaxRegister(i, registerValue); } return; default: throw new RuntimeException("Unsupported HLL type " + type); } }
[ "private", "void", "homogeneousUnion", "(", "final", "HLL", "other", ")", "{", "switch", "(", "type", ")", "{", "case", "EMPTY", ":", "// union of empty and empty is empty", "return", ";", "case", "EXPLICIT", ":", "for", "(", "final", "long", "value", ":", "other", ".", "explicitStorage", ")", "{", "addRaw", "(", "value", ")", ";", "}", "// NOTE: #addRaw() will handle promotion, if necessary", "return", ";", "case", "SPARSE", ":", "for", "(", "final", "int", "registerIndex", ":", "other", ".", "sparseProbabilisticStorage", ".", "keySet", "(", ")", ")", "{", "final", "byte", "registerValue", "=", "other", ".", "sparseProbabilisticStorage", ".", "get", "(", "registerIndex", ")", ";", "final", "byte", "currentRegisterValue", "=", "sparseProbabilisticStorage", ".", "get", "(", "registerIndex", ")", ";", "if", "(", "registerValue", ">", "currentRegisterValue", ")", "{", "sparseProbabilisticStorage", ".", "put", "(", "registerIndex", ",", "registerValue", ")", ";", "}", "}", "// promotion, if necessary", "if", "(", "sparseProbabilisticStorage", ".", "size", "(", ")", ">", "sparseThreshold", ")", "{", "initializeStorage", "(", "HLLType", ".", "FULL", ")", ";", "for", "(", "final", "int", "registerIndex", ":", "sparseProbabilisticStorage", ".", "keySet", "(", ")", ")", "{", "final", "byte", "registerValue", "=", "sparseProbabilisticStorage", ".", "get", "(", "registerIndex", ")", ";", "probabilisticStorage", ".", "setMaxRegister", "(", "registerIndex", ",", "registerValue", ")", ";", "}", "sparseProbabilisticStorage", "=", "null", ";", "}", "return", ";", "case", "FULL", ":", "for", "(", "int", "i", "=", "0", ";", "i", "<", "m", ";", "i", "++", ")", "{", "final", "long", "registerValue", "=", "other", ".", "probabilisticStorage", ".", "getRegister", "(", "i", ")", ";", "probabilisticStorage", ".", "setMaxRegister", "(", "i", ",", "registerValue", ")", ";", "}", "return", ";", "default", ":", "throw", "new", "RuntimeException", "(", "\"Unsupported HLL type \"", "+", "type", ")", ";", "}", "}" ]
Computes the union of two HLLs of the same type, and stores the result in this instance. @param other the other {@link HLL} instance to union into this one. This cannot be <code>null</code>.
[ "Computes", "the", "union", "of", "two", "HLLs", "of", "the", "same", "type", "and", "stores", "the", "result", "in", "this", "instance", "." ]
1f4126e79a85b79581460c75bf1c1634b8a7402d
https://github.com/aggregateknowledge/java-hll/blob/1f4126e79a85b79581460c75bf1c1634b8a7402d/src/main/java/net/agkn/hll/HLL.java#L818-L857
144,285
aggregateknowledge/java-hll
src/main/java/net/agkn/hll/HLL.java
HLL.toBytes
public byte[] toBytes(final ISchemaVersion schemaVersion) { final byte[] bytes; switch(type) { case EMPTY: bytes = new byte[schemaVersion.paddingBytes(type)]; break; case EXPLICIT: { final IWordSerializer serializer = schemaVersion.getSerializer(type, Long.SIZE, explicitStorage.size()); final long[] values = explicitStorage.toLongArray(); Arrays.sort(values); for(final long value : values) { serializer.writeWord(value); } bytes = serializer.getBytes(); break; } case SPARSE: { final IWordSerializer serializer = schemaVersion.getSerializer(type, shortWordLength, sparseProbabilisticStorage.size()); final int[] indices = sparseProbabilisticStorage.keySet().toIntArray(); Arrays.sort(indices); for(final int registerIndex : indices) { final long registerValue = sparseProbabilisticStorage.get(registerIndex); // pack index and value into "short word" final long shortWord = ((registerIndex << regwidth) | registerValue); serializer.writeWord(shortWord); } bytes = serializer.getBytes(); break; } case FULL: { final IWordSerializer serializer = schemaVersion.getSerializer(type, regwidth, m); probabilisticStorage.getRegisterContents(serializer); bytes = serializer.getBytes(); break; } default: throw new RuntimeException("Unsupported HLL type " + type); } final IHLLMetadata metadata = new HLLMetadata(schemaVersion.schemaVersionNumber(), type, log2m, regwidth, (int)NumberUtil.log2(explicitThreshold), explicitOff, explicitAuto, !sparseOff); schemaVersion.writeMetadata(bytes, metadata); return bytes; }
java
public byte[] toBytes(final ISchemaVersion schemaVersion) { final byte[] bytes; switch(type) { case EMPTY: bytes = new byte[schemaVersion.paddingBytes(type)]; break; case EXPLICIT: { final IWordSerializer serializer = schemaVersion.getSerializer(type, Long.SIZE, explicitStorage.size()); final long[] values = explicitStorage.toLongArray(); Arrays.sort(values); for(final long value : values) { serializer.writeWord(value); } bytes = serializer.getBytes(); break; } case SPARSE: { final IWordSerializer serializer = schemaVersion.getSerializer(type, shortWordLength, sparseProbabilisticStorage.size()); final int[] indices = sparseProbabilisticStorage.keySet().toIntArray(); Arrays.sort(indices); for(final int registerIndex : indices) { final long registerValue = sparseProbabilisticStorage.get(registerIndex); // pack index and value into "short word" final long shortWord = ((registerIndex << regwidth) | registerValue); serializer.writeWord(shortWord); } bytes = serializer.getBytes(); break; } case FULL: { final IWordSerializer serializer = schemaVersion.getSerializer(type, regwidth, m); probabilisticStorage.getRegisterContents(serializer); bytes = serializer.getBytes(); break; } default: throw new RuntimeException("Unsupported HLL type " + type); } final IHLLMetadata metadata = new HLLMetadata(schemaVersion.schemaVersionNumber(), type, log2m, regwidth, (int)NumberUtil.log2(explicitThreshold), explicitOff, explicitAuto, !sparseOff); schemaVersion.writeMetadata(bytes, metadata); return bytes; }
[ "public", "byte", "[", "]", "toBytes", "(", "final", "ISchemaVersion", "schemaVersion", ")", "{", "final", "byte", "[", "]", "bytes", ";", "switch", "(", "type", ")", "{", "case", "EMPTY", ":", "bytes", "=", "new", "byte", "[", "schemaVersion", ".", "paddingBytes", "(", "type", ")", "]", ";", "break", ";", "case", "EXPLICIT", ":", "{", "final", "IWordSerializer", "serializer", "=", "schemaVersion", ".", "getSerializer", "(", "type", ",", "Long", ".", "SIZE", ",", "explicitStorage", ".", "size", "(", ")", ")", ";", "final", "long", "[", "]", "values", "=", "explicitStorage", ".", "toLongArray", "(", ")", ";", "Arrays", ".", "sort", "(", "values", ")", ";", "for", "(", "final", "long", "value", ":", "values", ")", "{", "serializer", ".", "writeWord", "(", "value", ")", ";", "}", "bytes", "=", "serializer", ".", "getBytes", "(", ")", ";", "break", ";", "}", "case", "SPARSE", ":", "{", "final", "IWordSerializer", "serializer", "=", "schemaVersion", ".", "getSerializer", "(", "type", ",", "shortWordLength", ",", "sparseProbabilisticStorage", ".", "size", "(", ")", ")", ";", "final", "int", "[", "]", "indices", "=", "sparseProbabilisticStorage", ".", "keySet", "(", ")", ".", "toIntArray", "(", ")", ";", "Arrays", ".", "sort", "(", "indices", ")", ";", "for", "(", "final", "int", "registerIndex", ":", "indices", ")", "{", "final", "long", "registerValue", "=", "sparseProbabilisticStorage", ".", "get", "(", "registerIndex", ")", ";", "// pack index and value into \"short word\"", "final", "long", "shortWord", "=", "(", "(", "registerIndex", "<<", "regwidth", ")", "|", "registerValue", ")", ";", "serializer", ".", "writeWord", "(", "shortWord", ")", ";", "}", "bytes", "=", "serializer", ".", "getBytes", "(", ")", ";", "break", ";", "}", "case", "FULL", ":", "{", "final", "IWordSerializer", "serializer", "=", "schemaVersion", ".", "getSerializer", "(", "type", ",", "regwidth", ",", "m", ")", ";", "probabilisticStorage", ".", "getRegisterContents", "(", "serializer", ")", ";", "bytes", "=", "serializer", ".", "getBytes", "(", ")", ";", "break", ";", "}", "default", ":", "throw", "new", "RuntimeException", "(", "\"Unsupported HLL type \"", "+", "type", ")", ";", "}", "final", "IHLLMetadata", "metadata", "=", "new", "HLLMetadata", "(", "schemaVersion", ".", "schemaVersionNumber", "(", ")", ",", "type", ",", "log2m", ",", "regwidth", ",", "(", "int", ")", "NumberUtil", ".", "log2", "(", "explicitThreshold", ")", ",", "explicitOff", ",", "explicitAuto", ",", "!", "sparseOff", ")", ";", "schemaVersion", ".", "writeMetadata", "(", "bytes", ",", "metadata", ")", ";", "return", "bytes", ";", "}" ]
Serializes the HLL to an array of bytes in correspondence with the format of the specified schema version. @param schemaVersion the schema version dictating the serialization format @return the array of bytes representing the HLL. This will never be <code>null</code> or empty.
[ "Serializes", "the", "HLL", "to", "an", "array", "of", "bytes", "in", "correspondence", "with", "the", "format", "of", "the", "specified", "schema", "version", "." ]
1f4126e79a85b79581460c75bf1c1634b8a7402d
https://github.com/aggregateknowledge/java-hll/blob/1f4126e79a85b79581460c75bf1c1634b8a7402d/src/main/java/net/agkn/hll/HLL.java#L880-L937
144,286
aggregateknowledge/java-hll
src/main/java/net/agkn/hll/util/BitVector.java
BitVector.getRegisterContents
public void getRegisterContents(final IWordSerializer serializer) { for(final LongIterator iter = registerIterator(); iter.hasNext();) { serializer.writeWord(iter.next()); } }
java
public void getRegisterContents(final IWordSerializer serializer) { for(final LongIterator iter = registerIterator(); iter.hasNext();) { serializer.writeWord(iter.next()); } }
[ "public", "void", "getRegisterContents", "(", "final", "IWordSerializer", "serializer", ")", "{", "for", "(", "final", "LongIterator", "iter", "=", "registerIterator", "(", ")", ";", "iter", ".", "hasNext", "(", ")", ";", ")", "{", "serializer", ".", "writeWord", "(", "iter", ".", "next", "(", ")", ")", ";", "}", "}" ]
Serializes the registers of the vector using the specified serializer. @param serializer the serializer to use. This cannot be <code>null</code>.
[ "Serializes", "the", "registers", "of", "the", "vector", "using", "the", "specified", "serializer", "." ]
1f4126e79a85b79581460c75bf1c1634b8a7402d
https://github.com/aggregateknowledge/java-hll/blob/1f4126e79a85b79581460c75bf1c1634b8a7402d/src/main/java/net/agkn/hll/util/BitVector.java#L245-L249
144,287
OnyxDevTools/onyx-database-parent
onyx-database-examples/model-updates/model-after-update/src/main/java/com/onyxdevtools/modelUpdate/after/UpdateIndexDemo.java
UpdateIndexDemo.parseDate
private static Date parseDate(@SuppressWarnings("SameParameterValue") String stringDate) { try { return formatter.parse(stringDate); } catch (ParseException e) { e.printStackTrace(); return null; } }
java
private static Date parseDate(@SuppressWarnings("SameParameterValue") String stringDate) { try { return formatter.parse(stringDate); } catch (ParseException e) { e.printStackTrace(); return null; } }
[ "private", "static", "Date", "parseDate", "(", "@", "SuppressWarnings", "(", "\"SameParameterValue\"", ")", "String", "stringDate", ")", "{", "try", "{", "return", "formatter", ".", "parse", "(", "stringDate", ")", ";", "}", "catch", "(", "ParseException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "return", "null", ";", "}", "}" ]
Helper method used to parse a date in string format. Meant to encapsulate the error handling. @param stringDate String in format of MM-dd-yyyy @return Date key
[ "Helper", "method", "used", "to", "parse", "a", "date", "in", "string", "format", ".", "Meant", "to", "encapsulate", "the", "error", "handling", "." ]
474dfc273a094dbc2ca08fcc08a2858cd538c920
https://github.com/OnyxDevTools/onyx-database-parent/blob/474dfc273a094dbc2ca08fcc08a2858cd538c920/onyx-database-examples/model-updates/model-after-update/src/main/java/com/onyxdevtools/modelUpdate/after/UpdateIndexDemo.java#L80-L88
144,288
buschmais/jqa-maven3-plugin
src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenModelScannerPlugin.java
MavenModelScannerPlugin.createMavenPomDescriptor
protected MavenPomDescriptor createMavenPomDescriptor(Model model, Scanner scanner) { ScannerContext context = scanner.getContext(); MavenPomDescriptor pomDescriptor = context.peek(MavenPomDescriptor.class); if (model instanceof EffectiveModel) { context.getStore().addDescriptorType(pomDescriptor, EffectiveDescriptor.class); } pomDescriptor.setName(model.getName()); pomDescriptor.setGroupId(model.getGroupId()); pomDescriptor.setArtifactId(model.getArtifactId()); pomDescriptor.setPackaging(model.getPackaging()); pomDescriptor.setVersion(model.getVersion()); pomDescriptor.setUrl(model.getUrl()); Coordinates artifactCoordinates = new ModelCoordinates(model); MavenArtifactDescriptor artifact = getArtifactResolver(context).resolve(artifactCoordinates, context); pomDescriptor.getDescribes().add(artifact); return pomDescriptor; }
java
protected MavenPomDescriptor createMavenPomDescriptor(Model model, Scanner scanner) { ScannerContext context = scanner.getContext(); MavenPomDescriptor pomDescriptor = context.peek(MavenPomDescriptor.class); if (model instanceof EffectiveModel) { context.getStore().addDescriptorType(pomDescriptor, EffectiveDescriptor.class); } pomDescriptor.setName(model.getName()); pomDescriptor.setGroupId(model.getGroupId()); pomDescriptor.setArtifactId(model.getArtifactId()); pomDescriptor.setPackaging(model.getPackaging()); pomDescriptor.setVersion(model.getVersion()); pomDescriptor.setUrl(model.getUrl()); Coordinates artifactCoordinates = new ModelCoordinates(model); MavenArtifactDescriptor artifact = getArtifactResolver(context).resolve(artifactCoordinates, context); pomDescriptor.getDescribes().add(artifact); return pomDescriptor; }
[ "protected", "MavenPomDescriptor", "createMavenPomDescriptor", "(", "Model", "model", ",", "Scanner", "scanner", ")", "{", "ScannerContext", "context", "=", "scanner", ".", "getContext", "(", ")", ";", "MavenPomDescriptor", "pomDescriptor", "=", "context", ".", "peek", "(", "MavenPomDescriptor", ".", "class", ")", ";", "if", "(", "model", "instanceof", "EffectiveModel", ")", "{", "context", ".", "getStore", "(", ")", ".", "addDescriptorType", "(", "pomDescriptor", ",", "EffectiveDescriptor", ".", "class", ")", ";", "}", "pomDescriptor", ".", "setName", "(", "model", ".", "getName", "(", ")", ")", ";", "pomDescriptor", ".", "setGroupId", "(", "model", ".", "getGroupId", "(", ")", ")", ";", "pomDescriptor", ".", "setArtifactId", "(", "model", ".", "getArtifactId", "(", ")", ")", ";", "pomDescriptor", ".", "setPackaging", "(", "model", ".", "getPackaging", "(", ")", ")", ";", "pomDescriptor", ".", "setVersion", "(", "model", ".", "getVersion", "(", ")", ")", ";", "pomDescriptor", ".", "setUrl", "(", "model", ".", "getUrl", "(", ")", ")", ";", "Coordinates", "artifactCoordinates", "=", "new", "ModelCoordinates", "(", "model", ")", ";", "MavenArtifactDescriptor", "artifact", "=", "getArtifactResolver", "(", "context", ")", ".", "resolve", "(", "artifactCoordinates", ",", "context", ")", ";", "pomDescriptor", ".", "getDescribes", "(", ")", ".", "add", "(", "artifact", ")", ";", "return", "pomDescriptor", ";", "}" ]
Create the descriptor and set base information. @param model The model. @param scanner The scanner. @return The descriptor.
[ "Create", "the", "descriptor", "and", "set", "base", "information", "." ]
6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f
https://github.com/buschmais/jqa-maven3-plugin/blob/6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f/src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenModelScannerPlugin.java#L146-L162
144,289
buschmais/jqa-maven3-plugin
src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenModelScannerPlugin.java
MavenModelScannerPlugin.addActivation
private void addActivation(MavenProfileDescriptor mavenProfileDescriptor, Activation activation, Store store) { if (null == activation) { return; } MavenProfileActivationDescriptor profileActivationDescriptor = store.create(MavenProfileActivationDescriptor.class); mavenProfileDescriptor.setActivation(profileActivationDescriptor); profileActivationDescriptor.setJdk(activation.getJdk()); profileActivationDescriptor.setActiveByDefault(activation.isActiveByDefault()); ActivationFile activationFile = activation.getFile(); if (null != activationFile) { MavenActivationFileDescriptor activationFileDescriptor = store.create(MavenActivationFileDescriptor.class); profileActivationDescriptor.setActivationFile(activationFileDescriptor); activationFileDescriptor.setExists(activationFile.getExists()); activationFileDescriptor.setMissing(activationFile.getMissing()); } ActivationOS os = activation.getOs(); if (null != os) { MavenActivationOSDescriptor osDescriptor = store.create(MavenActivationOSDescriptor.class); profileActivationDescriptor.setActivationOS(osDescriptor); osDescriptor.setArch(os.getArch()); osDescriptor.setFamily(os.getFamily()); osDescriptor.setName(os.getName()); osDescriptor.setVersion(os.getVersion()); } ActivationProperty property = activation.getProperty(); if (null != property) { PropertyDescriptor propertyDescriptor = store.create(PropertyDescriptor.class); profileActivationDescriptor.setProperty(propertyDescriptor); propertyDescriptor.setName(property.getName()); propertyDescriptor.setValue(property.getValue()); } }
java
private void addActivation(MavenProfileDescriptor mavenProfileDescriptor, Activation activation, Store store) { if (null == activation) { return; } MavenProfileActivationDescriptor profileActivationDescriptor = store.create(MavenProfileActivationDescriptor.class); mavenProfileDescriptor.setActivation(profileActivationDescriptor); profileActivationDescriptor.setJdk(activation.getJdk()); profileActivationDescriptor.setActiveByDefault(activation.isActiveByDefault()); ActivationFile activationFile = activation.getFile(); if (null != activationFile) { MavenActivationFileDescriptor activationFileDescriptor = store.create(MavenActivationFileDescriptor.class); profileActivationDescriptor.setActivationFile(activationFileDescriptor); activationFileDescriptor.setExists(activationFile.getExists()); activationFileDescriptor.setMissing(activationFile.getMissing()); } ActivationOS os = activation.getOs(); if (null != os) { MavenActivationOSDescriptor osDescriptor = store.create(MavenActivationOSDescriptor.class); profileActivationDescriptor.setActivationOS(osDescriptor); osDescriptor.setArch(os.getArch()); osDescriptor.setFamily(os.getFamily()); osDescriptor.setName(os.getName()); osDescriptor.setVersion(os.getVersion()); } ActivationProperty property = activation.getProperty(); if (null != property) { PropertyDescriptor propertyDescriptor = store.create(PropertyDescriptor.class); profileActivationDescriptor.setProperty(propertyDescriptor); propertyDescriptor.setName(property.getName()); propertyDescriptor.setValue(property.getValue()); } }
[ "private", "void", "addActivation", "(", "MavenProfileDescriptor", "mavenProfileDescriptor", ",", "Activation", "activation", ",", "Store", "store", ")", "{", "if", "(", "null", "==", "activation", ")", "{", "return", ";", "}", "MavenProfileActivationDescriptor", "profileActivationDescriptor", "=", "store", ".", "create", "(", "MavenProfileActivationDescriptor", ".", "class", ")", ";", "mavenProfileDescriptor", ".", "setActivation", "(", "profileActivationDescriptor", ")", ";", "profileActivationDescriptor", ".", "setJdk", "(", "activation", ".", "getJdk", "(", ")", ")", ";", "profileActivationDescriptor", ".", "setActiveByDefault", "(", "activation", ".", "isActiveByDefault", "(", ")", ")", ";", "ActivationFile", "activationFile", "=", "activation", ".", "getFile", "(", ")", ";", "if", "(", "null", "!=", "activationFile", ")", "{", "MavenActivationFileDescriptor", "activationFileDescriptor", "=", "store", ".", "create", "(", "MavenActivationFileDescriptor", ".", "class", ")", ";", "profileActivationDescriptor", ".", "setActivationFile", "(", "activationFileDescriptor", ")", ";", "activationFileDescriptor", ".", "setExists", "(", "activationFile", ".", "getExists", "(", ")", ")", ";", "activationFileDescriptor", ".", "setMissing", "(", "activationFile", ".", "getMissing", "(", ")", ")", ";", "}", "ActivationOS", "os", "=", "activation", ".", "getOs", "(", ")", ";", "if", "(", "null", "!=", "os", ")", "{", "MavenActivationOSDescriptor", "osDescriptor", "=", "store", ".", "create", "(", "MavenActivationOSDescriptor", ".", "class", ")", ";", "profileActivationDescriptor", ".", "setActivationOS", "(", "osDescriptor", ")", ";", "osDescriptor", ".", "setArch", "(", "os", ".", "getArch", "(", ")", ")", ";", "osDescriptor", ".", "setFamily", "(", "os", ".", "getFamily", "(", ")", ")", ";", "osDescriptor", ".", "setName", "(", "os", ".", "getName", "(", ")", ")", ";", "osDescriptor", ".", "setVersion", "(", "os", ".", "getVersion", "(", ")", ")", ";", "}", "ActivationProperty", "property", "=", "activation", ".", "getProperty", "(", ")", ";", "if", "(", "null", "!=", "property", ")", "{", "PropertyDescriptor", "propertyDescriptor", "=", "store", ".", "create", "(", "PropertyDescriptor", ".", "class", ")", ";", "profileActivationDescriptor", ".", "setProperty", "(", "propertyDescriptor", ")", ";", "propertyDescriptor", ".", "setName", "(", "property", ".", "getName", "(", ")", ")", ";", "propertyDescriptor", ".", "setValue", "(", "property", ".", "getValue", "(", ")", ")", ";", "}", "}" ]
Adds activation information for the given profile. @param mavenProfileDescriptor The profile descriptor. @param activation The activation information. @param store The database.
[ "Adds", "activation", "information", "for", "the", "given", "profile", "." ]
6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f
https://github.com/buschmais/jqa-maven3-plugin/blob/6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f/src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenModelScannerPlugin.java#L191-L224
144,290
buschmais/jqa-maven3-plugin
src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenModelScannerPlugin.java
MavenModelScannerPlugin.addConfiguration
private void addConfiguration(ConfigurableDescriptor configurableDescriptor, Xpp3Dom config, Store store) { if (null == config) { return; } MavenConfigurationDescriptor configDescriptor = store.create(MavenConfigurationDescriptor.class); configurableDescriptor.setConfiguration(configDescriptor); Xpp3Dom[] children = config.getChildren(); for (Xpp3Dom child : children) { configDescriptor.getValues().add(getConfigChildNodes(child, store)); } }
java
private void addConfiguration(ConfigurableDescriptor configurableDescriptor, Xpp3Dom config, Store store) { if (null == config) { return; } MavenConfigurationDescriptor configDescriptor = store.create(MavenConfigurationDescriptor.class); configurableDescriptor.setConfiguration(configDescriptor); Xpp3Dom[] children = config.getChildren(); for (Xpp3Dom child : children) { configDescriptor.getValues().add(getConfigChildNodes(child, store)); } }
[ "private", "void", "addConfiguration", "(", "ConfigurableDescriptor", "configurableDescriptor", ",", "Xpp3Dom", "config", ",", "Store", "store", ")", "{", "if", "(", "null", "==", "config", ")", "{", "return", ";", "}", "MavenConfigurationDescriptor", "configDescriptor", "=", "store", ".", "create", "(", "MavenConfigurationDescriptor", ".", "class", ")", ";", "configurableDescriptor", ".", "setConfiguration", "(", "configDescriptor", ")", ";", "Xpp3Dom", "[", "]", "children", "=", "config", ".", "getChildren", "(", ")", ";", "for", "(", "Xpp3Dom", "child", ":", "children", ")", "{", "configDescriptor", ".", "getValues", "(", ")", ".", "add", "(", "getConfigChildNodes", "(", "child", ",", "store", ")", ")", ";", "}", "}" ]
Adds configuration information. @param configurableDescriptor The descriptor for the configured element (Plugin, PluginExecution). @param config The configuration information. @param store The database.
[ "Adds", "configuration", "information", "." ]
6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f
https://github.com/buschmais/jqa-maven3-plugin/blob/6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f/src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenModelScannerPlugin.java#L237-L247
144,291
buschmais/jqa-maven3-plugin
src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenModelScannerPlugin.java
MavenModelScannerPlugin.getDependencies
private <P extends MavenDependentDescriptor, D extends AbstractDependencyDescriptor> List<MavenDependencyDescriptor> getDependencies(P dependent, List<Dependency> dependencies, Class<D> dependsOnType, ScannerContext scannerContext) { Store store = scannerContext.getStore(); List<MavenDependencyDescriptor> dependencyDescriptors = new ArrayList<>(dependencies.size()); for (Dependency dependency : dependencies) { MavenArtifactDescriptor dependencyArtifactDescriptor = getMavenArtifactDescriptor(dependency, scannerContext); // Deprecated graph structure D dependsOnDescriptor = store.create(dependent, dependsOnType, dependencyArtifactDescriptor); dependsOnDescriptor.setOptional(dependency.isOptional()); dependsOnDescriptor.setScope(dependency.getScope()); // New graph structure supporting exclusions MavenDependencyDescriptor dependencyDescriptor = store.create(MavenDependencyDescriptor.class); dependencyDescriptor.setToArtifact(dependencyArtifactDescriptor); dependencyDescriptor.setOptional(dependency.isOptional()); dependencyDescriptor.setScope(dependency.getScope()); for (Exclusion exclusion : dependency.getExclusions()) { MavenExcludesDescriptor mavenExcludesDescriptor = store.create(MavenExcludesDescriptor.class); mavenExcludesDescriptor.setGroupId(exclusion.getGroupId()); mavenExcludesDescriptor.setArtifactId(exclusion.getArtifactId()); dependencyDescriptor.getExclusions().add(mavenExcludesDescriptor); } dependencyDescriptors.add(dependencyDescriptor); } return dependencyDescriptors; }
java
private <P extends MavenDependentDescriptor, D extends AbstractDependencyDescriptor> List<MavenDependencyDescriptor> getDependencies(P dependent, List<Dependency> dependencies, Class<D> dependsOnType, ScannerContext scannerContext) { Store store = scannerContext.getStore(); List<MavenDependencyDescriptor> dependencyDescriptors = new ArrayList<>(dependencies.size()); for (Dependency dependency : dependencies) { MavenArtifactDescriptor dependencyArtifactDescriptor = getMavenArtifactDescriptor(dependency, scannerContext); // Deprecated graph structure D dependsOnDescriptor = store.create(dependent, dependsOnType, dependencyArtifactDescriptor); dependsOnDescriptor.setOptional(dependency.isOptional()); dependsOnDescriptor.setScope(dependency.getScope()); // New graph structure supporting exclusions MavenDependencyDescriptor dependencyDescriptor = store.create(MavenDependencyDescriptor.class); dependencyDescriptor.setToArtifact(dependencyArtifactDescriptor); dependencyDescriptor.setOptional(dependency.isOptional()); dependencyDescriptor.setScope(dependency.getScope()); for (Exclusion exclusion : dependency.getExclusions()) { MavenExcludesDescriptor mavenExcludesDescriptor = store.create(MavenExcludesDescriptor.class); mavenExcludesDescriptor.setGroupId(exclusion.getGroupId()); mavenExcludesDescriptor.setArtifactId(exclusion.getArtifactId()); dependencyDescriptor.getExclusions().add(mavenExcludesDescriptor); } dependencyDescriptors.add(dependencyDescriptor); } return dependencyDescriptors; }
[ "private", "<", "P", "extends", "MavenDependentDescriptor", ",", "D", "extends", "AbstractDependencyDescriptor", ">", "List", "<", "MavenDependencyDescriptor", ">", "getDependencies", "(", "P", "dependent", ",", "List", "<", "Dependency", ">", "dependencies", ",", "Class", "<", "D", ">", "dependsOnType", ",", "ScannerContext", "scannerContext", ")", "{", "Store", "store", "=", "scannerContext", ".", "getStore", "(", ")", ";", "List", "<", "MavenDependencyDescriptor", ">", "dependencyDescriptors", "=", "new", "ArrayList", "<>", "(", "dependencies", ".", "size", "(", ")", ")", ";", "for", "(", "Dependency", "dependency", ":", "dependencies", ")", "{", "MavenArtifactDescriptor", "dependencyArtifactDescriptor", "=", "getMavenArtifactDescriptor", "(", "dependency", ",", "scannerContext", ")", ";", "// Deprecated graph structure", "D", "dependsOnDescriptor", "=", "store", ".", "create", "(", "dependent", ",", "dependsOnType", ",", "dependencyArtifactDescriptor", ")", ";", "dependsOnDescriptor", ".", "setOptional", "(", "dependency", ".", "isOptional", "(", ")", ")", ";", "dependsOnDescriptor", ".", "setScope", "(", "dependency", ".", "getScope", "(", ")", ")", ";", "// New graph structure supporting exclusions", "MavenDependencyDescriptor", "dependencyDescriptor", "=", "store", ".", "create", "(", "MavenDependencyDescriptor", ".", "class", ")", ";", "dependencyDescriptor", ".", "setToArtifact", "(", "dependencyArtifactDescriptor", ")", ";", "dependencyDescriptor", ".", "setOptional", "(", "dependency", ".", "isOptional", "(", ")", ")", ";", "dependencyDescriptor", ".", "setScope", "(", "dependency", ".", "getScope", "(", ")", ")", ";", "for", "(", "Exclusion", "exclusion", ":", "dependency", ".", "getExclusions", "(", ")", ")", "{", "MavenExcludesDescriptor", "mavenExcludesDescriptor", "=", "store", ".", "create", "(", "MavenExcludesDescriptor", ".", "class", ")", ";", "mavenExcludesDescriptor", ".", "setGroupId", "(", "exclusion", ".", "getGroupId", "(", ")", ")", ";", "mavenExcludesDescriptor", ".", "setArtifactId", "(", "exclusion", ".", "getArtifactId", "(", ")", ")", ";", "dependencyDescriptor", ".", "getExclusions", "(", ")", ".", "add", "(", "mavenExcludesDescriptor", ")", ";", "}", "dependencyDescriptors", ".", "add", "(", "dependencyDescriptor", ")", ";", "}", "return", "dependencyDescriptors", ";", "}" ]
Adds information about artifact dependencies. @param dependent The dependent to add artifacts as dependencies @param dependencies The dependencies information. @param dependsOnType The type for creating the {@link com.buschmais.jqassistant.plugin.common.api.model.DependsOnDescriptor}. @param scannerContext The scanner context @return The list of {@link MavenDependencyDescriptor}s.
[ "Adds", "information", "about", "artifact", "dependencies", "." ]
6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f
https://github.com/buschmais/jqa-maven3-plugin/blob/6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f/src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenModelScannerPlugin.java#L282-L306
144,292
buschmais/jqa-maven3-plugin
src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenModelScannerPlugin.java
MavenModelScannerPlugin.addExecutionGoals
private void addExecutionGoals(MavenPluginExecutionDescriptor executionDescriptor, PluginExecution pluginExecution, Store store) { List<String> goals = pluginExecution.getGoals(); for (String goal : goals) { MavenExecutionGoalDescriptor goalDescriptor = store.create(MavenExecutionGoalDescriptor.class); goalDescriptor.setName(goal); executionDescriptor.getGoals().add(goalDescriptor); } }
java
private void addExecutionGoals(MavenPluginExecutionDescriptor executionDescriptor, PluginExecution pluginExecution, Store store) { List<String> goals = pluginExecution.getGoals(); for (String goal : goals) { MavenExecutionGoalDescriptor goalDescriptor = store.create(MavenExecutionGoalDescriptor.class); goalDescriptor.setName(goal); executionDescriptor.getGoals().add(goalDescriptor); } }
[ "private", "void", "addExecutionGoals", "(", "MavenPluginExecutionDescriptor", "executionDescriptor", ",", "PluginExecution", "pluginExecution", ",", "Store", "store", ")", "{", "List", "<", "String", ">", "goals", "=", "pluginExecution", ".", "getGoals", "(", ")", ";", "for", "(", "String", "goal", ":", "goals", ")", "{", "MavenExecutionGoalDescriptor", "goalDescriptor", "=", "store", ".", "create", "(", "MavenExecutionGoalDescriptor", ".", "class", ")", ";", "goalDescriptor", ".", "setName", "(", "goal", ")", ";", "executionDescriptor", ".", "getGoals", "(", ")", ".", "add", "(", "goalDescriptor", ")", ";", "}", "}" ]
Adds information about execution goals. @param executionDescriptor The descriptor for the execution. @param pluginExecution The PluginExecution. @param store The database.
[ "Adds", "information", "about", "execution", "goals", "." ]
6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f
https://github.com/buschmais/jqa-maven3-plugin/blob/6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f/src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenModelScannerPlugin.java#L318-L326
144,293
buschmais/jqa-maven3-plugin
src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenModelScannerPlugin.java
MavenModelScannerPlugin.addLicenses
private void addLicenses(MavenPomDescriptor pomDescriptor, Model model, Store store) { List<License> licenses = model.getLicenses(); for (License license : licenses) { MavenLicenseDescriptor licenseDescriptor = store.create(MavenLicenseDescriptor.class); licenseDescriptor.setUrl(license.getUrl()); licenseDescriptor.setComments(license.getComments()); licenseDescriptor.setName(license.getName()); licenseDescriptor.setDistribution(license.getDistribution()); pomDescriptor.getLicenses().add(licenseDescriptor); } }
java
private void addLicenses(MavenPomDescriptor pomDescriptor, Model model, Store store) { List<License> licenses = model.getLicenses(); for (License license : licenses) { MavenLicenseDescriptor licenseDescriptor = store.create(MavenLicenseDescriptor.class); licenseDescriptor.setUrl(license.getUrl()); licenseDescriptor.setComments(license.getComments()); licenseDescriptor.setName(license.getName()); licenseDescriptor.setDistribution(license.getDistribution()); pomDescriptor.getLicenses().add(licenseDescriptor); } }
[ "private", "void", "addLicenses", "(", "MavenPomDescriptor", "pomDescriptor", ",", "Model", "model", ",", "Store", "store", ")", "{", "List", "<", "License", ">", "licenses", "=", "model", ".", "getLicenses", "(", ")", ";", "for", "(", "License", "license", ":", "licenses", ")", "{", "MavenLicenseDescriptor", "licenseDescriptor", "=", "store", ".", "create", "(", "MavenLicenseDescriptor", ".", "class", ")", ";", "licenseDescriptor", ".", "setUrl", "(", "license", ".", "getUrl", "(", ")", ")", ";", "licenseDescriptor", ".", "setComments", "(", "license", ".", "getComments", "(", ")", ")", ";", "licenseDescriptor", ".", "setName", "(", "license", ".", "getName", "(", ")", ")", ";", "licenseDescriptor", ".", "setDistribution", "(", "license", ".", "getDistribution", "(", ")", ")", ";", "pomDescriptor", ".", "getLicenses", "(", ")", ".", "add", "(", "licenseDescriptor", ")", ";", "}", "}" ]
Adds information about references licenses. @param pomDescriptor The descriptor for the current POM. @param model The Maven Model. @param store The database.
[ "Adds", "information", "about", "references", "licenses", "." ]
6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f
https://github.com/buschmais/jqa-maven3-plugin/blob/6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f/src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenModelScannerPlugin.java#L338-L349
144,294
buschmais/jqa-maven3-plugin
src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenModelScannerPlugin.java
MavenModelScannerPlugin.addDevelopers
private void addDevelopers(MavenPomDescriptor pomDescriptor, Model model, Store store) { List<Developer> developers = model.getDevelopers(); for (Developer developer : developers) { MavenDeveloperDescriptor developerDescriptor = store.create(MavenDeveloperDescriptor.class); developerDescriptor.setId(developer.getId()); addCommonParticipantAttributes(developerDescriptor, developer, store); pomDescriptor.getDevelopers().add(developerDescriptor); } }
java
private void addDevelopers(MavenPomDescriptor pomDescriptor, Model model, Store store) { List<Developer> developers = model.getDevelopers(); for (Developer developer : developers) { MavenDeveloperDescriptor developerDescriptor = store.create(MavenDeveloperDescriptor.class); developerDescriptor.setId(developer.getId()); addCommonParticipantAttributes(developerDescriptor, developer, store); pomDescriptor.getDevelopers().add(developerDescriptor); } }
[ "private", "void", "addDevelopers", "(", "MavenPomDescriptor", "pomDescriptor", ",", "Model", "model", ",", "Store", "store", ")", "{", "List", "<", "Developer", ">", "developers", "=", "model", ".", "getDevelopers", "(", ")", ";", "for", "(", "Developer", "developer", ":", "developers", ")", "{", "MavenDeveloperDescriptor", "developerDescriptor", "=", "store", ".", "create", "(", "MavenDeveloperDescriptor", ".", "class", ")", ";", "developerDescriptor", ".", "setId", "(", "developer", ".", "getId", "(", ")", ")", ";", "addCommonParticipantAttributes", "(", "developerDescriptor", ",", "developer", ",", "store", ")", ";", "pomDescriptor", ".", "getDevelopers", "(", ")", ".", "add", "(", "developerDescriptor", ")", ";", "}", "}" ]
Adds information about developers. @param pomDescriptor The descriptor for the current POM. @param model The Maven Model. @param store The database.
[ "Adds", "information", "about", "developers", "." ]
6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f
https://github.com/buschmais/jqa-maven3-plugin/blob/6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f/src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenModelScannerPlugin.java#L361-L371
144,295
buschmais/jqa-maven3-plugin
src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenModelScannerPlugin.java
MavenModelScannerPlugin.addManagedDependencies
private List<MavenDependencyDescriptor> addManagedDependencies(MavenDependentDescriptor pomDescriptor, DependencyManagement dependencyManagement, ScannerContext scannerContext, Class<? extends AbstractDependencyDescriptor> relationClass) { if (dependencyManagement == null) { return Collections.emptyList(); } List<Dependency> dependencies = dependencyManagement.getDependencies(); return getDependencies(pomDescriptor, dependencies, relationClass, scannerContext); }
java
private List<MavenDependencyDescriptor> addManagedDependencies(MavenDependentDescriptor pomDescriptor, DependencyManagement dependencyManagement, ScannerContext scannerContext, Class<? extends AbstractDependencyDescriptor> relationClass) { if (dependencyManagement == null) { return Collections.emptyList(); } List<Dependency> dependencies = dependencyManagement.getDependencies(); return getDependencies(pomDescriptor, dependencies, relationClass, scannerContext); }
[ "private", "List", "<", "MavenDependencyDescriptor", ">", "addManagedDependencies", "(", "MavenDependentDescriptor", "pomDescriptor", ",", "DependencyManagement", "dependencyManagement", ",", "ScannerContext", "scannerContext", ",", "Class", "<", "?", "extends", "AbstractDependencyDescriptor", ">", "relationClass", ")", "{", "if", "(", "dependencyManagement", "==", "null", ")", "{", "return", "Collections", ".", "emptyList", "(", ")", ";", "}", "List", "<", "Dependency", ">", "dependencies", "=", "dependencyManagement", ".", "getDependencies", "(", ")", ";", "return", "getDependencies", "(", "pomDescriptor", ",", "dependencies", ",", "relationClass", ",", "scannerContext", ")", ";", "}" ]
Adds dependency management information. @param pomDescriptor The descriptor for the current POM. @param dependencyManagement The dependency management information. @param scannerContext
[ "Adds", "dependency", "management", "information", "." ]
6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f
https://github.com/buschmais/jqa-maven3-plugin/blob/6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f/src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenModelScannerPlugin.java#L382-L389
144,296
buschmais/jqa-maven3-plugin
src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenModelScannerPlugin.java
MavenModelScannerPlugin.addManagedPlugins
private void addManagedPlugins(BaseProfileDescriptor pomDescriptor, BuildBase build, ScannerContext scannerContext) { if (null == build) { return; } PluginManagement pluginManagement = build.getPluginManagement(); if (null == pluginManagement) { return; } List<MavenPluginDescriptor> pluginDescriptors = createMavenPluginDescriptors(pluginManagement.getPlugins(), scannerContext); pomDescriptor.getManagedPlugins().addAll(pluginDescriptors); }
java
private void addManagedPlugins(BaseProfileDescriptor pomDescriptor, BuildBase build, ScannerContext scannerContext) { if (null == build) { return; } PluginManagement pluginManagement = build.getPluginManagement(); if (null == pluginManagement) { return; } List<MavenPluginDescriptor> pluginDescriptors = createMavenPluginDescriptors(pluginManagement.getPlugins(), scannerContext); pomDescriptor.getManagedPlugins().addAll(pluginDescriptors); }
[ "private", "void", "addManagedPlugins", "(", "BaseProfileDescriptor", "pomDescriptor", ",", "BuildBase", "build", ",", "ScannerContext", "scannerContext", ")", "{", "if", "(", "null", "==", "build", ")", "{", "return", ";", "}", "PluginManagement", "pluginManagement", "=", "build", ".", "getPluginManagement", "(", ")", ";", "if", "(", "null", "==", "pluginManagement", ")", "{", "return", ";", "}", "List", "<", "MavenPluginDescriptor", ">", "pluginDescriptors", "=", "createMavenPluginDescriptors", "(", "pluginManagement", ".", "getPlugins", "(", ")", ",", "scannerContext", ")", ";", "pomDescriptor", ".", "getManagedPlugins", "(", ")", ".", "addAll", "(", "pluginDescriptors", ")", ";", "}" ]
Adds information about managed plugins. @param pomDescriptor The descriptor for the current POM. @param build Information required to build the project. @param scannerContext The scanner context.
[ "Adds", "information", "about", "managed", "plugins", "." ]
6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f
https://github.com/buschmais/jqa-maven3-plugin/blob/6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f/src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenModelScannerPlugin.java#L401-L411
144,297
buschmais/jqa-maven3-plugin
src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenModelScannerPlugin.java
MavenModelScannerPlugin.createMavenPluginDescriptors
private List<MavenPluginDescriptor> createMavenPluginDescriptors(List<Plugin> plugins, ScannerContext context) { Store store = context.getStore(); List<MavenPluginDescriptor> pluginDescriptors = new ArrayList<>(); for (Plugin plugin : plugins) { MavenPluginDescriptor mavenPluginDescriptor = store.create(MavenPluginDescriptor.class); MavenArtifactDescriptor artifactDescriptor = getArtifactResolver(context).resolve(new PluginCoordinates(plugin), context); mavenPluginDescriptor.setArtifact(artifactDescriptor); mavenPluginDescriptor.setInherited(plugin.isInherited()); mavenPluginDescriptor.getDeclaresDependencies() .addAll(getDependencies(mavenPluginDescriptor, plugin.getDependencies(), PluginDependsOnDescriptor.class, context)); addPluginExecutions(mavenPluginDescriptor, plugin, store); addConfiguration(mavenPluginDescriptor, (Xpp3Dom) plugin.getConfiguration(), store); pluginDescriptors.add(mavenPluginDescriptor); } return pluginDescriptors; }
java
private List<MavenPluginDescriptor> createMavenPluginDescriptors(List<Plugin> plugins, ScannerContext context) { Store store = context.getStore(); List<MavenPluginDescriptor> pluginDescriptors = new ArrayList<>(); for (Plugin plugin : plugins) { MavenPluginDescriptor mavenPluginDescriptor = store.create(MavenPluginDescriptor.class); MavenArtifactDescriptor artifactDescriptor = getArtifactResolver(context).resolve(new PluginCoordinates(plugin), context); mavenPluginDescriptor.setArtifact(artifactDescriptor); mavenPluginDescriptor.setInherited(plugin.isInherited()); mavenPluginDescriptor.getDeclaresDependencies() .addAll(getDependencies(mavenPluginDescriptor, plugin.getDependencies(), PluginDependsOnDescriptor.class, context)); addPluginExecutions(mavenPluginDescriptor, plugin, store); addConfiguration(mavenPluginDescriptor, (Xpp3Dom) plugin.getConfiguration(), store); pluginDescriptors.add(mavenPluginDescriptor); } return pluginDescriptors; }
[ "private", "List", "<", "MavenPluginDescriptor", ">", "createMavenPluginDescriptors", "(", "List", "<", "Plugin", ">", "plugins", ",", "ScannerContext", "context", ")", "{", "Store", "store", "=", "context", ".", "getStore", "(", ")", ";", "List", "<", "MavenPluginDescriptor", ">", "pluginDescriptors", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "Plugin", "plugin", ":", "plugins", ")", "{", "MavenPluginDescriptor", "mavenPluginDescriptor", "=", "store", ".", "create", "(", "MavenPluginDescriptor", ".", "class", ")", ";", "MavenArtifactDescriptor", "artifactDescriptor", "=", "getArtifactResolver", "(", "context", ")", ".", "resolve", "(", "new", "PluginCoordinates", "(", "plugin", ")", ",", "context", ")", ";", "mavenPluginDescriptor", ".", "setArtifact", "(", "artifactDescriptor", ")", ";", "mavenPluginDescriptor", ".", "setInherited", "(", "plugin", ".", "isInherited", "(", ")", ")", ";", "mavenPluginDescriptor", ".", "getDeclaresDependencies", "(", ")", ".", "addAll", "(", "getDependencies", "(", "mavenPluginDescriptor", ",", "plugin", ".", "getDependencies", "(", ")", ",", "PluginDependsOnDescriptor", ".", "class", ",", "context", ")", ")", ";", "addPluginExecutions", "(", "mavenPluginDescriptor", ",", "plugin", ",", "store", ")", ";", "addConfiguration", "(", "mavenPluginDescriptor", ",", "(", "Xpp3Dom", ")", "plugin", ".", "getConfiguration", "(", ")", ",", "store", ")", ";", "pluginDescriptors", ".", "add", "(", "mavenPluginDescriptor", ")", ";", "}", "return", "pluginDescriptors", ";", "}" ]
Create plugin descriptors for the given plugins. @param plugins The plugins. @param context The scanner context. @return The plugin descriptors.
[ "Create", "plugin", "descriptors", "for", "the", "given", "plugins", "." ]
6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f
https://github.com/buschmais/jqa-maven3-plugin/blob/6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f/src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenModelScannerPlugin.java#L422-L437
144,298
buschmais/jqa-maven3-plugin
src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenModelScannerPlugin.java
MavenModelScannerPlugin.addModules
private void addModules(BaseProfileDescriptor pomDescriptor, List<String> modules, Store store) { for (String module : modules) { MavenModuleDescriptor moduleDescriptor = store.create(MavenModuleDescriptor.class); moduleDescriptor.setName(module); pomDescriptor.getModules().add(moduleDescriptor); } }
java
private void addModules(BaseProfileDescriptor pomDescriptor, List<String> modules, Store store) { for (String module : modules) { MavenModuleDescriptor moduleDescriptor = store.create(MavenModuleDescriptor.class); moduleDescriptor.setName(module); pomDescriptor.getModules().add(moduleDescriptor); } }
[ "private", "void", "addModules", "(", "BaseProfileDescriptor", "pomDescriptor", ",", "List", "<", "String", ">", "modules", ",", "Store", "store", ")", "{", "for", "(", "String", "module", ":", "modules", ")", "{", "MavenModuleDescriptor", "moduleDescriptor", "=", "store", ".", "create", "(", "MavenModuleDescriptor", ".", "class", ")", ";", "moduleDescriptor", ".", "setName", "(", "module", ")", ";", "pomDescriptor", ".", "getModules", "(", ")", ".", "add", "(", "moduleDescriptor", ")", ";", "}", "}" ]
Adds information about referenced modules. @param pomDescriptor The descriptor for the current POM. @param modules The modules. @param store The database.
[ "Adds", "information", "about", "referenced", "modules", "." ]
6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f
https://github.com/buschmais/jqa-maven3-plugin/blob/6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f/src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenModelScannerPlugin.java#L462-L469
144,299
buschmais/jqa-maven3-plugin
src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenModelScannerPlugin.java
MavenModelScannerPlugin.addParent
private void addParent(MavenPomDescriptor pomDescriptor, Model model, ScannerContext context) { Parent parent = model.getParent(); if (null != parent) { ArtifactResolver resolver = getArtifactResolver(context); MavenArtifactDescriptor parentDescriptor = resolver.resolve(new ParentCoordinates(parent), context); pomDescriptor.setParent(parentDescriptor); } }
java
private void addParent(MavenPomDescriptor pomDescriptor, Model model, ScannerContext context) { Parent parent = model.getParent(); if (null != parent) { ArtifactResolver resolver = getArtifactResolver(context); MavenArtifactDescriptor parentDescriptor = resolver.resolve(new ParentCoordinates(parent), context); pomDescriptor.setParent(parentDescriptor); } }
[ "private", "void", "addParent", "(", "MavenPomDescriptor", "pomDescriptor", ",", "Model", "model", ",", "ScannerContext", "context", ")", "{", "Parent", "parent", "=", "model", ".", "getParent", "(", ")", ";", "if", "(", "null", "!=", "parent", ")", "{", "ArtifactResolver", "resolver", "=", "getArtifactResolver", "(", "context", ")", ";", "MavenArtifactDescriptor", "parentDescriptor", "=", "resolver", ".", "resolve", "(", "new", "ParentCoordinates", "(", "parent", ")", ",", "context", ")", ";", "pomDescriptor", ".", "setParent", "(", "parentDescriptor", ")", ";", "}", "}" ]
Adds information about parent POM. @param pomDescriptor The descriptor for the current POM. @param model The Maven Model. @param context The scanner context.
[ "Adds", "information", "about", "parent", "POM", "." ]
6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f
https://github.com/buschmais/jqa-maven3-plugin/blob/6c6e2dca56de6d5b8ceeb2f28982fb6d7c98778f/src/main/java/com/buschmais/jqassistant/plugin/maven3/impl/scanner/MavenModelScannerPlugin.java#L481-L488