Input: Reads a JVMS verification_type_info structure and stores it at the given index in the given array . [CODESPLIT] private int readVerificationTypeInfo ( final int verificationTypeInfoOffset , final Object [ ] frame , final int index , final char [ ] charBuffer , final Label [ ] labels ) { int currentOffset = verificationTypeInfoOffset ; int tag = b [ currentOffset ++ ] & 0xFF ; switch ( tag ) { case Frame . ITEM_TOP : frame [ index ] = Opcodes . TOP ; break ; case Frame . ITEM_INTEGER : frame [ index ] = Opcodes . INTEGER ; break ; case Frame . ITEM_FLOAT : frame [ index ] = Opcodes . FLOAT ; break ; case Frame . ITEM_DOUBLE : frame [ index ] = Opcodes . DOUBLE ; break ; case Frame . ITEM_LONG : frame [ index ] = Opcodes . LONG ; break ; case Frame . ITEM_NULL : frame [ index ] = Opcodes . NULL ; break ; case Frame . ITEM_UNINITIALIZED_THIS : frame [ index ] = Opcodes . UNINITIALIZED_THIS ; break ; case Frame . ITEM_OBJECT : frame [ index ] = readClass ( currentOffset , charBuffer ) ; currentOffset += 2 ; break ; case Frame . ITEM_UNINITIALIZED : frame [ index ] = createLabel ( readUnsignedShort ( currentOffset ) , labels ) ; currentOffset += 2 ; break ; default : throw new IllegalArgumentException ( ) ; } return currentOffset ; }


