signature:
public class MethodProxy { /** * Return the < code > MethodProxy < / code > used when intercepting the method
 * matching the given signature .
 * @ param type the class generated by Enhancer
 * @ param sig the signature to match
 * @ return the MethodProxy instance , or null if no applicable matching method is found
 * @ throws IllegalArgumentException if the Class was not created by Enhancer or does not use a MethodInterceptor */
public static MethodProxy find ( Class type , Signature sig ) { } }

implementation: try { Method m = type . getDeclaredMethod ( MethodInterceptorGenerator . FIND_PROXY_NAME , MethodInterceptorGenerator . FIND_PROXY_TYPES ) ; return ( MethodProxy ) m . invoke ( null , new Object [ ] { sig } ) ; } catch ( NoSuchMethodException e ) { throw new IllegalArgumentException ( "Class " + type + " does not use a MethodInterceptor" ) ; } catch ( IllegalAccessException e ) { throw new CodeGenerationException ( e ) ; } catch ( InvocationTargetException e ) { throw new CodeGenerationException ( e ) ; }


signature:
public class MethodProxy { /** * Invoke the original method , on a different object of the same type .
 * @ param obj the compatible object ; recursion will result if you use the object passed as the first
 * argument to the MethodInterceptor ( usually not what you want )
 * @ param args the arguments passed to the intercepted method ; you may substitute a different
 * argument array as long as the types are compatible
 * @ see MethodInterceptor # intercept
 * @ throws Throwable the bare exceptions thrown by the called method are passed through
 * without wrapping in an < code > InvocationTargetException < / code > */
public Object invoke ( Object obj , Object [ ] args ) throws Throwable { } }

implementation: try { init ( ) ; FastClassInfo fci = fastClassInfo ; return fci . f1 . invoke ( fci . i1 , obj , args ) ; } catch ( InvocationTargetException e ) { throw e . getTargetException ( ) ; } catch ( IllegalArgumentException e ) { if ( fastClassInfo . i1 < 0 ) throw new IllegalArgumentException ( "Protected method: " + sig1 ) ; throw e ; }


signature:
public class MethodProxy { /** * Invoke the original ( super ) method on the specified object .
 * @ param obj the enhanced object , must be the object passed as the first
 * argument to the MethodInterceptor
 * @ param args the arguments passed to the intercepted method ; you may substitute a different
 * argument array as long as the types are compatible
 * @ see MethodInterceptor # intercept
 * @ throws Throwable the bare exceptions thrown by the called method are passed through
 * without wrapping in an < code > InvocationTargetException < / code > */
public Object invokeSuper ( Object obj , Object [ ] args ) throws Throwable { } }

implementation: try { init ( ) ; FastClassInfo fci = fastClassInfo ; return fci . f2 . invoke ( fci . i2 , obj , args ) ; } catch ( InvocationTargetException e ) { throw e . getTargetException ( ) ; }


signature:
public class CodeEmitter { /** * Casts from one primitive numeric type to another */
public void cast_numeric ( Type from , Type to ) { } }

implementation: if ( from != to ) { if ( from == Type . DOUBLE_TYPE ) { if ( to == Type . FLOAT_TYPE ) { mv . visitInsn ( Constants . D2F ) ; } else if ( to == Type . LONG_TYPE ) { mv . visitInsn ( Constants . D2L ) ; } else { mv . visitInsn ( Constants . D2I ) ; cast_numeric ( Type . INT_TYPE , to ) ; } } else if ( from == Type . FLOAT_TYPE ) { if ( to == Type . DOUBLE_TYPE ) { mv . visitInsn ( Constants . F2D ) ; } else if ( to == Type . LONG_TYPE ) { mv . visitInsn ( Constants . F2L ) ; } else { mv . visitInsn ( Constants . F2I ) ; cast_numeric ( Type . INT_TYPE , to ) ; } } else if ( from == Type . LONG_TYPE ) { if ( to == Type . DOUBLE_TYPE ) { mv . visitInsn ( Constants . L2D ) ; } else if ( to == Type . FLOAT_TYPE ) { mv . visitInsn ( Constants . L2F ) ; } else { mv . visitInsn ( Constants . L2I ) ; cast_numeric ( Type . INT_TYPE , to ) ; } } else { if ( to == Type . BYTE_TYPE ) { mv . visitInsn ( Constants . I2B ) ; } else if ( to == Type . CHAR_TYPE ) { mv . visitInsn ( Constants . I2C ) ; } else if ( to == Type . DOUBLE_TYPE ) { mv . visitInsn ( Constants . I2D ) ; } else if ( to == Type . FLOAT_TYPE ) { mv . visitInsn ( Constants . I2F ) ; } else if ( to == Type . LONG_TYPE ) { mv . visitInsn ( Constants . I2L ) ; } else if ( to == Type . SHORT_TYPE ) { mv . visitInsn ( Constants . I2S ) ; } } }


signature:
public class CodeEmitter { /** * Pushes the specified argument of the current method onto the stack .
 * @ param index the zero - based index into the argument list */
public void load_arg ( int index ) { } }

implementation: load_local ( state . argumentTypes [ index ] , state . localOffset + skipArgs ( index ) ) ;


signature:
public class CodeEmitter { /** * zero - based ( see load _ this ) */
public void load_args ( int fromArg , int count ) { } }

implementation: int pos = state . localOffset + skipArgs ( fromArg ) ; for ( int i = 0 ; i < count ; i ++ ) { Type t = state . argumentTypes [ fromArg + i ] ; load_local ( t , pos ) ; pos += t . getSize ( ) ; }


signature:
public class CodeEmitter { /** * package - protected for EmitUtils , try to fix */
void emit_field ( int opcode , Type ctype , String name , Type ftype ) { } }

implementation: mv . visitFieldInsn ( opcode , ctype . getInternalName ( ) , name , ftype . getDescriptor ( ) ) ;


signature:
public class CodeEmitter { /** * If the argument is a primitive class , replaces the primitive value
 * on the top of the stack with the wrapped ( Object ) equivalent . For
 * example , char - > Character .
 * If the class is Void , a null is pushed onto the stack instead .
 * @ param type the class indicating the current type of the top stack value */
public void box ( Type type ) { } }

implementation:
if ( TypeUtils . isPrimitive ( type ) ) { if ( type == Type . VOID_TYPE ) { aconst_null ( ) ; } else { Type boxed = TypeUtils . getBoxedType ( type ) ; new_instance ( boxed ) ; if ( type . getSize ( ) == 2 ) { // Pp - > Ppo - > oPpo - > ooPpo - > ooPp - > o
dup_x2 ( ) ; dup_x2 ( ) ; pop ( ) ; } else { // p - > po - > opo - > oop - > o
dup_x1 ( ) ; swap ( ) ; } invoke_constructor ( boxed , new Signature ( Constants . CONSTRUCTOR_NAME , Type . VOID_TYPE , new Type [ ] { type } ) ) ; } }


signature:
public class CodeEmitter { /** * If the argument is a primitive class , replaces the object
 * on the top of the stack with the unwrapped ( primitive )
 * equivalent . For example , Character - > char .
 * @ param type the class indicating the desired type of the top stack value
 * @ return true if the value was unboxed */
public void unbox ( Type type ) { } }

implementation: Type t = Constants . TYPE_NUMBER ; Signature sig = null ; switch ( type . getSort ( ) ) { case Type . VOID : return ; case Type . CHAR : t = Constants . TYPE_CHARACTER ; sig = CHAR_VALUE ; break ; case Type . BOOLEAN : t = Constants . TYPE_BOOLEAN ; sig = BOOLEAN_VALUE ; break ; case Type . DOUBLE : sig = DOUBLE_VALUE ; break ; case Type . FLOAT : sig = FLOAT_VALUE ; break ; case Type . LONG : sig = LONG_VALUE ; break ; case Type . INT : case Type . SHORT : case Type . BYTE : sig = INT_VALUE ; } if ( sig == null ) { checkcast ( type ) ; } else { checkcast ( t ) ; invoke_virtual ( t , sig ) ; }


signature:
public class CodeEmitter { /** * Allocates and fills an Object [ ] array with the arguments to the
 * current method . Primitive values are inserted as their boxed
 * ( Object ) equivalents . */
public void create_arg_array ( ) { } }

implementation:
/* generates :
 Object [ ] args = new Object [ ] { arg1 , new Integer ( arg2 ) } ; */
push ( state . argumentTypes . length ) ; newarray ( ) ; for ( int i = 0 ; i < state . argumentTypes . length ; i ++ ) { dup ( ) ; push ( i ) ; load_arg ( i ) ; box ( state . argumentTypes [ i ] ) ; aastore ( ) ; }


signature:
public class CodeEmitter { /** * Pushes a zero onto the stack if the argument is a primitive class , or a null otherwise . */
public void zero_or_null ( Type type ) { } }

implementation: if ( TypeUtils . isPrimitive ( type ) ) { switch ( type . getSort ( ) ) { case Type . DOUBLE : push ( 0d ) ; break ; case Type . LONG : push ( 0L ) ; break ; case Type . FLOAT : push ( 0f ) ; break ; case Type . VOID : aconst_null ( ) ; default : push ( 0 ) ; } } else { aconst_null ( ) ; }


signature:
public class CodeEmitter { /** * Unboxes the object on the top of the stack . If the object is null , the
 * unboxed primitive value becomes zero . */
public void unbox_or_zero ( Type type ) { } }

implementation: if ( TypeUtils . isPrimitive ( type ) ) { if ( type != Type . VOID_TYPE ) { Label nonNull = make_label ( ) ; Label end = make_label ( ) ; dup ( ) ; ifnonnull ( nonNull ) ; pop ( ) ; zero_or_null ( type ) ; goTo ( end ) ; mark ( nonNull ) ; unbox ( type ) ; mark ( end ) ; } } else { checkcast ( type ) ; }


signature:
public class EmitUtils { /** * Process an array on the stack . Assumes the top item on the stack
 * is an array of the specified type . For each element in the array ,
 * puts the element on the stack and triggers the callback .
 * @ param type the type of the array ( type . isArray ( ) must be true )
 * @ param callback the callback triggered for each element */
public static void process_array ( CodeEmitter e , Type type , ProcessArrayCallback callback ) { } }

implementation: Type componentType = TypeUtils . getComponentType ( type ) ; Local array = e . make_local ( ) ; Local loopvar = e . make_local ( Type . INT_TYPE ) ; Label loopbody = e . make_label ( ) ; Label checkloop = e . make_label ( ) ; e . store_local ( array ) ; e . push ( 0 ) ; e . store_local ( loopvar ) ; e . goTo ( checkloop ) ; e . mark ( loopbody ) ; e . load_local ( array ) ; e . load_local ( loopvar ) ; e . array_load ( componentType ) ; callback . processElement ( componentType ) ; e . iinc ( loopvar , 1 ) ; e . mark ( checkloop ) ; e . load_local ( loopvar ) ; e . load_local ( array ) ; e . arraylength ( ) ; e . if_icmp ( e . LT , loopbody ) ;


signature:
public class EmitUtils { /** * Branches to the specified label if the top two items on the stack
 * are not equal . The items must both be of the specified
 * class . Equality is determined by comparing primitive values
 * directly and by invoking the < code > equals < / code > method for
 * Objects . Arrays are recursively processed in the same manner . */
public static void not_equals ( final CodeEmitter e , Type type , final Label notEquals , final CustomizerRegistry registry ) { } }

implementation: ( new ProcessArrayCallback ( ) { public void processElement ( Type type ) { not_equals_helper ( e , type , notEquals , registry , this ) ; } } ) . processElement ( type ) ;


signature:
public class EmitUtils { /** * If both objects on the top of the stack are non - null , does nothing .
 * If one is null , or both are null , both are popped off and execution
 * branches to the respective label .
 * @ param oneNull label to branch to if only one of the objects is null
 * @ param bothNull label to branch to if both of the objects are null */
private static void nullcmp ( CodeEmitter e , Label oneNull , Label bothNull ) { } }

implementation: e . dup2 ( ) ; Label nonNull = e . make_label ( ) ; Label oneNullHelper = e . make_label ( ) ; Label end = e . make_label ( ) ; e . ifnonnull ( nonNull ) ; e . ifnonnull ( oneNullHelper ) ; e . pop2 ( ) ; e . goTo ( bothNull ) ; e . mark ( nonNull ) ; e . ifnull ( oneNullHelper ) ; e . goTo ( end ) ; e . mark ( oneNullHelper ) ; e . pop2 ( ) ; e . goTo ( oneNull ) ; e . mark ( end ) ;


