signature:
public class HttpUtil { /** * Extracts header parameter . Returns < code > null < / code >
 * if parameter not found . */
public static String extractHeaderParameter ( final String header , final String parameter , final char separator ) { } }

implementation:
int index = 0 ; while ( true ) { index = header . indexOf ( separator , index ) ; if ( index == - 1 ) { return null ; } index ++ ; // skip whitespaces
while ( index < header . length ( ) && header . charAt ( index ) == ' ' ) { index ++ ; } int eqNdx = header . indexOf ( '=' , index ) ; if ( eqNdx == - 1 ) { return null ; } String paramName = header . substring ( index , eqNdx ) ; eqNdx ++ ; if ( ! paramName . equalsIgnoreCase ( parameter ) ) { index = eqNdx ; continue ; } int endIndex = header . indexOf ( ';' , eqNdx ) ; if ( endIndex == - 1 ) { return header . substring ( eqNdx ) ; } else { return header . substring ( eqNdx , endIndex ) ; } }


signature:
public class DbUtil { /** * Sets prepared statement object using target SQL type .
 * Here Jodd makes conversion and not JDBC driver .
 * See : http : / / www . tutorialspoint . com / jdbc / jdbc - data - types . htm */
public static void setPreparedStatementObject ( final PreparedStatement preparedStatement , final int index , final Object value , final int targetSqlType ) throws SQLException { } }

implementation: if ( value == null ) { preparedStatement . setNull ( index , Types . NULL ) ; return ; } switch ( targetSqlType ) { case Types . VARCHAR : case Types . LONGVARCHAR : case Types . CHAR : preparedStatement . setString ( index , Converter . get ( ) . toString ( value ) ) ; break ; case Types . INTEGER : case Types . SMALLINT : case Types . TINYINT : preparedStatement . setInt ( index , Converter . get ( ) . toIntValue ( value ) ) ; break ; case Types . BIGINT : preparedStatement . setLong ( index , Converter . get ( ) . toLongValue ( value ) ) ; break ; case Types . BOOLEAN : case Types . BIT : preparedStatement . setBoolean ( index , Converter . get ( ) . toBooleanValue ( value ) ) ; break ; case Types . DATE : preparedStatement . setDate ( index , TypeConverterManager . get ( ) . convertType ( value , java . sql . Date . class ) ) ; break ; case Types . NUMERIC : case Types . DECIMAL : preparedStatement . setBigDecimal ( index , Converter . get ( ) . toBigDecimal ( value ) ) ; break ; case Types . DOUBLE : preparedStatement . setDouble ( index , Converter . get ( ) . toDoubleValue ( value ) ) ; break ; case Types . REAL : case Types . FLOAT : preparedStatement . setFloat ( index , Converter . get ( ) . toFloatValue ( value ) ) ; break ; case Types . TIME : preparedStatement . setTime ( index , TypeConverterManager . get ( ) . convertType ( value , java . sql . Time . class ) ) ; break ; case Types . TIMESTAMP : preparedStatement . setTimestamp ( index , TypeConverterManager . get ( ) . convertType ( value , Timestamp . class ) ) ; break ; case Types . BINARY : case Types . VARBINARY : preparedStatement . setBytes ( index , TypeConverterManager . get ( ) . convertType ( value , byte [ ] . class ) ) ; break ; default : if ( targetSqlType != SqlType . DB_SQLTYPE_NOT_AVAILABLE ) { preparedStatement . setObject ( index , value , targetSqlType ) ; } else { preparedStatement . setObject ( index , value ) ; } }


signature:
public class BasePathMacros { /** * { @ inheritDoc } */
@ Override public boolean init ( final String actionPath , final String [ ] separators ) { } }

implementation:
String prefix = separators [ 0 ] ; String split = separators [ 1 ] ; String suffix = separators [ 2 ] ; macrosCount = StringUtil . count ( actionPath , prefix ) ; if ( macrosCount == 0 ) { return false ; } names = new String [ macrosCount ] ; patterns = new String [ macrosCount ] ; fixed = new String [ macrosCount + 1 ] ; int offset = 0 ; int i = 0 ; while ( true ) { int [ ] ndx = StringUtil . indexOfRegion ( actionPath , prefix , suffix , offset ) ; if ( ndx == null ) { break ; } fixed [ i ] = actionPath . substring ( offset , ndx [ 0 ] ) ; String name = actionPath . substring ( ndx [ 1 ] , ndx [ 2 ] ) ; // name : pattern
String pattern = null ; int colonNdx = name . indexOf ( split ) ; if ( colonNdx != - 1 ) { pattern = name . substring ( colonNdx + 1 ) . trim ( ) ; name = name . substring ( 0 , colonNdx ) . trim ( ) ; } this . patterns [ i ] = pattern ; this . names [ i ] = name ; // iterate
offset = ndx [ 3 ] ; i ++ ; } if ( offset < actionPath . length ( ) ) { fixed [ i ] = actionPath . substring ( offset ) ; } else { fixed [ i ] = StringPool . EMPTY ; } return true ;


signature:
public class BasePathMacros { /** * { @ inheritDoc } */
@ Override public int match ( final String actionPath ) { } }

implementation: String [ ] values = process ( actionPath , true ) ; if ( values == null ) { return - 1 ; } int macroChars = 0 ; for ( String value : values ) { if ( value != null ) { macroChars += value . length ( ) ; } } return actionPath . length ( ) - macroChars ;


signature:
public class BasePathMacros { /** * Process action path in two modes : matching mode and extracting mode .
 * @ return string array of extracted macro values ( null element is allowed ) or null */
private String [ ] process ( final String actionPath , final boolean match ) { } }

implementation:
// first check the first fixed as a prefix
if ( match && ! actionPath . startsWith ( fixed [ 0 ] ) ) { return null ; } String [ ] values = new String [ macrosCount ] ; int offset = fixed [ 0 ] . length ( ) ; int i = 0 ; while ( i < macrosCount ) { int nexti = i ; // defines next fixed string to match
String nextFixed ; while ( true ) { nexti ++ ; if ( nexti > macrosCount ) { nextFixed = null ; // match to the end of line
break ; } nextFixed = fixed [ nexti ] ; if ( nextFixed . length ( ) != 0 ) { break ; } // next fixed is an empty string , so skip the next macro .
} // find next fixed string
int ndx ; if ( nextFixed != null ) { ndx = actionPath . indexOf ( nextFixed , offset ) ; } else { ndx = actionPath . length ( ) ; } if ( ndx == - 1 ) { return null ; } String macroValue = actionPath . substring ( offset , ndx ) ; values [ i ] = macroValue ; if ( match && patterns [ i ] != null ) { if ( ! matchValue ( i , macroValue ) ) { return null ; } } if ( nextFixed == null ) { offset = ndx ; break ; } // iterate
int nextFixedLength = nextFixed . length ( ) ; offset = ndx + nextFixedLength ; i = nexti ; } if ( offset != actionPath . length ( ) ) { // action path is not consumed fully during this matching
return null ; } return values ;


signature:
public class LagartoHtmlRenderer { /** * Renders node to appendable . */
public String toHtml ( final Node node , final Appendable appendable ) { } }

implementation: NodeVisitor renderer = createRenderer ( appendable ) ; node . visit ( renderer ) ; return appendable . toString ( ) ;


signature:
public class LagartoHtmlRenderer { /** * Renders node children to appendable . */
public String toInnerHtml ( final Node node , final Appendable appendable ) { } }

implementation: NodeVisitor renderer = createRenderer ( appendable ) ; node . visitChildren ( renderer ) ; return appendable . toString ( ) ;


signature:
public class DecoraRequestWrapper { /** * Returns < code > null < / code > for excluded HTTP headers . */
@ Override public String getHeader ( final String header ) { } }

implementation: if ( isExcluded ( header ) ) { return null ; } return super . getHeader ( header ) ;


signature:
public class AbstractCacheMap { /** * { @ inheritDoc } */
@ Override public void put ( final K key , final V object , final long timeout ) { } }

implementation: Objects . requireNonNull ( object ) ; final long stamp = lock . writeLock ( ) ; try { CacheObject < K , V > co = new CacheObject < > ( key , object , timeout ) ; if ( timeout != 0 ) { existCustomTimeout = true ; } if ( isReallyFull ( key ) ) { pruneCache ( ) ; } cacheMap . put ( key , co ) ; } finally { lock . unlockWrite ( stamp ) ; }


signature:
public class AbstractCacheMap { /** * { @ inheritDoc } */
@ Override public V get ( final K key ) { } }

implementation:
long stamp = lock . readLock ( ) ; try { CacheObject < K , V > co = cacheMap . get ( key ) ; if ( co == null ) { missCount ++ ; return null ; } if ( co . isExpired ( ) ) { final long newStamp = lock . tryConvertToWriteLock ( stamp ) ; if ( newStamp != 0L ) { stamp = newStamp ; // lock is upgraded to write lock
} else { // manually upgrade lock to write lock
lock . unlockRead ( stamp ) ; stamp = lock . writeLock ( ) ; } CacheObject < K , V > removedCo = cacheMap . remove ( key ) ; if ( removedCo != null ) { onRemove ( removedCo . key , removedCo . cachedObject ) ; } missCount ++ ; return null ; } hitCount ++ ; return co . getObject ( ) ; } finally { lock . unlock ( stamp ) ; }


signature:
public class AbstractCacheMap { /** * { @ inheritDoc } */
@ Override public V remove ( final K key ) { } }

implementation: V removedValue = null ; final long stamp = lock . writeLock ( ) ; try { CacheObject < K , V > co = cacheMap . remove ( key ) ; if ( co != null ) { onRemove ( co . key , co . cachedObject ) ; removedValue = co . cachedObject ; } } finally { lock . unlockWrite ( stamp ) ; } return removedValue ;


signature:
public class AbstractCacheMap { /** * { @ inheritDoc } */
@ Override public void clear ( ) { } }

implementation: final long stamp = lock . writeLock ( ) ; try { cacheMap . clear ( ) ; } finally { lock . unlockWrite ( stamp ) ; }


signature:
public class AbstractCacheMap { /** * { @ inheritDoc } */
@ Override public Map < K , V > snapshot ( ) { } }

implementation: final long stamp = lock . writeLock ( ) ; try { Map < K , V > map = new HashMap < > ( cacheMap . size ( ) ) ; cacheMap . forEach ( ( key , cacheValue ) -> map . put ( key , cacheValue . getObject ( ) ) ) ; return map ; } finally { lock . unlockWrite ( stamp ) ; }


signature:
public class Madvoc { /** * Configures Madvoc by reading context init parameters . */
public void configureWith ( final ServletContext servletContext ) { } }

implementation: webAppClassName = servletContext . getInitParameter ( PARAM_MADVOC_WEBAPP ) ; paramsFiles = Converter . get ( ) . toStringArray ( servletContext . getInitParameter ( PARAM_MADVOC_PARAMS ) ) ; madvocConfiguratorClassName = servletContext . getInitParameter ( PARAM_MADVOC_CONFIGURATOR ) ;


signature:
public class Madvoc { /** * Creates and starts new < code > Madvoc < / code > web application .
 * < code > Madvoc < / code > instance is stored in servlet context .
 * Important : < code > servletContext < / code > may be < code > null < / code > ,
 * when web application is run out from container . */
@ SuppressWarnings ( "InstanceofCatchParameter" ) public WebApp startWebApplication ( final ServletContext servletContext ) { } }

implementation: try { WebApp webApp = _start ( servletContext ) ; log . info ( "Madvoc is up and running." ) ; return webApp ; } catch ( Exception ex ) { if ( log != null ) { log . error ( "Madvoc startup failure." , ex ) ; } else { ex . printStackTrace ( ) ; } if ( ex instanceof MadvocException ) { throw ( MadvocException ) ex ; } throw new MadvocException ( ex ) ; }


signature:
public class Madvoc { /** * Stops < em > Madvoc < / em > web application . */
public void stopWebApplication ( ) { } }

implementation: log . info ( "Madvoc shutting down..." ) ; if ( servletContext != null ) { servletContext . removeAttribute ( MADVOC_ATTR ) ; } webapp . shutdown ( ) ; webapp = null ;


signature:
public class Madvoc { /** * Creates { @ link WebApp } . */
protected WebApp createWebApplication ( ) { } }

implementation: if ( ( webAppClassName == null ) && ( webAppClass == null ) ) { return new WebApp ( ) ; } final WebApp webApp ; try { if ( webAppClassName != null ) { webAppClass = ClassLoaderUtil . loadClass ( webAppClassName ) ; } webApp = ( WebApp ) ClassUtil . newInstance ( webAppClass ) ; } catch ( Exception ex ) { throw new MadvocException ( "Unable to load Madvoc web application class: " + webAppClassName , ex ) ; } return webApp ;