Input: Returns the offset in { @link #b } of the first ClassFile s attributes array field entry . [CODESPLIT] final int getFirstAttributeOffset ( ) { // Skip the access_flags, this_class, super_class, and interfaces_count fields (using 2 bytes // each), as well as the interfaces array field (2 bytes per interface). int currentOffset = header + 8 + readUnsignedShort ( header + 6 ) * 2 ; // Read the fields_count field. int fieldsCount = readUnsignedShort ( currentOffset ) ; currentOffset += 2 ; // Skip the 'fields' array field. while ( fieldsCount -- > 0 ) { // Invariant: currentOffset is the offset of a field_info structure. // Skip the access_flags, name_index and descriptor_index fields (2 bytes each), and read the // attributes_count field. int attributesCount = readUnsignedShort ( currentOffset + 6 ) ; currentOffset += 8 ; // Skip the 'attributes' array field. while ( attributesCount -- > 0 ) { // Invariant: currentOffset is the offset of an attribute_info structure. // Read the attribute_length field (2 bytes after the start of the attribute_info) and skip // this many bytes, plus 6 for the attribute_name_index and attribute_length fields // (yielding the total size of the attribute_info structure). currentOffset += 6 + readInt ( currentOffset + 2 ) ; } } // Skip the methods_count and 'methods' fields, using the same method as above. int methodsCount = readUnsignedShort ( currentOffset ) ; currentOffset += 2 ; while ( methodsCount -- > 0 ) { int attributesCount = readUnsignedShort ( currentOffset + 6 ) ; currentOffset += 8 ; while ( attributesCount -- > 0 ) { currentOffset += 6 + readInt ( currentOffset + 2 ) ; } } // Skip the ClassFile's attributes_count field. return currentOffset + 2 ; }


Input: Reads the BootstrapMethods attribute to compute the offset of each bootstrap method . [CODESPLIT] private int [ ] readBootstrapMethodsAttribute ( final int maxStringLength ) { char [ ] charBuffer = new char [ maxStringLength ] ; int currentAttributeOffset = getFirstAttributeOffset ( ) ; int [ ] currentBootstrapMethodOffsets = null ; for ( int i = readUnsignedShort ( currentAttributeOffset - 2 ) ; i > 0 ; -- i ) { // Read the attribute_info's attribute_name and attribute_length fields. String attributeName = readUTF8 ( currentAttributeOffset , charBuffer ) ; int attributeLength = readInt ( currentAttributeOffset + 2 ) ; currentAttributeOffset += 6 ; if ( Constants . BOOTSTRAP_METHODS . equals ( attributeName ) ) { // Read the num_bootstrap_methods field and create an array of this size. currentBootstrapMethodOffsets = new int [ readUnsignedShort ( currentAttributeOffset ) ] ; // Compute and store the offset of each 'bootstrap_methods' array field entry. int currentBootstrapMethodOffset = currentAttributeOffset + 2 ; for ( int j = 0 ; j < currentBootstrapMethodOffsets . length ; ++ j ) { currentBootstrapMethodOffsets [ j ] = currentBootstrapMethodOffset ; // Skip the bootstrap_method_ref and num_bootstrap_arguments fields (2 bytes each), // as well as the bootstrap_arguments array field (of size num_bootstrap_arguments * 2). currentBootstrapMethodOffset += 4 + readUnsignedShort ( currentBootstrapMethodOffset + 2 ) * 2 ; } return currentBootstrapMethodOffsets ; } currentAttributeOffset += attributeLength ; } return null ; }


Input: Reads a non standard JVMS attribute structure in { @link #b } . [CODESPLIT] private Attribute readAttribute ( final Attribute [ ] attributePrototypes , final String type , final int offset , final int length , final char [ ] charBuffer , final int codeAttributeOffset , final Label [ ] labels ) { for ( Attribute attributePrototype : attributePrototypes ) { if ( attributePrototype . type . equals ( type ) ) { return attributePrototype . read ( this , offset , length , charBuffer , codeAttributeOffset , labels ) ; } } return new Attribute ( type ) . read ( this , offset , length , null , - 1 , null ) ; }


Input: Reads a signed int value in { @link #b } . <i > This method is intended for { @link Attribute } sub classes and is normally not needed by class generators or adapters . < / i > [CODESPLIT] public int readInt ( final int offset ) { byte [ ] classFileBuffer = b ; return ( ( classFileBuffer [ offset ] & 0xFF ) << 24 ) | ( ( classFileBuffer [ offset + 1 ] & 0xFF ) << 16 ) | ( ( classFileBuffer [ offset + 2 ] & 0xFF ) << 8 ) | ( classFileBuffer [ offset + 3 ] & 0xFF ) ; }


Input: Reads a signed long value in { @link #b } . <i > This method is intended for { @link Attribute } sub classes and is normally not needed by class generators or adapters . < / i > [CODESPLIT] public long readLong ( final int offset ) { long l1 = readInt ( offset ) ; long l0 = readInt ( offset + 4 ) & 0xFFFFFFFF  L ; return ( l1 << 32 ) | l0 ; }


Input: DontCheck ( AbbreviationAsWordInName ) : can t be renamed ( for backward binary compatibility ) . [CODESPLIT] public String readUTF8 ( final int offset , final char [ ] charBuffer ) { int constantPoolEntryIndex = readUnsignedShort ( offset ) ; if ( offset == 0 || constantPoolEntryIndex == 0 ) { return null ; } return readUtf ( constantPoolEntryIndex , charBuffer ) ; }


Input: Reads a CONSTANT_Utf8 constant pool entry in { @link #b } . [CODESPLIT] final String readUtf ( final int constantPoolEntryIndex , final char [ ] charBuffer ) { String value = constantUtf8Values [ constantPoolEntryIndex ] ; if ( value != null ) { return value ; } int cpInfoOffset = cpInfoOffsets [ constantPoolEntryIndex ] ; return constantUtf8Values [ constantPoolEntryIndex ] = readUtf ( cpInfoOffset + 2 , readUnsignedShort ( cpInfoOffset ) , charBuffer ) ; }


Input: Reads an UTF8 string in { @link #b } . [CODESPLIT] private String readUtf ( final int utfOffset , final int utfLength , final char [ ] charBuffer ) { int currentOffset = utfOffset ; int endOffset = currentOffset + utfLength ; int strLength = 0 ; byte [ ] classFileBuffer = b ; while ( currentOffset < endOffset ) { int currentByte = classFileBuffer [ currentOffset ++ ] ; if ( ( currentByte & 0x80 ) == 0 ) { charBuffer [ strLength ++ ] = ( char ) ( currentByte & 0x7F ) ; } else if ( ( currentByte & 0xE0 ) == 0xC0 ) { charBuffer [ strLength ++ ] = ( char ) ( ( ( currentByte & 0x1F ) << 6 ) + ( classFileBuffer [ currentOffset ++ ] & 0x3F ) ) ; } else { charBuffer [ strLength ++ ] = ( char ) ( ( ( currentByte & 0xF ) << 12 ) + ( ( classFileBuffer [ currentOffset ++ ] & 0x3F ) << 6 ) + ( classFileBuffer [ currentOffset ++ ] & 0x3F ) ) ; } } return new String ( charBuffer , 0 , strLength ) ; }


Input: Reads a CONSTANT_Dynamic constant pool entry in { @link #b } . [CODESPLIT] private ConstantDynamic readConstantDynamic ( final int constantPoolEntryIndex , final char [ ] charBuffer ) { ConstantDynamic constantDynamic = constantDynamicValues [ constantPoolEntryIndex ] ; if ( constantDynamic != null ) { return constantDynamic ; } int cpInfoOffset = cpInfoOffsets [ constantPoolEntryIndex ] ; int nameAndTypeCpInfoOffset = cpInfoOffsets [ readUnsignedShort ( cpInfoOffset + 2 ) ] ; String name = readUTF8 ( nameAndTypeCpInfoOffset , charBuffer ) ; String descriptor = readUTF8 ( nameAndTypeCpInfoOffset + 2 , charBuffer ) ; int bootstrapMethodOffset = bootstrapMethodOffsets [ readUnsignedShort ( cpInfoOffset ) ] ; Handle handle = ( Handle ) readConst ( readUnsignedShort ( bootstrapMethodOffset ) , charBuffer ) ; Object [ ] bootstrapMethodArguments = new Object [ readUnsignedShort ( bootstrapMethodOffset + 2 ) ] ; bootstrapMethodOffset += 4 ; for ( int i = 0 ; i < bootstrapMethodArguments . length ; i ++ ) { bootstrapMethodArguments [ i ] = readConst ( readUnsignedShort ( bootstrapMethodOffset ) , charBuffer ) ; bootstrapMethodOffset += 2 ; } return constantDynamicValues [ constantPoolEntryIndex ] = new ConstantDynamic ( name , descriptor , handle , bootstrapMethodArguments ) ; }


Input: Reads a numeric or string constant pool entry in { @link #b } . <i > This method is intended for { @link Attribute } sub classes and is normally not needed by class generators or adapters . < / i > [CODESPLIT] public Object readConst ( final int constantPoolEntryIndex , final char [ ] charBuffer ) { int cpInfoOffset = cpInfoOffsets [ constantPoolEntryIndex ] ; switch ( b [ cpInfoOffset - 1 ] ) { case Symbol . CONSTANT_INTEGER_TAG : return readInt ( cpInfoOffset ) ; case Symbol . CONSTANT_FLOAT_TAG : return Float . intBitsToFloat ( readInt ( cpInfoOffset ) ) ; case Symbol . CONSTANT_LONG_TAG : return readLong ( cpInfoOffset ) ; case Symbol . CONSTANT_DOUBLE_TAG : return Double . longBitsToDouble ( readLong ( cpInfoOffset ) ) ; case Symbol . CONSTANT_CLASS_TAG : return Type . getObjectType ( readUTF8 ( cpInfoOffset , charBuffer ) ) ; case Symbol . CONSTANT_STRING_TAG : return readUTF8 ( cpInfoOffset , charBuffer ) ; case Symbol . CONSTANT_METHOD_TYPE_TAG : return Type . getMethodType ( readUTF8 ( cpInfoOffset , charBuffer ) ) ; case Symbol . CONSTANT_METHOD_HANDLE_TAG : int referenceKind = readByte ( cpInfoOffset ) ; int referenceCpInfoOffset = cpInfoOffsets [ readUnsignedShort ( cpInfoOffset + 1 ) ] ; int nameAndTypeCpInfoOffset = cpInfoOffsets [ readUnsignedShort ( referenceCpInfoOffset + 2 ) ] ; String owner = readClass ( referenceCpInfoOffset , charBuffer ) ; String name = readUTF8 ( nameAndTypeCpInfoOffset , charBuffer ) ; String descriptor = readUTF8 ( nameAndTypeCpInfoOffset + 2 , charBuffer ) ; boolean isInterface = b [ referenceCpInfoOffset - 1 ] == Symbol . CONSTANT_INTERFACE_METHODREF_TAG ; return new Handle ( referenceKind , owner , name , descriptor , isInterface ) ; case Symbol . CONSTANT_DYNAMIC_TAG : return readConstantDynamic ( constantPoolEntryIndex , charBuffer ) ; default : throw new IllegalArgumentException ( ) ; } }


Input: { [CODESPLIT] @ Override public Clob get ( final ResultSet rs , final int index , final int dbSqlType ) throws SQLException { return rs . getClob ( index ) ; }


Input: { [CODESPLIT] @ Override public void set ( final PreparedStatement st , final int index , final Clob value , final int dbSqlType ) throws SQLException { st . setClob ( index , value ) ; }


Input: Sets content type . If charset is missing current value is reset . If passed value is <code > null< / code > content type will be reset as never set . [CODESPLIT] @ Override public void setContentType ( final String type ) { if ( type == null ) { mimeType = null ; characterEncoding = null ; return ; } ContentTypeHeaderResolver contentTypeResolver = new ContentTypeHeaderResolver ( type ) ; mimeType = contentTypeResolver . getMimeType ( ) ; characterEncoding = contentTypeResolver . getEncoding ( ) ; }


Input: Returns content type and optionally charset . Returns <code > null< / code > when mime type is not set . [CODESPLIT] @ Override public String getContentType ( ) { String contentType = mimeType ; if ( mimeType != null && characterEncoding != null ) { contentType += ";charset=" + characterEncoding ; } return contentType ; }


Input: { [CODESPLIT] @ Override public String get ( final ResultSet rs , final int index , final int dbSqlType ) throws SQLException { return rs . getString ( index ) ; }


Input: { [CODESPLIT] @ Override public void set ( final PreparedStatement st , final int index , final String value , final int dbSqlType ) throws SQLException { st . setString ( index , value ) ; }


Input: Inspects all declared constructors of a target type . [CODESPLIT] protected CtorDescriptor [ ] inspectConstructors ( ) { Class type = classDescriptor . getType ( ) ; Constructor [ ] ctors = type . getDeclaredConstructors ( ) ; CtorDescriptor [ ] allCtors = new CtorDescriptor [ ctors . length ] ; for ( int i = 0 ; i < ctors . length ; i ++ ) { Constructor ctor = ctors [ i ] ; CtorDescriptor ctorDescriptor = createCtorDescriptor ( ctor ) ; allCtors [ i ] = ctorDescriptor ; if ( ctorDescriptor . isDefault ( ) ) { defaultCtor = ctorDescriptor ; } } return allCtors ; }


Input: Finds constructor description that matches given argument types . [CODESPLIT] public CtorDescriptor getCtorDescriptor ( final Class ... args ) { ctors : for ( CtorDescriptor ctorDescriptor : allCtors ) { Class [ ] arg = ctorDescriptor . getParameters ( ) ; if ( arg . length != args . length ) { continue ; } for ( int j = 0 ; j < arg . length ; j ++ ) { if ( arg [ j ] != args [ j ] ) { continue ctors ; } } return ctorDescriptor ; } return null ; }


Input: Returns instance map from http request . [CODESPLIT] @ SuppressWarnings ( "unchecked" ) protected Map < String , TransientBeanData > getRequestMap ( final HttpServletRequest servletRequest ) { return ( Map < String , TransientBeanData > ) servletRequest . getAttribute ( ATTR_NAME ) ; }


Input: Creates instance map and stores it in the request . [CODESPLIT] protected Map < String , TransientBeanData > createRequestMap ( final HttpServletRequest servletRequest ) { Map < String , TransientBeanData > map = new HashMap <> ( ) ; servletRequest . setAttribute ( ATTR_NAME , map ) ; return map ; }


Input: Returns request from current thread . [CODESPLIT] protected HttpServletRequest getCurrentHttpRequest ( ) { HttpServletRequest request = RequestContextListener . getRequest ( ) ; if ( request == null ) { throw new PetiteException ( "No HTTP request bound to the current thread. Is RequestContextListener registered?" ) ; } return request ; }


Input: Converts non - array value to array . Detects various collection types and iterates them to make conversion and to create target array . [CODESPLIT] protected long [ ] convertValueToArray ( final Object value ) { if ( value instanceof Collection ) { final Collection collection = ( Collection ) value ; final long [ ] target = new long [ 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 < Long > longArrayList = new ArrayList <> ( ) ; for ( final Object element : iterable ) { final long convertedValue = convertType ( element ) ; longArrayList . add ( Long . valueOf ( convertedValue ) ) ; } final long [ ] array = new long [ longArrayList . size ( ) ] ; for ( int i = 0 ; i < longArrayList . size ( ) ; i ++ ) { final Long l = longArrayList . get ( i ) ; array [ i ] = l . longValue ( ) ; } return array ; } if ( value instanceof CharSequence ) { final String [ ] strings = StringUtil . splitc ( value . toString ( ) , ArrayConverter . NUMBER_DELIMITERS ) ; return convertArrayToArray ( strings ) ; } // everything else: return convertToSingleElementArray ( value ) ; }


Input: Converts array value to array . [CODESPLIT] protected long [ ] convertArrayToArray ( final Object value ) { final Class valueComponentType = value . getClass ( ) . getComponentType ( ) ; final long [ ] result ; if ( valueComponentType . isPrimitive ( ) ) { result = convertPrimitiveArrayToArray ( value , valueComponentType ) ; } else { // convert object array to target array final Object [ ] array = ( Object [ ] ) value ; result = new long [ array . length ] ; for ( int i = 0 ; i < array . length ; i ++ ) { result [ i ] = convertType ( array [ i ] ) ; } } return result ; }


Input: Converts primitive array to target array . [CODESPLIT] protected long [ ] convertPrimitiveArrayToArray ( final Object value , final Class primitiveComponentType ) { long [ ] result = null ; if ( primitiveComponentType == long . class ) { return ( long [ ] ) value ; } if ( primitiveComponentType == int . class ) { final int [ ] array = ( int [ ] ) value ; result = new long [ array . length ] ; for ( int i = 0 ; i < array . length ; i ++ ) { result [ i ] = array [ i ] ; } } else if ( primitiveComponentType == float . class ) { final float [ ] array = ( float [ ] ) value ; result = new long [ array . length ] ; for ( int i = 0 ; i < array . length ; i ++ ) { result [ i ] = ( long ) array [ i ] ; } } else if ( primitiveComponentType == double . class ) { final double [ ] array = ( double [ ] ) value ; result = new long [ array . length ] ; for ( int i = 0 ; i < array . length ; i ++ ) { result [ i ] = ( long ) array [ i ] ; } } else if ( primitiveComponentType == short . class ) { final short [ ] array = ( short [ ] ) value ; result = new long [ array . length ] ; for ( int i = 0 ; i < array . length ; i ++ ) { result [ i ] = array [ i ] ; } } else if ( primitiveComponentType == byte . class ) { final byte [ ] array = ( byte [ ] ) value ; result = new long [ array . length ] ; for ( int i = 0 ; i < array . length ; i ++ ) { result [ i ] = array [ i ] ; } } else if ( primitiveComponentType == char . class ) { final char [ ] array = ( char [ ] ) value ; result = new long [ array . length ] ; for ( int i = 0 ; i < array . length ; i ++ ) { result [ i ] = array [ i ] ; } } else if ( primitiveComponentType == boolean . class ) { final boolean [ ] array = ( boolean [ ] ) value ; result = new long [ array . length ] ; for ( int i = 0 ; i < array . length ; i ++ ) { result [ i ] = array [ i ] ? 1 : 0 ; } } return result ; }


Input: Initializes Decora filter . Loads manager and parser from init parameters . [CODESPLIT] @ Override public void init ( final FilterConfig filterConfig ) throws ServletException { // final String decoraManagerClass = filterConfig . getInitParameter ( PARAM_DECORA_MANAGER ) ; if ( decoraManagerClass != null ) { try { final Class decoraManagerType = ClassLoaderUtil . loadClass ( decoraManagerClass ) ; decoraManager = ( DecoraManager ) ClassUtil . newInstance ( decoraManagerType ) ; } catch ( Exception ex ) { log . error ( "Unable to load Decora manager class: " + decoraManagerClass , ex ) ; throw new ServletException ( ex ) ; } } else { decoraManager = createDecoraManager ( ) ; } // final String decoraParserClass = filterConfig . getInitParameter ( PARAM_DECORA_PARSER ) ; if ( decoraParserClass != null ) { try { final Class decoraParserType = ClassLoaderUtil . loadClass ( decoraParserClass ) ; decoraParser = ( DecoraParser ) ClassUtil . newInstance ( decoraParserType ) ; } catch ( Exception ex ) { log . error ( "Unable to load Decora parser class: " + decoraParserClass , ex ) ; throw new ServletException ( ex ) ; } } else { decoraParser = createDecoraParser ( ) ; } // final String decoraCache = filterConfig . getInitParameter ( PARAM_DECORA_CACHE ) ; if ( decoraCache != null ) { cached = Converter . get ( ) . toBoolean ( decoraCache , false ) ; } }


Input: Registers file consumer [CODESPLIT] public FindFile onFile ( final Consumer < File > fileConsumer ) { if ( consumers == null ) { consumers = Consumers . of ( fileConsumer ) ; } else { consumers . add ( fileConsumer ) ; } return this ; }


Input: Specifies the search path . If provided path contains { [CODESPLIT] public FindFile searchPath ( final String searchPath ) { if ( searchPath . indexOf ( File . pathSeparatorChar ) != - 1 ) { String [ ] paths = StringUtil . split ( searchPath , File . pathSeparator ) ; for ( String path : paths ) { addPath ( new File ( path ) ) ; } } else { addPath ( new File ( searchPath ) ) ; } return this ; }


Input: Specifies the search path . Throws an exception if URI is invalid . [CODESPLIT] public FindFile searchPath ( final URI searchPath ) { File file ; try { file = new File ( searchPath ) ; } catch ( Exception ex ) { throw new FindFileException ( "URI error: " + searchPath , ex ) ; } addPath ( file ) ; return this ; }


Input: Specifies the search path . Throws an exception if URL is invalid . [CODESPLIT] public FindFile searchPath ( final URL searchPath ) { File file = FileUtil . toContainerFile ( searchPath ) ; if ( file == null ) { throw new FindFileException ( "URL error: " + searchPath ) ; } addPath ( file ) ; return this ; }


Input: Defines include patterns . [CODESPLIT] public FindFile include ( final String ... patterns ) { for ( String pattern : patterns ) { rules . include ( pattern ) ; } return this ; }


Input: Defines exclude patterns . [CODESPLIT] public FindFile exclude ( final String ... patterns ) { for ( String pattern : patterns ) { rules . exclude ( pattern ) ; } return this ; }


Input: Determine if file is accepted based on include and exclude rules . Called on each file entry ( file or directory ) and returns <code > true< / code > if file passes search criteria . File is matched using { [CODESPLIT] protected boolean acceptFile ( final File file ) { String matchingFilePath = getMatchingFilePath ( file ) ; if ( rules . match ( matchingFilePath ) ) { if ( consumers != null ) { consumers . accept ( file ) ; } return true ; } return false ; }


Input: Resolves file path depending on { [CODESPLIT] protected String getMatchingFilePath ( final File file ) { String path = null ; switch ( matchType ) { case FULL_PATH : path = file . getAbsolutePath ( ) ; break ; case RELATIVE_PATH : path = file . getAbsolutePath ( ) ; path = path . substring ( rootPath . length ( ) ) ; break ; case NAME : path = file . getName ( ) ; } path = FileNameUtil . separatorsToUnix ( path ) ; return path ; }


Input: Adds existing search path to the file list . Non existing files are ignored . If path is a folder it will be scanned for all files . [CODESPLIT] protected void addPath ( final File path ) { if ( ! path . exists ( ) ) { return ; } if ( pathList == null ) { pathList = new LinkedList <> ( ) ; } pathList . add ( path ) ; }


Input: Reset the search so it can be run again with very same parameters ( and sorting options ) . [CODESPLIT] public void reset ( ) { pathList = pathListOriginal ; pathListOriginal = null ; todoFiles = null ; lastFile = null ; rules . reset ( ) ; }


Input: Finds the next file . Returns founded file that matches search configuration or <code > null< / code > if no more files can be found . [CODESPLIT] public File nextFile ( ) { if ( todoFiles == null ) { init ( ) ; } while ( true ) { // iterate files if ( ! todoFiles . isEmpty ( ) ) { FilesIterator filesIterator = todoFiles . getLast ( ) ; File nextFile = filesIterator . next ( ) ; if ( nextFile == null ) { todoFiles . removeLast ( ) ; continue ; } if ( nextFile . isDirectory ( ) ) { if ( ! walking ) { todoFolders . add ( nextFile ) ; continue ; } // walking if ( recursive ) { todoFiles . add ( new FilesIterator ( nextFile ) ) ; } if ( includeDirs ) { if ( acceptFile ( nextFile ) ) { lastFile = nextFile ; return nextFile ; } } continue ; } lastFile = nextFile ; return nextFile ; } // process folders File folder ; boolean initialDir = false ; if ( todoFolders . isEmpty ( ) ) { if ( pathList . isEmpty ( ) ) { // the end return null ; } folder = pathList . removeFirst ( ) ; rootFile = folder ; rootPath = rootFile . getAbsolutePath ( ) ; initialDir = true ; } else { folder = todoFolders . removeFirst ( ) ; } if ( ( initialDir ) || ( recursive ) ) { todoFiles . add ( new FilesIterator ( folder ) ) ; } if ( ( ! initialDir ) && ( includeDirs ) ) { if ( acceptFile ( folder ) ) { lastFile = folder ; return folder ; } } } }


Input: Finds all files and returns list of founded files . [CODESPLIT] public List < File > findAll ( ) { List < File > allFiles = new ArrayList <> ( ) ; File file ; while ( ( file = nextFile ( ) ) != null ) { allFiles . add ( file ) ; } return allFiles ; }


Input: Initializes file walking . Separates input files and folders . [CODESPLIT] protected void init ( ) { rules . detectMode ( ) ; todoFiles = new LinkedList <> ( ) ; todoFolders = new LinkedList <> ( ) ; if ( pathList == null ) { pathList = new LinkedList <> ( ) ; return ; } if ( pathListOriginal == null ) { pathListOriginal = ( LinkedList < File > ) pathList . clone ( ) ; } String [ ] files = new String [ pathList . size ( ) ] ; int index = 0 ; Iterator < File > iterator = pathList . iterator ( ) ; while ( iterator . hasNext ( ) ) { File file = iterator . next ( ) ; if ( file . isFile ( ) ) { files [ index ++ ] = file . getAbsolutePath ( ) ; iterator . remove ( ) ; } } if ( index != 0 ) { FilesIterator filesIterator = new FilesIterator ( files ) ; todoFiles . add ( filesIterator ) ; } }


Input: Returns file walking iterator . [CODESPLIT] @ Override public Iterator < File > iterator ( ) { return new Iterator < File > ( ) { private File nextFile ; @ Override public boolean hasNext ( ) { nextFile = nextFile ( ) ; return nextFile != null ; } @ Override public File next ( ) { if ( nextFile == null ) { throw new NoSuchElementException ( ) ; } return nextFile ; } @ Override public void remove ( ) { throw new UnsupportedOperationException ( ) ; } } ; }


Input: { [CODESPLIT] @ Override public byte [ ] get ( final ResultSet rs , final int index , final int dbSqlType ) throws SQLException { return rs . getBytes ( index ) ; }


Input: { [CODESPLIT] @ Override public void set ( final PreparedStatement st , final int index , final byte [ ] value , final int dbSqlType ) throws SQLException { st . setBytes ( index , value ) ; }


Input: Resolves bean s auto - wire flag from the annotation . Returns default auto - wire if annotation doesn t exist . [CODESPLIT] public WiringMode resolveBeanWiringMode ( final Class type ) { PetiteBean petiteBean = ( ( Class < ? > ) type ) . getAnnotation ( PetiteBean . class ) ; return petiteBean != null ? petiteBean . wiring ( ) : WiringMode . DEFAULT ; }


Input: Resolves bean s scope type from the annotation . Returns <code > null< / code > if annotation doesn t exist . [CODESPLIT] public Class < ? extends Scope > resolveBeanScopeType ( final Class type ) { PetiteBean petiteBean = ( ( Class < ? > ) type ) . getAnnotation ( PetiteBean . class ) ; return petiteBean != null ? petiteBean . scope ( ) : null ; }


Input: Resolves bean s name from bean annotation or type name . May be used for resolving bean name of base type during registration of bean subclass . [CODESPLIT] public String resolveBeanName ( final Class type , final boolean useLongTypeName ) { PetiteBean petiteBean = ( ( Class < ? > ) type ) . getAnnotation ( PetiteBean . class ) ; String name = null ; if ( petiteBean != null ) { name = petiteBean . value ( ) . trim ( ) ; } if ( ( name == null ) || ( name . length ( ) == 0 ) ) { if ( useLongTypeName ) { name = type . getName ( ) ; } else { name = StringUtil . uncapitalize ( type . getSimpleName ( ) ) ; } } return name ; }


Input: Returns <code > true< / code > if bean has name defined by Petite annotation . [CODESPLIT] public boolean beanHasAnnotationName ( final Class type ) { PetiteBean petiteBean = ( ( Class < ? > ) type ) . getAnnotation ( PetiteBean . class ) ; if ( petiteBean == null ) { return false ; } String name = petiteBean . value ( ) . trim ( ) ; return ! name . isEmpty ( ) ; }


Input: Returns a writer . [CODESPLIT] public PrintWriter getWriter ( ) { if ( outWriter == null ) { if ( outStream != null ) { throw new IllegalStateException ( "Can't call getWriter() after getOutputStream()" ) ; } bufferedWriter = new FastCharArrayWriter ( ) ; outWriter = new PrintWriter ( bufferedWriter ) { @ Override public void close ( ) { // do not close the print writer after rendering // since it will remove reference to bufferedWriter } } ; } return outWriter ; }


Input: Returns a servlet output stream . [CODESPLIT] public ServletOutputStream getOutputStream ( ) { if ( outStream == null ) { if ( outWriter != null ) { throw new IllegalStateException ( "Can't call getOutputStream() after getWriter()" ) ; } bufferOutputStream = new FastByteArrayServletOutputStream ( ) ; outStream = bufferOutputStream ; } return outStream ; }


Input: Returns the { @link Type } corresponding to the given class . [CODESPLIT] public static Type getType ( final Class < ? > clazz ) { if ( clazz . isPrimitive ( ) ) { if ( clazz == Integer . TYPE ) { return INT_TYPE ; } else if ( clazz == Void . TYPE ) { return VOID_TYPE ; } else if ( clazz == Boolean . TYPE ) { return BOOLEAN_TYPE ; } else if ( clazz == Byte . TYPE ) { return BYTE_TYPE ; } else if ( clazz == Character . TYPE ) { return CHAR_TYPE ; } else if ( clazz == Short . TYPE ) { return SHORT_TYPE ; } else if ( clazz == Double . TYPE ) { return DOUBLE_TYPE ; } else if ( clazz == Float . TYPE ) { return FLOAT_TYPE ; } else if ( clazz == Long . TYPE ) { return LONG_TYPE ; } else { throw new AssertionError ( ) ; } } else { return getType ( getDescriptor ( clazz ) ) ; } }


Input: Returns the { @link Type } corresponding to the given internal name . [CODESPLIT] public static Type getObjectType ( final String internalName ) { return new Type ( internalName . charAt ( 0 ) == ' ' ? ARRAY : INTERNAL , internalName , 0 , internalName . length ( ) ) ; }


Input: Returns the method { @link Type } corresponding to the given argument and return types . [CODESPLIT] public static Type getMethodType ( final Type returnType , final Type ... argumentTypes ) { return getType ( getMethodDescriptor ( returnType , argumentTypes ) ) ; }


Input: Returns the { @link Type } values corresponding to the argument types of the given method descriptor . [CODESPLIT] public static Type [ ] getArgumentTypes ( final String methodDescriptor ) { // First step: compute the number of argument types in methodDescriptor. int numArgumentTypes = 0 ; // Skip the first character, which is always a '('. int currentOffset = 1 ; // Parse the argument types, one at a each loop iteration. while ( methodDescriptor . charAt ( currentOffset ) != ' ' ) { while ( methodDescriptor . charAt ( currentOffset ) == ' ' ) { currentOffset ++ ; } if ( methodDescriptor . charAt ( currentOffset ++ ) == ' ' ) { // Skip the argument descriptor content. currentOffset = methodDescriptor . indexOf ( ' ' , currentOffset ) + 1 ; } ++ numArgumentTypes ; } // Second step: create a Type instance for each argument type. Type [ ] argumentTypes = new Type [ numArgumentTypes ] ; // Skip the first character, which is always a '('. currentOffset = 1 ; // Parse and create the argument types, one at each loop iteration. int currentArgumentTypeIndex = 0 ; while ( methodDescriptor . charAt ( currentOffset ) != ' ' ) { final int currentArgumentTypeOffset = currentOffset ; while ( methodDescriptor . charAt ( currentOffset ) == ' ' ) { currentOffset ++ ; } if ( methodDescriptor . charAt ( currentOffset ++ ) == ' ' ) { // Skip the argument descriptor content. currentOffset = methodDescriptor . indexOf ( ' ' , currentOffset ) + 1 ; } argumentTypes [ currentArgumentTypeIndex ++ ] = getTypeInternal ( methodDescriptor , currentArgumentTypeOffset , currentOffset ) ; } return argumentTypes ; }


Input: Returns the { @link Type } corresponding to the return type of the given method descriptor . [CODESPLIT] public static Type getReturnType ( final String methodDescriptor ) { // Skip the first character, which is always a '('. int currentOffset = 1 ; // Skip the argument types, one at a each loop iteration. while ( methodDescriptor . charAt ( currentOffset ) != ' ' ) { while ( methodDescriptor . charAt ( currentOffset ) == ' ' ) { currentOffset ++ ; } if ( methodDescriptor . charAt ( currentOffset ++ ) == ' ' ) { // Skip the argument descriptor content. currentOffset = methodDescriptor . indexOf ( ' ' , currentOffset ) + 1 ; } } return getTypeInternal ( methodDescriptor , currentOffset + 1 , methodDescriptor . length ( ) ) ; }


Input: Returns the { @link Type } corresponding to the given field or method descriptor . [CODESPLIT] private static Type getTypeInternal ( final String descriptorBuffer , final int descriptorBegin , final int descriptorEnd ) { switch ( descriptorBuffer . charAt ( descriptorBegin ) ) { case ' ' : return VOID_TYPE ; case ' ' : return BOOLEAN_TYPE ; case ' ' : return CHAR_TYPE ; case ' ' : return BYTE_TYPE ; case ' ' : return SHORT_TYPE ; case ' ' : return INT_TYPE ; case ' ' : return FLOAT_TYPE ; case ' ' : return LONG_TYPE ; case ' ' : return DOUBLE_TYPE ; case ' ' : return new Type ( ARRAY , descriptorBuffer , descriptorBegin , descriptorEnd ) ; case ' ' : return new Type ( OBJECT , descriptorBuffer , descriptorBegin + 1 , descriptorEnd - 1 ) ; case ' ' : return new Type ( METHOD , descriptorBuffer , descriptorBegin , descriptorEnd ) ; default : throw new IllegalArgumentException ( ) ; } }


Input: Returns the binary name of the class corresponding to this type . This method must not be used on method types . [CODESPLIT] public String getClassName ( ) { switch ( sort ) { case VOID : return "void" ; case BOOLEAN : return "boolean" ; case CHAR : return "char" ; case BYTE : return "byte" ; case SHORT : return "short" ; case INT : return "int" ; case FLOAT : return "float" ; case LONG : return "long" ; case DOUBLE : return "double" ; case ARRAY : StringBuilder stringBuilder = new StringBuilder ( getElementType ( ) . getClassName ( ) ) ; for ( int i = getDimensions ( ) ; i > 0 ; -- i ) { stringBuilder . append ( "[]" ) ; } return stringBuilder . toString ( ) ; case OBJECT : case INTERNAL : return valueBuffer . substring ( valueBegin , valueEnd ) . replace ( ' ' , ' ' ) ; default : throw new AssertionError ( ) ; } }


Input: Returns the descriptor corresponding to the given constructor . [CODESPLIT] public static String getConstructorDescriptor ( final Constructor < ? > constructor ) { StringBuilder stringBuilder = new StringBuilder ( ) ; stringBuilder . append ( ' ' ) ; Class < ? > [ ] parameters = constructor . getParameterTypes ( ) ; for ( Class < ? > parameter : parameters ) { appendDescriptor ( parameter , stringBuilder ) ; } return stringBuilder . append ( ")V" ) . toString ( ) ; }


Input: Returns the descriptor corresponding to the given argument and return types . [CODESPLIT] public static String getMethodDescriptor ( final Type returnType , final Type ... argumentTypes ) { StringBuilder stringBuilder = new StringBuilder ( ) ; stringBuilder . append ( ' ' ) ; for ( Type argumentType : argumentTypes ) { argumentType . appendDescriptor ( stringBuilder ) ; } stringBuilder . append ( ' ' ) ; returnType . appendDescriptor ( stringBuilder ) ; return stringBuilder . toString ( ) ; }


Input: Returns the descriptor corresponding to the given method . [CODESPLIT] public static String getMethodDescriptor ( final Method method ) { StringBuilder stringBuilder = new StringBuilder ( ) ; stringBuilder . append ( ' ' ) ; Class < ? > [ ] parameters = method . getParameterTypes ( ) ; for ( Class < ? > parameter : parameters ) { appendDescriptor ( parameter , stringBuilder ) ; } stringBuilder . append ( ' ' ) ; appendDescriptor ( method . getReturnType ( ) , stringBuilder ) ; return stringBuilder . toString ( ) ; }


Input: Appends the descriptor corresponding to this type to the given string buffer . [CODESPLIT] private void appendDescriptor ( final StringBuilder stringBuilder ) { if ( sort == OBJECT ) { stringBuilder . append ( valueBuffer , valueBegin - 1 , valueEnd + 1 ) ; } else if ( sort == INTERNAL ) { stringBuilder . append ( ' ' ) . append ( valueBuffer , valueBegin , valueEnd ) . append ( ' ' ) ; } else { stringBuilder . append ( valueBuffer , valueBegin , valueEnd ) ; } }


Input: Returns the size of values of this type . This method must not be used for method types . [CODESPLIT] public int getSize ( ) { switch ( sort ) { case VOID : return 0 ; case BOOLEAN : case CHAR : case BYTE : case SHORT : case INT : case FLOAT : case ARRAY : case OBJECT : case INTERNAL : return 1 ; case LONG : case DOUBLE : return 2 ; default : throw new AssertionError ( ) ; } }


Input: Computes the size of the arguments and of the return value of a method . [CODESPLIT] public static int getArgumentsAndReturnSizes ( final String methodDescriptor ) { int argumentsSize = 1 ; // Skip the first character, which is always a '('. int currentOffset = 1 ; int currentChar = methodDescriptor . charAt ( currentOffset ) ; // Parse the argument types and compute their size, one at a each loop iteration. while ( currentChar != ' ' ) { if ( currentChar == ' ' || currentChar == ' ' ) { currentOffset ++ ; argumentsSize += 2 ; } else { while ( methodDescriptor . charAt ( currentOffset ) == ' ' ) { currentOffset ++ ; } if ( methodDescriptor . charAt ( currentOffset ++ ) == ' ' ) { // Skip the argument descriptor content. currentOffset = methodDescriptor . indexOf ( ' ' , currentOffset ) + 1 ; } argumentsSize += 1 ; } currentChar = methodDescriptor . charAt ( currentOffset ) ; } currentChar = methodDescriptor . charAt ( currentOffset + 1 ) ; if ( currentChar == ' ' ) { return argumentsSize << 2 ; } else { int returnSize = ( currentChar == ' ' || currentChar == ' ' ) ? 2 : 1 ; return argumentsSize << 2 | returnSize ; } }


Input: Returns a JVM instruction opcode adapted to this { @link Type } . This method must not be used for method types . [CODESPLIT] public int getOpcode ( final int opcode ) { if ( opcode == Opcodes . IALOAD || opcode == Opcodes . IASTORE ) { switch ( sort ) { case BOOLEAN : case BYTE : return opcode + ( Opcodes . BALOAD - Opcodes . IALOAD ) ; case CHAR : return opcode + ( Opcodes . CALOAD - Opcodes . IALOAD ) ; case SHORT : return opcode + ( Opcodes . SALOAD - Opcodes . IALOAD ) ; case INT : return opcode ; case FLOAT : return opcode + ( Opcodes . FALOAD - Opcodes . IALOAD ) ; case LONG : return opcode + ( Opcodes . LALOAD - Opcodes . IALOAD ) ; case DOUBLE : return opcode + ( Opcodes . DALOAD - Opcodes . IALOAD ) ; case ARRAY : case OBJECT : case INTERNAL : return opcode + ( Opcodes . AALOAD - Opcodes . IALOAD ) ; case METHOD : case VOID : throw new UnsupportedOperationException ( ) ; default : throw new AssertionError ( ) ; } } else { switch ( sort ) { case VOID : if ( opcode != Opcodes . IRETURN ) { throw new UnsupportedOperationException ( ) ; } return Opcodes . RETURN ; case BOOLEAN : case BYTE : case CHAR : case SHORT : case INT : return opcode ; case FLOAT : return opcode + ( Opcodes . FRETURN - Opcodes . IRETURN ) ; case LONG : return opcode + ( Opcodes . LRETURN - Opcodes . IRETURN ) ; case DOUBLE : return opcode + ( Opcodes . DRETURN - Opcodes . IRETURN ) ; case ARRAY : case OBJECT : case INTERNAL : if ( opcode != Opcodes . ILOAD && opcode != Opcodes . ISTORE && opcode != Opcodes . IRETURN ) { throw new UnsupportedOperationException ( ) ; } return opcode + ( Opcodes . ARETURN - Opcodes . IRETURN ) ; case METHOD : throw new UnsupportedOperationException ( ) ; default : throw new AssertionError ( ) ; } } }


Input: Modify the transaction associated with the target object such that the only possible outcome of the transaction is to roll back the transaction . [CODESPLIT] public void setRollbackOnly ( final Throwable th ) { if ( ! isNoTransaction ( ) ) { if ( ( status != STATUS_MARKED_ROLLBACK ) && ( status != STATUS_ACTIVE ) ) { throw new JtxException ( "TNo active TX that can be marked as rollback only" ) ; } } rollbackCause = th ; status = STATUS_MARKED_ROLLBACK ; }


Input: Performs either commit or rollback on all transaction resources . [CODESPLIT] protected void commitOrRollback ( boolean doCommit ) { if ( log . isDebugEnabled ( ) ) { if ( doCommit ) { log . debug ( "Commit JTX" ) ; } else { log . debug ( "Rollback JTX" ) ; } } boolean forcedRollback = false ; if ( ! isNoTransaction ( ) ) { if ( isRollbackOnly ( ) ) { if ( doCommit ) { doCommit = false ; forcedRollback = true ; } } else if ( ! isActive ( ) ) { if ( isCompleted ( ) ) { throw new JtxException ( "TX is already completed, commit or rollback should be called once per TX" ) ; } throw new JtxException ( "No active TX to " + ( doCommit ? "commit" : "rollback" ) ) ; } } if ( doCommit ) { commitAllResources ( ) ; } else { rollbackAllResources ( forcedRollback ) ; } }


Input: Commits all attached resources . On successful commit resource will be closed and detached from this transaction . On exception resource remains attached to transaction . <p > All resources will be committed even if commit fails on some in that process . If there was at least one failed commit its exception will be re - thrown after finishing committing all resources and transaction will be marked as rollback only . [CODESPLIT] protected void commitAllResources ( ) throws JtxException { status = STATUS_COMMITTING ; Exception lastException = null ; Iterator < JtxResource > it = resources . iterator ( ) ; while ( it . hasNext ( ) ) { JtxResource resource = it . next ( ) ; try { resource . commitTransaction ( ) ; it . remove ( ) ; } catch ( Exception ex ) { lastException = ex ; } } if ( lastException != null ) { setRollbackOnly ( lastException ) ; throw new JtxException ( "Commit failed: one or more TX resources couldn't commit a TX" , lastException ) ; } txManager . removeTransaction ( this ) ; status = STATUS_COMMITTED ; }


Input: Rollbacks all attached resources . Resource will be closed . and detached from this transaction . If exception occurs it will be rethrown at the end . [CODESPLIT] protected void rollbackAllResources ( final boolean wasForced ) { status = STATUS_ROLLING_BACK ; Exception lastException = null ; Iterator < JtxResource > it = resources . iterator ( ) ; while ( it . hasNext ( ) ) { JtxResource resource = it . next ( ) ; try { resource . rollbackTransaction ( ) ; } catch ( Exception ex ) { lastException = ex ; } finally { it . remove ( ) ; } } txManager . removeTransaction ( this ) ; status = STATUS_ROLLEDBACK ; if ( lastException != null ) { status = STATUS_UNKNOWN ; throw new JtxException ( "Rollback failed: one or more TX resources couldn't rollback a TX" , lastException ) ; } if ( wasForced ) { throw new JtxException ( "TX rolled back because it has been marked as rollback-only" , rollbackCause ) ; } }


Input: Requests a resource . If resource is not found it will be created and new transaction will be started on it . [CODESPLIT] public < E > E requestResource ( final Class < E > resourceType ) { if ( isCompleted ( ) ) { throw new JtxException ( "TX is already completed, resource are not available after commit or rollback" ) ; } if ( isRollbackOnly ( ) ) { throw new JtxException ( "TX is marked as rollback only, resource are not available" , rollbackCause ) ; } if ( ! isNoTransaction ( ) && ! isActive ( ) ) { throw new JtxException ( "Resources are not available since TX is not active" ) ; } checkTimeout ( ) ; E resource = lookupResource ( resourceType ) ; if ( resource == null ) { int maxResources = txManager . getMaxResourcesPerTransaction ( ) ; if ( ( maxResources != - 1 ) && ( resources . size ( ) >= maxResources ) ) { throw new JtxException ( "TX already has attached max. number of resources" ) ; } JtxResourceManager < E > resourceManager = txManager . lookupResourceManager ( resourceType ) ; resource = resourceManager . beginTransaction ( mode , isActive ( ) ) ; resources . add ( new JtxResource <> ( this , resourceManager , resource ) ) ; } return resource ; }


Input: Lookups for open resource . Returns <code > null< / code > if resource not found . Only open resources can be found . [CODESPLIT] protected < E > E lookupResource ( final Class < E > resourceType ) { for ( JtxResource jtxResource : resources ) { if ( jtxResource . isSameTypeAsResource ( resourceType ) ) { //noinspection unchecked return ( E ) jtxResource . getResource ( ) ; } } return null ; }


Input: Stores name to temporary stack . Used when name s value may or may not be serialized ( e . g . it may be excluded ) in that case we do not need to write the name . [CODESPLIT] public void pushName ( final String name , final boolean withComma ) { pushedName = name ; pushedComma = withComma ; isPushed = true ; }


Input: Writes stored name to JSON string . Cleans storage . [CODESPLIT] protected void popName ( ) { if ( isPushed ) { if ( pushedComma ) { writeComma ( ) ; } String name = pushedName ; pushedName = null ; isPushed = false ; writeName ( name ) ; } }


Input: Writes object s property name : string and a colon . [CODESPLIT] public void writeName ( final String name ) { if ( name != null ) { writeString ( name ) ; } else { write ( NULL ) ; } write ( ' ' ) ; }


Input: Write a quoted and escaped value to the output . [CODESPLIT] public void writeString ( final String value ) { popName ( ) ; write ( StringPool . QUOTE ) ; int len = value . length ( ) ; for ( int i = 0 ; i < len ; i ++ ) { char c = value . charAt ( i ) ; switch ( c ) { case ' ' : write ( "\\\"" ) ; break ; case ' ' : write ( "\\\\" ) ; break ; case ' ' : if ( strictStringEncoding ) { write ( "\\/" ) ; } else { write ( c ) ; } break ; case ' ' : write ( "\\b" ) ; break ; case ' ' : write ( "\\f" ) ; break ; case ' ' : write ( "\\n" ) ; break ; case ' ' : write ( "\\r" ) ; break ; case ' ' : write ( "\\t" ) ; break ; default : if ( Character . isISOControl ( c ) ) { unicode ( c ) ; } else { write ( c ) ; } } } write ( StringPool . QUOTE ) ; }


Input: Writes unicode representation of a character . [CODESPLIT] protected void unicode ( final char c ) { write ( "\\u" ) ; int n = c ; for ( int i = 0 ; i < 4 ; ++ i ) { int digit = ( n & 0xf000 ) >> 12 ; char hex = CharUtil . int2hex ( digit ) ; write ( hex ) ; n <<= 4 ; } }


Input: Appends char sequence to the buffer . Used for numbers nulls booleans etc . [CODESPLIT] public void write ( final CharSequence charSequence ) { popName ( ) ; try { out . append ( charSequence ) ; } catch ( IOException ioex ) { throw new JsonException ( ioex ) ; } }


Input: Sets parsing error log level as a name . [CODESPLIT] public LagartoDomBuilderConfig setParsingErrorLogLevelName ( String logLevel ) { logLevel = logLevel . trim ( ) . toUpperCase ( ) ; parsingErrorLogLevel = Logger . Level . valueOf ( logLevel ) ; return this ; }


Input: ---------------------------------------------------------------- util methods [CODESPLIT] protected static StringBuilder toUppercase ( final StringBuilder string ) { final int strLen = string . length ( ) ; for ( int i = 0 ; i < strLen ; i ++ ) { char c = string . charAt ( i ) ; char uppercaseChar = Character . toUpperCase ( c ) ; if ( c != uppercaseChar ) { string . setCharAt ( i , uppercaseChar ) ; } } return string ; }


Input: Returns <code > true< / code > if provided tag matches decorator tag . [CODESPLIT] public boolean isMatchedTag ( final Tag tag ) { if ( ! tag . nameEquals ( name ) ) { return false ; } if ( id != null ) { CharSequence tagId = tag . getId ( ) ; if ( tagId == null ) { return false ; } if ( ! CharSequenceUtil . equals ( id , tagId ) ) { return false ; } } return true ; }


Input: Starts defining region by setting the start index and reset region length to zero . [CODESPLIT] public void startRegion ( final int start , final int tagLen , final int deepLevel ) { this . regionStart = start + tagLen ; this . regionLength = 0 ; this . regionTagStart = start ; this . deepLevel = deepLevel ; }


Input: Returns <code > true< / code > if region of this Decora tag is inside of region of provided Decora tag . [CODESPLIT] public boolean isInsideOtherTagRegion ( final DecoraTag decoraTag ) { return ( regionStart > decoraTag . getRegionStart ( ) ) && ( regionStart < decoraTag . getRegionStart ( ) + decoraTag . getRegionLength ( ) ) ; }


Input: Returns true if attribute is containing some value . [CODESPLIT] public boolean isContaining ( final String include ) { if ( value == null ) { return false ; } if ( splits == null ) { splits = StringUtil . splitc ( value , ' ' ) ; } for ( String s : splits ) { if ( s . equals ( include ) ) { return true ; } } return false ; }


Input: Registers pseudo function . [CODESPLIT] public static void registerPseudoFunction ( final Class < ? extends PseudoFunction > pseudoFunctionType ) { PseudoFunction pseudoFunction ; try { pseudoFunction = ClassUtil . newInstance ( pseudoFunctionType ) ; } catch ( Exception ex ) { throw new CSSellyException ( ex ) ; } PSEUDO_FUNCTION_MAP . put ( pseudoFunction . getPseudoFunctionName ( ) , pseudoFunction ) ; }


Input: Lookups pseudo function for given pseudo function name . [CODESPLIT] public static PseudoFunction < ? > lookupPseudoFunction ( final String pseudoFunctionName ) { PseudoFunction pseudoFunction = PSEUDO_FUNCTION_MAP . get ( pseudoFunctionName ) ; if ( pseudoFunction == null ) { throw new CSSellyException ( "Unsupported pseudo function: " + pseudoFunctionName ) ; } return pseudoFunction ; }


Input: Accepts node within selected results . Invoked after results are matched . [CODESPLIT] @ Override public boolean accept ( final List < Node > currentResults , final Node node , final int index ) { return pseudoFunction . match ( currentResults , node , index , parsedExpression ) ; }


Input: Creates destination subclass header from current target class . Destination name is created from targets by adding a suffix and optionally a number . Destination extends the target . [CODESPLIT] @ Override public void visit ( final int version , int access , final String name , final String signature , final String superName , final String [ ] interfaces ) { wd . init ( name , superName , this . suffix , this . reqProxyClassName ) ; // change access of destination access &= ~ AsmUtil . ACC_ABSTRACT ; // write destination class final int v = ProxettaAsmUtil . resolveJavaVersion ( version ) ; wd . dest . visit ( v , access , wd . thisReference , signature , wd . superName , null ) ; wd . proxyAspects = new ProxyAspectData [ aspects . length ] ; for ( int i = 0 ; i < aspects . length ; i ++ ) { wd . proxyAspects [ i ] = new ProxyAspectData ( wd , aspects [ i ] , i ) ; } }


Input: Creates proxified methods and constructors . Destination proxy will have all constructors as a target class using { [CODESPLIT] @ Override public MethodVisitor visitMethod ( final int access , final String name , final String desc , final String signature , final String [ ] exceptions ) { final MethodSignatureVisitor msign = targetClassInfo . lookupMethodSignatureVisitor ( access , name , desc , wd . superReference ) ; if ( msign == null ) { return null ; } if ( msign . isFinal && ! wd . allowFinalMethods ) { return null ; } // destination constructors [A1] if ( name . equals ( INIT ) ) { MethodVisitor mv = wd . dest . visitMethod ( access , name , desc , msign . getAsmMethodSignature ( ) , null ) ; return new ProxettaCtorBuilder ( mv , msign , wd ) ; } // ignore destination static block if ( name . equals ( CLINIT ) ) { return null ; } return applyProxy ( msign ) ; }


Input: Copies all destination type annotations to the target . [CODESPLIT] @ Override public AnnotationVisitor visitAnnotation ( final String desc , final boolean visible ) { AnnotationVisitor destAnn = wd . dest . visitAnnotation ( desc , visible ) ; // [A3] return new AnnotationVisitorAdapter ( destAnn ) ; }


Input: Creates static initialization block that simply calls all advice static init methods in correct order . [CODESPLIT] protected void makeStaticInitBlock ( ) { if ( wd . adviceClinits != null ) { MethodVisitor mv = wd . dest . visitMethod ( AsmUtil . ACC_STATIC , CLINIT , DESC_VOID , null , null ) ; mv . visitCode ( ) ; for ( String name : wd . adviceClinits ) { mv . visitMethodInsn ( INVOKESTATIC , wd . thisReference , name , DESC_VOID , false ) ; } mv . visitInsn ( RETURN ) ; mv . visitMaxs ( 0 , 0 ) ; mv . visitEnd ( ) ; } }


Input: Creates init method that simply calls all advice constructor methods in correct order . This created init method is called from each destination s constructor . [CODESPLIT] protected void makeProxyConstructor ( ) { MethodVisitor mv = wd . dest . visitMethod ( AsmUtil . ACC_PRIVATE | AsmUtil . ACC_FINAL , ProxettaNames . initMethodName , DESC_VOID , null , null ) ; mv . visitCode ( ) ; if ( wd . adviceInits != null ) { for ( String name : wd . adviceInits ) { mv . visitVarInsn ( ALOAD , 0 ) ; mv . visitMethodInsn ( INVOKESPECIAL , wd . thisReference , name , DESC_VOID , false ) ; } } mv . visitInsn ( RETURN ) ; mv . visitMaxs ( 0 , 0 ) ; mv . visitEnd ( ) ; }


Input: Checks for all public super methods that are not overridden . [CODESPLIT] protected void processSuperMethods ( ) { for ( ClassReader cr : targetClassInfo . superClassReaders ) { cr . accept ( new EmptyClassVisitor ( ) { String declaredClassName ; @ Override public void visit ( final int version , final int access , final String name , final String signature , final String superName , final String [ ] interfaces ) { declaredClassName = name ; } @ Override public MethodVisitor visitMethod ( final int access , final String name , final String desc , final String signature , final String [ ] exceptions ) { if ( name . equals ( INIT ) || name . equals ( CLINIT ) ) { return null ; } MethodSignatureVisitor msign = targetClassInfo . lookupMethodSignatureVisitor ( access , name , desc , declaredClassName ) ; if ( msign == null ) { return null ; } return applyProxy ( msign ) ; } } , 0 ) ; } }


Input: Check if proxy should be applied on method and return proxy method builder if so . Otherwise returns <code > null< / code > . [CODESPLIT] protected ProxettaMethodBuilder applyProxy ( final MethodSignatureVisitor msign ) { List < ProxyAspectData > aspectList = matchMethodPointcuts ( msign ) ; if ( aspectList == null ) { // no pointcuts on this method, return return null ; } int access = msign . getAccessFlags ( ) ; if ( ( access & ACC_ABSTRACT ) != 0 ) { throw new ProxettaException ( "Unable to process abstract method: " + msign ) ; } wd . proxyApplied = true ; return new ProxettaMethodBuilder ( msign , wd , aspectList ) ; }


Input: Matches pointcuts on method . If no pointcut found returns <code > null< / code > . [CODESPLIT] protected List < ProxyAspectData > matchMethodPointcuts ( final MethodSignatureVisitor msign ) { List < ProxyAspectData > aspectList = null ; for ( ProxyAspectData aspectData : wd . proxyAspects ) { if ( aspectData . apply ( msign ) ) { if ( aspectList == null ) { aspectList = new ArrayList <> ( wd . proxyAspects . length ) ; } aspectList . add ( aspectData ) ; } } return aspectList ; }


Input: Finds index of given element in inclusive index range . Returns negative value if element is not found . [CODESPLIT] public int find ( int low , int high ) { while ( low <= high ) { int mid = ( low + high ) >>> 1 ; int delta = compare ( mid ) ; if ( delta < 0 ) { low = mid + 1 ; } else if ( delta > 0 ) { high = mid - 1 ; } else { return mid ; } } // not found return - ( low + 1 ) ; }


Input: Finds very first index of given element in inclusive index range . Returns negative value if element is not found . [CODESPLIT] public int findFirst ( int low , int high ) { int ndx = - 1 ; while ( low <= high ) { int mid = ( low + high ) >>> 1 ; int delta = compare ( mid ) ; if ( delta < 0 ) { low = mid + 1 ; } else { if ( delta == 0 ) { ndx = mid ; } high = mid - 1 ; } } if ( ndx == - 1 ) { return - ( low + 1 ) ; } return ndx ; }


Input: Finds very last index of given element in inclusive index range . Returns negative value if element is not found . [CODESPLIT] public int findLast ( int low , int high ) { int ndx = - 1 ; while ( low <= high ) { int mid = ( low + high ) >>> 1 ; int delta = compare ( mid ) ; if ( delta > 0 ) { high = mid - 1 ; } else { if ( delta == 0 ) { ndx = mid ; } low = mid + 1 ; } } if ( ndx == - 1 ) { return - ( low + 1 ) ; } return ndx ; }


Input: ---------------------------------------------------------------- internal [CODESPLIT] protected void startSequence ( final String value ) { if ( prefix == null ) { prefix = new StringBuilder ( ) ; prefix . append ( "\u001B[" ) ; } else { prefix . append ( StringPool . SEMICOLON ) ; } prefix . append ( value ) ; }


Input: Returns chalked string . [CODESPLIT] public String on ( final String string ) { if ( ! enabled ) { return string ; } final StringBuilder sb = new StringBuilder ( ) ; if ( prefix != null ) { sb . append ( prefix ) . append ( "m" ) ; } sb . append ( string ) ; if ( suffix != null ) { sb . append ( suffix ) . append ( "m" ) ; } return sb . toString ( ) ; }


Input: ----------------------------------------------------------------------------------------------- [CODESPLIT] @ Override public final void visit ( final int version , final int access , final String name , final String signature , final String superName , final String [ ] interfaces ) { this . version = version ; this . accessFlags = access ; this . thisClass = symbolTable . setMajorVersionAndClassName ( version & 0xFFFF , name ) ; if ( signature != null ) { this . signatureIndex = symbolTable . addConstantUtf8 ( signature ) ; } this . superClass = superName == null ? 0 : symbolTable . addConstantClass ( superName ) . index ; if ( interfaces != null && interfaces . length > 0 ) { interfaceCount = interfaces . length ; this . interfaces = new int [ interfaceCount ] ; for ( int i = 0 ; i < interfaceCount ; ++ i ) { this . interfaces [ i ] = symbolTable . addConstantClass ( interfaces [ i ] ) . index ; } } if ( compute == MethodWriter . COMPUTE_MAX_STACK_AND_LOCAL && ( version & 0xFFFF ) >= Opcodes . V1_7 ) { compute = MethodWriter . COMPUTE_MAX_STACK_AND_LOCAL_FROM_FRAMES ; } }


Input: Returns the content of the class file that was built by this ClassWriter . [CODESPLIT] public byte [ ] toByteArray ( ) throws ClassTooLargeException , MethodTooLargeException { // First step: compute the size in bytes of the ClassFile structure. // The magic field uses 4 bytes, 10 mandatory fields (minor_version, major_version, // constant_pool_count, access_flags, this_class, super_class, interfaces_count, fields_count, // methods_count and attributes_count) use 2 bytes each, and each interface uses 2 bytes too. int size = 24 + 2 * interfaceCount ; int fieldsCount = 0 ; FieldWriter fieldWriter = firstField ; while ( fieldWriter != null ) { ++ fieldsCount ; size += fieldWriter . computeFieldInfoSize ( ) ; fieldWriter = ( FieldWriter ) fieldWriter . fv ; } int methodsCount = 0 ; MethodWriter methodWriter = firstMethod ; while ( methodWriter != null ) { ++ methodsCount ; size += methodWriter . computeMethodInfoSize ( ) ; methodWriter = ( MethodWriter ) methodWriter . mv ; } // For ease of reference, we use here the same attribute order as in Section 4.7 of the JVMS. int attributesCount = 0 ; if ( innerClasses != null ) { ++ attributesCount ; size += 8 + innerClasses . length ; symbolTable . addConstantUtf8 ( Constants . INNER_CLASSES ) ; } if ( enclosingClassIndex != 0 ) { ++ attributesCount ; size += 10 ; symbolTable . addConstantUtf8 ( Constants . ENCLOSING_METHOD ) ; } if ( ( accessFlags & Opcodes . ACC_SYNTHETIC ) != 0 && ( version & 0xFFFF ) < Opcodes . V1_5 ) { ++ attributesCount ; size += 6 ; symbolTable . addConstantUtf8 ( Constants . SYNTHETIC ) ; } if ( signatureIndex != 0 ) { ++ attributesCount ; size += 8 ; symbolTable . addConstantUtf8 ( Constants . SIGNATURE ) ; } if ( sourceFileIndex != 0 ) { ++ attributesCount ; size += 8 ; symbolTable . addConstantUtf8 ( Constants . SOURCE_FILE ) ; } if ( debugExtension != null ) { ++ attributesCount ; size += 6 + debugExtension . length ; symbolTable . addConstantUtf8 ( Constants . SOURCE_DEBUG_EXTENSION ) ; } if ( ( accessFlags & Opcodes . ACC_DEPRECATED ) != 0 ) { ++ attributesCount ; size += 6 ; symbolTable . addConstantUtf8 ( Constants . DEPRECATED ) ; } if ( lastRuntimeVisibleAnnotation != null ) { ++ attributesCount ; size += lastRuntimeVisibleAnnotation . computeAnnotationsSize ( Constants . RUNTIME_VISIBLE_ANNOTATIONS ) ; } if ( lastRuntimeInvisibleAnnotation != null ) { ++ attributesCount ; size += lastRuntimeInvisibleAnnotation . computeAnnotationsSize ( Constants . RUNTIME_INVISIBLE_ANNOTATIONS ) ; } if ( lastRuntimeVisibleTypeAnnotation != null ) { ++ attributesCount ; size += lastRuntimeVisibleTypeAnnotation . computeAnnotationsSize ( Constants . RUNTIME_VISIBLE_TYPE_ANNOTATIONS ) ; } if ( lastRuntimeInvisibleTypeAnnotation != null ) { ++ attributesCount ; size += lastRuntimeInvisibleTypeAnnotation . computeAnnotationsSize ( Constants . RUNTIME_INVISIBLE_TYPE_ANNOTATIONS ) ; } if ( symbolTable . computeBootstrapMethodsSize ( ) > 0 ) { ++ attributesCount ; size += symbolTable . computeBootstrapMethodsSize ( ) ; } if ( moduleWriter != null ) { attributesCount += moduleWriter . getAttributeCount ( ) ; size += moduleWriter . computeAttributesSize ( ) ; } if ( nestHostClassIndex != 0 ) { ++ attributesCount ; size += 8 ; symbolTable . addConstantUtf8 ( Constants . NEST_HOST ) ; } if ( nestMemberClasses != null ) { ++ attributesCount ; size += 8 + nestMemberClasses . length ; symbolTable . addConstantUtf8 ( Constants . NEST_MEMBERS ) ; } if ( firstAttribute != null ) { attributesCount += firstAttribute . getAttributeCount ( ) ; size += firstAttribute . computeAttributesSize ( symbolTable ) ; } // IMPORTANT: this must be the last part of the ClassFile size computation, because the previous // statements can add attribute names to the constant pool, thereby changing its size! size += symbolTable . getConstantPoolLength ( ) ; int constantPoolCount = symbolTable . getConstantPoolCount ( ) ; if ( constantPoolCount > 0xFFFF ) { throw new ClassTooLargeException ( symbolTable . getClassName ( ) , constantPoolCount ) ; } // Second step: allocate a ByteVector of the correct size (in order to avoid any array copy in // dynamic resizes) and fill it with the ClassFile content. ByteVector result = new ByteVector ( size ) ; result . putInt ( 0xCAFEBABE ) . putInt ( version ) ; symbolTable . putConstantPool ( result ) ; int mask = ( version & 0xFFFF ) < Opcodes . V1_5 ? Opcodes . ACC_SYNTHETIC : 0 ; result . putShort ( accessFlags & ~ mask ) . putShort ( thisClass ) . putShort ( superClass ) ; result . putShort ( interfaceCount ) ; for ( int i = 0 ; i < interfaceCount ; ++ i ) { result . putShort ( interfaces [ i ] ) ; } result . putShort ( fieldsCount ) ; fieldWriter = firstField ; while ( fieldWriter != null ) { fieldWriter . putFieldInfo ( result ) ; fieldWriter = ( FieldWriter ) fieldWriter . fv ; } result . putShort ( methodsCount ) ; boolean hasFrames = false ; boolean hasAsmInstructions = false ; methodWriter = firstMethod ; while ( methodWriter != null ) { hasFrames |= methodWriter . hasFrames ( ) ; hasAsmInstructions |= methodWriter . hasAsmInstructions ( ) ; methodWriter . putMethodInfo ( result ) ; methodWriter = ( MethodWriter ) methodWriter . mv ; } // For ease of reference, we use here the same attribute order as in Section 4.7 of the JVMS. result . putShort ( attributesCount ) ; if ( innerClasses != null ) { result . putShort ( symbolTable . addConstantUtf8 ( Constants . INNER_CLASSES ) ) . putInt ( innerClasses . length + 2 ) . putShort ( numberOfInnerClasses ) . putByteArray ( innerClasses . data , 0 , innerClasses . length ) ; } if ( enclosingClassIndex != 0 ) { result . putShort ( symbolTable . addConstantUtf8 ( Constants . ENCLOSING_METHOD ) ) . putInt ( 4 ) . putShort ( enclosingClassIndex ) . putShort ( enclosingMethodIndex ) ; } if ( ( accessFlags & Opcodes . ACC_SYNTHETIC ) != 0 && ( version & 0xFFFF ) < Opcodes . V1_5 ) { result . putShort ( symbolTable . addConstantUtf8 ( Constants . SYNTHETIC ) ) . putInt ( 0 ) ; } if ( signatureIndex != 0 ) { result . putShort ( symbolTable . addConstantUtf8 ( Constants . SIGNATURE ) ) . putInt ( 2 ) . putShort ( signatureIndex ) ; } if ( sourceFileIndex != 0 ) { result . putShort ( symbolTable . addConstantUtf8 ( Constants . SOURCE_FILE ) ) . putInt ( 2 ) . putShort ( sourceFileIndex ) ; } if ( debugExtension != null ) { int length = debugExtension . length ; result . putShort ( symbolTable . addConstantUtf8 ( Constants . SOURCE_DEBUG_EXTENSION ) ) . putInt ( length ) . putByteArray ( debugExtension . data , 0 , length ) ; } if ( ( accessFlags & Opcodes . ACC_DEPRECATED ) != 0 ) { result . putShort ( symbolTable . addConstantUtf8 ( Constants . DEPRECATED ) ) . putInt ( 0 ) ; } if ( lastRuntimeVisibleAnnotation != null ) { lastRuntimeVisibleAnnotation . putAnnotations ( symbolTable . addConstantUtf8 ( Constants . RUNTIME_VISIBLE_ANNOTATIONS ) , result ) ; } if ( lastRuntimeInvisibleAnnotation != null ) { lastRuntimeInvisibleAnnotation . putAnnotations ( symbolTable . addConstantUtf8 ( Constants . RUNTIME_INVISIBLE_ANNOTATIONS ) , result ) ; } if ( lastRuntimeVisibleTypeAnnotation != null ) { lastRuntimeVisibleTypeAnnotation . putAnnotations ( symbolTable . addConstantUtf8 ( Constants . RUNTIME_VISIBLE_TYPE_ANNOTATIONS ) , result ) ; } if ( lastRuntimeInvisibleTypeAnnotation != null ) { lastRuntimeInvisibleTypeAnnotation . putAnnotations ( symbolTable . addConstantUtf8 ( Constants . RUNTIME_INVISIBLE_TYPE_ANNOTATIONS ) , result ) ; } symbolTable . putBootstrapMethods ( result ) ; if ( moduleWriter != null ) { moduleWriter . putAttributes ( result ) ; } if ( nestHostClassIndex != 0 ) { result . putShort ( symbolTable . addConstantUtf8 ( Constants . NEST_HOST ) ) . putInt ( 2 ) . putShort ( nestHostClassIndex ) ; } if ( nestMemberClasses != null ) { result . putShort ( symbolTable . addConstantUtf8 ( Constants . NEST_MEMBERS ) ) . putInt ( nestMemberClasses . length + 2 ) . putShort ( numberOfNestMemberClasses ) . putByteArray ( nestMemberClasses . data , 0 , nestMemberClasses . length ) ; } if ( firstAttribute != null ) { firstAttribute . putAttributes ( symbolTable , result ) ; } // Third step: replace the ASM specific instructions, if any. if ( hasAsmInstructions ) { return replaceAsmInstructions ( result . data , hasFrames ) ; } else { return result . data ; } }


Input: Returns the equivalent of the given class file with the ASM specific instructions replaced with standard ones . This is done with a ClassReader - &gt ; ClassWriter round trip . [CODESPLIT] private byte [ ] replaceAsmInstructions ( final byte [ ] classFile , final boolean hasFrames ) { final Attribute [ ] attributes = getAttributePrototypes ( ) ; firstField = null ; lastField = null ; firstMethod = null ; lastMethod = null ; lastRuntimeVisibleAnnotation = null ; lastRuntimeInvisibleAnnotation = null ; lastRuntimeVisibleTypeAnnotation = null ; lastRuntimeInvisibleTypeAnnotation = null ; moduleWriter = null ; nestHostClassIndex = 0 ; numberOfNestMemberClasses = 0 ; nestMemberClasses = null ; firstAttribute = null ; compute = hasFrames ? MethodWriter . COMPUTE_INSERTED_FRAMES : MethodWriter . COMPUTE_NOTHING ; new ClassReader ( classFile , 0 , /* checkClassVersion = */ false ) . accept ( this , attributes , ( hasFrames ? ClassReader . EXPAND_FRAMES : 0 ) | ClassReader . EXPAND_ASM_INSNS ) ; return toByteArray ( ) ; }


Input: Returns the prototypes of the attributes used by this class its fields and its methods . [CODESPLIT] private Attribute [ ] getAttributePrototypes ( ) { Attribute . Set attributePrototypes = new Attribute . Set ( ) ; attributePrototypes . addAttributes ( firstAttribute ) ; FieldWriter fieldWriter = firstField ; while ( fieldWriter != null ) { fieldWriter . collectAttributePrototypes ( attributePrototypes ) ; fieldWriter = ( FieldWriter ) fieldWriter . fv ; } MethodWriter methodWriter = firstMethod ; while ( methodWriter != null ) { methodWriter . collectAttributePrototypes ( attributePrototypes ) ; methodWriter = ( MethodWriter ) methodWriter . mv ; } return attributePrototypes . toArray ( ) ; }


Input: Adds a handle to the constant pool of the class being build . Does nothing if the constant pool already contains a similar item . <i > This method is intended for { @link Attribute } sub classes and is normally not needed by class generators or adapters . < / i > [CODESPLIT] public int newHandle ( final int tag , final String owner , final String name , final String descriptor , final boolean isInterface ) { return symbolTable . addConstantMethodHandle ( tag , owner , name , descriptor , isInterface ) . index ; }


Input: Adds a dynamic constant reference to the constant pool of the class being build . Does nothing if the constant pool already contains a similar item . <i > This method is intended for { @link Attribute } sub classes and is normally not needed by class generators or adapters . < / i > [CODESPLIT] public int newConstantDynamic ( final String name , final String descriptor , final Handle bootstrapMethodHandle , final Object ... bootstrapMethodArguments ) { return symbolTable . addConstantDynamic ( name , descriptor , bootstrapMethodHandle , bootstrapMethodArguments ) . index ; }


Input: Adds an invokedynamic reference to the constant pool of the class being build . Does nothing if the constant pool already contains a similar item . <i > This method is intended for { @link Attribute } sub classes and is normally not needed by class generators or adapters . < / i > [CODESPLIT] public int newInvokeDynamic ( final String name , final String descriptor , final Handle bootstrapMethodHandle , final Object ... bootstrapMethodArguments ) { return symbolTable . addConstantInvokeDynamic ( name , descriptor , bootstrapMethodHandle , bootstrapMethodArguments ) . index ; }


Input: Adds a field reference to the constant pool of the class being build . Does nothing if the constant pool already contains a similar item . <i > This method is intended for { @link Attribute } sub classes and is normally not needed by class generators or adapters . < / i > [CODESPLIT] public int newField ( final String owner , final String name , final String descriptor ) { return symbolTable . addConstantFieldref ( owner , name , descriptor ) . index ; }


Input: Adds a method reference to the constant pool of the class being build . Does nothing if the constant pool already contains a similar item . <i > This method is intended for { @link Attribute } sub classes and is normally not needed by class generators or adapters . < / i > [CODESPLIT] public int newMethod ( final String owner , final String name , final String descriptor , final boolean isInterface ) { return symbolTable . addConstantMethodref ( owner , name , descriptor , isInterface ) . index ; }


Input: Returns the common super type of the two given types . The default implementation of this method <i > loads< / i > the two given classes and uses the java . lang . Class methods to find the common super class . It can be overridden to compute this common super type in other ways in particular without actually loading any class or to take into account the class that is currently being generated by this ClassWriter which can of course not be loaded since it is under construction . [CODESPLIT] protected String getCommonSuperClass ( final String type1 , final String type2 ) { ClassLoader classLoader = getClassLoader ( ) ; Class < ? > class1 ; try { class1 = Class . forName ( type1 . replace ( ' ' , ' ' ) , false , classLoader ) ; } catch ( ClassNotFoundException e ) { throw new TypeNotPresentException ( type1 , e ) ; } Class < ? > class2 ; try { class2 = Class . forName ( type2 . replace ( ' ' , ' ' ) , false , classLoader ) ; } catch ( ClassNotFoundException e ) { throw new TypeNotPresentException ( type2 , e ) ; } if ( class1 . isAssignableFrom ( class2 ) ) { return type1 ; } if ( class2 . isAssignableFrom ( class1 ) ) { return type2 ; } if ( class1 . isInterface ( ) || class2 . isInterface ( ) ) { return "java/lang/Object" ; } else { do { class1 = class1 . getSuperclass ( ) ; } while ( ! class1 . isAssignableFrom ( class2 ) ) ; return class1 . getName ( ) . replace ( ' ' , ' ' ) ; } }


Input: Registers default set of SQL types . [CODESPLIT] public void registerDefaults ( ) { register ( Integer . class , IntegerSqlType . class ) ; register ( int . class , IntegerSqlType . class ) ; register ( MutableInteger . class , IntegerSqlType . class ) ; register ( Float . class , FloatSqlType . class ) ; register ( float . class , FloatSqlType . class ) ; register ( MutableFloat . class , FloatSqlType . class ) ; register ( Double . class , DoubleSqlType . class ) ; register ( double . class , DoubleSqlType . class ) ; register ( MutableDouble . class , DoubleSqlType . class ) ; register ( Byte . class , ByteSqlType . class ) ; register ( byte . class , ByteSqlType . class ) ; register ( MutableByte . class , ByteSqlType . class ) ; register ( Boolean . class , BooleanSqlType . class ) ; register ( boolean . class , BooleanSqlType . class ) ; register ( MutableBoolean . class , BooleanSqlType . class ) ; register ( Long . class , LongSqlType . class ) ; register ( long . class , LongSqlType . class ) ; register ( MutableLong . class , LongSqlType . class ) ; register ( Short . class , ShortSqlType . class ) ; register ( short . class , ShortSqlType . class ) ; register ( MutableShort . class , ShortSqlType . class ) ; register ( Character . class , CharacterSqlType . class ) ; register ( char . class , CharacterSqlType . class ) ; register ( BigDecimal . class , BigDecimalSqlType . class ) ; register ( BigInteger . class , BigIntegerSqlType . class ) ; register ( String . class , StringSqlType . class ) ; register ( LocalDateTime . class , LocalDateTimeSqlType . class ) ; register ( LocalDate . class , LocalDateSqlType . class ) ; register ( LocalTime . class , LocalTimeSqlType . class ) ; register ( Date . class , SqlDateSqlType . class ) ; register ( Timestamp . class , TimestampSqlType . class ) ; register ( Time . class , TimeSqlType . class ) ; register ( java . util . Date . class , DateSqlType . class ) ; register ( JulianDate . class , JulianDateSqlType . class ) ; register ( byte [ ] . class , ByteArraySqlType . class ) ; register ( URL . class , URLSqlType . class ) ; register ( Blob . class , BlobSqlType . class ) ; register ( Clob . class , ClobSqlType . class ) ; register ( Array . class , SqlArraySqlType . class ) ; register ( Ref . class , SqlRefSqlType . class ) ; }


Input: Registers sql type for provided type . [CODESPLIT] public void register ( final Class type , final Class < ? extends SqlType > sqlTypeClass ) { types . put ( type , lookupSqlType ( sqlTypeClass ) ) ; }


Input: Retrieves SQL type for provided type . All subclasses and interfaces are examined for matching sql type . [CODESPLIT] public SqlType lookup ( final Class clazz ) { SqlType sqlType ; for ( Class x = clazz ; x != null ; x = x . getSuperclass ( ) ) { sqlType = types . get ( clazz ) ; if ( sqlType != null ) { return sqlType ; } Class [ ] interfaces = x . getInterfaces ( ) ; for ( Class i : interfaces ) { sqlType = types . get ( i ) ; if ( sqlType != null ) { return sqlType ; } } } return null ; }


Input: Returns sql type instance . Instances are stored for better performances . [CODESPLIT] public SqlType lookupSqlType ( final Class < ? extends SqlType > sqlTypeClass ) { SqlType sqlType = sqlTypes . get ( sqlTypeClass ) ; if ( sqlType == null ) { try { sqlType = ClassUtil . newInstance ( sqlTypeClass ) ; } catch ( Exception ex ) { throw new DbSqlException ( "SQL type not found: " + sqlTypeClass . getSimpleName ( ) , ex ) ; } sqlTypes . put ( sqlTypeClass , sqlType ) ; } return sqlType ; }


Input: Creates SOCKS4 proxy . [CODESPLIT] public static ProxyInfo socks4Proxy ( final String proxyAddress , final int proxyPort , final String proxyUser ) { return new ProxyInfo ( ProxyType . SOCKS4 , proxyAddress , proxyPort , proxyUser , null ) ; }


Input: Creates SOCKS5 proxy . [CODESPLIT] public static ProxyInfo socks5Proxy ( final String proxyAddress , final int proxyPort , final String proxyUser , final String proxyPassword ) { return new ProxyInfo ( ProxyType . SOCKS5 , proxyAddress , proxyPort , proxyUser , proxyPassword ) ; }


Input: Creates HTTP proxy . [CODESPLIT] public static ProxyInfo httpProxy ( final String proxyAddress , final int proxyPort , final String proxyUser , final String proxyPassword ) { return new ProxyInfo ( ProxyType . HTTP , proxyAddress , proxyPort , proxyUser , proxyPassword ) ; }


Input: Returns total number of transactions associated with current thread . [CODESPLIT] public int totalThreadTransactions ( ) { ArrayList < JtxTransaction > txList = txStack . get ( ) ; if ( txList == null ) { return 0 ; } return txList . size ( ) ; }


Input: Returns total number of transactions of the specified status associated with current thread . [CODESPLIT] public int totalThreadTransactionsWithStatus ( final JtxStatus status ) { ArrayList < JtxTransaction > txlist = txStack . get ( ) ; if ( txlist == null ) { return 0 ; } int count = 0 ; for ( JtxTransaction tx : txlist ) { if ( tx . getStatus ( ) == status ) { count ++ ; } } return count ; }


Input: Returns <code > true< / code > if provided transaction is associated with current thread . [CODESPLIT] public boolean isAssociatedWithThread ( final JtxTransaction tx ) { ArrayList < JtxTransaction > txList = txStack . get ( ) ; if ( txList == null ) { return false ; } return txList . contains ( tx ) ; }


Input: Removes transaction association with current thread . Transaction should be properly handled ( committed or rolledback ) before removing from current thread . Also removes thread list from this thread . [CODESPLIT] protected boolean removeTransaction ( final JtxTransaction tx ) { ArrayList < JtxTransaction > txList = txStack . get ( ) ; if ( txList == null ) { return false ; } boolean removed = txList . remove ( tx ) ; if ( removed ) { totalTransactions -- ; } if ( txList . isEmpty ( ) ) { txStack . remove ( ) ; } return removed ; }


Input: Returns last transaction associated with current thread or <code > null< / code > when thread has no associated transactions created by this transaction manager . [CODESPLIT] public JtxTransaction getTransaction ( ) { ArrayList < JtxTransaction > txlist = txStack . get ( ) ; if ( txlist == null ) { return null ; } if ( txlist . isEmpty ( ) ) { return null ; } return txlist . get ( txlist . size ( ) - 1 ) ; // get last }


Input: Associate transaction to current thread . [CODESPLIT] protected void associateTransaction ( final JtxTransaction tx ) { totalTransactions ++ ; ArrayList < JtxTransaction > txList = txStack . get ( ) ; if ( txList == null ) { txList = new ArrayList <> ( ) ; txStack . set ( txList ) ; } txList . add ( tx ) ; // add last }


Input: Creates new { [CODESPLIT] protected JtxTransaction createNewTransaction ( final JtxTransactionMode tm , final Object scope , final boolean active ) { return new JtxTransaction ( this , tm , scope , active ) ; }


Input: Requests transaction with specified { [CODESPLIT] public JtxTransaction requestTransaction ( final JtxTransactionMode mode , final Object scope ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "Requesting TX " + mode . toString ( ) ) ; } JtxTransaction currentTx = getTransaction ( ) ; if ( ! isNewTxScope ( currentTx , scope ) ) { return currentTx ; } switch ( mode . getPropagationBehavior ( ) ) { case PROPAGATION_REQUIRED : return propRequired ( currentTx , mode , scope ) ; case PROPAGATION_SUPPORTS : return propSupports ( currentTx , mode , scope ) ; case PROPAGATION_MANDATORY : return propMandatory ( currentTx , mode , scope ) ; case PROPAGATION_REQUIRES_NEW : return propRequiresNew ( currentTx , mode , scope ) ; case PROPAGATION_NOT_SUPPORTED : return propNotSupported ( currentTx , mode , scope ) ; case PROPAGATION_NEVER : return propNever ( currentTx , mode , scope ) ; } throw new JtxException ( "Invalid TX propagation value: " + mode . getPropagationBehavior ( ) . value ( ) ) ; }


Input: Returns <code > true< / code > if scope is specified and it is different then of existing transaction . [CODESPLIT] protected boolean isNewTxScope ( final JtxTransaction currentTx , final Object destScope ) { if ( ignoreScope ) { return true ; } if ( currentTx == null ) { return true ; } if ( destScope == null ) { return true ; } if ( currentTx . getScope ( ) == null ) { return true ; } return ! destScope . equals ( currentTx . getScope ( ) ) ; }


Input: Check if propagation of a transaction is possible due to source and destination transaction modes . [CODESPLIT] protected void continueTx ( final JtxTransaction sourceTx , final JtxTransactionMode destMode ) { if ( ! validateExistingTransaction ) { return ; } JtxTransactionMode sourceMode = sourceTx . getTransactionMode ( ) ; JtxIsolationLevel destIsolationLevel = destMode . getIsolationLevel ( ) ; if ( destIsolationLevel != ISOLATION_DEFAULT ) { JtxIsolationLevel currentIsolationLevel = sourceMode . getIsolationLevel ( ) ; if ( currentIsolationLevel != destIsolationLevel ) { throw new JtxException ( "Participating TX specifies isolation level: " + destIsolationLevel + " which is incompatible with existing TX: " + currentIsolationLevel ) ; } } if ( ( ! destMode . isReadOnly ( ) ) && ( sourceMode . isReadOnly ( ) ) ) { throw new JtxException ( "Participating TX is not marked as read-only, but existing TX is" ) ; } }


Input: Propagation : REQUIRED <pre > { [CODESPLIT] protected JtxTransaction propRequired ( JtxTransaction currentTx , final JtxTransactionMode mode , final Object scope ) { if ( ( currentTx == null ) || ( currentTx . isNoTransaction ( ) ) ) { currentTx = createNewTransaction ( mode , scope , true ) ; } else { continueTx ( currentTx , mode ) ; } return currentTx ; }


Input: Propagation : REQUIRES_NEW <pre > { [CODESPLIT] @ SuppressWarnings ( { "UnusedDeclaration" } ) protected JtxTransaction propRequiresNew ( final JtxTransaction currentTx , final JtxTransactionMode mode , final Object scope ) { return createNewTransaction ( mode , scope , true ) ; }


Input: Propagation : SUPPORTS <pre > { [CODESPLIT] protected JtxTransaction propSupports ( JtxTransaction currentTx , final JtxTransactionMode mode , final Object scope ) { if ( ( currentTx != null ) && ( ! currentTx . isNoTransaction ( ) ) ) { continueTx ( currentTx , mode ) ; } if ( currentTx == null ) { currentTx = createNewTransaction ( mode , scope , false ) ; } return currentTx ; }


Input: Propagation : MANDATORY <pre > { [CODESPLIT] @ SuppressWarnings ( { "UnusedDeclaration" } ) protected JtxTransaction propMandatory ( final JtxTransaction currentTx , final JtxTransactionMode mode , final Object scope ) { if ( ( currentTx == null ) || ( currentTx . isNoTransaction ( ) ) ) { throw new JtxException ( "No existing TX found for TX marked with propagation 'mandatory'" ) ; } continueTx ( currentTx , mode ) ; return currentTx ; }


Input: Propagation : NOT_SUPPORTED <pre > { [CODESPLIT] protected JtxTransaction propNotSupported ( final JtxTransaction currentTx , final JtxTransactionMode mode , final Object scope ) { if ( currentTx == null ) { return createNewTransaction ( mode , scope , false ) ; } if ( currentTx . isNoTransaction ( ) ) { return currentTx ; } return createNewTransaction ( mode , scope , false ) ; }


Input: Propagation : NEVER <pre > { [CODESPLIT] protected JtxTransaction propNever ( JtxTransaction currentTx , final JtxTransactionMode mode , final Object scope ) { if ( ( currentTx != null ) && ( ! currentTx . isNoTransaction ( ) ) ) { throw new JtxException ( "Existing TX found for TX marked with propagation 'never'" ) ; } if ( currentTx == null ) { currentTx = createNewTransaction ( mode , scope , false ) ; } return currentTx ; }


Input: Registers new { [CODESPLIT] public void registerResourceManager ( final JtxResourceManager resourceManager ) { if ( ( oneResourceManager ) && ( ! resourceManagers . isEmpty ( ) ) ) { throw new JtxException ( "TX manager allows only one resource manager" ) ; } this . resourceManagers . put ( resourceManager . getResourceType ( ) , resourceManager ) ; }


Input: Lookups resource manager for provided type . Throws an exception if provider doesn t exists . [CODESPLIT] protected < E > JtxResourceManager < E > lookupResourceManager ( final Class < E > resourceType ) { //noinspection unchecked JtxResourceManager < E > resourceManager = this . resourceManagers . get ( resourceType ) ; if ( resourceManager == null ) { throw new JtxException ( "No registered resource manager for resource type: " + resourceType . getSimpleName ( ) ) ; } return resourceManager ; }


Input: Closes transaction manager . All registered { [CODESPLIT] public void close ( ) { this . resourceManagers . forEachValue ( resourceManager -> { try { resourceManager . close ( ) ; } catch ( Exception ex ) { // ignore } } ) ; resourceManagers . clear ( ) ; }


Input: Creates proxy object . [CODESPLIT] protected C createProxyObject ( Class < C > target ) { target = ProxettaUtil . resolveTargetClass ( target ) ; Class proxyClass = cache . get ( target ) ; if ( proxyClass == null ) { proxyClass = proxetta . defineProxy ( target ) ; cache . put ( target , proxyClass ) ; } C proxy ; try { proxy = ( C ) ClassUtil . newInstance ( proxyClass ) ; } catch ( Exception ex ) { throw new PathrefException ( ex ) ; } return proxy ; }


Input: Appends method name to existing path . [CODESPLIT] protected void append ( final String methodName ) { if ( path . length ( ) != 0 ) { path += StringPool . DOT ; } if ( methodName . startsWith ( StringPool . LEFT_SQ_BRACKET ) ) { path = StringUtil . substring ( path , 0 , - 1 ) ; } path += methodName ; }


Input: Static factory of next target . It handles special cases of maps sets and lists . In case target can not be proxified ( like for Java classes ) it returns <code > null< / code > . [CODESPLIT] @ SuppressWarnings ( "unchecked" ) public < T > T continueWith ( final Object currentInstance , final String methodName , final Class < T > target ) { Class currentClass = currentInstance . getClass ( ) ; Method method ; try { method = currentClass . getDeclaredMethod ( methodName ) ; } catch ( NoSuchMethodException e ) { throw new PathrefException ( "Not a getter: " + methodName , e ) ; } if ( ! ClassUtil . isBeanPropertyGetter ( method ) ) { throw new PathrefException ( "Not a getter: " + methodName ) ; } String getterName = ClassUtil . getBeanPropertyGetterName ( method ) ; append ( getterName ) ; if ( ClassUtil . isTypeOf ( target , List . class ) ) { final Class componentType = ClassUtil . getComponentType ( method . getGenericReturnType ( ) , currentClass , 0 ) ; if ( componentType == null ) { throw new PathrefException ( "Unknown component name for: " + methodName ) ; } return ( T ) new ArrayList ( ) { @ Override public Object get ( final int index ) { if ( index >= 0 ) { append ( "[" + index + "]" ) ; } return new Pathref <> ( componentType , Pathref . this ) . to ( ) ; } } ; } try { return new Pathref <> ( target , this ) . to ( ) ; } catch ( Exception ex ) { return null ; } }


Input: ----------------------------------------------------------------------- Apache Commons Codec - Base64 [CODESPLIT] @ Benchmark public String encode_Apache_Base64 ( ) { return org . apache . commons . codec . binary . Base64 . encodeBase64String ( to_be_encoded ) ; }


Input: Puts the text to the left and pads with spaces until the size is reached . [CODESPLIT] public static String alignLeftAndPad ( final String text , final int size ) { int textLength = text . length ( ) ; if ( textLength > size ) { return text . substring ( 0 , size ) ; } final StringBuilder sb = new StringBuilder ( size ) ; sb . append ( text ) ; while ( textLength ++ < size ) { sb . append ( ' ' ) ; } return sb . toString ( ) ; }


Input: Formats byte size to human readable bytecount . https : // stackoverflow . com / questions / 3758606 / how - to - convert - byte - size - into - human - readable - format - in - java / 3758880#3758880 [CODESPLIT] public static String humanReadableByteCount ( final long bytes , final boolean useSi ) { final int unit = useSi ? 1000 : 1024 ; if ( bytes < unit ) return bytes + " B" ; final int exp = ( int ) ( Math . log ( bytes ) / Math . log ( unit ) ) ; final String pre = ( useSi ? "kMGTPE" : "KMGTPE" ) . charAt ( exp - 1 ) + ( useSi ? "" : "i" ) ; return String . format ( "%.1f %sB" , bytes / Math . pow ( unit , exp ) , pre ) ; }


Input: Converts object into pretty string . All arrays are iterated . [CODESPLIT] public static String toPrettyString ( final Object value ) { if ( value == null ) { return StringPool . NULL ; } final Class < ? > type = value . getClass ( ) ; if ( type . isArray ( ) ) { final Class componentType = type . getComponentType ( ) ; if ( componentType . isPrimitive ( ) ) { final StringBuilder sb = new StringBuilder ( ) ; sb . append ( ' ' ) ; if ( componentType == int . class ) { sb . append ( ArraysUtil . toString ( ( int [ ] ) value ) ) ; } else if ( componentType == long . class ) { sb . append ( ArraysUtil . toString ( ( long [ ] ) value ) ) ; } else if ( componentType == double . class ) { sb . append ( ArraysUtil . toString ( ( double [ ] ) value ) ) ; } else if ( componentType == float . class ) { sb . append ( ArraysUtil . toString ( ( float [ ] ) value ) ) ; } else if ( componentType == boolean . class ) { sb . append ( ArraysUtil . toString ( ( boolean [ ] ) value ) ) ; } else if ( componentType == short . class ) { sb . append ( ArraysUtil . toString ( ( short [ ] ) value ) ) ; } else if ( componentType == byte . class ) { sb . append ( ArraysUtil . toString ( ( byte [ ] ) value ) ) ; } else { throw new IllegalArgumentException ( ) ; } sb . append ( ' ' ) ; return sb . toString ( ) ; } else { final StringBuilder sb = new StringBuilder ( ) ; sb . append ( ' ' ) ; final Object [ ] array = ( Object [ ] ) value ; for ( int i = 0 ; i < array . length ; i ++ ) { if ( i > 0 ) { sb . append ( ' ' ) ; } sb . append ( toPrettyString ( array [ i ] ) ) ; } sb . append ( ' ' ) ; return sb . toString ( ) ; } } else if ( value instanceof Iterable ) { final Iterable iterable = ( Iterable ) value ; final StringBuilder sb = new StringBuilder ( ) ; sb . append ( ' ' ) ; int i = 0 ; for ( final Object o : iterable ) { if ( i > 0 ) { sb . append ( ' ' ) ; } sb . append ( toPrettyString ( o ) ) ; i ++ ; } sb . append ( ' ' ) ; return sb . toString ( ) ; } return value . toString ( ) ; }


Input: Changes CamelCase string to lower case words separated by provided separator character . The following translations are applied : <ul > <li > Every upper case letter in the CamelCase name is translated into two characters a separator and the lower case equivalent of the target character with three exceptions . <ol > <li > For contiguous sequences of upper case letters characters after the first character are replaced only by their lower case equivalent and are not preceded by a separator ( <code > theFOO< / code > to <code > the_foo< / code > ) . <li > An upper case character in the first position of the CamelCase name is not preceded by a separator character and is translated only to its lower case equivalent . ( <code > Foo< / code > to <code > foo< / code > and not <code > _foo< / code > ) <li > An upper case character in the CamelCase name that is already preceded by a separator character is translated only to its lower case equivalent and is not preceded by an additional separator . ( <code > user_Name< / code > to <code > user_name< / code > and not <code > user__name< / code > . < / ol > <li > If the CamelCase name starts with a separator then that separator is not included in the translated name unless the CamelCase name is just one character in length i . e . it is the separator character . This applies only to the first character of the CamelCase name . < / ul > [CODESPLIT] public static String fromCamelCase ( final String input , final char separator ) { final int length = input . length ( ) ; final StringBuilder result = new StringBuilder ( length * 2 ) ; int resultLength = 0 ; boolean prevTranslated = false ; for ( int i = 0 ; i < length ; i ++ ) { char c = input . charAt ( i ) ; if ( i > 0 || c != separator ) { // skip first starting separator if ( Character . isUpperCase ( c ) ) { if ( ! prevTranslated && resultLength > 0 && result . charAt ( resultLength - 1 ) != separator ) { result . append ( separator ) ; resultLength ++ ; } c = Character . toLowerCase ( c ) ; prevTranslated = true ; } else { prevTranslated = false ; } result . append ( c ) ; resultLength ++ ; } } return resultLength > 0 ? result . toString ( ) : input ; }


Input: Converts separated string value to CamelCase . [CODESPLIT] public static String toCamelCase ( final String input , final boolean firstCharUppercase , final char separator ) { final int length = input . length ( ) ; final StringBuilder sb = new StringBuilder ( length ) ; boolean upperCase = firstCharUppercase ; for ( int i = 0 ; i < length ; i ++ ) { final char ch = input . charAt ( i ) ; if ( ch == separator ) { upperCase = true ; } else if ( upperCase ) { sb . append ( Character . toUpperCase ( ch ) ) ; upperCase = false ; } else { sb . append ( ch ) ; } } return sb . toString ( ) ; }


Input: Formats provided string as paragraph . [CODESPLIT] public static String formatParagraph ( final String src , final int len , final boolean breakOnWhitespace ) { StringBuilder str = new StringBuilder ( ) ; int total = src . length ( ) ; int from = 0 ; while ( from < total ) { int to = from + len ; if ( to >= total ) { to = total ; } else if ( breakOnWhitespace ) { int ndx = StringUtil . lastIndexOfWhitespace ( src , to - 1 , from ) ; if ( ndx != - 1 ) { to = ndx + 1 ; } } int cutFrom = StringUtil . indexOfNonWhitespace ( src , from , to ) ; if ( cutFrom != - 1 ) { int cutTo = StringUtil . lastIndexOfNonWhitespace ( src , to - 1 , from ) + 1 ; str . append ( src , cutFrom , cutTo ) ; } str . append ( ' ' ) ; from = to ; } return str . toString ( ) ; }


Input: Converts all tabs on a line to spaces according to the provided tab width . This is not a simple tab to spaces replacement since the resulting indentation remains the same . [CODESPLIT] public static String convertTabsToSpaces ( final String line , final int tabWidth ) { int tab_index , tab_size ; int last_tab_index = 0 ; int added_chars = 0 ; if ( tabWidth == 0 ) { return StringUtil . remove ( line , ' ' ) ; } StringBuilder result = new StringBuilder ( ) ; while ( ( tab_index = line . indexOf ( ' ' , last_tab_index ) ) != - 1 ) { tab_size = tabWidth - ( ( tab_index + added_chars ) % tabWidth ) ; if ( tab_size == 0 ) { tab_size = tabWidth ; } added_chars += tab_size - 1 ; result . append ( line , last_tab_index , tab_index ) ; result . append ( StringUtil . repeat ( ' ' , tab_size ) ) ; last_tab_index = tab_index + 1 ; } if ( last_tab_index == 0 ) { return line ; } result . append ( line . substring ( last_tab_index ) ) ; return result . toString ( ) ; }


Input: Escapes a string using java rules . [CODESPLIT] public static String escapeJava ( final String string ) { int strLen = string . length ( ) ; StringBuilder sb = new StringBuilder ( strLen ) ; for ( int i = 0 ; i < strLen ; i ++ ) { char c = string . charAt ( i ) ; switch ( c ) { case ' ' : sb . append ( "\\b" ) ; break ; case ' ' : sb . append ( "\\t" ) ; break ; case ' ' : sb . append ( "\\n" ) ; break ; case ' ' : sb . append ( "\\f" ) ; break ; case ' ' : sb . append ( "\\r" ) ; break ; case ' ' : sb . append ( "\\\"" ) ; break ; case ' ' : sb . append ( "\\\\" ) ; break ; default : if ( ( c < 32 ) || ( c > 127 ) ) { String hex = Integer . toHexString ( c ) ; sb . append ( "\\u" ) ; for ( int k = hex . length ( ) ; k < 4 ; k ++ ) { sb . append ( ' ' ) ; } sb . append ( hex ) ; } else { sb . append ( c ) ; } } } return sb . toString ( ) ; }


Input: Unescapes a string using java rules . [CODESPLIT] public static String unescapeJava ( final String str ) { char [ ] chars = str . toCharArray ( ) ; StringBuilder sb = new StringBuilder ( str . length ( ) ) ; for ( int i = 0 ; i < chars . length ; i ++ ) { char c = chars [ i ] ; if ( c != ' ' ) { sb . append ( c ) ; continue ; } i ++ ; c = chars [ i ] ; switch ( c ) { case ' ' : sb . append ( ' ' ) ; break ; case ' ' : sb . append ( ' ' ) ; break ; case ' ' : sb . append ( ' ' ) ; break ; case ' ' : sb . append ( ' ' ) ; break ; case ' ' : sb . append ( ' ' ) ; break ; case ' ' : sb . append ( ' ' ) ; break ; case ' ' : sb . append ( ' ' ) ; break ; case ' ' : char hex = ( char ) Integer . parseInt ( new String ( chars , i + 1 , 4 ) , 16 ) ; sb . append ( hex ) ; i += 4 ; break ; default : throw new IllegalArgumentException ( "Invalid escaping character: " + c ) ; } } return sb . toString ( ) ; }


Input: Shortcut for checking the annotation on annotated element and returning either the values or { [CODESPLIT] public static TransactionAnnotationValues of ( final AnnotationParser annotationParser , final AnnotatedElement annotatedElement ) { if ( ! annotationParser . hasAnnotationOn ( annotatedElement ) ) { return null ; } return new TransactionAnnotationValues ( annotationParser . of ( annotatedElement ) ) ; }


Input: ---------------------------------------------------------------- core [CODESPLIT] protected Object lookupMixingScopedBean ( final BeanDefinition def , final BeanReferences refNames ) { final boolean mixing = petiteConfig . wireScopedProxy || petiteConfig . detectMixedScopes ; Object value = null ; if ( mixing ) { final BeanDefinition refBeanDefinition = lookupBeanDefinitions ( refNames ) ; if ( refBeanDefinition != null ) { value = scopedProxyManager . lookupValue ( PetiteContainer . this , def , refBeanDefinition ) ; } } if ( value == null ) { value = PetiteContainer . this . getBean ( refNames ) ; } return value ; }


Input: Returns Petite bean instance . Bean name will be resolved from provided type . [CODESPLIT] @ SuppressWarnings ( { "unchecked" } ) public < T > T getBean ( final Class < T > type ) { String name = resolveBeanName ( type ) ; return ( T ) getBean ( name ) ; }


Input: Returns Petite bean instance named as one of the provided names . Returns { [CODESPLIT] protected Object getBean ( final BeanReferences beanReferences ) { final int total = beanReferences . size ( ) ; for ( int i = 0 ; i < total ; i ++ ) { String name = beanReferences . name ( i ) ; if ( name != null ) { Object bean = getBean ( name ) ; if ( bean != null ) { return bean ; } } } return null ; }


Input: Returns Petite bean instance . Petite container will find the bean in corresponding scope and all its dependencies either by constructor or property injection . When using constructor injection cyclic dependencies can not be prevented but at least they are detected . [CODESPLIT] public < T > T getBean ( final String name ) { // Lookup for registered bean definition. BeanDefinition def = lookupBeanDefinition ( name ) ; if ( def == null ) { // try provider ProviderDefinition providerDefinition = providers . get ( name ) ; if ( providerDefinition != null ) { return ( T ) invokeProvider ( providerDefinition ) ; } return null ; } // Find the bean in its scope Object bean = def . scopeLookup ( ) ; if ( bean == null ) { // Create new bean in the scope initBeanDefinition ( def ) ; final BeanData beanData = new BeanData ( this , def ) ; registerBeanAndWireAndInjectParamsAndInvokeInitMethods ( beanData ) ; bean = beanData . bean ( ) ; } return ( T ) bean ; }