signature:
public class EmitUtils { /** * / * generates :
 * } catch ( RuntimeException e ) {
 * throw e ;
 * } catch ( Error e ) {
 * throw e ;
 * } catch ( < DeclaredException > e ) {
 * throw e ;
 * } catch ( Throwable e ) {
 * throw new < Wrapper > ( e ) ; */
public static void wrap_undeclared_throwable ( CodeEmitter e , Block handler , Type [ ] exceptions , Type wrapper ) { } }

implementation:
Set set = ( exceptions == null ) ? Collections . EMPTY_SET : new HashSet ( Arrays . asList ( exceptions ) ) ; if ( set . contains ( Constants . TYPE_THROWABLE ) ) return ; boolean needThrow = exceptions != null ; if ( ! set . contains ( Constants . TYPE_RUNTIME_EXCEPTION ) ) { e . catch_exception ( handler , Constants . TYPE_RUNTIME_EXCEPTION ) ; needThrow = true ; } if ( ! set . contains ( Constants . TYPE_ERROR ) ) { e . catch_exception ( handler , Constants . TYPE_ERROR ) ; needThrow = true ; } if ( exceptions != null ) { for ( int i = 0 ; i < exceptions . length ; i ++ ) { e . catch_exception ( handler , exceptions [ i ] ) ; } } if ( needThrow ) { e . athrow ( ) ; } // e - > eo - > oeo - > ooe - > o
e . catch_exception ( handler , Constants . TYPE_THROWABLE ) ; e . new_instance ( wrapper ) ; e . dup_x1 ( ) ; e . swap ( ) ; e . invoke_constructor ( wrapper , CSTRUCT_THROWABLE ) ; e . athrow ( ) ;


signature:
public class BridgeMethodResolver { /** * Finds all bridge methods that are being called with invokespecial &
 * returns them . */
public Map /* < Signature , Signature > */
resolveAll ( ) { } }

implementation: Map resolved = new HashMap ( ) ; for ( Iterator entryIter = declToBridge . entrySet ( ) . iterator ( ) ; entryIter . hasNext ( ) ; ) { Map . Entry entry = ( Map . Entry ) entryIter . next ( ) ; Class owner = ( Class ) entry . getKey ( ) ; Set bridges = ( Set ) entry . getValue ( ) ; try { InputStream is = classLoader . getResourceAsStream ( owner . getName ( ) . replace ( '.' , '/' ) + ".class" ) ; if ( is == null ) { return resolved ; } try { new ClassReader ( is ) . accept ( new BridgedFinder ( bridges , resolved ) , ClassReader . SKIP_FRAMES | ClassReader . SKIP_DEBUG ) ; } finally { is . close ( ) ; } } catch ( IOException ignored ) { } } return resolved ;


signature:
public class Enhancer { /** * Set the class which the generated class will extend . As a convenience ,
 * if the supplied superclass is actually an interface , < code > setInterfaces < / code >
 * will be called with the appropriate argument instead .
 * A non - interface argument must not be declared as final , and must have an
 * accessible constructor .
 * @ param superclass class to extend or interface to implement
 * @ see # setInterfaces ( Class [ ] ) */
public void setSuperclass ( Class superclass ) { } }

implementation:
if ( superclass != null && superclass . isInterface ( ) ) { setInterfaces ( new Class [ ] { superclass } ) ; } else if ( superclass != null && superclass . equals ( Object . class ) ) { // affects choice of ClassLoader
this . superclass = null ; } else { this . superclass = superclass ; }


signature:
public class Enhancer { /** * Set the array of callbacks to use .
 * Ignored if you use { @ link # createClass } .
 * You must use a { @ link CallbackFilter } to specify the index into this
 * array for each method in the proxied class .
 * @ param callbacks the callback array
 * @ see # setCallbackFilter
 * @ see # setCallback */
public void setCallbacks ( Callback [ ] callbacks ) { } }

implementation: if ( callbacks != null && callbacks . length == 0 ) { throw new IllegalArgumentException ( "Array cannot be empty" ) ; } this . callbacks = callbacks ;


signature:
public class Enhancer { /** * Set the array of callback types to use .
 * This may be used instead of { @ link # setCallbacks } when calling
 * { @ link # createClass } , since it may not be possible to have
 * an array of actual callback instances .
 * You must use a { @ link CallbackFilter } to specify the index into this
 * array for each method in the proxied class .
 * @ param callbackTypes the array of callback types */
public void setCallbackTypes ( Class [ ] callbackTypes ) { } }

implementation: if ( callbackTypes != null && callbackTypes . length == 0 ) { throw new IllegalArgumentException ( "Array cannot be empty" ) ; } this . callbackTypes = CallbackInfo . determineTypes ( callbackTypes ) ;


signature:
public class Enhancer { /** * Generate a new class if necessary and uses the specified
 * callbacks ( if any ) to create a new object instance .
 * Uses the constructor of the superclass matching the < code > argumentTypes < / code >
 * parameter , with the given arguments .
 * @ param argumentTypes constructor signature
 * @ param arguments compatible wrapped arguments to pass to constructor
 * @ return a new instance */
public Object create ( Class [ ] argumentTypes , Object [ ] arguments ) { } }

implementation: classOnly = false ; if ( argumentTypes == null || arguments == null || argumentTypes . length != arguments . length ) { throw new IllegalArgumentException ( "Arguments must be non-null and of equal length" ) ; } this . argumentTypes = argumentTypes ; this . arguments = arguments ; return createHelper ( ) ;


signature:
public class Enhancer { /** * Finds all of the methods that will be extended by an
 * Enhancer - generated class using the specified superclass and
 * interfaces . This can be useful in building a list of Callback
 * objects . The methods are added to the end of the given list . Due
 * to the subclassing nature of the classes generated by Enhancer ,
 * the methods are guaranteed to be non - static , non - final , and
 * non - private . Each method signature will only occur once , even if
 * it occurs in multiple classes .
 * @ param superclass the class that will be extended , or null
 * @ param interfaces the list of interfaces that will be implemented , or null
 * @ param methods the list into which to copy the applicable methods */
public static void getMethods ( Class superclass , Class [ ] interfaces , List methods ) { } }

implementation: getMethods ( superclass , interfaces , methods , null , null ) ;


signature:
public class Enhancer { /** * Filter the list of constructors from the superclass . The
 * constructors which remain will be included in the generated
 * class . The default implementation is to filter out all private
 * constructors , but subclasses may extend Enhancer to override this
 * behavior .
 * @ param sc the superclass
 * @ param constructors the list of all declared constructors from the superclass
 * @ throws IllegalArgumentException if there are no non - private constructors */
protected void filterConstructors ( Class sc , List constructors ) { } }

implementation: CollectionUtils . filter ( constructors , new VisibilityPredicate ( sc , true ) ) ; if ( constructors . size ( ) == 0 ) throw new IllegalArgumentException ( "No visible constructors in " + sc ) ;


signature:
public class Enhancer { /** * Determine if a class was generated using < code > Enhancer < / code > .
 * @ param type any class
 * @ return whether the class was generated using < code > Enhancer < / code > */
public static boolean isEnhanced ( Class type ) { } }

implementation: try { getCallbacksSetter ( type , SET_THREAD_CALLBACKS_NAME ) ; return true ; } catch ( NoSuchMethodException e ) { return false ; }


signature:
public class Enhancer { /** * Instantiates a proxy instance and assigns callback values .
 * Implementation detail : java . lang . reflect instances are not cached , so this method should not
 * be used on a hot path .
 * This method is used when { @ link # setUseCache ( boolean ) } is set to { @ code false } .
 * @ param type class to instantiate
 * @ return newly created instance */
private Object createUsingReflection ( Class type ) { } }

implementation:
setThreadCallbacks ( type , callbacks ) ; try { if ( argumentTypes != null ) { return ReflectUtils . newInstance ( type , argumentTypes , arguments ) ; } else { return ReflectUtils . newInstance ( type ) ; } } finally { // clear thread callbacks to allow them to be gc ' d
setThreadCallbacks ( type , null ) ; }


signature:
public class Enhancer { /** * Helper method to create an intercepted object .
 * For finer control over the generated instance , use a new instance of < code > Enhancer < / code >
 * instead of this static method .
 * @ param type class to extend or interface to implement
 * @ param callback the callback to use for all methods */
public static Object create ( Class type , Callback callback ) { } }

implementation: Enhancer e = new Enhancer ( ) ; e . setSuperclass ( type ) ; e . setCallback ( callback ) ; return e . create ( ) ;


signature:
public class Enhancer { /** * Helper method to create an intercepted object .
 * For finer control over the generated instance , use a new instance of < code > Enhancer < / code >
 * instead of this static method .
 * @ param superclass class to extend or interface to implement
 * @ param interfaces array of interfaces to implement , or null
 * @ param callback the callback to use for all methods */
public static Object create ( Class superclass , Class interfaces [ ] , Callback callback ) { } }

implementation: Enhancer e = new Enhancer ( ) ; e . setSuperclass ( superclass ) ; e . setInterfaces ( interfaces ) ; e . setCallback ( callback ) ; return e . create ( ) ;


signature:
public class Enhancer { /** * Helper method to create an intercepted object .
 * For finer control over the generated instance , use a new instance of < code > Enhancer < / code >
 * instead of this static method .
 * @ param superclass class to extend or interface to implement
 * @ param interfaces array of interfaces to implement , or null
 * @ param filter the callback filter to use when generating a new class
 * @ param callbacks callback implementations to use for the enhanced object */
public static Object create ( Class superclass , Class [ ] interfaces , CallbackFilter filter , Callback [ ] callbacks ) { } }

implementation: Enhancer e = new Enhancer ( ) ; e . setSuperclass ( superclass ) ; e . setInterfaces ( interfaces ) ; e . setCallbackFilter ( filter ) ; e . setCallbacks ( callbacks ) ; return e . create ( ) ;


signature:
public class BeanGenerator { /** * Set the class which the generated class will extend . The class
 * must not be declared as final , and must have a non - private
 * no - argument constructor .
 * @ param superclass class to extend , or null to extend Object */
public void setSuperclass ( Class superclass ) { } }

implementation: if ( superclass != null && superclass . equals ( Object . class ) ) { superclass = null ; } this . superclass = superclass ;


signature:
public class FieldProviderTransformer { /** * to avoid JVM hashcode implementation incompatibilities */
private void getField ( String [ ] names ) throws Exception { } }

implementation: final CodeEmitter e = begin_method ( Constants . ACC_PUBLIC , PROVIDER_GET , null ) ; e . load_this ( ) ; e . load_arg ( 0 ) ; EmitUtils . string_switch ( e , names , Constants . SWITCH_STYLE_HASH , new ObjectSwitchCallback ( ) { public void processCase ( Object key , Label end ) { Type type = ( Type ) fields . get ( key ) ; e . getfield ( ( String ) key ) ; e . box ( type ) ; e . return_value ( ) ; } public void processDefault ( ) { e . throw_exception ( ILLEGAL_ARGUMENT_EXCEPTION , "Unknown field name" ) ; } } ) ; e . end_method ( ) ;


signature:
public class InterfaceMaker { /** * Add a method signature to the interface . The method modifiers are ignored ,
 * since interface methods are by definition abstract and public .
 * @ param method the method to add to the interface */
public void add ( Method method ) { } }

implementation: add ( ReflectUtils . getSignature ( method ) , ReflectUtils . getExceptionTypes ( method ) ) ;


signature:
public class InterfaceMaker { /** * Add all the public methods in the specified class .
 * Methods from superclasses are included , except for methods declared in the base
 * Object class ( e . g . < code > getClass < / code > , < code > equals < / code > , < code > hashCode < / code > ) .
 * @ param class the class containing the methods to add to the interface */
public void add ( Class clazz ) { } }

implementation: Method [ ] methods = clazz . getMethods ( ) ; for ( int i = 0 ; i < methods . length ; i ++ ) { Method m = methods [ i ] ; if ( ! m . getDeclaringClass ( ) . getName ( ) . equals ( "java.lang.Object" ) ) { add ( m ) ; } }