signature:
public class Madvoc { /** * Loads Madvoc parameters . New { @ link Props } is created from the classpath . */
protected Props loadMadvocParams ( final String [ ] patterns ) { } }

implementation: if ( log . isInfoEnabled ( ) ) { log . info ( "Loading Madvoc parameters from: " + Converter . get ( ) . toString ( patterns ) ) ; } try { return new Props ( ) . loadFromClasspath ( patterns ) ; } catch ( Exception ex ) { throw new MadvocException ( "Unable to load Madvoc parameters from: " + Converter . get ( ) . toString ( patterns ) + ".properties': " + ex . toString ( ) , ex ) ; }


signature:
public class Madvoc { /** * Loads Madvoc component that will be used for configuring the user actions .
 * If class name is < code > null < / code > , default { @ link AutomagicMadvocConfigurator }
 * will be used . */
protected void resolveMadvocConfigClass ( ) { } }

implementation: if ( ( madvocConfiguratorClassName == null ) && ( madvocConfiguratorClass == null ) ) { return ; } try { if ( madvocConfiguratorClassName != null ) { madvocConfiguratorClass = ClassLoaderUtil . loadClass ( madvocConfiguratorClassName ) ; } log . info ( "Configuring Madvoc using: " + madvocConfiguratorClass . getName ( ) ) ; } catch ( Exception ex ) { throw new MadvocException ( "Unable to load Madvoc configurator class: " + madvocConfiguratorClassName , ex ) ; }


signature:
public class DefineClass { /** * Defines a class from byte array into the specified class loader .
 * Warning : this is a < b > hack < / b > !
 * @ param className optional class name , may be < code > null < / code >
 * @ param classData bytecode data
 * @ param classLoader classloader that will load class */
public static Class of ( final String className , final byte [ ] classData , ClassLoader classLoader ) { } }

implementation: if ( classLoader == null ) { classLoader = ClassLoaderUtil . getDefaultClassLoader ( ) ; } try { final Method defineClassMethod = ClassLoader . class . getDeclaredMethod ( "defineClass" , String . class , byte [ ] . class , int . class , int . class ) ; defineClassMethod . setAccessible ( true ) ; return ( Class ) defineClassMethod . invoke ( classLoader , className , classData , 0 , classData . length ) ; } catch ( Throwable th ) { throw new RuntimeException ( "Define class failed: " + className , th ) ; }


signature:
public class JsonParser { /** * Resets JSON parser , so it can be reused . */
protected void reset ( ) { } }

implementation: this . ndx = 0 ; this . textLen = 0 ; this . path = new Path ( ) ; this . notFirstObject = false ; if ( useAltPaths ) { path . altPath = new Path ( ) ; } if ( classMetadataName != null ) { mapToBean = createMapToBean ( classMetadataName ) ; }


signature:
public class JsonParser { /** * Defines how JSON parser works . In non - lazy mode , the whole JSON is parsed as it is .
 * In the lazy mode , not everything is parsed , but some things are left lazy .
 * This way we gain performance , especially on partial usage of the whole JSON .
 * However , be aware that parser holds the input memory until the returned
 * objects are disposed . */
public JsonParser lazy ( final boolean lazy ) { } }

implementation: this . lazy = lazy ; this . mapSupplier = lazy ? LAZYMAP_SUPPLIER : HASHMAP_SUPPLIER ; this . listSupplier = lazy ? LAZYLIST_SUPPLIER : ARRAYLIST_SUPPLIER ; return this ;


signature:
public class JsonParser { /** * Maps a class to given path . For arrays , append < code > values < / code >
 * to the path to specify component type ( if not specified by
 * generics ) . */
public JsonParser map ( final String path , final Class target ) { } }

implementation: if ( path == null ) { rootType = target ; return this ; } if ( mappings == null ) { mappings = new HashMap < > ( ) ; } mappings . put ( Path . parse ( path ) , target ) ; return this ;


signature:
public class JsonParser { /** * Replaces type with mapped type for current path . */
protected Class replaceWithMappedTypeForPath ( final Class target ) { } }

implementation:
if ( mappings == null ) { return target ; } Class newType ; // first try alt paths
Path altPath = path . getAltPath ( ) ; if ( altPath != null ) { if ( ! altPath . equals ( path ) ) { newType = mappings . get ( altPath ) ; if ( newType != null ) { return newType ; } } } // now check regular paths
newType = mappings . get ( path ) ; if ( newType != null ) { return newType ; } return target ;


signature:
public class JsonParser { /** * Defines { @ link jodd . json . ValueConverter } to use on given path . */
public JsonParser withValueConverter ( final String path , final ValueConverter valueConverter ) { } }

implementation: if ( convs == null ) { convs = new HashMap < > ( ) ; } convs . put ( Path . parse ( path ) , valueConverter ) ; return this ;


signature:
public class JsonParser { /** * Adds a { @ link jodd . util . Wildcard wildcard } pattern for white - listing classes .
 * @ see # setClassMetadataName ( String ) */
public JsonParser allowClass ( final String classPattern ) { } }

implementation: if ( super . classnameWhitelist == null ) { super . classnameWhitelist = new ArrayList < > ( ) ; } classnameWhitelist . add ( classPattern ) ; return this ;


signature:
public class JsonParser { /** * Parses input JSON as given type . */
@ SuppressWarnings ( "unchecked" ) public < T > T parse ( final String input , final Class < T > targetType ) { } }

implementation: rootType = targetType ; return _parse ( UnsafeUtil . getChars ( input ) ) ;


signature:
public class JsonParser { /** * Parses input JSON to a list with specified component type . */
public < T > List < T > parseAsList ( final String string , final Class < T > componentType ) { } }

implementation: return new JsonParser ( ) . map ( JsonParser . VALUES , componentType ) . parse ( string ) ;


signature:
public class JsonParser { /** * Parses input JSON to a list with specified key and value types . */
public < K , V > Map < K , V > parseAsMap ( final String string , final Class < K > keyType , final Class < V > valueType ) { } }

implementation: return new JsonParser ( ) . map ( JsonParser . KEYS , keyType ) . map ( JsonParser . VALUES , valueType ) . parse ( string ) ;


signature:
public class JsonParser { /** * Parses input JSON as given type . */
@ SuppressWarnings ( "unchecked" ) public < T > T parse ( final char [ ] input , final Class < T > targetType ) { } }

implementation: rootType = targetType ; return _parse ( input ) ;


signature:
public class JsonParser { /** * Parses a JSON value .
 * @ param targetType target type to convert , may be < code > null < / code >
 * @ param componentType component type for maps and arrays , may be < code > null < / code > */
protected Object parseValue ( final Class targetType , final Class keyType , final Class componentType ) { } }

implementation:
final ValueConverter valueConverter ; final char c = input [ ndx ] ; switch ( c ) { case '\'' : if ( ! looseMode ) { break ; } case '"' : ndx ++ ; Object string = parseStringContent ( c ) ; valueConverter = lookupValueConverter ( ) ; if ( valueConverter != null ) { return valueConverter . convert ( string ) ; } if ( targetType != null && targetType != String . class ) { string = convertType ( string , targetType ) ; } return string ; case '{' : ndx ++ ; if ( lazy ) { if ( notFirstObject ) { final Object value = new ObjectParser ( this , targetType , keyType , componentType ) ; skipObject ( ) ; return value ; } else { notFirstObject = true ; } } return parseObjectContent ( targetType , keyType , componentType ) ; case '[' : ndx ++ ; return parseArrayContent ( targetType , componentType ) ; case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : case '-' : Object number = parseNumber ( ) ; valueConverter = lookupValueConverter ( ) ; if ( valueConverter != null ) { return valueConverter . convert ( number ) ; } if ( targetType != null ) { number = convertType ( number , targetType ) ; } return number ; case 'n' : ndx ++ ; if ( match ( N_ULL ) ) { valueConverter = lookupValueConverter ( ) ; if ( valueConverter != null ) { return valueConverter . convert ( null ) ; } return null ; } break ; case 't' : ndx ++ ; if ( match ( T_RUE ) ) { Object value = Boolean . TRUE ; valueConverter = lookupValueConverter ( ) ; if ( valueConverter != null ) { return valueConverter . convert ( value ) ; } if ( targetType != null ) { value = convertType ( value , targetType ) ; } return value ; } break ; case 'f' : ndx ++ ; if ( match ( F_ALSE ) ) { Object value = Boolean . FALSE ; valueConverter = lookupValueConverter ( ) ; if ( valueConverter != null ) { return valueConverter . convert ( value ) ; } if ( targetType != null ) { value = convertType ( value , targetType ) ; } return value ; } break ; } if ( looseMode ) { // try to parse unquoted string
Object string = parseUnquotedStringContent ( ) ; valueConverter = lookupValueConverter ( ) ; if ( valueConverter != null ) { return valueConverter . convert ( string ) ; } if ( targetType != null && targetType != String . class ) { string = convertType ( string , targetType ) ; } return string ; } syntaxError ( "Invalid char: " + input [ ndx ] ) ; return null ;


signature:
public class JsonParser { /** * Resolves lazy value during the parsing runtime . */
private Object resolveLazyValue ( Object value ) { } }

implementation: if ( value instanceof Supplier ) { value = ( ( Supplier ) value ) . get ( ) ; } return value ;


signature:
public class JsonParser { /** * Skips over complete object . It is not parsed , just skipped . It will be
 * parsed later , but only if required . */
private void skipObject ( ) { } }

implementation: int bracketCount = 1 ; boolean insideString = false ; while ( ndx < total ) { final char c = input [ ndx ] ; if ( insideString ) { if ( c == '\"' && notPrecededByEvenNumberOfBackslashes ( ) ) { insideString = false ; } } else if ( c == '\"' ) { insideString = true ; } else if ( c == '{' ) { bracketCount ++ ; } else if ( c == '}' ) { bracketCount -- ; if ( bracketCount == 0 ) { ndx ++ ; return ; } } ndx ++ ; }


signature:
public class JsonParser { /** * Parses a string . */
protected String parseString ( ) { } }

implementation: char quote = '\"' ; if ( looseMode ) { quote = consumeOneOf ( '\"' , '\'' ) ; if ( quote == 0 ) { return parseUnquotedStringContent ( ) ; } } else { consume ( quote ) ; } return parseStringContent ( quote ) ;


signature:
public class JsonParser { /** * Parses string content , once when starting quote has been consumed . */
protected String parseStringContent ( final char quote ) { } }

implementation:
final int startNdx = ndx ; // roll - out until the end of the string or the escape char
while ( true ) { final char c = input [ ndx ] ; if ( c == quote ) { // no escapes found , just use existing string
ndx ++ ; return new String ( input , startNdx , ndx - 1 - startNdx ) ; } if ( c == '\\' ) { break ; } ndx ++ ; } // escapes found , proceed differently
textLen = ndx - startNdx ; growEmpty ( ) ; // for ( int i = startNdx , j = 0 ; j < textLen ; i + + , j + + ) {
// text [ j ] = input [ i ] ;
System . arraycopy ( input , startNdx , text , 0 , textLen ) ; // escape char , process everything until the end
while ( true ) { char c = input [ ndx ] ; if ( c == quote ) { // done
ndx ++ ; final String str = new String ( text , 0 , textLen ) ; textLen = 0 ; return str ; } if ( c == '\\' ) { // escape char found
ndx ++ ; c = input [ ndx ] ; switch ( c ) { case '\"' : c = '\"' ; break ; case '\\' : c = '\\' ; break ; case '/' : c = '/' ; break ; case 'b' : c = '\b' ; break ; case 'f' : c = '\f' ; break ; case 'n' : c = '\n' ; break ; case 'r' : c = '\r' ; break ; case 't' : c = '\t' ; break ; case 'u' : ndx ++ ; c = parseUnicode ( ) ; break ; default : if ( looseMode ) { if ( c != '\'' ) { c = '\\' ; ndx -- ; } } else { syntaxError ( "Invalid escape char: " + c ) ; } } } text [ textLen ] = c ; textLen ++ ; growAndCopy ( ) ; ndx ++ ; }


signature:
public class JsonParser { /** * Grows text array when { @ code text . length = = textLen } . */
protected void growAndCopy ( ) { } }

implementation: if ( textLen == text . length ) { int newSize = text . length << 1 ; char [ ] newText = new char [ newSize ] ; if ( textLen > 0 ) { System . arraycopy ( text , 0 , newText , 0 , textLen ) ; } text = newText ; }


signature:
public class JsonParser { /** * Parses 4 characters and returns unicode character . */
protected char parseUnicode ( ) { } }

