signature:
public class AutomagicMadvocConfigurator { /** * Parses class name that matches madvoc - related names . */
protected void registerAsConsumer ( final ClassScanner classScanner ) { } }

implementation: classScanner . registerEntryConsumer ( classPathEntry -> { final String entryName = classPathEntry . name ( ) ; if ( entryName . endsWith ( actionClassSuffix ) ) { try { acceptActionClass ( classPathEntry . loadClass ( ) ) ; } catch ( Exception ex ) { log . debug ( "Invalid Madvoc action, ignoring: " + entryName ) ; } } else if ( classPathEntry . isTypeSignatureInUse ( MADVOC_COMPONENT_ANNOTATION ) ) { try { acceptMadvocComponentClass ( classPathEntry . loadClass ( ) ) ; } catch ( Exception ex ) { log . debug ( "Invalid Madvoc component ignoring: {}" + entryName ) ; } } } ) ;


signature:
public class AutomagicMadvocConfigurator { /** * Determines if class should be examined for Madvoc annotations .
 * Array , anonymous , primitive , interfaces and so on should be
 * ignored . Sometimes , checking may fail due to e . g . < code > NoClassDefFoundError < / code > ;
 * we should continue searching anyway . */
protected boolean checkClass ( final Class clazz ) { } }

implementation: try { if ( clazz . isAnonymousClass ( ) ) { return false ; } if ( clazz . isArray ( ) || clazz . isEnum ( ) ) { return false ; } if ( clazz . isInterface ( ) ) { return false ; } if ( clazz . isLocalClass ( ) ) { return false ; } if ( ( clazz . isMemberClass ( ) ^ Modifier . isStatic ( clazz . getModifiers ( ) ) ) ) { return false ; } if ( clazz . isPrimitive ( ) ) { return false ; } int modifiers = clazz . getModifiers ( ) ; if ( Modifier . isAbstract ( modifiers ) ) { return false ; } return true ; } catch ( Throwable ignore ) { return false ; }


signature:
public class AutomagicMadvocConfigurator { /** * Builds action runtime configuration on founded action class .
 * Action classes are annotated with { @ link jodd . madvoc . meta . MadvocAction } annotation . */
@ SuppressWarnings ( "NonConstantStringShouldBeStringBuffer" ) protected void acceptActionClass ( final Class < ? > actionClass ) { } }

implementation:
if ( actionClass == null ) { return ; } if ( ! checkClass ( actionClass ) ) { return ; } if ( actionClass . getAnnotation ( MadvocAction . class ) == null ) { return ; } ClassDescriptor cd = ClassIntrospector . get ( ) . lookup ( actionClass ) ; MethodDescriptor [ ] allMethodDescriptors = cd . getAllMethodDescriptors ( ) ; for ( MethodDescriptor methodDescriptor : allMethodDescriptors ) { if ( ! methodDescriptor . isPublic ( ) ) { continue ; } // just public methods
final Method method = methodDescriptor . getMethod ( ) ; final boolean hasAnnotation = actionConfigManager . hasActionAnnotationOn ( method ) ; if ( ! hasAnnotation ) { continue ; } webappConfigurations . add ( ( ) -> actionsManager . registerAction ( actionClass , method , null ) ) ; }


signature:
public class AutomagicMadvocConfigurator { /** * Registers new Madvoc component . */
protected void acceptMadvocComponentClass ( final Class componentClass ) { } }

implementation: if ( componentClass == null ) { return ; } if ( ! checkClass ( componentClass ) ) { return ; } madvocComponents . add ( ( ) -> madvocContainer . registerComponent ( componentClass ) ) ;


signature:
public class ClassLoaderUtil { /** * Returns default class loader . By default , it is { @ link # getContextClassLoader ( ) threads context class loader } .
 * If this one is < code > null < / code > , then class loader of the < b > caller class < / b > is returned . */
public static ClassLoader getDefaultClassLoader ( ) { } }

implementation: ClassLoader cl = getContextClassLoader ( ) ; if ( cl == null ) { Class callerClass = ClassUtil . getCallerClass ( 2 ) ; cl = callerClass . getClassLoader ( ) ; } return cl ;


signature:
public class ClassLoaderUtil { /** * Returns system class loader . */
public static ClassLoader getSystemClassLoader ( ) { } }

implementation: if ( System . getSecurityManager ( ) == null ) { return ClassLoader . getSystemClassLoader ( ) ; } else { return AccessController . doPrivileged ( ( PrivilegedAction < ClassLoader > ) ClassLoader :: getSystemClassLoader ) ; }


signature:
public class ClassLoaderUtil { /** * Returns classpath item manifest or < code > null < / code > if not found . */
public static Manifest getClasspathItemManifest ( final File classpathItem ) { } }

implementation: Manifest manifest = null ; if ( classpathItem . isFile ( ) ) { FileInputStream fis = null ; try { fis = new FileInputStream ( classpathItem ) ; JarFile jar = new JarFile ( classpathItem ) ; manifest = jar . getManifest ( ) ; } catch ( IOException ignore ) { } finally { StreamUtil . close ( fis ) ; } } else { File metaDir = new File ( classpathItem , "META-INF" ) ; File manifestFile = null ; if ( metaDir . isDirectory ( ) ) { for ( String m : MANIFESTS ) { File mFile = new File ( metaDir , m ) ; if ( mFile . isFile ( ) ) { manifestFile = mFile ; break ; } } } if ( manifestFile != null ) { FileInputStream fis = null ; try { fis = new FileInputStream ( manifestFile ) ; manifest = new Manifest ( fis ) ; } catch ( IOException ignore ) { } finally { StreamUtil . close ( fis ) ; } } } return manifest ;


signature:
public class ClassLoaderUtil { /** * Returns base folder for classpath item . If item is a ( jar ) file ,
 * its parent is returned . If item is a directory , its name is returned . */
public static String getClasspathItemBaseDir ( final File classpathItem ) { } }

implementation: String base ; if ( classpathItem . isFile ( ) ) { base = classpathItem . getParent ( ) ; } else { base = classpathItem . toString ( ) ; } return base ;


signature:
public class ClassLoaderUtil { /** * Returns default class path from all available < code > URLClassLoader < / code >
 * in classloader hierarchy . The following is added to the classpath list :
 * < ul >
 * < li > file URLs from < code > URLClassLoader < / code > ( other URL protocols are ignored ) < / li >
 * < li > inner entries from containing < b > manifest < / b > files ( if exist ) < / li >
 * < li > bootstrap classpath is ignored < / li >
 * < / ul > */
public static File [ ] getDefaultClasspath ( ClassLoader classLoader ) { } }

implementation: Set < File > classpaths = new TreeSet < > ( ) ; while ( classLoader != null ) { URL [ ] urls = ClassPathURLs . of ( classLoader , null ) ; if ( urls != null ) { for ( URL u : urls ) { File f = FileUtil . toContainerFile ( u ) ; if ( ( f != null ) && f . exists ( ) ) { try { f = f . getCanonicalFile ( ) ; boolean newElement = classpaths . add ( f ) ; if ( newElement ) { addInnerClasspathItems ( classpaths , f ) ; } } catch ( IOException ignore ) { } } } } classLoader = classLoader . getParent ( ) ; } File [ ] result = new File [ classpaths . size ( ) ] ; return classpaths . toArray ( result ) ;


signature:
public class ClassLoaderUtil { /** * Retrieves given resource as URL . Resource is always absolute and may
 * starts with a slash character .
 * Resource will be loaded using class loaders in the following order :
 * < ul >
 * < li > { @ link Thread # getContextClassLoader ( ) Thread . currentThread ( ) . getContextClassLoader ( ) } < / li >
 * < li > { @ link Class # getClassLoader ( ) ClassLoaderUtil . class . getClassLoader ( ) } < / li >
 * < li > if < code > callingClass < / code > is provided : { @ link Class # getClassLoader ( ) callingClass . getClassLoader ( ) } < / li >
 * < / ul > */
public static URL getResourceUrl ( String resourceName , final ClassLoader classLoader ) { } }

implementation:
if ( resourceName . startsWith ( "/" ) ) { resourceName = resourceName . substring ( 1 ) ; } URL resourceUrl ; // try # 1 - using provided class loader
if ( classLoader != null ) { resourceUrl = classLoader . getResource ( resourceName ) ; if ( resourceUrl != null ) { return resourceUrl ; } } // try # 2 - using thread class loader
ClassLoader currentThreadClassLoader = Thread . currentThread ( ) . getContextClassLoader ( ) ; if ( ( currentThreadClassLoader != null ) && ( currentThreadClassLoader != classLoader ) ) { resourceUrl = currentThreadClassLoader . getResource ( resourceName ) ; if ( resourceUrl != null ) { return resourceUrl ; } } // try # 3 - using caller classloader , similar as Class . forName ( )
Class callerClass = ClassUtil . getCallerClass ( 2 ) ; ClassLoader callerClassLoader = callerClass . getClassLoader ( ) ; if ( ( callerClassLoader != classLoader ) && ( callerClassLoader != currentThreadClassLoader ) ) { resourceUrl = callerClassLoader . getResource ( resourceName ) ; if ( resourceUrl != null ) { return resourceUrl ; } } return null ;


signature:
public class ClassLoaderUtil { /** * Opens a resource of the specified name for reading .
 * @ see # getResourceUrl ( String , ClassLoader ) */
public static InputStream getResourceAsStream ( final String resourceName , final ClassLoader callingClass ) throws IOException { } }

implementation: URL url = getResourceUrl ( resourceName , callingClass ) ; if ( url != null ) { return url . openStream ( ) ; } return null ;


signature:
public class ClassLoaderUtil { /** * Opens a resource of the specified name for reading . Controls caching ,
 * that is important when the same jar is reloaded using custom classloader . */
public static InputStream getResourceAsStream ( final String resourceName , final ClassLoader callingClass , final boolean useCache ) throws IOException { } }

implementation: URL url = getResourceUrl ( resourceName , callingClass ) ; if ( url != null ) { URLConnection urlConnection = url . openConnection ( ) ; urlConnection . setUseCaches ( useCache ) ; return urlConnection . getInputStream ( ) ; } return null ;


signature:
public class ClassLoaderUtil { /** * Opens a class of the specified name for reading using class classloader .
 * @ see # getResourceAsStream ( String , ClassLoader ) */
public static InputStream getClassAsStream ( final Class clazz ) throws IOException { } }

implementation: return getResourceAsStream ( ClassUtil . convertClassNameToFileName ( clazz ) , clazz . getClassLoader ( ) ) ;


signature:
public class ClassLoaderUtil { /** * Opens a class of the specified name for reading using provided class loader . */
public static InputStream getClassAsStream ( final String className , final ClassLoader classLoader ) throws IOException { } }

implementation: return getResourceAsStream ( ClassUtil . convertClassNameToFileName ( className ) , classLoader ) ;


signature:
public class ClassLoaderUtil { /** * Loads a class using default class loader strategy .
 * @ see jodd . util . cl . DefaultClassLoaderStrategy */
public static Class loadClass ( final String className ) throws ClassNotFoundException { } }

implementation: return ClassLoaderStrategy . get ( ) . loadClass ( className , null ) ;


signature:
public class ClassLoaderUtil { /** * Loads a class using default class loader strategy .
 * @ see jodd . util . cl . DefaultClassLoaderStrategy */
public static Class loadClass ( final String className , final ClassLoader classLoader ) throws ClassNotFoundException { } }

implementation: return ClassLoaderStrategy . get ( ) . loadClass ( className , classLoader ) ;


signature:
public class RouteChunk { /** * Adds a new child to the tree . */
public RouteChunk add ( final String newValue ) { } }

implementation: RouteChunk routeChunk = new RouteChunk ( routes , this , newValue ) ; if ( children == null ) { children = new RouteChunk [ ] { routeChunk } ; } else { children = ArraysUtil . append ( children , routeChunk ) ; } return routeChunk ;


signature:
public class RouteChunk { /** * Finds existing chunk or creates a new one if does not exist . */
public RouteChunk findOrCreateChild ( final String value ) { } }

implementation: if ( children != null ) { for ( RouteChunk child : children ) { if ( child . get ( ) . equals ( value ) ) { return child ; } } } return add ( value ) ;


signature:
public class RouteChunk { /** * Returns { @ code true } if path chunk value matches the input . */
public boolean match ( final String value ) { } }

implementation: if ( pathMacros == null ) { return this . value . equals ( value ) ; } return pathMacros . match ( value ) != - 1 ;


signature:
public class MultipartRequest { /** * Returns new or existing instance of < code > MultipartRequest < / code > . */
public static MultipartRequest getInstance ( final HttpServletRequest request , final FileUploadFactory fileUploadFactory , final String encoding ) throws IOException { } }