signature:
public class TinyBitSet { /** * If bit 31 is set then this method results in an infinite loop .
 * @ return the number of bits set to < code > true < / code > in this TinyBitSet . */
public int cardinality ( ) { } }

implementation: int w = value ; int c = 0 ; while ( w != 0 ) { c += T [ w & 255 ] ; w >>= 8 ; } return c ;


signature:
public class AbstractClassGenerator { /** * Override the default naming policy .
 * @ see DefaultNamingPolicy
 * @ param namingPolicy the custom policy , or null to use the default */
public void setNamingPolicy ( NamingPolicy namingPolicy ) { } }

implementation: if ( namingPolicy == null ) namingPolicy = DefaultNamingPolicy . INSTANCE ; this . namingPolicy = namingPolicy ;


signature:
public class AbstractClassGenerator { /** * Set the strategy to use to create the bytecode from this generator .
 * By default an instance of { @ see DefaultGeneratorStrategy } is used . */
public void setStrategy ( GeneratorStrategy strategy ) { } }

implementation: if ( strategy == null ) strategy = DefaultGeneratorStrategy . INSTANCE ; this . strategy = strategy ;


signature:
public class LoadingCache { /** * Loads entry to the cache .
 * If entry is missing , put { @ link FutureTask } first so other competing thread might wait for the result .
 * @ param key original key that would be used to load the instance
 * @ param cacheKey key that would be used to store the entry in internal map
 * @ param v null or { @ link FutureTask < V > }
 * @ return newly created instance */
protected V createEntry ( final K key , KK cacheKey , Object v ) { } }

implementation:
FutureTask < V > task ; boolean creator = false ; if ( v != null ) { // Another thread is already loading an instance
task = ( FutureTask < V > ) v ; } else { task = new FutureTask < V > ( new Callable < V > ( ) { public V call ( ) throws Exception { return loader . apply ( key ) ; } } ) ; Object prevTask = map . putIfAbsent ( cacheKey , task ) ; if ( prevTask == null ) { // creator does the load
creator = true ; task . run ( ) ; } else if ( prevTask instanceof FutureTask ) { task = ( FutureTask < V > ) prevTask ; } else { return ( V ) prevTask ; } } V result ; try { result = task . get ( ) ; } catch ( InterruptedException e ) { throw new IllegalStateException ( "Interrupted while loading cache item" , e ) ; } catch ( ExecutionException e ) { Throwable cause = e . getCause ( ) ; if ( cause instanceof RuntimeException ) { throw ( ( RuntimeException ) cause ) ; } throw new IllegalStateException ( "Unable to load cache item" , cause ) ; } if ( creator ) { map . put ( cacheKey , result ) ; } return result ;


signature:
public class ReflectUtils { /** * used by MethodInterceptorGenerated generated code */
public static Method [ ] findMethods ( String [ ] namesAndDescriptors , Method [ ] methods ) { } }

implementation:
Map map = new HashMap ( ) ; for ( int i = 0 ; i < methods . length ; i ++ ) { Method method = methods [ i ] ; map . put ( method . getName ( ) + Type . getMethodDescriptor ( method ) , method ) ; } Method [ ] result = new Method [ namesAndDescriptors . length / 2 ] ; for ( int i = 0 ; i < result . length ; i ++ ) { result [ i ] = ( Method ) map . get ( namesAndDescriptors [ i * 2 ] + namesAndDescriptors [ i * 2 + 1 ] ) ; if ( result [ i ] == null ) { // TODO : error ?
} } return result ;


signature:
public class PathUtil { /** * Resolves subpath in safer way . For some reason , if child starts with
 * a separator it gets resolved as a full path , ignoring the base .
 * This method acts different . */
public static Path resolve ( final Path base , String child ) { } }

implementation: if ( StringUtil . startsWithChar ( child , File . separatorChar ) ) { child = child . substring ( 1 ) ; } return base . resolve ( child ) ;


signature:
public class PathUtil { /** * Reads path content . */
public static String readString ( final Path path ) throws IOException { } }

implementation:
try ( BufferedReader reader = Files . newBufferedReader ( path , StandardCharsets . UTF_8 ) ) { StringWriter writer = new StringWriter ( ) ; // flush & close not needed for StringWriter - instance
StreamUtil . copy ( reader , writer ) ; return writer . toString ( ) ; }


signature:
public class HttpRequest { /** * Sets request host name . */
public HttpRequest host ( final String host ) { } }

implementation: this . host = host ; if ( headers . contains ( HEADER_HOST ) ) { headerOverwrite ( HEADER_HOST , host ) ; } return this ;


signature:
public class HttpRequest { /** * Sets the destination ( method , host , port . . . ) at once . */
public HttpRequest set ( String destination ) { } }

implementation:
destination = destination . trim ( ) ; // http method , optional
int ndx = destination . indexOf ( ' ' ) ; if ( ndx != - 1 ) { String method = destination . substring ( 0 , ndx ) . toUpperCase ( ) ; try { HttpMethod httpMethod = HttpMethod . valueOf ( method ) ; this . method = httpMethod . name ( ) ; destination = destination . substring ( ndx + 1 ) ; } catch ( IllegalArgumentException ignore ) { // unknown http method
} } // protocol
ndx = destination . indexOf ( "://" ) ; if ( ndx != - 1 ) { protocol = destination . substring ( 0 , ndx ) ; destination = destination . substring ( ndx + 3 ) ; } // host
ndx = destination . indexOf ( '/' ) ; if ( ndx == - 1 ) { ndx = destination . length ( ) ; } if ( ndx != 0 ) { String hostToSet = destination . substring ( 0 , ndx ) ; destination = destination . substring ( ndx ) ; // port
ndx = hostToSet . indexOf ( ':' ) ; if ( ndx == - 1 ) { port = Defaults . DEFAULT_PORT ; } else { port = Integer . parseInt ( hostToSet . substring ( ndx + 1 ) ) ; hostToSet = hostToSet . substring ( 0 , ndx ) ; } host ( hostToSet ) ; } // path + query
path ( destination ) ; return this ;


signature:
public class HttpRequest { /** * Generic request builder , usually used when method is a variable .
 * Otherwise , use one of the other static request builder methods . */
public static HttpRequest create ( final String method , final String destination ) { } }

implementation: return new HttpRequest ( ) . method ( method . toUpperCase ( ) ) . set ( destination ) ;


signature:
public class HttpRequest { /** * Builds a CONNECT request . */
public static HttpRequest connect ( final String destination ) { } }

implementation: return new HttpRequest ( ) . method ( HttpMethod . CONNECT ) . set ( destination ) ;


signature:
public class HttpRequest { /** * Builds a GET request . */
public static HttpRequest get ( final String destination ) { } }

implementation: return new HttpRequest ( ) . method ( HttpMethod . GET ) . set ( destination ) ;


signature:
public class HttpRequest { /** * Builds a POST request . */
public static HttpRequest post ( final String destination ) { } }

implementation: return new HttpRequest ( ) . method ( HttpMethod . POST ) . set ( destination ) ;


signature:
public class HttpRequest { /** * Builds a PUT request . */
public static HttpRequest put ( final String destination ) { } }

implementation: return new HttpRequest ( ) . method ( HttpMethod . PUT ) . set ( destination ) ;


signature:
public class HttpRequest { /** * Builds a PATCH request . */
public static HttpRequest patch ( final String destination ) { } }

implementation: return new HttpRequest ( ) . method ( HttpMethod . PATCH ) . set ( destination ) ;


signature:
public class HttpRequest { /** * Builds a DELETE request . */
public static HttpRequest delete ( final String destination ) { } }

implementation: return new HttpRequest ( ) . method ( HttpMethod . DELETE ) . set ( destination ) ;


signature:
public class HttpRequest { /** * Builds a HEAD request . */
public static HttpRequest head ( final String destination ) { } }

implementation: return new HttpRequest ( ) . method ( HttpMethod . HEAD ) . set ( destination ) ;


signature:
public class HttpRequest { /** * Builds a TRACE request . */
public static HttpRequest trace ( final String destination ) { } }

implementation: return new HttpRequest ( ) . method ( HttpMethod . TRACE ) . set ( destination ) ;


signature:
public class HttpRequest { /** * Builds an OPTIONS request . */
public static HttpRequest options ( final String destination ) { } }

implementation: return new HttpRequest ( ) . method ( HttpMethod . OPTIONS ) . set ( destination ) ;


signature:
public class HttpRequest { /** * Sets request path . Query string is allowed .
 * Adds a slash if path doesn ' t start with one .
 * Query will be stripped out from the path .
 * Previous query is discarded .
 * @ see # query ( ) */
public HttpRequest path ( String path ) { } }

implementation:
// this must be the only place that sets the path
if ( ! path . startsWith ( StringPool . SLASH ) ) { path = StringPool . SLASH + path ; } int ndx = path . indexOf ( '?' ) ; if ( ndx != - 1 ) { String queryString = path . substring ( ndx + 1 ) ; path = path . substring ( 0 , ndx ) ; query = HttpUtil . parseQuery ( queryString , true ) ; } else { query = HttpMultiMap . newCaseInsensitiveMap ( ) ; } this . path = path ; return this ;


signature:
public class HttpRequest { /** * Sets cookies to the request . */
public HttpRequest cookies ( final Cookie ... cookies ) { } }

implementation: if ( cookies . length == 0 ) { return this ; } StringBuilder cookieString = new StringBuilder ( ) ; boolean first = true ; for ( Cookie cookie : cookies ) { Integer maxAge = cookie . getMaxAge ( ) ; if ( maxAge != null && maxAge . intValue ( ) == 0 ) { continue ; } if ( ! first ) { cookieString . append ( "; " ) ; } first = false ; cookieString . append ( cookie . getName ( ) ) ; cookieString . append ( '=' ) ; cookieString . append ( cookie . getValue ( ) ) ; } headerOverwrite ( "cookie" , cookieString . toString ( ) ) ; return this ;


signature:
public class HttpRequest { /** * Adds query parameter . */
public HttpRequest query ( final String name , final String value ) { } }

implementation: query . add ( name , value ) ; return this ;


signature:
public class HttpRequest { /** * Adds many query parameters at once . Although it accepts objects ,
 * each value will be converted to string . */
public HttpRequest query ( final String name1 , final Object value1 , final Object ... parameters ) { } }

implementation: query ( name1 , value1 == null ? null : value1 . toString ( ) ) ; for ( int i = 0 ; i < parameters . length ; i += 2 ) { String name = parameters [ i ] . toString ( ) ; String value = parameters [ i + 1 ] . toString ( ) ; query . add ( name , value ) ; } return this ;


signature:
public class HttpRequest { /** * Adds all parameters from the provided map . */
public HttpRequest query ( final Map < String , String > queryMap ) { } }

implementation: for ( Map . Entry < String , String > entry : queryMap . entrySet ( ) ) { query . add ( entry . getKey ( ) , entry . getValue ( ) ) ; } return this ;


signature:
public class HttpRequest { /** * Sets query from provided query string . Previous query values
 * are discarded . */
public HttpRequest queryString ( final String queryString , final boolean decode ) { } }

implementation: this . query = HttpUtil . parseQuery ( queryString , decode ) ; return this ;


signature:
public class HttpRequest { /** * Generates query string . All values are URL encoded . */
public String queryString ( ) { } }

implementation: if ( query == null ) { return StringPool . EMPTY ; } return HttpUtil . buildQuery ( query , queryEncoding ) ;


signature:
public class HttpRequest { /** * Returns full URL path .
 * Simply concatenates { @ link # protocol ( String ) protocol } , { @ link # host ( String ) host } ,
 * { @ link # port ( int ) port } , { @ link # path ( String ) path } and { @ link # queryString ( String ) query string } . */
public String url ( ) { } }

implementation: StringBuilder url = new StringBuilder ( ) ; url . append ( hostUrl ( ) ) ; if ( path != null ) { url . append ( path ) ; } String queryString = queryString ( ) ; if ( StringUtil . isNotBlank ( queryString ) ) { url . append ( '?' ) ; url . append ( queryString ) ; } return url . toString ( ) ;


signature:
public class HttpRequest { /** * Returns just host url , without path and query . */
public String hostUrl ( ) { } }