implementation: int i0 = CharUtil . hex2int ( input [ ndx ++ ] ) ; int i1 = CharUtil . hex2int ( input [ ndx ++ ] ) ; int i2 = CharUtil . hex2int ( input [ ndx ++ ] ) ; int i3 = CharUtil . hex2int ( input [ ndx ] ) ; return ( char ) ( ( i0 << 12 ) + ( i1 << 8 ) + ( i2 << 4 ) + i3 ) ;


signature:
public class JsonParser { /** * Parses un - quoted string content . */
protected String parseUnquotedStringContent ( ) { } }

implementation:
final int startNdx = ndx ; while ( true ) { final char c = input [ ndx ] ; if ( c <= ' ' || CharUtil . equalsOne ( c , UNQUOTED_DELIMETERS ) ) { final int currentNdx = ndx ; // done
skipWhiteSpaces ( ) ; return new String ( input , startNdx , currentNdx - startNdx ) ; } ndx ++ ; }


signature:
public class JsonParser { /** * Parses JSON numbers . */
protected Number parseNumber ( ) { } }

implementation:
final int startIndex = ndx ; char c = input [ ndx ] ; boolean isDouble = false ; boolean isExp = false ; if ( c == '-' ) { ndx ++ ; } while ( true ) { if ( isEOF ( ) ) { break ; } c = input [ ndx ] ; if ( c >= '0' && c <= '9' ) { ndx ++ ; continue ; } if ( c <= 32 ) { // white space
break ; } if ( c == ',' || c == '}' || c == ']' ) { // delimiter
break ; } if ( c == '.' ) { isDouble = true ; } else if ( c == 'e' || c == 'E' ) { isExp = true ; } ndx ++ ; } final String value = new String ( input , startIndex , ndx - startIndex ) ; if ( isDouble ) { return Double . valueOf ( value ) ; } long longNumber ; if ( isExp ) { longNumber = Double . valueOf ( value ) . longValue ( ) ; } else { if ( value . length ( ) >= 19 ) { // if string is 19 chars and longer , it can be over the limit
BigInteger bigInteger = new BigInteger ( value ) ; if ( isGreaterThanLong ( bigInteger ) ) { return bigInteger ; } longNumber = bigInteger . longValue ( ) ; } else { longNumber = Long . parseLong ( value ) ; } } if ( ( longNumber >= Integer . MIN_VALUE ) && ( longNumber <= Integer . MAX_VALUE ) ) { return ( int ) longNumber ; } return longNumber ;


signature:
public class JsonParser { /** * Parses arrays , once when open bracket has been consumed . */
protected Object parseArrayContent ( Class targetType , Class componentType ) { } }

implementation:
// detect special case
if ( targetType == Object . class ) { targetType = List . class ; } // continue
targetType = replaceWithMappedTypeForPath ( targetType ) ; if ( componentType == null && targetType != null && targetType . isArray ( ) ) { componentType = targetType . getComponentType ( ) ; } path . push ( VALUES ) ; componentType = replaceWithMappedTypeForPath ( componentType ) ; Collection < Object > target = newArrayInstance ( targetType ) ; boolean koma = false ; mainloop : while ( true ) { skipWhiteSpaces ( ) ; char c = input [ ndx ] ; if ( c == ']' ) { if ( koma ) { syntaxError ( "Trailing comma" ) ; } ndx ++ ; path . pop ( ) ; return target ; } Object value = parseValue ( componentType , null , null ) ; target . add ( value ) ; skipWhiteSpaces ( ) ; c = input [ ndx ] ; switch ( c ) { case ']' : ndx ++ ; break mainloop ; case ',' : ndx ++ ; koma = true ; break ; default : syntaxError ( "Invalid char: expected ] or ," ) ; } } path . pop ( ) ; if ( targetType != null ) { return convertType ( target , targetType ) ; } return target ;


signature:
public class JsonParser { /** * Parses object , once when open bracket has been consumed . */
protected Object parseObjectContent ( Class targetType , Class valueKeyType , Class valueType ) { } }

implementation:
// detect special case
if ( targetType == Object . class ) { targetType = Map . class ; } // continue
targetType = replaceWithMappedTypeForPath ( targetType ) ; Object target ; boolean isTargetTypeMap = true ; boolean isTargetRealTypeMap = true ; ClassDescriptor targetTypeClassDescriptor = null ; TypeData typeData = null ; if ( targetType != null ) { targetTypeClassDescriptor = ClassIntrospector . get ( ) . lookup ( targetType ) ; // find if the target is really a map
// because when classMetadataName ! = null we are forcing
// map usage locally in this method
isTargetRealTypeMap = targetTypeClassDescriptor . isMap ( ) ; typeData = jsonAnnotationManager . lookupTypeData ( targetType ) ; } if ( isTargetRealTypeMap ) { // resolve keys only for real maps
path . push ( KEYS ) ; valueKeyType = replaceWithMappedTypeForPath ( valueKeyType ) ; path . pop ( ) ; } if ( classMetadataName == null ) { // create instance of target type , no ' class ' information
target = newObjectInstance ( targetType ) ; isTargetTypeMap = isTargetRealTypeMap ; } else { // all beans will be created first as a map
target = mapSupplier . get ( ) ; } boolean koma = false ; mainloop : while ( true ) { skipWhiteSpaces ( ) ; char c = input [ ndx ] ; if ( c == '}' ) { if ( koma ) { syntaxError ( "Trailing comma" ) ; } ndx ++ ; break ; } koma = false ; String key = parseString ( ) ; String keyOriginal = key ; skipWhiteSpaces ( ) ; consume ( ':' ) ; skipWhiteSpaces ( ) ; // read the type of the simple property
PropertyDescriptor pd = null ; Class propertyType = null ; Class keyType = null ; Class componentType = null ; // resolve simple property
if ( ! isTargetRealTypeMap ) { // replace key with real property value
key = jsonAnnotationManager . resolveRealName ( targetType , key ) ; } if ( ! isTargetTypeMap ) { pd = targetTypeClassDescriptor . getPropertyDescriptor ( key , true ) ; if ( pd != null ) { propertyType = pd . getType ( ) ; keyType = pd . resolveKeyType ( true ) ; componentType = pd . resolveComponentType ( true ) ; } } Object value ; if ( ! isTargetTypeMap ) { // * * * inject into bean
path . push ( key ) ; value = parseValue ( propertyType , keyType , componentType ) ; path . pop ( ) ; if ( typeData . rules . match ( keyOriginal , ! typeData . strict ) ) { if ( pd != null ) { if ( lazy ) { // need to resolve lazy value before injecting objects into it
value = resolveLazyValue ( value ) ; } // only inject values if target property exist
injectValueIntoObject ( target , pd , value ) ; } } } else { Object keyValue = key ; if ( valueKeyType != null ) { keyValue = convertType ( key , valueKeyType ) ; } // * * * add to map
if ( isTargetRealTypeMap ) { path . push ( VALUES , key ) ; valueType = replaceWithMappedTypeForPath ( valueType ) ; } else { path . push ( key ) ; } value = parseValue ( valueType , null , null ) ; path . pop ( ) ; ( ( Map ) target ) . put ( keyValue , value ) ; } skipWhiteSpaces ( ) ; c = input [ ndx ] ; switch ( c ) { case '}' : ndx ++ ; break mainloop ; case ',' : ndx ++ ; koma = true ; break ; default : syntaxError ( "Invalid char: expected } or ," ) ; } } // done
// convert Map to target type
if ( classMetadataName != null ) { target = mapToBean . map2bean ( ( Map ) target , targetType ) ; } return target ;


signature:
public class JsonParser { /** * Consumes one of the allowed char at current position .
 * If char is different , return < code > 0 < / code > .
 * If matched , returns matched char . */
protected char consumeOneOf ( final char c1 , final char c2 ) { } }

implementation: char c = input [ ndx ] ; if ( ( c != c1 ) && ( c != c2 ) ) { return 0 ; } ndx ++ ; return c ;


signature:
public class JsonParser { /** * Matches char buffer with content on given location . */
protected final boolean match ( final char [ ] target ) { } }

implementation: for ( char c : target ) { if ( input [ ndx ] != c ) { return false ; } ndx ++ ; } return true ;


signature:
public class JsonParser { /** * Throws { @ link jodd . json . JsonException } indicating a syntax error . */
protected void syntaxError ( final String message ) { } }

implementation: String left = "..." ; String right = "..." ; int offset = 10 ; int from = ndx - offset ; if ( from < 0 ) { from = 0 ; left = StringPool . EMPTY ; } int to = ndx + offset ; if ( to > input . length ) { to = input . length ; right = StringPool . EMPTY ; } final CharSequence str = CharArraySequence . of ( input , from , to - from ) ; throw new JsonException ( "Syntax error! " + message + "\n" + "offset: " + ndx + " near: \"" + left + str + right + "\"" ) ;


signature:
public class ProxettaWrapperClassBuilder { /** * { @ inheritDoc } */
@ Override public void visit ( final int version , int access , final String name , final String signature , final String superName , String [ ] interfaces ) { } }

implementation:
wd . init ( name , superName , this . suffix , this . reqProxyClassName ) ; // no superclass
wd . superName = AsmUtil . SIGNATURE_JAVA_LANG_OBJECT ; // change access of destination
access &= ~ AsmUtil . ACC_ABSTRACT ; access &= ~ AsmUtil . ACC_INTERFACE ; // write destination class
if ( targetClassOrInterface . isInterface ( ) ) { // target is interface
wd . wrapInterface = true ; interfaces = new String [ ] { targetClassOrInterface . getName ( ) . replace ( '.' , '/' ) } ; } else { // target is class
wd . wrapInterface = false ; if ( targetInterface != null ) { // interface provided
interfaces = new String [ ] { targetInterface . getName ( ) . replace ( '.' , '/' ) } ; } else { // no interface provided , use all
// interfaces = null ;
} } final int v = ProxettaAsmUtil . resolveJavaVersion ( version ) ; wd . dest . visit ( v , access , wd . thisReference , signature , wd . superName , interfaces ) ; wd . proxyAspects = new ProxyAspectData [ aspects . length ] ; for ( int i = 0 ; i < aspects . length ; i ++ ) { wd . proxyAspects [ i ] = new ProxyAspectData ( wd , aspects [ i ] , i ) ; } // create new field wrapper field and store it ' s reference into work - data
wd . wrapperRef = targetFieldName ; wd . wrapperType = 'L' + name + ';' ; if ( createTargetInDefaultCtor ) { // create private , final field
final FieldVisitor fv = wd . dest . visitField ( AsmUtil . ACC_PRIVATE | AsmUtil . ACC_FINAL , wd . wrapperRef , wd . wrapperType , null , null ) ; fv . visitEnd ( ) ; createEmptyCtorThatCreatesTarget ( ) ; } else { // create public , non - final field
final FieldVisitor fv = wd . dest . visitField ( AsmUtil . ACC_PUBLIC , wd . wrapperRef , wd . wrapperType , null , null ) ; fv . visitEnd ( ) ; createEmptyCtor ( ) ; }


signature:
public class ProxettaWrapperClassBuilder { /** * Created empty default constructor . */
protected void createEmptyCtor ( ) { } }

implementation: final MethodVisitor mv = wd . dest . visitMethod ( AsmUtil . ACC_PUBLIC , INIT , "()V" , null , null ) ; mv . visitCode ( ) ; mv . visitVarInsn ( Opcodes . ALOAD , 0 ) ; mv . visitMethodInsn ( Opcodes . INVOKESPECIAL , AsmUtil . SIGNATURE_JAVA_LANG_OBJECT , INIT , "()V" , false ) ; mv . visitInsn ( Opcodes . RETURN ) ; mv . visitMaxs ( 1 , 1 ) ; mv . visitEnd ( ) ;


signature:
public class ProxettaWrapperClassBuilder { /** * { @ inheritDoc } */
@ Override public MethodVisitor visitMethod ( final int access , final String name , final String desc , final String signature , final String [ ] exceptions ) { } }

implementation:
MethodSignatureVisitor msign = targetClassInfo . lookupMethodSignatureVisitor ( access , name , desc , wd . superReference ) ; if ( msign == null ) { return null ; } // ignore all destination constructors
if ( name . equals ( INIT ) ) { return null ; } // ignore all destination static block
if ( name . equals ( CLINIT ) ) { return null ; } // skip all static methods
if ( Modifier . isStatic ( access ) ) { return null ; } return applyProxy ( msign ) ;


signature:
public class ProxettaWrapperClassBuilder { /** * Creates simple method wrapper without proxy . */
protected void createSimpleMethodWrapper ( final MethodSignatureVisitor msign ) { } }