implementation: MultipartRequest mreq = ( MultipartRequest ) request . getAttribute ( MREQ_ATTR_NAME ) ; if ( mreq == null ) { mreq = new MultipartRequest ( request , fileUploadFactory , encoding ) ; request . setAttribute ( MREQ_ATTR_NAME , mreq ) ; } if ( ! mreq . isParsed ( ) ) { mreq . parseRequest ( ) ; } return mreq ;


signature:
public class MultipartRequest { /** * Checks if request if multi - part and parse it . If request is not multi - part it
 * copies all parameters , to make usage the same in both cases .
 * @ see MultipartRequestWrapper */
public void parseRequest ( ) throws IOException { } }

implementation: if ( ServletUtil . isMultipartRequest ( request ) ) { parseRequestStream ( request . getInputStream ( ) , characterEncoding ) ; } else { Enumeration names = request . getParameterNames ( ) ; while ( names . hasMoreElements ( ) ) { String paramName = ( String ) names . nextElement ( ) ; String [ ] values = request . getParameterValues ( paramName ) ; putParameters ( paramName , values ) ; } }


signature:
public class BeanUtilUtil { /** * Converts object to destination type . Invoked before the
 * value is set into destination . Throws < code > TypeConversionException < / code >
 * if conversion fails . */
@ SuppressWarnings ( "unchecked" ) protected Object convertType ( final Object value , final Class type ) { } }

implementation: return typeConverterManager . convertType ( value , type ) ;


signature:
public class BeanUtilUtil { /** * Converter to collection . */
@ SuppressWarnings ( "unchecked" ) protected Object convertToCollection ( final Object value , final Class destinationType , final Class componentType ) { } }

implementation: return typeConverterManager . convertToCollection ( value , destinationType , componentType ) ;


signature:
public class BeanUtilUtil { /** * Invokes setter , but first converts type to match the setter type . */
protected Object invokeSetter ( final Setter setter , final BeanProperty bp , Object value ) { } }

implementation:
try { final MapperFunction setterMapperFunction = setter . getMapperFunction ( ) ; if ( setterMapperFunction != null ) { value = setterMapperFunction . apply ( value ) ; } final Class type = setter . getSetterRawType ( ) ; if ( ClassUtil . isTypeOf ( type , Collection . class ) ) { Class componentType = setter . getSetterRawComponentType ( ) ; value = convertToCollection ( value , type , componentType ) ; } else { // no collections
value = convertType ( value , type ) ; } setter . invokeSetter ( bp . bean , value ) ; } catch ( Exception ex ) { if ( isSilent ) { return null ; } throw new BeanException ( "Setter failed: " + setter , ex ) ; } return value ;


signature:
public class BeanUtilUtil { /** * Returns the element of an array forced . If value is < code > null < / code > , it will be instantiated .
 * If not the last part of indexed bean property , array will be expanded to the index if necessary . */
protected Object arrayForcedGet ( final BeanProperty bp , Object array , final int index ) { } }

implementation:
Class componentType = array . getClass ( ) . getComponentType ( ) ; if ( ! bp . last ) { array = ensureArraySize ( bp , array , componentType , index ) ; } Object value = Array . get ( array , index ) ; if ( value == null ) { try { // noinspection unchecked
value = ClassUtil . newInstance ( componentType ) ; } catch ( Exception ex ) { if ( isSilent ) { return null ; } throw new BeanException ( "Invalid array element: " + bp . name + '[' + index + ']' , bp , ex ) ; } Array . set ( array , index , value ) ; } return value ;


signature:
public class BeanUtilUtil { /** * Sets the array element forced . If index is greater then arrays length , array will be expanded to the index .
 * If speed is critical , it is better to allocate an array with proper size before using this method . */
protected void arrayForcedSet ( final BeanProperty bp , Object array , final int index , Object value ) { } }

implementation: Class componentType = array . getClass ( ) . getComponentType ( ) ; array = ensureArraySize ( bp , array , componentType , index ) ; value = convertType ( value , componentType ) ; Array . set ( array , index , value ) ;


signature:
public class BeanUtilUtil { /** * Finds the very first next dot . Ignores dots between index brackets .
 * Returns < code > - 1 < / code > when dot is not found . */
protected int indexOfDot ( final String name ) { } }

implementation: int ndx = 0 ; int len = name . length ( ) ; boolean insideBracket = false ; while ( ndx < len ) { char c = name . charAt ( ndx ) ; if ( insideBracket ) { if ( c == ']' ) { insideBracket = false ; } } else { if ( c == '.' ) { return ndx ; } if ( c == '[' ) { insideBracket = true ; } } ndx ++ ; } return - 1 ;


signature:
public class BeanUtilUtil { /** * Extract index string from non - nested property name .
 * If index is found , it is stripped from bean property name .
 * If no index is found , it returns < code > null < / code > . */
protected String extractIndex ( final BeanProperty bp ) { } }

implementation: bp . index = null ; String name = bp . name ; int lastNdx = name . length ( ) - 1 ; if ( lastNdx < 0 ) { return null ; } if ( name . charAt ( lastNdx ) == ']' ) { int leftBracketNdx = name . lastIndexOf ( '[' ) ; if ( leftBracketNdx != - 1 ) { bp . setName ( name . substring ( 0 , leftBracketNdx ) ) ; bp . index = name . substring ( leftBracketNdx + 1 , lastNdx ) ; return bp . index ; } } return null ;


signature:
public class BeanUtilUtil { /** * Creates new instance for current property name through its setter .
 * It uses default constructor ! */
protected Object createBeanProperty ( final BeanProperty bp ) { } }

implementation: Setter setter = bp . getSetter ( true ) ; if ( setter == null ) { return null ; } Class type = setter . getSetterRawType ( ) ; Object newInstance ; try { newInstance = ClassUtil . newInstance ( type ) ; } catch ( Exception ex ) { if ( isSilent ) { return null ; } throw new BeanException ( "Invalid property: " + bp . name , bp , ex ) ; } newInstance = invokeSetter ( setter , bp , newInstance ) ; return newInstance ;


signature:
public class BeanUtilUtil { /** * Extracts generic component type of a property . Returns < code > Object . class < / code >
 * when property does not have component . */
protected Class extractGenericComponentType ( final Getter getter ) { } }

implementation: Class componentType = null ; if ( getter != null ) { componentType = getter . getGetterRawComponentType ( ) ; } if ( componentType == null ) { componentType = Object . class ; } return componentType ;


signature:
public class BeanUtilUtil { /** * Converts < b > Map < / b > index to key type . If conversion fails , original value will be returned . */
protected Object convertIndexToMapKey ( final Getter getter , final Object index ) { } }

implementation:
Class indexType = null ; if ( getter != null ) { indexType = getter . getGetterRawKeyComponentType ( ) ; } // check if set
if ( indexType == null ) { indexType = Object . class ; // marker for no generic type
} if ( indexType == Object . class ) { return index ; } try { return convertType ( index , indexType ) ; } catch ( Exception ignore ) { return index ; }


signature:
public class BeanUtilUtil { /** * Extracts type of current property . */
protected Class extractType ( final BeanProperty bp ) { } }

implementation: Getter getter = bp . getGetter ( isDeclared ) ; if ( getter != null ) { if ( bp . index != null ) { Class type = getter . getGetterRawComponentType ( ) ; return type == null ? Object . class : type ; } return getter . getGetterRawType ( ) ; } return null ; // this should not happens


signature:
public class UserSession { /** * Retrieves the user session from the HTTP session . Returns { @ code null }
 * if no session found . */
public static UserSession get ( final HttpServletRequest httpServletRequest ) { } }

implementation: final HttpSession httpSession = httpServletRequest . getSession ( false ) ; if ( httpSession == null ) { return null ; } return ( UserSession ) httpSession . getAttribute ( AUTH_SESSION_NAME ) ;


signature:
public class UserSession { /** * Stops the user session by removing it from the http session and invalidating the cookie . */
public static void stop ( final HttpServletRequest servletRequest , final HttpServletResponse servletResponse ) { } }

implementation: final HttpSession httpSession = servletRequest . getSession ( false ) ; if ( httpSession != null ) { httpSession . removeAttribute ( AUTH_SESSION_NAME ) ; } final Cookie cookie = ServletUtil . getCookie ( servletRequest , AUTH_COOKIE_NAME ) ; if ( cookie == null ) { return ; } cookie . setMaxAge ( 0 ) ; cookie . setPath ( "/" ) ; servletResponse . addCookie ( cookie ) ;


signature:
public class UserSession { /** * Starts new user session . */
public void start ( final HttpServletRequest httpServletRequest , final HttpServletResponse httpServletResponse ) { } }

implementation:
final HttpSession httpSession = httpServletRequest . getSession ( true ) ; httpSession . setAttribute ( AUTH_SESSION_NAME , this ) ; final Cookie cookie = new Cookie ( AUTH_COOKIE_NAME , authTokenValue ) ; // cookie . setDomain ( SSORealm . SSO _ DOMAIN ) ;
cookie . setMaxAge ( cookieMaxAge ) ; cookie . setPath ( "/" ) ; httpServletResponse . addCookie ( cookie ) ;


signature:
public class TimeUtil { /** * Converts local date to Date . */
public static Date toDate ( final LocalDate localDate ) { } }

implementation: return Date . from ( localDate . atStartOfDay ( ZoneId . systemDefault ( ) ) . toInstant ( ) ) ;


signature:
public class TimeUtil { /** * Converts local date time to Calendar . */
public static Calendar toCalendar ( final LocalDateTime localDateTime ) { } }

implementation: return GregorianCalendar . from ( ZonedDateTime . of ( localDateTime , ZoneId . systemDefault ( ) ) ) ;


signature:
public class TimeUtil { /** * Formats time to HTTP date / time format . Note that number of milliseconds
 * is lost . */
public static String formatHttpDate ( final long millis ) { } }

implementation: final Date date = new Date ( millis ) ; return HTTP_DATE_FORMAT . format ( date ) ;


signature:
public class TimeUtil { /** * Parses the HTTP date / time format . Returns < code > - 1 < / code > if given string
 * is invalid . */
public static long parseHttpTime ( final String time ) { } }

implementation: if ( time == null ) { return - 1 ; } try { return TimeUtil . HTTP_DATE_FORMAT . parse ( time ) . getTime ( ) ; } catch ( ParseException e ) { return - 1 ; }


signature:
public class MethrefProxetta { /** * Generates new class . */
public Class defineProxy ( final Class target ) { } }

implementation: ProxyProxettaFactory builder = proxetta . proxy ( ) ; builder . setTarget ( target ) ; return builder . define ( ) ;


signature:
public class ValidationContext { /** * Adds validation checks . */
public void add ( final Check check ) { } }

implementation: String name = check . getName ( ) ; List < Check > list = map . computeIfAbsent ( name , k -> new ArrayList < > ( ) ) ; list . add ( check ) ;


signature:
public class ValidationContext { /** * Resolve validation context for provided target class .
 * @ see # addClassChecks ( Class ) */
public static ValidationContext resolveFor ( final Class < ? > target ) { } }

implementation: ValidationContext vc = new ValidationContext ( ) ; vc . addClassChecks ( target ) ; return vc ;


signature:
public class ValidationContext { /** * Parses class annotations and adds all checks .
 * @ see # resolveFor ( Class ) */
public void addClassChecks ( final Class target ) { } }

implementation: final List < Check > list = cache . get ( target , ( ) -> { final List < Check > newList = new ArrayList < > ( ) ; final ClassDescriptor cd = ClassIntrospector . get ( ) . lookup ( target ) ; final PropertyDescriptor [ ] allProperties = cd . getAllPropertyDescriptors ( ) ; for ( PropertyDescriptor propertyDescriptor : allProperties ) { collectPropertyAnnotationChecks ( newList , propertyDescriptor ) ; } return newList ; } ) ; addAll ( list ) ;


signature:
public class ValidationContext { /** * Process all annotations of provided properties . */
protected void collectPropertyAnnotationChecks ( final List < Check > annChecks , final PropertyDescriptor propertyDescriptor ) { } }

implementation: FieldDescriptor fd = propertyDescriptor . getFieldDescriptor ( ) ; if ( fd != null ) { Annotation [ ] annotations = fd . getField ( ) . getAnnotations ( ) ; collectAnnotationChecks ( annChecks , propertyDescriptor . getType ( ) , propertyDescriptor . getName ( ) , annotations ) ; } MethodDescriptor md = propertyDescriptor . getReadMethodDescriptor ( ) ; if ( md != null ) { Annotation [ ] annotations = md . getMethod ( ) . getAnnotations ( ) ; collectAnnotationChecks ( annChecks , propertyDescriptor . getType ( ) , propertyDescriptor . getName ( ) , annotations ) ; } md = propertyDescriptor . getWriteMethodDescriptor ( ) ; if ( md != null ) { Annotation [ ] annotations = md . getMethod ( ) . getAnnotations ( ) ; collectAnnotationChecks ( annChecks , propertyDescriptor . getType ( ) , propertyDescriptor . getName ( ) , annotations ) ; }


