signature:
public class Methods { /** * Returns all methods . Cached . Lazy . */
public MethodDescriptor [ ] getAllMethodDescriptors ( ) { } }

implementation: if ( allMethods == null ) { final List < MethodDescriptor > allMethodsList = new ArrayList < > ( ) ; for ( MethodDescriptor [ ] methodDescriptors : methodsMap . values ( ) ) { Collections . addAll ( allMethodsList , methodDescriptors ) ; } final MethodDescriptor [ ] allMethods = allMethodsList . toArray ( new MethodDescriptor [ 0 ] ) ; Arrays . sort ( allMethods , Comparator . comparing ( md -> md . getMethod ( ) . getName ( ) ) ) ; this . allMethods = allMethods ; } return allMethods ;


signature:
public class NetUtil { /** * Resolves IP address from a hostname . */
public static String resolveIpAddress ( final String hostname ) { } }

implementation: try { InetAddress netAddress ; if ( hostname == null || hostname . equalsIgnoreCase ( LOCAL_HOST ) ) { netAddress = InetAddress . getLocalHost ( ) ; } else { netAddress = Inet4Address . getByName ( hostname ) ; } return netAddress . getHostAddress ( ) ; } catch ( UnknownHostException ignore ) { return null ; }


signature:
public class NetUtil { /** * Returns IP address as integer . */
public static int getIpAsInt ( final String ipAddress ) { } }

implementation: int ipIntValue = 0 ; String [ ] tokens = StringUtil . splitc ( ipAddress , '.' ) ; for ( String token : tokens ) { if ( ipIntValue > 0 ) { ipIntValue <<= 8 ; } ipIntValue += Integer . parseInt ( token ) ; } return ipIntValue ;


signature:
public class NetUtil { /** * Checks given string against IP address v4 format .
 * @ param input an ip address - may be null
 * @ return < tt > true < / tt > if param has a valid ip v4 format < tt > false < / tt > otherwise
 * @ see < a href = " https : / / en . wikipedia . org / wiki / IP _ address # IPv4 _ addresses " > ip address v4 < / a > */
public static boolean validateAgaintIPAdressV4Format ( final String input ) { } }

implementation: if ( input == null ) { return false ; } int hitDots = 0 ; char [ ] data = input . toCharArray ( ) ; for ( int i = 0 ; i < data . length ; i ++ ) { char c = data [ i ] ; int b = 0 ; do { if ( c < '0' || c > '9' ) { return false ; } b = ( b * 10 + c ) - 48 ; if ( ++ i >= data . length ) { break ; } c = data [ i ] ; } while ( c != '.' ) ; if ( b > 255 ) { return false ; } hitDots ++ ; } return hitDots == 4 ;


signature:
public class NetUtil { /** * Resolves host name from IP address bytes . */
public static String resolveHostName ( final byte [ ] ip ) { } }

implementation: try { InetAddress address = InetAddress . getByAddress ( ip ) ; return address . getHostName ( ) ; } catch ( UnknownHostException ignore ) { return null ; }


signature:
public class NetUtil { /** * Downloads resource as byte array . */
public static byte [ ] downloadBytes ( final String url ) throws IOException { } }

implementation: try ( InputStream inputStream = new URL ( url ) . openStream ( ) ) { return StreamUtil . readBytes ( inputStream ) ; }


signature:
public class NetUtil { /** * Downloads resource as String . */
public static String downloadString ( final String url , final String encoding ) throws IOException { } }

implementation: try ( InputStream inputStream = new URL ( url ) . openStream ( ) ) { return new String ( StreamUtil . readChars ( inputStream , encoding ) ) ; }


signature:
public class NetUtil { /** * Downloads resource to a file , potentially very efficiently . */
public static void downloadFile ( final String url , final File file ) throws IOException { } }

implementation: try ( InputStream inputStream = new URL ( url ) . openStream ( ) ; ReadableByteChannel rbc = Channels . newChannel ( inputStream ) ; FileChannel fileChannel = FileChannel . open ( file . toPath ( ) , StandardOpenOption . CREATE , StandardOpenOption . TRUNCATE_EXISTING , StandardOpenOption . WRITE ) ) { fileChannel . transferFrom ( rbc , 0 , Long . MAX_VALUE ) ; }


signature:
public class LagartoServletFilter { /** * Wraps the response and parse it using Lagarto parser .
 * It first calls { @ link # processActionPath ( javax . servlet . http . HttpServletRequest , javax . servlet . http . HttpServletResponse , String ) }
 * to optionally consumes path , then { @ link # acceptActionPath ( javax . servlet . http . HttpServletRequest , String ) } to
 * check if path is accepted for processing . */
@ Override public void doFilter ( final ServletRequest servletRequest , final ServletResponse servletResponse , final FilterChain filterChain ) throws IOException , ServletException { } }

implementation:
HttpServletRequest request = ( HttpServletRequest ) servletRequest ; HttpServletResponse response = ( HttpServletResponse ) servletResponse ; String actionPath = DispatcherUtil . getServletPath ( request ) ; if ( processActionPath ( request , response , actionPath ) ) { return ; } if ( ! acceptActionPath ( request , actionPath ) ) { filterChain . doFilter ( servletRequest , servletResponse ) ; return ; } BufferResponseWrapper wrapper = new BufferResponseWrapper ( response ) ; filterChain . doFilter ( servletRequest , wrapper ) ; // reset servlet response content length AFTER the chain , since
// servlet container may set it and we are changing the content .
servletResponse . setContentLength ( - 1 ) ; char [ ] content = wrapper . getBufferContentAsChars ( ) ; if ( ( content != null ) && ( content . length != 0 ) ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "Lagarto is about to parse: " + actionPath ) ; } try { content = parse ( content , request ) ; } catch ( Exception ex ) { log . error ( "Error parsing" , ex ) ; throw new ServletException ( ex ) ; } wrapper . writeContentToResponse ( content ) ; }


signature:
public class LagartoServletFilter { /** * Accepts action path for further parsing . By default , only < code > * . htm ( l ) < / code >
 * requests are passed through and those without any extension . */
protected boolean acceptActionPath ( final HttpServletRequest request , final String actionPath ) { } }

implementation: String extension = FileNameUtil . getExtension ( actionPath ) ; if ( extension . length ( ) == 0 ) { return true ; } if ( extension . equals ( "html" ) || extension . equals ( "htm" ) ) { return true ; } return false ;


signature:
public class ChainActionResult { /** * Sets the { @ link jodd . madvoc . ActionRequest # setNextActionPath ( String ) next action request } for the chain . */
@ Override public void render ( final ActionRequest actionRequest , final Object resultValue ) { } }

implementation: final Chain chainResult ; if ( resultValue == null ) { chainResult = Chain . to ( StringPool . EMPTY ) ; } else { if ( resultValue instanceof String ) { chainResult = Chain . to ( ( String ) resultValue ) ; } else { chainResult = ( Chain ) resultValue ; } } final String resultBasePath = actionRequest . getActionRuntime ( ) . getResultBasePath ( ) ; final String resultPath = resultMapper . resolveResultPathString ( resultBasePath , chainResult . path ( ) ) ; actionRequest . setNextActionPath ( resultPath ) ;


signature:
public class ServletConfigInterceptor { /** * { @ inheritDoc } */
@ Override public Object intercept ( final ActionRequest actionRequest ) throws Exception { } }

implementation:
HttpServletRequest servletRequest = actionRequest . getHttpServletRequest ( ) ; // detect multipart request
if ( ServletUtil . isMultipartRequest ( servletRequest ) ) { servletRequest = new MultipartRequestWrapper ( servletRequest , fileUploader . get ( ) , madvocEncoding . getEncoding ( ) ) ; actionRequest . bind ( servletRequest ) ; } // do it
inject ( actionRequest ) ; final Object result = actionRequest . invoke ( ) ; outject ( actionRequest ) ; return result ;


signature:
public class ServletConfigInterceptor { /** * Performs injection . */
protected void inject ( final ActionRequest actionRequest ) { } }

implementation: final Targets targets = actionRequest . getTargets ( ) ; final ServletContext servletContext = actionRequest . getHttpServletRequest ( ) . getServletContext ( ) ; scopeResolver . forEachScope ( madvocScope -> madvocScope . inject ( servletContext , targets ) ) ; scopeResolver . forEachScope ( madvocScope -> madvocScope . inject ( actionRequest , targets ) ) ;


signature:
public class ServletConfigInterceptor { /** * Performs outjection . */
protected void outject ( final ActionRequest actionRequest ) { } }

implementation: final Targets targets = actionRequest . getTargets ( ) ; scopeResolver . forEachScope ( madvocScope -> madvocScope . outject ( actionRequest , targets ) ) ;


signature:
public class Sockets { /** * Creates a socket . */
public static Socket connect ( final String hostname , final int port ) throws IOException { } }

implementation: final Socket socket = new Socket ( ) ; socket . connect ( new InetSocketAddress ( hostname , port ) ) ; return socket ;


signature:
public class Sockets { /** * Creates a socket with a timeout . */
public static Socket connect ( final String hostname , final int port , final int connectionTimeout ) throws IOException { } }

implementation: final Socket socket = new Socket ( ) ; if ( connectionTimeout <= 0 ) { socket . connect ( new InetSocketAddress ( hostname , port ) ) ; } else { socket . connect ( new InetSocketAddress ( hostname , port ) , connectionTimeout ) ; } return socket ;


signature:
public class DefaultClassLoaderStrategy { /** * Prepares classname for loading , respecting the arrays .
 * Returns < code > null < / code > if class name is not an array . */
public static String prepareArrayClassnameForLoading ( String className ) { } }

implementation:
int bracketCount = StringUtil . count ( className , '[' ) ; if ( bracketCount == 0 ) { // not an array
return null ; } String brackets = StringUtil . repeat ( '[' , bracketCount ) ; int bracketIndex = className . indexOf ( '[' ) ; className = className . substring ( 0 , bracketIndex ) ; int primitiveNdx = getPrimitiveClassNameIndex ( className ) ; if ( primitiveNdx >= 0 ) { className = String . valueOf ( PRIMITIVE_BYTECODE_NAME [ primitiveNdx ] ) ; return brackets + className ; } else { return brackets + 'L' + className + ';' ; }


signature:
public class DefaultClassLoaderStrategy { /** * Detects if provided class name is a primitive type .
 * Returns > = 0 number if so . */
private static int getPrimitiveClassNameIndex ( final String className ) { } }

implementation: int dotIndex = className . indexOf ( '.' ) ; if ( dotIndex != - 1 ) { return - 1 ; } return Arrays . binarySearch ( PRIMITIVE_TYPE_NAMES , className ) ;


signature:
public class DefaultClassLoaderStrategy { /** * Loads class by name . */
@ Override public Class loadClass ( final String className , final ClassLoader classLoader ) throws ClassNotFoundException { } }

implementation:
String arrayClassName = prepareArrayClassnameForLoading ( className ) ; if ( ( className . indexOf ( '.' ) == - 1 ) && ( arrayClassName == null ) ) { // maybe a primitive
int primitiveNdx = getPrimitiveClassNameIndex ( className ) ; if ( primitiveNdx >= 0 ) { return PRIMITIVE_TYPES [ primitiveNdx ] ; } } // try # 1 - using provided class loader
if ( classLoader != null ) { Class klass = loadClass ( className , arrayClassName , classLoader ) ; if ( klass != null ) { return klass ; } } // try # 2 - using thread class loader
ClassLoader currentThreadClassLoader = Thread . currentThread ( ) . getContextClassLoader ( ) ; if ( ( currentThreadClassLoader != null ) && ( currentThreadClassLoader != classLoader ) ) { Class klass = loadClass ( className , arrayClassName , currentThreadClassLoader ) ; if ( klass != null ) { return klass ; } } // try # 3 - using caller classloader , similar as Class . forName ( )
// Class callerClass = ReflectUtil . getCallerClass ( 2 ) ;
Class callerClass = ClassUtil . getCallerClass ( ) ; ClassLoader callerClassLoader = callerClass . getClassLoader ( ) ; if ( ( callerClassLoader != classLoader ) && ( callerClassLoader != currentThreadClassLoader ) ) { Class klass = loadClass ( className , arrayClassName , callerClassLoader ) ; if ( klass != null ) { return klass ; } } // try # 4 - everything failed , try alternative array loader
if ( arrayClassName != null ) { try { return loadArrayClassByComponentType ( className , classLoader ) ; } catch ( ClassNotFoundException ignore ) { } } throw new ClassNotFoundException ( "Class not found: " + className ) ;