implementation: int access = msign . getAccessFlags ( ) ; access &= ~ ACC_ABSTRACT ; access &= ~ ACC_NATIVE ; MethodVisitor mv = wd . dest . visitMethod ( access , msign . getMethodName ( ) , msign . getDescription ( ) , msign . getAsmMethodSignature ( ) , msign . getExceptions ( ) ) ; mv . visitCode ( ) ; mv . visitVarInsn ( ALOAD , 0 ) ; mv . visitFieldInsn ( GETFIELD , wd . thisReference , wd . wrapperRef , wd . wrapperType ) ; loadVirtualMethodArguments ( mv , msign ) ; if ( wd . wrapInterface ) { mv . visitMethodInsn ( INVOKEINTERFACE , wd . wrapperType . substring ( 1 , wd . wrapperType . length ( ) - 1 ) , msign . getMethodName ( ) , msign . getDescription ( ) , true ) ; } else { mv . visitMethodInsn ( INVOKEVIRTUAL , wd . wrapperType . substring ( 1 , wd . wrapperType . length ( ) - 1 ) , msign . getMethodName ( ) , msign . getDescription ( ) , false ) ; } ProxettaAsmUtil . prepareReturnValue ( mv , msign , 0 ) ; visitReturn ( mv , msign , true ) ; mv . visitMaxs ( 0 , 0 ) ; mv . visitEnd ( ) ;


signature:
public class MethodSignatureVisitor { /** * - - - - - method - info signature */
@ Override public String getSignature ( ) { } }

implementation: if ( signature == null ) { String decl = getDeclaration ( ) ; int ndx = decl . indexOf ( ')' ) ; ndx ++ ; String retType = decl . substring ( ndx ) ; StringBuilder methodDeclaration = new StringBuilder ( 50 ) ; methodDeclaration . append ( retType ) . append ( ' ' ) . append ( methodName ) . append ( decl , 0 , ndx ) ; String exceptionsAsString = getExceptionsAsString ( ) ; if ( exceptionsAsString != null ) { methodDeclaration . append ( " throws " ) . append ( exceptionsAsString ) ; } signature = methodDeclaration . toString ( ) ; } return signature ;


signature:
public class MethodSignatureVisitor { /** * Resolves raw type name using the generics information from the class
 * or method information . */
private String resolveRawTypeName ( String typeName ) { } }

implementation: if ( typeName == null ) { return null ; } boolean isArray = typeName . startsWith ( StringPool . LEFT_SQ_BRACKET ) ; if ( isArray ) { typeName = typeName . substring ( 1 ) ; } String rawTypeName ; if ( generics . containsKey ( typeName ) ) { rawTypeName = generics . get ( typeName ) ; } else { rawTypeName = declaredTypeGeneric . getOrDefault ( typeName , typeName ) ; } if ( isArray ) { rawTypeName = '[' + rawTypeName ; } return rawTypeName ;


signature:
public class ReferencesResolver { /** * Resolves reference from given values . Returns bean reference of given value or defaults
 * if given name is blank . */
public BeanReferences resolveReferenceFromValue ( final PropertyDescriptor propertyDescriptor , final String refName ) { } }

implementation: BeanReferences references ; if ( refName == null || refName . isEmpty ( ) ) { references = buildDefaultReference ( propertyDescriptor ) ; } else { references = BeanReferences . of ( refName ) ; } references = references . removeDuplicateNames ( ) ; return references ;


signature:
public class ReferencesResolver { /** * Takes given parameters references and returns reference set for given method or constructor . */
public BeanReferences [ ] resolveReferenceFromValues ( final Executable methodOrCtor , final String ... parameterReferences ) { } }

implementation: BeanReferences [ ] references = convertRefToReferences ( parameterReferences ) ; if ( references == null || references . length == 0 ) { references = buildDefaultReferences ( methodOrCtor ) ; } if ( methodOrCtor . getParameterTypes ( ) . length != references . length ) { throw new PetiteException ( "Different number of method parameters and references for: " + methodOrCtor . getDeclaringClass ( ) . getName ( ) + '#' + methodOrCtor . getName ( ) ) ; } removeAllDuplicateNames ( references ) ; return references ;


signature:
public class ReferencesResolver { /** * Extracts references for given property . Returns { @ code null } if property is not marked with an
 * annotation . */
public BeanReferences readReferenceFromAnnotation ( final PropertyDescriptor propertyDescriptor ) { } }

implementation: final MethodDescriptor writeMethodDescriptor = propertyDescriptor . getWriteMethodDescriptor ( ) ; final FieldDescriptor fieldDescriptor = propertyDescriptor . getFieldDescriptor ( ) ; PetiteInject ref = null ; if ( writeMethodDescriptor != null ) { ref = writeMethodDescriptor . getMethod ( ) . getAnnotation ( PetiteInject . class ) ; } if ( ref == null && fieldDescriptor != null ) { ref = fieldDescriptor . getField ( ) . getAnnotation ( PetiteInject . class ) ; } if ( ref == null ) { return null ; } BeanReferences reference = null ; String name = ref . value ( ) . trim ( ) ; if ( name . length ( ) != 0 ) { reference = BeanReferences . of ( name ) ; } reference = updateReferencesWithDefaultsIfNeeded ( propertyDescriptor , reference ) ; reference = reference . removeDuplicateNames ( ) ; return reference ;


signature:
public class ReferencesResolver { /** * Extracts references from method or constructor annotation . */
public BeanReferences [ ] readAllReferencesFromAnnotation ( final Executable methodOrCtor ) { } }

implementation:
PetiteInject petiteInject = methodOrCtor . getAnnotation ( PetiteInject . class ) ; final Parameter [ ] parameters = methodOrCtor . getParameters ( ) ; BeanReferences [ ] references ; final boolean hasAnnotationOnMethodOrCtor ; if ( petiteInject != null ) { references = convertAnnValueToReferences ( petiteInject . value ( ) ) ; hasAnnotationOnMethodOrCtor = true ; } else { references = new BeanReferences [ parameters . length ] ; hasAnnotationOnMethodOrCtor = false ; } int parametersWithAnnotationCount = 0 ; for ( int i = 0 ; i < parameters . length ; i ++ ) { Parameter parameter = parameters [ i ] ; petiteInject = parameter . getAnnotation ( PetiteInject . class ) ; if ( petiteInject == null ) { // no annotation on argument
continue ; } // there is annotation on argument , override values
String annotationValue = readAnnotationValue ( petiteInject ) ; if ( annotationValue != null ) { references [ i ] = BeanReferences . of ( annotationValue ) ; } parametersWithAnnotationCount ++ ; } if ( ! hasAnnotationOnMethodOrCtor ) { if ( parametersWithAnnotationCount == 0 ) { return null ; } if ( parametersWithAnnotationCount != parameters . length ) { throw new PetiteException ( "All arguments must be annotated with PetiteInject" ) ; } } references = updateReferencesWithDefaultsIfNeeded ( methodOrCtor , references ) ; removeAllDuplicateNames ( references ) ; return references ;


signature:
public class ReferencesResolver { /** * Reads annotation value and returns { @ code null } if value is empty . */
private String readAnnotationValue ( final PetiteInject annotation ) { } }

implementation: String value = annotation . value ( ) . trim ( ) ; if ( value . isEmpty ( ) ) { return null ; } return value ;


signature:
public class ReferencesResolver { /** * Builds default method references . */
private BeanReferences [ ] buildDefaultReferences ( final Executable methodOrCtor ) { } }

implementation: final boolean useParamo = petiteConfig . getUseParamo ( ) ; final PetiteReferenceType [ ] lookupReferences = petiteConfig . getLookupReferences ( ) ; MethodParameter [ ] methodParameters = null ; if ( useParamo ) { methodParameters = Paramo . resolveParameters ( methodOrCtor ) ; } final Class [ ] paramTypes = methodOrCtor . getParameterTypes ( ) ; final BeanReferences [ ] references = new BeanReferences [ paramTypes . length ] ; for ( int j = 0 ; j < paramTypes . length ; j ++ ) { String [ ] ref = new String [ lookupReferences . length ] ; references [ j ] = BeanReferences . of ( ref ) ; for ( int i = 0 ; i < ref . length ; i ++ ) { switch ( lookupReferences [ i ] ) { case NAME : ref [ i ] = methodParameters != null ? methodParameters [ j ] . getName ( ) : null ; break ; case TYPE_SHORT_NAME : ref [ i ] = StringUtil . uncapitalize ( paramTypes [ j ] . getSimpleName ( ) ) ; break ; case TYPE_FULL_NAME : ref [ i ] = paramTypes [ j ] . getName ( ) ; break ; } } } return references ;


signature:
public class ReferencesResolver { /** * Builds default field references . */
public BeanReferences buildDefaultReference ( final PropertyDescriptor propertyDescriptor ) { } }

implementation: final PetiteReferenceType [ ] lookupReferences = petiteConfig . getLookupReferences ( ) ; final String [ ] references = new String [ lookupReferences . length ] ; for ( int i = 0 ; i < references . length ; i ++ ) { switch ( lookupReferences [ i ] ) { case NAME : references [ i ] = propertyDescriptor . getName ( ) ; break ; case TYPE_SHORT_NAME : references [ i ] = StringUtil . uncapitalize ( propertyDescriptor . getType ( ) . getSimpleName ( ) ) ; break ; case TYPE_FULL_NAME : references [ i ] = propertyDescriptor . getType ( ) . getName ( ) ; break ; } } return BeanReferences . of ( references ) ;


signature:
public class ReferencesResolver { /** * Removes duplicate names from bean references . */
private void removeAllDuplicateNames ( final BeanReferences [ ] allBeanReferences ) { } }

implementation: for ( int i = 0 ; i < allBeanReferences . length ; i ++ ) { BeanReferences references = allBeanReferences [ i ] ; allBeanReferences [ i ] = references . removeDuplicateNames ( ) ; }


signature:
public class ReferencesResolver { /** * Converts single string array to an array of bean references . */
private BeanReferences [ ] convertRefToReferences ( final String [ ] references ) { } }

implementation: if ( references == null ) { return null ; } BeanReferences [ ] ref = new BeanReferences [ references . length ] ; for ( int i = 0 ; i < references . length ; i ++ ) { ref [ i ] = BeanReferences . of ( references [ i ] ) ; } return ref ;


signature:
public class ReferencesResolver { /** * Converts comma - separated string into array of Bean references . */
private BeanReferences [ ] convertAnnValueToReferences ( String value ) { } }

implementation: if ( value == null ) { return null ; } value = value . trim ( ) ; if ( value . length ( ) == 0 ) { return null ; } String [ ] refNames = Converter . get ( ) . toStringArray ( value ) ; BeanReferences [ ] references = new BeanReferences [ refNames . length ] ; for ( int i = 0 ; i < refNames . length ; i ++ ) { references [ i ] = BeanReferences . of ( refNames [ i ] . trim ( ) ) ; } return references ;


signature:
public class StandaloneJoddJoy { /** * Runs JOY in standalone mode , with only backend . */
public void runJoy ( final Consumer < JoddJoyRuntime > consumer ) { } }

implementation: final JoddJoy joddJoy = new JoddJoy ( ) ; final JoddJoyRuntime joyRuntime = joddJoy . startOnlyBackend ( ) ; joddJoy . withDb ( joyDb -> setJtxManager ( joyRuntime . getJtxManager ( ) ) ) ; final JtxTransaction tx = startRwTx ( ) ; final Print print = new Print ( ) ; try { print . line ( "START" , 80 ) ; print . newLine ( ) ; consumer . accept ( joyRuntime ) ; print . newLine ( ) ; print . line ( "END" , 80 ) ; if ( tx != null ) { tx . commit ( ) ; } } catch ( Throwable throwable ) { throwable . printStackTrace ( ) ; if ( tx != null ) { tx . rollback ( ) ; } } joddJoy . stop ( ) ;


signature:
public class StandaloneJoddJoy { /** * Starts new read / write transaction in PROPAGATION _ REQUIRED mode . */
private JtxTransaction startRwTx ( ) { } }

implementation: if ( jtxManager == null ) { return null ; } return jtxManager . requestTransaction ( new JtxTransactionMode ( JtxPropagationBehavior . PROPAGATION_REQUIRED , false ) ) ;


signature:
public class ClassUtil { /** * Returns method from an object , matched by name . This may be considered as
 * a slow operation , since methods are matched one by one .
 * Returns only accessible methods .
 * Only first method is matched .
 * @ param c class to examine
 * @ param methodName Full name of the method .
 * @ return null if method not found */
public static Method findMethod ( final Class c , final String methodName ) { } }

implementation: return findDeclaredMethod ( c , methodName , true ) ;


signature:
public class ClassUtil { /** * Finds constructor with given parameter types . First matched ctor is returned . */
public static < T > Constructor < T > findConstructor ( final Class < T > clazz , final Class < ? > ... parameterTypes ) { } }