implementation: StringBand url = new StringBand ( 8 ) ; if ( protocol != null ) { url . append ( protocol ) ; url . append ( "://" ) ; } if ( host != null ) { url . append ( host ) ; } if ( port != Defaults . DEFAULT_PORT ) { url . append ( ':' ) ; url . append ( port ) ; } return url . toString ( ) ;


signature:
public class HttpRequest { /** * Enables basic authentication by adding required header . */
public HttpRequest basicAuthentication ( final String username , final String password ) { } }

implementation: if ( username != null && password != null ) { String data = username . concat ( StringPool . COLON ) . concat ( password ) ; String base64 = Base64 . encodeToString ( data ) ; headerOverwrite ( HEADER_AUTHORIZATION , "Basic " + base64 ) ; } return this ;


signature:
public class HttpRequest { /** * Sets ' Host ' header from current host and port . */
public HttpRequest setHostHeader ( ) { } }

implementation: String hostPort = this . host ; if ( port != Defaults . DEFAULT_PORT ) { hostPort += StringPool . COLON + port ; } headerOverwrite ( HEADER_HOST , hostPort ) ; return this ;


signature:
public class HttpRequest { /** * Opens a new { @ link jodd . http . HttpConnection connection }
 * using given { @ link jodd . http . HttpConnectionProvider } . */
public HttpRequest open ( final HttpConnectionProvider httpConnectionProvider ) { } }

implementation: if ( this . httpConnection != null ) { throw new HttpException ( "Connection already opened" ) ; } try { this . httpConnectionProvider = httpConnectionProvider ; this . httpConnection = httpConnectionProvider . createHttpConnection ( this ) ; } catch ( IOException ioex ) { throw new HttpException ( "Can't connect to: " + url ( ) , ioex ) ; } return this ;


signature:
public class HttpRequest { /** * Assignees provided { @ link jodd . http . HttpConnection } for communication .
 * It does not actually opens it until the { @ link # send ( ) sending } . */
public HttpRequest open ( final HttpConnection httpConnection ) { } }

implementation: if ( this . httpConnection != null ) { throw new HttpException ( "Connection already opened" ) ; } this . httpConnection = httpConnection ; this . httpConnectionProvider = null ; return this ;


signature:
public class HttpRequest { /** * Continues using the same keep - alive connection .
 * Don ' t use any variant of < code > open ( ) < / code > when
 * continuing the communication !
 * First it checks if " Connection " header exist in the response
 * and if it is equal to " Keep - Alive " value . Then it
 * checks the " Keep - Alive " headers " max " parameter .
 * If its value is positive , then the existing { @ link jodd . http . HttpConnection }
 * from the request will be reused . If max value is 1,
 * connection will be sent with " Connection : Close " header , indicating
 * its the last request . When new connection is created , the
 * same { @ link jodd . http . HttpConnectionProvider } that was used for
 * creating initial connection is used for opening the new connection .
 * @ param doContinue set it to < code > false < / code > to indicate the last connection */
public HttpRequest keepAlive ( final HttpResponse httpResponse , final boolean doContinue ) { } }

implementation:
boolean keepAlive = httpResponse . isConnectionPersistent ( ) ; if ( keepAlive ) { HttpConnection previousConnection = httpResponse . getHttpRequest ( ) . httpConnection ; if ( previousConnection != null ) { // keep using the connection !
this . httpConnection = previousConnection ; this . httpConnectionProvider = httpResponse . getHttpRequest ( ) . connectionProvider ( ) ; } // keepAlive = true ; ( already set )
} else { // close previous connection
httpResponse . close ( ) ; // force keep - alive on new request
keepAlive = true ; } // if we don ' t want to continue with this persistent session , mark this connection as closed
if ( ! doContinue ) { keepAlive = false ; } connectionKeepAlive ( keepAlive ) ; // if connection is not opened , open it using previous connection provider
if ( httpConnection == null ) { open ( httpResponse . getHttpRequest ( ) . connectionProvider ( ) ) ; } return this ;


signature:
public class HttpRequest { /** * { @ link # open ( ) Opens connection } if not already open , sends request ,
 * reads response and closes the request . If keep - alive mode is enabled
 * connection will not be closed . */
public HttpResponse send ( ) { } }

implementation: if ( ! followRedirects ) { return _send ( ) ; } int redirects = this . maxRedirects ; while ( redirects > 0 ) { redirects -- ; final HttpResponse httpResponse = _send ( ) ; final int statusCode = httpResponse . statusCode ( ) ; if ( HttpStatus . isRedirect ( statusCode ) ) { _reset ( ) ; set ( httpResponse . location ( ) ) ; continue ; } return httpResponse ; } throw new HttpException ( "Max number of redirects exceeded: " + this . maxRedirects ) ;


signature:
public class HttpRequest { /** * Prepares the request buffer . */
@ Override protected Buffer buffer ( final boolean fullRequest ) { } }

implementation:
// INITIALIZATION
// host port
if ( header ( HEADER_HOST ) == null ) { setHostHeader ( ) ; } // form
Buffer formBuffer = formBuffer ( ) ; // query string
String queryString = queryString ( ) ; // user - agent
if ( header ( "User-Agent" ) == null ) { header ( "User-Agent" , Defaults . userAgent ) ; } // POST method requires Content - Type to be set
if ( method . equals ( "POST" ) && ( contentLength ( ) == null ) ) { contentLength ( 0 ) ; } // BUILD OUT
Buffer request = new Buffer ( ) ; request . append ( method ) . append ( SPACE ) . append ( path ) ; if ( query != null && ! query . isEmpty ( ) ) { request . append ( '?' ) ; request . append ( queryString ) ; } request . append ( SPACE ) . append ( httpVersion ) . append ( CRLF ) ; populateHeaderAndBody ( request , formBuffer , fullRequest ) ; return request ;


signature:
public class HttpRequest { /** * Syntax sugar . */
public < R > R sendAndReceive ( final Function < HttpResponse , R > responseHandler ) { } }

implementation: return responseHandler . apply ( send ( ) ) ;


signature:
public class EMLProperties { /** * Creates new { @ link Session } with or without custom { @ link Properties } .
 * @ param properties Custom properties to be used during { @ link Session } creation . It is acceptable is this value is { @ code null } .
 * @ return { @ link Session } with any custom { @ link Properties } */
protected Session createSession ( Properties properties ) { } }

implementation: if ( properties == null ) { properties = System . getProperties ( ) ; } this . session = Session . getInstance ( properties ) ; return session ;


signature:
public class EMLProperties { /** * Copies properties from given set . If { @ link Session } is already created , exception will be thrown .
 * @ param properties { @ link Properties } to set .
 * @ return this
 * @ throws MailException if the { @ link Properties } has already been set . */
public T set ( final Properties properties ) throws MailException { } }

implementation: checkSessionNotSet ( ) ; this . properties . putAll ( properties ) ; return _this ( ) ;


signature:
public class EMLProperties { /** * Sets property for the { @ link Session } . If { @ link Session } is already created , an exception
 * will be thrown .
 * @ param name Property name to set .
 * @ param value Property value to set .
 * @ return this
 * @ throws MailException if the { @ link Properties } has already been set . */
public T set ( final String name , final String value ) { } }

implementation: checkSessionNotSet ( ) ; properties . setProperty ( name , value ) ; return _this ( ) ;


signature:
public class Document { /** * Add new error message to the { @ link # getErrors ( ) errors list } .
 * If errors are not collected error , message is ignored . */
public void addError ( final String message ) { } }

implementation: if ( config . collectErrors ) { if ( errors == null ) { errors = new ArrayList < > ( ) ; } errors . add ( message ) ; }


signature:
public class Handler { /** * Removes the range between start and end from the Handler list that begins with the given
 * element .
 * @ param firstHandler the beginning of a Handler list . May be { @ literal null } .
 * @ param start the start of the range to be removed .
 * @ param end the end of the range to be removed . Maybe { @ literal null } .
 * @ return the exception handler list with the start - end range removed . */
static Handler removeRange ( final Handler firstHandler , final Label start , final Label end ) { } }

implementation:
if ( firstHandler == null ) { return null ; } else { firstHandler . nextHandler = removeRange ( firstHandler . nextHandler , start , end ) ; } int handlerStart = firstHandler . startPc . bytecodeOffset ; int handlerEnd = firstHandler . endPc . bytecodeOffset ; int rangeStart = start . bytecodeOffset ; int rangeEnd = end == null ? Integer . MAX_VALUE : end . bytecodeOffset ; // Return early if [ handlerStart , handlerEnd [ and [ rangeStart , rangeEnd [ don ' t intersect .
if ( rangeStart >= handlerEnd || rangeEnd <= handlerStart ) { return firstHandler ; } if ( rangeStart <= handlerStart ) { if ( rangeEnd >= handlerEnd ) { // If [ handlerStart , handlerEnd [ is included in [ rangeStart , rangeEnd [ , remove firstHandler .
return firstHandler . nextHandler ; } else { // [ handlerStart , handlerEnd [ - [ rangeStart , rangeEnd [ = [ rangeEnd , handlerEnd [
return new Handler ( firstHandler , end , firstHandler . endPc ) ; } } else if ( rangeEnd >= handlerEnd ) { // [ handlerStart , handlerEnd [ - [ rangeStart , rangeEnd [ = [ handlerStart , rangeStart [
return new Handler ( firstHandler , firstHandler . startPc , start ) ; } else { // [ handlerStart , handlerEnd [ - [ rangeStart , rangeEnd [ =
// [ handlerStart , rangeStart [ + [ rangeEnd , handerEnd [
firstHandler . nextHandler = new Handler ( firstHandler , end , firstHandler . endPc ) ; return new Handler ( firstHandler , firstHandler . startPc , start ) ; }


signature:
public class Handler { /** * Returns the number of elements of the Handler list that begins with the given element .
 * @ param firstHandler the beginning of a Handler list . May be { @ literal null } .
 * @ return the number of elements of the Handler list that begins with ' handler ' . */
static int getExceptionTableLength ( final Handler firstHandler ) { } }

implementation: int length = 0 ; Handler handler = firstHandler ; while ( handler != null ) { length ++ ; handler = handler . nextHandler ; } return length ;


signature:
public class Handler { /** * Puts the JVMS exception _ table corresponding to the Handler list that begins with the given
 * element . < i > This includes the exception _ table _ length field . < / i >
 * @ param firstHandler the beginning of a Handler list . May be { @ literal null } .
 * @ param output where the exception _ table _ length and exception _ table structures must be put . */
static void putExceptionTable ( final Handler firstHandler , final ByteVector output ) { } }

implementation: output . putShort ( getExceptionTableLength ( firstHandler ) ) ; Handler handler = firstHandler ; while ( handler != null ) { output . putShort ( handler . startPc . bytecodeOffset ) . putShort ( handler . endPc . bytecodeOffset ) . putShort ( handler . handlerPc . bytecodeOffset ) . putShort ( handler . catchType ) ; handler = handler . nextHandler ; }


signature:
public class MadvocConfigurations { /** * Collects all interceptors . */
protected void collectActionInterceptors ( ) { } }

implementation: final Collection < ? extends ActionInterceptor > interceptorValues = interceptorsManager . getAllInterceptors ( ) ; interceptors = new ArrayList < > ( ) ; interceptors . addAll ( interceptorValues ) ; interceptors . sort ( Comparator . comparing ( a -> a . getClass ( ) . getSimpleName ( ) ) ) ;


signature:
public class MadvocConfigurations { /** * Collects all filters . */
protected void collectActionFilters ( ) { } }

implementation: final Collection < ? extends ActionFilter > filterValues = filtersManager . getAllFilters ( ) ; filters = new ArrayList < > ( ) ; filters . addAll ( filterValues ) ; filters . sort ( Comparator . comparing ( a -> a . getClass ( ) . getSimpleName ( ) ) ) ;


signature:
public class MadvocConfigurations { /** * Collects all action results . */
protected void collectActionResults ( ) { } }

implementation: final Collection < ActionResult > resultsValues = resultsManager . getAllActionResults ( ) ; results = new ArrayList < > ( ) ; results . addAll ( resultsValues ) ; results . sort ( Comparator . comparing ( a -> a . getClass ( ) . getSimpleName ( ) ) ) ;


signature:
public class MadvocConfigurations { /** * Collects all action runtime configurations . */
protected void collectActionRuntimes ( ) { } }