signature:
public class DefaultClassLoaderStrategy { /** * Loads a class using provided class loader .
 * If class is an array , it will be first loaded using the < code > Class . forName < / code > !
 * We must use this since for JDK { @ literal > = } 6 arrays will be not loaded using classloader ,
 * but only with < code > forName < / code > method . However , array loading strategy can be
 * { @ link # setLoadArrayClassByComponentTypes ( boolean ) changed } . */
protected Class loadClass ( final String className , final String arrayClassName , final ClassLoader classLoader ) { } }

implementation: if ( arrayClassName != null ) { try { if ( loadArrayClassByComponentTypes ) { return loadArrayClassByComponentType ( className , classLoader ) ; } else { return Class . forName ( arrayClassName , true , classLoader ) ; } } catch ( ClassNotFoundException ignore ) { } } try { return classLoader . loadClass ( className ) ; } catch ( ClassNotFoundException ignore ) { } return null ;


signature:
public class DefaultClassLoaderStrategy { /** * Loads array class using component type . */
protected Class loadArrayClassByComponentType ( final String className , final ClassLoader classLoader ) throws ClassNotFoundException { } }

implementation: int ndx = className . indexOf ( '[' ) ; int multi = StringUtil . count ( className , '[' ) ; String componentTypeName = className . substring ( 0 , ndx ) ; Class componentType = loadClass ( componentTypeName , classLoader ) ; if ( multi == 1 ) { return Array . newInstance ( componentType , 0 ) . getClass ( ) ; } int [ ] multiSizes ; if ( multi == 2 ) { multiSizes = new int [ ] { 0 , 0 } ; } else if ( multi == 3 ) { multiSizes = new int [ ] { 0 , 0 , 0 } ; } else { multiSizes = ( int [ ] ) Array . newInstance ( int . class , multi ) ; } return Array . newInstance ( componentType , multiSizes ) . getClass ( ) ;


signature:
public class SingletonScope { /** * Iterate all beans and invokes registered destroy methods . */
@ Override public void shutdown ( ) { } }

implementation: for ( final BeanData beanData : instances . values ( ) ) { beanData . callDestroyMethods ( ) ; } instances . clear ( ) ;


signature:
public class BinarySearch { /** * Creates binary search wrapper over an array . */
public static < T extends Comparable > BinarySearch < T > forArray ( final T [ ] array ) { } }

implementation: return new BinarySearch < T > ( ) { @ Override @ SuppressWarnings ( { "unchecked" } ) protected int compare ( final int index , final T element ) { return array [ index ] . compareTo ( element ) ; } @ Override protected int getLastIndex ( ) { return array . length - 1 ; } } ;


signature:
public class BinarySearch { /** * Creates binary search wrapper over an array with given comparator . */
public static < T > BinarySearch < T > forArray ( final T [ ] array , final Comparator < T > comparator ) { } }

implementation: return new BinarySearch < T > ( ) { @ Override @ SuppressWarnings ( { "unchecked" } ) protected int compare ( final int index , final T element ) { return comparator . compare ( array [ index ] , element ) ; } @ Override protected int getLastIndex ( ) { return array . length - 1 ; } } ;


signature:
public class BinarySearch { /** * Finds index of given element in inclusive index range . Returns negative
 * value if element is not found . */
public int find ( final E element , int low , int high ) { } }

implementation:
while ( low <= high ) { int mid = ( low + high ) >>> 1 ; int delta = compare ( mid , element ) ; if ( delta < 0 ) { low = mid + 1 ; } else if ( delta > 0 ) { high = mid - 1 ; } else { return mid ; } } // not found
return - ( low + 1 ) ;


signature:
public class BeanVisitorImplBase { /** * Defines excluded property names . */
public T exclude ( final String ... excludes ) { } }

implementation: for ( String ex : excludes ) { rules . exclude ( ex ) ; } return _this ( ) ;


signature:
public class BeanVisitorImplBase { /** * Defines included property names . */
public T include ( final String ... includes ) { } }

implementation: for ( String in : includes ) { rules . include ( in ) ; } return _this ( ) ;


signature:
public class BeanVisitorImplBase { /** * Defines included property names as public properties
 * of given template class . Sets to black list mode . */
public T includeAs ( final Class template ) { } }

implementation: blacklist = false ; String [ ] properties = getAllBeanPropertyNames ( template , false ) ; include ( properties ) ; return _this ( ) ;


signature:
public class ParsedTag { /** * Starts the tag with the index of first ' < ' .
 * Resets all tag data . */
public void start ( final int startIndex ) { } }

implementation: this . tagStartIndex = startIndex ; this . name = null ; this . idNdx = - 1 ; this . attributesCount = 0 ; this . tagLength = 0 ; this . modified = false ; this . type = TagType . START ; this . rawTag = false ;


signature:
public class ParsedTag { /** * - - - - - match */
@ Override public boolean nameEquals ( final CharSequence charSequence ) { } }

implementation: return caseSensitive ? CharSequenceUtil . equals ( name , charSequence ) : CharSequenceUtil . equalsIgnoreCase ( name , charSequence ) ;


signature:
public class ParsedTag { /** * - - - - - util */
private void ensureLength ( ) { } }

implementation: if ( attributesCount + 1 >= attrNames . length ) { attrNames = ArraysUtil . resize ( attrNames , attributesCount * 2 ) ; attrValues = ArraysUtil . resize ( attrValues , attributesCount * 2 ) ; }


signature:
public class ParsedTag { /** * - - - - - output */
private void appendTo ( final Appendable out ) { } }

implementation: try { out . append ( type . getStartString ( ) ) ; out . append ( name ) ; if ( attributesCount > 0 ) { for ( int i = 0 ; i < attributesCount ; i ++ ) { out . append ( ' ' ) ; out . append ( attrNames [ i ] ) ; final CharSequence value = attrValues [ i ] ; if ( value != null ) { out . append ( '=' ) . append ( '"' ) ; out . append ( HtmlEncoder . attributeDoubleQuoted ( value ) ) ; out . append ( '"' ) ; } } } out . append ( type . getEndString ( ) ) ; } catch ( IOException ioex ) { throw new LagartoException ( ioex ) ; }


signature:
public class MadvocContainer { /** * Registers component using its { @ link # resolveBaseComponentName ( Class ) base name } .
 * Previously defined component will be removed .
 * @ see # registerComponentInstance ( Object ) */
public void registerComponent ( final Class component ) { } }

implementation: String name = resolveBaseComponentName ( component ) ; registerComponent ( name , component ) ;


signature:
public class MadvocContainer { /** * Registers Madvoc component with given name . */
public < T > void registerComponent ( final String name , final Class < T > component , final Consumer < T > consumer ) { } }

implementation: log . debug ( ( ) -> "Madvoc WebApp component: [" + name + "] --> " + component . getName ( ) ) ; madpc . removeBean ( name ) ; madpc . registerPetiteBean ( component , name , null , null , false , consumer ) ;


signature:
public class MadvocContainer { /** * Registers component instance using its { @ link # resolveBaseComponentName ( Class ) base name } .
 * Previously defined component will be removed .
 * @ see # registerComponentInstance ( String , Object ) */
public void registerComponentInstance ( final Object componentInstance ) { } }

implementation: Class component = componentInstance . getClass ( ) ; String name = resolveBaseComponentName ( component ) ; registerComponentInstance ( name , componentInstance ) ;


signature:
public class MadvocContainer { /** * Registers component instance and wires it with internal container .
 * Warning : in this moment we can not guarantee that all other components
 * are registered , replaced or configuration is update ; therefore DO NOT
 * USE injection , unless you are absolutely sure it works . */
public void registerComponentInstance ( final String name , final Object componentInstance ) { } }

implementation: log . debug ( ( ) -> "Madvoc WebApp component: [" + name + "] --> " + componentInstance . getClass ( ) . getName ( ) ) ; madpc . removeBean ( name ) ; madpc . addBean ( name , componentInstance ) ;


signature:
public class MadvocContainer { /** * Fires the Madvoc event .
 * Warning : since event handlers may register more handlers , we
 * must collect first the list of components that matches the type
 * and then to execute . */
public void fireEvent ( final Class listenerType ) { } }

implementation:
final Set < String > existing = new HashSet < > ( ) ; while ( true ) { MutableInteger newCount = MutableInteger . of ( 0 ) ; madpc . forEachBeanType ( listenerType , name -> { if ( existing . add ( name ) ) { // name not found , fire !
newCount . value ++ ; Object listener = lookupComponent ( name ) ; if ( listener != null ) { MadvocComponentLifecycle . invoke ( listener , listenerType ) ; } } } ) ; if ( newCount . value == 0 ) { break ; } }