implementation: final Constructor < ? > [ ] constructors = clazz . getConstructors ( ) ; Class < ? > [ ] pts ; for ( Constructor < ? > constructor : constructors ) { pts = constructor . getParameterTypes ( ) ; if ( isAllAssignableFrom ( pts , parameterTypes ) ) { return ( Constructor < T > ) constructor ; } } return null ;


signature:
public class ClassUtil { /** * Returns { @ code true } if all types are assignable from the other array of types . */
public static boolean isAllAssignableFrom ( final Class < ? > [ ] typesTarget , final Class < ? > [ ] typesFrom ) { } }

implementation: if ( typesTarget . length == typesFrom . length ) { for ( int i = 0 ; i < typesTarget . length ; i ++ ) { if ( ! typesTarget [ i ] . isAssignableFrom ( typesFrom [ i ] ) ) { return false ; } } return true ; } return false ;


signature:
public class ClassUtil { /** * Returns classes from array of objects . It accepts { @ code null }
 * values . */
public static Class [ ] getClasses ( final Object ... objects ) { } }

implementation: if ( objects . length == 0 ) { return EMPTY_CLASS_ARRAY ; } Class [ ] result = new Class [ objects . length ] ; for ( int i = 0 ; i < objects . length ; i ++ ) { if ( objects [ i ] != null ) { result [ i ] = objects [ i ] . getClass ( ) ; } } return result ;


signature:
public class ClassUtil { /** * Safe version of < code > isAssignableFrom < / code > method that
 * returns < code > false < / code > if one of the arguments is < code > null < / code > . */
public static boolean isTypeOf ( final Class < ? > lookupClass , final Class < ? > targetClass ) { } }

implementation: if ( targetClass == null || lookupClass == null ) { return false ; } return targetClass . isAssignableFrom ( lookupClass ) ;


signature:
public class ClassUtil { /** * Safe version of < code > isInstance < / code > , returns < code > false < / code >
 * if any of the arguments is < code > null < / code > . */
public static boolean isInstanceOf ( final Object object , final Class target ) { } }

implementation: if ( object == null || target == null ) { return false ; } return target . isInstance ( object ) ;


signature:
public class ClassUtil { /** * Resolves all interfaces of a type . No duplicates are returned .
 * Direct interfaces are prior the interfaces of subclasses in
 * the returned array . */
public static Class [ ] resolveAllInterfaces ( final Class type ) { } }

implementation: Set < Class > bag = new LinkedHashSet < > ( ) ; _resolveAllInterfaces ( type , bag ) ; return bag . toArray ( new Class [ 0 ] ) ;


signature:
public class ClassUtil { /** * Resolves all super classes , from top ( direct subclass ) to down . < code > Object < / code >
 * class is not included in the list . */
public static Class [ ] resolveAllSuperclasses ( Class type ) { } }

implementation: List < Class > list = new ArrayList < > ( ) ; while ( true ) { type = type . getSuperclass ( ) ; if ( ( type == null ) || ( type == Object . class ) ) { break ; } list . add ( type ) ; } return list . toArray ( new Class [ 0 ] ) ;


signature:
public class ClassUtil { /** * Returns array of all methods that are accessible from given class , upto limit
 * ( usually < code > Object . class < / code > ) . Abstract methods are ignored . */
public static Method [ ] getAccessibleMethods ( Class clazz , final Class limit ) { } }

implementation:
Package topPackage = clazz . getPackage ( ) ; List < Method > methodList = new ArrayList < > ( ) ; int topPackageHash = topPackage == null ? 0 : topPackage . hashCode ( ) ; boolean top = true ; do { if ( clazz == null ) { break ; } Method [ ] declaredMethods = clazz . getDeclaredMethods ( ) ; for ( Method method : declaredMethods ) { if ( Modifier . isVolatile ( method . getModifiers ( ) ) ) { continue ; } // if ( Modifier . isAbstract ( method . getModifiers ( ) ) ) {
// continue ;
if ( top ) { // add all top declared methods
methodList . add ( method ) ; continue ; } int modifier = method . getModifiers ( ) ; if ( Modifier . isPrivate ( modifier ) ) { continue ; // ignore super private methods
} if ( Modifier . isAbstract ( modifier ) ) { // ignore super abstract methods
continue ; } if ( Modifier . isPublic ( modifier ) ) { addMethodIfNotExist ( methodList , method ) ; // add super public methods
continue ; } if ( Modifier . isProtected ( modifier ) ) { addMethodIfNotExist ( methodList , method ) ; // add super protected methods
continue ; } // add super default methods from the same package
Package pckg = method . getDeclaringClass ( ) . getPackage ( ) ; int pckgHash = pckg == null ? 0 : pckg . hashCode ( ) ; if ( pckgHash == topPackageHash ) { addMethodIfNotExist ( methodList , method ) ; } } top = false ; } while ( ( clazz = clazz . getSuperclass ( ) ) != limit ) ; Method [ ] methods = new Method [ methodList . size ( ) ] ; for ( int i = 0 ; i < methods . length ; i ++ ) { methods [ i ] = methodList . get ( i ) ; } return methods ;


signature:
public class ClassUtil { /** * Returns a < code > Method < / code > array of the methods to which instances of the specified
 * respond except for those methods defined in the class specified by limit
 * or any of its superclasses . Note that limit is usually used to eliminate
 * them methods defined by < code > java . lang . Object < / code > . If limit is < code > null < / code > then all
 * methods are returned . */
public static Method [ ] getSupportedMethods ( final Class clazz , final Class limit ) { } }

implementation: final ArrayList < Method > supportedMethods = new ArrayList < > ( ) ; for ( Class c = clazz ; c != limit && c != null ; c = c . getSuperclass ( ) ) { final Method [ ] methods = c . getDeclaredMethods ( ) ; for ( final Method method : methods ) { boolean found = false ; for ( final Method supportedMethod : supportedMethods ) { if ( compareSignatures ( method , supportedMethod ) ) { found = true ; break ; } } if ( ! found ) { supportedMethods . add ( method ) ; } } } return supportedMethods . toArray ( new Method [ 0 ] ) ;


signature:
public class ClassUtil { /** * Compares method declarations : signature and return types . */
public static boolean compareDeclarations ( final Method first , final Method second ) { } }

implementation: if ( first . getReturnType ( ) != second . getReturnType ( ) ) { return false ; } return compareSignatures ( first , second ) ;


signature:
public class ClassUtil { /** * Compares method signatures : names and parameters . */
public static boolean compareSignatures ( final Method first , final Method second ) { } }

implementation: if ( ! first . getName ( ) . equals ( second . getName ( ) ) ) { return false ; } return compareParameters ( first . getParameterTypes ( ) , second . getParameterTypes ( ) ) ;


signature:
public class ClassUtil { /** * Compares classes , usually method or ctor parameters . */
public static boolean compareParameters ( final Class [ ] first , final Class [ ] second ) { } }

implementation: if ( first . length != second . length ) { return false ; } for ( int i = 0 ; i < first . length ; i ++ ) { if ( first [ i ] != second [ i ] ) { return false ; } } return true ;


signature:
public class ClassUtil { /** * Suppress access check against a reflection object . SecurityException is silently ignored .
 * Checks first if the object is already accessible . */
public static void forceAccess ( final AccessibleObject accObject ) { } }

implementation:
try { if ( System . getSecurityManager ( ) == null ) accObject . setAccessible ( true ) ; else { AccessController . doPrivileged ( ( PrivilegedAction ) ( ) -> { accObject . setAccessible ( true ) ; return null ; } ) ; } } catch ( SecurityException sex ) { // ignore
}


signature:
public class ClassUtil { /** * Returns < code > true < / code > if class member is public and if its declaring class is also public . */
public static boolean isPublicPublic ( final Member member ) { } }

implementation: if ( Modifier . isPublic ( member . getModifiers ( ) ) ) { if ( Modifier . isPublic ( member . getDeclaringClass ( ) . getModifiers ( ) ) ) { return true ; } } return false ;


signature:
public class ClassUtil { /** * Creates new instance of given class with given optional arguments . */
@ SuppressWarnings ( "unchecked" ) public static < T > T newInstance ( final Class < T > clazz , final Object ... params ) throws InstantiationException , IllegalAccessException , InvocationTargetException , NoSuchMethodException { } }

implementation: if ( params . length == 0 ) { return newInstance ( clazz ) ; } final Class < ? > [ ] paramTypes = getClasses ( params ) ; final Constructor < ? > constructor = findConstructor ( clazz , paramTypes ) ; if ( constructor == null ) { throw new InstantiationException ( "No constructor matched parameter types." ) ; } return ( T ) constructor . newInstance ( params ) ;


signature:
public class ClassUtil { /** * Creates new instances including for common mutable classes that do not have a default constructor .
 * more user - friendly . It examines if class is a map , list ,
 * String , Character , Boolean or a Number . Immutable instances are cached and not created again .
 * Arrays are also created with no elements . Note that this bunch of < code > if < / code > blocks
 * is faster then using a < code > HashMap < / code > . */
@ SuppressWarnings ( "unchecked" ) public static < T > T newInstance ( final Class < T > type ) throws IllegalAccessException , InstantiationException , NoSuchMethodException , InvocationTargetException { } }

implementation: if ( type . isPrimitive ( ) ) { if ( type == int . class ) { return ( T ) Integer . valueOf ( 0 ) ; } if ( type == long . class ) { return ( T ) Long . valueOf ( 0 ) ; } if ( type == boolean . class ) { return ( T ) Boolean . FALSE ; } if ( type == float . class ) { return ( T ) Float . valueOf ( 0 ) ; } if ( type == double . class ) { return ( T ) Double . valueOf ( 0 ) ; } if ( type == byte . class ) { return ( T ) Byte . valueOf ( ( byte ) 0 ) ; } if ( type == short . class ) { return ( T ) Short . valueOf ( ( short ) 0 ) ; } if ( type == char . class ) { return ( T ) Character . valueOf ( ( char ) 0 ) ; } throw new IllegalArgumentException ( "Invalid primitive: " + type ) ; } if ( type . getName ( ) . startsWith ( "java." ) ) { if ( type == Integer . class ) { return ( T ) Integer . valueOf ( 0 ) ; } if ( type == String . class ) { return ( T ) StringPool . EMPTY ; } if ( type == Long . class ) { return ( T ) Long . valueOf ( 0 ) ; } if ( type == Boolean . class ) { return ( T ) Boolean . FALSE ; } if ( type == Float . class ) { return ( T ) Float . valueOf ( 0 ) ; } if ( type == Double . class ) { return ( T ) Double . valueOf ( 0 ) ; } if ( type == Map . class ) { return ( T ) new HashMap ( ) ; } if ( type == List . class ) { return ( T ) new ArrayList ( ) ; } if ( type == Set . class ) { return ( T ) new HashSet ( ) ; } if ( type == Collection . class ) { return ( T ) new ArrayList ( ) ; } if ( type == Byte . class ) { return ( T ) Byte . valueOf ( ( byte ) 0 ) ; } if ( type == Short . class ) { return ( T ) Short . valueOf ( ( short ) 0 ) ; } if ( type == Character . class ) { return ( T ) Character . valueOf ( ( char ) 0 ) ; } } if ( type . isEnum ( ) ) { return type . getEnumConstants ( ) [ 0 ] ; } if ( type . isArray ( ) ) { return ( T ) Array . newInstance ( type . getComponentType ( ) , 0 ) ; } Constructor < T > declaredConstructor = type . getDeclaredConstructor ( ) ; forceAccess ( declaredConstructor ) ; return declaredConstructor . newInstance ( ) ;


signature:
public class ClassUtil { /** * Returns < code > true < / code > if the first member is accessible from second one . */
public static boolean isAssignableFrom ( final Member member1 , final Member member2 ) { } }

implementation: return member1 . getDeclaringClass ( ) . isAssignableFrom ( member2 . getDeclaringClass ( ) ) ;


signature:
public class ClassUtil { /** * Returns all superclasses . */
public static Class [ ] getSuperclasses ( final Class type ) { } }

implementation: int i = 0 ; for ( Class x = type . getSuperclass ( ) ; x != null ; x = x . getSuperclass ( ) ) { i ++ ; } Class [ ] result = new Class [ i ] ; i = 0 ; for ( Class x = type . getSuperclass ( ) ; x != null ; x = x . getSuperclass ( ) ) { result [ i ] = x ; i ++ ; } return result ;


signature:
public class ClassUtil { /** * Returns < code > true < / code > if method is a bean property . */
public static boolean isBeanProperty ( final Method method ) { } }

