signature:
public class StringUtil { /** * Returns indexes of the first string region . Region is defined by its left and right boundary .
 * Return value is an array of the following indexes :
 * < ul >
 * < li > start of left boundary index < / li >
 * < li > region start index , i . e . end of left boundary < / li >
 * < li > region end index , i . e . start of right boundary < / li >
 * < li > end of right boundary index < / li >
 * < / ul >
 * Escape character may be used to prefix boundaries so they can be ignored .
 * Double escaped region will be found , and first index of the result will be
 * decreased to include one escape character .
 * If region is not founded , < code > null < / code > is returned . */
public static int [ ] indexOfRegion ( final String string , final String leftBoundary , final String rightBoundary , final char escape , final int offset ) { } }

implementation:
int ndx = offset ; int [ ] res = new int [ 4 ] ; while ( true ) { ndx = string . indexOf ( leftBoundary , ndx ) ; if ( ndx == - 1 ) { return null ; } int leftBoundaryLen = leftBoundary . length ( ) ; if ( ndx > 0 ) { if ( string . charAt ( ndx - 1 ) == escape ) { // check previous char
boolean cont = true ; if ( ndx > 1 ) { if ( string . charAt ( ndx - 2 ) == escape ) { // check double escapes
ndx -- ; leftBoundaryLen ++ ; cont = false ; } } if ( cont ) { ndx += leftBoundaryLen ; continue ; } } } res [ 0 ] = ndx ; ndx += leftBoundaryLen ; res [ 1 ] = ndx ; while ( true ) { // find right boundary
ndx = string . indexOf ( rightBoundary , ndx ) ; if ( ndx == - 1 ) { return null ; } if ( ndx > 0 ) { if ( string . charAt ( ndx - 1 ) == escape ) { ndx += rightBoundary . length ( ) ; continue ; } } res [ 2 ] = ndx ; res [ 3 ] = ndx + rightBoundary . length ( ) ; return res ; } }


signature:
public class StringUtil { /** * Joins an collection of objects into one string with separator . */
public static String join ( final Collection collection , final char separator ) { } }

implementation: if ( collection == null ) { return null ; } if ( collection . size ( ) == 0 ) { return StringPool . EMPTY ; } final StringBuilder sb = new StringBuilder ( collection . size ( ) * 16 ) ; final Iterator it = collection . iterator ( ) ; for ( int i = 0 ; i < collection . size ( ) ; i ++ ) { if ( i > 0 ) { sb . append ( separator ) ; } sb . append ( it . next ( ) ) ; } return sb . toString ( ) ;


signature:
public class StringUtil { /** * Joins an array of objects into one string with separator . */
public static String join ( final Object [ ] array , final String separator ) { } }

implementation: if ( array == null ) { return null ; } if ( array . length == 0 ) { return StringPool . EMPTY ; } if ( array . length == 1 ) { return String . valueOf ( array [ 0 ] ) ; } final StringBuilder sb = new StringBuilder ( array . length * 16 ) ; for ( int i = 0 ; i < array . length ; i ++ ) { if ( i > 0 ) { sb . append ( separator ) ; } sb . append ( array [ i ] ) ; } return sb . toString ( ) ;


signature:
public class StringUtil { /** * Converts string charset . If charset names are the same , the same string is returned . */
public static String convertCharset ( final String source , final String srcCharsetName , final String newCharsetName ) { } }

implementation: if ( srcCharsetName . equals ( newCharsetName ) ) { return source ; } return StringUtil . newString ( StringUtil . getBytes ( source , srcCharsetName ) , newCharsetName ) ;


signature:
public class StringUtil { /** * Safely compares provided char with char on given location . */
public static boolean isCharAtEqual ( final String string , final int index , final char charToCompare ) { } }

implementation: if ( ( index < 0 ) || ( index >= string . length ( ) ) ) { return false ; } return string . charAt ( index ) == charToCompare ;


signature:
public class StringUtil { /** * Surrounds the string with provided prefix and suffix if such missing from string . */
public static String surround ( String string , final String prefix , final String suffix ) { } }

implementation: if ( ! string . startsWith ( prefix ) ) { string = prefix + string ; } if ( ! string . endsWith ( suffix ) ) { string += suffix ; } return string ;


signature:
public class StringUtil { /** * Inserts prefix if doesn ' t exist . */
public static String prefix ( String string , final String prefix ) { } }

implementation: if ( ! string . startsWith ( prefix ) ) { string = prefix + string ; } return string ;


signature:
public class StringUtil { /** * Appends suffix if doesn ' t exist . */
public static String suffix ( String string , final String suffix ) { } }

implementation: if ( ! string . endsWith ( suffix ) ) { string += suffix ; } return string ;


signature:
public class StringUtil { /** * Cuts the string from beginning to the first index of provided substring . */
public static String cutToIndexOf ( String string , final String substring ) { } }

implementation: int i = string . indexOf ( substring ) ; if ( i != - 1 ) { string = string . substring ( 0 , i ) ; } return string ;


signature:
public class StringUtil { /** * Cuts the string from the first index of provided substring to the end . */
public static String cutFromIndexOf ( String string , final String substring ) { } }

implementation: int i = string . indexOf ( substring ) ; if ( i != - 1 ) { string = string . substring ( i ) ; } return string ;


signature:
public class StringUtil { /** * Cuts prefix if exists . */
public static String cutPrefix ( String string , final String prefix ) { } }

implementation: if ( string . startsWith ( prefix ) ) { string = string . substring ( prefix . length ( ) ) ; } return string ;


signature:
public class StringUtil { /** * Cuts sufix if exists . */
public static String cutSuffix ( String string , final String suffix ) { } }

implementation: if ( string . endsWith ( suffix ) ) { string = string . substring ( 0 , string . length ( ) - suffix . length ( ) ) ; } return string ;


signature:
public class StringUtil { /** * Removes surrounding prefix and suffixes . */
public static String cutSurrounding ( final String string , final String prefix , final String suffix ) { } }

implementation: int start = 0 ; int end = string . length ( ) ; if ( string . startsWith ( prefix ) ) { start = prefix . length ( ) ; } if ( string . endsWith ( suffix ) ) { end -= suffix . length ( ) ; } if ( end <= start ) { return StringPool . EMPTY ; } return string . substring ( start , end ) ;


signature:
public class StringUtil { /** * Cuts a string between two other strings . If either of left and right
 * is missing , nothing will be cut and < code > null < / code > is returned .
 * If indexes of left or right strings are wrong , empty string is returned . */
public static String cutBetween ( final String string , final String left , final String right ) { } }

implementation: int leftNdx = string . indexOf ( left ) ; if ( leftNdx == - 1 ) { return null ; } int rightNdx = string . indexOf ( right ) ; if ( rightNdx == - 1 ) { return null ; } leftNdx += left . length ( ) ; if ( leftNdx >= rightNdx ) { return StringPool . EMPTY ; } return string . substring ( leftNdx , rightNdx ) ;


signature:
public class StringUtil { /** * Returns < code > true < / code > if character at provided index position is escaped
 * by escape character . */
public static boolean isCharAtEscaped ( final String src , int ndx , final char escapeChar ) { } }

implementation: if ( ndx == 0 ) { return false ; } ndx -- ; return src . charAt ( ndx ) == escapeChar ;


signature:
public class StringUtil { /** * Inserts a string on provided offset . */
public static String insert ( final String src , final String insert , int offset ) { } }

implementation: if ( offset < 0 ) { offset = 0 ; } if ( offset > src . length ( ) ) { offset = src . length ( ) ; } StringBuilder sb = new StringBuilder ( src ) ; sb . insert ( offset , insert ) ; return sb . toString ( ) ;


signature:
public class StringUtil { /** * Creates a new string that contains the provided string a number of times . */
public static String repeat ( final String source , int count ) { } }

implementation: StringBand result = new StringBand ( count ) ; while ( count > 0 ) { result . append ( source ) ; count -- ; } return result . toString ( ) ;


signature:
public class StringUtil { /** * Reverse a string . */
public static String reverse ( final String s ) { } }

implementation: StringBuilder result = new StringBuilder ( s . length ( ) ) ; for ( int i = s . length ( ) - 1 ; i >= 0 ; i -- ) { result . append ( s . charAt ( i ) ) ; } return result . toString ( ) ;


signature:
public class StringUtil { /** * Returns max common prefix of two strings . */
public static String maxCommonPrefix ( final String one , final String two ) { } }

implementation: final int minLength = Math . min ( one . length ( ) , two . length ( ) ) ; final StringBuilder sb = new StringBuilder ( minLength ) ; for ( int pos = 0 ; pos < minLength ; pos ++ ) { final char currentChar = one . charAt ( pos ) ; if ( currentChar != two . charAt ( pos ) ) { break ; } sb . append ( currentChar ) ; } return sb . toString ( ) ;


signature:
public class StringUtil { /** * Finds common prefix for several strings . Returns an empty string if
 * arguments do not have a common prefix . */
public static String findCommonPrefix ( final String ... strings ) { } }

implementation: StringBuilder prefix = new StringBuilder ( ) ; int index = 0 ; char c = 0 ; loop : while ( true ) { for ( int i = 0 ; i < strings . length ; i ++ ) { String s = strings [ i ] ; if ( index == s . length ( ) ) { break loop ; } if ( i == 0 ) { c = s . charAt ( index ) ; } else { if ( s . charAt ( index ) != c ) { break loop ; } } } index ++ ; prefix . append ( c ) ; } return prefix . length ( ) == 0 ? StringPool . EMPTY : prefix . toString ( ) ;


signature:
public class StringUtil { /** * Shorten string to given length . */
public static String shorten ( String s , int length , final String suffix ) { } }

implementation: length -= suffix . length ( ) ; if ( s . length ( ) > length ) { for ( int j = length ; j >= 0 ; j -- ) { if ( CharUtil . isWhitespace ( s . charAt ( j ) ) ) { length = j ; break ; } } String temp = s . substring ( 0 , length ) ; s = temp . concat ( suffix ) ; } return s ;


signature:
public class StringUtil { /** * Converts all of the characters in the string to upper case , based on the
 * locale .
 * @ param s the string to convert
 * @ param locale apply this locale ' s rules
 * @ return the string , converted to upper case , or < code > null < / code > if the
 * string is < code > null < / code > */
public static String toUpperCase ( final String s , Locale locale ) { } }

implementation:
if ( s == null ) { return null ; } StringBuilder sb = null ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { char c = s . charAt ( i ) ; if ( c > 127 ) { // found non - ascii char , fallback to the slow unicode detection
if ( locale == null ) { locale = Locale . getDefault ( ) ; } return s . toUpperCase ( locale ) ; } if ( ( c >= 'a' ) && ( c <= 'z' ) ) { if ( sb == null ) { sb = new StringBuilder ( s ) ; } sb . setCharAt ( i , ( char ) ( c - 32 ) ) ; } } if ( sb == null ) { return s ; } return sb . toString ( ) ;


signature:
public class StringUtil { /** * Removes starting and ending single or double quotes . */
public static String removeQuotes ( final String string ) { } }

implementation: if ( ( startsWithChar ( string , '\'' ) && endsWithChar ( string , '\'' ) ) || ( startsWithChar ( string , '"' ) && endsWithChar ( string , '"' ) ) || ( startsWithChar ( string , '`' ) && endsWithChar ( string , '`' ) ) ) { return substring ( string , 1 , - 1 ) ; } return string ;


signature:
public class StringUtil { /** * Converts bytes to hex string . */
public static String toHexString ( final byte [ ] bytes ) { } }

implementation: char [ ] chars = new char [ bytes . length * 2 ] ; int i = 0 ; for ( byte b : bytes ) { chars [ i ++ ] = CharUtil . int2hex ( ( b & 0xF0 ) >> 4 ) ; chars [ i ++ ] = CharUtil . int2hex ( b & 0x0F ) ; } return new String ( chars ) ;


signature:
public class StringUtil { /** * Executes function on a string if not { @ code null } . Otherwise returns an empty string . */
public static String ifNotNull ( final String input , final Function < String , String > stringFunction ) { } }

implementation: if ( input == null ) { return StringPool . EMPTY ; } return stringFunction . apply ( input ) ;


signature:
public class StringUtil { /** * Returns String bytes using Jodds default encoding . */
public static byte [ ] getBytes ( final String string ) { } }

implementation: try { return string . getBytes ( JoddCore . encoding ) ; } catch ( UnsupportedEncodingException e ) { throw new RuntimeException ( e ) ; }


signature:
public class StringUtil { /** * Detects quote character or return 0. */
public static char detectQuoteChar ( final String str ) { } }

implementation: if ( str . length ( ) < 2 ) { return 0 ; } final char c = str . charAt ( 0 ) ; if ( c != str . charAt ( str . length ( ) - 1 ) ) { return 0 ; } if ( c == '\'' || c == '"' || c == '`' ) { return c ; } return 0 ;