signature:
public class MadvocContainer { /** * Returns registered component or { @ code null } if component is not registered . */
@ SuppressWarnings ( { } }

implementation: "unchecked" } ) public < T > T lookupComponent ( final Class < T > component ) { String name = resolveBaseComponentName ( component ) ; return ( T ) madpc . getBean ( name ) ;


signature:
public class MadvocContainer { /** * Returns existing component . Throws an exception if component is not registered . */
public < T > T requestComponent ( final Class < T > component ) { } }

implementation: T existingComponent = lookupComponent ( component ) ; if ( existingComponent == null ) { throw new MadvocException ( "Madvoc component not found: " + component . getName ( ) ) ; } return existingComponent ;


signature:
public class MadvocContainer { /** * Returns existing component . Throws an exception if component is not registered . */
public < T > T requestComponent ( final String componentName ) { } }

implementation: T existingComponent = ( T ) lookupComponent ( componentName ) ; if ( existingComponent == null ) { throw new MadvocException ( "Madvoc component not found: " + componentName ) ; } return existingComponent ;


signature:
public class MadvocContainer { /** * Resolves the name of the last base non - abstract subclass for provided component .
 * It iterates all subclasses up to the < code > Object < / cde > and declares the last
 * non - abstract class as base component . Component name will be resolved from the
 * founded base component . */
private String resolveBaseComponentName ( Class component ) { } }

implementation: Class lastComponent = component ; while ( true ) { Class superClass = component . getSuperclass ( ) ; if ( superClass . equals ( Object . class ) ) { break ; } component = superClass ; if ( ! Modifier . isAbstract ( component . getModifiers ( ) ) ) { lastComponent = component ; } } return madpc . resolveBeanName ( lastComponent ) ;


signature:
public class DbOomQuery { /** * Prepares the query after initialization . Besides default work , it checks if sql generator
 * is used , and if so , generator hints and query parameters will be used for this query .
 * Note regarding hints : since hints can be added manually , generators hints will be ignored
 * if there exists some manually set hints . */
@ Override protected void prepareQuery ( ) { } }

implementation:
super . prepareQuery ( ) ; if ( sqlgen == null ) { return ; } if ( hints == null ) { String [ ] joinHints = sqlgen . getJoinHints ( ) ; if ( joinHints != null ) { withHints ( joinHints ) ; } } // insert parameters
Map < String , ParameterValue > parameters = sqlgen . getQueryParameters ( ) ; if ( parameters == null ) { return ; } for ( Map . Entry < String , ParameterValue > entry : parameters . entrySet ( ) ) { String paramName = entry . getKey ( ) ; ParameterValue param = entry . getValue ( ) ; DbEntityColumnDescriptor dec = param . getColumnDescriptor ( ) ; if ( dec == null ) { setObject ( paramName , param . getValue ( ) ) ; } else { resolveColumnDbSqlType ( connection , dec ) ; setObject ( paramName , param . getValue ( ) , dec . getSqlTypeClass ( ) , dec . getDbSqlType ( ) ) ; } }


signature:
public class DbOomQuery { /** * Resolves column db sql type and populates it in column descriptor if missing . */
protected void resolveColumnDbSqlType ( final Connection connection , final DbEntityColumnDescriptor dec ) { } }

implementation: if ( dec . dbSqlType != SqlType . DB_SQLTYPE_UNKNOWN ) { return ; } ResultSet rs = null ; DbEntityDescriptor ded = dec . getDbEntityDescriptor ( ) ; try { DatabaseMetaData dmd = connection . getMetaData ( ) ; rs = dmd . getColumns ( null , ded . getSchemaName ( ) , ded . getTableName ( ) , dec . getColumnName ( ) ) ; if ( rs . next ( ) ) { dec . dbSqlType = rs . getInt ( "DATA_TYPE" ) ; } else { dec . dbSqlType = SqlType . DB_SQLTYPE_NOT_AVAILABLE ; if ( log . isWarnEnabled ( ) ) { log . warn ( "Column SQL type not available: " + ded . toString ( ) + '.' + dec . getColumnName ( ) ) ; } } } catch ( SQLException sex ) { dec . dbSqlType = SqlType . DB_SQLTYPE_NOT_AVAILABLE ; if ( log . isWarnEnabled ( ) ) { log . warn ( "Column SQL type not resolved: " + ded . toString ( ) + '.' + dec . getColumnName ( ) , sex ) ; } } finally { DbUtil . close ( rs ) ; }


signature:
public class DbOomQuery { /** * Pre - process SQL before using it . If string starts with a non - ascii char
 * or it has no spaces , it will be loaded from the query map . */
protected String preprocessSql ( String sqlString ) { } }

implementation:
// detects callable statement
if ( sqlString . charAt ( 0 ) == '{' ) { return sqlString ; } // quickly detect if SQL string is a key
if ( ! CharUtil . isAlpha ( sqlString . charAt ( 0 ) ) ) { sqlString = sqlString . substring ( 1 ) ; } else if ( sqlString . indexOf ( ' ' ) != - 1 ) { return sqlString ; } final String sqlFromMap = dbOom . queryMap ( ) . getQuery ( sqlString ) ; if ( sqlFromMap != null ) { sqlString = sqlFromMap . trim ( ) ; } return sqlString ;


signature:
public class DbOomQuery { /** * Prepares a row ( array of rows mapped object ) using hints .
 * Returns either single object or objects array . */
protected Object resolveRowResults ( Object [ ] row ) { } }

implementation: if ( hintResolver == null ) { hintResolver = new JoinHintResolver ( ) ; } row = hintResolver . join ( row , hints ) ; return row . length == 1 ? row [ 0 ] : row ;


signature:
public class DbOomQuery { /** * Factory for result sets mapper . */
protected ResultSetMapper createResultSetMapper ( final ResultSet resultSet ) { } }

implementation: final Map < String , ColumnData > columnAliases = sqlgen != null ? sqlgen . getColumnData ( ) : null ; return new DefaultResultSetMapper ( dbOom , resultSet , columnAliases , cacheEntities , this ) ;


signature:
public class DbOomQuery { /** * Finds generated key column of given type . */
public < T > T findGeneratedKey ( final Class < T > type ) { } }

implementation: return find ( new Class [ ] { type } , false , getGeneratedColumns ( ) ) ;


signature:
public class DbOomQuery { /** * Populates entity with generated column values from executed query . */
public void populateGeneratedKeys ( final Object entity ) { } }

implementation:
final String [ ] generatedColumns = getGeneratedColumnNames ( ) ; if ( generatedColumns == null ) { return ; } DbEntityDescriptor ded = dbOom . entityManager ( ) . lookupType ( entity . getClass ( ) ) ; // prepare key types
Class [ ] keyTypes = new Class [ generatedColumns . length ] ; String [ ] properties = new String [ generatedColumns . length ] ; for ( int i = 0 ; i < generatedColumns . length ; i ++ ) { String column = generatedColumns [ i ] ; DbEntityColumnDescriptor decd = ded . findByColumnName ( column ) ; if ( decd != null ) { keyTypes [ i ] = decd . getPropertyType ( ) ; properties [ i ] = decd . getPropertyName ( ) ; } } final Object keyValues = findGeneratedColumns ( keyTypes ) ; if ( ! keyValues . getClass ( ) . isArray ( ) ) { BeanUtil . declared . setProperty ( entity , properties [ 0 ] , keyValues ) ; } else { for ( int i = 0 ; i < properties . length ; i ++ ) { BeanUtil . declared . setProperty ( entity , properties [ i ] , ( ( Object [ ] ) keyValues ) [ i ] ) ; } }


signature:
public class PetiteInterceptorManager { /** * Acquires interceptor from Petite container . */
@ Override protected < R extends ActionInterceptor > R createWrapper ( final Class < R > wrapperClass ) { } }

implementation: return petiteContainer . createBean ( wrapperClass ) ;


signature:
public class DbQuery { /** * Clears the current parameter values immediately .
 * In general , parameter values remain in force for repeated use of a
 * statement . Setting a parameter value automatically clears its
 * previous value . However , in some cases it is useful to immediately
 * release the resources used by the current parameter values ; this can
 * be done by calling the method < code > clearParameters < / code > . */
public Q clearParameters ( ) { } }

implementation: init ( ) ; if ( preparedStatement == null ) { return _this ( ) ; } try { preparedStatement . clearParameters ( ) ; } catch ( SQLException sex ) { throw new DbSqlException ( sex ) ; } return _this ( ) ;


signature:
public class DbQuery { /** * - - - - - null */
public Q setNull ( final int index , final int type ) { } }

implementation: initPrepared ( ) ; try { preparedStatement . setNull ( index , type ) ; } catch ( SQLException sex ) { throw new DbSqlException ( this , "Failed to set null to parameter: " + index , sex ) ; } return _this ( ) ;


signature:
public class DbQuery { /** * - - - - - int */
public Q setInteger ( final int index , final int value ) { } }

implementation: initPrepared ( ) ; try { preparedStatement . setInt ( index , value ) ; } catch ( SQLException sex ) { throwSetParamError ( index , sex ) ; } return _this ( ) ;


signature:
public class DbQuery { /** * - - - - - Integer */
public Q setInteger ( final int index , final Number value ) { } }

implementation: if ( value == null ) { setNull ( index , Types . INTEGER ) ; } else { setInteger ( index , value . intValue ( ) ) ; } return _this ( ) ;


signature:
public class DbQuery { /** * - - - - - Boolean */
public Q setBoolean ( final int index , final Boolean value ) { } }

implementation: if ( value == null ) { setNull ( index , Types . BOOLEAN ) ; } else { setBoolean ( index , value . booleanValue ( ) ) ; } return _this ( ) ;


signature:
public class DbQuery { /** * - - - - - Long */
public Q setLong ( final int index , final Number value ) { } }

implementation: if ( value == null ) { setNull ( index , Types . BIGINT ) ; } else { setLong ( index , value . longValue ( ) ) ; } return _this ( ) ;


signature:
public class DbQuery { /** * - - - - - Byte */
public Q setByte ( final int index , final Number value ) { } }

implementation: if ( value == null ) { setNull ( index , Types . SMALLINT ) ; } else { setByte ( index , value . byteValue ( ) ) ; } return _this ( ) ;


signature:
public class DbQuery { /** * - - - - - double */
public Q setDouble ( final int index , final double value ) { } }

implementation: initPrepared ( ) ; try { preparedStatement . setDouble ( index , value ) ; } catch ( SQLException sex ) { throwSetParamError ( index , sex ) ; } return _this ( ) ;


signature:
public class DbQuery { /** * - - - - - Double */
public Q setDouble ( final int index , final Number value ) { } }

implementation: if ( value == null ) { setNull ( index , Types . DOUBLE ) ; } else { setDouble ( index , value . doubleValue ( ) ) ; } return _this ( ) ;


signature:
public class DbQuery { /** * - - - - - Float */
public Q setFloat ( final int index , final Number value ) { } }

implementation: if ( value == null ) { setNull ( index , Types . FLOAT ) ; } else { setFloat ( index , value . floatValue ( ) ) ; } return _this ( ) ;


signature:
public class DbQuery { /** * - - - - - Short */
public Q setShort ( final int index , final Number value ) { } }

implementation: if ( value == null ) { setNull ( index , Types . SMALLINT ) ; } else { setShort ( index , value . shortValue ( ) ) ; } return _this ( ) ;


signature:
public class DbQuery { /** * - - - - - string */
public Q setString ( final int index , final String value ) { } }

implementation: initPrepared ( ) ; try { preparedStatement . setString ( index , value ) ; } catch ( SQLException sex ) { throwSetParamError ( index , sex ) ; } return _this ( ) ;


signature:
public class DbQuery { /** * - - - - - date */
public Q setDate ( final int index , final Date value ) { } }

implementation: initPrepared ( ) ; try { preparedStatement . setDate ( index , value ) ; } catch ( SQLException sex ) { throwSetParamError ( index , sex ) ; } return _this ( ) ;


signature:
public class DbQuery { /** * - - - - - time */
public Q setTime ( final int index , final Time value ) { } }

implementation: initPrepared ( ) ; try { preparedStatement . setTime ( index , value ) ; } catch ( SQLException sex ) { throwSetParamError ( index , sex ) ; } return _this ( ) ;


signature:
public class DbQuery { /** * - - - - - timestamp */
public Q setTimestamp ( final int index , final Timestamp value ) { } }

implementation: initPrepared ( ) ; try { preparedStatement . setTimestamp ( index , value ) ; } catch ( SQLException sex ) { throwSetParamError ( index , sex ) ; } return _this ( ) ;


signature:
public class DbQuery { /** * - - - - - big decimal */
public Q setBigDecimal ( final int index , final BigDecimal value ) { } }

implementation: initPrepared ( ) ; try { preparedStatement . setBigDecimal ( index , value ) ; } catch ( SQLException sex ) { throwSetParamError ( index , sex ) ; } return _this ( ) ;


signature:
public class DbQuery { /** * - - - - - big integer */
public Q setBigInteger ( final int index , final BigInteger value ) { } }

implementation: if ( value == null ) { setNull ( index , Types . NUMERIC ) ; } else { setLong ( index , value . longValue ( ) ) ; } return _this ( ) ;


signature:
public class DbQuery { /** * - - - - - URL */
public Q setURL ( final int index , final URL value ) { } }

implementation: initPrepared ( ) ; try { preparedStatement . setURL ( index , value ) ; } catch ( SQLException sex ) { throwSetParamError ( index , sex ) ; } return _this ( ) ;


signature:
public class DbQuery { /** * - - - - - BLOB */
public Q setBlob ( final int index , final Blob value ) { } }

implementation: initPrepared ( ) ; try { preparedStatement . setBlob ( index , value ) ; } catch ( SQLException sex ) { throwSetParamError ( index , sex ) ; } return _this ( ) ;


signature:
public class DbQuery { /** * - - - - - CLOB */
public Q setClob ( final int index , final Clob value ) { } }

implementation: initPrepared ( ) ; try { preparedStatement . setClob ( index , value ) ; } catch ( SQLException sex ) { throwSetParamError ( index , sex ) ; } return _this ( ) ;


signature:
public class DbQuery { /** * - - - - - Array */
public Q setArray ( final int index , final Array value ) { } }

implementation: initPrepared ( ) ; try { preparedStatement . setArray ( index , value ) ; } catch ( SQLException sex ) { throwSetParamError ( index , sex ) ; } return _this ( ) ;


signature:
public class DbQuery { /** * - - - - - Ref */
public Q setRef ( final int index , final Ref value ) { } }

implementation: initPrepared ( ) ; try { preparedStatement . setRef ( index , value ) ; } catch ( SQLException sex ) { throwSetParamError ( index , sex ) ; } return _this ( ) ;


signature:
public class DbQuery { /** * - - - - - ascii streams */
public Q setAsciiStream ( final int index , final InputStream stream ) { } }

implementation: initPrepared ( ) ; try { preparedStatement . setAsciiStream ( index , stream , stream . available ( ) ) ; } catch ( IOException | SQLException ioex ) { throwSetParamError ( index , ioex ) ; } return _this ( ) ;


signature:
public class DbQuery { /** * Sets bean parameters from bean . Non - existing bean properties are ignored . */
public Q setBean ( final String beanName , final Object bean ) { } }

implementation: if ( bean == null ) { return _this ( ) ; } init ( ) ; final String beanNamePrefix = beanName + '.' ; query . forEachNamedParameter ( p -> { final String paramName = p . name ; if ( paramName . startsWith ( beanNamePrefix ) ) { final String propertyName = paramName . substring ( beanNamePrefix . length ( ) ) ; if ( BeanUtil . declared . hasRootProperty ( bean , propertyName ) ) { final Object value = BeanUtil . declared . getProperty ( bean , propertyName ) ; setObject ( paramName , value ) ; } } } ) ; return _this ( ) ;


signature:
public class DbQuery { /** * Sets properties from the map . */
public Q setMap ( final Map parameters ) { } }

implementation: if ( parameters == null ) { return _this ( ) ; } init ( ) ; query . forEachNamedParameter ( p -> { final String paramName = p . name ; setObject ( paramName , parameters . get ( paramName ) ) ; } ) ; return _this ( ) ;


signature:
public class DbQuery { /** * Sets the value of the designated parameter with the given object .
 * This method is like the method < code > setObject < / code >
 * above , except that it assumes a scale of zero . */
public Q setObject ( final int index , final Object object , final int targetSqlType ) { } }

implementation: initPrepared ( ) ; try { preparedStatement . setObject ( index , object , targetSqlType ) ; } catch ( SQLException sex ) { throwSetParamError ( index , sex ) ; } return _this ( ) ;


signature:
public class DbQuery { /** * Sets the value of the designated parameter with the given object .
 * This method is like the method < code > setObject < / code >
 * above , except that it assumes a scale of zero . */
public Q setObject ( final String param , final Object object , final int targetSqlType ) { } }

implementation: initPrepared ( ) ; final int [ ] positions = query . getNamedParameterIndices ( param ) ; try { for ( final int position : positions ) { preparedStatement . setObject ( position , object , targetSqlType ) ; } } catch ( SQLException sex ) { throwSetParamError ( param , sex ) ; } return _this ( ) ;


signature:
public class DbQuery { /** * Sets the value of the designated parameter with the given object .
 * This method is like the method < code > setObject < / code >
 * above , except that it assumes a scale of zero . */
void setObject ( final int index , final Object object , final int targetSqlType , final int scale ) { } }

implementation: initPrepared ( ) ; try { preparedStatement . setObject ( index , object , targetSqlType , scale ) ; } catch ( SQLException sex ) { throwSetParamError ( index , sex ) ; }


signature:
public class DbQuery { /** * Sets object parameter in an advanced way .
 * First , it checks if object is < code > null < / code > and invokes < code > setNull < / code > if so .
 * If object is not < code > null < / code > , it tries to resolve { @ link SqlType sql type } ( by looking up
 * or using provided class ) and use it for setting data .
 * If sql type is not found , default < code > setObject < / code > is invoked . */
@ SuppressWarnings ( { } }

implementation: "unchecked" } ) public Q setObject ( final int index , final Object value , final Class < ? extends SqlType > sqlTypeClass , final int dbSqlType ) { init ( ) ; if ( value == null ) { setNull ( index , Types . NULL ) ; return _this ( ) ; } final SqlType sqlType ; if ( sqlTypeClass != null ) { sqlType = SqlTypeManager . get ( ) . lookupSqlType ( sqlTypeClass ) ; } else { sqlType = SqlTypeManager . get ( ) . lookup ( value . getClass ( ) ) ; } try { if ( ( sqlType != null ) && ( dbSqlType != SqlType . DB_SQLTYPE_NOT_AVAILABLE ) ) { sqlType . storeValue ( preparedStatement , index , value , dbSqlType ) ; } else { DbUtil . setPreparedStatementObject ( preparedStatement , index , value , dbSqlType ) ; } } catch ( SQLException sex ) { throwSetParamError ( index , sex ) ; } return _this ( ) ;


signature:
public class DbQuery { /** * Sets an array of objects parameters in given order . */
public Q setObjects ( final Object ... objects ) { } }

implementation: int index = 1 ; for ( final Object object : objects ) { setObject ( index ++ , object ) ; } return _this ( ) ;


signature:
public class DbQuery { /** * Sets sql parameters from two arrays : names and values . */
public Q setObjects ( final String [ ] names , final Object [ ] values ) { } }

implementation: init ( ) ; if ( names . length != values . length ) { throw new DbSqlException ( this , "Different number of parameter names and values" ) ; } for ( int i = 0 ; i < names . length ; i ++ ) { setObject ( names [ i ] , values [ i ] ) ; } return _this ( ) ;


signature:
public class DbQuery { /** * Sets batch parameters with given array of values . */
public Q setBatch ( final String name , final int [ ] array , int startingIndex ) { } }

implementation: init ( ) ; final int batchSize = query . getBatchParameterSize ( name ) ; for ( int i = 1 ; i <= batchSize ; i ++ ) { final String paramName = name + '.' + i ; if ( startingIndex < array . length ) { setInteger ( paramName , array [ startingIndex ] ) ; } else { setNull ( paramName , Types . INTEGER ) ; } startingIndex ++ ; } return _this ( ) ;


signature:
public class DbQuery { /** * Sets batch parameters with given array of values . */
public Q setBatch ( final String name , final Object [ ] array , int startingIndex ) { } }

implementation: init ( ) ; final int batchSize = query . getBatchParameterSize ( name ) ; for ( int i = 1 ; i <= batchSize ; i ++ ) { final String paramName = name + '.' + i ; if ( startingIndex < array . length ) { setObject ( paramName , array [ startingIndex ] ) ; } else { setObject ( paramName , null ) ; } startingIndex ++ ; } return _this ( ) ;


signature:
public class SqlChunk { /** * Appends chunk to previous one and maintains the double - linked list of the previous chunk .
 * Current surrounding connections of this chunk will be cut - off . */
public void insertChunkAfter ( final SqlChunk previous ) { } }

implementation: SqlChunk next = previous . nextChunk ; previous . nextChunk = this ; this . previousChunk = previous ; if ( next != null ) { next . previousChunk = this ; this . nextChunk = next ; }


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

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


signature:
public class SqlChunk { /** * Lookups for entity name and throws an exception if entity type is invalid . */
protected DbEntityDescriptor lookupType ( final Class entity ) { } }

implementation: final DbEntityDescriptor ded = dbEntityManager . lookupType ( entity ) ; if ( ded == null ) { throw new DbSqlBuilderException ( "Invalid or not-persistent entity: " + entity . getName ( ) ) ; } return ded ;


signature:
public class SqlChunk { /** * Finds a table that contains given column . */
protected DbEntityDescriptor findColumnRef ( final String columnRef ) { } }

implementation: DbEntityDescriptor ded = templateData . findTableDescriptorByColumnRef ( columnRef ) ; if ( ded == null ) { throw new DbSqlBuilderException ( "Invalid column reference: [" + columnRef + "]" ) ; } return ded ;


signature:
public class SqlChunk { /** * Resolves table name or alias that will be used in the query . */
protected String resolveTable ( final String tableRef , final DbEntityDescriptor ded ) { } }

implementation: String tableAlias = templateData . getTableAlias ( tableRef ) ; if ( tableAlias != null ) { return tableAlias ; } return ded . getTableNameForQuery ( ) ;


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

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


signature:
public class SqlChunk { /** * Resolves object to a class . */
protected static Class resolveClass ( final Object object ) { } }

implementation: Class type = object . getClass ( ) ; return type == Class . class ? ( Class ) object : type ;


signature:
public class SqlChunk { /** * Returns < code > true < / code > if a value is considered empty i . e . not existing . */
protected boolean isEmptyColumnValue ( final DbEntityColumnDescriptor dec , final Object value ) { } }

implementation:
if ( value == null ) { return true ; } // special case for ID column
if ( dec . isId ( ) && value instanceof Number ) { final double d = ( ( Number ) value ) . doubleValue ( ) ; if ( d == 0.0d ) { return true ; } } // special case for primitives
if ( dec . getPropertyType ( ) . isPrimitive ( ) ) { if ( char . class == dec . getPropertyType ( ) ) { final Character c = ( ( Character ) value ) ; if ( '\u0000' == c . charValue ( ) ) { return true ; } } else { final double d = ( ( Number ) value ) . doubleValue ( ) ; if ( d == 0 ) { return true ; } } } // special case for strings
if ( value instanceof CharSequence ) { if ( StringUtil . isBlank ( ( CharSequence ) value ) ) { return true ; } } return false ;


signature:
public class SqlChunk { /** * Appends missing space if the output doesn ' t end with whitespace . */
protected void appendMissingSpace ( final StringBuilder out ) { } }

implementation: int len = out . length ( ) ; if ( len == 0 ) { return ; } len -- ; if ( ! CharUtil . isWhitespace ( out . charAt ( len ) ) ) { out . append ( ' ' ) ; }


signature:
public class EqualToDeclaredFieldConstraint { /** * - - - - - valid */
public boolean isValid ( final ValidationConstraintContext vcc , final Object value ) { } }

implementation: return validate ( vcc . getTarget ( ) , value , fieldName ) ;


signature:
public class ConnectionPoolDataSourceConnectionProvider { /** * - - - - - get / free */
@ Override public Connection getConnection ( ) { } }

implementation: PooledConnection pconn ; try { pconn = cpds . getPooledConnection ( ) ; } catch ( SQLException sex ) { throw new DbSqlException ( "Invalid pooled connection" , sex ) ; } try { return pconn . getConnection ( ) ; } catch ( SQLException sex ) { throw new DbSqlException ( "Invalid pooled connection" , sex ) ; }


signature:
public class MultipartRequestWrapper { /** * Get an enumeration of the parameter names for uploaded files */
public Enumeration < String > getFileParameterNames ( ) { } }

implementation: if ( mreq == null ) { return null ; } return Collections . enumeration ( mreq . getFileParameterNames ( ) ) ;


signature:
public class MultipartRequestWrapper { /** * Get a { @ link FileUpload } array for the given input field name .
 * @ param fieldName input field name
 * @ return a File [ ] object for files associated with the specified input field name */
public FileUpload [ ] getFiles ( final String fieldName ) { } }

implementation: if ( mreq == null ) { return null ; } return mreq . getFiles ( fieldName ) ;


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

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


signature:
public class DispatcherUtil { /** * Include page which path is relative to the current HTTP request . */
public static boolean include ( final ServletRequest request , final ServletResponse response , final String page ) throws IOException , ServletException { } }

implementation: RequestDispatcher dispatcher = request . getRequestDispatcher ( page ) ; if ( dispatcher != null ) { dispatcher . include ( request , response ) ; return true ; } return false ;


signature:
public class DispatcherUtil { /** * Include named resource . */
public static boolean includeNamed ( final HttpServletRequest request , final ServletResponse response , final String resource ) throws IOException , ServletException { } }

implementation: return includeNamed ( request . getServletContext ( ) , request , response , resource ) ;


signature:
public class DispatcherUtil { /** * Include named resource . */
public static boolean includeNamed ( final ServletContext context , final ServletRequest request , final ServletResponse response , final String page ) throws IOException , ServletException { } }

implementation: RequestDispatcher dispatcher = context . getNamedDispatcher ( page ) ; if ( dispatcher != null ) { dispatcher . include ( request , response ) ; return true ; } return false ;


signature:
public class DispatcherUtil { /** * Include page which path relative to the root of the ServletContext . */
public static boolean includeAbsolute ( final HttpServletRequest request , final HttpServletResponse response , final String page ) throws IOException , ServletException { } }

implementation: return includeAbsolute ( request . getServletContext ( ) , request , response , page ) ;


signature:
public class DispatcherUtil { /** * Include page which path relative to the root of the ServletContext . */
public static boolean includeAbsolute ( final ServletContext context , final ServletRequest request , final HttpServletResponse response , final String page ) throws IOException , ServletException { } }

implementation: RequestDispatcher dispatcher = context . getRequestDispatcher ( page ) ; if ( dispatcher != null ) { dispatcher . include ( request , response ) ; return true ; } return false ;


signature:
public class DispatcherUtil { /** * Forward to page path relative to the root of the ServletContext . */
public static boolean forwardAbsolute ( final HttpServletRequest request , final ServletResponse response , final String page ) throws IOException , ServletException { } }

implementation: return forwardAbsolute ( request . getServletContext ( ) , request , response , page ) ;


signature:
public class DispatcherUtil { /** * Forward to page path relative to the root of the ServletContext . */
public static boolean forwardAbsolute ( final ServletContext context , final ServletRequest request , final ServletResponse response , final String resource ) throws IOException , ServletException { } }

implementation: RequestDispatcher dispatcher = context . getRequestDispatcher ( resource ) ; if ( dispatcher != null ) { dispatcher . forward ( request , response ) ; return true ; } return false ;


signature:
public class DispatcherUtil { /** * Performs redirection ( 302 ) to specified url . */
public static void redirect ( final HttpServletRequest request , final HttpServletResponse response , String url ) throws IOException { } }

implementation: if ( url . startsWith ( StringPool . SLASH ) ) { url = ServletUtil . getContextPath ( request ) + url ; } response . sendRedirect ( response . encodeRedirectURL ( url ) ) ;


signature:
public class DispatcherUtil { /** * Performs permanent redirection ( 301 ) to specified url . */
public static void redirectPermanent ( final HttpServletRequest request , final HttpServletResponse response , String url ) { } }

implementation: if ( url . startsWith ( StringPool . SLASH ) ) { url = ServletUtil . getContextPath ( request ) + url ; } response . setStatus ( HttpServletResponse . SC_MOVED_PERMANENTLY ) ; response . setHeader ( "Location" , url ) ;


signature:
public class DispatcherUtil { /** * Returns full URL : uri + query string , including the context path . */
public static String getFullUrl ( final HttpServletRequest request ) { } }

implementation: String url = request . getRequestURI ( ) ; String query = request . getQueryString ( ) ; if ( ( query != null ) && ( query . length ( ) != 0 ) ) { url += '?' + query ; } return url ;


signature:
public class DispatcherUtil { /** * Returns url , without context path , convenient for request dispatcher . */
public static String getUrl ( final HttpServletRequest request ) { } }

implementation: String servletPath = request . getServletPath ( ) ; String query = request . getQueryString ( ) ; if ( ( query != null ) && ( query . length ( ) != 0 ) ) { servletPath += '?' + query ; } return servletPath ;


signature:
public class DispatcherUtil { /** * Returns < code > true < / code > if current page is included . */
public static boolean isPageIncluded ( final HttpServletRequest request , final HttpServletResponse response ) { } }

implementation: return ( response . isCommitted ( ) || ( getIncludeServletPath ( request ) != null ) ) ;


signature:
public class DispatcherUtil { /** * Returns the base ( top - level ) uri . */
public static String getBaseRequestUri ( final HttpServletRequest request ) { } }

implementation: String result = getForwardRequestUri ( request ) ; if ( result == null ) { result = request . getRequestURI ( ) ; } return result ;


signature:
public class DispatcherUtil { /** * Get current request uri . */
public static String getRequestUri ( final HttpServletRequest request ) { } }

implementation: String result = getIncludeRequestUri ( request ) ; if ( result == null ) { result = request . getRequestURI ( ) ; } return result ;


signature:
public class ActionMethodParamNameResolver { /** * Returns method parameter names . */
public String [ ] resolveParamNames ( final Method actionClassMethod ) { } }

implementation: MethodParameter [ ] methodParameters = Paramo . resolveParameters ( actionClassMethod ) ; String [ ] names = new String [ methodParameters . length ] ; for ( int i = 0 ; i < methodParameters . length ; i ++ ) { names [ i ] = methodParameters [ i ] . getName ( ) ; } return names ;


signature:
public class Routes { /** * Builds { @ link PathMacros action path macros } from given action
 * path chunks . Returns either < code > null < / code > , if
 * no action path contains no macros , or instance of the < code > PathMacro < / code >
 * implementations . */
public PathMacros buildActionPathMacros ( final String actionPath ) { } }

implementation: if ( actionPath . isEmpty ( ) ) { return null ; } PathMacros pathMacros = createPathMacroInstance ( ) ; if ( ! pathMacros . init ( actionPath , actionsManager . getPathMacroSeparators ( ) ) ) { return null ; } return pathMacros ;


signature:
public class Routes { /** * Creates new < code > PathMacro < / code > instance . */
private PathMacros createPathMacroInstance ( ) { } }

implementation: try { return ClassUtil . newInstance ( actionsManager . getPathMacroClass ( ) ) ; } catch ( Exception ex ) { throw new MadvocException ( ex ) ; }


signature:
public class JoyPetite { /** * Creates and initializes Petite container .
 * It will be auto - magically configured by scanning the classpath . */
@ Override public void start ( ) { } }

implementation:
initLogger ( ) ; log . info ( "PETITE start  ----------" ) ; petiteContainer = createPetiteContainer ( ) ; if ( externalsCache ) { petiteContainer . setExternalsCache ( TypeCache . createDefault ( ) ) ; } log . info ( "Web application? " + isWebApplication ) ; if ( ! isWebApplication ) { // make session scope to act as singleton scope
// if this is not a web application ( and http session is not available ) .
petiteContainer . registerScope ( SessionScope . class , new SingletonScope ( petiteContainer ) ) ; } // load parameters from properties files
petiteContainer . defineParameters ( joyPropsSupplier . get ( ) . getProps ( ) ) ; // automagic configuration
if ( autoConfiguration ) { final AutomagicPetiteConfigurator automagicPetiteConfigurator = new AutomagicPetiteConfigurator ( petiteContainer ) ; automagicPetiteConfigurator . registerAsConsumer ( joyScannerSupplier . get ( ) . getClassScanner ( ) ) ; } petiteContainerConsumers . accept ( this . petiteContainer ) ; log . info ( "PETITE OK!" ) ;


signature:
public class JoyPetite { /** * Stops Petite container . */
@ Override public void stop ( ) { } }

implementation: if ( log != null ) { log . info ( "PETITE stop" ) ; } if ( petiteContainer != null ) { petiteContainer . shutdown ( ) ; } petiteContainer = null ;


signature:
public class JoyPetite { /** * - - - - - print */
public void printBeans ( final int width ) { } }

implementation: final Print print = new Print ( ) ; print . line ( "Beans" , width ) ; final List < BeanDefinition > beanDefinitionList = new ArrayList < > ( ) ; final String appName = appNameSupplier . get ( ) ; final String prefix = appName + "." ; petiteContainer . forEachBean ( beanDefinitionList :: add ) ; beanDefinitionList . stream ( ) . sorted ( ( bd1 , bd2 ) -> { if ( bd1 . name ( ) . startsWith ( prefix ) ) { if ( bd2 . name ( ) . startsWith ( prefix ) ) { return bd1 . name ( ) . compareTo ( bd2 . name ( ) ) ; } return 1 ; } if ( bd2 . name ( ) . startsWith ( prefix ) ) { if ( bd1 . name ( ) . startsWith ( prefix ) ) { return bd1 . name ( ) . compareTo ( bd2 . name ( ) ) ; } return - 1 ; } return bd1 . name ( ) . compareTo ( bd2 . name ( ) ) ; } ) . forEach ( beanDefinition -> { print . out ( Chalk256 . chalk ( ) . yellow ( ) , scopeName ( beanDefinition ) , 10 ) ; print . space ( ) ; print . outLeftRightNewLine ( Chalk256 . chalk ( ) . green ( ) , beanDefinition . name ( ) , Chalk256 . chalk ( ) . blue ( ) , ClassUtil . getShortClassName ( beanDefinition . type ( ) , 2 ) , width - 10 - 1 ) ; } ) ; print . line ( width ) ;


signature:
public class CurrentFrame { /** * Sets this CurrentFrame to the input stack map frame of the next " current " instruction , i . e . the
 * instruction just after the given one . It is assumed that the value of this object when this
 * method is called is the stack map frame status just before the given instruction is executed . */
@ Override void execute ( final int opcode , final int arg , final Symbol symbolArg , final SymbolTable symbolTable ) { } }

implementation: super . execute ( opcode , arg , symbolArg , symbolTable ) ; Frame successor = new Frame ( null ) ; merge ( symbolTable , successor , 0 ) ; copyFrom ( successor ) ;


signature:
public class EmailFilter { /** * Defines filter for SUBJECT field .
 * @ param subject The SUBJECT .
 * @ return this */
public EmailFilter subject ( final String subject ) { } }

implementation: final SearchTerm subjectTerm = new SubjectTerm ( subject ) ; concat ( subjectTerm ) ; return this ;


signature:
public class EmailFilter { /** * Defines filter for message id .
 * @ param messageId The message ID .
 * @ return this */
public EmailFilter messageId ( final String messageId ) { } }

implementation: final SearchTerm msgIdTerm = new MessageIDTerm ( messageId ) ; concat ( msgIdTerm ) ; return this ;


signature:
public class EmailFilter { /** * Defines filter for FROM field .
 * @ param fromAddress The FROM address
 * @ return this */
public EmailFilter from ( final String fromAddress ) { } }

implementation: final SearchTerm fromTerm = new FromStringTerm ( fromAddress ) ; concat ( fromTerm ) ; return this ;


signature:
public class EmailFilter { /** * Defines filter for TO field .
 * @ param toAddress The TO address .
 * @ return this */
public EmailFilter to ( final String toAddress ) { } }

implementation: final SearchTerm toTerm = new RecipientStringTerm ( RecipientType . TO , toAddress ) ; concat ( toTerm ) ; return this ;


signature:
public class EmailFilter { /** * Defines filter for CC field .
 * @ param ccAddress CC addreses .
 * @ return this */
public EmailFilter cc ( final String ccAddress ) { } }

implementation: final SearchTerm toTerm = new RecipientStringTerm ( RecipientType . CC , ccAddress ) ; concat ( toTerm ) ; return this ;


signature:
public class EmailFilter { /** * Defines filter for BCC field .
 * @ param bccAddress BCC address .
 * @ return this */
public EmailFilter bcc ( final String bccAddress ) { } }

implementation: final SearchTerm toTerm = new RecipientStringTerm ( RecipientType . BCC , bccAddress ) ; concat ( toTerm ) ; return this ;


signature:
public class EmailFilter { /** * Defines filter for many flags at once .
 * @ param flags The { @ link Flags } to filter on .
 * @ param value The { @ link Flag } setting to check for .
 * @ return this */
public EmailFilter flags ( final Flags flags , final boolean value ) { } }

implementation: final SearchTerm flagTerm = new FlagTerm ( flags , value ) ; concat ( flagTerm ) ; return this ;


signature:
public class EmailFilter { /** * Defines filter for single flag .
 * @ param flag The flag to filter on .
 * @ param value The { @ link Flag } setting to check for .
 * @ return this */
public EmailFilter flag ( final Flag flag , final boolean value ) { } }

implementation: final Flags flags = new Flags ( ) ; flags . add ( flag ) ; return flags ( flags , value ) ;


signature:
public class EmailFilter { /** * Defines filter for received date .
 * @ return this */
public EmailFilter receivedDate ( final Operator operator , final long milliseconds ) { } }

implementation: final SearchTerm term = new ReceivedDateTerm ( operator . value , new Date ( milliseconds ) ) ; concat ( term ) ; return this ;


signature:
public class EmailFilter { /** * Defines filter for sent date .
 * @ param operator { @ link Operator } to use .
 * @ param milliseconds the milliseconds since January 1 , 1970 , 00:00:00 GMT .
 * @ return this */
public EmailFilter sentDate ( final Operator operator , final long milliseconds ) { } }

implementation: final SearchTerm term = new SentDateTerm ( operator . value , new Date ( milliseconds ) ) ; concat ( term ) ; return this ;


signature:
public class EmailFilter { /** * Defines filter on a message body .
 * All parts of the message that are of MIME type " text / * " are searched .
 * @ param pattern String pattern use in body .
 * @ return this */
public EmailFilter text ( final String pattern ) { } }

implementation: final SearchTerm term = new BodyTerm ( pattern ) ; concat ( term ) ; return this ;


signature:
public class EmailFilter { /** * Defines filter for { @ link Header } .
 * @ param headerName The name of the { @ link Header } .
 * @ param pattern String pattern to use for headerName .
 * @ return this */
public EmailFilter header ( final String headerName , final String pattern ) { } }

implementation: final SearchTerm term = new HeaderTerm ( headerName , pattern ) ; concat ( term ) ; return this ;


signature:
public class EmailFilter { /** * Defines filter for message size .
 * @ param comparison { @ link Operator } .
 * @ param size size of message .
 * @ return this */
public EmailFilter size ( final Operator comparison , final int size ) { } }

implementation: final SearchTerm term = new SizeTerm ( comparison . value , size ) ; concat ( term ) ; return this ;


signature:
public class EmailFilter { /** * Defines AND group of filters .
 * @ param emailFilters array of { @ link EmailFilter } s to AND .
 * @ return this */
public EmailFilter and ( final EmailFilter ... emailFilters ) { } }

implementation: final SearchTerm [ ] searchTerms = new SearchTerm [ emailFilters . length ] ; for ( int i = 0 ; i < emailFilters . length ; i ++ ) { searchTerms [ i ] = emailFilters [ i ] . searchTerm ; } concat ( new AndTerm ( searchTerms ) ) ; return this ;


signature:
public class EmailFilter { /** * Defines OR group of filters .
 * @ param emailFilters array of { @ link EmailFilter } s to OR .
 * @ return this */
public EmailFilter or ( final EmailFilter ... emailFilters ) { } }

implementation: final SearchTerm [ ] searchTerms = new SearchTerm [ emailFilters . length ] ; for ( int i = 0 ; i < emailFilters . length ; i ++ ) { searchTerms [ i ] = emailFilters [ i ] . searchTerm ; } concat ( new OrTerm ( searchTerms ) ) ; return this ;


signature:
public class EmailFilter { /** * Appends single filter as NOT .
 * @ param emailFilter { @ link EmailFilter } to append .
 * @ return this */
public EmailFilter not ( final EmailFilter emailFilter ) { } }

implementation: final SearchTerm searchTerm = new NotTerm ( emailFilter . searchTerm ) ; concat ( searchTerm ) ; return this ;


signature:
public class EmailFilter { /** * Concatenates last search term with new one .
 * @ param searchTerm searchTerm { @ link SearchTerm } concatenate .
 * @ see # and ( SearchTerm )
 * @ see # or ( SearchTerm ) */
protected void concat ( SearchTerm searchTerm ) { } }

implementation: if ( nextIsNot ) { searchTerm = new NotTerm ( searchTerm ) ; nextIsNot = false ; } if ( operatorAnd ) { and ( searchTerm ) ; } else { or ( searchTerm ) ; }


signature:
public class EmailFilter { /** * Sets { @ link AndTerm } as searchTerm .
 * @ param searchTerm { @ link SearchTerm } to set as AND . */
protected void and ( final SearchTerm searchTerm ) { } }

implementation: if ( this . searchTerm == null ) { this . searchTerm = searchTerm ; return ; } this . searchTerm = new AndTerm ( this . searchTerm , searchTerm ) ;


signature:
public class EmailFilter { /** * Sets { @ link OrTerm } searchTerm .
 * @ param searchTerm { @ link SearchTerm } to set as OR . */
protected void or ( final SearchTerm searchTerm ) { } }

implementation: if ( this . searchTerm == null ) { this . searchTerm = searchTerm ; return ; } this . searchTerm = new OrTerm ( this . searchTerm , searchTerm ) ;


signature:
public class Base32 { /** * Encode an array of binary bytes into a Base32 string . */
public static String encode ( final byte [ ] bytes ) { } }

implementation:
StringBuilder base32 = new StringBuilder ( ( bytes . length * 8 + 4 ) / 5 ) ; int currByte , digit , i = 0 ; while ( i < bytes . length ) { // STEP 0 ; insert new 5 bits , leave 3 bits
currByte = bytes [ i ++ ] & 255 ; base32 . append ( CHARS [ currByte >> 3 ] ) ; digit = ( currByte & 7 ) << 2 ; if ( i >= bytes . length ) { base32 . append ( CHARS [ digit ] ) ; break ; } // STEP 3 : insert 2 new bits , then 5 bits , leave 1 bit
currByte = bytes [ i ++ ] & 255 ; base32 . append ( CHARS [ digit | ( currByte >> 6 ) ] ) ; base32 . append ( CHARS [ ( currByte >> 1 ) & 31 ] ) ; digit = ( currByte & 1 ) << 4 ; if ( i >= bytes . length ) { base32 . append ( CHARS [ digit ] ) ; break ; } // STEP 1 : insert 4 new bits , leave 4 bit
currByte = bytes [ i ++ ] & 255 ; base32 . append ( CHARS [ digit | ( currByte >> 4 ) ] ) ; digit = ( currByte & 15 ) << 1 ; if ( i >= bytes . length ) { base32 . append ( CHARS [ digit ] ) ; break ; } // STEP 4 : insert 1 new bit , then 5 bits , leave 2 bits
currByte = bytes [ i ++ ] & 255 ; base32 . append ( CHARS [ digit | ( currByte >> 7 ) ] ) ; base32 . append ( CHARS [ ( currByte >> 2 ) & 31 ] ) ; digit = ( currByte & 3 ) << 3 ; if ( i >= bytes . length ) { base32 . append ( CHARS [ digit ] ) ; break ; } // STEP 2 : insert 3 new bits , then 5 bits , leave 0 bit
currByte = bytes [ i ++ ] & 255 ; base32 . append ( CHARS [ digit | ( currByte >> 5 ) ] ) ; base32 . append ( CHARS [ currByte & 31 ] ) ; } return base32 . toString ( ) ;


signature:
public class Base32 { /** * Decode a Base32 string into an array of binary bytes . */
public static byte [ ] decode ( final String base32 ) throws IllegalArgumentException { } }

implementation:
switch ( base32 . length ( ) % 8 ) { case 1 : case 3 : case 6 : throw new IllegalArgumentException ( ERR_CANONICAL_LEN ) ; } byte [ ] bytes = new byte [ base32 . length ( ) * 5 / 8 ] ; int offset = 0 , i = 0 , lookup ; byte nextByte , digit ; while ( i < base32 . length ( ) ) { lookup = base32 . charAt ( i ++ ) - '2' ; if ( lookup < 0 || lookup >= LOOKUP . length ) { throw new IllegalArgumentException ( ERR_INVALID_CHARS ) ; } digit = LOOKUP [ lookup ] ; if ( digit == - 1 ) { throw new IllegalArgumentException ( ERR_INVALID_CHARS ) ; } // STEP n = 0 : leave 5 bits
nextByte = ( byte ) ( digit << 3 ) ; lookup = base32 . charAt ( i ++ ) - '2' ; if ( lookup < 0 || lookup >= LOOKUP . length ) { throw new IllegalArgumentException ( ERR_INVALID_CHARS ) ; } digit = LOOKUP [ lookup ] ; if ( digit == - 1 ) { throw new IllegalArgumentException ( ERR_INVALID_CHARS ) ; } // STEP n = 5 : insert 3 bits , leave 2 bits
bytes [ offset ++ ] = ( byte ) ( nextByte | ( digit >> 2 ) ) ; nextByte = ( byte ) ( ( digit & 3 ) << 6 ) ; if ( i >= base32 . length ( ) ) { if ( nextByte != ( byte ) 0 ) { throw new IllegalArgumentException ( ERR_CANONICAL_END ) ; } break ; } lookup = base32 . charAt ( i ++ ) - '2' ; if ( lookup < 0 || lookup >= LOOKUP . length ) { throw new IllegalArgumentException ( ERR_INVALID_CHARS ) ; } digit = LOOKUP [ lookup ] ; if ( digit == - 1 ) { throw new IllegalArgumentException ( ERR_INVALID_CHARS ) ; } // STEP n = 2 : leave 7 bits
nextByte |= ( byte ) ( digit << 1 ) ; lookup = base32 . charAt ( i ++ ) - '2' ; if ( lookup < 0 || lookup >= LOOKUP . length ) { throw new IllegalArgumentException ( ERR_INVALID_CHARS ) ; } digit = LOOKUP [ lookup ] ; if ( digit == - 1 ) { throw new IllegalArgumentException ( ERR_INVALID_CHARS ) ; } // STEP n = 7 : insert 1 bit , leave 4 bits
bytes [ offset ++ ] = ( byte ) ( nextByte | ( digit >> 4 ) ) ; nextByte = ( byte ) ( ( digit & 15 ) << 4 ) ; if ( i >= base32 . length ( ) ) { if ( nextByte != ( byte ) 0 ) { throw new IllegalArgumentException ( ERR_CANONICAL_END ) ; } break ; } lookup = base32 . charAt ( i ++ ) - '2' ; if ( lookup < 0 || lookup >= LOOKUP . length ) { throw new IllegalArgumentException ( ERR_INVALID_CHARS ) ; } digit = LOOKUP [ lookup ] ; if ( digit == - 1 ) { throw new IllegalArgumentException ( ERR_INVALID_CHARS ) ; } // STEP n = 4 : insert 4 bits , leave 1 bit
bytes [ offset ++ ] = ( byte ) ( nextByte | ( digit >> 1 ) ) ; nextByte = ( byte ) ( ( digit & 1 ) << 7 ) ; if ( i >= base32 . length ( ) ) { if ( nextByte != ( byte ) 0 ) { throw new IllegalArgumentException ( ERR_CANONICAL_END ) ; } break ; } lookup = base32 . charAt ( i ++ ) - '2' ; if ( lookup < 0 || lookup >= LOOKUP . length ) { throw new IllegalArgumentException ( ERR_INVALID_CHARS ) ; } digit = LOOKUP [ lookup ] ; if ( digit == - 1 ) { throw new IllegalArgumentException ( ERR_INVALID_CHARS ) ; } // STEP n = 1 : leave 6 bits
nextByte |= ( byte ) ( digit << 2 ) ; lookup = base32 . charAt ( i ++ ) - '2' ; if ( lookup < 0 || lookup >= LOOKUP . length ) { throw new IllegalArgumentException ( ERR_INVALID_CHARS ) ; } digit = LOOKUP [ lookup ] ; if ( digit == - 1 ) { throw new IllegalArgumentException ( ERR_INVALID_CHARS ) ; } // STEP n = 6 : insert 2 bits , leave 3 bits
bytes [ offset ++ ] = ( byte ) ( nextByte | ( digit >> 3 ) ) ; nextByte = ( byte ) ( ( digit & 7 ) << 5 ) ; if ( i >= base32 . length ( ) ) { if ( nextByte != ( byte ) 0 ) { throw new IllegalArgumentException ( ERR_CANONICAL_END ) ; } break ; } lookup = base32 . charAt ( i ++ ) - '2' ; if ( lookup < 0 || lookup >= LOOKUP . length ) { throw new IllegalArgumentException ( ERR_INVALID_CHARS ) ; } digit = LOOKUP [ lookup ] ; if ( digit == - 1 ) { throw new IllegalArgumentException ( ERR_INVALID_CHARS ) ; } // STEP n = 3 : insert 5 bits , leave 0 bit
bytes [ offset ++ ] = ( byte ) ( nextByte | digit ) ; } return bytes ;


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

implementation:
if ( value instanceof Blob ) { final Blob blob = ( Blob ) value ; try { final long length = blob . length ( ) ; if ( length > Integer . MAX_VALUE ) { throw new TypeConversionException ( "Blob is too big." ) ; } return blob . getBytes ( 1 , ( int ) length ) ; } catch ( SQLException sex ) { throw new TypeConversionException ( value , sex ) ; } } if ( value instanceof File ) { try { return FileUtil . readBytes ( ( File ) value ) ; } catch ( IOException ioex ) { throw new TypeConversionException ( value , ioex ) ; } } if ( value instanceof Collection ) { final Collection collection = ( Collection ) value ; final byte [ ] target = new byte [ collection . size ( ) ] ; int i = 0 ; for ( final Object element : collection ) { target [ i ] = convertType ( element ) ; i ++ ; } return target ; } if ( value instanceof Iterable ) { final Iterable iterable = ( Iterable ) value ; final ArrayList < Byte > byteArrayList = new ArrayList < > ( ) ; for ( final Object element : iterable ) { final byte convertedValue = convertType ( element ) ; byteArrayList . add ( Byte . valueOf ( convertedValue ) ) ; } final byte [ ] array = new byte [ byteArrayList . size ( ) ] ; for ( int i = 0 ; i < byteArrayList . size ( ) ; i ++ ) { final Byte b = byteArrayList . get ( i ) ; array [ i ] = b . byteValue ( ) ; } return array ; } if ( value instanceof CharSequence ) { final String [ ] strings = StringUtil . splitc ( value . toString ( ) , ArrayConverter . NUMBER_DELIMITERS ) ; return convertArrayToArray ( strings ) ; } // everything else :
return convertToSingleElementArray ( value ) ;


signature:
public class GzipFilter { /** * If browser supports gzip , sets the Content - Encoding response header and
 * invoke resource with a wrapped response that collects all the output .
 * Extracts the output and write it into a gzipped byte array . Finally , write
 * that array to the client ' s output stream .
 * If browser does not support gzip , invokes resource normally . */
@ Override public void doFilter ( final ServletRequest request , final ServletResponse response , final FilterChain chain ) throws ServletException , IOException { } }

implementation: HttpServletRequest req = ( HttpServletRequest ) request ; HttpServletResponse res = ( HttpServletResponse ) response ; if ( ( threshold == 0 ) || ( ! ServletUtil . isGzipSupported ( req ) ) || ( ! isGzipEligible ( req ) ) ) { chain . doFilter ( request , response ) ; return ; } GzipResponseWrapper wrappedResponse = new GzipResponseWrapper ( res ) ; wrappedResponse . setCompressionThreshold ( threshold ) ; try { chain . doFilter ( request , wrappedResponse ) ; } finally { wrappedResponse . finishResponse ( ) ; }


signature:
public class GzipFilter { /** * Filter initialization . */
@ Override public void init ( final FilterConfig config ) { } }

implementation:
try { wildcards = Converter . get ( ) . toBooleanValue ( config . getInitParameter ( "wildcards" ) , false ) ; } catch ( TypeConversionException ignore ) { wildcards = false ; } // min size
try { threshold = Converter . get ( ) . toIntValue ( config . getInitParameter ( "threshold" ) , 0 ) ; } catch ( TypeConversionException ignore ) { threshold = 0 ; } // match string
String uriMatch = config . getInitParameter ( "match" ) ; if ( ( uriMatch != null ) && ( ! uriMatch . equals ( StringPool . STAR ) ) ) { matches = StringUtil . splitc ( uriMatch , ',' ) ; for ( int i = 0 ; i < matches . length ; i ++ ) { matches [ i ] = matches [ i ] . trim ( ) ; } } // exclude string
String uriExclude = config . getInitParameter ( "exclude" ) ; if ( uriExclude != null ) { excludes = StringUtil . splitc ( uriExclude , ',' ) ; for ( int i = 0 ; i < excludes . length ; i ++ ) { excludes [ i ] = excludes [ i ] . trim ( ) ; } } // request parameter name
requestParameterName = config . getInitParameter ( "requestParameterName" ) ; if ( requestParameterName == null ) { requestParameterName = "gzip" ; } requestParameterName = requestParameterName . trim ( ) ; // allowed extensions
String urlExtensions = config . getInitParameter ( "extensions" ) ; if ( urlExtensions != null ) { if ( urlExtensions . equals ( StringPool . STAR ) ) { extensions = null ; } else { extensions = StringUtil . splitc ( urlExtensions , ", " ) ; } } else { extensions = new String [ ] { "html" , "htm" , "js" , "css" } ; }


signature:
public class GzipFilter { /** * Determine if request is eligible for GZipping . */
protected boolean isGzipEligible ( final HttpServletRequest request ) { } }

implementation:
// request parameter name
if ( requestParameterName . length ( ) != 0 ) { String forceGzipString = request . getParameter ( requestParameterName ) ; if ( forceGzipString != null ) { return Converter . get ( ) . toBooleanValue ( forceGzipString , false ) ; } } // extract uri
String uri = request . getRequestURI ( ) ; if ( uri == null ) { return false ; } uri = uri . toLowerCase ( ) ; boolean result = false ; // check uri
if ( matches == null ) { // match = = *
if ( extensions == null ) { // extensions = = *
return true ; } // extension
String extension = FileNameUtil . getExtension ( uri ) ; if ( extension . length ( ) > 0 ) { extension = extension . toLowerCase ( ) ; if ( StringUtil . equalsOne ( extension , extensions ) != - 1 ) { result = true ; } } } else { if ( wildcards ) { result = Wildcard . matchPathOne ( uri , matches ) != - 1 ; } else { for ( String match : matches ) { if ( uri . contains ( match ) ) { result = true ; break ; } } } } if ( ( result ) && ( excludes != null ) ) { if ( wildcards ) { if ( Wildcard . matchPathOne ( uri , excludes ) != - 1 ) { result = false ; } } else { for ( String exclude : excludes ) { if ( uri . contains ( exclude ) ) { result = false ; // excludes founded
break ; } } } } return result ;


signature:
public class Vtor { /** * Adds new { @ link Violation violation } . Violations are added during { @ link # validate ( ValidationContext , Object , String ) validation } .
 * They can be added after the validation as well , with < code > null < / code > check ( and constraint ) . */
public void addViolation ( final Violation v ) { } }

implementation: if ( v == null ) { return ; } if ( violations == null ) { violations = new ArrayList < > ( ) ; } violations . add ( v ) ;


signature:
public class Vtor { /** * Validate object using context from the annotations . */
public List < Violation > validate ( final Object target ) { } }

implementation: return validate ( ValidationContext . resolveFor ( target . getClass ( ) ) , target ) ;


signature:
public class Vtor { /** * Performs validation of provided validation context and appends violations . */
public List < Violation > validate ( final ValidationContext ctx , final Object target , final String targetName ) { } }

implementation:
for ( Map . Entry < String , List < Check > > entry : ctx . map . entrySet ( ) ) { String name = entry . getKey ( ) ; Object value = BeanUtil . declaredSilent . getProperty ( target , name ) ; String valueName = targetName != null ? ( targetName + '.' + name ) : name ; // move up
ValidationConstraintContext vcc = new ValidationConstraintContext ( this , target , valueName ) ; for ( Check check : entry . getValue ( ) ) { String [ ] checkProfiles = check . getProfiles ( ) ; if ( ! matchProfiles ( checkProfiles ) ) { continue ; } if ( check . getSeverity ( ) < severity ) { continue ; } ValidationConstraint constraint = check . getConstraint ( ) ; if ( ! constraint . isValid ( vcc , value ) ) { addViolation ( new Violation ( valueName , target , value , check ) ) ; } } } return getViolations ( ) ;


signature:
public class Vtor { /** * Enables single profile . */
public void useProfile ( final String profile ) { } }

implementation: if ( profile == null ) { return ; } if ( this . enabledProfiles == null ) { this . enabledProfiles = new HashSet < > ( ) ; } this . enabledProfiles . add ( profile ) ;


signature:
public class Vtor { /** * Enables list of profiles . */
public void useProfiles ( final String ... enabledProfiles ) { } }

implementation: if ( enabledProfiles == null ) { return ; } if ( this . enabledProfiles == null ) { this . enabledProfiles = new HashSet < > ( ) ; } Collections . addAll ( this . enabledProfiles , enabledProfiles ) ;


signature:
public class Vtor { /** * Determine if any of checks profiles is among enabled profiles . */
protected boolean matchProfiles ( final String [ ] checkProfiles ) { } }

implementation:
// test for all profiles
if ( ( checkProfiles != null ) && ( checkProfiles . length == 1 ) && checkProfiles [ 0 ] . equals ( ALL_PROFILES ) ) { return true ; } if ( enabledProfiles == null || enabledProfiles . isEmpty ( ) ) { if ( validateAllProfilesByDefault ) { return true ; // all profiles are considered as enabled
} // only default profile is enabled
if ( ( checkProfiles == null ) || ( checkProfiles . length == 0 ) ) { return true ; } for ( String profile : checkProfiles ) { if ( StringUtil . isEmpty ( profile ) ) { return true ; // default profile
} if ( profile . equals ( DEFAULT_PROFILE ) ) { return true ; } } return false ; } // there are enabled profiles
if ( ( checkProfiles == null ) || ( checkProfiles . length == 0 ) ) { return enabledProfiles . contains ( DEFAULT_PROFILE ) ; } boolean result = false ; for ( String profile : checkProfiles ) { boolean b = true ; boolean must = false ; if ( StringUtil . isEmpty ( profile ) ) { profile = DEFAULT_PROFILE ; } else if ( profile . charAt ( 0 ) == '-' ) { profile = profile . substring ( 1 ) ; b = false ; } else if ( profile . charAt ( 0 ) == '+' ) { profile = profile . substring ( 1 ) ; must = true ; } if ( enabledProfiles . contains ( profile ) ) { if ( ! b ) { return false ; } result = true ; } else { if ( must ) { return false ; } } } return result ;


signature:
public class JsonBodyScope { /** * Parses request body into the target type . */
protected Object parseRequestBody ( final String body , final Class targetType ) { } }

implementation: return JsonParser . create ( ) . parse ( body , targetType ) ;


signature:
public class JulianDate { /** * Converts to milliseconds . */
public long toMilliseconds ( ) { } }

implementation: double then = ( fraction - JD_1970 . fraction ) * MILLIS_IN_DAY ; then += ( integer - JD_1970 . integer ) * MILLIS_IN_DAY ; then += then > 0 ? 1.0e-6 : - 1.0e-6 ; return ( long ) then ;


signature:
public class JulianDate { /** * Adds a JD to current instance . */
public JulianDate add ( final JulianDate jds ) { } }

implementation: int i = this . integer + jds . integer ; double f = this . fraction + jds . fraction ; return new JulianDate ( i , f ) ;


signature:
public class JulianDate { /** * Subtracts a JD from current instance . */
public JulianDate sub ( final JulianDate jds ) { } }

implementation: int i = this . integer - jds . integer ; double f = this . fraction - jds . fraction ; return new JulianDate ( i , f ) ;


signature:
public class JulianDate { /** * Sets integer and fractional part with normalization .
 * Normalization means that if double is out of range ,
 * values will be correctly fixed . */
private void set ( final int i , double f ) { } }

implementation: integer = i ; int fi = ( int ) f ; f -= fi ; integer += fi ; if ( f < 0 ) { f += 1 ; integer -- ; } this . fraction = f ;


signature:
public class JulianDate { /** * Returns span between two days . Returned value may be positive ( when this date
 * is after the provided one ) or negative ( when comparing to future date ) . */
public int daysSpan ( final JulianDate otherDate ) { } }

implementation: int now = getJulianDayNumber ( ) ; int then = otherDate . getJulianDayNumber ( ) ; return now - then ;


signature:
public class Chalk256 { /** * - - - - - fg codes */
public Chalk256 standard ( final int index ) { } }

implementation: startSequence ( FG_CODES [ index ( index , 0 , 8 ) ] ) ; endSequence ( RESET ) ; return _this ( ) ;


signature:
public class Chalk256 { /** * Colors with red - green - blue value , in the range 0 to 6. */
public Chalk256 rgb ( final int r , final int b , final int g ) { } }

implementation: startSequence ( FG_CODES [ index ( 36 * r + 6 * g + b , 16 , 232 ) ] ) ; endSequence ( RESET ) ; return _this ( ) ;


signature:
public class Chalk256 { /** * - - - - - bg codes */
public Chalk256 bgStandard ( final int index ) { } }

implementation: startSequence ( BG_CODES [ index ( index , 0 , 8 ) ] ) ; endSequence ( RESET ) ; return _this ( ) ;


signature:
public class Chalk256 { /** * Colors with red - green - blue value , in the range 0 to 6. */
public Chalk256 bgRgb ( final int r , final int b , final int g ) { } }

implementation: startSequence ( BG_CODES [ index ( 36 * r + 6 * g + b , 16 , 232 ) ] ) ; endSequence ( RESET ) ; return _this ( ) ;


signature:
public class Chalk256 { /** * - - - - - bgcolors */
private int index ( int index , final int from , final int to ) { } }

implementation: index += from ; if ( ( index < from ) || ( index >= to ) ) { throw new IllegalArgumentException ( "Color index not in range: [0, " + ( to - from ) + "]" ) ; } return index ;


signature:
public class LagartoParser { /** * Initializes parser . */
@ Override protected void initialize ( final char [ ] input ) { } }

implementation: super . initialize ( input ) ; this . tag = new ParsedTag ( ) ; this . doctype = new ParsedDoctype ( ) ; this . text = new char [ 1024 ] ; this . textLen = 0 ; this . parsingTime = - 1 ;


signature:
public class LagartoParser { /** * Parses content and callback provided { @ link TagVisitor } . */
public void parse ( final TagVisitor visitor ) { } }

implementation: tag . init ( config . caseSensitive ) ; this . parsingTime = System . currentTimeMillis ( ) ; this . visitor = visitor ; visitor . start ( ) ; parsing = true ; while ( parsing ) { state . parse ( ) ; } emitText ( ) ; visitor . end ( ) ; this . parsingTime = System . currentTimeMillis ( ) - parsingTime ;


signature:
public class LagartoParser { /** * Emits a comment . Also checks for conditional comments ! */
protected void emitComment ( final int from , final int to ) { } }

implementation:
if ( config . enableConditionalComments ) { // CC : downlevel - hidden starting
if ( match ( CC_IF , from ) ) { int endBracketNdx = find ( ']' , from + 3 , to ) ; CharSequence expression = charSequence ( from + 1 , endBracketNdx ) ; ndx = endBracketNdx + 1 ; char c = input [ ndx ] ; if ( c != '>' ) { errorInvalidToken ( ) ; } visitor . condComment ( expression , true , true , false ) ; state = DATA_STATE ; return ; } if ( to > CC_ENDIF2 . length && match ( CC_ENDIF2 , to - CC_ENDIF2 . length ) ) { // CC : downlevel - hidden ending
visitor . condComment ( _ENDIF , false , true , true ) ; state = DATA_STATE ; return ; } } CharSequence comment = charSequence ( from , to ) ; visitor . comment ( comment ) ; commentStart = - 1 ;


signature:
public class LagartoParser { /** * Prepares error message and reports it to the visitor . */
protected void _error ( String message ) { } }

implementation: if ( config . calculatePosition ) { Position currentPosition = position ( ndx ) ; message = message . concat ( StringPool . SPACE ) . concat ( currentPosition . toString ( ) ) ; } else { message = message . concat ( " [@" ) . concat ( Integer . toString ( ndx ) ) . concat ( StringPool . RIGHT_SQ_BRACKET ) ; } visitor . error ( message ) ;


signature:
public class LagartoParser { /** * - - - - - util */
private boolean isAppropriateTagName ( final char [ ] lowerCaseNameToMatch , final int from , final int to ) { } }

implementation: final int len = to - from ; if ( len != lowerCaseNameToMatch . length ) { return false ; } for ( int i = from , k = 0 ; i < to ; i ++ , k ++ ) { char c = input [ i ] ; c = CharUtil . toLowerAscii ( c ) ; if ( c != lowerCaseNameToMatch [ k ] ) { return false ; } } return true ;


signature:
public class PBKDF2Hash { /** * Returns a salted PBKDF2 hash of the password .
 * @ param password the password to hash
 * @ return a salted PBKDF2 hash of the password */
public String createHash ( final char [ ] password ) { } }

implementation:
// Generate a random salt
SecureRandom random = new SecureRandom ( ) ; byte [ ] salt = new byte [ saltBytes ] ; random . nextBytes ( salt ) ; // Hash the password
byte [ ] hash = pbkdf2 ( password , salt , pbkdf2Iterations , hashBytes ) ; // format iterations : salt : hash
return pbkdf2Iterations + ":" + StringUtil . toHexString ( salt ) + ":" + StringUtil . toHexString ( hash ) ;


signature:
public class PBKDF2Hash { /** * Computes the PBKDF2 hash of a password .
 * @ param password the password to hash .
 * @ param salt the salt
 * @ param iterations the iteration count ( slowness factor )
 * @ param bytes the length of the hash to compute in bytes
 * @ return the PBDKF2 hash of the password */
private static byte [ ] pbkdf2 ( final char [ ] password , final byte [ ] salt , final int iterations , final int bytes ) { } }

implementation: PBEKeySpec spec = new PBEKeySpec ( password , salt , iterations , bytes * 8 ) ; try { SecretKeyFactory skf = SecretKeyFactory . getInstance ( PBKDF2_ALGORITHM ) ; return skf . generateSecret ( spec ) . getEncoded ( ) ; } catch ( NoSuchAlgorithmException ignore ) { return null ; } catch ( InvalidKeySpecException e ) { throw new IllegalArgumentException ( e ) ; }


signature:
public class PBKDF2Hash { /** * Converts a string of hexadecimal characters into a byte array .
 * @ param hex the hex string
 * @ return the hex string decoded into a byte array */
private static byte [ ] fromHex ( final String hex ) { } }

implementation: final byte [ ] binary = new byte [ hex . length ( ) / 2 ] ; for ( int i = 0 ; i < binary . length ; i ++ ) { binary [ i ] = ( byte ) Integer . parseInt ( hex . substring ( 2 * i , 2 * i + 2 ) , 16 ) ; } return binary ;


signature:
public class PetiteResolvers { /** * Resolves provider definition defined in a bean . */
public ProviderDefinition [ ] resolveProviderDefinitions ( final Class type , final String name ) { } }

implementation: return providerResolver . resolve ( type , name ) ;


signature:
public class EmailAttachmentBuilder { /** * Sets file name .
 * @ param name File name to set .
 * @ return this */
public EmailAttachmentBuilder name ( final String name ) { } }

implementation: if ( name != null && ! name . trim ( ) . isEmpty ( ) ) { this . name = name ; } return this ;


signature:
public class EmailAttachmentBuilder { /** * Sets the { @ link DataSource } . Common { @ link DataSource } s include { @ link ByteArrayDataSource } and
 * { @ link FileDataSource } .
 * @ param dataSource { @ link DataSource }
 * @ return this */
public < T extends DataSource > EmailAttachmentBuilder content ( final T dataSource ) { } }

implementation: this . dataSource = dataSource ; name ( dataSource . getName ( ) ) ; return this ;


signature:
public class EmailAttachmentBuilder { /** * Creates new { @ link ByteArrayDataSource } and then calls { @ link # content ( DataSource ) } .
 * @ param inputStream { @ link InputStream }
 * @ param contentType content type from { @ link EmailAttachment } .
 * @ return this
 * @ throws IOException if { @ link ByteArrayDataSource } cannot be created from { @ link InputStream }
 * @ see # content ( DataSource ) */
public EmailAttachmentBuilder content ( final InputStream inputStream , final String contentType ) throws IOException { } }

implementation: return content ( new ByteArrayDataSource ( inputStream , resolveContentType ( contentType ) ) ) ;


signature:
public class EmailAttachmentBuilder { /** * Creates new { @ link ByteArrayDataSource } and then calls { @ link # content ( DataSource ) } .
 * @ param bytes array of bytes
 * @ param contentType content type from { @ link EmailAttachment } .
 * @ return this
 * @ see # content ( DataSource ) */
public EmailAttachmentBuilder content ( final byte [ ] bytes , final String contentType ) { } }

implementation: return content ( new ByteArrayDataSource ( bytes , resolveContentType ( contentType ) ) ) ;


signature:
public class EmailAttachmentBuilder { /** * Creates { @ link EmailAttachment } .
 * @ return { @ link EmailAttachment } .
 * @ throws MailException if issue with { @ link DataSource } . */
public EmailAttachment < ByteArrayDataSource > buildByteArrayDataSource ( ) throws MailException { } }

implementation: try { final ByteArrayDataSource bads ; if ( dataSource instanceof ByteArrayDataSource ) { bads = ( ByteArrayDataSource ) dataSource ; } else { bads = new ByteArrayDataSource ( dataSource . getInputStream ( ) , dataSource . getContentType ( ) ) ; } checkDataSource ( ) ; return new EmailAttachment < > ( name , contentId , isInline , bads ) . setEmbeddedMessage ( targetMessage ) ; } catch ( final IOException ioexc ) { throw new MailException ( ioexc ) ; }


signature:
public class EmailAttachmentBuilder { /** * Creates { @ link EmailAttachment } .
 * @ return { @ link EmailAttachment } .
 * @ throws MailException if issue with { @ link DataSource } . */
public EmailAttachment < FileDataSource > buildFileDataSource ( final String messageId , final File attachmentStorage ) throws MailException { } }

implementation: try { final FileDataSource fds ; if ( dataSource instanceof FileDataSource ) { fds = ( FileDataSource ) dataSource ; } else { final File file = new File ( attachmentStorage , messageId ) ; FileUtil . writeStream ( file , dataSource . getInputStream ( ) ) ; fds = new FileDataSource ( file ) ; } checkDataSource ( ) ; return new EmailAttachment < > ( name , contentId , isInline , fds ) . setEmbeddedMessage ( targetMessage ) ; } catch ( final IOException ioexc ) { throw new MailException ( ioexc ) ; }


signature:
public class EmailAttachmentBuilder { /** * Set content ID if it is missing .
 * @ return this
 * @ see # contentId ( String ) */
protected EmailAttachmentBuilder setContentIdFromNameIfMissing ( ) { } }

implementation: if ( contentId == null ) { if ( name != null ) { contentId ( FileNameUtil . getName ( name ) ) ; } else { contentId ( NO_NAME ) ; } } return this ;


signature:
public class EmailAttachmentBuilder { /** * Resolves content type from all data .
 * @ param contentType Content type if we know it . { @ code null } is fine to use .
 * @ return content type */
protected String resolveContentType ( final String contentType ) { } }

implementation: if ( contentType != null ) { return contentType ; } if ( name == null ) { return MimeTypes . MIME_APPLICATION_OCTET_STREAM ; } final String extension = FileNameUtil . getExtension ( name ) ; return MimeTypes . getMimeType ( extension ) ;


signature:
public class SignatureReader { /** * Makes the given visitor visit the signature of this { @ link SignatureReader } . This signature is
 * the one specified in the constructor ( see { @ link # SignatureReader } ) . This method is intended to
 * be called on a { @ link SignatureReader } that was created using a < i > ClassSignature < / i > ( such as
 * the < code > signature < / code > parameter of the { @ link org . objectweb . asm . ClassVisitor # visit }
 * method ) or a < i > MethodSignature < / i > ( such as the < code > signature < / code > parameter of the { @ link
 * org . objectweb . asm . ClassVisitor # visitMethod } method ) .
 * @ param signatureVistor the visitor that must visit this signature . */
public void accept ( final SignatureVisitor signatureVistor ) { } }

implementation:
String signature = this . signatureValue ; int length = signature . length ( ) ; int offset ; // Current offset in the parsed signature ( parsed from left to right ) .
char currentChar ; // The signature character at ' offset ' , or just before .
// If the signature starts with ' < ' , it starts with TypeParameters , i . e . a formal type parameter
// identifier , followed by one or more pair ' : ' , ReferenceTypeSignature ( for its class bound and
// interface bounds ) .
if ( signature . charAt ( 0 ) == '<' ) { // Invariant : offset points to the second character of a formal type parameter name at the
// beginning of each iteration of the loop below .
offset = 2 ; do { // The formal type parameter name is everything between offset - 1 and the first ' : ' .
int classBoundStartOffset = signature . indexOf ( ':' , offset ) ; signatureVistor . visitFormalTypeParameter ( signature . substring ( offset - 1 , classBoundStartOffset ) ) ; // If the character after the ' : ' class bound marker is not the start of a
// ReferenceTypeSignature , it means the class bound is empty ( which is a valid case ) .
offset = classBoundStartOffset + 1 ; currentChar = signature . charAt ( offset ) ; if ( currentChar == 'L' || currentChar == '[' || currentChar == 'T' ) { offset = parseType ( signature , offset , signatureVistor . visitClassBound ( ) ) ; } // While the character after the class bound or after the last parsed interface bound
// is ' : ' , we need to parse another interface bound .
while ( ( currentChar = signature . charAt ( offset ++ ) ) == ':' ) { offset = parseType ( signature , offset , signatureVistor . visitInterfaceBound ( ) ) ; } // At this point a TypeParameter has been fully parsed , and we need to parse the next one
// ( note that currentChar is now the first character of the next TypeParameter , and that
// offset points to the second character ) , unless the character just after this
// TypeParameter signals the end of the TypeParameters .
} while ( currentChar != '>' ) ; } else { offset = 0 ; } // If the ( optional ) TypeParameters is followed by ' ( ' this means we are parsing a
// MethodSignature , which has JavaTypeSignature type inside parentheses , followed by a Result
// type and optional ThrowsSignature types .
if ( signature . charAt ( offset ) == '(' ) { offset ++ ; while ( signature . charAt ( offset ) != ')' ) { offset = parseType ( signature , offset , signatureVistor . visitParameterType ( ) ) ; } // Use offset + 1 to skip ' ) ' .
offset = parseType ( signature , offset + 1 , signatureVistor . visitReturnType ( ) ) ; while ( offset < length ) { // Use offset + 1 to skip the first character of a ThrowsSignature , i . e . ' ^ ' .
offset = parseType ( signature , offset + 1 , signatureVistor . visitExceptionType ( ) ) ; } } else { // Otherwise we are parsing a ClassSignature ( by hypothesis on the method input ) , which has
// one or more ClassTypeSignature for the super class and the implemented interfaces .
offset = parseType ( signature , offset , signatureVistor . visitSuperclass ( ) ) ; while ( offset < length ) { offset = parseType ( signature , offset , signatureVistor . visitInterface ( ) ) ; } }