implementation:
if ( isObjectMethod ( method ) ) { return false ; } String methodName = method . getName ( ) ; Class returnType = method . getReturnType ( ) ; Class [ ] paramTypes = method . getParameterTypes ( ) ; if ( methodName . startsWith ( METHOD_GET_PREFIX ) ) { // getter method must starts with ' get ' and it is not getClass ( )
if ( ( returnType != null ) && ( paramTypes . length == 0 ) ) { // getter must have a return type and no arguments
return true ; } } else if ( methodName . startsWith ( METHOD_IS_PREFIX ) ) { // ister must starts with ' is '
if ( ( returnType != null ) && ( paramTypes . length == 0 ) ) { // ister must have return type and no arguments
return true ; } } else if ( methodName . startsWith ( METHOD_SET_PREFIX ) ) { // setter must start with a ' set '
if ( paramTypes . length == 1 ) { // setter must have just one argument
return true ; } } return false ;


signature:
public class ClassUtil { /** * Returns property name from a getter method .
 * Returns < code > null < / code > if method is not a real getter . */
public static String getBeanPropertyGetterName ( final Method method ) { } }

implementation: int prefixLength = getBeanPropertyGetterPrefixLength ( method ) ; if ( prefixLength == 0 ) { return null ; } String methodName = method . getName ( ) . substring ( prefixLength ) ; return StringUtil . decapitalize ( methodName ) ;


signature:
public class ClassUtil { /** * Returns beans property setter name or < code > null < / code > if method is not a real setter . */
public static String getBeanPropertySetterName ( final Method method ) { } }

implementation: int prefixLength = getBeanPropertySetterPrefixLength ( method ) ; if ( prefixLength == 0 ) { return null ; } String methodName = method . getName ( ) . substring ( prefixLength ) ; return StringUtil . decapitalize ( methodName ) ;


signature:
public class ClassUtil { /** * Returns single component type for given type and implementation .
 * Index is used when type consist of many
 * components . If negative , index will be calculated from the end of the
 * returned array . Returns < code > null < / code > if component type
 * does not exist or if index is out of bounds .
 * @ see # getComponentTypes ( java . lang . reflect . Type , Class ) */
public static Class getComponentType ( final Type type , final Class implClass , int index ) { } }

implementation: Class [ ] componentTypes = getComponentTypes ( type , implClass ) ; if ( componentTypes == null ) { return null ; } if ( index < 0 ) { index += componentTypes . length ; } if ( index >= componentTypes . length ) { return null ; } return componentTypes [ index ] ;


signature:
public class ClassUtil { /** * Returns all component types of the given type .
 * For example the following types all have the
 * component - type MyClass :
 * < ul >
 * < li > MyClass [ ] < / li >
 * < li > List & lt ; MyClass & gt ; < / li >
 * < li > Foo & lt ; ? extends MyClass & gt ; < / li >
 * < li > Bar & lt ; ? super MyClass & gt ; < / li >
 * < li > & lt ; T extends MyClass & gt ; T [ ] < / li >
 * < / ul > */
public static Class [ ] getComponentTypes ( final Type type , final Class implClass ) { } }

implementation: if ( type instanceof Class ) { Class clazz = ( Class ) type ; if ( clazz . isArray ( ) ) { return new Class [ ] { clazz . getComponentType ( ) } ; } } else if ( type instanceof ParameterizedType ) { ParameterizedType pt = ( ParameterizedType ) type ; Type [ ] generics = pt . getActualTypeArguments ( ) ; if ( generics . length == 0 ) { return null ; } Class [ ] types = new Class [ generics . length ] ; for ( int i = 0 ; i < generics . length ; i ++ ) { types [ i ] = getRawType ( generics [ i ] , implClass ) ; } return types ; } else if ( type instanceof GenericArrayType ) { GenericArrayType gat = ( GenericArrayType ) type ; Class rawType = getRawType ( gat . getGenericComponentType ( ) , implClass ) ; if ( rawType == null ) { return null ; } return new Class [ ] { rawType } ; } return null ;


signature:
public class ClassUtil { /** * Converts < code > Type < / code > to a < code > String < / code > . Supports successor interfaces :
 * < ul >
 * < li > < code > java . lang . Class < / code > - represents usual class < / li >
 * < li > < code > java . lang . reflect . ParameterizedType < / code > - class with generic parameter ( e . g . < code > List < / code > ) < / li >
 * < li > < code > java . lang . reflect . TypeVariable < / code > - generic type literal ( e . g . < code > List < / code > , < code > T < / code > - type variable ) < / li >
 * < li > < code > java . lang . reflect . WildcardType < / code > - wildcard type ( < code > List & lt ; ? extends Number & gt ; < / code > , < code > " ? extends Number < / code > - wildcard type ) < / li >
 * < li > < code > java . lang . reflect . GenericArrayType < / code > - type for generic array ( e . g . < code > T [ ] < / code > , < code > T < / code > - array type ) < / li >
 * < / ul > */
public static String typeToString ( final Type type ) { } }

implementation: StringBuilder sb = new StringBuilder ( ) ; typeToString ( sb , type , new HashSet < Type > ( ) ) ; return sb . toString ( ) ;


signature:
public class ClassUtil { /** * Reads annotation value . Returns < code > null < / code > on error
 * ( e . g . when value name not found ) . */
public static Object readAnnotationValue ( final Annotation annotation , final String name ) { } }

implementation: try { Method method = annotation . annotationType ( ) . getDeclaredMethod ( name ) ; return method . invoke ( annotation ) ; } catch ( Exception ignore ) { return null ; }


signature:
public class ClassUtil { /** * Emulates < code > Reflection . getCallerClass < / code > using standard API .
 * This implementation uses custom < code > SecurityManager < / code >
 * and it is the fastest . Other implementations are :
 * < ul >
 * < li > < code > new Throwable ( ) . getStackTrace ( ) [ callStackDepth ] < / code > < / li >
 * < li > < code > Thread . currentThread ( ) . getStackTrace ( ) [ callStackDepth ] < / code > ( the slowest ) < / li >
 * < / ul >
 * In case when usage of < code > SecurityManager < / code > is not allowed ,
 * this method fails back to the second implementation .
 * Note that original < code > Reflection . getCallerClass < / code > is way faster
 * then any emulation . */
public static Class getCallerClass ( int framesToSkip ) { } }

implementation: if ( SECURITY_MANAGER != null ) { return SECURITY_MANAGER . getCallerClass ( framesToSkip ) ; } StackTraceElement [ ] stackTraceElements = new Throwable ( ) . getStackTrace ( ) ; if ( framesToSkip >= 2 ) { framesToSkip += 4 ; } String className = stackTraceElements [ framesToSkip ] . getClassName ( ) ; try { return Thread . currentThread ( ) . getContextClassLoader ( ) . loadClass ( className ) ; } catch ( ClassNotFoundException cnfex ) { throw new UnsupportedOperationException ( className + " not found." ) ; }


signature:
public class ClassUtil { /** * Smart variant of { @ link # getCallerClass ( int ) } that skips all relevant Jodd calls .
 * However , this one does not use the security manager . */
public static Class getCallerClass ( ) { } }

implementation: String className = null ; StackTraceElement [ ] stackTraceElements = new Throwable ( ) . getStackTrace ( ) ; for ( StackTraceElement stackTraceElement : stackTraceElements ) { className = stackTraceElement . getClassName ( ) ; String methodName = stackTraceElement . getMethodName ( ) ; if ( methodName . equals ( "loadClass" ) ) { if ( className . contains ( ClassLoaderStrategy . class . getSimpleName ( ) ) ) { continue ; } if ( className . equals ( ClassLoaderUtil . class . getName ( ) ) ) { continue ; } } else if ( methodName . equals ( "getCallerClass" ) ) { continue ; } break ; } try { return Thread . currentThread ( ) . getContextClassLoader ( ) . loadClass ( className ) ; } catch ( ClassNotFoundException cnfex ) { throw new UnsupportedOperationException ( className + " not found." ) ; }


signature:
public class ClassUtil { /** * Returns < code > enum < / code > class or < code > null < / code > if class is not an enum . */
public static Class findEnum ( Class target ) { } }

implementation: if ( target . isPrimitive ( ) ) { return null ; } while ( target != Object . class ) { if ( target . isEnum ( ) ) { return target ; } target = target . getSuperclass ( ) ; } return null ;


signature:
public class ClassUtil { /** * Returns the class of the immediate subclass of the given parent class for
 * the given object instance ; or null if such immediate subclass cannot be
 * uniquely identified for the given object instance . */
public static Class < ? > childClassOf ( final Class < ? > parentClass , final Object instance ) { } }

implementation: if ( instance == null || instance == Object . class ) { return null ; } if ( parentClass != null ) { if ( parentClass . isInterface ( ) ) { return null ; } } Class < ? > childClass = instance . getClass ( ) ; while ( true ) { Class < ? > parent = childClass . getSuperclass ( ) ; if ( parent == parentClass ) { return childClass ; } if ( parent == null ) { return null ; } childClass = parent ; }


signature:
public class ClassUtil { /** * Returns the jar file from which the given class is loaded ; or null
 * if no such jar file can be located . */
public static JarFile jarFileOf ( final Class < ? > klass ) { } }

implementation:
URL url = klass . getResource ( "/" + klass . getName ( ) . replace ( '.' , '/' ) + ".class" ) ; if ( url == null ) { return null ; } String s = url . getFile ( ) ; int beginIndex = s . indexOf ( "file:" ) + "file:" . length ( ) ; int endIndex = s . indexOf ( ".jar!" ) ; if ( endIndex == - 1 ) { return null ; } endIndex += ".jar" . length ( ) ; String f = s . substring ( beginIndex , endIndex ) ; // decode URL string - it may contain encoded chars ( e . g . whitespaces ) which are not supported for file - instances
f = URLDecoder . decode ( f , "UTF-8" ) ; File file = new File ( f ) ; try { return file . exists ( ) ? new JarFile ( file ) : null ; } catch ( IOException e ) { throw new IllegalStateException ( e ) ; }


signature:
public class ClassUtil { /** * Resolves class file name from class name by replacing dot ' s with ' / ' separator
 * and adding class extension at the end . If array , component type is returned . */
public static String convertClassNameToFileName ( Class clazz ) { } }

implementation: if ( clazz . isArray ( ) ) { clazz = clazz . getComponentType ( ) ; } return convertClassNameToFileName ( clazz . getName ( ) ) ;


signature:
public class ClassUtil { /** * Returns { @ code true } if type is a Kotlin class . */
public static boolean isKotlinClass ( final Class type ) { } }

implementation: final Annotation [ ] annotations = type . getAnnotations ( ) ; for ( Annotation annotation : annotations ) { if ( annotation . annotationType ( ) . getName ( ) . equals ( "kotlin.Metadata" ) ) { return true ; } } return false ;


signature:
public class TypesUtil { /** * Returns < code > true < / code > if type is some integer - like type : INTEGER , SMALLINT , TINYINT , BIT . */
public static boolean isIntegerType ( final int type ) { } }

implementation: return ( type == Types . INTEGER ) || ( type == Types . SMALLINT ) || ( type == Types . TINYINT ) || ( type == Types . BIT ) ;


signature:
public class ThreadUtil { /** * Puts a thread to sleep , without throwing an InterruptedException .
 * @ param ms the length of time to sleep in milliseconds */
public static void sleep ( final long ms ) { } }

implementation: try { Thread . sleep ( ms ) ; } catch ( InterruptedException iex ) { Thread . currentThread ( ) . interrupt ( ) ; }


signature:
public class ThreadUtil { /** * Puts a thread to sleep forever . */
public static void sleep ( ) { } }

implementation: try { Thread . sleep ( Long . MAX_VALUE ) ; } catch ( InterruptedException iex ) { Thread . currentThread ( ) . interrupt ( ) ; }


signature:
public class ThreadUtil { /** * Waits for a object for synchronization purposes . */
public static void wait ( final Object obj ) { } }

implementation: synchronized ( obj ) { try { obj . wait ( ) ; } catch ( InterruptedException inex ) { Thread . currentThread ( ) . interrupt ( ) ; } }


signature:
public class ThreadUtil { /** * - - - - - join */
public static void join ( final Thread thread ) { } }

implementation: try { thread . join ( ) ; } catch ( InterruptedException inex ) { Thread . currentThread ( ) . interrupt ( ) ; }


signature:
public class ThreadUtil { /** * Creates new daemon thread factory . */
public static ThreadFactory daemonThreadFactory ( final String name , final int priority ) { } }

implementation: return new ThreadFactory ( ) { private AtomicInteger count = new AtomicInteger ( ) ; @ Override public Thread newThread ( final Runnable r ) { Thread thread = new Thread ( r ) ; thread . setName ( name + '-' + count . incrementAndGet ( ) ) ; thread . setDaemon ( true ) ; thread . setPriority ( priority ) ; return thread ; } } ;


signature:
public class LazyValue { /** * Returns the value . Value will be computed on first call . */
@ Override public T get ( ) { } }