implementation: actions = actionsManager . getAllActionRuntimes ( ) ; actions . sort ( Comparator . comparing ( ActionRuntime :: getActionPath ) ) ;


signature:
public class BeanUtilBean { /** * Resolves nested property name to the very last indexed property .
 * If forced , < code > null < / code > or non - existing properties will be created . */
protected void resolveNestedProperties ( final BeanProperty bp ) { } }

implementation: String name = bp . name ; int dotNdx ; while ( ( dotNdx = indexOfDot ( name ) ) != - 1 ) { bp . last = false ; bp . setName ( name . substring ( 0 , dotNdx ) ) ; bp . updateBean ( getIndexProperty ( bp ) ) ; name = name . substring ( dotNdx + 1 ) ; } bp . last = true ; bp . setName ( name ) ;


signature:
public class BeanUtilBean { /** * - - - - - simple property */
@ Override public boolean hasSimpleProperty ( final Object bean , final String property ) { } }

implementation: return hasSimpleProperty ( new BeanProperty ( this , bean , property ) ) ;


signature:
public class BeanUtilBean { /** * Sets a value of simple property . */
@ SuppressWarnings ( { } }

implementation:
"unchecked" } ) protected void setSimpleProperty ( final BeanProperty bp , final Object value ) { Setter setter = bp . getSetter ( isDeclared ) ; // try : setter
if ( setter != null ) { invokeSetter ( setter , bp , value ) ; return ; } // try : put ( " property " , value )
if ( bp . isMap ( ) ) { ( ( Map ) bp . bean ) . put ( bp . name , value ) ; return ; } if ( isSilent ) { return ; } throw new BeanException ( "Simple property not found: " + bp . name , bp ) ;


signature:
public class BeanUtilBean { /** * - - - - - indexed property */
protected boolean hasIndexProperty ( final BeanProperty bp ) { } }

implementation:
if ( bp . bean == null ) { return false ; } String indexString = extractIndex ( bp ) ; if ( indexString == null ) { return hasSimpleProperty ( bp ) ; } Object resultBean = getSimpleProperty ( bp ) ; if ( resultBean == null ) { return false ; } // try : property [ index ]
if ( resultBean . getClass ( ) . isArray ( ) ) { int index = parseInt ( indexString , bp ) ; return ( index >= 0 ) && ( index < Array . getLength ( resultBean ) ) ; } // try : list . get ( index )
if ( resultBean instanceof List ) { int index = parseInt ( indexString , bp ) ; return ( index >= 0 ) && ( index < ( ( List ) resultBean ) . size ( ) ) ; } if ( resultBean instanceof Map ) { return ( ( Map ) resultBean ) . containsKey ( indexString ) ; } // failed
return false ;


signature:
public class BeanUtilBean { /** * Get non - nested property value : either simple or indexed property .
 * If forced , missing bean will be created if possible . */
protected Object getIndexProperty ( final BeanProperty bp ) { } }

implementation: bp . indexString = extractIndex ( bp ) ; Object value = _getIndexProperty ( bp ) ; bp . indexString = null ; return value ;


signature:
public class BeanUtilBean { /** * Sets indexed or regular properties ( no nested ! ) . */
protected void setIndexProperty ( final BeanProperty bp , final Object value ) { } }

implementation: bp . indexString = extractIndex ( bp ) ; _setIndexProperty ( bp , value ) ; bp . indexString = null ;


signature:
public class BeanUtilBean { /** * - - - - - SET */
@ Override public void setProperty ( final Object bean , final String name , final Object value ) { } }

implementation: BeanProperty beanProperty = new BeanProperty ( this , bean , name ) ; if ( ! isSilent ) { resolveNestedProperties ( beanProperty ) ; setIndexProperty ( beanProperty , value ) ; } else { try { resolveNestedProperties ( beanProperty ) ; setIndexProperty ( beanProperty , value ) ; } catch ( Exception ignore ) { } }


signature:
public class BeanUtilBean { /** * Returns value of bean ' s property . */
@ Override public < T > T getProperty ( final Object bean , final String name ) { } }

implementation: BeanProperty beanProperty = new BeanProperty ( this , bean , name ) ; if ( ! isSilent ) { resolveNestedProperties ( beanProperty ) ; return ( T ) getIndexProperty ( beanProperty ) ; } else { try { resolveNestedProperties ( beanProperty ) ; return ( T ) getIndexProperty ( beanProperty ) ; } catch ( Exception ignore ) { return null ; } }


signature:
public class BeanUtilBean { /** * - - - - - HAS */
@ Override public boolean hasProperty ( final Object bean , final String name ) { } }

implementation: BeanProperty beanProperty = new BeanProperty ( this , bean , name ) ; if ( ! resolveExistingNestedProperties ( beanProperty ) ) { return false ; } return hasIndexProperty ( beanProperty ) ;


signature:
public class BeanUtilBean { /** * - - - - - type */
@ Override public Class < ? > getPropertyType ( final Object bean , final String name ) { } }

implementation: BeanProperty beanProperty = new BeanProperty ( this , bean , name ) ; if ( ! resolveExistingNestedProperties ( beanProperty ) ) { return null ; } hasIndexProperty ( beanProperty ) ; return extractType ( beanProperty ) ;


signature:
public class BeanUtilBean { /** * Extract the first name of this reference . */
@ Override public String extractThisReference ( final String propertyName ) { } }

implementation: int ndx = StringUtil . indexOfChars ( propertyName , INDEX_CHARS ) ; if ( ndx == - 1 ) { return propertyName ; } return propertyName . substring ( 0 , ndx ) ;


signature:
public class CharArrayResponseWrapper { /** * Returns buffered writer . Buffer will be created if not already used . */
@ Override public PrintWriter getWriter ( ) { } }

implementation: if ( writer == null ) { writer = new FastCharArrayWriter ( ) ; printWriter = new PrintWriter ( writer ) ; } return printWriter ;


signature:
public class TemplateData { /** * Resets the builder so it can be used again . Not everything is reset :
 * object references and column alias type is not . */
protected void resetSoft ( ) { } }

implementation:
columnCount = 0 ; paramCount = 0 ; hintCount = 0 ; if ( tableRefs != null ) { tableRefs . clear ( ) ; } // objectRefs = null ;
if ( columnData != null ) { columnData . clear ( ) ; } if ( parameters != null ) { parameters . clear ( ) ; } if ( hints != null ) { hints . clear ( ) ; } // columnAliasType = defaultColumnAliasType ;


signature:
public class TemplateData { /** * Saves object reference . */
public void setObjectReference ( final String name , final Object object ) { } }

implementation: if ( objectRefs == null ) { objectRefs = new HashMap < > ( ) ; } objectRefs . put ( name , object ) ;


signature:
public class TemplateData { /** * Returns object reference . */
public Object getObjectReference ( final String name ) { } }

implementation: if ( objectRefs == null ) { return null ; } return objectRefs . get ( name ) ;


signature:
public class TemplateData { /** * Lookups for object reference and throws an exception if reference doesn ' t exist . */
public Object lookupObject ( final String ref ) { } }

implementation: Object value = getObjectReference ( ref ) ; if ( value == null ) { throw new DbSqlBuilderException ( "Invalid object reference: " + ref ) ; } return value ;


signature:
public class TemplateData { /** * Returns entity descriptor for provided table reference . */
public DbEntityDescriptor getTableDescriptor ( final String tableRef ) { } }

implementation: if ( tableRefs == null ) { return null ; } TableRefData t = tableRefs . get ( tableRef ) ; return t == null ? null : t . desc ;


signature:
public class TemplateData { /** * Finds entity descriptor of a table that contains provided column reference . */
public DbEntityDescriptor findTableDescriptorByColumnRef ( final String columnRef ) { } }

implementation: for ( Map . Entry < String , TableRefData > entry : tableRefs . entrySet ( ) ) { DbEntityDescriptor ded = entry . getValue ( ) . desc ; if ( ded . findByPropertyName ( columnRef ) != null ) { return ded ; } } return null ;


signature:
public class TemplateData { /** * Returns table alias for provided table reference . */
public String getTableAlias ( final String tableRef ) { } }

implementation: if ( tableRefs == null ) { return null ; } TableRefData t = tableRefs . get ( tableRef ) ; return t == null ? null : t . alias ;


signature:
public class TemplateData { /** * Registers table reference for provided entity . */
public void registerTableReference ( final String tableReference , final DbEntityDescriptor ded , final String tableAlias ) { } }

implementation: if ( tableRefs == null ) { tableRefs = new HashMap < > ( ) ; } TableRefData t = new TableRefData ( ded , tableAlias ) ; if ( tableRefs . put ( tableReference , t ) != null ) { throw new DbSqlBuilderException ( "Duplicated table reference: " + tableReference ) ; }


signature:
public class TemplateData { /** * Adds query parameter . */
public void addParameter ( final String name , final Object value , final DbEntityColumnDescriptor dec ) { } }

implementation: if ( parameters == null ) { parameters = new HashMap < > ( ) ; } parameters . put ( name , new ParameterValue ( value , dec ) ) ;


signature:
public class TemplateData { /** * Lookups for entity name and throws exception if entity name not found . */
protected DbEntityDescriptor lookupName ( final String entityName ) { } }

implementation: DbEntityDescriptor ded = entityManager . lookupName ( entityName ) ; if ( ded == null ) { throw new DbSqlBuilderException ( "Entity name not registered: " + entityName ) ; } return ded ;


signature:
public class TemplateData { /** * Lookups for table reference and throws an exception if table reference not found . */
protected DbEntityDescriptor lookupTableRef ( final String tableRef ) { } }

implementation: DbEntityDescriptor ded = getTableDescriptor ( tableRef ) ; if ( ded == null ) { throw new DbSqlBuilderException ( "Table reference not used in this query: " + tableRef ) ; } return ded ;


signature:
public class TemplateData { /** * Defines parameter with name and its value . */
protected void defineParameter ( final StringBuilder query , String name , final Object value ) { } }

implementation: if ( name == null ) { name = getNextParameterName ( ) ; } query . append ( ':' ) . append ( name ) ; addParameter ( name , value , null ) ;


signature:
public class TemplateData { /** * Registers a hint . */
public void registerHint ( final String hint ) { } }

implementation: if ( hints == null ) { hints = new ArrayList < > ( hintCount ) ; } hints . add ( hint ) ;


signature:
public class ValueJsonSerializer { /** * Detects circular dependencies and pushes value as current
 * type context . */
@ Override public final boolean serialize ( final JsonContext jsonContext , final T value ) { } }

implementation:
if ( jsonContext . pushValue ( value ) ) { // prevent circular dependencies
return false ; } serializeValue ( jsonContext , value ) ; jsonContext . popValue ( ) ; return true ;


signature:
public class RequestScope { /** * - - - - - inject */
@ Override public void inject ( final ActionRequest actionRequest , final Targets targets ) { } }

implementation: final HttpServletRequest servletRequest = actionRequest . getHttpServletRequest ( ) ; instancesInjector . inject ( actionRequest , targets ) ; if ( injectAttributes ) { injectAttributes ( servletRequest , targets ) ; } if ( injectParameters ) { injectParameters ( servletRequest , targets ) ; injectUploadedFiles ( servletRequest , targets ) ; } actionPathMacroInjector . inject ( actionRequest , targets ) ;


signature:
public class RequestScope { /** * Injects request attributes . */
protected void injectAttributes ( final HttpServletRequest servletRequest , final Targets targets ) { } }

implementation: final Enumeration < String > attributeNames = servletRequest . getAttributeNames ( ) ; while ( attributeNames . hasMoreElements ( ) ) { final String attrName = attributeNames . nextElement ( ) ; targets . forEachTargetAndIn ( this , ( target , in ) -> { final String name = in . matchedName ( attrName ) ; if ( name != null ) { final Object attrValue = servletRequest . getAttribute ( attrName ) ; target . writeValue ( name , attrValue , true ) ; } } ) ; }


signature:
public class RequestScope { /** * Inject request parameters . */
protected void injectParameters ( final HttpServletRequest servletRequest , final Targets targets ) { } }

implementation: final boolean encode = encodeGetParams && servletRequest . getMethod ( ) . equals ( "GET" ) ; final Enumeration < String > paramNames = servletRequest . getParameterNames ( ) ; while ( paramNames . hasMoreElements ( ) ) { final String paramName = paramNames . nextElement ( ) ; if ( servletRequest . getAttribute ( paramName ) != null ) { continue ; } targets . forEachTargetAndIn ( this , ( target , in ) -> { final String name = in . matchedName ( paramName ) ; if ( name != null ) { String [ ] paramValues = servletRequest . getParameterValues ( paramName ) ; paramValues = ServletUtil . prepareParameters ( paramValues , treatEmptyParamsAsNull , ignoreEmptyRequestParams ) ; if ( paramValues != null ) { if ( encode ) { for ( int j = 0 ; j < paramValues . length ; j ++ ) { final String p = paramValues [ j ] ; if ( p != null ) { final String encoding = madvocEncoding . getEncoding ( ) ; paramValues [ j ] = StringUtil . convertCharset ( p , StringPool . ISO_8859_1 , encoding ) ; } } } final Object value = ( paramValues . length != 1 ? paramValues : paramValues [ 0 ] ) ; target . writeValue ( name , value , true ) ; } } } ) ; }


signature:
public class RequestScope { /** * Inject uploaded files from multipart request parameters . */
protected void injectUploadedFiles ( final HttpServletRequest servletRequest , final Targets targets ) { } }

implementation: if ( ! ( servletRequest instanceof MultipartRequestWrapper ) ) { return ; } final MultipartRequestWrapper multipartRequest = ( MultipartRequestWrapper ) servletRequest ; if ( ! multipartRequest . isMultipart ( ) ) { return ; } final Enumeration < String > paramNames = multipartRequest . getFileParameterNames ( ) ; while ( paramNames . hasMoreElements ( ) ) { final String paramName = paramNames . nextElement ( ) ; if ( servletRequest . getAttribute ( paramName ) != null ) { continue ; } targets . forEachTargetAndIn ( this , ( target , in ) -> { final String name = in . matchedName ( paramName ) ; if ( name != null ) { final FileUpload [ ] paramValues = multipartRequest . getFiles ( paramName ) ; if ( ignoreInvalidUploadFiles ) { for ( int j = 0 ; j < paramValues . length ; j ++ ) { final FileUpload paramValue = paramValues [ j ] ; if ( ( ! paramValue . isValid ( ) ) || ( ! paramValue . isUploaded ( ) ) ) { paramValues [ j ] = null ; } } } final Object value = ( paramValues . length == 1 ? paramValues [ 0 ] : paramValues ) ; target . writeValue ( name , value , true ) ; } } ) ; }


signature:
public class RequestScope { /** * - - - - - outject */
@ Override public void outject ( final ActionRequest actionRequest , final Targets targets ) { } }

implementation: final HttpServletRequest servletRequest = actionRequest . getHttpServletRequest ( ) ; targets . forEachTargetAndOut ( this , ( target , out ) -> { final Object value = target . readValue ( out ) ; servletRequest . setAttribute ( out . name ( ) , value ) ; } ) ;


signature:
public class ColumnNamingStrategy { /** * Converts property name to column name . */
public String convertPropertyNameToColumnName ( final String propertyName ) { } }

implementation: StringBuilder tableName = new StringBuilder ( propertyName . length ( ) * 2 ) ; if ( splitCamelCase ) { String convertedTableName = Format . fromCamelCase ( propertyName , separatorChar ) ; tableName . append ( convertedTableName ) ; } else { tableName . append ( propertyName ) ; } if ( ! changeCase ) { return tableName . toString ( ) ; } return uppercase ? toUppercase ( tableName ) . toString ( ) : toLowercase ( tableName ) . toString ( ) ;


signature:
public class ColumnNamingStrategy { /** * Converts column name to property name . */
public String convertColumnNameToPropertyName ( final String columnName ) { } }

implementation: StringBuilder propertyName = new StringBuilder ( columnName . length ( ) ) ; int len = columnName . length ( ) ; if ( splitCamelCase ) { boolean toUpper = false ; for ( int i = 0 ; i < len ; i ++ ) { char c = columnName . charAt ( i ) ; if ( c == separatorChar ) { toUpper = true ; continue ; } if ( toUpper ) { propertyName . append ( Character . toUpperCase ( c ) ) ; toUpper = false ; } else { propertyName . append ( Character . toLowerCase ( c ) ) ; } } return propertyName . toString ( ) ; } return columnName ;


signature:
public class ColumnNamingStrategy { /** * Applies column naming strategy to given column name hint .
 * Returns full column name . */
public String applyToColumnName ( final String columnName ) { } }

implementation: String propertyName = convertColumnNameToPropertyName ( columnName ) ; return convertPropertyNameToColumnName ( propertyName ) ;


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

implementation:
if ( value instanceof Collection ) { final Collection collection = ( Collection ) value ; final boolean [ ] target = new boolean [ 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 < Boolean > booleanArrayList = new ArrayList < > ( ) ; for ( final Object element : iterable ) { final boolean convertedValue = convertType ( element ) ; booleanArrayList . add ( Boolean . valueOf ( convertedValue ) ) ; } final boolean [ ] array = new boolean [ booleanArrayList . size ( ) ] ; for ( int i = 0 ; i < booleanArrayList . size ( ) ; i ++ ) { final Boolean b = booleanArrayList . get ( i ) ; array [ i ] = b . booleanValue ( ) ; } 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 SqlType { /** * Stores value in database . Value is casted to sql type . */
public void storeValue ( final PreparedStatement st , final int index , final Object value , final int dbSqlType ) throws SQLException { } }

implementation: T t = TypeConverterManager . get ( ) . convertType ( value , sqlType ) ; set ( st , index , t , dbSqlType ) ;


signature:
public class SqlType { /** * Once when value is read from result set , prepare it to match destination type .
 * @ param t get value
 * @ param destinationType destination type */
@ SuppressWarnings ( { } }

implementation: "unchecked" } ) protected < E > E prepareGetValue ( final T t , final Class < E > destinationType ) { if ( t == null ) { return null ; } if ( destinationType == null ) { return ( E ) t ; } return TypeConverterManager . get ( ) . convertType ( t , destinationType ) ;


signature:
public class WrapperManager { /** * Returns all action wrappers . Returns a copy in new set . */
protected Set < T > getAll ( ) { } }

implementation: final Set < T > set = new HashSet < > ( wrappers . size ( ) ) ; set . addAll ( wrappers . values ( ) ) ; return set ;


signature:
public class WrapperManager { /** * Resolves single wrapper . Creates new wrapper instance if not already registered .
 * Does not expand the wrappers . */
public T resolve ( final Class < ? extends T > wrapperClass ) { } }

implementation: String wrapperClassName = wrapperClass . getName ( ) ; T wrapper = lookup ( wrapperClassName ) ; if ( wrapper == null ) { wrapper = createWrapper ( wrapperClass ) ; initializeWrapper ( wrapper ) ; wrappers . put ( wrapperClassName , wrapper ) ; } return wrapper ;


signature:
public class WrapperManager { /** * Resolves wrappers . Unregistered wrappers will be registered . Returned array may be
 * different size than size of provided array , due to { @ link # expand ( Class [ ] ) expanding } . */
public T [ ] resolveAll ( Class < ? extends T > [ ] wrapperClasses ) { } }

implementation: if ( wrapperClasses == null ) { return null ; } wrapperClasses = expand ( wrapperClasses ) ; T [ ] result = createArray ( wrapperClasses . length ) ; for ( int i = 0 ; i < wrapperClasses . length ; i ++ ) { result [ i ] = resolve ( wrapperClasses [ i ] ) ; } return result ;


signature:
public class WrapperManager { /** * Replaces all { @ link BaseActionWrapperStack } with stack values . */
protected Class < ? extends T > [ ] expand ( final Class < ? extends T > [ ] actionWrappers ) { } }

implementation:
if ( actionWrappers == null ) { return null ; } List < Class < ? extends T > > list = new ArrayList < > ( actionWrappers . length ) ; list . addAll ( Arrays . asList ( actionWrappers ) ) ; int i = 0 ; while ( i < list . size ( ) ) { Class < ? extends T > wrapperClass = list . get ( i ) ; if ( wrapperClass == null ) { continue ; } if ( ClassUtil . isTypeOf ( wrapperClass , BaseActionWrapperStack . class ) ) { BaseActionWrapperStack stack = ( BaseActionWrapperStack ) resolve ( wrapperClass ) ; list . remove ( i ) ; Class < ? extends T > [ ] stackWrappers = stack . getWrappers ( ) ; if ( stackWrappers != null ) { list . addAll ( i , Arrays . asList ( stackWrappers ) ) ; } i -- ; // continue ;
} i ++ ; } return list . toArray ( new Class [ 0 ] ) ;


signature:
public class WrapperManager { /** * Creates new wrapper . */
protected < R extends T > R createWrapper ( final Class < R > wrapperClass ) { } }

implementation: try { return ClassUtil . newInstance ( wrapperClass ) ; } catch ( Exception ex ) { throw new MadvocException ( "Invalid Madvoc wrapper: " + wrapperClass , ex ) ; }


signature:
public class FileNameUtil { /** * Concatenates a filename to a base path using normal command line style rules .
 * The effect is equivalent to resultant directory after changing
 * directory to the first argument , followed by changing directory to
 * the second argument .
 * The first argument is the base path , the second is the path to concatenate .
 * The returned path is always normalized via { @ link # normalize ( String ) } ,
 * thus < code > . . < / code > is handled .
 * If < code > pathToAdd < / code > is absolute ( has an absolute prefix ) , then
 * it will be normalized and returned .
 * Otherwise , the paths will be joined , normalized and returned .
 * The output will be the same on both Unix and Windows except
 * for the separator character .
 * < pre > { @ code
 * / foo / + bar - - > / foo / bar
 * / foo + bar - - > / foo / bar
 * / foo + / bar - - > / bar
 * / foo + C : / bar - - > C : / bar
 * / foo + C : bar - - > C : bar ( * )
 * / foo / a / + . . / bar - - > foo / bar
 * / foo / + . . / . . / bar - - > null
 * / foo / + / bar - - > / bar
 * / foo / . . + / bar - - > / bar
 * / foo + bar / c . txt - - > / foo / bar / c . txt
 * / foo / c . txt + bar - - > / foo / c . txt / bar ( ! )
 * } < / pre >
 * ( * ) Note that the Windows relative drive prefix is unreliable when
 * used with this method .
 * ( ! ) Note that the first parameter must be a path . If it ends with a name , then
 * the name will be built into the concatenated path . If this might be a problem ,
 * use { @ link # getFullPath ( String ) } on the base path argument .
 * @ param basePath the base path to attach to , always treated as a path
 * @ param fullFilenameToAdd the filename ( or path ) to attach to the base
 * @ return the concatenated path , or null if invalid */
public static String concat ( final String basePath , final String fullFilenameToAdd ) { } }

implementation: return doConcat ( basePath , fullFilenameToAdd , SYSTEM_SEPARATOR ) ;


signature:
public class FileNameUtil { /** * Converts all separators to the system separator .
 * @ param path the path to be changed , null ignored
 * @ return the updated path */
public static String separatorsToSystem ( final String path ) { } }

implementation: if ( path == null ) { return null ; } if ( SYSTEM_SEPARATOR == WINDOWS_SEPARATOR ) { return separatorsToWindows ( path ) ; } else { return separatorsToUnix ( path ) ; }


signature:
public class FileNameUtil { /** * Returns the index of the last directory separator character .
 * This method will handle a file in either Unix or Windows format .
 * The position of the last forward or backslash is returned .
 * The output will be the same irrespective of the machine that the code is running on .
 * @ param filename the filename to find the last path separator in , null returns - 1
 * @ return the index of the last separator character , or - 1 if there is no such character */
public static int indexOfLastSeparator ( final String filename ) { } }

implementation: if ( filename == null ) { return - 1 ; } int lastUnixPos = filename . lastIndexOf ( UNIX_SEPARATOR ) ; int lastWindowsPos = filename . lastIndexOf ( WINDOWS_SEPARATOR ) ; return Math . max ( lastUnixPos , lastWindowsPos ) ;


signature:
public class FileNameUtil { /** * Does the work of getting the path .
 * @ param filename the filename
 * @ param separatorAdd 0 to omit the end separator , 1 to return it
 * @ return the path */
private static String doGetPath ( final String filename , final int separatorAdd ) { } }

implementation: if ( filename == null ) { return null ; } int prefix = getPrefixLength ( filename ) ; if ( prefix < 0 ) { return null ; } int index = indexOfLastSeparator ( filename ) ; int endIndex = index + separatorAdd ; if ( prefix >= filename . length ( ) || index < 0 || prefix >= endIndex ) { return StringPool . EMPTY ; } return filename . substring ( prefix , endIndex ) ;


signature:
public class FileNameUtil { /** * Splits filename into a array of four Strings containing prefix , path , basename and extension .
 * Path will contain ending separator . */
public static String [ ] split ( final String filename ) { } }

implementation: String prefix = getPrefix ( filename ) ; if ( prefix == null ) { prefix = StringPool . EMPTY ; } int lastSeparatorIndex = indexOfLastSeparator ( filename ) ; int lastExtensionIndex = indexOfExtension ( filename ) ; String path ; String baseName ; String extension ; if ( lastSeparatorIndex == - 1 ) { path = StringPool . EMPTY ; if ( lastExtensionIndex == - 1 ) { baseName = filename . substring ( prefix . length ( ) ) ; extension = StringPool . EMPTY ; } else { baseName = filename . substring ( prefix . length ( ) , lastExtensionIndex ) ; extension = filename . substring ( lastExtensionIndex + 1 ) ; } } else { path = filename . substring ( prefix . length ( ) , lastSeparatorIndex + 1 ) ; if ( lastExtensionIndex == - 1 ) { baseName = filename . substring ( prefix . length ( ) + path . length ( ) ) ; extension = StringPool . EMPTY ; } else { baseName = filename . substring ( prefix . length ( ) + path . length ( ) , lastExtensionIndex ) ; extension = filename . substring ( lastExtensionIndex + 1 ) ; } } return new String [ ] { prefix , path , baseName , extension } ;


signature:
public class FileNameUtil { /** * Resolve < code > ~ < / code > in the path . */
public static String resolveHome ( final String path ) { } }

implementation: if ( path . length ( ) == 1 ) { if ( path . charAt ( 0 ) == '~' ) { return SystemUtil . info ( ) . getHomeDir ( ) ; } return path ; } if ( path . length ( ) >= 2 ) { if ( ( path . charAt ( 0 ) == '~' ) && ( path . charAt ( 1 ) == File . separatorChar ) ) { return SystemUtil . info ( ) . getHomeDir ( ) + path . substring ( 1 ) ; } } return path ;


signature:
public class FileNameUtil { /** * Calculates relative path of target path on base path . */
public static String relativePath ( final String targetPath , final String basePath ) { } }

implementation: return new File ( basePath ) . toPath ( ) . relativize ( new File ( targetPath ) . toPath ( ) ) . toString ( ) ;


signature:
public class AnnotationReader { /** * - - - - - visitor */
@ Override public void visit ( final String name , final Object value ) { } }

implementation: elements . put ( name , value ) ;


signature:
public class WebApp { /** * Registers additional Madvoc components after the registration of default components . */
public WebApp registerComponent ( final Class < ? > madvocComponent ) { } }

implementation: Objects . requireNonNull ( madvocComponent ) ; madvocComponents . add ( ClassConsumer . of ( madvocComponent ) ) ; return this ;


signature:
public class WebApp { /** * Registers Madvoc component < i > instance < / i > . Use with caution , as injection of
 * components registered after this will fail . */
public WebApp registerComponent ( final Object madvocComponent ) { } }

implementation: Objects . requireNonNull ( madvocComponent ) ; madvocComponentInstances . add ( madvocComponent ) ; return this ;


signature:
public class WebApp { /** * Configures the action configurations . */
public < A extends ActionConfig > WebApp withActionConfig ( final Class < A > actionConfigType , final Consumer < A > actionConfigConsumer ) { } }

implementation: withRegisteredComponent ( ActionConfigManager . class , acm -> acm . with ( actionConfigType , actionConfigConsumer ) ) ; return this ;


signature:
public class WebApp { /** * Configures a component . While the signature is the same as for { @ link # registerComponent ( Class , Consumer ) }
 * this method does not register component , just operates on an already registered one . */
public < T > WebApp withRegisteredComponent ( final Class < T > madvocComponent , final Consumer < T > componentConsumer ) { } }

implementation:
if ( componentConfigs == null ) { // component is already configured
final T component = madvocContainer . lookupComponent ( madvocComponent ) ; if ( component == null ) { throw new MadvocException ( "Component not found: " + madvocComponent . getName ( ) ) ; } componentConsumer . accept ( component ) ; } else { componentConfigs . add ( madvocContainer -> { final T component = madvocContainer . lookupComponent ( madvocComponent ) ; if ( component == null ) { throw new MadvocException ( "Component not found: " + madvocComponent . getName ( ) ) ; } componentConsumer . accept ( component ) ; } ) ; } return this ;


signature:
public class WebApp { /** * Initializes and starts web application . */
public WebApp start ( ) { } }

implementation:
log = LoggerFactory . getLogger ( WebApp . class ) ; log . debug ( "Initializing Madvoc WebApp" ) ; // / / params & props
for ( final Map < String , Object > params : paramsList ) { madvocContainer . defineParams ( params ) ; } for ( final Props props : propsList ) { madvocContainer . defineParams ( props ) ; } propsList = null ; // / / components
registerMadvocComponents ( ) ; madvocComponents . forEach ( madvocComponent -> madvocContainer . registerComponent ( madvocComponent . type ( ) , madvocComponent . consumer ( ) ) ) ; madvocComponents = null ; madvocComponentInstances . forEach ( madvocContainer :: registerComponentInstance ) ; madvocComponentInstances = null ; configureDefaults ( ) ; // / / listeners
madvocContainer . fireEvent ( Init . class ) ; // / / component configuration
componentConfigs . accept ( madvocContainer ) ; componentConfigs = null ; initialized ( ) ; madvocContainer . fireEvent ( Start . class ) ; if ( ! madvocRouterConsumers . isEmpty ( ) ) { final MadvocRouter madvocRouter = MadvocRouter . create ( ) ; madvocContainer . registerComponentInstance ( madvocRouter ) ; madvocRouterConsumers . accept ( madvocRouter ) ; } madvocRouterConsumers = null ; started ( ) ; madvocContainer . fireEvent ( Ready . class ) ; ready ( ) ; return this ;


signature:
public class WebApp { /** * Configure defaults . */
protected void configureDefaults ( ) { } }

implementation: final ActionConfigManager actionConfigManager = madvocContainer . lookupComponent ( ActionConfigManager . class ) ; actionConfigManager . registerAnnotation ( Action . class ) ; actionConfigManager . registerAnnotation ( RestAction . class ) ;


signature:
public class WebApp { /** * Registers default Madvoc components . */
protected void registerMadvocComponents ( ) { } }

implementation: if ( madvocContainer == null ) { throw new MadvocException ( "Madvoc WebApp not initialized." ) ; } log . debug ( "Registering Madvoc WebApp components" ) ; madvocContainer . registerComponent ( MadvocEncoding . class ) ; madvocContainer . registerComponentInstance ( new ServletContextProvider ( servletContext ) ) ; madvocContainer . registerComponent ( ActionConfigManager . class ) ; madvocContainer . registerComponent ( ActionMethodParamNameResolver . class ) ; madvocContainer . registerComponent ( ActionMethodParser . class ) ; madvocContainer . registerComponent ( ActionPathRewriter . class ) ; madvocContainer . registerComponent ( ActionsManager . class ) ; madvocContainer . registerComponent ( ContextInjectorComponent . class ) ; madvocContainer . registerComponent ( InterceptorsManager . class ) ; madvocContainer . registerComponent ( FiltersManager . class ) ; madvocContainer . registerComponent ( MadvocController . class ) ; madvocContainer . registerComponent ( RootPackages . class ) ; madvocContainer . registerComponent ( ResultsManager . class ) ; madvocContainer . registerComponent ( ResultMapper . class ) ; madvocContainer . registerComponent ( ScopeResolver . class ) ; madvocContainer . registerComponent ( ScopeDataInspector . class ) ; madvocContainer . registerComponent ( AsyncActionExecutor . class ) ; madvocContainer . registerComponent ( FileUploader . class ) ;


signature:
public class ClassScanner { /** * Specify excluded jars . */
public ClassScanner excludeJars ( final String ... excludedJars ) { } }

implementation: for ( final String excludedJar : excludedJars ) { rulesJars . exclude ( excludedJar ) ; } return this ;


signature:
public class ClassScanner { /** * Specify included jars . */
public ClassScanner includeJars ( final String ... includedJars ) { } }

implementation: for ( final String includedJar : includedJars ) { rulesJars . include ( includedJar ) ; } return this ;


signature:
public class ClassScanner { /** * Sets included set of names that will be considered during configuration .
 * @ see InExRules */
public ClassScanner includeEntries ( final String ... includedEntries ) { } }

implementation: for ( final String includedEntry : includedEntries ) { rulesEntries . include ( includedEntry ) ; } return this ;


signature:
public class ClassScanner { /** * Sets excluded names that narrows included set of packages .
 * @ see InExRules */
public ClassScanner excludeEntries ( final String ... excludedEntries ) { } }

implementation: for ( final String excludedEntry : excludedEntries ) { rulesEntries . exclude ( excludedEntry ) ; } return this ;


signature:
public class ClassScanner { /** * Returns < code > true < / code > if some JAR file has to be accepted . */
protected boolean acceptJar ( final File jarFile ) { } }

implementation: String path = jarFile . getAbsolutePath ( ) ; path = FileNameUtil . separatorsToUnix ( path ) ; return rulesJars . match ( path ) ;


signature:
public class ClassScanner { /** * Scans classes inside single JAR archive . Archive is scanned as a zip file .
 * @ see # onEntry ( ClassPathEntry ) */
protected void scanJarFile ( final File file ) { } }

implementation: final ZipFile zipFile ; try { zipFile = new ZipFile ( file ) ; } catch ( IOException ioex ) { if ( ! ignoreException ) { throw new FindFileException ( "Invalid zip: " + file . getName ( ) , ioex ) ; } return ; } final Enumeration entries = zipFile . entries ( ) ; while ( entries . hasMoreElements ( ) ) { final ZipEntry zipEntry = ( ZipEntry ) entries . nextElement ( ) ; final String zipEntryName = zipEntry . getName ( ) ; try { if ( StringUtil . endsWithIgnoreCase ( zipEntryName , CLASS_FILE_EXT ) ) { final String entryName = prepareEntryName ( zipEntryName , true ) ; final ClassPathEntry classPathEntry = new ClassPathEntry ( entryName , zipFile , zipEntry ) ; try { scanEntry ( classPathEntry ) ; } finally { classPathEntry . closeInputStream ( ) ; } } else if ( includeResources ) { final String entryName = prepareEntryName ( zipEntryName , false ) ; final ClassPathEntry classPathEntry = new ClassPathEntry ( entryName , zipFile , zipEntry ) ; try { scanEntry ( classPathEntry ) ; } finally { classPathEntry . closeInputStream ( ) ; } } } catch ( RuntimeException rex ) { if ( ! ignoreException ) { ZipUtil . close ( zipFile ) ; throw rex ; } } } ZipUtil . close ( zipFile ) ;


signature:
public class ClassScanner { /** * Scans single classpath directory .
 * @ see # onEntry ( ClassPathEntry ) */
protected void scanClassPath ( final File root ) { } }

implementation: String rootPath = root . getAbsolutePath ( ) ; if ( ! rootPath . endsWith ( File . separator ) ) { rootPath += File . separatorChar ; } final FindFile ff = FindFile . create ( ) . includeDirs ( false ) . recursive ( true ) . searchPath ( rootPath ) ; File file ; while ( ( file = ff . nextFile ( ) ) != null ) { final String filePath = file . getAbsolutePath ( ) ; try { if ( StringUtil . endsWithIgnoreCase ( filePath , CLASS_FILE_EXT ) ) { scanClassFile ( filePath , rootPath , file , true ) ; } else if ( includeResources ) { scanClassFile ( filePath , rootPath , file , false ) ; } } catch ( RuntimeException rex ) { if ( ! ignoreException ) { throw rex ; } } }


signature:
public class ClassScanner { /** * Prepares resource and class names . For classes , it strips ' . class ' from the end and converts
 * all ( back ) slashes to dots . For resources , it replaces all backslashes to slashes . */
protected String prepareEntryName ( final String name , final boolean isClass ) { } }

implementation:
String entryName = name ; if ( isClass ) { entryName = name . substring ( 0 , name . length ( ) - 6 ) ; // 6 = = " . class " . length ( )
entryName = StringUtil . replaceChar ( entryName , '/' , '.' ) ; entryName = StringUtil . replaceChar ( entryName , '\\' , '.' ) ; } else { entryName = '/' + StringUtil . replaceChar ( entryName , '\\' , '/' ) ; } return entryName ;


signature:
public class ClassScanner { /** * If entry name is { @ link # acceptEntry ( String ) accepted } invokes { @ link # onEntry ( ClassPathEntry ) } a callback } . */
protected void scanEntry ( final ClassPathEntry classPathEntry ) { } }

implementation: if ( ! acceptEntry ( classPathEntry . name ( ) ) ) { return ; } try { onEntry ( classPathEntry ) ; } catch ( Exception ex ) { throw new FindFileException ( "Scan entry error: " + classPathEntry , ex ) ; }


signature:
public class ClassScanner { /** * Returns type signature bytes used for searching in class file . */
public static byte [ ] bytecodeSignatureOfType ( final Class type ) { } }

implementation: final String name = 'L' + type . getName ( ) . replace ( '.' , '/' ) + ';' ; return name . getBytes ( ) ;


signature:
public class ClassScanner { /** * Scans URLs . If ( # ignoreExceptions } is set , exceptions
 * per one URL will be ignored and loops continues . */
public ClassScanner scan ( final URL ... urls ) { } }

implementation: for ( final URL url : urls ) { final File file = FileUtil . toContainerFile ( url ) ; if ( file == null ) { if ( ! ignoreException ) { throw new FindFileException ( "URL is not a valid file: " + url ) ; } } else { filesToScan . add ( file ) ; } } return this ;


signature:
public class ClassScanner { /** * Scans provided paths . */
public ClassScanner scan ( final String ... paths ) { } }

implementation: for ( final String path : paths ) { filesToScan . add ( new File ( path ) ) ; } return this ;


signature:
public class ClassScanner { /** * Starts with the scanner . */
public void start ( ) { } }

implementation: if ( detectEntriesMode ) { rulesEntries . detectMode ( ) ; } filesToScan . forEach ( file -> { final String path = file . getAbsolutePath ( ) ; if ( StringUtil . endsWithIgnoreCase ( path , JAR_FILE_EXT ) ) { if ( ! acceptJar ( file ) ) { return ; } scanJarFile ( file ) ; } else if ( file . isDirectory ( ) ) { scanClassPath ( file ) ; } } ) ;


signature:
public class UnsafeUtil { /** * Returns String characters in most performing way .
 * If possible , the inner < code > char [ ] < / code > will be returned .
 * If not , < code > toCharArray ( ) < / code > will be called .
 * Returns < code > null < / code > when argument is < code > null < / code > . */
public static char [ ] getChars ( final String string ) { } }

implementation: if ( string == null ) { return null ; } if ( ! HAS_UNSAFE || ! JoddCore . unsafeUsageEnabled ) { return string . toCharArray ( ) ; } return UnsafeInternal . unsafeGetChars ( string ) ;


signature:
public class DbJtxTransactionManager { /** * { @ inheritDoc } */
@ Override public DbJtxTransaction requestTransaction ( final JtxTransactionMode mode , final Object scope ) { } }

implementation: return ( DbJtxTransaction ) super . requestTransaction ( mode , scope ) ;


signature:
public class DbJtxTransactionManager { /** * Builds new transaction instance . */
@ Override protected JtxTransaction createNewTransaction ( final JtxTransactionMode tm , final Object scope , final boolean active ) { } }

implementation: return new DbJtxTransaction ( this , tm , scope , active ) ;


signature:
public class ScopeResolver { /** * Lookups the scope instance of given scope annotation .
 * If instance does not exist , it will be created , cached and returned . */
@ SuppressWarnings ( "unchecked" ) public < S extends MadvocScope > S defaultOrScopeType ( final Class < S > scopeClass ) { } }

implementation: if ( scopeClass == null ) { return ( S ) getOrInitScope ( RequestScope . class ) ; } return ( S ) getOrInitScope ( scopeClass ) ;


signature:
public class ScopeResolver { /** * Performs search for the scope class and returns it ' s instance . */
protected MadvocScope getOrInitScope ( final Class < ? extends MadvocScope > madvocScopeType ) { } }

implementation:
for ( final MadvocScope s : allScopes ) { if ( s . getClass ( ) . equals ( madvocScopeType ) ) { return s ; } } // new scope detected
final MadvocScope newScope ; try { newScope = madpc . createBean ( madvocScopeType ) ; } catch ( Exception ex ) { throw new MadvocException ( "Unable to create scope: " + madvocScopeType , ex ) ; } allScopes . add ( newScope ) ; return newScope ;


signature:
public class ScopeResolver { /** * Finds a given scope and consumes it . */
public void forScope ( final Class < ? extends MadvocScope > scopeType , final Consumer < MadvocScope > madvocScopeConsumer ) { } }

implementation: final MadvocScope scope = getOrInitScope ( scopeType ) ; madvocScopeConsumer . accept ( scope ) ;


signature:
public class ReceivedEmail { /** * Parses { @ link Message } and extracts all data for the received message .
 * @ param msg { @ link Message } to parse .
 * @ throws IOException if there is an error with the content
 * @ throws MessagingException if there is an error . */
protected void parseMessage ( final Message msg , final boolean envelope ) throws MessagingException , IOException { } }

implementation:
// flags
flags ( msg . getFlags ( ) ) ; // message number
messageNumber ( msg . getMessageNumber ( ) ) ; if ( msg instanceof MimeMessage ) { messageId ( ( ( MimeMessage ) msg ) . getMessageID ( ) ) ; } // single from
final Address [ ] addresses = msg . getFrom ( ) ; if ( addresses != null && addresses . length > 0 ) { from ( addresses [ 0 ] ) ; } // reply - to
replyTo ( msg . getReplyTo ( ) ) ; // recipients
to ( msg . getRecipients ( Message . RecipientType . TO ) ) ; cc ( msg . getRecipients ( Message . RecipientType . CC ) ) ; // no BCC because this will always be empty
// subject
subject ( msg . getSubject ( ) ) ; // dates
receivedDate ( msg . getReceivedDate ( ) ) ; sentDate ( msg . getSentDate ( ) ) ; // headers
headers ( msg . getAllHeaders ( ) ) ; // content
if ( ! envelope ) { processPart ( msg ) ; }


signature:
public class ReceivedEmail { /** * Process part of the received message . All parts are simply added to the { @ link ReceivedEmail } ,
 * i . e . hierarchy is not saved .
 * @ param part { @ link Part } of received message
 * @ throws IOException if there is an error with the content .
 * @ throws MessagingException if there is an error . */
protected void processPart ( final Part part ) throws MessagingException , IOException { } }

implementation: final Object content = part . getContent ( ) ; if ( content instanceof String ) { addStringContent ( part , ( String ) content ) ; } else if ( content instanceof Multipart ) { processMultipart ( ( Multipart ) content ) ; } else if ( content instanceof InputStream ) { addAttachment ( part , ( InputStream ) content , attachmentStorage ) ; } else if ( content instanceof MimeMessage ) { final MimeMessage mimeMessage = ( MimeMessage ) content ; attachedMessage ( new ReceivedEmail ( mimeMessage , false , attachmentStorage ) ) ; } else { addAttachment ( part , part . getInputStream ( ) , attachmentStorage ) ; }


signature:
public class ReceivedEmail { /** * Process the { @ link Multipart } .
 * @ param mp { @ link Multipart }
 * @ throws MessagingException if there is a failure .
 * @ throws IOException if there is an issue with the { @ link Multipart } . */
private void processMultipart ( final Multipart mp ) throws MessagingException , IOException { } }

implementation: final int count = mp . getCount ( ) ; for ( int i = 0 ; i < count ; i ++ ) { final Part innerPart = mp . getBodyPart ( i ) ; processPart ( innerPart ) ; }


signature:
public class ReceivedEmail { /** * Adds String content as either { @ link EmailAttachment } or as { @ link EmailMessage } .
 * @ param part { @ link Part }
 * @ param content Content as { @ link String }
 * @ throws MessagingException if there is a failure .
 * @ throws UnsupportedEncodingException if the named charset is not supported .
 * @ see # message ( String , String , String ) */
private void addStringContent ( final Part part , final String content ) throws MessagingException , UnsupportedEncodingException { } }

implementation: final String contentType = part . getContentType ( ) ; final String encoding = EmailUtil . extractEncoding ( contentType , StringPool . US_ASCII ) ; final String disposition = part . getDisposition ( ) ; if ( disposition != null && disposition . equalsIgnoreCase ( Part . ATTACHMENT ) ) { addAttachment ( part , content . getBytes ( encoding ) ) ; } else { final String mimeType = EmailUtil . extractMimeType ( contentType ) ; message ( content , mimeType , encoding ) ; }


signature:
public class ReceivedEmail { /** * Returns the Content - ID of this { @ link Part } . Returns { @ code null } if none present .
 * @ param part { @ link Part } the Part to parse .
 * @ return String containing content ID .
 * @ throws MessagingException if there is a failure .
 * @ see MimePart # getContentID ( ) */
protected static String parseContentId ( final Part part ) throws MessagingException { } }

implementation: if ( part instanceof MimePart ) { final MimePart mp = ( MimePart ) part ; return mp . getContentID ( ) ; } else { return null ; }


signature:
public class ReceivedEmail { /** * Returns { @ code true } if the { @ link Part } is inline .
 * @ param part { @ link Part } to parse .
 * @ return { @ code true } if the { @ link Part } is inline .
 * @ throws MessagingException if there is a failure . */
protected static boolean parseInline ( final Part part ) throws MessagingException { } }

implementation: if ( part instanceof MimePart ) { final String dispositionId = part . getDisposition ( ) ; return dispositionId != null && dispositionId . equalsIgnoreCase ( "inline" ) ; } return false ;


signature:
public class ReceivedEmail { /** * Adds received attachment .
 * @ param part { @ link Part } .
 * @ param content Content as { @ link InputStream } .
 * @ return this
 * @ see # attachment ( EmailAttachment ) */
private ReceivedEmail addAttachment ( final Part part , final InputStream content , final File attachmentStorage ) throws MessagingException , IOException { } }

implementation: final EmailAttachmentBuilder builder = addAttachmentInfo ( part ) ; builder . content ( content , part . getContentType ( ) ) ; if ( attachmentStorage != null ) { String name = messageId + "-" + ( this . attachments ( ) . size ( ) + 1 ) ; return storeAttachment ( builder . buildFileDataSource ( name , attachmentStorage ) ) ; } return storeAttachment ( builder . buildByteArrayDataSource ( ) ) ;


signature:
public class ReceivedEmail { /** * Adds received attachment .
 * @ param part { @ link Part } .
 * @ param content Content as byte array .
 * @ return this
 * @ see # attachment ( EmailAttachment ) */
private ReceivedEmail addAttachment ( final Part part , final byte [ ] content ) throws MessagingException { } }

implementation: final EmailAttachmentBuilder builder = addAttachmentInfo ( part ) ; builder . content ( content , part . getContentType ( ) ) ; final EmailAttachment < ByteArrayDataSource > attachment = builder . buildByteArrayDataSource ( ) ; attachment . setSize ( content . length ) ; return storeAttachment ( attachment ) ;


signature:
public class ReceivedEmail { /** * Creates { @ link EmailAttachmentBuilder } from { @ link Part } and sets Content ID , inline and name .
 * @ param part { @ link Part } .
 * @ return this
 * @ see # attachment ( EmailAttachment ) */
private static EmailAttachmentBuilder addAttachmentInfo ( final Part part ) throws MessagingException { } }

implementation: final String fileName = EmailUtil . resolveFileName ( part ) ; final String contentId = parseContentId ( part ) ; final boolean isInline = parseInline ( part ) ; return new EmailAttachmentBuilder ( ) . name ( fileName ) . contentId ( contentId ) . inline ( isInline ) ;