signature:
public class ValidationContext { /** * Collect annotations for some target . */
@ SuppressWarnings ( { } }

implementation:
"unchecked" } ) protected void collectAnnotationChecks ( final List < Check > annChecks , final Class targetType , final String targetName , final Annotation [ ] annotations ) { for ( Annotation annotation : annotations ) { Constraint c = annotation . annotationType ( ) . getAnnotation ( Constraint . class ) ; Class < ? extends ValidationConstraint > constraintClass ; if ( c == null ) { // if constraint is not available , try lookup
String constraintClassName = annotation . annotationType ( ) . getName ( ) + "Constraint" ; try { constraintClass = ClassLoaderUtil . loadClass ( constraintClassName , this . getClass ( ) . getClassLoader ( ) ) ; } catch ( ClassNotFoundException ingore ) { continue ; } } else { constraintClass = c . value ( ) ; } ValidationConstraint vc ; try { vc = newConstraint ( constraintClass , targetType ) ; } catch ( Exception ex ) { throw new VtorException ( "Invalid constraint: " + constraintClass . getClass ( ) . getName ( ) , ex ) ; } vc . configure ( annotation ) ; Check check = new Check ( targetName , vc ) ; copyDefaultCheckProperties ( check , annotation ) ; annChecks . add ( check ) ; }


signature:
public class ValidationContext { /** * Create new constraint . The following rules are used :
 * < ul >
 * < li > use default constructor if exist . < / li >
 * < li > otherwise , use constructor with ValidationContext parameter . < / li >
 * < / ul > */
protected < V extends ValidationConstraint > V newConstraint ( final Class < V > constraint , final Class targetType ) throws Exception { } }

implementation: Constructor < V > ctor ; try { ctor = constraint . getConstructor ( ) ; return ctor . newInstance ( ) ; } catch ( NoSuchMethodException ignore ) { ctor = constraint . getConstructor ( ValidationContext . class ) ; return ctor . newInstance ( resolveFor ( targetType ) ) ; }


signature:
public class ValidationContext { /** * Copies default properties from annotation to the check . */
protected void copyDefaultCheckProperties ( final Check destCheck , final Annotation annotation ) { } }

implementation: Integer severity = ( Integer ) ClassUtil . readAnnotationValue ( annotation , ANN_SEVERITY ) ; destCheck . setSeverity ( severity . intValue ( ) ) ; String [ ] profiles = ( String [ ] ) ClassUtil . readAnnotationValue ( annotation , ANN_PROFILES ) ; destCheck . setProfiles ( profiles ) ; String message = ( String ) ClassUtil . readAnnotationValue ( annotation , ANN_MESSAGE ) ; destCheck . setMessage ( message ) ;


signature:
public class Futures { /** * Returns { @ code CompletableFuture } that fails after certain number of milliseconds . */
public static < T > CompletableFuture < T > failAfter ( final long duration ) { } }

implementation: final CompletableFuture < T > promise = new CompletableFuture < > ( ) ; SCHEDULER . schedule ( ( ) -> { final TimeoutException ex = new TimeoutException ( "Timeout after " + duration ) ; return promise . completeExceptionally ( ex ) ; } , duration , MILLISECONDS ) ; return promise ;


signature:
public class SqlArraySqlType { /** * { @ inheritDoc } */
@ Override public Array get ( final ResultSet rs , final int index , final int dbSqlType ) throws SQLException { } }

implementation: return rs . getArray ( index ) ;


signature:
public class SqlArraySqlType { /** * { @ inheritDoc } */
@ Override public void set ( final PreparedStatement st , final int index , final Array value , final int dbSqlType ) throws SQLException { } }

implementation: st . setArray ( index , value ) ;


signature:
public class URLCoder { /** * Encodes single URI component . */
private static String encodeUriComponent ( final String source , final String encoding , final URIPart uriPart ) { } }

implementation: if ( source == null ) { return null ; } byte [ ] bytes = encodeBytes ( StringUtil . getBytes ( source , encoding ) , uriPart ) ; char [ ] chars = new char [ bytes . length ] ; for ( int i = 0 ; i < bytes . length ; i ++ ) { chars [ i ] = ( char ) bytes [ i ] ; } return new String ( chars ) ;


signature:
public class URLCoder { /** * Encodes byte array using allowed characters from { @ link URIPart } . */
private static byte [ ] encodeBytes ( final byte [ ] source , final URIPart uriPart ) { } }

implementation: ByteArrayOutputStream bos = new ByteArrayOutputStream ( source . length ) ; for ( byte b : source ) { if ( b < 0 ) { b += 256 ; } if ( uriPart . isValid ( ( char ) b ) ) { bos . write ( b ) ; } else { bos . write ( '%' ) ; char hex1 = Character . toUpperCase ( Character . forDigit ( ( b >> 4 ) & 0xF , 16 ) ) ; char hex2 = Character . toUpperCase ( Character . forDigit ( b & 0xF , 16 ) ) ; bos . write ( hex1 ) ; bos . write ( hex2 ) ; } } return bos . toByteArray ( ) ;


signature:
public class URLCoder { /** * Encodes string using default RFCP rules . */
public static String encode ( final String string , final String encoding ) { } }

implementation: return encodeUriComponent ( string , encoding , URIPart . UNRESERVED ) ;


signature:
public class URLCoder { /** * Encodes the given URI scheme with the given encoding . */
public static String encodeScheme ( final String scheme , final String encoding ) { } }

implementation: return encodeUriComponent ( scheme , encoding , URIPart . SCHEME ) ;


signature:
public class URLCoder { /** * Encodes the given URI host with the given encoding . */
public static String encodeHost ( final String host , final String encoding ) { } }

implementation: return encodeUriComponent ( host , encoding , URIPart . HOST ) ;


signature:
public class URLCoder { /** * Encodes the given URI port with the given encoding . */
public static String encodePort ( final String port , final String encoding ) { } }

implementation: return encodeUriComponent ( port , encoding , URIPart . PORT ) ;


signature:
public class URLCoder { /** * Encodes the given URI path with the given encoding . */
public static String encodePath ( final String path , final String encoding ) { } }

implementation: return encodeUriComponent ( path , encoding , URIPart . PATH ) ;


signature:
public class URLCoder { /** * Encodes the given URI query with the given encoding . */
public static String encodeQuery ( final String query , final String encoding ) { } }

implementation: return encodeUriComponent ( query , encoding , URIPart . QUERY ) ;


signature:
public class URLCoder { /** * Encodes the given URI query parameter with the given encoding . */
public static String encodeQueryParam ( final String queryParam , final String encoding ) { } }

implementation: return encodeUriComponent ( queryParam , encoding , URIPart . QUERY_PARAM ) ;


signature:
public class URLCoder { /** * Encodes the given URI fragment with the given encoding . */
public static String encodeFragment ( final String fragment , final String encoding ) { } }

implementation: return encodeUriComponent ( fragment , encoding , URIPart . FRAGMENT ) ;


signature:
public class URLCoder { /** * Encodes the given source URI into an encoded String . All various URI components are
 * encoded according to their respective valid character sets .
 * < p > This method does < b > not < / b > attempt to encode " = " and " { @ literal & } "
 * characters in query parameter names and query parameter values because they cannot
 * be parsed in a reliable way . */
public static String encodeUri ( final String uri , final String encoding ) { } }

implementation: Matcher m = URI_PATTERN . matcher ( uri ) ; if ( m . matches ( ) ) { String scheme = m . group ( 2 ) ; String authority = m . group ( 3 ) ; String userinfo = m . group ( 5 ) ; String host = m . group ( 6 ) ; String port = m . group ( 8 ) ; String path = m . group ( 9 ) ; String query = m . group ( 11 ) ; String fragment = m . group ( 13 ) ; return encodeUriComponents ( scheme , authority , userinfo , host , port , path , query , fragment , encoding ) ; } throw new IllegalArgumentException ( "Invalid URI: " + uri ) ;


signature:
public class URLCoder { /** * Encodes the given HTTP URI into an encoded String . All various URI components are
 * encoded according to their respective valid character sets .
 * < p > This method does < b > not < / b > support fragments ( { @ code # } ) ,
 * as these are not supposed to be sent to the server , but retained by the client .
 * < p > This method does < b > not < / b > attempt to encode " = " and " { @ literal & } "
 * characters in query parameter names and query parameter values because they cannot
 * be parsed in a reliable way . */
public static String encodeHttpUrl ( final String httpUrl , final String encoding ) { } }

implementation: Matcher m = HTTP_URL_PATTERN . matcher ( httpUrl ) ; if ( m . matches ( ) ) { String scheme = m . group ( 1 ) ; String authority = m . group ( 2 ) ; String userinfo = m . group ( 4 ) ; String host = m . group ( 5 ) ; String portString = m . group ( 7 ) ; String path = m . group ( 8 ) ; String query = m . group ( 10 ) ; return encodeUriComponents ( scheme , authority , userinfo , host , portString , path , query , null , encoding ) ; } throw new IllegalArgumentException ( "Invalid HTTP URL: " + httpUrl ) ;


signature:
public class URLCoder { /** * Creates URL builder with given path that can be optionally encoded .
 * Since most of the time path is valid and does not require to be encoded ,
 * use this method to gain some performance . When encoding flag is turned off ,
 * provided path is used without processing .
 * The purpose of builder is to help with query parameters . All other URI parts
 * should be set previously or after the URL is built . */
public static Builder build ( final String path , final boolean encodePath ) { } }

implementation: return new Builder ( path , encodePath , JoddCore . encoding ) ;


signature:
public class Properties { /** * Inspects all properties of target type . */
protected HashMap < String , PropertyDescriptor > inspectProperties ( ) { } }

implementation:
boolean scanAccessible = classDescriptor . isScanAccessible ( ) ; Class type = classDescriptor . getType ( ) ; HashMap < String , PropertyDescriptor > map = new HashMap < > ( ) ; Method [ ] methods = scanAccessible ? ClassUtil . getAccessibleMethods ( type ) : ClassUtil . getSupportedMethods ( type ) ; for ( int iteration = 0 ; iteration < 2 ; iteration ++ ) { // first find the getters , and then the setters !
for ( Method method : methods ) { if ( Modifier . isStatic ( method . getModifiers ( ) ) ) { continue ; // ignore static methods
} boolean add = false ; boolean issetter = false ; String propertyName ; if ( iteration == 0 ) { propertyName = ClassUtil . getBeanPropertyGetterName ( method ) ; if ( propertyName != null ) { add = true ; issetter = false ; } } else { propertyName = ClassUtil . getBeanPropertySetterName ( method ) ; if ( propertyName != null ) { add = true ; issetter = true ; } } if ( add ) { MethodDescriptor methodDescriptor = classDescriptor . getMethodDescriptor ( method . getName ( ) , method . getParameterTypes ( ) , true ) ; addProperty ( map , propertyName , methodDescriptor , issetter ) ; } } } if ( classDescriptor . isIncludeFieldsAsProperties ( ) ) { FieldDescriptor [ ] fieldDescriptors = classDescriptor . getAllFieldDescriptors ( ) ; String [ ] prefix = classDescriptor . getPropertyFieldPrefix ( ) ; for ( FieldDescriptor fieldDescriptor : fieldDescriptors ) { Field field = fieldDescriptor . getField ( ) ; if ( Modifier . isStatic ( field . getModifiers ( ) ) ) { continue ; // ignore static fields
} String name = field . getName ( ) ; if ( prefix != null ) { for ( String p : prefix ) { if ( ! name . startsWith ( p ) ) { continue ; } name = name . substring ( p . length ( ) ) ; break ; } } if ( ! map . containsKey ( name ) ) { // add missing field as a potential property
map . put ( name , createPropertyDescriptor ( name , fieldDescriptor ) ) ; } } } return map ;


signature:
public class Properties { /** * Adds a setter and / or getter method to the property .
 * If property is already defined , the new , updated , definition will be created . */
protected void addProperty ( final HashMap < String , PropertyDescriptor > map , final String name , final MethodDescriptor methodDescriptor , final boolean isSetter ) { } }

implementation:
MethodDescriptor setterMethod = isSetter ? methodDescriptor : null ; MethodDescriptor getterMethod = isSetter ? null : methodDescriptor ; PropertyDescriptor existing = map . get ( name ) ; if ( existing == null ) { // new property , just add it
PropertyDescriptor propertyDescriptor = createPropertyDescriptor ( name , getterMethod , setterMethod ) ; map . put ( name , propertyDescriptor ) ; return ; } // property exist
if ( ! isSetter ) { // use existing setter
setterMethod = existing . getWriteMethodDescriptor ( ) ; // check existing
MethodDescriptor existingMethodDescriptor = existing . getReadMethodDescriptor ( ) ; if ( existingMethodDescriptor != null ) { // check for special case of double get / is
// getter with the same name already exist
String methodName = methodDescriptor . getMethod ( ) . getName ( ) ; String existingMethodName = existingMethodDescriptor . getMethod ( ) . getName ( ) ; if ( existingMethodName . startsWith ( METHOD_IS_PREFIX ) && methodName . startsWith ( METHOD_GET_PREFIX ) ) { // ignore getter when ister exist
return ; } } } else { // setter
// use existing getter
getterMethod = existing . getReadMethodDescriptor ( ) ; if ( getterMethod != null ) { Class returnType = getterMethod . getMethod ( ) . getReturnType ( ) ; if ( setterMethod != null ) { Class parameterType = setterMethod . getMethod ( ) . getParameterTypes ( ) [ 0 ] ; if ( returnType != parameterType ) { // getter ' s type is different then setter ' s
return ; } } } } PropertyDescriptor propertyDescriptor = createPropertyDescriptor ( name , getterMethod , setterMethod ) ; map . put ( name , propertyDescriptor ) ;


signature:
public class Properties { /** * Creates new { @ link PropertyDescriptor } . Note that this method may be called
 * up to three times ( depends on use case ) for the same property . Each time when
 * a property is updated , a new definition is created with updated information . */
protected PropertyDescriptor createPropertyDescriptor ( final String name , final MethodDescriptor getterMethod , final MethodDescriptor setterMethod ) { } }

implementation: return new PropertyDescriptor ( classDescriptor , name , getterMethod , setterMethod ) ;


signature:
public class Properties { /** * Creates new field - only { @ link PropertyDescriptor } . It will be invoked only once . */
protected PropertyDescriptor createPropertyDescriptor ( final String name , final FieldDescriptor fieldDescriptor ) { } }

implementation: return new PropertyDescriptor ( classDescriptor , name , fieldDescriptor ) ;


signature:
public class Properties { /** * Returns all property descriptors .
 * Properties are sorted by name . */
public PropertyDescriptor [ ] getAllPropertyDescriptors ( ) { } }

implementation: if ( allProperties == null ) { PropertyDescriptor [ ] allProperties = new PropertyDescriptor [ propertyDescriptors . size ( ) ] ; int index = 0 ; for ( PropertyDescriptor propertyDescriptor : propertyDescriptors . values ( ) ) { allProperties [ index ] = propertyDescriptor ; index ++ ; } Arrays . sort ( allProperties , new Comparator < PropertyDescriptor > ( ) { @ Override public int compare ( final PropertyDescriptor pd1 , final PropertyDescriptor pd2 ) { return pd1 . getName ( ) . compareTo ( pd2 . getName ( ) ) ; } } ) ; this . allProperties = allProperties ; } return allProperties ;


signature:
public class HttpResponse { /** * Parses ' location ' header to return the next location or returns { @ code null } if location not specified .
 * Specification ( < a href = " http : / / www . w3 . org / Protocols / rfc2616 / rfc2616 - sec14 . html # sec14.30 " > rfc2616 < / a > )
 * says that only absolute path must be provided , however , this does not
 * happens in the real world . There a < a href = " https : / / tools . ietf . org / html / rfc7231 # section - 7.1.2 " > proposal < / a >
 * that allows server name etc to be omitted . */
public String location ( ) { } }

implementation: String location = header ( "location" ) ; if ( location == null ) { return null ; } if ( location . startsWith ( StringPool . SLASH ) ) { location = getHttpRequest ( ) . hostUrl ( ) + location ; } return location ;


signature:
public class HttpResponse { /** * Returns list of valid cookies sent from server .
 * If no cookie found , returns an empty array . Invalid cookies are ignored . */
public Cookie [ ] cookies ( ) { } }

implementation:
List < String > newCookies = headers ( "set-cookie" ) ; if ( newCookies == null ) { return new Cookie [ 0 ] ; } List < Cookie > cookieList = new ArrayList < > ( newCookies . size ( ) ) ; for ( String cookieValue : newCookies ) { try { Cookie cookie = new Cookie ( cookieValue ) ; cookieList . add ( cookie ) ; } catch ( Exception ex ) { // ignore
} } return cookieList . toArray ( new Cookie [ 0 ] ) ;


signature:
public class HttpResponse { /** * Unzips GZip - ed body content , removes the content - encoding header
 * and sets the new content - length value . */
public HttpResponse unzip ( ) { } }

implementation: String contentEncoding = contentEncoding ( ) ; if ( contentEncoding != null && contentEncoding ( ) . equals ( "gzip" ) ) { if ( body != null ) { headerRemove ( HEADER_CONTENT_ENCODING ) ; try { ByteArrayInputStream in = new ByteArrayInputStream ( body . getBytes ( StringPool . ISO_8859_1 ) ) ; GZIPInputStream gzipInputStream = new GZIPInputStream ( in ) ; ByteArrayOutputStream out = new ByteArrayOutputStream ( ) ; StreamUtil . copy ( gzipInputStream , out ) ; body ( out . toString ( StringPool . ISO_8859_1 ) ) ; } catch ( IOException ioex ) { throw new HttpException ( ioex ) ; } } } return this ;


signature:
public class HttpResponse { /** * Creates response { @ link jodd . http . Buffer buffer } . */
@ Override protected Buffer buffer ( final boolean fullResponse ) { } }

implementation:
// form
Buffer formBuffer = formBuffer ( ) ; // response
Buffer response = new Buffer ( ) ; response . append ( httpVersion ) . append ( SPACE ) . append ( statusCode ) . append ( SPACE ) . append ( statusPhrase ) . append ( CRLF ) ; populateHeaderAndBody ( response , formBuffer , fullResponse ) ; return response ;


signature:
public class HttpResponse { /** * Reads response input stream and returns { @ link HttpResponse response } .
 * Supports both streamed and chunked response . */
public static HttpResponse readFrom ( final InputStream in ) { } }

implementation:
InputStreamReader inputStreamReader ; try { inputStreamReader = new InputStreamReader ( in , StringPool . ISO_8859_1 ) ; } catch ( UnsupportedEncodingException unee ) { throw new HttpException ( unee ) ; } BufferedReader reader = new BufferedReader ( inputStreamReader ) ; HttpResponse httpResponse = new HttpResponse ( ) ; // the first line
String line ; try { line = reader . readLine ( ) ; } catch ( IOException ioex ) { throw new HttpException ( ioex ) ; } if ( line != null ) { line = line . trim ( ) ; int ndx = line . indexOf ( ' ' ) ; int ndx2 ; if ( ndx > - 1 ) { httpResponse . httpVersion ( line . substring ( 0 , ndx ) ) ; ndx2 = line . indexOf ( ' ' , ndx + 1 ) ; } else { httpResponse . httpVersion ( HTTP_1_1 ) ; ndx2 = - 1 ; ndx = 0 ; } if ( ndx2 == - 1 ) { ndx2 = line . length ( ) ; } try { httpResponse . statusCode ( Integer . parseInt ( line . substring ( ndx , ndx2 ) . trim ( ) ) ) ; } catch ( NumberFormatException nfex ) { httpResponse . statusCode ( - 1 ) ; } httpResponse . statusPhrase ( line . substring ( ndx2 ) . trim ( ) ) ; } httpResponse . readHeaders ( reader ) ; httpResponse . readBody ( reader ) ; return httpResponse ;


signature:
public class HttpResponse { /** * Closes requests connection if it was open .
 * Should be called when using keep - alive connections .
 * Otherwise , connection will be already closed . */
public HttpResponse close ( ) { } }

implementation: HttpConnection httpConnection = httpRequest . httpConnection ; if ( httpConnection != null ) { httpConnection . close ( ) ; httpRequest . httpConnection = null ; } return this ;


signature:
public class ThreadLocalScope { /** * Defines allowed referenced scopes that can be injected into the
 * thread - local scoped bean . */
@ Override public boolean accept ( final Scope referenceScope ) { } }

implementation: Class < ? extends Scope > refScopeType = referenceScope . getClass ( ) ; if ( refScopeType == ProtoScope . class ) { return true ; } if ( refScopeType == SingletonScope . class ) { return true ; } if ( refScopeType == ThreadLocalScope . class ) { return true ; } return false ;


signature:
public class JoyMadvoc { /** * - - - - - lifecycle */
@ Override public void start ( ) { } }

implementation:
initLogger ( ) ; log . info ( "MADVOC start  ----------" ) ; webApp = webAppSupplier == null ? new PetiteWebApp ( joyPetiteSupplier . get ( ) . getPetiteContainer ( ) ) : webAppSupplier . get ( ) ; webApp . withRegisteredComponent ( ActionConfigManager . class , acm -> { acm . bindAnnotationConfig ( Action . class , JoyActionConfig . class ) ; acm . bindAnnotationConfig ( RestAction . class , JoyRestActionConfig . class ) ; } ) ; if ( servletContext != null ) { webApp . bindServletContext ( servletContext ) ; } final Props allProps = joyPropsSupplier . get ( ) . getProps ( ) ; webApp . withParams ( allProps . innerMap ( beanNamePrefix ( ) ) ) ; webApp . registerComponent ( new ProxettaSupplier ( joyProxettaSupplier . get ( ) . getProxetta ( ) ) ) ; webApp . registerComponent ( ProxettaAwareActionsManager . class ) ; // Automagic Madvoc configurator will scan and register ALL !
// This way we reduce the startup time and have only one scanning .
// Scanning happens in the INIT phase .
final AutomagicMadvocConfigurator automagicMadvocConfigurator = new AutomagicMadvocConfigurator ( joyScannerSupplier . get ( ) . getClassScanner ( ) ) { @ Override protected String createInfoMessage ( ) { return "Scanning completed in " + elapsed + "ms." ; } } ; webApp . registerComponent ( automagicMadvocConfigurator ) ; webAppConsumers . accept ( webApp ) ; webApp . start ( ) ; log . info ( "MADVOC OK!" ) ;


signature:
public class JoyMadvoc { /** * Prints routes to console . */
protected void printRoutes ( final int width ) { } }

implementation: final ActionsManager actionsManager = webApp . madvocContainer ( ) . lookupComponent ( ActionsManager . class ) ; final List < ActionRuntime > actions = actionsManager . getAllActionRuntimes ( ) ; final Map < String , String > aliases = actionsManager . getAllAliases ( ) ; if ( actions . isEmpty ( ) ) { return ; } final Print print = new Print ( ) ; print . line ( "Routes" , width ) ; actions . stream ( ) . sorted ( Comparator . comparing ( actionRuntime -> actionRuntime . getActionPath ( ) + ' ' + actionRuntime . getActionMethod ( ) ) ) . forEach ( ar -> { final String actionMethod = ar . getActionMethod ( ) ; print . out ( Chalk256 . chalk ( ) . yellow ( ) , actionMethod == null ? "*" : actionMethod , 7 ) ; print . space ( ) ; final String signature = ClassUtil . getShortClassName ( ProxettaUtil . resolveTargetClass ( ar . getActionClass ( ) ) , 2 ) + '#' + ar . getActionClassMethod ( ) . getName ( ) ; print . outLeftRightNewLine ( Chalk256 . chalk ( ) . green ( ) , ar . getActionPath ( ) , Chalk256 . chalk ( ) . blue ( ) , signature , width - 7 - 1 ) ; } ) ; if ( ! aliases . isEmpty ( ) ) { print . line ( "Aliases" , width ) ; actions . stream ( ) . sorted ( Comparator . comparing ( actionRuntime -> actionRuntime . getActionPath ( ) + ' ' + actionRuntime . getActionMethod ( ) ) ) . forEach ( ar -> { final String actionPath = ar . getActionPath ( ) ; for ( final Map . Entry < String , String > entry : aliases . entrySet ( ) ) { if ( entry . getValue ( ) . equals ( actionPath ) ) { print . space ( 8 ) ; print . outLeftRightNewLine ( Chalk256 . chalk ( ) . green ( ) , entry . getValue ( ) , Chalk256 . chalk ( ) . blue ( ) , entry . getKey ( ) , width - 8 ) ; } } } ) ; } print . line ( width ) ;


signature:
public class BlockCipher { /** * Encrypts complete content , block by block . */
public byte [ ] encrypt ( final byte [ ] content ) { } }

implementation:
FastByteBuffer fbb = new FastByteBuffer ( ) ; int length = content . length + 1 ; int blockCount = length / blockSizeInBytes ; int remaining = length ; int offset = 0 ; for ( int i = 0 ; i < blockCount ; i ++ ) { if ( remaining == blockSizeInBytes ) { break ; } byte [ ] encrypted = encryptBlock ( content , offset ) ; fbb . append ( encrypted ) ; offset += blockSizeInBytes ; remaining -= blockSizeInBytes ; } if ( remaining != 0 ) { // process remaining bytes
byte [ ] block = new byte [ blockSizeInBytes ] ; System . arraycopy ( content , offset , block , 0 , remaining - 1 ) ; block [ remaining - 1 ] = TERMINATOR ; byte [ ] encrypted = encryptBlock ( block , 0 ) ; fbb . append ( encrypted ) ; } return fbb . toArray ( ) ;


signature:
public class BlockCipher { /** * Decrypts the whole content , block by block . */
public byte [ ] decrypt ( final byte [ ] encryptedContent ) { } }

implementation:
FastByteBuffer fbb = new FastByteBuffer ( ) ; int length = encryptedContent . length ; int blockCount = length / blockSizeInBytes ; int offset = 0 ; for ( int i = 0 ; i < blockCount - 1 ; i ++ ) { byte [ ] decrypted = decryptBlock ( encryptedContent , offset ) ; fbb . append ( decrypted ) ; offset += blockSizeInBytes ; } // process last block
byte [ ] decrypted = decryptBlock ( encryptedContent , offset ) ; // find terminator
int ndx = blockSizeInBytes - 1 ; while ( ndx >= 0 ) { if ( decrypted [ ndx ] == TERMINATOR ) { break ; } ndx -- ; } fbb . append ( decrypted , 0 , ndx ) ; return fbb . toArray ( ) ;


signature:
public class MapToBean { /** * Converts map to target type . */
public Object map2bean ( final Map map , Class targetType ) { } }

implementation:
Object target = null ; // create targets type
String className = ( String ) map . get ( classMetadataName ) ; if ( className == null ) { if ( targetType == null ) { // nothing to do , no information about target type found
target = map ; } } else { checkClassName ( jsonParser . classnameWhitelist , className ) ; try { targetType = ClassLoaderUtil . loadClass ( className ) ; } catch ( ClassNotFoundException cnfex ) { throw new JsonException ( cnfex ) ; } } if ( target == null ) { target = jsonParser . newObjectInstance ( targetType ) ; } ClassDescriptor cd = ClassIntrospector . get ( ) . lookup ( target . getClass ( ) ) ; boolean targetIsMap = target instanceof Map ; for ( Object key : map . keySet ( ) ) { String keyName = key . toString ( ) ; if ( classMetadataName != null ) { if ( keyName . equals ( classMetadataName ) ) { continue ; } } PropertyDescriptor pd = cd . getPropertyDescriptor ( keyName , declared ) ; if ( ! targetIsMap && pd == null ) { // target property does not exist , continue
continue ; } // value is one of JSON basic types , like Number , Map , List . . .
Object value = map . get ( key ) ; Class propertyType = pd == null ? null : pd . getType ( ) ; Class componentType = pd == null ? null : pd . resolveComponentType ( true ) ; if ( value != null ) { if ( value instanceof List ) { if ( componentType != null && componentType != String . class ) { value = generifyList ( ( List ) value , componentType ) ; } } else if ( value instanceof Map ) { // if the value we want to inject is a Map . . .
if ( ! ClassUtil . isTypeOf ( propertyType , Map . class ) ) { // . . . and if target is NOT a map
value = map2bean ( ( Map ) value , propertyType ) ; } else { // target is also a Map , but we might need to generify it
Class keyType = pd == null ? null : pd . resolveKeyType ( true ) ; if ( keyType != String . class || componentType != String . class ) { // generify
value = generifyMap ( ( Map ) value , keyType , componentType ) ; } } } } if ( targetIsMap ) { ( ( Map ) target ) . put ( keyName , value ) ; } else { try { setValue ( target , pd , value ) ; } catch ( Exception ignore ) { ignore . printStackTrace ( ) ; } } } return target ;


signature:
public class MapToBean { /** * Converts type of all list elements to match the component type . */
private Object generifyList ( final List list , final Class componentType ) { } }

implementation: for ( int i = 0 ; i < list . size ( ) ; i ++ ) { Object element = list . get ( i ) ; if ( element != null ) { if ( element instanceof Map ) { Object bean = map2bean ( ( Map ) element , componentType ) ; list . set ( i , bean ) ; } else { Object value = convert ( element , componentType ) ; list . set ( i , value ) ; } } } return list ;


signature:
public class MapToBean { /** * Sets the property value . */
private void setValue ( final Object target , final PropertyDescriptor pd , Object value ) throws InvocationTargetException , IllegalAccessException { } }

implementation: Class propertyType ; Setter setter = pd . getSetter ( true ) ; if ( setter != null ) { if ( value != null ) { propertyType = setter . getSetterRawType ( ) ; value = jsonParser . convertType ( value , propertyType ) ; } setter . invokeSetter ( target , value ) ; }


signature:
public class MapToBean { /** * Change map elements to match key and value types . */
protected < K , V > Map < K , V > generifyMap ( final Map < Object , Object > map , final Class < K > keyType , final Class < V > valueType ) { } }

implementation:
if ( keyType == String . class ) { // only value type is changed , we can make value replacements
for ( Map . Entry < Object , Object > entry : map . entrySet ( ) ) { Object value = entry . getValue ( ) ; Object newValue = convert ( value , valueType ) ; if ( value != newValue ) { entry . setValue ( newValue ) ; } } return ( Map < K , V > ) map ; } // key is changed too , we need a new map
Map < K , V > newMap = new HashMap < > ( map . size ( ) ) ; for ( Map . Entry < Object , Object > entry : map . entrySet ( ) ) { Object key = entry . getKey ( ) ; Object newKey = convert ( key , keyType ) ; Object value = entry . getValue ( ) ; Object newValue = convert ( value , valueType ) ; newMap . put ( ( K ) newKey , ( V ) newValue ) ; } return newMap ;


signature:
public class MethrefAdvice { /** * Reads method name and stores it in local variable .
 * For methods that return < code > String < / code > returns the method name ,
 * otherwise returns < code > null < / code > . */
public Object execute ( ) { } }

implementation: methodName = targetMethodName ( ) ; Class returnType = returnType ( ) ; if ( returnType == String . class ) { return ProxyTarget . returnValue ( targetMethodName ( ) ) ; } return ProxyTarget . returnValue ( null ) ;


signature:
public class ShortArrayConverter { /** * Converts non - array value to array . Detects various
 * collection types and iterates them to make conversion
 * and to create target array . */
protected short [ ] convertValueToArray ( final Object value ) { } }

implementation:
if ( value instanceof Collection ) { final Collection collection = ( Collection ) value ; final short [ ] target = new short [ collection . size ( ) ] ; int i = 0 ; for ( final Object element : collection ) { target [ i ] = convertType ( element ) ; i ++ ; } return target ; } if ( value instanceof Iterable ) { final Iterable iterable = ( Iterable ) value ; final ArrayList < Short > shortArrayList = new ArrayList < > ( ) ; for ( final Object element : iterable ) { final short convertedValue = convertType ( element ) ; shortArrayList . add ( Short . valueOf ( convertedValue ) ) ; } final short [ ] array = new short [ shortArrayList . size ( ) ] ; for ( int i = 0 ; i < shortArrayList . size ( ) ; i ++ ) { final Short s = shortArrayList . get ( i ) ; array [ i ] = s . shortValue ( ) ; } return array ; } if ( value instanceof CharSequence ) { final String [ ] strings = StringUtil . splitc ( value . toString ( ) , ArrayConverter . NUMBER_DELIMITERS ) ; return convertArrayToArray ( strings ) ; } // everything else :
return convertToSingleElementArray ( value ) ;


signature:
public class DbEntityColumnDescriptor { /** * Compares two column descriptors . Identity columns should be the first on the list .
 * Each group then will be sorted by column name . */
@ Override public int compareTo ( final Object o ) { } }

implementation:
DbEntityColumnDescriptor that = ( DbEntityColumnDescriptor ) o ; if ( this . isId != that . isId ) { return this . isId ? - 1 : 1 ; // IDs should be the first in the array
} return this . columnName . compareTo ( that . columnName ) ;


signature:
public class HttpBrowser { /** * Adds default header to all requests . */
public HttpBrowser setDefaultHeader ( final String name , final String value ) { } }

implementation: defaultHeaders . addHeader ( name , value ) ; return this ;


signature:
public class HttpBrowser { /** * Sends new request as a browser . Before sending ,
 * all browser cookies are added to the request .
 * After sending , the cookies are read from the response .
 * Moreover , status codes 301 and 302 are automatically
 * handled . Returns very last response . */
public HttpResponse sendRequest ( HttpRequest httpRequest ) { } }

implementation:
elapsedTime = System . currentTimeMillis ( ) ; // send request
httpRequest . followRedirects ( false ) ; while ( true ) { this . httpRequest = httpRequest ; HttpResponse previousResponse = this . httpResponse ; this . httpResponse = null ; addDefaultHeaders ( httpRequest ) ; addCookies ( httpRequest ) ; // send request
if ( catchTransportExceptions ) { try { this . httpResponse = _sendRequest ( httpRequest , previousResponse ) ; } catch ( HttpException httpException ) { httpResponse = new HttpResponse ( ) ; httpResponse . assignHttpRequest ( httpRequest ) ; httpResponse . statusCode ( 503 ) ; httpResponse . statusPhrase ( "Service unavailable. " + ExceptionUtil . message ( httpException ) ) ; } } else { this . httpResponse = _sendRequest ( httpRequest , previousResponse ) ; } readCookies ( httpResponse ) ; int statusCode = httpResponse . statusCode ( ) ; // 301 : moved permanently
if ( statusCode == 301 ) { String newPath = httpResponse . location ( ) ; if ( newPath == null ) { break ; } httpRequest = HttpRequest . get ( newPath ) ; continue ; } // 302 : redirect , 303 : see other
if ( statusCode == 302 || statusCode == 303 ) { String newPath = httpResponse . location ( ) ; if ( newPath == null ) { break ; } httpRequest = HttpRequest . get ( newPath ) ; continue ; } // 307 : temporary redirect , 308 : permanent redirect
if ( statusCode == 307 || statusCode == 308 ) { String newPath = httpResponse . location ( ) ; if ( newPath == null ) { break ; } String originalMethod = httpRequest . method ( ) ; httpRequest = new HttpRequest ( ) . method ( originalMethod ) . set ( newPath ) ; continue ; } break ; } elapsedTime = System . currentTimeMillis ( ) - elapsedTime ; return this . httpResponse ;


signature:
public class HttpBrowser { /** * Opens connection and sends a response . */
protected HttpResponse _sendRequest ( final HttpRequest httpRequest , final HttpResponse previouseResponse ) { } }

implementation:
if ( ! keepAlive ) { httpRequest . open ( httpConnectionProvider ) ; } else { // keeping alive
if ( previouseResponse == null ) { httpRequest . open ( httpConnectionProvider ) . connectionKeepAlive ( true ) ; } else { httpRequest . keepAlive ( previouseResponse , true ) ; } } return httpRequest . send ( ) ;


signature:
public class HttpBrowser { /** * Add default headers to the request . If request already has a header set ,
 * default header will be ignored . */
protected void addDefaultHeaders ( final HttpRequest httpRequest ) { } }

implementation: for ( Map . Entry < String , String > entry : defaultHeaders . entries ( ) ) { String name = entry . getKey ( ) ; if ( ! httpRequest . headers . contains ( name ) ) { httpRequest . headers . add ( name , entry . getValue ( ) ) ; } }


signature:
public class HttpBrowser { /** * Reads cookies from response and adds to cookies list . */
protected void readCookies ( final HttpResponse httpResponse ) { } }

implementation: Cookie [ ] newCookies = httpResponse . cookies ( ) ; for ( Cookie cookie : newCookies ) { cookies . add ( cookie . getName ( ) , cookie ) ; }


signature:
public class HttpBrowser { /** * Add cookies to the request . */
protected void addCookies ( final HttpRequest httpRequest ) { } }

implementation:
// prepare all cookies
List < Cookie > cookiesList = new ArrayList < > ( ) ; if ( ! cookies . isEmpty ( ) ) { for ( Map . Entry < String , Cookie > cookieEntry : cookies ) { cookiesList . add ( cookieEntry . getValue ( ) ) ; } httpRequest . cookies ( cookiesList . toArray ( new Cookie [ 0 ] ) ) ; }


signature:
public class SendMailSession { /** * Prepares message and sends it . Returns Message ID of sent email .
 * @ param email { @ link Email } to send .
 * @ return String representing message ID . */
public String sendMail ( final Email email ) { } }

implementation: try { final MimeMessage msg = createMessage ( email ) ; getService ( ) . sendMessage ( msg , msg . getAllRecipients ( ) ) ; return msg . getMessageID ( ) ; } catch ( final MessagingException msgexc ) { throw new MailException ( "Failed to send email: " + email , msgexc ) ; }


signature:
public class SendMailSession { /** * Creates new { @ link MimeMessage } from an { @ link Email } .
 * @ param email { @ link Email } to be created as a { @ link MimeMessage } .
 * @ return { @ link MimeMessage } created from an { @ link Email } .
 * @ throws MessagingException if there is a failure */
protected MimeMessage createMessage ( final Email email ) throws MessagingException { } }

implementation: final Email clone = email . clone ( ) ; final MimeMessage newMsg = new MimeMessage ( getSession ( ) ) ; setPeople ( clone , newMsg ) ; setSubject ( clone , newMsg ) ; setSentDate ( clone , newMsg ) ; setHeaders ( clone , newMsg ) ; addBodyData ( clone , newMsg ) ; return newMsg ;


signature:
public class SendMailSession { /** * Sets subject in msgToSet from subject in emailWithData .
 * @ param emailWithData { @ link Email } with data
 * @ param msgToSet { @ link MimeMessage } to set data into .
 * @ throws MessagingException if there is a failure */
private void setSubject ( final Email emailWithData , final MimeMessage msgToSet ) throws MessagingException { } }

implementation: if ( emailWithData . subjectEncoding ( ) != null ) { msgToSet . setSubject ( emailWithData . subject ( ) , emailWithData . subjectEncoding ( ) ) ; } else { msgToSet . setSubject ( emailWithData . subject ( ) ) ; }


signature:
public class SendMailSession { /** * Sets sent date in msgToSet with sent date from emailWithData .
 * @ param emailWithData { @ link Email } with data
 * @ param msgToSet { @ link MimeMessage } to set data into .
 * @ throws MessagingException if there is a failure */
private void setSentDate ( final Email emailWithData , final MimeMessage msgToSet ) throws MessagingException { } }

implementation: Date date = emailWithData . sentDate ( ) ; if ( date == null ) { date = new Date ( ) ; } msgToSet . setSentDate ( date ) ;


signature:
public class SendMailSession { /** * Sets headers in msgToSet with headers from emailWithData .
 * @ param emailWithData { @ link Email } with data
 * @ param msgToSet { @ link MimeMessage } to set data into .
 * @ throws MessagingException if there is a failure */
private void setHeaders ( final Email emailWithData , final MimeMessage msgToSet ) throws MessagingException { } }

implementation: final Map < String , String > headers = emailWithData . headers ( ) ; if ( headers != null ) { for ( final Map . Entry < String , String > entry : headers . entrySet ( ) ) { msgToSet . setHeader ( entry . getKey ( ) , entry . getValue ( ) ) ; } }


signature:
public class SendMailSession { /** * Sets FROM , REPLY - TO and recipients .
 * @ param emailWithData { @ link Email } with data
 * @ param msgToSet { @ link MimeMessage } to set data into .
 * @ throws MessagingException if there is a failure */
private void setPeople ( final Email emailWithData , final MimeMessage msgToSet ) throws MessagingException { } }

implementation: msgToSet . setFrom ( emailWithData . from ( ) . toInternetAddress ( ) ) ; msgToSet . setReplyTo ( EmailAddress . convert ( emailWithData . replyTo ( ) ) ) ; setRecipients ( emailWithData , msgToSet ) ;


signature:
public class SendMailSession { /** * Sets TO , CC and BCC in msgToSet with TO , CC and BCC from emailWithData .
 * @ param emailWithData { @ link Email } with data
 * @ param msgToSet { @ link MimeMessage } to set data into .
 * @ throws MessagingException if there is a failure . */
private void setRecipients ( final Email emailWithData , final MimeMessage msgToSet ) throws MessagingException { } }

implementation:
// TO
final InternetAddress [ ] to = EmailAddress . convert ( emailWithData . to ( ) ) ; if ( to . length > 0 ) { msgToSet . setRecipients ( RecipientType . TO , to ) ; } // CC
final InternetAddress [ ] cc = EmailAddress . convert ( emailWithData . cc ( ) ) ; if ( cc . length > 0 ) { msgToSet . setRecipients ( RecipientType . CC , cc ) ; } // BCC
final InternetAddress [ ] bcc = EmailAddress . convert ( emailWithData . bcc ( ) ) ; if ( bcc . length > 0 ) { msgToSet . setRecipients ( RecipientType . BCC , bcc ) ; }


signature:
public class SendMailSession { /** * Adds message data and attachments .
 * @ param emailWithData { @ link Email } with data
 * @ param msgToSet { @ link MimeMessage } to set data into .
 * @ throws MessagingException if there is a failure . */
private void addBodyData ( final Email emailWithData , final MimeMessage msgToSet ) throws MessagingException { } }

implementation:
final List < EmailMessage > messages = emailWithData . messages ( ) ; final int totalMessages = messages . size ( ) ; // Need to use new list since filterEmbeddedAttachments ( List ) removes attachments from the source List
final List < EmailAttachment < ? extends DataSource > > attachments = new ArrayList < > ( emailWithData . attachments ( ) ) ; if ( attachments . isEmpty ( ) && totalMessages == 1 ) { // special case : no attachments and just one content
setContent ( messages . get ( 0 ) , msgToSet ) ; } else { final MimeMultipart multipart = new MimeMultipart ( ) ; final MimeMultipart msgMultipart = new MimeMultipart ( ALTERNATIVE ) ; multipart . addBodyPart ( getBaseBodyPart ( msgMultipart ) ) ; for ( final EmailMessage emailMessage : messages ) { msgMultipart . addBodyPart ( getBodyPart ( emailMessage , attachments ) ) ; } addAnyAttachments ( attachments , multipart ) ; msgToSet . setContent ( multipart ) ; }


signature:
public class SendMailSession { /** * Returns new { @ link MimeBodyPart } with content set as msgMultipart .
 * @ param msgMultipart { @ link MimeMultipart } to add to the new { @ link MimeBodyPart } .
 * @ return new { @ link MimeBodyPart } with content set as msgMultipart .
 * @ throws MessagingException if there is a failure . */
private MimeBodyPart getBaseBodyPart ( final MimeMultipart msgMultipart ) throws MessagingException { } }

implementation: final MimeBodyPart bodyPart = new MimeBodyPart ( ) ; bodyPart . setContent ( msgMultipart ) ; return bodyPart ;


signature:
public class SendMailSession { /** * Sets emailWithData content into msgToSet .
 * @ param emailWithData { @ link EmailMessage } with data .
 * @ param partToSet { @ link Part } to set data into .
 * @ throws MessagingException if there is a failure . */
private void setContent ( final EmailMessage emailWithData , final Part partToSet ) throws MessagingException { } }

implementation: partToSet . setContent ( emailWithData . getContent ( ) , emailWithData . getMimeType ( ) + CHARSET + emailWithData . getEncoding ( ) ) ;


signature:
public class SendMailSession { /** * Creates attachment body part . Handles regular and inline attachments .
 * @ param attachment Body part { @ link EmailAttachment } .
 * @ return { @ link MimeBodyPart } which represents body part attachment .
 * @ throws MessagingException if there is a failure . */
protected MimeBodyPart createAttachmentBodyPart ( final EmailAttachment < ? extends DataSource > attachment ) throws MessagingException { } }

implementation: final MimeBodyPart part = new MimeBodyPart ( ) ; final String attachmentName = attachment . getEncodedName ( ) ; if ( attachmentName != null ) { part . setFileName ( attachmentName ) ; } part . setDataHandler ( new DataHandler ( attachment . getDataSource ( ) ) ) ; if ( attachment . getContentId ( ) != null ) { part . setContentID ( StringPool . LEFT_CHEV + attachment . getContentId ( ) + StringPool . RIGHT_CHEV ) ; } if ( attachment . isInline ( ) ) { part . setDisposition ( INLINE ) ; } return part ;


signature:
public class SendMailSession { /** * Filters out the { @ link List } of embedded { @ link EmailAttachment } s for given { @ link EmailMessage } .
 * This will remove the embedded attachments from the { @ link List } and return them in a new { @ link List } .
 * @ param attachments { @ link List } of attachments to search for in emailMessage .
 * @ param emailMessage { @ link EmailMessage } to see if attachment is embedded into .
 * @ return { @ link List } of embedded { @ link EmailAttachment } s ; otherwise , returns empty { @ link List } . */
protected List < EmailAttachment < ? extends DataSource > > filterEmbeddedAttachments ( final List < EmailAttachment < ? extends DataSource > > attachments , final EmailMessage emailMessage ) { } }

implementation: final List < EmailAttachment < ? extends DataSource > > embeddedAttachments = new ArrayList < > ( ) ; if ( attachments == null || attachments . isEmpty ( ) || emailMessage == null ) { return embeddedAttachments ; } final Iterator < EmailAttachment < ? extends DataSource > > iterator = attachments . iterator ( ) ; while ( iterator . hasNext ( ) ) { final EmailAttachment < ? extends DataSource > emailAttachment = iterator . next ( ) ; if ( emailAttachment . isEmbeddedInto ( emailMessage ) ) { embeddedAttachments . add ( emailAttachment ) ; iterator . remove ( ) ; } } return embeddedAttachments ;


signature:
public class SendMailSession { /** * Adds { @ link List } of { @ link EmailAttachment } s to multipart .
 * @ param attachments { @ link List } of { @ link EmailAttachment } s to add to multipart . This can be { @ code null } .
 * @ param multipart { @ link MimeMultipart } to set data into .
 * @ throws MessagingException if there is a failure . */
private void addAnyAttachments ( final List < EmailAttachment < ? extends DataSource > > attachments , final MimeMultipart multipart ) throws MessagingException { } }

implementation: for ( final EmailAttachment < ? extends DataSource > attachment : attachments ) { final MimeBodyPart bodyPart = createAttachmentBodyPart ( attachment ) ; multipart . addBodyPart ( bodyPart ) ; }


signature:
public class MutableInteger { /** * Compares value of two same instances . */
@ Override public int compareTo ( final MutableInteger other ) { } }

implementation: return value < other . value ? - 1 : ( value == other . value ? 0 : 1 ) ;


signature:
public class FileUploadHeader { /** * Gets value of data field or < code > null < / code > if field not found . */
private String getDataFieldValue ( final String dataHeader , final String fieldName ) { } }

implementation: String value = null ; String token = String . valueOf ( ( new StringBuffer ( String . valueOf ( fieldName ) ) ) . append ( '=' ) . append ( '"' ) ) ; int pos = dataHeader . indexOf ( token ) ; if ( pos > 0 ) { int start = pos + token . length ( ) ; int end = dataHeader . indexOf ( '"' , start ) ; if ( ( start > 0 ) && ( end > 0 ) ) { value = dataHeader . substring ( start , end ) ; } } return value ;


signature:
public class FileUploadHeader { /** * Strips content type information from requests data header .
 * @ param dataHeader data header string
 * @ return content type or an empty string if no content type defined */
private String getContentType ( final String dataHeader ) { } }

implementation: String token = "Content-Type:" ; int start = dataHeader . indexOf ( token ) ; if ( start == - 1 ) { return StringPool . EMPTY ; } start += token . length ( ) ; return dataHeader . substring ( start ) . trim ( ) ;


signature:
public class DbQueryBase { /** * Stores result set . */
protected void saveResultSet ( final ResultSet rs ) { } }

implementation: if ( resultSets == null ) { resultSets = new HashSet < > ( ) ; } resultSets . add ( rs ) ;


signature:
public class DbQueryBase { /** * Initializes session . When not specified ( i . e . is < code > null < / code > ) ,
 * session is fetched from session provider . */
protected void initSession ( final DbSession session ) { } }

implementation: if ( session != null ) { this . session = session ; return ; } final DbSessionProvider dbSessionProvider = dbOom . sessionProvider ( ) ; this . session = dbSessionProvider . getDbSession ( ) ;


signature:
public class DbQueryBase { /** * Performs JDBC initialization of the query . Obtains connection , parses the SQL query string
 * and creates statements . Initialization is performed only once , when switching to initialized state . */
@ SuppressWarnings ( "MagicConstant" ) protected void initializeJdbc ( ) { } }

implementation:
// connection
if ( connection == null ) { initSession ( session ) ; connection = session . getConnection ( ) ; } this . query = new DbQueryParser ( sqlString ) ; // callable statement
if ( query . callable ) { try { if ( debug ) { if ( holdability != QueryHoldability . DEFAULT ) { callableStatement = new LoggableCallableStatement ( connection . prepareCall ( query . sql , type . value ( ) , concurrencyType . value ( ) , holdability . value ( ) ) , query . sql ) ; } else { callableStatement = new LoggableCallableStatement ( connection . prepareCall ( query . sql , type . value ( ) , concurrencyType . value ( ) ) , query . sql ) ; } } else { if ( holdability != QueryHoldability . DEFAULT ) { callableStatement = connection . prepareCall ( query . sql , type . value ( ) , concurrencyType . value ( ) , holdability . value ( ) ) ; } else { callableStatement = connection . prepareCall ( query . sql , type . value ( ) , concurrencyType . value ( ) ) ; } } } catch ( SQLException sex ) { throw new DbSqlException ( this , "Error creating callable statement" , sex ) ; } preparedStatement = callableStatement ; statement = callableStatement ; return ; } // prepared statement
if ( query . prepared || forcePreparedStatement ) { try { if ( debug ) { if ( generatedColumns != null ) { if ( generatedColumns . length == 0 ) { preparedStatement = new LoggablePreparedStatement ( connection . prepareStatement ( query . sql , Statement . RETURN_GENERATED_KEYS ) , query . sql ) ; } else { preparedStatement = new LoggablePreparedStatement ( connection . prepareStatement ( query . sql , generatedColumns ) , query . sql ) ; } } else { if ( holdability != QueryHoldability . DEFAULT ) { preparedStatement = new LoggablePreparedStatement ( connection . prepareStatement ( query . sql , type . value ( ) , concurrencyType . value ( ) , holdability . value ( ) ) , query . sql ) ; } else { preparedStatement = new LoggablePreparedStatement ( connection . prepareStatement ( query . sql , type . value ( ) , concurrencyType . value ( ) ) , query . sql ) ; } } } else { if ( generatedColumns != null ) { if ( generatedColumns . length == 0 ) { preparedStatement = connection . prepareStatement ( query . sql , Statement . RETURN_GENERATED_KEYS ) ; } else { preparedStatement = connection . prepareStatement ( query . sql , generatedColumns ) ; } } else { if ( holdability != QueryHoldability . DEFAULT ) { preparedStatement = connection . prepareStatement ( query . sql , type . value ( ) , concurrencyType . value ( ) , holdability . value ( ) ) ; } else { preparedStatement = connection . prepareStatement ( query . sql , type . value ( ) , concurrencyType . value ( ) ) ; } } } } catch ( SQLException sex ) { throw new DbSqlException ( this , "Error creating prepared statement" , sex ) ; } statement = preparedStatement ; return ; } // statement
try { if ( holdability != QueryHoldability . DEFAULT ) { statement = connection . createStatement ( type . value ( ) , concurrencyType . value ( ) , holdability . value ( ) ) ; } else { statement = connection . createStatement ( type . value ( ) , concurrencyType . value ( ) ) ; } } catch ( SQLException sex ) { throw new DbSqlException ( this , "Error creating statement" , sex ) ; }


signature:
public class DbQueryBase { /** * Closes all result sets opened by this query . Query remains active .
 * Returns < code > SQLException < / code > ( stacked with all exceptions )
 * or < code > null < / code > . */
private SQLException closeQueryResultSets ( ) { } }

implementation: SQLException sqlException = null ; if ( resultSets != null ) { for ( final ResultSet rs : resultSets ) { try { rs . close ( ) ; } catch ( SQLException sex ) { if ( sqlException == null ) { sqlException = sex ; } else { sqlException . setNextException ( sex ) ; } } finally { totalOpenResultSetCount -- ; } } resultSets . clear ( ) ; resultSets = null ; } return sqlException ;


signature:
public class DbQueryBase { /** * Closes all result sets created by this query . Query remains active . */
public Q closeAllResultSets ( ) { } }

implementation: final SQLException sex = closeQueryResultSets ( ) ; if ( sex != null ) { throw new DbSqlException ( "Close associated ResultSets error" , sex ) ; } return _this ( ) ;


signature:
public class DbQueryBase { /** * Closes all assigned result sets and then closes the query . Query becomes closed . */
protected SQLException closeQuery ( ) { } }

implementation: SQLException sqlException = closeQueryResultSets ( ) ; if ( statement != null ) { try { statement . close ( ) ; } catch ( SQLException sex ) { if ( sqlException == null ) { sqlException = sex ; } else { sqlException . setNextException ( sex ) ; } } statement = null ; } query = null ; queryState = CLOSED ; return sqlException ;


signature:
public class DbQueryBase { /** * Closes the query and all created results sets and detaches itself from the session . */
@ Override @ SuppressWarnings ( { } }

implementation: "ClassReferencesSubclass" } ) public void close ( ) { final SQLException sqlException = closeQuery ( ) ; connection = null ; if ( this . session != null ) { this . session . detachQuery ( this ) ; } if ( sqlException != null ) { throw new DbSqlException ( "Close query error" , sqlException ) ; }


signature:
public class DbQueryBase { /** * Closes single result set that was created by this query . It is not necessary to close result sets
 * explicitly , since { @ link DbQueryBase # close ( ) } method closes all created result sets .
 * Query remains active . */
public void closeResultSet ( final ResultSet rs ) { } }

implementation: if ( rs == null ) { return ; } if ( ! resultSets . remove ( rs ) ) { throw new DbSqlException ( this , "ResultSet is not created by this query" ) ; } try { rs . close ( ) ; } catch ( SQLException sex ) { throw new DbSqlException ( this , "Close result set error" , sex ) ; } finally { totalOpenResultSetCount -- ; }


signature:
public class DbQueryBase { /** * Gives the JDBC driver a hint as to the number of rows that should be fetched from the database when
 * more rows are needed . The number of rows specified affects only result sets created using this statement .
 * If the value specified is zero , then the hint is ignored . The default value is zero .
 * @ see Statement # setFetchSize ( int ) */
public Q setFetchSize ( final int rows ) { } }

implementation: checkNotClosed ( ) ; this . fetchSize = rows ; if ( statement != null ) { try { statement . setFetchSize ( fetchSize ) ; } catch ( SQLException sex ) { throw new DbSqlException ( this , "Unable to set fetch size: " + fetchSize , sex ) ; } } return _this ( ) ;


signature:
public class DbQueryBase { /** * Sets the limit for the maximum number of rows that any ResultSet object can contain to the given number .
 * If the limit is exceeded , the excess rows are silently dropped . Zero means there is no limit .
 * @ see Statement # setMaxRows ( int ) */
public Q setMaxRows ( final int maxRows ) { } }

implementation: checkNotClosed ( ) ; this . maxRows = maxRows ; if ( statement != null ) { try { statement . setMaxRows ( maxRows ) ; } catch ( SQLException sex ) { throw new DbSqlException ( this , "Unable to set max rows: " + maxRows , sex ) ; } } return _this ( ) ;


signature:
public class DbQueryBase { /** * Executes the query . If this method is invoked at least once , the query or
 * all created ResultSets must be explicitly closed at the end of query usage .
 * This can be done explicitly by calling { @ link DbQueryBase # closeResultSet ( ResultSet ) }
 * оr implicitly , during { @ link DbQueryBase # close ( ) } .
 * @ see Statement # execute ( String ) */
public ResultSet execute ( ) { } }

implementation: start = System . currentTimeMillis ( ) ; init ( ) ; ResultSet rs = null ; if ( log . isDebugEnabled ( ) ) { log . debug ( "Executing statement: " + getQueryString ( ) ) ; } try { if ( preparedStatement == null ) { rs = statement . executeQuery ( query . sql ) ; } else { rs = preparedStatement . executeQuery ( ) ; } rs . setFetchSize ( fetchSize ) ; } catch ( SQLException sex ) { DbUtil . close ( rs ) ; throw new DbSqlException ( this , "Query execution failed" , sex ) ; } saveResultSet ( rs ) ; totalOpenResultSetCount ++ ; elapsed = System . currentTimeMillis ( ) - start ; if ( log . isDebugEnabled ( ) ) { log . debug ( "execution time: " + elapsed + "ms" ) ; } return rs ;


signature:
public class DbQueryBase { /** * Executes UPDATE , INSERT or DELETE queries and optionally closes the query .
 * @ see Statement # executeUpdate ( String ) */
protected int executeUpdate ( final boolean closeQuery ) { } }

implementation: start = System . currentTimeMillis ( ) ; init ( ) ; final int result ; if ( log . isDebugEnabled ( ) ) { log . debug ( "Executing update: " + getQueryString ( ) ) ; } try { if ( preparedStatement == null ) { if ( generatedColumns != null ) { if ( generatedColumns . length == 0 ) { result = statement . executeUpdate ( query . sql , Statement . RETURN_GENERATED_KEYS ) ; } else { result = statement . executeUpdate ( query . sql , generatedColumns ) ; } } else { result = statement . executeUpdate ( query . sql ) ; } } else { result = preparedStatement . executeUpdate ( ) ; } } catch ( SQLException sex ) { throw new DbSqlException ( this , "Query execution failed" , sex ) ; } if ( closeQuery ) { close ( ) ; } elapsed = System . currentTimeMillis ( ) - start ; if ( log . isDebugEnabled ( ) ) { log . debug ( "execution time: " + elapsed + "ms" ) ; } return result ;


signature:
public class DbQueryBase { /** * Executes count queries and optionally closes query afterwards . */
protected long executeCount ( final boolean close ) { } }

implementation: start = System . currentTimeMillis ( ) ; init ( ) ; ResultSet rs = null ; if ( log . isDebugEnabled ( ) ) { log . debug ( "Executing prepared count: " + getQueryString ( ) ) ; } try { if ( preparedStatement == null ) { rs = statement . executeQuery ( query . sql ) ; } else { rs = preparedStatement . executeQuery ( ) ; } final long firstLong = DbUtil . getFirstLong ( rs ) ; elapsed = System . currentTimeMillis ( ) - start ; if ( log . isDebugEnabled ( ) ) { log . debug ( "execution time: " + elapsed + "ms" ) ; } return firstLong ; } catch ( SQLException sex ) { throw new DbSqlException ( this , "Count query failed" , sex ) ; } finally { DbUtil . close ( rs ) ; if ( close ) { close ( ) ; } }


signature:
public class DbQueryBase { /** * { @ link # execute ( ) Executes } the query , iterates result set and
 * { @ link QueryMapper maps } each row . */
public < T > List < T > list ( final QueryMapper < T > queryMapper ) { } }

implementation: final ResultSet resultSet = execute ( ) ; final List < T > list = new ArrayList < > ( ) ; try { while ( resultSet . next ( ) ) { final T t = queryMapper . process ( resultSet ) ; if ( t == null ) { break ; } list . add ( t ) ; } } catch ( SQLException sex ) { throw new DbSqlException ( sex ) ; } finally { DbUtil . close ( resultSet ) ; } return list ;


signature:
public class DbQueryBase { /** * { @ link # execute ( ) Executes } the query and { @ link QueryMapper maps } single result row . */
public < T > T find ( final QueryMapper < T > queryMapper ) { } }

implementation: final ResultSet resultSet = execute ( ) ; try { if ( resultSet . next ( ) ) { return queryMapper . process ( resultSet ) ; } } catch ( SQLException sex ) { throw new DbSqlException ( sex ) ; } finally { DbUtil . close ( resultSet ) ; } return null ;


signature:
public class DbQueryBase { /** * { @ link # execute ( ) Executes } the query , iterates all rows and
 * { @ link QueryMapper maps } them . */
public < T > Set < T > listSet ( final QueryMapper < T > queryMapper ) { } }

implementation: final ResultSet resultSet = execute ( ) ; final Set < T > set = new HashSet < > ( ) ; try { while ( resultSet . next ( ) ) { final T t = queryMapper . process ( resultSet ) ; if ( t == null ) { break ; } set . add ( t ) ; } } catch ( SQLException sex ) { throw new DbSqlException ( sex ) ; } finally { DbUtil . close ( resultSet ) ; } return set ;


signature:
public class DbQueryBase { /** * Returns generated columns . */
public ResultSet getGeneratedColumns ( ) { } }

implementation: checkInitialized ( ) ; if ( generatedColumns == null ) { throw new DbSqlException ( this , "No column is specified as auto-generated" ) ; } final ResultSet rs ; try { rs = statement . getGeneratedKeys ( ) ; } catch ( SQLException sex ) { throw new DbSqlException ( this , "No generated keys" , sex ) ; } saveResultSet ( rs ) ; totalOpenResultSetCount ++ ; return rs ;


signature:
public class DbQueryBase { /** * Returns generated key i . e . first generated column as < code > long < / code > . */
public long getGeneratedKey ( ) { } }

implementation: checkInitialized ( ) ; final ResultSet rs = getGeneratedColumns ( ) ; try { return DbUtil . getFirstLong ( rs ) ; } catch ( SQLException sex ) { throw new DbSqlException ( this , "No generated key as long" , sex ) ; } finally { DbUtil . close ( rs ) ; resultSets . remove ( rs ) ; totalOpenResultSetCount -- ; }


signature:
public class DbQueryBase { /** * Returns query SQL string . For prepared statements , returned sql string with quick - and - dirty replaced values . */
public String getQueryString ( ) { } }

implementation: if ( debug ) { if ( ( callableStatement != null ) ) { if ( preparedStatement instanceof LoggableCallableStatement ) { return ( ( LoggableCallableStatement ) callableStatement ) . getQueryString ( ) ; } } if ( preparedStatement != null ) { if ( preparedStatement instanceof LoggablePreparedStatement ) { return ( ( LoggablePreparedStatement ) preparedStatement ) . getQueryString ( ) ; } } } if ( query != null ) { return query . sql ; } return sqlString ;


signature:
public class EmailAddress { /** * Creates new address by specifying one of the following :
 * < ul >
 * < li > { @ code " foo @ bar . com " - only email address . } < / li >
 * < li > { @ code " Jenny Doe & lt ; foo @ bar . com & gt ; " - first part of the string is personal name ,
 * and the other part is email , surrounded with < and > . } < / li >
 * < / ul >
 * @ param address { @ link String } containing address to convert . */
public static EmailAddress of ( String address ) { } }

implementation: address = address . trim ( ) ; if ( ! StringUtil . endsWithChar ( address , '>' ) ) { return new EmailAddress ( null , address ) ; } final int ndx = address . lastIndexOf ( '<' ) ; if ( ndx == - 1 ) { return new EmailAddress ( null , address ) ; } String email = address . substring ( ndx + 1 , address . length ( ) - 1 ) ; String personalName = address . substring ( 0 , ndx ) . trim ( ) ; return new EmailAddress ( personalName , email ) ;


signature:
public class EmailAddress { /** * Creates new { @ link InternetAddress } from current data .
 * @ return { @ link InternetAddress } from current data . */
public InternetAddress toInternetAddress ( ) throws AddressException { } }

implementation: try { return new InternetAddress ( email , personalName , JoddCore . encoding ) ; } catch ( final UnsupportedEncodingException ueex ) { throw new AddressException ( ueex . toString ( ) ) ; }


signature:
public class EmailAddress { /** * Converts array of { @ link Address } to { @ link EmailAddress } .
 * @ param addresses array of { @ link Address } es to convert .
 * @ return an array of { @ link EmailAddress } . */
public static EmailAddress [ ] of ( final Address ... addresses ) { } }

implementation: if ( addresses == null ) { return EmailAddress . EMPTY_ARRAY ; } if ( addresses . length == 0 ) { return EmailAddress . EMPTY_ARRAY ; } final EmailAddress [ ] res = new EmailAddress [ addresses . length ] ; for ( int i = 0 ; i < addresses . length ; i ++ ) { res [ i ] = EmailAddress . of ( addresses [ i ] ) ; } return res ;


signature:
public class EmailAddress { /** * Convert from array of { @ link EmailAddress } to array of { @ link InternetAddress } .
 * @ param addresses { @ link EmailMessage }
 * @ return array of { @ link InternetAddress } . Returns empty array if addresses was { @ code null } .
 * @ throws MessagingException if there are failures */
public static InternetAddress [ ] convert ( final EmailAddress [ ] addresses ) throws MessagingException { } }

implementation: if ( addresses == null ) { return new InternetAddress [ 0 ] ; } final int numRecipients = addresses . length ; final InternetAddress [ ] address = new InternetAddress [ numRecipients ] ; for ( int i = 0 ; i < numRecipients ; i ++ ) { address [ i ] = addresses [ i ] . toInternetAddress ( ) ; } return address ;


signature:
public class AopProxy { /** * Creates a proxy of given target and the aspect . */
@ SuppressWarnings ( "unchecked" ) public static < T > T proxyOf ( final T target , final Class < ? extends Aspect > aspectClass ) { } }

implementation: final Aspect aspect ; try { aspect = ClassUtil . newInstance ( aspectClass , target ) ; } catch ( Exception e ) { throw new IllegalArgumentException ( "Can't create new instance of aspect class" , e ) ; } return ( T ) newProxyInstance ( target . getClass ( ) . getClassLoader ( ) , aspect , target . getClass ( ) . getInterfaces ( ) ) ;


signature:
public class AopProxy { /** * Creates a proxy from given { @ link Aspect } . */
@ SuppressWarnings ( "unchecked" ) public static < T > T proxyOf ( final Aspect aspect ) { } }

implementation: final Object target = aspect . getTarget ( ) ; return ( T ) newProxyInstance ( target . getClass ( ) . getClassLoader ( ) , aspect , target . getClass ( ) . getInterfaces ( ) ) ;


signature:
public class StringTemplateParser { /** * Parses string template and replaces macros with resolved values . */
public String parse ( String template , final Function < String , String > macroResolver ) { } }

implementation:
StringBuilder result = new StringBuilder ( template . length ( ) ) ; int i = 0 ; int len = template . length ( ) ; // strict flag means that start and end tag are not necessary
boolean strict ; if ( macroPrefix == null ) { // when prefix is not specified , make it equals to macro start
// so we can use the same code
macroPrefix = macroStart ; strict = true ; } else { strict = false ; } final int prefixLen = macroPrefix . length ( ) ; final int startLen = macroStart . length ( ) ; final int endLen = macroEnd . length ( ) ; while ( i < len ) { int ndx = template . indexOf ( macroPrefix , i ) ; if ( ndx == - 1 ) { result . append ( i == 0 ? template : template . substring ( i ) ) ; break ; } // check escaped
int j = ndx - 1 ; boolean escape = false ; int count = 0 ; while ( ( j >= 0 ) && ( template . charAt ( j ) == escapeChar ) ) { escape = ! escape ; if ( escape ) { count ++ ; } j -- ; } if ( resolveEscapes ) { result . append ( template . substring ( i , ndx - count ) ) ; } else { result . append ( template . substring ( i , ndx ) ) ; } if ( escape ) { result . append ( macroPrefix ) ; i = ndx + prefixLen ; continue ; } // macro started , detect strict format
boolean detectedStrictFormat = strict ; if ( ! detectedStrictFormat ) { if ( StringUtil . isSubstringAt ( template , macroStart , ndx ) ) { detectedStrictFormat = true ; } } int ndx1 ; int ndx2 ; if ( ! detectedStrictFormat ) { // not strict format : $ foo
ndx += prefixLen ; ndx1 = ndx ; ndx2 = ndx ; while ( ( ndx2 < len ) && CharUtil . isPropertyNameChar ( template . charAt ( ndx2 ) ) ) { ndx2 ++ ; } if ( ndx2 == len ) { ndx2 -- ; } while ( ( ndx2 > ndx ) && ! CharUtil . isAlphaOrDigit ( template . charAt ( ndx2 ) ) ) { ndx2 -- ; } ndx2 ++ ; if ( ndx2 == ndx1 + 1 ) { // no value , hence no macro
result . append ( macroPrefix ) ; i = ndx1 ; continue ; } } else { // strict format : $ { foo }
// find macros end
ndx += startLen ; ndx2 = template . indexOf ( macroEnd , ndx ) ; if ( ndx2 == - 1 ) { throw new IllegalArgumentException ( "Invalid template, unclosed macro at: " + ( ndx - startLen ) ) ; } // detect inner macros , there is no escaping
ndx1 = ndx ; while ( ndx1 < ndx2 ) { int n = StringUtil . indexOf ( template , macroStart , ndx1 , ndx2 ) ; if ( n == - 1 ) { break ; } ndx1 = n + startLen ; } } final String name = template . substring ( ndx1 , ndx2 ) ; // find value and append
Object value ; if ( missingKeyReplacement != null || ! replaceMissingKey ) { try { value = macroResolver . apply ( name ) ; } catch ( Exception ignore ) { value = null ; } if ( value == null ) { if ( replaceMissingKey ) { value = missingKeyReplacement ; } else { if ( detectedStrictFormat ) { value = template . substring ( ndx1 - startLen , ndx2 + endLen ) ; } else { value = template . substring ( ndx1 - 1 , ndx2 ) ; } } } } else { value = macroResolver . apply ( name ) ; if ( value == null ) { value = StringPool . EMPTY ; } } if ( ndx == ndx1 ) { String stringValue = value . toString ( ) ; if ( parseValues ) { if ( stringValue . contains ( macroStart ) ) { stringValue = parse ( stringValue , macroResolver ) ; } } result . append ( stringValue ) ; i = ndx2 ; if ( detectedStrictFormat ) { i += endLen ; } } else { // inner macro
template = template . substring ( 0 , ndx1 - startLen ) + value . toString ( ) + template . substring ( ndx2 + endLen ) ; len = template . length ( ) ; i = ndx - startLen ; } } return result . toString ( ) ;


signature:
public class CollectionUtil { /** * Adapt the specified < code > Iterator < / code > to the
 * < code > Enumeration < / code > interface . */
public static < E > Enumeration < E > asEnumeration ( final Iterator < E > iter ) { } }

implementation: return new Enumeration < E > ( ) { @ Override public boolean hasMoreElements ( ) { return iter . hasNext ( ) ; } @ Override public E nextElement ( ) { return iter . next ( ) ; } } ;


signature:
public class CollectionUtil { /** * Adapt the specified < code > Enumeration < / code > to the < code > Iterator < / code > interface . */
public static < E > Iterator < E > asIterator ( final Enumeration < E > e ) { } }

implementation: return new Iterator < E > ( ) { @ Override public boolean hasNext ( ) { return e . hasMoreElements ( ) ; } @ Override public E next ( ) { if ( ! hasNext ( ) ) { throw new NoSuchElementException ( ) ; } return e . nextElement ( ) ; } @ Override public void remove ( ) { throw new UnsupportedOperationException ( ) ; } } ;


signature:
public class CollectionUtil { /** * Returns a collection containing all elements of the iterator . */
public static < T > Collection < T > collectionOf ( final Iterator < ? extends T > iterator ) { } }

implementation: final List < T > list = new ArrayList < > ( ) ; while ( iterator . hasNext ( ) ) { list . add ( iterator . next ( ) ) ; } return list ;


signature:
public class CollectionUtil { /** * Converts iterator to a stream . */
public static < T > Stream < T > streamOf ( final Iterator < T > iterator ) { } }

implementation: return StreamSupport . stream ( ( ( Iterable < T > ) ( ) -> iterator ) . spliterator ( ) , false ) ;


signature:
public class CollectionUtil { /** * Wraps an iterator as a stream . */
public static < T > Stream < T > parallelStreamOf ( final Iterator < T > iterator ) { } }

implementation: return StreamSupport . stream ( ( ( Iterable < T > ) ( ) -> iterator ) . spliterator ( ) , true ) ;


signature:
public class CollectionUtil { /** * Wraps an iterator as a stream . */
public static < T > Stream < T > parallelStreamOf ( final Iterable < T > iterable ) { } }

implementation: return StreamSupport . stream ( iterable . spliterator ( ) , true ) ;


signature:
public class ThreadDbSessionProvider { /** * { @ inheritDoc } */
@ Override public DbSession getDbSession ( ) { } }

implementation: log . debug ( "Requesting thread session" ) ; final DbSession session = ThreadDbSessionHolder . get ( ) ; if ( session == null ) { throw new DbSqlException ( "No DbSession associated with current thread." + "It seems that ThreadDbSessionHolder is not used." ) ; } return session ;


signature:
public class MultiComparator { /** * Compares two objects starting with first comparator ; if they are equals
 * proceeds to the next comparator and so on . */
@ Override public int compare ( final T o1 , final T o2 ) { } }

implementation: for ( Comparator < T > comparator : comparators ) { int result = comparator . compare ( o1 , o2 ) ; if ( result != 0 ) { return result ; } } return 0 ;


signature:
public class ZipBuilder { /** * - - - - - add content */
public AddContentToZip add ( final String content ) { } }

implementation: return new AddContentToZip ( StringUtil . getBytes ( content , StringPool . UTF_8 ) ) ;


signature:
public class ZipBuilder { /** * - - - - - folder */
public ZipBuilder addFolder ( final String folderName ) throws IOException { } }

implementation: ZipUtil . addFolderToZip ( zos , folderName , null ) ; return this ;