signature:
public class ServletPermanentRedirectActionResult { /** * Redirects to the given location . Provided path is parsed , action is used as a value context . */
@ Override public void render ( final ActionRequest actionRequest , final Object resultValue ) { } }

implementation: final PermRedirect redirectResult ; if ( resultValue == null ) { redirectResult = PermRedirect . to ( StringPool . SLASH ) ; } else { if ( resultValue instanceof String ) { redirectResult = PermRedirect . to ( ( String ) resultValue ) ; } else { redirectResult = ( PermRedirect ) resultValue ; } } final String resultBasePath = actionRequest . getActionRuntime ( ) . getResultBasePath ( ) ; final String redirectValue = redirectResult . path ( ) ; final String resultPath ; if ( redirectValue . startsWith ( "http://" ) || redirectValue . startsWith ( "https://" ) ) { resultPath = redirectValue ; } else { resultPath = resultMapper . resolveResultPathString ( resultBasePath , redirectValue ) ; } final HttpServletRequest request = actionRequest . getHttpServletRequest ( ) ; final HttpServletResponse response = actionRequest . getHttpServletResponse ( ) ; String path = beanTemplateParser . parseWithBean ( resultPath , actionRequest . getAction ( ) ) ; DispatcherUtil . redirectPermanent ( request , response , path ) ;


signature:
public class FastIntBuffer { /** * Appends another fast buffer to this one . */
public FastIntBuffer append ( final FastIntBuffer buff ) { } }

implementation: if ( buff . offset == 0 ) { return this ; } append ( buff . buffer , 0 , buff . offset ) ; return this ;


signature:
public class AnnotationVisitor { /** * Visits a primitive value of the annotation .
 * @ param name the value name .
 * @ param value the actual value , whose type must be { @ link Byte } , { @ link Boolean } , { @ link
 * Character } , { @ link Short } , { @ link Integer } , { @ link Long } , { @ link Float } , { @ link Double } ,
 * { @ link String } or { @ link Type } of { @ link Type # OBJECT } or { @ link Type # ARRAY } sort . This
 * value can also be an array of byte , boolean , short , char , int , long , float or double values
 * ( this is equivalent to using { @ link # visitArray } and visiting each array element in turn ,
 * but is more convenient ) . */
public void visit ( final String name , final Object value ) { } }

implementation: if ( av != null ) { av . visit ( name , value ) ; }


signature:
public class AnnotationVisitor { /** * Visits an enumeration value of the annotation .
 * @ param name the value name .
 * @ param descriptor the class descriptor of the enumeration class .
 * @ param value the actual enumeration value . */
public void visitEnum ( final String name , final String descriptor , final String value ) { } }

implementation: if ( av != null ) { av . visitEnum ( name , descriptor , value ) ; }


signature:
public class AnnotationVisitor { /** * Visits a nested annotation value of the annotation .
 * @ param name the value name .
 * @ param descriptor the class descriptor of the nested annotation class .
 * @ return a visitor to visit the actual nested annotation value , or { @ literal null } if this
 * visitor is not interested in visiting this nested annotation . < i > The nested annotation
 * value must be fully visited before calling other methods on this annotation visitor < / i > . */
public AnnotationVisitor visitAnnotation ( final String name , final String descriptor ) { } }

implementation: if ( av != null ) { return av . visitAnnotation ( name , descriptor ) ; } return null ;


signature:
public class DbEntityManager { /** * Lookups { @ link DbEntityDescriptor } for some type and registers the type if is new .
 * Returns < code > null < / code > for core classes from < code > java < / code > run - time packages !
 * Some types are < b > not < / b > entities , i . e . domain objects . Instead , primitive entities
 * are simply mapped to one column . */
public < E > DbEntityDescriptor < E > lookupType ( final Class < E > type ) { } }

implementation: String typeName = type . getName ( ) ; if ( StringUtil . startsWithOne ( typeName , primitiveEntitiesPrefixes ) != - 1 ) { return null ; } DbEntityDescriptor < E > ded = descriptorsMap . get ( type ) ; if ( ded == null ) { ded = registerType ( type ) ; } return ded ;


signature:
public class DbEntityManager { /** * Registers just type and entity names . Enough for most usages . */
public < E > DbEntityDescriptor < E > registerType ( final Class < E > type ) { } }

implementation: DbEntityDescriptor < E > ded = createDbEntityDescriptor ( type ) ; DbEntityDescriptor < E > existing = descriptorsMap . put ( type , ded ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( "Register " + type . getName ( ) + " as " + ded . getTableName ( ) ) ; } if ( existing != null ) { if ( ded . getType ( ) == type ) { return ded ; } throw new DbOomException ( "Type already registered: " + existing . getType ( ) ) ; } existing = entityNamesMap . put ( ded . getEntityName ( ) , ded ) ; if ( existing != null ) { throw new DbOomException ( "Name '" + ded . getEntityName ( ) + "' already mapped to an entity: " + existing . getType ( ) ) ; } return ded ;


signature:
public class DbEntityManager { /** * Registers entity . { @ link # registerType ( Class ) Registers types } and table names . */
public < E > DbEntityDescriptor < E > registerEntity ( final Class < E > type ) { } }

implementation: DbEntityDescriptor < E > ded = registerType ( type ) ; DbEntityDescriptor existing = tableNamesMap . put ( ded . getTableName ( ) , ded ) ; if ( existing != null ) { if ( ded . getType ( ) == type ) { return ded ; } throw new DbOomException ( "Entity registration failed! Table '" + ded . getTableName ( ) + "' already mapped to an entity: " + existing . getType ( ) ) ; } return ded ;


signature:
public class DbEntityManager { /** * Registers entity . Existing entity will be removed if exist , so no exception will be thrown . */
public < E > DbEntityDescriptor < E > registerEntity ( final Class < E > type , final boolean force ) { } }

implementation: if ( force ) { removeEntity ( type ) ; } return registerEntity ( type ) ;


signature:
public class DbEntityManager { /** * Removes entity and returns removed descriptor . */
public < E > DbEntityDescriptor < E > removeEntity ( final Class < E > type ) { } }

implementation: DbEntityDescriptor < E > ded = descriptorsMap . remove ( type ) ; if ( ded == null ) { ded = createDbEntityDescriptor ( type ) ; } entityNamesMap . remove ( ded . getEntityName ( ) ) ; tableNamesMap . remove ( ded . getTableName ( ) ) ; return ded ;


signature:
public class DbEntityManager { /** * Creates { @ link DbEntityDescriptor } . */
protected < E > DbEntityDescriptor < E > createDbEntityDescriptor ( final Class < E > type ) { } }

implementation: final String schemaName = dbOomConfig . getSchemaName ( ) ; final TableNamingStrategy tableNames = dbOomConfig . getTableNames ( ) ; final ColumnNamingStrategy columnNames = dbOomConfig . getColumnNames ( ) ; return new DbEntityDescriptor < > ( type , schemaName , tableNames , columnNames ) ;


signature:
public class DbEntityManager { /** * Creates new entity instances . */
public < E > E createEntityInstance ( final Class < E > type ) { } }

implementation: try { return ClassUtil . newInstance ( type ) ; } catch ( Exception ex ) { throw new DbOomException ( ex ) ; }


signature:
public class WrapperProxettaFactory { /** * Defines the interface of the resulting class . */
public WrapperProxettaFactory setTargetInterface ( final Class targetInterface ) { } }

implementation: if ( ! targetInterface . isInterface ( ) ) { throw new ProxettaException ( "Not an interface: " + targetInterface . getName ( ) ) ; } this . targetInterface = targetInterface ; return this ;


signature:
public class WrapperProxettaFactory { /** * { @ inheritDoc } */
@ Override protected WorkData process ( final ClassReader cr , final TargetClassInfoReader targetClassInfoReader ) { } }

implementation: final ProxettaWrapperClassBuilder pcb = new ProxettaWrapperClassBuilder ( targetClassOrInterface , targetInterface , targetFieldName , destClassWriter , proxetta . getAspects ( new ProxyAspect [ 0 ] ) , resolveClassNameSuffix ( ) , requestedProxyClassName , targetClassInfoReader , createTargetInDefaultCtor ) ; cr . accept ( pcb , 0 ) ; return pcb . getWorkData ( ) ;


signature:
public class WrapperProxettaFactory { /** * Injects target into wrapper . */
public void injectTargetIntoWrapper ( final Object target , final Object wrapper ) { } }

implementation: ProxettaUtil . injectTargetIntoWrapper ( target , wrapper , targetFieldName ) ;


signature:
public class AnnotatedPropertyInterceptor { /** * Lookups for annotated properties . Caches all annotated properties on the first
 * action class scan . */
protected PropertyDescriptor [ ] lookupAnnotatedProperties ( final Class type ) { } }

implementation: PropertyDescriptor [ ] properties = annotatedProperties . get ( type ) ; if ( properties != null ) { return properties ; } ClassDescriptor cd = ClassIntrospector . get ( ) . lookup ( type ) ; PropertyDescriptor [ ] allProperties = cd . getAllPropertyDescriptors ( ) ; List < PropertyDescriptor > list = new ArrayList < > ( ) ; for ( PropertyDescriptor propertyDescriptor : allProperties ) { Annotation ann = null ; if ( propertyDescriptor . getFieldDescriptor ( ) != null ) { ann = propertyDescriptor . getFieldDescriptor ( ) . getField ( ) . getAnnotation ( annotations ) ; } if ( ann == null && propertyDescriptor . getWriteMethodDescriptor ( ) != null ) { ann = propertyDescriptor . getWriteMethodDescriptor ( ) . getMethod ( ) . getAnnotation ( annotations ) ; } if ( ann == null && propertyDescriptor . getReadMethodDescriptor ( ) != null ) { ann = propertyDescriptor . getReadMethodDescriptor ( ) . getMethod ( ) . getAnnotation ( annotations ) ; } if ( ann != null ) { list . add ( propertyDescriptor ) ; } } if ( list . isEmpty ( ) ) { properties = EMPTY ; } else { properties = list . toArray ( new PropertyDescriptor [ 0 ] ) ; } annotatedProperties . put ( type , properties ) ; return properties ;


signature:
public class DbDetector { /** * Detects database and configure DbOom engine . */
public DbServer detectDatabaseAndConfigureDbOom ( final ConnectionProvider cp , final DbOomConfig dbOomConfig ) { } }

implementation: cp . init ( ) ; final Connection connection = cp . getConnection ( ) ; final DbServer dbServer = detectDatabase ( connection ) ; cp . closeConnection ( connection ) ; dbServer . accept ( dbOomConfig ) ; return dbServer ;


signature:
public class DbDetector { /** * Detects database and returns { @ link DbServer } . */
public DbServer detectDatabase ( final Connection connection ) { } }

implementation: final String dbName ; final int dbMajorVersion ; final String version ; try { log . info ( "Detecting database..." ) ; DatabaseMetaData databaseMetaData = connection . getMetaData ( ) ; dbName = databaseMetaData . getDatabaseProductName ( ) ; dbMajorVersion = databaseMetaData . getDatabaseMajorVersion ( ) ; final int dbMinorVersion = databaseMetaData . getDatabaseMinorVersion ( ) ; version = dbMajorVersion + "." + dbMinorVersion ; log . info ( "Database: " + dbName + " v" + dbMajorVersion + "." + dbMinorVersion ) ; } catch ( SQLException sex ) { String msg = sex . getMessage ( ) ; if ( msg . contains ( "explicitly set for database: DB2" ) ) { return new Db2DbServer ( ) ; } throw new DbSqlException ( sex ) ; } if ( dbName . equals ( "Apache Derby" ) ) { return new DerbyDbServer ( version ) ; } if ( dbName . startsWith ( "DB2/" ) ) { return new Db2DbServer ( version ) ; } if ( dbName . equals ( "HSQL Database Engine" ) ) { return new HsqlDbServer ( version ) ; } if ( dbName . equals ( "Informix Dynamic Server" ) ) { return new InformixDbServer ( version ) ; } if ( dbName . startsWith ( "Microsoft SQL Server" ) ) { return new SqlServerDbServer ( version ) ; } if ( dbName . equals ( "MySQL" ) ) { return new MySqlDbServer ( version ) ; } if ( dbName . equals ( "Oracle" ) ) { return new OracleDbServer ( version ) ; } if ( dbName . equals ( "PostgreSQL" ) ) { return new PostgreSqlDbServer ( version ) ; } if ( dbName . equals ( "Sybase SQL Server" ) ) { return new SybaseDbServer ( version ) ; } if ( dbName . equals ( "ASE" ) && ( dbMajorVersion == 15 ) ) { return new SybaseDbServer ( version ) ; } if ( dbName . equals ( "SQLite" ) ) { return new SQLiteDbServer ( version ) ; } return new GenericDbServer ( ) ;