implementation: if ( ! initialized ) { synchronized ( this ) { if ( ! initialized ) { final T t = supplier . get ( ) ; value = t ; initialized = true ; supplier = null ; return t ; } } } return value ;


signature:
public class MethodVisitor { /** * Visits a parameter of this method .
 * @ param name parameter name or null if none is provided .
 * @ param access the parameter ' s access flags , only { @ code ACC _ FINAL } , { @ code ACC _ SYNTHETIC }
 * or / and { @ code ACC _ MANDATED } are allowed ( see { @ link Opcodes } ) . */
public void visitParameter ( final String name , final int access ) { } }

implementation: if ( api < Opcodes . ASM5 ) { throw new UnsupportedOperationException ( REQUIRES_ASM5 ) ; } if ( mv != null ) { mv . visitParameter ( name , access ) ; }


signature:
public class MethodVisitor { /** * Visits an annotation of this method .
 * @ param descriptor the class descriptor of the annotation class .
 * @ param visible { @ literal true } if the annotation is visible at runtime .
 * @ return a visitor to visit the annotation values , or { @ literal null } if this visitor is not
 * interested in visiting this annotation . */
public AnnotationVisitor visitAnnotation ( final String descriptor , final boolean visible ) { } }

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


signature:
public class MethodVisitor { /** * Visits an annotation on a type in the method signature .
 * @ param typeRef a reference to the annotated type . The sort of this type reference must be
 * { @ link TypeReference # METHOD _ TYPE _ PARAMETER } , { @ link
 * TypeReference # METHOD _ TYPE _ PARAMETER _ BOUND } , { @ link TypeReference # METHOD _ RETURN } , { @ link
 * TypeReference # METHOD _ RECEIVER } , { @ link TypeReference # METHOD _ FORMAL _ PARAMETER } or { @ link
 * TypeReference # THROWS } . See { @ link TypeReference } .
 * @ param typePath the path to the annotated type argument , wildcard bound , array element type , or
 * static inner type within ' typeRef ' . May be { @ literal null } if the annotation targets
 * ' typeRef ' as a whole .
 * @ param descriptor the class descriptor of the annotation class .
 * @ param visible { @ literal true } if the annotation is visible at runtime .
 * @ return a visitor to visit the annotation values , or { @ literal null } if this visitor is not
 * interested in visiting this annotation . */
public AnnotationVisitor visitTypeAnnotation ( final int typeRef , final TypePath typePath , final String descriptor , final boolean visible ) { } }

implementation: if ( api < Opcodes . ASM5 ) { throw new UnsupportedOperationException ( REQUIRES_ASM5 ) ; } if ( mv != null ) { return mv . visitTypeAnnotation ( typeRef , typePath , descriptor , visible ) ; } return null ;


signature:
public class MethodVisitor { /** * Visits an annotation of a parameter this method .
 * @ param parameter the parameter index . This index must be strictly smaller than the number of
 * parameters in the method descriptor , and strictly smaller than the parameter count
 * specified in { @ link # visitAnnotableParameterCount } . Important note : < i > a parameter index i
 * is not required to correspond to the i ' th parameter descriptor in the method
 * descriptor < / i > , in particular in case of synthetic parameters ( see
 * https : / / docs . oracle . com / javase / specs / jvms / se9 / html / jvms - 4 . html # jvms - 4.7.18 ) .
 * @ param descriptor the class descriptor of the annotation class .
 * @ param visible { @ literal true } if the annotation is visible at runtime .
 * @ return a visitor to visit the annotation values , or { @ literal null } if this visitor is not
 * interested in visiting this annotation . */
public AnnotationVisitor visitParameterAnnotation ( final int parameter , final String descriptor , final boolean visible ) { } }

implementation: if ( mv != null ) { return mv . visitParameterAnnotation ( parameter , descriptor , visible ) ; } return null ;


signature:
public class MethodVisitor { /** * Visits the current state of the local variables and operand stack elements . This method must ( * )
 * be called < i > just before < / i > any instruction < b > i < / b > that follows an unconditional branch
 * instruction such as GOTO or THROW , that is the target of a jump instruction , or that starts an
 * exception handler block . The visited types must describe the values of the local variables and
 * of the operand stack elements < i > just before < / i > < b > i < / b > is executed . < br >
 * < br >
 * ( * ) this is mandatory only for classes whose version is greater than or equal to { @ link
 * Opcodes # V1_6 } . < br >
 * < br >
 * The frames of a method must be given either in expanded form , or in compressed form ( all frames
 * must use the same format , i . e . you must not mix expanded and compressed frames within a single
 * method ) :
 * < ul >
 * < li > In expanded form , all frames must have the F _ NEW type .
 * < li > In compressed form , frames are basically " deltas " from the state of the previous frame :
 * < ul >
 * < li > { @ link Opcodes # F _ SAME } representing frame with exactly the same locals as the
 * previous frame and with the empty stack .
 * < li > { @ link Opcodes # F _ SAME1 } representing frame with exactly the same locals as the
 * previous frame and with single value on the stack ( < code > numStack < / code > is 1 and
 * < code > stack [ 0 ] < / code > contains value for the type of the stack item ) .
 * < li > { @ link Opcodes # F _ APPEND } representing frame with current locals are the same as the
 * locals in the previous frame , except that additional locals are defined ( < code >
 * numLocal < / code > is 1 , 2 or 3 and < code > local < / code > elements contains values
 * representing added types ) .
 * < li > { @ link Opcodes # F _ CHOP } representing frame with current locals are the same as the
 * locals in the previous frame , except that the last 1-3 locals are absent and with
 * the empty stack ( < code > numLocal < / code > is 1 , 2 or 3 ) .
 * < li > { @ link Opcodes # F _ FULL } representing complete frame data .
 * < / ul >
 * < / ul >
 * < br >
 * In both cases the first frame , corresponding to the method ' s parameters and access flags , is
 * implicit and must not be visited . Also , it is illegal to visit two or more frames for the same
 * code location ( i . e . , at least one instruction must be visited between two calls to visitFrame ) .
 * @ param type the type of this stack map frame . Must be { @ link Opcodes # F _ NEW } for expanded
 * frames , or { @ link Opcodes # F _ FULL } , { @ link Opcodes # F _ APPEND } , { @ link Opcodes # F _ CHOP } , { @ link
 * Opcodes # F _ SAME } or { @ link Opcodes # F _ APPEND } , { @ link Opcodes # F _ SAME1 } for compressed frames .
 * @ param numLocal the number of local variables in the visited frame .
 * @ param local the local variable types in this frame . This array must not be modified . Primitive
 * types are represented by { @ link Opcodes # TOP } , { @ link Opcodes # INTEGER } , { @ link
 * Opcodes # FLOAT } , { @ link Opcodes # LONG } , { @ link Opcodes # DOUBLE } , { @ link Opcodes # NULL } or
 * { @ link Opcodes # UNINITIALIZED _ THIS } ( long and double are represented by a single element ) .
 * Reference types are represented by String objects ( representing internal names ) , and
 * uninitialized types by Label objects ( this label designates the NEW instruction that
 * created this uninitialized value ) .
 * @ param numStack the number of operand stack elements in the visited frame .
 * @ param stack the operand stack types in this frame . This array must not be modified . Its
 * content has the same format as the " local " array .
 * @ throws IllegalStateException if a frame is visited just after another one , without any
 * instruction between the two ( unless this frame is a Opcodes # F _ SAME frame , in which case it
 * is silently ignored ) . */
public void visitFrame ( final int type , final int numLocal , final Object [ ] local , final int numStack , final Object [ ] stack ) { } }

implementation: if ( mv != null ) { mv . visitFrame ( type , numLocal , local , numStack , stack ) ; }


signature:
public class MethodVisitor { /** * Visits a field instruction . A field instruction is an instruction that loads or stores the
 * value of a field of an object .
 * @ param opcode the opcode of the type instruction to be visited . This opcode is either
 * GETSTATIC , PUTSTATIC , GETFIELD or PUTFIELD .
 * @ param owner the internal name of the field ' s owner class ( see { @ link Type # getInternalName ( ) } ) .
 * @ param name the field ' s name .
 * @ param descriptor the field ' s descriptor ( see { @ link Type } ) . */
public void visitFieldInsn ( final int opcode , final String owner , final String name , final String descriptor ) { } }

implementation: if ( mv != null ) { mv . visitFieldInsn ( opcode , owner , name , descriptor ) ; }


signature:
public class MethodVisitor { /** * Visits a method instruction . A method instruction is an instruction that invokes a method .
 * @ param opcode the opcode of the type instruction to be visited . This opcode is either
 * INVOKEVIRTUAL , INVOKESPECIAL , INVOKESTATIC or INVOKEINTERFACE .
 * @ param owner the internal name of the method ' s owner class ( see { @ link
 * Type # getInternalName ( ) } ) .
 * @ param name the method ' s name .
 * @ param descriptor the method ' s descriptor ( see { @ link Type } ) .
 * @ param isInterface if the method ' s owner class is an interface . */
public void visitMethodInsn ( final int opcode , final String owner , final String name , final String descriptor , final boolean isInterface ) { } }

implementation: if ( api < Opcodes . ASM5 ) { if ( isInterface != ( opcode == Opcodes . INVOKEINTERFACE ) ) { throw new IllegalArgumentException ( "INVOKESPECIAL/STATIC on interfaces requires ASM5" ) ; } visitMethodInsn ( opcode , owner , name , descriptor ) ; return ; } if ( mv != null ) { mv . visitMethodInsn ( opcode , owner , name , descriptor , isInterface ) ; }


signature:
public class MethodVisitor { /** * Visits an invokedynamic instruction .
 * @ param name the method ' s name .
 * @ param descriptor the method ' s descriptor ( see { @ link Type } ) .
 * @ param bootstrapMethodHandle the bootstrap method .
 * @ param bootstrapMethodArguments the bootstrap method constant arguments . Each argument must be
 * an { @ link Integer } , { @ link Float } , { @ link Long } , { @ link Double } , { @ link String } , { @ link
 * Type } , { @ link Handle } or { @ link ConstantDynamic } value . This method is allowed to modify
 * the content of the array so a caller should expect that this array may change . */
public void visitInvokeDynamicInsn ( final String name , final String descriptor , final Handle bootstrapMethodHandle , final Object ... bootstrapMethodArguments ) { } }

implementation: if ( api < Opcodes . ASM5 ) { throw new UnsupportedOperationException ( REQUIRES_ASM5 ) ; } if ( mv != null ) { mv . visitInvokeDynamicInsn ( name , descriptor , bootstrapMethodHandle , bootstrapMethodArguments ) ; }


signature:
public class MethodVisitor { /** * Visits a jump instruction . A jump instruction is an instruction that may jump to another
 * instruction .
 * @ param opcode the opcode of the type instruction to be visited . This opcode is either IFEQ ,
 * IFNE , IFLT , IFGE , IFGT , IFLE , IF _ ICMPEQ , IF _ ICMPNE , IF _ ICMPLT , IF _ ICMPGE , IF _ ICMPGT ,
 * IF _ ICMPLE , IF _ ACMPEQ , IF _ ACMPNE , GOTO , JSR , IFNULL or IFNONNULL .
 * @ param label the operand of the instruction to be visited . This operand is a label that
 * designates the instruction to which the jump instruction may jump . */
public void visitJumpInsn ( final int opcode , final Label label ) { } }

implementation: if ( mv != null ) { mv . visitJumpInsn ( opcode , label ) ; }


signature:
public class MethodVisitor { /** * Visits a MULTIANEWARRAY instruction .
 * @ param descriptor an array type descriptor ( see { @ link Type } ) .
 * @ param numDimensions the number of dimensions of the array to allocate . */
public void visitMultiANewArrayInsn ( final String descriptor , final int numDimensions ) { } }

implementation: if ( mv != null ) { mv . visitMultiANewArrayInsn ( descriptor , numDimensions ) ; }


signature:
public class MethodVisitor { /** * Visits a try catch block .
 * @ param start the beginning of the exception handler ' s scope ( inclusive ) .
 * @ param end the end of the exception handler ' s scope ( exclusive ) .
 * @ param handler the beginning of the exception handler ' s code .
 * @ param type the internal name of the type of exceptions handled by the handler , or { @ literal
 * null } to catch any exceptions ( for " finally " blocks ) .
 * @ throws IllegalArgumentException if one of the labels has already been visited by this visitor
 * ( by the { @ link # visitLabel } method ) . */
public void visitTryCatchBlock ( final Label start , final Label end , final Label handler , final String type ) { } }

implementation: if ( mv != null ) { mv . visitTryCatchBlock ( start , end , handler , type ) ; }