signature:
public class GzipResponseStream { /** * Closes this output stream , causing any buffered data to be flushed and any
 * further output data to throw an IOException . */
@ Override public void close ( ) throws IOException { } }

implementation: if ( closed ) { return ; } if ( gzipstream != null ) { flushToGZip ( ) ; gzipstream . close ( ) ; gzipstream = null ; } else { if ( bufferCount > 0 ) { output . write ( buffer , 0 , bufferCount ) ; bufferCount = 0 ; } } output . close ( ) ; closed = true ;


signature:
public class GzipResponseStream { /** * Writes the specified byte to our output stream . */
@ Override public void write ( final int b ) throws IOException { } }

implementation: if ( closed ) { throw new IOException ( "Cannot write to a closed output stream" ) ; } if ( bufferCount >= buffer . length ) { flushToGZip ( ) ; } buffer [ bufferCount ++ ] = ( byte ) b ;


signature:
public class GzipResponseStream { /** * Writes < code > len < / code > bytes from the specified byte array , starting at
 * the specified offset , to our output stream .
 * @ param b byte array containing the bytes to be written
 * @ param off zero - relative starting offset of the bytes to be written
 * @ param len number of bytes to be written */
@ Override public void write ( final byte [ ] b , final int off , final int len ) throws IOException { } }

implementation:
if ( closed ) { throw new IOException ( "Cannot write to a closed output stream" ) ; } if ( len == 0 ) { return ; } // Can we write into buffer ?
if ( len <= ( buffer . length - bufferCount ) ) { System . arraycopy ( b , off , buffer , bufferCount , len ) ; bufferCount += len ; return ; } // There is not enough space in buffer . Flush it . . .
flushToGZip ( ) ; // . . . and try again . Note , that bufferCount = 0 here !
if ( len <= ( buffer . length - bufferCount ) ) { System . arraycopy ( b , off , buffer , bufferCount , len ) ; bufferCount += len ; return ; } // write direct to gzip
writeToGZip ( b , off , len ) ;


signature:
public class GzipResponseStream { /** * Writes byte array to gzip output stream . Creates new < code > GZIPOutputStream < / code >
 * if not created yet . Also sets the " Content - Encoding " header . */
public void writeToGZip ( final byte [ ] b , final int off , final int len ) throws IOException { } }

implementation: if ( gzipstream == null ) { gzipstream = new GZIPOutputStream ( output ) ; response . setHeader ( "Content-Encoding" , "gzip" ) ; } gzipstream . write ( b , off , len ) ;


signature:
public class RemoveSessionFromUrlFilter { /** * Filters requests to remove URL - based session identifiers . */
@ Override public void doFilter ( final ServletRequest request , final ServletResponse response , final FilterChain chain ) throws IOException , ServletException { } }

implementation:
HttpServletRequest httpRequest = ( HttpServletRequest ) request ; HttpServletResponse httpResponse = ( HttpServletResponse ) response ; if ( isRequestedSessionIdFromURL ( httpRequest ) ) { HttpSession session = httpRequest . getSession ( false ) ; if ( session != null ) { session . invalidate ( ) ; // clear session if session id in URL
} } // wrap response to remove URL encoding
HttpServletResponseWrapper wrappedResponse = new HttpServletResponseWrapper ( httpResponse ) { @ Override public String encodeRedirectUrl ( final String url ) { return url ; } @ Override public String encodeRedirectURL ( final String url ) { return url ; } @ Override public String encodeUrl ( final String url ) { return url ; } @ Override public String encodeURL ( final String url ) { return url ; } } ; chain . doFilter ( request , wrappedResponse ) ;


signature:
public class RemoveSessionFromUrlFilter { /** * Detects if session ID exist in the URL . It works more reliable
 * than < code > servletRequest . isRequestedSessionIdFromURL ( ) < / code > . */
protected boolean isRequestedSessionIdFromURL ( final HttpServletRequest servletRequest ) { } }

implementation: if ( servletRequest . isRequestedSessionIdFromURL ( ) ) { return true ; } HttpSession session = servletRequest . getSession ( false ) ; if ( session != null ) { String sessionId = session . getId ( ) ; StringBuffer requestUri = servletRequest . getRequestURL ( ) ; return requestUri . indexOf ( sessionId ) != - 1 ; } return false ;


signature:
public class EmailAttachment { /** * Returns encoded attachment name .
 * @ return encoded attachment name . Value may be { @ code null } . */
public String getEncodedName ( ) { } }

implementation: if ( name == null ) { return null ; } try { return MimeUtility . encodeText ( name ) ; } catch ( final UnsupportedEncodingException ueex ) { throw new MailException ( ueex ) ; }


signature:
public class EmailAttachment { /** * Returns byte content of the attachment .
 * @ return byte array with content of the attachment . */
public byte [ ] toByteArray ( ) { } }

implementation: final FastByteArrayOutputStream out ; if ( size != - 1 ) { out = new FastByteArrayOutputStream ( size ) ; } else { out = new FastByteArrayOutputStream ( ) ; } writeToStream ( out ) ; return out . toByteArray ( ) ;


signature:
public class EmailAttachment { /** * Saves attachment to a file .
 * @ param destination The destination file to be written . */
public void writeToFile ( final File destination ) { } }

implementation: InputStream input = null ; final OutputStream output ; try { input = getDataSource ( ) . getInputStream ( ) ; output = new FileOutputStream ( destination ) ; StreamUtil . copy ( input , output ) ; } catch ( final IOException ioex ) { throw new MailException ( ioex ) ; } finally { StreamUtil . close ( input ) ; }


signature:
public class EmailAttachment { /** * Saves attachment to the output stream .
 * @ param out OutputStream where attachment should be copied to . */
public void writeToStream ( final OutputStream out ) { } }

implementation: InputStream input = null ; try { input = getDataSource ( ) . getInputStream ( ) ; StreamUtil . copy ( input , out ) ; } catch ( final IOException ioex ) { throw new MailException ( ioex ) ; } finally { StreamUtil . close ( input ) ; }


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

implementation: return rs . getBigDecimal ( index ) ;


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

implementation: st . setBigDecimal ( index , value ) ;


signature:
public class InvokeReplacerMethodAdapter { /** * Invoked on INVOKEVIRTUAL , INVOKESPECIAL , INVOKESTATIC , INVOKEINTERFACE or INVOKEDYNAMIC . */
@ Override public void visitMethodInsn ( final int opcode , String owner , String name , String desc , final boolean isInterface ) { } }

implementation:
// replace NEW . < init >
if ( ( newInvokeReplacer != null ) && ( opcode == INVOKESPECIAL ) ) { String exOwner = owner ; owner = newInvokeReplacer . getOwner ( ) ; name = newInvokeReplacer . getMethodName ( ) ; desc = changeReturnType ( desc , 'L' + exOwner + ';' ) ; super . visitMethodInsn ( INVOKESTATIC , owner , name , desc , isInterface ) ; newInvokeReplacer = null ; return ; } InvokeInfo invokeInfo = new InvokeInfo ( owner , name , desc ) ; // creating FooClone . < init > ; inside the FOO constructor
// replace the very first invokespecial < init > call ( SUB . < init > )
// to targets subclass with target ( FOO . < init > ) .
if ( methodInfo . getMethodName ( ) . equals ( INIT ) ) { if ( ( ! firstSuperCtorInitCalled ) && ( opcode == INVOKESPECIAL ) && name . equals ( INIT ) && owner . equals ( wd . nextSupername ) ) { firstSuperCtorInitCalled = true ; owner = wd . superReference ; super . visitMethodInsn ( opcode , owner , name , desc , isInterface ) ; return ; } } // detection of super calls
if ( ( opcode == INVOKESPECIAL ) && ( owner . equals ( wd . nextSupername ) && ( ! name . equals ( INIT ) ) ) ) { throw new ProxettaException ( "Super call detected in class " + methodInfo . getClassname ( ) + " method: " + methodInfo . getSignature ( ) + "\nProxetta can't handle super calls due to VM limitations." ) ; } InvokeReplacer ir = null ; // find first matching aspect
for ( InvokeAspect aspect : aspects ) { ir = aspect . pointcut ( invokeInfo ) ; if ( ir != null ) { break ; } } if ( ir == null || ir . isNone ( ) ) { if ( ProxettaAsmUtil . isCreateArgumentsArrayMethod ( name , desc ) ) { ProxyTargetReplacement . createArgumentsArray ( mv , methodInfo ) ; wd . proxyApplied = true ; return ; } if ( ProxettaAsmUtil . isCreateArgumentsClassArrayMethod ( name , desc ) ) { ProxyTargetReplacement . createArgumentsClassArray ( mv , methodInfo ) ; wd . proxyApplied = true ; return ; } if ( ProxettaAsmUtil . isArgumentsCountMethod ( name , desc ) ) { ProxyTargetReplacement . argumentsCount ( mv , methodInfo ) ; wd . proxyApplied = true ; return ; } if ( ProxettaAsmUtil . isTargetMethodNameMethod ( name , desc ) ) { ProxyTargetReplacement . targetMethodName ( mv , methodInfo ) ; wd . proxyApplied = true ; return ; } if ( ProxettaAsmUtil . isTargetMethodDescriptionMethod ( name , desc ) ) { ProxyTargetReplacement . targetMethodDescription ( mv , methodInfo ) ; wd . proxyApplied = true ; return ; } if ( ProxettaAsmUtil . isTargetMethodSignatureMethod ( name , desc ) ) { ProxyTargetReplacement . targetMethodSignature ( mv , methodInfo ) ; wd . proxyApplied = true ; return ; } if ( ProxettaAsmUtil . isReturnTypeMethod ( name , desc ) ) { ProxyTargetReplacement . returnType ( mv , methodInfo ) ; wd . proxyApplied = true ; return ; } if ( ProxettaAsmUtil . isTargetClassMethod ( name , desc ) ) { ProxyTargetReplacement . targetClass ( mv , methodInfo ) ; wd . proxyApplied = true ; return ; } if ( isArgumentTypeMethod ( name , desc ) ) { int argIndex = this . getArgumentIndex ( ) ; ProxyTargetReplacement . argumentType ( mv , methodInfo , argIndex ) ; wd . proxyApplied = true ; return ; } if ( isArgumentMethod ( name , desc ) ) { int argIndex = this . getArgumentIndex ( ) ; ProxyTargetReplacement . argument ( mv , methodInfo , argIndex ) ; wd . proxyApplied = true ; return ; } if ( isInfoMethod ( name , desc ) ) { proxyInfoRequested = true ; // we are NOT calling the replacement here , as we would expect .
// NO , we need to wait for the very next ASTORE method so we
// can read the index and use it for replacement method ! ! !
// ProxyTargetReplacement . info ( mv , methodInfo ) ;
wd . proxyApplied = true ; return ; } if ( isTargetMethodAnnotationMethod ( name , desc ) ) { String [ ] args = getLastTwoStringArguments ( ) ; // pop current two args
mv . visitInsn ( POP ) ; mv . visitInsn ( POP ) ; ProxyTargetReplacement . targetMethodAnnotation ( mv , methodInfo , args ) ; wd . proxyApplied = true ; return ; } if ( isTargetClassAnnotationMethod ( name , desc ) ) { String [ ] args = getLastTwoStringArguments ( ) ; // pop current two args
mv . visitInsn ( POP ) ; mv . visitInsn ( POP ) ; ProxyTargetReplacement . targetClassAnnotation ( mv , methodInfo . getClassInfo ( ) , args ) ; wd . proxyApplied = true ; return ; } super . visitMethodInsn ( opcode , owner , name , desc , isInterface ) ; return ; } wd . proxyApplied = true ; String exOwner = owner ; owner = ir . getOwner ( ) ; name = ir . getMethodName ( ) ; switch ( opcode ) { case INVOKEINTERFACE : desc = prependArgument ( desc , AsmUtil . L_SIGNATURE_JAVA_LANG_OBJECT ) ; break ; case INVOKEVIRTUAL : desc = prependArgument ( desc , AsmUtil . L_SIGNATURE_JAVA_LANG_OBJECT ) ; break ; case INVOKESTATIC : break ; default : throw new ProxettaException ( "Unsupported opcode: " + opcode ) ; } // additional arguments
if ( ir . isPassOwnerName ( ) ) { desc = appendArgument ( desc , AsmUtil . L_SIGNATURE_JAVA_LANG_STRING ) ; super . visitLdcInsn ( exOwner ) ; } if ( ir . isPassMethodName ( ) ) { desc = appendArgument ( desc , AsmUtil . L_SIGNATURE_JAVA_LANG_STRING ) ; super . visitLdcInsn ( methodInfo . getMethodName ( ) ) ; } if ( ir . isPassMethodSignature ( ) ) { desc = appendArgument ( desc , AsmUtil . L_SIGNATURE_JAVA_LANG_STRING ) ; super . visitLdcInsn ( methodInfo . getSignature ( ) ) ; } if ( ir . isPassTargetClass ( ) ) { desc = appendArgument ( desc , AsmUtil . L_SIGNATURE_JAVA_LANG_CLASS ) ; super . mv . visitLdcInsn ( Type . getType ( 'L' + wd . superReference + ';' ) ) ; } if ( ir . isPassThis ( ) ) { desc = appendArgument ( desc , AsmUtil . L_SIGNATURE_JAVA_LANG_OBJECT ) ; super . mv . visitVarInsn ( ALOAD , 0 ) ; } super . visitMethodInsn ( INVOKESTATIC , owner , name , desc , false ) ;


signature:
public class InvokeReplacerMethodAdapter { /** * Appends argument to the existing description . */
protected static String appendArgument ( final String desc , final String type ) { } }

implementation: int ndx = desc . indexOf ( ')' ) ; return desc . substring ( 0 , ndx ) + type + desc . substring ( ndx ) ;


signature:
public class InvokeReplacerMethodAdapter { /** * Prepends argument to the existing description . */
protected static String prependArgument ( final String desc , final String type ) { } }

implementation: int ndx = desc . indexOf ( '(' ) ; ndx ++ ; return desc . substring ( 0 , ndx ) + type + desc . substring ( ndx ) ;


signature:
public class InvokeReplacerMethodAdapter { /** * Changes return type . */
protected static String changeReturnType ( final String desc , final String type ) { } }

implementation: int ndx = desc . indexOf ( ')' ) ; return desc . substring ( 0 , ndx + 1 ) + type ;


signature:
public class StripHtmlTagAdapter { /** * Cleans unnecessary whitespaces . */
@ Override public void text ( final CharSequence text ) { } }

implementation: if ( ! strip ) { super . text ( text ) ; return ; } int textLength = text . length ( ) ; char [ ] dest = new char [ textLength ] ; int ndx = 0 ; boolean regularChar = true ; for ( int i = 0 ; i < textLength ; i ++ ) { char c = text . charAt ( i ) ; if ( CharUtil . isWhitespace ( c ) ) { if ( regularChar ) { regularChar = false ; c = ' ' ; } else { continue ; } } else { regularChar = true ; } dest [ ndx ] = c ; ndx ++ ; } if ( regularChar || ( ndx != 1 ) ) { super . text ( CharBuffer . wrap ( dest , 0 , ndx ) ) ; strippedCharsCount += textLength - ndx ; } else { strippedCharsCount += textLength ; }


signature:
public class TypeConverterManager { /** * Registers default set of converters . */
public void registerDefaults ( ) { } }

implementation:
register ( String . class , new StringConverter ( ) ) ; register ( String [ ] . class , new StringArrayConverter ( this ) ) ; IntegerConverter integerConverter = new IntegerConverter ( ) ; register ( Integer . class , integerConverter ) ; register ( int . class , integerConverter ) ; register ( MutableInteger . class , new MutableIntegerConverter ( this ) ) ; ShortConverter shortConverter = new ShortConverter ( ) ; register ( Short . class , shortConverter ) ; register ( short . class , shortConverter ) ; register ( MutableShort . class , new MutableShortConverter ( this ) ) ; LongConverter longConverter = new LongConverter ( ) ; register ( Long . class , longConverter ) ; register ( long . class , longConverter ) ; register ( MutableLong . class , new MutableLongConverter ( this ) ) ; ByteConverter byteConverter = new ByteConverter ( ) ; register ( Byte . class , byteConverter ) ; register ( byte . class , byteConverter ) ; register ( MutableByte . class , new MutableByteConverter ( this ) ) ; FloatConverter floatConverter = new FloatConverter ( ) ; register ( Float . class , floatConverter ) ; register ( float . class , floatConverter ) ; register ( MutableFloat . class , new MutableFloatConverter ( this ) ) ; DoubleConverter doubleConverter = new DoubleConverter ( ) ; register ( Double . class , doubleConverter ) ; register ( double . class , doubleConverter ) ; register ( MutableDouble . class , new MutableDoubleConverter ( this ) ) ; BooleanConverter booleanConverter = new BooleanConverter ( ) ; register ( Boolean . class , booleanConverter ) ; register ( boolean . class , booleanConverter ) ; CharacterConverter characterConverter = new CharacterConverter ( ) ; register ( Character . class , characterConverter ) ; register ( char . class , characterConverter ) ; register ( byte [ ] . class , new ByteArrayConverter ( this ) ) ; register ( short [ ] . class , new ShortArrayConverter ( this ) ) ; register ( int [ ] . class , new IntegerArrayConverter ( this ) ) ; register ( long [ ] . class , new LongArrayConverter ( this ) ) ; register ( float [ ] . class , new FloatArrayConverter ( this ) ) ; register ( double [ ] . class , new DoubleArrayConverter ( this ) ) ; register ( boolean [ ] . class , new BooleanArrayConverter ( this ) ) ; register ( char [ ] . class , new CharacterArrayConverter ( this ) ) ; // we don ' t really need these , but converters will be cached and not created every time
register ( Integer [ ] . class , new ArrayConverter < Integer > ( this , Integer . class ) { @ Override protected Integer [ ] createArray ( final int length ) { return new Integer [ length ] ; } } ) ; register ( Long [ ] . class , new ArrayConverter < Long > ( this , Long . class ) { @ Override protected Long [ ] createArray ( final int length ) { return new Long [ length ] ; } } ) ; register ( Byte [ ] . class , new ArrayConverter < Byte > ( this , Byte . class ) { @ Override protected Byte [ ] createArray ( final int length ) { return new Byte [ length ] ; } } ) ; register ( Short [ ] . class , new ArrayConverter < Short > ( this , Short . class ) { @ Override protected Short [ ] createArray ( final int length ) { return new Short [ length ] ; } } ) ; register ( Float [ ] . class , new ArrayConverter < Float > ( this , Float . class ) { @ Override protected Float [ ] createArray ( final int length ) { return new Float [ length ] ; } } ) ; register ( Double [ ] . class , new ArrayConverter < Double > ( this , Double . class ) { @ Override protected Double [ ] createArray ( final int length ) { return new Double [ length ] ; } } ) ; register ( Boolean [ ] . class , new ArrayConverter < Boolean > ( this , Boolean . class ) { @ Override protected Boolean [ ] createArray ( final int length ) { return new Boolean [ length ] ; } } ) ; register ( Character [ ] . class , new ArrayConverter < Character > ( this , Character . class ) { @ Override protected Character [ ] createArray ( final int length ) { return new Character [ length ] ; } } ) ; register ( MutableInteger [ ] . class , new ArrayConverter < > ( this , MutableInteger . class ) ) ; register ( MutableLong [ ] . class , new ArrayConverter < > ( this , MutableLong . class ) ) ; register ( MutableByte [ ] . class , new ArrayConverter < > ( this , MutableByte . class ) ) ; register ( MutableShort [ ] . class , new ArrayConverter < > ( this , MutableShort . class ) ) ; register ( MutableFloat [ ] . class , new ArrayConverter < > ( this , MutableFloat . class ) ) ; register ( MutableDouble [ ] . class , new ArrayConverter < > ( this , MutableDouble . class ) ) ; register ( BigDecimal . class , new BigDecimalConverter ( ) ) ; register ( BigInteger . class , new BigIntegerConverter ( ) ) ; register ( BigDecimal [ ] . class , new ArrayConverter < > ( this , BigDecimal . class ) ) ; register ( BigInteger [ ] . class , new ArrayConverter < > ( this , BigInteger . class ) ) ; register ( java . util . Date . class , new DateConverter ( ) ) ; register ( java . sql . Date . class , new SqlDateConverter ( ) ) ; register ( Time . class , new SqlTimeConverter ( ) ) ; register ( Timestamp . class , new SqlTimestampConverter ( ) ) ; register ( Calendar . class , new CalendarConverter ( ) ) ; // register ( GregorianCalendar . class , new CalendarConverter ( ) ) ;
register ( LocalDateTime . class , new LocalDateTimeConverter ( ) ) ; register ( LocalDate . class , new LocalDateConverter ( ) ) ; register ( LocalTime . class , new LocalTimeConverter ( ) ) ; register ( File . class , new FileConverter ( ) ) ; register ( FileUpload . class , new FileUploadConverter ( ) ) ; register ( Class . class , new ClassConverter ( ) ) ; register ( Class [ ] . class , new ClassArrayConverter ( this ) ) ; register ( URI . class , new URIConverter ( ) ) ; register ( URL . class , new URLConverter ( ) ) ; register ( Locale . class , new LocaleConverter ( ) ) ; register ( TimeZone . class , new TimeZoneConverter ( ) ) ; register ( UUID . class , new UUIDConverter ( ) ) ;


signature:
public class TypeConverterManager { /** * Registers a converter for specified type .
 * User must register converter for all super - classes as well .
 * @ param typeclass that converter is for
 * @ param typeConverterconverter for provided class */
public < T > void register ( final Class < T > type , final TypeConverter < T > typeConverter ) { } }

implementation: converters . put ( type , typeConverter ) ;


signature:
public class TypeConverterManager { /** * Retrieves converter for provided type . Only registered types are matched ,
 * therefore subclasses must be also registered .
 * @ return founded converter or < code > null < / code > */
public < T > TypeConverter < T > lookup ( final Class < T > type ) { } }

implementation: return converters . get ( type ) ;