signature:
public class MethodVisitor { /** * Visits an annotation on a local variable type .
 * @ param typeRef a reference to the annotated type . The sort of this type reference must be
 * { @ link TypeReference # LOCAL _ VARIABLE } or { @ link TypeReference # RESOURCE _ VARIABLE } . See { @ link
 * TypeReference } .
 * @ param typePath the path to the annotated type argument , wildcard bound , array element type , or
 * static inner type within ' typeRef ' . May be { @ literal null } if the annotation targets
 * ' typeRef ' as a whole .
 * @ param start the fist instructions corresponding to the continuous ranges that make the scope
 * of this local variable ( inclusive ) .
 * @ param end the last instructions corresponding to the continuous ranges that make the scope of
 * this local variable ( exclusive ) . This array must have the same size as the ' start ' array .
 * @ param index the local variable ' s index in each range . This array must have the same size as
 * the ' start ' array .
 * @ param descriptor the class descriptor of the annotation class .
 * @ param visible { @ literal true } if the annotation is visible at runtime .
 * @ return a visitor to visit the annotation values , or { @ literal null } if this visitor is not
 * interested in visiting this annotation . */
public AnnotationVisitor visitLocalVariableAnnotation ( final int typeRef , final TypePath typePath , final Label [ ] start , final Label [ ] end , final int [ ] index , final String descriptor , final boolean visible ) { } }

implementation: if ( api < Opcodes . ASM5 ) { throw new UnsupportedOperationException ( REQUIRES_ASM5 ) ; } if ( mv != null ) { return mv . visitLocalVariableAnnotation ( typeRef , typePath , start , end , index , descriptor , visible ) ; } return null ;


signature:
public class PropertiesToProps { /** * Convert Java Properties to Jodd Props format
 * @ param writer Writer to write Props formatted file content to
 * @ param properties Properties to convert to Props format
 * @ param profiles Properties per profile to convert and add to the Props format
 * @ throws IOException On any I / O error when writing to the writer */
void convertToWriter ( final Writer writer , final Properties properties , final Map < String , Properties > profiles ) throws IOException { } }

implementation: final BufferedWriter bw = getBufferedWriter ( writer ) ; writeBaseAndProfileProperties ( bw , properties , profiles ) ; writeProfilePropertiesThatAreNotInTheBase ( bw , properties , profiles ) ; bw . flush ( ) ;


signature:
public class MemoryFileUpload { /** * Reads data from input stream into byte array and stores file size . */
@ Override public void processStream ( ) throws IOException { } }

implementation:
FastByteArrayOutputStream out = new FastByteArrayOutputStream ( ) ; size = 0 ; if ( maxFileSize == - 1 ) { size += input . copyAll ( out ) ; } else { size += input . copyMax ( out , maxFileSize + 1 ) ; // one more byte to detect larger files
if ( size > maxFileSize ) { fileTooBig = true ; valid = false ; input . skipToBoundary ( ) ; return ; } } data = out . toByteArray ( ) ; size = data . length ; valid = true ;


signature:
public class DbListIterator { /** * Returns < code > true < / code > if there is { @ link # next ( ) next } parsed object
 * available . */
@ Override public boolean hasNext ( ) { } }

implementation: if ( hasNext == null ) { hasNext = Boolean . valueOf ( moveToNext ( ) ) ; } return hasNext . booleanValue ( ) ;


signature:
public class DbListIterator { /** * Returns next mapped object . */
@ Override public T next ( ) { } }

implementation: if ( hasNext == null ) { hasNext = Boolean . valueOf ( moveToNext ( ) ) ; } if ( hasNext == false ) { throw new NoSuchElementException ( ) ; } if ( ! entityAwareMode ) { hasNext = null ; return newElement ; } count ++ ; T result = previousElement ; previousElement = newElement ; hasNext = null ; return result ;


signature:
public class DbListIterator { /** * Moves to next element . */
private boolean moveToNext ( ) { } }

implementation:
if ( last ) { // last has been set to true , so no more rows to iterate - close everything
if ( closeOnEnd ) { query . close ( ) ; } else { query . closeResultSet ( resultSetMapper . getResultSet ( ) ) ; } return false ; } while ( true ) { if ( ! resultSetMapper . next ( ) ) { // no more rows , no more parsing , previousElement is the last one to iterate
last = true ; return entityAwareMode ; } // parse row
Object [ ] objects = resultSetMapper . parseObjects ( types ) ; Object row = query . resolveRowResults ( objects ) ; newElement = ( T ) row ; if ( entityAwareMode ) { if ( count == 0 && previousElement == null ) { previousElement = newElement ; continue ; } if ( previousElement != null && newElement != null ) { boolean equals ; if ( newElement . getClass ( ) . isArray ( ) ) { equals = Arrays . equals ( ( Object [ ] ) previousElement , ( Object [ ] ) newElement ) ; } else { equals = previousElement . equals ( newElement ) ; } if ( equals ) { continue ; } } } break ; } return true ;


signature:
public class ArraysUtil { /** * Joins arrays . Component type is resolved from the array argument . */
@ SuppressWarnings ( { } }

implementation: "unchecked" } ) public static < T > T [ ] join ( T [ ] ... arrays ) { Class < T > componentType = ( Class < T > ) arrays . getClass ( ) . getComponentType ( ) . getComponentType ( ) ; return join ( componentType , arrays ) ;


signature:
public class ArraysUtil { /** * Joins arrays using provided component type . */
@ SuppressWarnings ( { } }

implementation: "unchecked" } ) public static < T > T [ ] join ( Class < T > componentType , T [ ] [ ] arrays ) { if ( arrays . length == 1 ) { return arrays [ 0 ] ; } int length = 0 ; for ( T [ ] array : arrays ) { length += array . length ; } T [ ] result = ( T [ ] ) Array . newInstance ( componentType , length ) ; length = 0 ; for ( T [ ] array : arrays ) { System . arraycopy ( array , 0 , result , length , array . length ) ; length += array . length ; } return result ;


signature:
public class ArraysUtil { /** * Join < code > double < / code > arrays . */
public static double [ ] join ( double [ ] ... arrays ) { } }

implementation: if ( arrays . length == 0 ) { return new double [ 0 ] ; } if ( arrays . length == 1 ) { return arrays [ 0 ] ; } int length = 0 ; for ( double [ ] array : arrays ) { length += array . length ; } double [ ] result = new double [ length ] ; length = 0 ; for ( double [ ] array : arrays ) { System . arraycopy ( array , 0 , result , length , array . length ) ; length += array . length ; } return result ;


signature:
public class ArraysUtil { /** * Resizes an array . */
public static < T > T [ ] resize ( T [ ] buffer , int newSize ) { } }

implementation: Class < T > componentType = ( Class < T > ) buffer . getClass ( ) . getComponentType ( ) ; T [ ] temp = ( T [ ] ) Array . newInstance ( componentType , newSize ) ; System . arraycopy ( buffer , 0 , temp , 0 , buffer . length >= newSize ? newSize : buffer . length ) ; return temp ;


signature:
public class ArraysUtil { /** * Resizes a < code > String < / code > array . */
public static String [ ] resize ( String [ ] buffer , int newSize ) { } }

implementation: String [ ] temp = new String [ newSize ] ; System . arraycopy ( buffer , 0 , temp , 0 , buffer . length >= newSize ? newSize : buffer . length ) ; return temp ;


signature:
public class ArraysUtil { /** * Appends an element to array . */
public static < T > T [ ] append ( T [ ] buffer , T newElement ) { } }

implementation: T [ ] t = resize ( buffer , buffer . length + 1 ) ; t [ buffer . length ] = newElement ; return t ;


signature:
public class ArraysUtil { /** * Removes sub - array . */
@ SuppressWarnings ( { } }

implementation: "unchecked" } ) public static < T > T [ ] remove ( T [ ] buffer , int offset , int length , Class < T > componentType ) { int len2 = buffer . length - length ; T [ ] temp = ( T [ ] ) Array . newInstance ( componentType , len2 ) ; System . arraycopy ( buffer , 0 , temp , 0 , offset ) ; System . arraycopy ( buffer , offset + length , temp , offset , len2 - offset ) ; return temp ;


signature:
public class ArraysUtil { /** * Removes sub - array from < code > boolean < / code > array . */
public static boolean [ ] remove ( boolean [ ] buffer , int offset , int length ) { } }

implementation: int len2 = buffer . length - length ; boolean [ ] temp = new boolean [ len2 ] ; System . arraycopy ( buffer , 0 , temp , 0 , offset ) ; System . arraycopy ( buffer , offset + length , temp , offset , len2 - offset ) ; return temp ;


signature:
public class ArraysUtil { /** * Returns subarray . */
public static < T > T [ ] subarray ( T [ ] buffer , int offset , int length ) { } }

implementation: Class < T > componentType = ( Class < T > ) buffer . getClass ( ) . getComponentType ( ) ; return subarray ( buffer , offset , length , componentType ) ;


signature:
public class ArraysUtil { /** * Returns subarray . */
@ SuppressWarnings ( { } }

implementation: "unchecked" } ) public static < T > T [ ] subarray ( T [ ] buffer , int offset , int length , Class < T > componentType ) { T [ ] temp = ( T [ ] ) Array . newInstance ( componentType , length ) ; System . arraycopy ( buffer , offset , temp , 0 , length ) ; return temp ;


signature:
public class ArraysUtil { /** * Returns subarray . */
public static String [ ] subarray ( String [ ] buffer , int offset , int length ) { } }

implementation: String [ ] temp = new String [ length ] ; System . arraycopy ( buffer , offset , temp , 0 , length ) ; return temp ;


signature:
public class ArraysUtil { /** * Inserts one array into another < code > String < / code > array . */
public static String [ ] insert ( String [ ] dest , String [ ] src , int offset ) { } }

implementation: String [ ] temp = new String [ dest . length + src . length ] ; System . arraycopy ( dest , 0 , temp , 0 , offset ) ; System . arraycopy ( src , 0 , temp , offset , src . length ) ; System . arraycopy ( dest , offset , temp , src . length + offset , dest . length - offset ) ; return temp ;


signature:
public class ArraysUtil { /** * Inserts one array into another at given offset . */
public static < T > T [ ] insertAt ( T [ ] dest , T [ ] src , int offset ) { } }

implementation: Class < T > componentType = ( Class < T > ) dest . getClass ( ) . getComponentType ( ) ; return insertAt ( dest , src , offset , componentType ) ;


signature:
public class ArraysUtil { /** * Inserts one array into another at given offset . */
@ SuppressWarnings ( { } }

implementation: "unchecked" } ) public static < T > T [ ] insertAt ( T [ ] dest , T [ ] src , int offset , Class componentType ) { T [ ] temp = ( T [ ] ) Array . newInstance ( componentType , dest . length + src . length - 1 ) ; System . arraycopy ( dest , 0 , temp , 0 , offset ) ; System . arraycopy ( src , 0 , temp , offset , src . length ) ; System . arraycopy ( dest , offset + 1 , temp , src . length + offset , dest . length - offset - 1 ) ; return temp ;


signature:
public class ArraysUtil { /** * Converts to primitive array . */
public static byte [ ] values ( Byte [ ] array ) { } }

implementation: byte [ ] dest = new byte [ array . length ] ; for ( int i = 0 ; i < array . length ; i ++ ) { Byte v = array [ i ] ; if ( v != null ) { dest [ i ] = v . byteValue ( ) ; } } return dest ;


signature:
public class ArraysUtil { /** * Converts to object array . */
public static Byte [ ] valuesOf ( byte [ ] array ) { } }

implementation: Byte [ ] dest = new Byte [ array . length ] ; for ( int i = 0 ; i < array . length ; i ++ ) { dest [ i ] = Byte . valueOf ( array [ i ] ) ; } return dest ;


signature:
public class ArraysUtil { /** * Converts to primitive array . */
public static char [ ] values ( Character [ ] array ) { } }

implementation: char [ ] dest = new char [ array . length ] ; for ( int i = 0 ; i < array . length ; i ++ ) { Character v = array [ i ] ; if ( v != null ) { dest [ i ] = v . charValue ( ) ; } } return dest ;


signature:
public class ArraysUtil { /** * Converts to object array . */
public static Character [ ] valuesOf ( char [ ] array ) { } }

implementation: Character [ ] dest = new Character [ array . length ] ; for ( int i = 0 ; i < array . length ; i ++ ) { dest [ i ] = Character . valueOf ( array [ i ] ) ; } return dest ;


signature:
public class ArraysUtil { /** * Converts to primitive array . */
public static short [ ] values ( Short [ ] array ) { } }

implementation: short [ ] dest = new short [ array . length ] ; for ( int i = 0 ; i < array . length ; i ++ ) { Short v = array [ i ] ; if ( v != null ) { dest [ i ] = v . shortValue ( ) ; } } return dest ;