signature:
public class TypeConverterManager { /** * Converts an object to destination type . If type is registered , it ' s
 * { @ link TypeConverter } will be used . If not , it scans of destination is
 * an array or enum , as those two cases are handled in a special way .
 * If destination type is one of common types , consider using { @ link Converter }
 * instead for somewhat faster approach ( no lookup ) . */
@ SuppressWarnings ( { } }

implementation:
"unchecked" } ) public < T > T convertType ( final Object value , final Class < T > destinationType ) { if ( destinationType == Object . class ) { // no conversion : )
return ( T ) value ; } final TypeConverter converter = lookup ( destinationType ) ; if ( converter != null ) { return ( T ) converter . convert ( value ) ; } // no converter
if ( value == null ) { return null ; } // check same instances
if ( ClassUtil . isInstanceOf ( value , destinationType ) ) { return ( T ) value ; } // handle destination arrays
if ( destinationType . isArray ( ) ) { ArrayConverter < T > arrayConverter = new ArrayConverter ( this , destinationType . getComponentType ( ) ) ; return ( T ) arrayConverter . convert ( value ) ; } // handle enums
if ( destinationType . isEnum ( ) ) { Object [ ] enums = destinationType . getEnumConstants ( ) ; String valStr = value . toString ( ) ; for ( Object e : enums ) { if ( e . toString ( ) . equals ( valStr ) ) { return ( T ) e ; } } } // collection
if ( ClassUtil . isTypeOf ( destinationType , Collection . class ) ) { // component type is unknown because of Java ' s type - erasure
CollectionConverter < T > collectionConverter = new CollectionConverter ( this , destinationType , Object . class ) ; return ( T ) collectionConverter . convert ( value ) ; } // fail
throw new TypeConversionException ( "Conversion failed of input type: " + value . getClass ( ) + " into: " + destinationType . getName ( ) ) ;


signature:
public class TypeConverterManager { /** * Special case of { @ link # convertType ( Object , Class ) } when target is collection and
 * when component type is known . */
@ SuppressWarnings ( "unchecked" ) public < C extends Collection < T > , T > C convertToCollection ( final Object value , final Class < ? extends Collection > destinationType , final Class < T > componentType ) { } }

implementation:
if ( value == null ) { return null ; } // check same instances
if ( ClassUtil . isInstanceOf ( value , destinationType ) ) { return ( C ) value ; } final CollectionConverter collectionConverter ; if ( componentType == null ) { collectionConverter = new CollectionConverter ( destinationType , Object . class ) ; } else { collectionConverter = new CollectionConverter ( destinationType , componentType ) ; } return ( C ) collectionConverter . convert ( value ) ;


signature:
public class NodeSelector { /** * Selects nodes using CSS3 selector query . */
public List < Node > select ( final String query ) { } }

implementation: Collection < List < CssSelector > > selectorsCollection = CSSelly . parse ( query ) ; return select ( selectorsCollection ) ;


signature:
public class NodeSelector { /** * Selected nodes using pre - parsed CSS selectors . Take in consideration
 * collection type for results grouping order . */
public List < Node > select ( final Collection < List < CssSelector > > selectorsCollection ) { } }

implementation: List < Node > results = new ArrayList < > ( ) ; for ( List < CssSelector > selectors : selectorsCollection ) { processSelectors ( results , selectors ) ; } return results ;


signature:
public class NodeSelector { /** * Process selectors and keep adding results . */
protected void processSelectors ( final List < Node > results , final List < CssSelector > selectors ) { } }

implementation: List < Node > selectedNodes = select ( rootNode , selectors ) ; for ( Node selectedNode : selectedNodes ) { if ( ! results . contains ( selectedNode ) ) { results . add ( selectedNode ) ; } }


signature:
public class NodeSelector { /** * Selects nodes using CSS3 selector query and returns the very first one . */
public Node selectFirst ( final String query ) { } }

implementation: List < Node > selectedNodes = select ( query ) ; if ( selectedNodes . isEmpty ( ) ) { return null ; } return selectedNodes . get ( 0 ) ;


signature:
public class NodeSelector { /** * Selects nodes using { @ link NodeFilter node filter } . */
public List < Node > select ( final NodeFilter nodeFilter ) { } }

implementation: List < Node > nodes = new ArrayList < > ( ) ; walk ( rootNode , nodeFilter , nodes ) ; return nodes ;


signature:
public class NodeSelector { /** * Selects nodes using { @ link NodeFilter node filter } and return the very first one . */
public Node selectFirst ( final NodeFilter nodeFilter ) { } }

implementation: List < Node > selectedNodes = select ( nodeFilter ) ; if ( selectedNodes . isEmpty ( ) ) { return null ; } return selectedNodes . get ( 0 ) ;


signature:
public class NodeSelector { /** * - - - - - internal */
protected void walk ( final Node rootNode , final NodeFilter nodeFilter , final List < Node > result ) { } }

implementation: int childCount = rootNode . getChildNodesCount ( ) ; for ( int i = 0 ; i < childCount ; i ++ ) { Node node = rootNode . getChild ( i ) ; if ( nodeFilter . accept ( node ) ) { result . add ( node ) ; } walk ( node , nodeFilter , result ) ; }


signature:
public class NodeSelector { /** * Walks over the child notes , maintaining the tree order and not using recursion . */
protected void walkDescendantsIteratively ( final LinkedList < Node > nodes , final CssSelector cssSelector , final List < Node > result ) { } }

implementation:
while ( ! nodes . isEmpty ( ) ) { Node node = nodes . removeFirst ( ) ; selectAndAdd ( node , cssSelector , result ) ; // append children in walking order to be processed right after this node
int childCount = node . getChildNodesCount ( ) ; for ( int i = childCount - 1 ; i >= 0 ; i -- ) { nodes . addFirst ( node . getChild ( i ) ) ; } }


signature:
public class NodeSelector { /** * Finds nodes in the tree that matches single selector . */
protected void walk ( final Node rootNode , final CssSelector cssSelector , final List < Node > result ) { } }

implementation:
// previous combinator determines the behavior
CssSelector previousCssSelector = cssSelector . getPrevCssSelector ( ) ; Combinator combinator = previousCssSelector != null ? previousCssSelector . getCombinator ( ) : Combinator . DESCENDANT ; switch ( combinator ) { case DESCENDANT : LinkedList < Node > nodes = new LinkedList < > ( ) ; int childCount = rootNode . getChildNodesCount ( ) ; for ( int i = 0 ; i < childCount ; i ++ ) { nodes . add ( rootNode . getChild ( i ) ) ; // recursive
// selectAndAdd ( node , cssSelector , result ) ;
// walk ( node , cssSelector , result ) ;
} walkDescendantsIteratively ( nodes , cssSelector , result ) ; break ; case CHILD : childCount = rootNode . getChildNodesCount ( ) ; for ( int i = 0 ; i < childCount ; i ++ ) { Node node = rootNode . getChild ( i ) ; selectAndAdd ( node , cssSelector , result ) ; } break ; case ADJACENT_SIBLING : Node node = rootNode . getNextSiblingElement ( ) ; if ( node != null ) { selectAndAdd ( node , cssSelector , result ) ; } break ; case GENERAL_SIBLING : node = rootNode ; while ( true ) { node = node . getNextSiblingElement ( ) ; if ( node == null ) { break ; } selectAndAdd ( node , cssSelector , result ) ; } break ; }


signature:
public class NodeSelector { /** * Selects single node for single selector and appends it to the results . */
protected void selectAndAdd ( final Node node , final CssSelector cssSelector , final List < Node > result ) { } }

implementation:
// ignore all nodes that are not elements
if ( node . getNodeType ( ) != Node . NodeType . ELEMENT ) { return ; } boolean matched = cssSelector . accept ( node ) ; if ( matched ) { // check for duplicates
if ( result . contains ( node ) ) { return ; } // no duplicate found , add it to the results
result . add ( node ) ; }


signature:
public class NodeSelector { /** * Filter nodes . */
protected boolean filter ( final List < Node > currentResults , final Node node , final CssSelector cssSelector , final int index ) { } }

implementation: return cssSelector . accept ( currentResults , node , index ) ;


signature:
public class CSSellyLexer { /** * Unpacks the compressed character translation table .
 * @ param packed the packed character translation table
 * @ return the unpacked character translation table */
private static char [ ] zzUnpackCMap ( final String packed ) { } }

implementation:
char [ ] map = new char [ 0x110000 ] ; int i = 0 ; /* index in packed string */
int j = 0 ; /* index in unpacked array */
while ( i < 128 ) { int count = packed . charAt ( i ++ ) ; char value = packed . charAt ( i ++ ) ; do map [ j ++ ] = value ; while ( -- count > 0 ) ; } return map ;


signature:
public class CSSellyLexer { /** * Refills the input buffer .
 * @ return < code > false < / code > , iff there was new input . */
private boolean zzRefill ( ) { } }

implementation: if ( zzBuffer == null ) { zzBuffer = zzChars ; zzEndRead += zzChars . length ; return false ; } return true ;


signature:
public class CSSellyLexer { /** * Resumes scanning until the next regular expression is matched ,
 * the end of input is encountered or an I / O - Error occurs .
 * @ return the next token
 * @ exception java . io . IOException if any I / O - Error occurs */
public int yylex ( ) throws java . io . IOException { } }

implementation:
int zzInput ; int zzAction ; // cached fields :
int zzCurrentPosL ; int zzMarkedPosL ; int zzEndReadL = zzEndRead ; char [ ] zzBufferL = zzBuffer ; char [ ] zzCMapL = ZZ_CMAP ; int [ ] zzTransL = ZZ_TRANS ; int [ ] zzRowMapL = ZZ_ROWMAP ; int [ ] zzAttrL = ZZ_ATTRIBUTE ; while ( true ) { zzMarkedPosL = zzMarkedPos ; yychar += zzMarkedPosL - zzStartRead ; zzAction = - 1 ; zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL ; zzState = ZZ_LEXSTATE [ zzLexicalState ] ; // set up zzAction for empty match case :
int zzAttributes = zzAttrL [ zzState ] ; if ( ( zzAttributes & 1 ) == 1 ) { zzAction = zzState ; } zzForAction : { while ( true ) { if ( zzCurrentPosL < zzEndReadL ) { zzInput = Character . codePointAt ( zzBufferL , zzCurrentPosL , zzEndReadL ) ; zzCurrentPosL += Character . charCount ( zzInput ) ; } else if ( zzAtEOF ) { zzInput = YYEOF ; break zzForAction ; } else { // store back cached positions
zzCurrentPos = zzCurrentPosL ; zzMarkedPos = zzMarkedPosL ; boolean eof = zzRefill ( ) ; // get translated positions and possibly new buffer
zzCurrentPosL = zzCurrentPos ; zzMarkedPosL = zzMarkedPos ; zzBufferL = zzBuffer ; zzEndReadL = zzEndRead ; if ( eof ) { zzInput = YYEOF ; break zzForAction ; } else { zzInput = Character . codePointAt ( zzBufferL , zzCurrentPosL , zzEndReadL ) ; zzCurrentPosL += Character . charCount ( zzInput ) ; } } int zzNext = zzTransL [ zzRowMapL [ zzState ] + zzCMapL [ zzInput ] ] ; if ( zzNext == - 1 ) break zzForAction ; zzState = zzNext ; zzAttributes = zzAttrL [ zzState ] ; if ( ( zzAttributes & 1 ) == 1 ) { zzAction = zzState ; zzMarkedPosL = zzCurrentPosL ; if ( ( zzAttributes & 8 ) == 8 ) break zzForAction ; } } } // store back cached position
zzMarkedPos = zzMarkedPosL ; if ( zzInput == YYEOF && zzStartRead == zzCurrentPos ) { zzAtEOF = true ; zzDoEOF ( ) ; { return 0 ; } } else { switch ( zzAction < 0 ? zzAction : ZZ_ACTION [ zzAction ] ) { case 1 : { cssSelector . setCombinator ( Combinator . DESCENDANT ) ; stateReset ( ) ; } case 20 : break ; case 2 : { cssSelector = new CssSelector ( yytext ( ) ) ; selectors . add ( cssSelector ) ; stateSelector ( ) ; } case 21 : break ; case 3 : { cssSelector = new CssSelector ( ) ; selectors . add ( cssSelector ) ; yypushback ( 1 ) ; stateSelector ( ) ; } case 22 : break ; case 4 : { /* ignore whitespaces */
} case 23 : break ; case 5 : { cssSelector = new CssSelector ( ) ; selectors . add ( cssSelector ) ; stateSelector ( ) ; } case 24 : break ; case 6 : { throw new CSSellyException ( "Illegal character <" + yytext ( ) + ">." , yystate ( ) , line ( ) , column ( ) ) ; } case 25 : break ; case 7 : { yypushback ( 1 ) ; stateCombinator ( ) ; } case 26 : break ; case 8 : { stateAttr ( ) ; } case 27 : break ; case 9 : { cssSelector . addAttributeSelector ( yytext ( ) ) ; } case 28 : break ; case 10 : { stateSelector ( ) ; } case 29 : break ; case 11 : { throw new CSSellyException ( "Invalid combinator <" + yytext ( ) + ">." , yystate ( ) , line ( ) , column ( ) ) ; } case 30 : break ; case 12 : { cssSelector . setCombinator ( Combinator . GENERAL_SIBLING ) ; stateReset ( ) ; } case 31 : break ; case 13 : { cssSelector . setCombinator ( Combinator . CHILD ) ; stateReset ( ) ; } case 32 : break ; case 14 : { cssSelector . setCombinator ( Combinator . ADJACENT_SIBLING ) ; stateReset ( ) ; } case 33 : break ; case 15 : { cssSelector . addPseudoFunctionSelector ( pseudoFnName , yytext ( 0 , 1 ) ) ; stateSelector ( ) ; } case 34 : break ; case 16 : { cssSelector . addClassSelector ( yytext ( 1 ) ) ; } case 35 : break ; case 17 : { cssSelector . addIdSelector ( yytext ( 1 ) ) ; } case 36 : break ; case 18 : { cssSelector . addPseudoClassSelector ( yytext ( yycharat ( 1 ) == ':' ? 2 : 1 ) ) ; } case 37 : break ; case 19 : { pseudoFnName = yytext ( yycharat ( 1 ) == ':' ? 2 : 1 , 1 ) ; statePseudoFn ( ) ; } case 38 : break ; default : zzScanError ( ZZ_NO_MATCH ) ; } } }


signature:
public class DbPager { /** * Performs the pagination with given { @ link jodd . joy . page . PageRequest } .
 * @ param pageRequest page request , may be < code > null < / code > , then the { @ link # getDefaultPageRequest ( ) default page request } will be used
 * @ param sql SQL query that lists < b > all < / b > items
 * @ param params SQL query parameters or < code > null < / code >
 * @ param sortColumns array of all column names
 * @ param target db entities for mapping ( as usual in DbOom )
 * @ see # page ( String , java . util . Map , int , int , String , boolean , Class [ ] ) */
public < T > PageData < T > page ( PageRequest pageRequest , final String sql , final Map params , final String [ ] sortColumns , final Class [ ] target ) { } }

implementation:
if ( pageRequest == null ) { pageRequest = getDefaultPageRequest ( ) ; } // check sort
String sortColumName = null ; boolean ascending = true ; int sort = pageRequest . getSort ( ) ; if ( sort != 0 ) { ascending = sort > 0 ; if ( ! ascending ) { sort = - sort ; } int index = sort - 1 ; if ( index >= sortColumns . length ) { index = 1 ; } sortColumName = sortColumns [ index ] ; } // page
int page = pageRequest . getPage ( ) ; int pageSize = pageRequest . getSize ( ) ; PageData < T > pageData = page ( sql , params , page , pageSize , sortColumName , ascending , target ) ; // fix the out - of - bounds
if ( pageData . getItems ( ) . isEmpty ( ) && pageData . currentPage != 0 ) { if ( pageData . currentPage != page ) { // out of bounds
int newPage = pageData . getCurrentPage ( ) ; pageData = page ( sql , params , newPage , pageSize , sortColumName , ascending , target ) ; } } return pageData ;


signature:
public class DbPager { /** * Pages given page .
 * @ param sql sql query that lists < b > all < / b > items
 * @ param params map of SQL parameters
 * @ param page current page to show
 * @ param pageSize number of items to show
 * @ param sortColumnName name of sorting column , < code > null < / code > for no sorting
 * @ param ascending < code > true < / code > for ascending order
 * @ param target db entities for mapping ( sa usual in DbOom ) */
protected < T > PageData < T > page ( String sql , final Map params , final int page , final int pageSize , final String sortColumnName , final boolean ascending , final Class [ ] target ) { } }

implementation: if ( sortColumnName != null ) { sql = buildOrderSql ( sql , sortColumnName , ascending ) ; } int from = ( page - 1 ) * pageSize ; String pageSql = buildPageSql ( sql , from , pageSize ) ; DbSqlBuilder dbsql = sql ( pageSql ) ; DbOomQuery query = query ( dbsql ) ; query . setMaxRows ( pageSize ) ; query . setFetchSize ( pageSize ) ; query . setMap ( params ) ; List < T > list = query . list ( pageSize , target ) ; query . close ( ) ; String countSql = buildCountSql ( sql ) ; dbsql = sql ( countSql ) ; query = query ( dbsql ) ; query . setMap ( params ) ; long count = query . executeCount ( ) ; query . close ( ) ; return new PageData < > ( page , ( int ) count , pageSize , list ) ;


signature:
public class DbPager { /** * Removes the first ' select ' from the sql query . */
protected String removeSelect ( String sql ) { } }

implementation:
int ndx = StringUtil . indexOfIgnoreCase ( sql , "select" ) ; if ( ndx != - 1 ) { sql = sql . substring ( ndx + 6 ) ; // select . length ( )
} return sql ;


signature:
public class DbPager { /** * Removes the first part of the sql up to the relevant ' from ' .
 * Tries to detect sub - queries in the ' select ' part . */
protected String removeToFrom ( String sql ) { } }

implementation:
int from = 0 ; int fromCount = 1 ; int selectCount = 0 ; int lastNdx = 0 ; while ( true ) { int ndx = StringUtil . indexOfIgnoreCase ( sql , "from" , from ) ; if ( ndx == - 1 ) { break ; } // count selects in left part
String left = sql . substring ( lastNdx , ndx ) ; selectCount += StringUtil . countIgnoreCase ( left , "select" ) ; if ( fromCount >= selectCount ) { sql = sql . substring ( ndx ) ; break ; } // find next ' from '
lastNdx = ndx ; from = ndx + 4 ; fromCount ++ ; } return sql ;


signature:
public class DbPager { /** * Removes everything from last " order by " . */
protected String removeLastOrderBy ( String sql ) { } }

implementation: int ndx = StringUtil . lastIndexOfIgnoreCase ( sql , "order by" ) ; if ( ndx != - 1 ) { int ndx2 = sql . lastIndexOf ( sql , ')' ) ; if ( ndx > ndx2 ) { sql = sql . substring ( 0 , ndx ) ; } } return sql ;


signature:
public class HtmlDecoder { /** * Decodes HTML text . Assumes that all character references are properly closed with semi - colon . */
public static String decode ( final String html ) { } }

implementation:
int ndx = html . indexOf ( '&' ) ; if ( ndx == - 1 ) { return html ; } StringBuilder result = new StringBuilder ( html . length ( ) ) ; int lastIndex = 0 ; int len = html . length ( ) ; mainloop : while ( ndx != - 1 ) { result . append ( html . substring ( lastIndex , ndx ) ) ; lastIndex = ndx ; while ( html . charAt ( lastIndex ) != ';' ) { lastIndex ++ ; if ( lastIndex == len ) { lastIndex = ndx ; break mainloop ; } } if ( html . charAt ( ndx + 1 ) == '#' ) { // decimal / hex
char c = html . charAt ( ndx + 2 ) ; int radix ; if ( ( c == 'x' ) || ( c == 'X' ) ) { radix = 16 ; ndx += 3 ; } else { radix = 10 ; ndx += 2 ; } String number = html . substring ( ndx , lastIndex ) ; int i = Integer . parseInt ( number , radix ) ; result . append ( ( char ) i ) ; lastIndex ++ ; } else { // token
String encodeToken = html . substring ( ndx + 1 , lastIndex ) ; char [ ] replacement = ENTITY_MAP . get ( encodeToken ) ; if ( replacement == null ) { result . append ( '&' ) ; lastIndex = ndx + 1 ; } else { result . append ( replacement ) ; lastIndex ++ ; } } ndx = html . indexOf ( '&' , lastIndex ) ; } result . append ( html . substring ( lastIndex ) ) ; return result . toString ( ) ;


signature:
public class HtmlDecoder { /** * Detects the longest character reference name on given position in char array . */
public static String detectName ( final char [ ] input , int ndx ) { } }

implementation:
final Ptr ptr = new Ptr ( ) ; int firstIndex = 0 ; int lastIndex = ENTITY_NAMES . length - 1 ; int len = input . length ; char [ ] lastName = null ; final BinarySearchBase binarySearch = new BinarySearchBase ( ) { @ Override protected int compare ( final int index ) { char [ ] name = ENTITY_NAMES [ index ] ; if ( ptr . offset >= name . length ) { return - 1 ; } return name [ ptr . offset ] - ptr . c ; } } ; while ( true ) { ptr . c = input [ ndx ] ; if ( ! CharUtil . isAlphaOrDigit ( ptr . c ) ) { return lastName != null ? new String ( lastName ) : null ; } firstIndex = binarySearch . findFirst ( firstIndex , lastIndex ) ; if ( firstIndex < 0 ) { return lastName != null ? new String ( lastName ) : null ; } char [ ] element = ENTITY_NAMES [ firstIndex ] ; if ( element . length == ptr . offset + 1 ) { // total match , remember position , continue for finding the longer name
lastName = ENTITY_NAMES [ firstIndex ] ; } lastIndex = binarySearch . findLast ( firstIndex , lastIndex ) ; if ( firstIndex == lastIndex ) { // only one element found , check the rest
for ( int i = ptr . offset ; i < element . length ; i ++ ) { if ( element [ i ] != input [ ndx ] ) { return lastName != null ? new String ( lastName ) : null ; } ndx ++ ; } return new String ( element ) ; } ptr . offset ++ ; ndx ++ ; if ( ndx == len ) { return lastName != null ? new String ( lastName ) : null ; } }


signature:
public class ColumnValueChunk { /** * - - - - - define */
@ Override protected void defineParameter ( final StringBuilder query , final String name , final Object value , DbEntityColumnDescriptor dec ) { } }

implementation: if ( dec == null ) { dec = templateData . lastColumnDec ; } super . defineParameter ( query , name , value , dec ) ;


signature:
public class HsqlDbPager { /** * Appends ORDER BY keyword . */
@ Override protected String buildOrderSql ( String sql , final String column , final boolean ascending ) { } }

implementation: sql += " order by " + column ; if ( ! ascending ) { sql += " desc" ; } return sql ;


signature:
public class HsqlDbPager { /** * Builds page sql using LIMIT keyword after the SELECT . */
@ Override protected String buildPageSql ( String sql , final int from , final int pageSize ) { } }

implementation: sql = removeSelect ( sql ) ; return "select LIMIT " + from + ' ' + pageSize + sql ;


signature:
public class HsqlDbPager { /** * Builds count sql using COUNT ( * ) . */
@ Override protected String buildCountSql ( String sql ) { } }

implementation: sql = removeToFrom ( sql ) ; sql = removeLastOrderBy ( sql ) ; return "select count(*) " + sql ;


signature:
public class DbEntityDescriptor { /** * Resolves list of all columns and properties . */
private void resolveColumnsAndProperties ( final Class type ) { } }

implementation:
PropertyDescriptor [ ] allProperties = ClassIntrospector . get ( ) . lookup ( type ) . getAllPropertyDescriptors ( ) ; List < DbEntityColumnDescriptor > decList = new ArrayList < > ( allProperties . length ) ; int idcount = 0 ; HashSet < String > names = new HashSet < > ( allProperties . length ) ; for ( PropertyDescriptor propertyDescriptor : allProperties ) { DbEntityColumnDescriptor dec = DbMetaUtil . resolveColumnDescriptors ( this , propertyDescriptor , isAnnotated , columnNamingStrategy ) ; if ( dec != null ) { if ( ! names . add ( dec . getColumnName ( ) ) ) { throw new DbOomException ( "Duplicate column name: " + dec . getColumnName ( ) ) ; } decList . add ( dec ) ; if ( dec . isId ) { idcount ++ ; } } } if ( decList . isEmpty ( ) ) { throw new DbOomException ( "No column mappings in entity: " + type ) ; } columnDescriptors = decList . toArray ( new DbEntityColumnDescriptor [ 0 ] ) ; Arrays . sort ( columnDescriptors ) ; // extract ids from sorted list
if ( idcount > 0 ) { idColumnDescriptors = new DbEntityColumnDescriptor [ idcount ] ; idcount = 0 ; for ( DbEntityColumnDescriptor dec : columnDescriptors ) { if ( dec . isId ) { idColumnDescriptors [ idcount ++ ] = dec ; } } }


signature:
public class DbEntityDescriptor { /** * Finds column descriptor by column name . Case is ignored . */
public DbEntityColumnDescriptor findByColumnName ( final String columnName ) { } }

implementation: if ( columnName == null ) { return null ; } init ( ) ; for ( DbEntityColumnDescriptor columnDescriptor : columnDescriptors ) { if ( columnDescriptor . columnName . equalsIgnoreCase ( columnName ) ) { return columnDescriptor ; } } return null ;


signature:
public class DbEntityDescriptor { /** * Finds column descriptor by property name . */
public DbEntityColumnDescriptor findByPropertyName ( final String propertyName ) { } }

implementation: if ( propertyName == null ) { return null ; } init ( ) ; for ( DbEntityColumnDescriptor columnDescriptor : columnDescriptors ) { if ( columnDescriptor . propertyName . equals ( propertyName ) ) { return columnDescriptor ; } } return null ;


signature:
public class DbEntityDescriptor { /** * Returns property name for specified column name . */
public String getPropertyName ( final String columnName ) { } }

implementation: DbEntityColumnDescriptor dec = findByColumnName ( columnName ) ; return dec == null ? null : dec . propertyName ;


signature:
public class DbEntityDescriptor { /** * Returns column name for specified property name . . */
public String getColumnName ( final String propertyName ) { } }

implementation: DbEntityColumnDescriptor dec = findByPropertyName ( propertyName ) ; return dec == null ? null : dec . columnName ;


signature:
public class DbEntityDescriptor { /** * Returns ID value for given entity instance . */
public Object getIdValue ( final E object ) { } }

implementation: final String propertyName = getIdPropertyName ( ) ; return BeanUtil . declared . getProperty ( object , propertyName ) ;


signature:
public class DbEntityDescriptor { /** * Sets ID value for given entity . */
public void setIdValue ( final E object , final Object value ) { } }

implementation: final String propertyName = getIdPropertyName ( ) ; BeanUtil . declared . setProperty ( object , propertyName , value ) ;


signature:
public class DbEntityDescriptor { /** * Returns unique key for this entity . Returned key
 * is built from entity class and id value . */
public String getKeyValue ( final E object ) { } }

implementation: Object idValue = getIdValue ( object ) ; String idValueString = idValue == null ? StringPool . NULL : idValue . toString ( ) ; return type . getName ( ) . concat ( StringPool . COLON ) . concat ( idValueString ) ;


signature:
public class StringBand { /** * Appends a string . */
public StringBand append ( String s ) { } }

implementation: if ( s == null ) { s = StringPool . NULL ; } if ( index >= array . length ) { expandCapacity ( ) ; } array [ index ++ ] = s ; length += s . length ( ) ; return this ;


signature:
public class StringBand { /** * Specifies the new index . */
public void setIndex ( final int newIndex ) { } }

implementation: if ( newIndex < 0 ) { throw new ArrayIndexOutOfBoundsException ( newIndex ) ; } if ( newIndex > array . length ) { String [ ] newArray = new String [ newIndex ] ; System . arraycopy ( array , 0 , newArray , 0 , index ) ; array = newArray ; } if ( newIndex > index ) { for ( int i = index ; i < newIndex ; i ++ ) { array [ i ] = StringPool . EMPTY ; } } else if ( newIndex < index ) { for ( int i = newIndex ; i < index ; i ++ ) { array [ i ] = null ; } } index = newIndex ; length = calculateLength ( ) ;


signature:
public class StringBand { /** * Returns char at given position .
 * This method is < b > not < / b > fast as it calculates
 * the right string array element and the offset ! */
public char charAt ( final int pos ) { } }

implementation: int len = 0 ; for ( int i = 0 ; i < index ; i ++ ) { int newlen = len + array [ i ] . length ( ) ; if ( pos < newlen ) { return array [ i ] . charAt ( pos - len ) ; } len = newlen ; } throw new IllegalArgumentException ( "Invalid char index" ) ;


signature:
public class StringBand { /** * Expands internal string array by multiplying its size by 2. */
protected void expandCapacity ( ) { } }

implementation: String [ ] newArray = new String [ array . length << 1 ] ; System . arraycopy ( array , 0 , newArray , 0 , index ) ; array = newArray ;


signature:
public class StringBand { /** * Calculates string length . */
protected int calculateLength ( ) { } }

implementation: int len = 0 ; for ( int i = 0 ; i < index ; i ++ ) { len += array [ i ] . length ( ) ; } return len ;


signature:
public class ScopedProxyManager { /** * Returns scoped proxy bean if injection scopes are mixed on some injection point .
 * May return < code > null < / code > if mixing scopes is not detected . */
public Object lookupValue ( final PetiteContainer petiteContainer , final BeanDefinition targetBeanDefinition , final BeanDefinition refBeanDefinition ) { } }

implementation:
Scope targetScope = targetBeanDefinition . scope ; Scope refBeanScope = refBeanDefinition . scope ; boolean detectMixedScopes = petiteContainer . config ( ) . isDetectMixedScopes ( ) ; boolean wireScopedProxy = petiteContainer . config ( ) . isWireScopedProxy ( ) ; // when target scope is null then all beans can be injected into it
// similar to prototype scope
if ( targetScope != null && ! targetScope . accept ( refBeanScope ) ) { if ( ! wireScopedProxy ) { if ( detectMixedScopes ) { throw new PetiteException ( createMixingMessage ( targetBeanDefinition , refBeanDefinition ) ) ; } return null ; } if ( detectMixedScopes ) { if ( log . isWarnEnabled ( ) ) { log . warn ( createMixingMessage ( targetBeanDefinition , refBeanDefinition ) ) ; } } else { if ( log . isDebugEnabled ( ) ) { log . debug ( createMixingMessage ( targetBeanDefinition , refBeanDefinition ) ) ; } } String scopedProxyBeanName = refBeanDefinition . name ; Object proxy = proxies . get ( scopedProxyBeanName ) ; if ( proxy == null ) { proxy = createScopedProxyBean ( petiteContainer , refBeanDefinition ) ; proxies . put ( scopedProxyBeanName , proxy ) ; } return proxy ; } return null ;


signature:
public class ScopedProxyManager { /** * Creates mixed scope message . */
protected String createMixingMessage ( final BeanDefinition targetBeanDefinition , final BeanDefinition refBeanDefinition ) { } }

implementation: return "Scopes mixing detected: " + refBeanDefinition . name + "@" + refBeanDefinition . scope . getClass ( ) . getSimpleName ( ) + " -> " + targetBeanDefinition . name + "@" + targetBeanDefinition . scope . getClass ( ) . getSimpleName ( ) ;


signature:
public class ScopedProxyManager { /** * Creates scoped proxy bean for given bean definition . */
protected Object createScopedProxyBean ( final PetiteContainer petiteContainer , final BeanDefinition refBeanDefinition ) { } }

implementation:
Class beanType = refBeanDefinition . type ; Class proxyClass = proxyClasses . get ( beanType ) ; if ( proxyClass == null ) { // create proxy class only once
if ( refBeanDefinition instanceof ProxettaBeanDefinition ) { // special case , double proxy !
ProxettaBeanDefinition pbd = ( ProxettaBeanDefinition ) refBeanDefinition ; ProxyProxetta proxetta = Proxetta . proxyProxetta ( ) . withAspects ( ArraysUtil . insert ( pbd . proxyAspects , aspect , 0 ) ) ; proxetta . setClassNameSuffix ( "$ScopedProxy" ) ; proxetta . setVariableClassName ( true ) ; ProxyProxettaFactory builder = proxetta . proxy ( ) . setTarget ( pbd . originalTarget ) ; proxyClass = builder . define ( ) ; proxyClasses . put ( beanType , proxyClass ) ; } else { ProxyProxetta proxetta = Proxetta . proxyProxetta ( ) . withAspect ( aspect ) ; proxetta . setClassNameSuffix ( "$ScopedProxy" ) ; proxetta . setVariableClassName ( true ) ; ProxyProxettaFactory builder = proxetta . proxy ( ) . setTarget ( beanType ) ; proxyClass = builder . define ( ) ; proxyClasses . put ( beanType , proxyClass ) ; } } Object proxy ; try { proxy = ClassUtil . newInstance ( proxyClass ) ; Field field = proxyClass . getField ( "$__petiteContainer$0" ) ; field . set ( proxy , petiteContainer ) ; field = proxyClass . getField ( "$__name$0" ) ; field . set ( proxy , refBeanDefinition . name ) ; } catch ( Exception ex ) { throw new PetiteException ( ex ) ; } return proxy ;


signature:
public class LoopingTagSupport { /** * Prepares step value . If step is 0 , it will be set to + 1 or - 1 , depending on start and end value .
 * If autoDirection flag is < code > true < / code > then it is assumed that step is positive ,
 * and that direction ( step sign ) should be detected from start and end value .
 * If checkDirection flag is < code > true < / code > than it checks loop direction ( step sign ) based on
 * start and end value . Throws an exception if direction is invalid .
 * If autoDirection is set , direction checking is skipped . */
protected void prepareStepDirection ( final boolean autoDirection , final boolean checkDirection ) { } }

implementation: if ( step == 0 ) { step = ( start <= end ) ? 1 : - 1 ; return ; } if ( autoDirection ) { if ( step < 0 ) { throw new IllegalArgumentException ( "Step value can't be negative: " + step ) ; } if ( start > end ) { step = - step ; } return ; } if ( checkDirection ) { if ( start < end ) { if ( step < 0 ) { throw new IllegalArgumentException ( "Negative step value for increasing loop" ) ; } return ; } if ( start > end ) { if ( step > 0 ) { throw new IllegalArgumentException ( "Positive step value for decreasing loop" ) ; } } }


signature:
public class LoopingTagSupport { /** * Loops body . */
protected void loopBody ( ) throws JspException { } }

implementation: JspFragment body = getJspBody ( ) ; if ( body == null ) { return ; } LoopIterator loopIterator = new LoopIterator ( start , end , step , modulus ) ; if ( status != null ) { getJspContext ( ) . setAttribute ( status , loopIterator ) ; } while ( loopIterator . next ( ) ) { TagUtil . invokeBody ( body ) ; } if ( status != null ) { getJspContext ( ) . removeAttribute ( status ) ; }


signature:
public class DirWatcher { /** * Initializes dir watcher by reading all files
 * from watched folder . */
protected void init ( ) { } }

implementation: File [ ] filesArray = dir . listFiles ( ) ; filesCount = 0 ; if ( filesArray != null ) { filesCount = filesArray . length ; for ( File file : filesArray ) { if ( ! acceptFile ( file ) ) { continue ; } map . put ( file , new MutableLong ( file . lastModified ( ) ) ) ; } }


signature:
public class DirWatcher { /** * Accepts if a file is going to be watched . */
protected boolean acceptFile ( final File file ) { } }

implementation:
if ( ! file . isFile ( ) ) { return false ; // ignore non - files
} String fileName = file . getName ( ) ; if ( ignoreDotFiles ) { if ( fileName . startsWith ( StringPool . DOT ) ) { return false ; // ignore hidden files
} } if ( patterns == null ) { return true ; } return Wildcard . matchOne ( fileName , patterns ) != - 1 ;


signature:
public class DirWatcher { /** * Enables usage of provided watch file . */
public DirWatcher useWatchFile ( final String name ) { } }

implementation: watchFile = new File ( dir , name ) ; if ( ! watchFile . isFile ( ) || ! watchFile . exists ( ) ) { try { FileUtil . touch ( watchFile ) ; } catch ( IOException ioex ) { throw new DirWatcherException ( "Invalid watch file: " + name , ioex ) ; } } watchFileLastAccessTime = watchFile . lastModified ( ) ; return this ;


signature:
public class DirWatcher { /** * Starts the watcher . */
public void start ( final long pollingInterval ) { } }

implementation: if ( timer == null ) { if ( ! startBlank ) { init ( ) ; } timer = new Timer ( true ) ; timer . schedule ( new WatchTask ( ) , 0 , pollingInterval ) ; }


signature:
public class DirWatcher { /** * Triggers listeners on file change . */
protected void onChange ( final DirWatcherEvent . Type type , final File file ) { } }

implementation: listeners . accept ( new DirWatcherEvent ( type , file ) ) ;


signature:
public class CompositeEnumeration { /** * Adds an enumeration to this composite . */
public void add ( final Enumeration < T > enumeration ) { } }

implementation: if ( allEnumerations . contains ( enumeration ) ) { throw new IllegalArgumentException ( "Duplicate enumeration" ) ; } allEnumerations . add ( enumeration ) ;


signature:
public class CompositeEnumeration { /** * Returns < code > true < / code > if composite has more elements . */
public boolean hasMoreElements ( ) { } }

implementation: if ( currentEnumeration == - 1 ) { currentEnumeration = 0 ; } for ( int i = currentEnumeration ; i < allEnumerations . size ( ) ; i ++ ) { Enumeration enumeration = allEnumerations . get ( i ) ; if ( enumeration . hasMoreElements ( ) ) { currentEnumeration = i ; return true ; } } return false ;


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

implementation:
if ( value instanceof Collection ) { final Collection collection = ( Collection ) value ; final double [ ] target = new double [ 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 < Double > doubleArrayList = new ArrayList < > ( ) ; for ( final Object element : iterable ) { final double convertedValue = convertType ( element ) ; doubleArrayList . add ( Double . valueOf ( convertedValue ) ) ; } final double [ ] array = new double [ doubleArrayList . size ( ) ] ; for ( int i = 0 ; i < doubleArrayList . size ( ) ; i ++ ) { final Double d = doubleArrayList . get ( i ) ; array [ i ] = d . doubleValue ( ) ; } return array ; } if ( value instanceof CharSequence ) { final String [ ] strings = StringUtil . splitc ( value . toString ( ) , ArrayConverter . NUMBER_DELIMITERS ) ; return convertArrayToArray ( strings ) ; } // everything else :
return convertToSingleElementArray ( value ) ;


signature:
public class FieldWriter { /** * Returns the size of the field _ info JVMS structure generated by this FieldWriter . Also adds the
 * names of the attributes of this field in the constant pool .
 * @ return the size in bytes of the field _ info JVMS structure . */
int computeFieldInfoSize ( ) { } }

implementation:
// The access _ flags , name _ index , descriptor _ index and attributes _ count fields use 8 bytes .
int size = 8 ; // For ease of reference , we use here the same attribute order as in Section 4.7 of the JVMS .
if ( constantValueIndex != 0 ) { // ConstantValue attributes always use 8 bytes .
symbolTable . addConstantUtf8 ( Constants . CONSTANT_VALUE ) ; size += 8 ; } // Before Java 1.5 , synthetic fields are represented with a Synthetic attribute .
if ( ( accessFlags & Opcodes . ACC_SYNTHETIC ) != 0 && symbolTable . getMajorVersion ( ) < Opcodes . V1_5 ) { // Synthetic attributes always use 6 bytes .
symbolTable . addConstantUtf8 ( Constants . SYNTHETIC ) ; size += 6 ; } if ( signatureIndex != 0 ) { // Signature attributes always use 8 bytes .
symbolTable . addConstantUtf8 ( Constants . SIGNATURE ) ; size += 8 ; } // ACC _ DEPRECATED is ASM specific , the ClassFile format uses a Deprecated attribute instead .
if ( ( accessFlags & Opcodes . ACC_DEPRECATED ) != 0 ) { // Deprecated attributes always use 6 bytes .
symbolTable . addConstantUtf8 ( Constants . DEPRECATED ) ; size += 6 ; } if ( lastRuntimeVisibleAnnotation != null ) { size += lastRuntimeVisibleAnnotation . computeAnnotationsSize ( Constants . RUNTIME_VISIBLE_ANNOTATIONS ) ; } if ( lastRuntimeInvisibleAnnotation != null ) { size += lastRuntimeInvisibleAnnotation . computeAnnotationsSize ( Constants . RUNTIME_INVISIBLE_ANNOTATIONS ) ; } if ( lastRuntimeVisibleTypeAnnotation != null ) { size += lastRuntimeVisibleTypeAnnotation . computeAnnotationsSize ( Constants . RUNTIME_VISIBLE_TYPE_ANNOTATIONS ) ; } if ( lastRuntimeInvisibleTypeAnnotation != null ) { size += lastRuntimeInvisibleTypeAnnotation . computeAnnotationsSize ( Constants . RUNTIME_INVISIBLE_TYPE_ANNOTATIONS ) ; } if ( firstAttribute != null ) { size += firstAttribute . computeAttributesSize ( symbolTable ) ; } return size ;


signature:
public class FieldWriter { /** * Puts the content of the field _ info JVMS structure generated by this FieldWriter into the given
 * ByteVector .
 * @ param output where the field _ info structure must be put . */
void putFieldInfo ( final ByteVector output ) { } }

implementation:
boolean useSyntheticAttribute = symbolTable . getMajorVersion ( ) < Opcodes . V1_5 ; // Put the access _ flags , name _ index and descriptor _ index fields .
int mask = useSyntheticAttribute ? Opcodes . ACC_SYNTHETIC : 0 ; output . putShort ( accessFlags & ~ mask ) . putShort ( nameIndex ) . putShort ( descriptorIndex ) ; // Compute and put the attributes _ count field .
// For ease of reference , we use here the same attribute order as in Section 4.7 of the JVMS .
int attributesCount = 0 ; if ( constantValueIndex != 0 ) { ++ attributesCount ; } if ( ( accessFlags & Opcodes . ACC_SYNTHETIC ) != 0 && useSyntheticAttribute ) { ++ attributesCount ; } if ( signatureIndex != 0 ) { ++ attributesCount ; } if ( ( accessFlags & Opcodes . ACC_DEPRECATED ) != 0 ) { ++ attributesCount ; } if ( lastRuntimeVisibleAnnotation != null ) { ++ attributesCount ; } if ( lastRuntimeInvisibleAnnotation != null ) { ++ attributesCount ; } if ( lastRuntimeVisibleTypeAnnotation != null ) { ++ attributesCount ; } if ( lastRuntimeInvisibleTypeAnnotation != null ) { ++ attributesCount ; } if ( firstAttribute != null ) { attributesCount += firstAttribute . getAttributeCount ( ) ; } output . putShort ( attributesCount ) ; // Put the field _ info attributes .
// For ease of reference , we use here the same attribute order as in Section 4.7 of the JVMS .
if ( constantValueIndex != 0 ) { output . putShort ( symbolTable . addConstantUtf8 ( Constants . CONSTANT_VALUE ) ) . putInt ( 2 ) . putShort ( constantValueIndex ) ; } if ( ( accessFlags & Opcodes . ACC_SYNTHETIC ) != 0 && useSyntheticAttribute ) { output . putShort ( symbolTable . addConstantUtf8 ( Constants . SYNTHETIC ) ) . putInt ( 0 ) ; } if ( signatureIndex != 0 ) { output . putShort ( symbolTable . addConstantUtf8 ( Constants . SIGNATURE ) ) . putInt ( 2 ) . putShort ( signatureIndex ) ; } if ( ( accessFlags & Opcodes . ACC_DEPRECATED ) != 0 ) { output . putShort ( symbolTable . addConstantUtf8 ( Constants . DEPRECATED ) ) . putInt ( 0 ) ; } if ( lastRuntimeVisibleAnnotation != null ) { lastRuntimeVisibleAnnotation . putAnnotations ( symbolTable . addConstantUtf8 ( Constants . RUNTIME_VISIBLE_ANNOTATIONS ) , output ) ; } if ( lastRuntimeInvisibleAnnotation != null ) { lastRuntimeInvisibleAnnotation . putAnnotations ( symbolTable . addConstantUtf8 ( Constants . RUNTIME_INVISIBLE_ANNOTATIONS ) , output ) ; } if ( lastRuntimeVisibleTypeAnnotation != null ) { lastRuntimeVisibleTypeAnnotation . putAnnotations ( symbolTable . addConstantUtf8 ( Constants . RUNTIME_VISIBLE_TYPE_ANNOTATIONS ) , output ) ; } if ( lastRuntimeInvisibleTypeAnnotation != null ) { lastRuntimeInvisibleTypeAnnotation . putAnnotations ( symbolTable . addConstantUtf8 ( Constants . RUNTIME_INVISIBLE_TYPE_ANNOTATIONS ) , output ) ; } if ( firstAttribute != null ) { firstAttribute . putAttributes ( symbolTable , output ) ; }


signature:
public class HtmlCCommentExpressionMatcher { /** * Matches conditional comment expression with current mode .
 * Returns < code > true < / code > it conditional comment expression is positive ,
 * otherwise returns < code > false < / code > . */
public boolean match ( final float ieVersion , String expression ) { } }

implementation: expression = StringUtil . removeChars ( expression , "()" ) ; expression = expression . substring ( 3 ) ; String [ ] andChunks = StringUtil . splitc ( expression , '&' ) ; boolean valid = true ; for ( String andChunk : andChunks ) { String [ ] orChunks = StringUtil . splitc ( andChunk , '|' ) ; boolean innerValid = false ; for ( String orChunk : orChunks ) { orChunk = orChunk . trim ( ) ; if ( orChunk . startsWith ( "IE " ) ) { String value = orChunk . substring ( 3 ) ; float number = Float . parseFloat ( value ) ; if ( versionToCompare ( ieVersion , number ) == number ) { innerValid = true ; break ; } continue ; } if ( orChunk . startsWith ( "!IE " ) ) { String value = orChunk . substring ( 4 ) ; float number = Float . parseFloat ( value ) ; if ( versionToCompare ( ieVersion , number ) != number ) { innerValid = true ; break ; } continue ; } if ( orChunk . startsWith ( "lt IE " ) ) { String value = orChunk . substring ( 6 ) ; float number = Float . parseFloat ( value ) ; if ( ieVersion < number ) { innerValid = true ; break ; } continue ; } if ( orChunk . startsWith ( "lte IE " ) ) { String value = orChunk . substring ( 7 ) ; float number = Float . parseFloat ( value ) ; if ( versionToCompare ( ieVersion , number ) <= number ) { innerValid = true ; break ; } continue ; } if ( orChunk . startsWith ( "gt IE " ) ) { String value = orChunk . substring ( 6 ) ; float number = Float . parseFloat ( value ) ; if ( versionToCompare ( ieVersion , number ) > number ) { innerValid = true ; break ; } continue ; } if ( orChunk . startsWith ( "gte IE " ) ) { String value = orChunk . substring ( 7 ) ; float number = Float . parseFloat ( value ) ; if ( ieVersion >= number ) { innerValid = true ; break ; } continue ; } } valid = valid && innerValid ; } return valid ;


signature:
public class FastByteBuffer { /** * Appends another fast buffer to this one . */
public FastByteBuffer append ( final FastByteBuffer buff ) { } }

implementation: if ( buff . offset == 0 ) { return this ; } append ( buff . buffer , 0 , buff . offset ) ; return this ;


signature:
public class Target { /** * Creates a common target over a value , with known scope data . */
public static Target ofValue ( final Object value , final ScopeData scopeData ) { } }

implementation: return new Target ( value , null , scopeData , null , VALUE_INSTANCE_CREATOR ) ;


signature:
public class Target { /** * Creates a common target over a method param . */
public static Target ofMethodParam ( final MethodParam methodParam , final Object object ) { } }

implementation: return new Target ( object , methodParam . type ( ) , methodParam . scopeData ( ) , methodParam . mapperFunction ( ) , VALUE_INSTANCE_CREATOR ) ;


signature:
public class Target { /** * Creates a common target over a method param . */
public static Target ofMethodParam ( final MethodParam methodParam , final Function < Class , Object > valueInstanceCreator ) { } }

implementation: return new Target ( null , methodParam . type ( ) , methodParam . scopeData ( ) , methodParam . mapperFunction ( ) , valueInstanceCreator ) ;


signature:
public class Target { /** * Writes value to this target . Depending on a flag , writing the value can be
 * completely silent , when no exception is thrown and with top performances .
 * Otherwise , an exception is thrown on a failure . */
public void writeValue ( final InjectionPoint injectionPoint , final Object propertyValue , final boolean silent ) { } }

implementation: writeValue ( injectionPoint . targetName ( ) , propertyValue , silent ) ;


signature:
public class DecoraParser { /** * Decorates page content with decorator template and outputs the result . */
public void decorate ( final Writer writer , final char [ ] pageContent , final char [ ] decoraContent ) throws IOException { } }

implementation: DecoraTag [ ] decoraTags = parseDecorator ( decoraContent ) ; parsePage ( pageContent , decoraTags ) ; writeDecoratedPage ( writer , decoraContent , pageContent , decoraTags ) ;


signature:
public class DecoraParser { /** * Parses decorator file and collects { @ link jodd . decora . parser . DecoraTag Decora tags }
 * used in template . Returned Decora tags have start and end index set ,
 * but their region is not set . */
protected DecoraTag [ ] parseDecorator ( final char [ ] decoraContent ) { } }

implementation: LagartoParser lagartoParser = new LagartoParser ( decoraContent ) ; lagartoParser . getConfig ( ) . setEnableRawTextModes ( false ) ; DecoratorTagVisitor visitor = new DecoratorTagVisitor ( ) ; lagartoParser . parse ( visitor ) ; return visitor . getDecoraTags ( ) ;


signature:
public class DecoraParser { /** * Parses target page and extracts Decora regions for replacements . */
protected void parsePage ( final char [ ] pageContent , final DecoraTag [ ] decoraTags ) { } }

implementation: LagartoParser lagartoParser = new LagartoParser ( pageContent ) ; PageRegionExtractor writer = new PageRegionExtractor ( decoraTags ) ; lagartoParser . parse ( writer ) ;


signature:
public class DecoraParser { /** * Writes decorated content . */
protected void writeDecoratedPage ( final Writer out , final char [ ] decoratorContent , final char [ ] pageContent , final DecoraTag [ ] decoraTags ) throws IOException { } }

implementation:
int ndx = 0 ; for ( DecoraTag decoraTag : decoraTags ) { // [1 ] just copy content before the Decora tag
int decoratorLen = decoraTag . getStartIndex ( ) - ndx ; if ( decoratorLen <= 0 ) { continue ; } out . write ( decoratorContent , ndx , decoratorLen ) ; ndx = decoraTag . getEndIndex ( ) ; // [2 ] now write region at the place of Decora tag
int regionLen = decoraTag . getRegionLength ( ) ; if ( regionLen == 0 ) { if ( decoraTag . hasDefaultValue ( ) ) { out . write ( decoratorContent , decoraTag . getDefaultValueStart ( ) , decoraTag . getDefaultValueLength ( ) ) ; } } else { writeRegion ( out , pageContent , decoraTag , decoraTags ) ; } } // write remaining content
out . write ( decoratorContent , ndx , decoratorContent . length - ndx ) ;


signature:
public class DecoraParser { /** * Writes region to output , but extracts all inner regions . */
protected void writeRegion ( final Writer out , final char [ ] pageContent , final DecoraTag decoraTag , final DecoraTag [ ] decoraTags ) throws IOException { } }

implementation:
int regionStart = decoraTag . getRegionStart ( ) ; int regionLen = decoraTag . getRegionLength ( ) ; int regionEnd = regionStart + regionLen ; for ( DecoraTag innerDecoraTag : decoraTags ) { if ( decoraTag == innerDecoraTag ) { continue ; } if ( decoraTag . isRegionUndefined ( ) ) { continue ; } if ( innerDecoraTag . isInsideOtherTagRegion ( decoraTag ) ) { // write everything from region start to the inner Decora tag
out . write ( pageContent , regionStart , innerDecoraTag . getRegionTagStart ( ) - regionStart ) ; regionStart = innerDecoraTag . getRegionTagEnd ( ) ; } } // write remaining content of the region
out . write ( pageContent , regionStart , regionEnd - regionStart ) ;


signature:
public class Text { /** * Returns < code > true < / code > if text content is blank . */
public boolean isBlank ( ) { } }

implementation: if ( blank == null ) { blank = Boolean . valueOf ( StringUtil . isBlank ( nodeValue ) ) ; } return blank . booleanValue ( ) ;


signature:
public class HttpTunnel { /** * Starts HTTP tunnel . Method ends when the tunnel is stopped . */
public void start ( ) throws IOException { } }

implementation: serverSocket = new ServerSocket ( listenPort , socketBacklog ) ; serverSocket . setReuseAddress ( true ) ; executorService = Executors . newFixedThreadPool ( threadPoolSize ) ; running = true ; while ( running ) { Socket socket = serverSocket . accept ( ) ; socket . setKeepAlive ( false ) ; executorService . execute ( onSocketConnection ( socket ) ) ; } executorService . shutdown ( ) ;


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

implementation:
if ( value instanceof Collection ) { final Collection collection = ( Collection ) value ; final int [ ] target = new int [ 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 FastIntBuffer fastIntBuffer = new FastIntBuffer ( ) ; for ( final Object element : iterable ) { final int convertedValue = convertType ( element ) ; fastIntBuffer . append ( convertedValue ) ; } return fastIntBuffer . toArray ( ) ; } if ( value instanceof CharSequence ) { final String [ ] strings = StringUtil . splitc ( value . toString ( ) , ArrayConverter . NUMBER_DELIMITERS ) ; return convertArrayToArray ( strings ) ; } // everything else :
return convertToSingleElementArray ( value ) ;