signature:
public class DeclarationFilter { /** * Returns a filter that selects those declarations selected
 * by both this filter and another .
 * @ param f filter to be composed with this one
 * @ return a filter that selects those declarations selected by
 * both this filter and another */
public DeclarationFilter and ( DeclarationFilter f ) { } }

implementation: final DeclarationFilter f1 = this ; final DeclarationFilter f2 = f ; return new DeclarationFilter ( ) { public boolean matches ( Declaration d ) { return f1 . matches ( d ) && f2 . matches ( d ) ; } } ;


signature:
public class DeclarationFilter { /** * Returns a filter that selects those declarations selected
 * by either this filter or another .
 * @ param f filter to be composed with this one
 * @ return a filter that selects those declarations selected by
 * either this filter or another */
public DeclarationFilter or ( DeclarationFilter f ) { } }

implementation: final DeclarationFilter f1 = this ; final DeclarationFilter f2 = f ; return new DeclarationFilter ( ) { public boolean matches ( Declaration d ) { return f1 . matches ( d ) || f2 . matches ( d ) ; } } ;


signature:
public class DeclarationFilter { /** * Returns the declarations matched by this filter .
 * The result is a collection of the same type as the argument ;
 * the { @ linkplain # filter ( Collection , Class ) two - parameter version }
 * of < tt > filter < / tt > offers control over the result type .
 * @ param < D > type of the declarations being filtered
 * @ param decls declarations being filtered
 * @ return the declarations matched by this filter */
public < D extends Declaration > Collection < D > filter ( Collection < D > decls ) { } }

implementation: ArrayList < D > res = new ArrayList < D > ( decls . size ( ) ) ; for ( D d : decls ) { if ( matches ( d ) ) { res . add ( d ) ; } } return res ;


signature:
public class DeclarationFilter { /** * Returns the declarations matched by this filter , with the result
 * being restricted to declarations of a given kind .
 * Similar to the simpler
 * { @ linkplain # filter ( Collection ) single - parameter version }
 * of < tt > filter < / tt > , but the result type is specified explicitly .
 * @ param < D > type of the declarations being returned
 * @ param decls declarations being filtered
 * @ param resType type of the declarations being returned - -
 * the reflective view of < tt > D < / tt >
 * @ return the declarations matched by this filter , restricted to those
 * of the specified type */
public < D extends Declaration > Collection < D > filter ( Collection < ? extends Declaration > decls , Class < D > resType ) { } }

implementation: ArrayList < D > res = new ArrayList < D > ( decls . size ( ) ) ; for ( Declaration d : decls ) { if ( resType . isInstance ( d ) && matches ( d ) ) { res . add ( resType . cast ( d ) ) ; } } return res ;


signature:
public class StringEnumeratedMap { /** * double check for map */
protected Map < String , V > getAsMap ( ) { } }

implementation: Map < String , V > result = map ; if ( result == null ) { synchronized ( this ) { result = map ; if ( result == null ) { map = ( result = initialize ( ) ) ; } } } return result ;


signature:
public class ReflexUtil { /** * Direct writing the object attribute values , the private / protected
 * modifiers will be ignoring , if setter function exist , return setter
 * function value . < p > If recursively is true , will looking from all class
 * hierarchy < / p >
 * @ param object object
 * @ param fieldName field name
 * @ param value value
 * @ param recursively recursively */
public static void setFieldValue ( final Object object , String fieldName , final Object value , boolean recursively ) { } }

implementation:
if ( object == null ) return ; Field field = ClassUtil . getDeclaredField ( object . getClass ( ) , fieldName , recursively ) ; if ( field == null ) { log . debug ( "Could not find field [ {} ] on target [ {} ]" , fieldName , object . getClass ( ) . getSimpleName ( ) ) ; return ; } String methodName = "set" + CommUtil . capitalize ( fieldName ) ; Method method = ClassUtil . getDeclaredMethod ( object . getClass ( ) , recursively , methodName , value == null ? Object . class : value . getClass ( ) ) ; if ( method != null ) { try { makeAccessible ( method ) ; method . invoke ( object , value ) ; return ; } catch ( InvocationTargetException e ) { log . debug ( "Could not find method [ {} ] on target [ {} ]" , methodName , object . getClass ( ) . getSimpleName ( ) ) ; } catch ( NullPointerException e ) { log . debug ( "{} field: [ {} ] is null" , object . getClass ( ) . getSimpleName ( ) , fieldName ) ; } catch ( IllegalAccessException e ) { // Will not happen
} } makeAccessible ( field ) ; try { field . set ( object , value ) ; } catch ( NullPointerException e ) { log . debug ( "{} field: [ {} ] is null" , object . getClass ( ) . getSimpleName ( ) , fieldName ) ; } catch ( IllegalAccessException e ) { // Will not happen
}


signature:
public class ReflexUtil { /** * set constructor is accessible
 * @ param constructor { @ link java . lang . reflect . Constructor }
 * @ param < T > t */
public static < T > void makeAccessible ( final Constructor < T > constructor ) { } }

implementation: if ( ! Modifier . isPublic ( constructor . getModifiers ( ) ) || ! Modifier . isPublic ( constructor . getDeclaringClass ( ) . getModifiers ( ) ) ) { constructor . setAccessible ( true ) ; }


signature:
public class ReflexUtil { /** * obtained the parent class generic parameter types
 * for example :
 * < code >
 * ClassB & lt ; T & gt ; extends ClassA & lt ; T & gt ;
 * < / code >
 * @ param clazz { @ link java . lang . Class }
 * @ return Types */
public static Type [ ] getSuperClassGenricTypes ( final Class < ? > clazz ) { } }

implementation:
Type [ ] temp = { Object . class } ; // eg : ClassA < T >
if ( clazz == null ) return null ; Type type = clazz . getGenericSuperclass ( ) ; if ( type instanceof ParameterizedType ) { return ( ( ParameterizedType ) type ) . getActualTypeArguments ( ) ; } else { log . warn ( "{} 's superclass not ParameterizedType" , clazz ) ; return temp ; }


signature:
public class ReflexUtil { /** * obtained the parent class generic parameter type
 * for example :
 * < code >
 * ClassB & lt ; T & gt ; extends ClassA & lt ; T & gt ;
 * < / code >
 * @ param clazz { @ link java . lang . Class }
 * @ param index
 * start 0
 * @ return Type */
public static Type getSuperClassGenricType ( final Class < ? > clazz , int index ) { } }

implementation: Type [ ] types = getSuperClassGenricTypes ( clazz ) ; if ( index < 0 ) { log . warn ( "{}'s index must be greater than 0,return the 0" , clazz == null ? Object . class . getSimpleName ( ) : clazz . getSimpleName ( ) ) ; return types [ 0 ] ; } else if ( index > types . length ) { log . warn ( "{}'s index in {} not found,return the last" , clazz == null ? Object . class . getSimpleName ( ) : clazz . getSimpleName ( ) , index ) ; return types [ types . length - 1 ] ; } else { return types [ index ] ; }


signature:
public class ReflexUtil { /** * obtained the parent class generic parameter classes
 * for example :
 * < code >
 * ClassB & lt ; T & gt ; extends ClassA & lt ; T & gt ;
 * < / code >
 * @ param clazz { @ link java . lang . Class }
 * @ return Classes */
public static Class < ? > [ ] getSuperClassGenricClasses ( final Class < ? > clazz ) { } }

implementation: Type [ ] types = getSuperClassGenricTypes ( clazz ) ; Class < ? > [ ] clazzs = new Class < ? > [ types . length ] ; for ( int i = 0 ; i < types . length ; i ++ ) { clazzs [ i ] = ( Class < ? > ) types [ i ] ; } return clazzs ;


signature:
public class ReflexUtil { /** * obtained the interface generic parameter types
 * for example :
 * < code >
 * ClassB & lt ; T & gt ; implements ClassA & lt ; T & gt ;
 * < / code >
 * @ param clazz { @ link java . lang . Class }
 * @ return Types */
public static Type [ ] getInterfacesGenricTypes ( final Class < ? > clazz ) { } }

implementation: if ( clazz == null ) return null ; Type [ ] types = clazz . getGenericInterfaces ( ) ; Type [ ] gtypes = new Type [ 0 ] ; for ( Type t : types ) { if ( t instanceof ParameterizedType ) { Type [ ] gts = ( ( ParameterizedType ) t ) . getActualTypeArguments ( ) ; int olen = gtypes . length ; int ilen = gts . length ; Type [ ] tmp = new Type [ olen + ilen ] ; System . arraycopy ( gtypes , 0 , tmp , 0 , olen ) ; System . arraycopy ( gts , 0 , tmp , olen , ilen ) ; gtypes = tmp ; } } return gtypes ;


signature:
public class ReflexUtil { /** * obtained the interface generic parameter type
 * for example :
 * < code >
 * ClassB & lt ; T & gt ; implements ClassA & lt ; T & gt ;
 * < / code >
 * @ param clazz { @ link java . lang . Class }
 * @ param index
 * start 0
 * @ return Type */
public static Type getInterfacesGenricType ( final Class < ? > clazz , int index ) { } }

implementation: Type [ ] types = getInterfacesGenricTypes ( clazz ) ; if ( index < 0 ) { log . warn ( "{}'s index must be greater than 0,return the 0" , clazz == null ? Object . class . getSimpleName ( ) : clazz . getSimpleName ( ) ) ; return types [ 0 ] ; } else if ( index > types . length ) { log . warn ( "{}'s index in {} not found,return the last" , clazz == null ? Object . class . getSimpleName ( ) : clazz . getSimpleName ( ) , index ) ; return types [ types . length - 1 ] ; } else { return types [ index ] ; }


signature:
public class ReflexUtil { /** * obtained the interface generic parameter classes
 * for example :
 * < code >
 * ClassB & lt ; T & gt ; implements ClassA & lt ; T & gt ;
 * < / code >
 * @ param clazz { @ link java . lang . Class }
 * @ return Classes */
public static Class < ? > [ ] getInterfacesGenricClasses ( final Class < ? > clazz ) { } }

implementation: Type [ ] types = getInterfacesGenricTypes ( clazz ) ; Class < ? > [ ] clazzs = new Class < ? > [ types . length ] ; for ( int i = 0 ; i < types . length ; i ++ ) { clazzs [ i ] = ( Class < ? > ) types [ i ] ; } return clazzs ;


signature:
public class ReflexUtil { /** * Create new instance of specified class and type from a map < p > < b > note :
 * clazz must write setter < / b > < / p >
 * @ param clazz { @ link java . lang . Class }
 * @ param paramsMap
 * attributes
 * @ param accessible accesible
 * @ param < T > t
 * @ return instance */
public static < T > T getBasicInstance ( final Class < T > clazz , final Map < String , Object > paramsMap , boolean accessible ) { } }

implementation: if ( clazz != null && paramsMap != null && paramsMap . size ( ) > 0 ) { T instance = ClassUtil . getInstance ( clazz , accessible ) ; for ( Map . Entry < String , Object > entry : paramsMap . entrySet ( ) ) { String key = entry . getKey ( ) ; if ( CommUtil . isBlank ( key ) ) { continue ; } key = CommUtil . uncapitalize ( key ) ; setFieldValue ( instance , key , entry . getValue ( ) , false ) ; } return instance ; } else { return null ; }


signature:
public class ZipDestinationPropertyView { /** * Add your property controls to this panel .
 * Remember to set your own layout manager .
 * Also , remember to create a new JPanel , and pass it to the super class
 * so controls of the superclass can be included .
 * You have a 3 x 3 grid , so add three columns for each control
 * @ param panel This is the panel to add your controls to . */
public void addControlsToView ( JPanel panel ) { } }

implementation: panel . setLayout ( new BorderLayout ( ) ) ; JPanel panelMain = this . makeNewPanel ( panel , BorderLayout . CENTER ) ; panelMain . setLayout ( new GridLayout ( 3 , 2 ) ) ; panelMain . add ( new JLabel ( "Zip directory: " , JLabel . RIGHT ) ) ; panelMain . add ( m_tfRootPathname = new JTextField ( ) ) ; panelMain . add ( new JLabel ( "Zip filename: " , JLabel . RIGHT ) ) ; panelMain . add ( m_tfFilename = new JTextField ( ) ) ; panelMain . add ( new JLabel ( "Max size: " , JLabel . RIGHT ) ) ; panelMain . add ( m_tfMaxSize = new JTextField ( ) ) ; JPanel panelSub = this . makeNewPanel ( panel , BorderLayout . SOUTH ) ; super . addControlsToView ( panelSub ) ;


signature:
public class ZipDestinationPropertyView { /** * Set the properties to the current control values . */
public void controlsToProperties ( ) { } }

implementation: super . controlsToProperties ( ) ; String strPathname = m_tfRootPathname . getText ( ) ; m_properties . setProperty ( ZIPOUT_PATHNAME_PARAM , strPathname ) ; String strFilename = m_tfFilename . getText ( ) ; m_properties . setProperty ( ZIPOUT_FILENAME_PARAM , strFilename ) ; String strMaxSize = m_tfMaxSize . getText ( ) ; m_properties . setProperty ( MAX_SIZE_PARAM , strMaxSize ) ;


signature:
public class ZipDestinationPropertyView { /** * Set the properties to the current control values . */
public void propertiesToControls ( ) { } }

implementation: super . propertiesToControls ( ) ; String strPathname = m_properties . getProperty ( ZIPOUT_PATHNAME_PARAM ) ; m_tfRootPathname . setText ( strPathname ) ; String strFilename = m_properties . getProperty ( ZIPOUT_FILENAME_PARAM ) ; m_tfFilename . setText ( strFilename ) ; String strMaxSize = m_properties . getProperty ( MAX_SIZE_PARAM ) ; m_tfMaxSize . setText ( strMaxSize ) ;


signature:
public class FilesystemDestination { /** * Set up everything to start processing */
public void init ( Properties properties ) { } }

implementation: super . init ( properties ) ; String strPathname = properties . getProperty ( DEST_ROOT_PATHNAME_PARAM ) ; if ( strPathname == null ) { strPathname = System . getProperties ( ) . getProperty ( "java.io.tmpdir" , "c:/Temp" ) ; if ( strPathname != null ) if ( ! strPathname . endsWith ( File . separator ) ) strPathname += File . separator ; properties . setProperty ( DEST_ROOT_PATHNAME_PARAM , strPathname ) ; }


signature:
public class FilesystemDestination { /** * Set up everything to start processing */
public void initTransfer ( Properties properties ) { } }

implementation:
super . initTransfer ( properties ) ; m_strPathname = properties . getProperty ( DEST_ROOT_PATHNAME_PARAM ) ; if ( ( m_strPathname == null ) || ( m_strPathname . length ( ) == 0 ) ) m_strPathname = "" ; // No prefix
else if ( ( m_strPathname . lastIndexOf ( System . getProperties ( ) . getProperty ( "file.separator" ) ) != m_strPathname . length ( ) - 1 ) && ( m_strPathname . lastIndexOf ( '/' ) != m_strPathname . length ( ) - 1 ) ) m_strPathname += System . getProperties ( ) . getProperty ( "file.separator" ) ; // Must end in a path separator


signature:
public class FilesystemDestination { /** * Add this file to the destination .
 * Note : Only supply the file or the stream , not both . Supply the object that is easier , given
 * the source . This dual option is given to allow destinations that require File objects from
 * ( such as FTP or HTTP ) Having to write the inStream to a physical file before processing it .
 * @ param file Source file .
 * @ param inStream Source stream .
 * @ param strpath Full path of the source file ( including the filename ) .
 * @ param strFilename Filename .
 * @ param lStreamLength Length of the stream ( - 1 if unknown ) . */
public long addNextFile ( SourceFile source ) { } }

implementation: String strPath = source . getFilePath ( ) ; long lStreamLength = source . getStreamLength ( ) ; InputStream inStream = source . makeInStream ( ) ; try { strPath = m_strPathname + strPath ; File file = new File ( strPath ) ; file . mkdirs ( ) ; if ( file . exists ( ) ) file . delete ( ) ; file . createNewFile ( ) ; OutputStream outStream = new FileOutputStream ( file ) ; lStreamLength = Util . copyStream ( inStream , outStream ) ; outStream . close ( ) ; } catch ( IOException ex ) { ex . printStackTrace ( ) ; } return lStreamLength ;


signature:
public class BaseSource { /** * Set up everything to start processing */
public void initTransfer ( Properties properties ) { } }

implementation:
boolean bIncremental = false ; String strSelected = properties . getProperty ( BACKUP_INCREMENTAL_PARAM ) ; if ( TRUE . equalsIgnoreCase ( strSelected ) ) bIncremental = true ; String strDate = properties . getProperty ( BACKUPDATE_PARAM ) ; if ( bIncremental ) // If incremental , set the " filter date " .
m_dateLastBackup = Util . stringToDate ( strDate ) ; m_Filter = Util . makeFilter ( properties ) ;


signature:
public class BaseSource { /** * Close everything down after processing . */
public void finishTransfer ( Properties properties ) { } }

implementation: String strDateLastBackup = Util . dateToString ( new Date ( ) ) ; properties . setProperty ( BACKUPDATE_PARAM , strDateLastBackup ) ;


signature:
public class BaseSource { /** * Returns < tt > true < / tt > if the iteration has more elements . ( In other
 * words , returns < tt > true < / tt > if < tt > next < / tt > would return an element
 * rather than throwing an exception . )
 * @ return < tt > true < / tt > if the iterator has more elements . */
public boolean hasNext ( ) { } }

implementation: if ( m_nextPend != null ) return true ; m_nextPend = this . next ( ) ; if ( m_nextPend == null ) return false ; else return true ;


signature:
public class BaseSource { /** * Should I skip this file ?
 * Override this . */
public boolean skipFile ( File inFile ) { } }

implementation:
if ( m_dateLastBackup != null ) { // Check the date
Date dateLastMod = new Date ( inFile . lastModified ( ) ) ; if ( dateLastMod . before ( m_dateLastBackup ) ) return true ; // Skip it
} return false ; // Don ' t skip it


signature:
public class DebugDestinationPropertyView { /** * Add your property controls to this panel .
 * Remember to set your own layout manager .
 * Also , remember to create a new JPanel , and pass it to the super class
 * so controls of the superclass can be included .
 * You have a 3 x 3 grid , so add three columns for each control
 * @ param panel This is the panel to add your controls to . */
public void addControlsToView ( JPanel panel ) { } }

implementation: panel . setLayout ( new BorderLayout ( ) ) ; JPanel panelMain = this . makeNewPanel ( panel , BorderLayout . CENTER ) ; panelMain . setLayout ( new GridLayout ( 1 , 2 ) ) ; panelMain . add ( new JLabel ( "Log filename: " , JLabel . RIGHT ) ) ; panelMain . add ( m_tfLogFilename = new JTextField ( ) ) ; panelMain . add ( m_cbFileLength = new JCheckBox ( "Calc file length?" ) ) ; JPanel panelSub = this . makeNewPanel ( panel , BorderLayout . SOUTH ) ; super . addControlsToView ( panelSub ) ;


signature:
public class DebugDestinationPropertyView { /** * Set the properties to the current control values . */
public void controlsToProperties ( ) { } }

implementation: super . controlsToProperties ( ) ; String strPathname = m_tfLogFilename . getText ( ) ; m_properties . setProperty ( LOG_FILENAME_PARAM , strPathname ) ; boolean bSelected = m_cbFileLength . isSelected ( ) ; if ( bSelected ) m_properties . setProperty ( CALC_FILE_LENGTH_PARAM , TRUE ) ; else m_properties . setProperty ( CALC_FILE_LENGTH_PARAM , FALSE ) ;


signature:
public class DebugDestinationPropertyView { /** * Set the properties to the current control values . */
public void propertiesToControls ( ) { } }

implementation: super . propertiesToControls ( ) ; String strPathname = m_properties . getProperty ( LOG_FILENAME_PARAM ) ; m_tfLogFilename . setText ( strPathname ) ; boolean bSelected = true ; String strSelected = m_properties . getProperty ( CALC_FILE_LENGTH_PARAM ) ; if ( FALSE . equalsIgnoreCase ( strSelected ) ) bSelected = false ; m_cbFileLength . setSelected ( bSelected ) ;


signature:
public class DbHelper { /** * 启动一个事务 ( 默认支持子事务 ) */
public Transaction transaction ( ) { } }

implementation: if ( transationHandler . get ( ) != null ) { if ( ALLOW_NESTED_TRANSACTION ) { return new JdbcNestedTransaction ( transationHandler . get ( ) . getConnection ( ) ) ; } throw new TransactionException ( "Can't begin a nested transaction." ) ; } try { JdbcTransaction tx = new JdbcTransaction ( dataSource . getConnection ( ) , transationHandler ) ; transationHandler . set ( tx ) ; return tx ; } catch ( SQLException e ) { throw new TransactionException ( e ) ; }


signature:
public class DbHelper { /** * 获取一个当前线程的连接 ( 事务中 ) , 如果没有 , 则新建一个 。 */
private Connection getConnection ( ) { } }

implementation: JdbcTransaction tx = transationHandler . get ( ) ; try { if ( tx == null ) { return dataSource . getConnection ( ) ; } else { return tx . getConnection ( ) ; } } catch ( SQLException e ) { throw new DbException ( e ) ; }


signature:
public class DbHelper { /** * 判断表是否已经存在 */
public boolean tableExist ( String name ) { } }

implementation: Connection conn = null ; ResultSet rs = null ; try { conn = getConnection ( ) ; DatabaseMetaData metaData = conn . getMetaData ( ) ; rs = metaData . getTables ( null , null , name . toUpperCase ( ) , new String [ ] { "TABLE" } ) ; return rs . next ( ) ; } catch ( SQLException e ) { throw new DbException ( e ) ; } finally { DbUtils . closeQuietly ( rs ) ; closeConnection ( conn ) ; }


signature:
public class JaasBasedConnPropsBuilder { /** * Initialize a set of connection properties based on key / values in a < code > HashMap < / code > .
 * @ param properties A < code > HashMap < / code > with configuration properties as required by the init ( ) method in JAAS ,
 * using the keys as specified in this class
 * @ return A < code > ConnectionProperties < / code > object with default values , plus the provided parameters
 * @ throws NullPointerException When { @ code properties } is { @ code null } */
public static ConnectionProperties build ( final Map < String , ? > properties ) { } }

implementation:
Validate . notNull ( properties , "The validated object 'properties' is null" ) ; // tmpConfig now holds all the configuration values with the keys expected by the Util libs connection
// properties builder . We will let that library do all the hard work of setting reasonable defaults and
// dealing with null values .
// For this , we first try to copy the entire map to a Map < String , String > map ( because this is what the builder
// we will be using requires ) , and then ALSO copy the values that are in the Map and that we care about to the
// same map , potentially overwriting values that may already be there ( e . g . if the user has configured them
// under a key that coincidentally collides with a key that we care about ) .
final Map < String , String > tmpConfig = new ConcurrentHashMap < > ( ) ; // first try to copy all the values in the map . We know that they are all of the same type , but we do not know
// what that type is . Let ' s reasonably assume that they are Strings ( not sure if the JAAS configuration
// mechanism allows anything else ) , and just cast them . If the cast fails , we will fail the entire operation :
try { for ( final Map . Entry < String , ? > entry : properties . entrySet ( ) ) { final String key = entry . getKey ( ) ; final String value = ( String ) entry . getValue ( ) ; if ( value != null ) { tmpConfig . put ( key , value ) ; } } } catch ( ClassCastException e ) { final String error = "The values of the configured JAAS properties must be Strings. " + "Sorry, but we do not support anything else here!" ; throw new IllegalArgumentException ( error , e ) ; } // second , we copy the values that we care about from the " JAAS config namespace " to the " Connection namespace " :
copyValue ( properties , KEY_DRIVER , tmpConfig , MapBasedConnPropsBuilder . KEY_DRIVER ) ; copyValue ( properties , KEY_URL , tmpConfig , MapBasedConnPropsBuilder . KEY_URL ) ; copyValue ( properties , KEY_USERNAME , tmpConfig , MapBasedConnPropsBuilder . KEY_USERNAME ) ; copyValue ( properties , KEY_PASSWORD , tmpConfig , MapBasedConnPropsBuilder . KEY_PASSWORD ) ; copyValue ( properties , KEY_MAX_TOTAL , tmpConfig , MapBasedConnPropsBuilder . KEY_MAX_TOTAL ) ; copyValue ( properties , KEY_MAX_IDLE , tmpConfig , MapBasedConnPropsBuilder . KEY_MAX_IDLE ) ; copyValue ( properties , KEY_MIN_IDLE , tmpConfig , MapBasedConnPropsBuilder . KEY_MIN_IDLE ) ; copyValue ( properties , KEY_MAX_WAIT_MILLIS , tmpConfig , MapBasedConnPropsBuilder . KEY_MAX_WAIT_MILLIS ) ; copyValue ( properties , KEY_TEST_ON_CREATE , tmpConfig , MapBasedConnPropsBuilder . KEY_TEST_ON_CREATE ) ; copyValue ( properties , KEY_TEST_ON_BORROW , tmpConfig , MapBasedConnPropsBuilder . KEY_TEST_ON_BORROW ) ; copyValue ( properties , KEY_TEST_ON_RETURN , tmpConfig , MapBasedConnPropsBuilder . KEY_TEST_ON_RETURN ) ; copyValue ( properties , KEY_TEST_WHILE_IDLE , tmpConfig , MapBasedConnPropsBuilder . KEY_TEST_WHILE_IDLE ) ; copyValue ( properties , KEY_TIME_BETWEEN_EVICTION_RUNS_MILLIS , tmpConfig , MapBasedConnPropsBuilder . KEY_TIME_BETWEEN_EVICTION_RUNS_MILLIS ) ; copyValue ( properties , KEY_NUM_TESTS_PER_EVICITON_RUN , tmpConfig , MapBasedConnPropsBuilder . KEY_NUM_TESTS_PER_EVICITON_RUN ) ; copyValue ( properties , KEY_MIN_EVICTABLE_IDLE_TIME_MILLIS , tmpConfig , MapBasedConnPropsBuilder . KEY_MIN_EVICTABLE_IDLE_TIME_MILLIS ) ; copyValue ( properties , KEY_SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS , tmpConfig , MapBasedConnPropsBuilder . KEY_SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS ) ; copyValue ( properties , KEY_LIFO , tmpConfig , MapBasedConnPropsBuilder . KEY_LIFO ) ; copyValue ( properties , KEY_AUTO_COMMIT , tmpConfig , MapBasedConnPropsBuilder . KEY_AUTO_COMMIT ) ; copyValue ( properties , KEY_READ_ONLY , tmpConfig , MapBasedConnPropsBuilder . KEY_READ_ONLY ) ; copyValue ( properties , KEY_TRANSACTION_ISOLATION , tmpConfig , MapBasedConnPropsBuilder . KEY_TRANSACTION_ISOLATION ) ; copyValue ( properties , KEY_CACHE_STATE , tmpConfig , MapBasedConnPropsBuilder . KEY_CACHE_STATE ) ; copyValue ( properties , KEY_VALIDATION_QUERY , tmpConfig , MapBasedConnPropsBuilder . KEY_VALIDATION_QUERY ) ; copyValue ( properties , KEY_MAX_CONN_LIFETIME_MILLIS , tmpConfig , MapBasedConnPropsBuilder . KEY_MAX_CONN_LIFETIME_MILLIS ) ; return MapBasedConnPropsBuilder . build ( tmpConfig ) ;


signature:
public class JaasBasedConnPropsBuilder { /** * Copy the value of a specific key in a source map to a specific key in a target map .
 * The method checks if the value assigned to the source key is < code > null < / code > , and does not copy it if it is
 * < code > null < / code > .
 * @ param sourceMap The source map to copy from
 * @ param sourceKey The source key to copy from
 * @ param targetMap The target map to copy to
 * @ param targetKey The target key to copy to */
private static void copyValue ( final Map < String , ? > sourceMap , final String sourceKey , final Map < String , String > targetMap , final String targetKey ) { } }

implementation: if ( getOption ( sourceKey , sourceMap ) != null && String . class . isInstance ( getOption ( sourceKey , sourceMap ) ) ) { targetMap . put ( targetKey , ( String ) getOption ( sourceKey , sourceMap ) ) ; }


signature:
public class ZipDestination { /** * Get everything ready . */
public void init ( Properties properties ) { } }

implementation: super . init ( properties ) ; String strPathname = properties . getProperty ( ZIPOUT_PATHNAME_PARAM ) ; if ( strPathname == null ) { strPathname = System . getProperties ( ) . getProperty ( "java.io.tmpdir" , "c:/Temp" ) ; properties . setProperty ( ZIPOUT_PATHNAME_PARAM , strPathname ) ; } String strFilename = properties . getProperty ( ZIPOUT_FILENAME_PARAM ) ; if ( strFilename == null ) { strFilename = "[automatic]" ; properties . setProperty ( ZIPOUT_FILENAME_PARAM , strFilename ) ; }


signature:
public class ZipDestination { /** * Set up everything to start processing */
public void initTransfer ( Properties properties ) { } }

implementation: super . initTransfer ( properties ) ; String strPathname = properties . getProperty ( ZIPOUT_PATHNAME_PARAM ) ; if ( ( strPathname != null ) && ( strPathname . length ( ) > 0 ) && ( strPathname . lastIndexOf ( System . getProperties ( ) . getProperty ( "file.separator" ) ) == strPathname . length ( ) - 1 ) && ( strPathname . lastIndexOf ( '/' ) == strPathname . length ( ) - 1 ) ) strPathname += System . getProperties ( ) . getProperty ( "file.separator" ) ; m_strZipFilename = properties . getProperty ( ZIPOUT_FILENAME_PARAM ) ; if ( ( m_strZipFilename == null ) || ( m_strZipFilename . length ( ) == 0 ) || ( m_strZipFilename . equals ( "[automatic]" ) ) ) m_strZipFilename = this . getBackupFilename ( ) ; if ( strPathname != null ) m_strZipFilename = strPathname + m_strZipFilename ; String strMaxSize = properties . getProperty ( MAX_SIZE_PARAM ) ; m_lMaxZipFileSize = 0 ; try { if ( strMaxSize != null ) m_lMaxZipFileSize = Long . parseLong ( strMaxSize ) ; } catch ( NumberFormatException ex ) { m_lMaxZipFileSize = 0 ; } m_lCurrentLength = 0 ; m_iFileNumber = 0 ; try { FileOutputStream outStream = new FileOutputStream ( m_strZipFilename ) ; m_outZip = new ZipOutputStream ( outStream ) ; } catch ( IOException ex ) { ex . printStackTrace ( ) ; }


signature:
public class ZipDestination { /** * Close everything down after processing . */
public void finishTransfer ( Properties properties ) { } }

implementation: try { m_outZip . flush ( ) ; m_outZip . close ( ) ; } catch ( FileNotFoundException ex ) { ex . printStackTrace ( ) ; } catch ( IOException ex ) { ex . printStackTrace ( ) ; } super . finishTransfer ( properties ) ;


signature:
public class ZipDestination { /** * Add this file to the destination .
 * Note : Only supply the file or the stream , not both . Supply the object that is easier , given
 * the source . This dual option is given to allow destinations that require File objects from
 * ( such as FTP or HTTP ) Having to write the inStream to a physical file before processing it .
 * @ param file Source file .
 * @ param inStream Source stream .
 * @ param strpath Full path of the source file ( including the filename ) .
 * @ param strFilename Filename .
 * @ param lStreamLength Length of the stream ( - 1 if unknown ) . */
public long addNextFile ( SourceFile source ) { } }

implementation:
String strPath = source . getFilePath ( ) ; long lStreamLength = source . getStreamLength ( ) ; InputStream inStream = source . makeInStream ( ) ; long lLength = 0 ; try { if ( m_lMaxZipFileSize > 0 ) // ? if ( lLength ! = File . OL )
{ // Check to make sure this file will fit
if ( m_lCurrentLength + lStreamLength > m_lMaxZipFileSize ) { // Writing this file would push me past the file length limit
try { m_outZip . flush ( ) ; m_outZip . close ( ) ; m_lCurrentLength = 0 ; m_iFileNumber ++ ; int iPosDot = m_strZipFilename . lastIndexOf ( '.' ) ; if ( iPosDot == - 1 ) iPosDot = m_strZipFilename . length ( ) ; String strZipFilename = m_strZipFilename . substring ( 0 , iPosDot ) ; strZipFilename += Integer . toString ( m_iFileNumber ) ; if ( iPosDot != m_strZipFilename . length ( ) ) strZipFilename += m_strZipFilename . substring ( iPosDot ) ; FileOutputStream outStream = new FileOutputStream ( strZipFilename ) ; m_outZip = new ZipOutputStream ( outStream ) ; } catch ( FileNotFoundException ex ) { ex . printStackTrace ( ) ; } catch ( IOException ex ) { ex . printStackTrace ( ) ; } } } ZipEntry zipEntry = new ZipEntry ( strPath ) ; if ( DEBUG ) System . out . println ( strPath ) ; m_outZip . putNextEntry ( zipEntry ) ; lLength = Util . copyStream ( inStream , m_outZip ) ; m_lCurrentLength += lLength ; } catch ( IOException ex ) { ex . printStackTrace ( ) ; } return lLength ;


signature:
public class ZipDestination { /** * Add the files to the backup file */
public String getBackupFilename ( ) { } }

implementation: Date now = new Date ( ) ; String strDate = Util . dateToString ( now ) ; for ( int i = 0 ; i < strDate . length ( ) ; i ++ ) { char ch = strDate . charAt ( i ) ; if ( ! Character . isLetterOrDigit ( ch ) ) strDate = strDate . substring ( 0 , i ) + '_' + strDate . substring ( i + 1 , strDate . length ( ) ) ; } return "backup" + strDate + ".zip" ;


signature:
public class CopyOnWriteMap { /** * Adds the provided key and value to this map .
 * @ see java . util . Map # put ( java . lang . Object , java . lang . Object ) */
@ Override public V put ( K key , V value ) { } }

implementation: synchronized ( this ) { Map < K , V > newMap = new HashMap < K , V > ( internalMap ) ; V val = newMap . put ( key , value ) ; internalMap = newMap ; return val ; }


signature:
public class CopyOnWriteMap { /** * Removed the value and key from this map based on the
 * provided key .
 * @ see java . util . Map # remove ( java . lang . Object ) */
@ Override public V remove ( Object key ) { } }

implementation: synchronized ( this ) { Map < K , V > newMap = new HashMap < K , V > ( internalMap ) ; V val = newMap . remove ( key ) ; internalMap = newMap ; return val ; }


signature:
public class UrlTemplate { /** * 和实际的 URL 进行匹配 , 并返回成功匹配的参数 ( pathVariables ) */
public boolean match ( String [ ] urlSegments , PathVariables pathVariables ) { } }

implementation:
Validate . isTrue ( urlSegments . length == matchers . length ) ; for ( int i = 1 ; i < matchers . length ; i ++ ) { if ( ! matchers [ i ] . match ( urlSegments [ i ] , pathVariables ) ) { pathVariables . clear ( ) ; // 注意 : 不匹配的情况下 , 需要清除此次匹配的内容
return false ; } } return true ;


signature:
public class AuditHelper { /** * Audit an event ( during a login workflow ) .
 * If { @ code audit } is { @ code null } , then auditing is considered disabled
 * @ param audit The audit object to use for auditing the event
 * @ param domain The user ' s domain
 * @ param username The user ' s username
 * * @ param event The event to audit
 * @ param error The error message to be logged in the application log if auditing fails ( i . e . no audit message
 * can be created )
 * @ throws LoginException If auditing fails ( i . e . no audit message can be created )
 * @ throws NullPointerException When the { @ code domain } , { @ code username } , { @ code event } , or { @ code error } are
 * { @ code null }
 * @ throws IllegalArgumentException When { @ code domain } , { @ code username } , or { @ code error } are empty */
public static void auditEvent ( final Audit audit , final String domain , final String username , final Events event , final String error ) throws LoginException { } }

implementation:
// " audit " may be null , not validating here ( see below )
Validate . notBlank ( domain , "The validated character sequence 'domain' is null or empty" ) ; Validate . notBlank ( username , "The validated character sequence 'username' is null or empty" ) ; Validate . notNull ( event , "The validated object 'event' is null" ) ; Validate . notBlank ( error , "The validated character sequence 'error' is null or empty" ) ; // if auditing is disabled , the audit object will not have been initialized
if ( audit == null ) { // string concatenation is only executed if log level is actually enabled
if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "Auditing has been disabled, not creating event '" + event . getValue ( ) + "' for '" + username + "@" + domain + "'" ) ; } } else { try { audit . audit ( event , domain , username ) ; } catch ( AuditException e ) { LOG . warn ( error , e ) ; throw Util . newLoginException ( error , e ) ; } }


signature:
public class Scanner { /** * Standalone support .
 * Usually you specify a property file to use ( ie . , property . filename = c : \ \ temp \ \ updatesite . properties ) */
public static void main ( String [ ] args ) { } }

implementation:
Properties properties = new Properties ( ) ; if ( args != null ) { // Move the args to a property file
for ( int i = 0 ; i < args . length ; i ++ ) { int iEquals = args [ i ] . indexOf ( '=' ) ; if ( iEquals != - 1 ) if ( iEquals < args [ i ] . length ( ) - 1 ) properties . setProperty ( args [ i ] . substring ( 0 , iEquals ) , args [ i ] . substring ( iEquals + 1 ) ) ; } } String strPropertyFileName = properties . getProperty ( PROPERTY_FILENAME_PARAM ) ; if ( strPropertyFileName != null ) { Properties propertiesRead = AppUtilities . readProperties ( strPropertyFileName ) ; propertiesRead . putAll ( properties ) ; // Add the read - in properties
properties = propertiesRead ; } Scanner scanner = new Scanner ( properties ) ; scanner . run ( ) ; AppUtilities . writeProperties ( strPropertyFileName , properties ) ;


signature:
public class Scanner { /** * Move files from the source to the destination . */
public void run ( ) { } }

implementation: if ( m_properties == null ) { System . out . println ( "Must supply properties." ) ; return ; } String strSourceClass = m_properties . getProperty ( SOURCE_PARAM ) ; String strDestinationClass = m_properties . getProperty ( DESTINATION_PARAM ) ; if ( ( strSourceClass == null ) || ( strDestinationClass == null ) ) { System . out . println ( "Must supply source and destination class names." ) ; return ; } SourceFileList sourceList = ( SourceFileList ) Util . makeObjectFromClassName ( Object . class . getName ( ) , "source" , strSourceClass ) ; DestinationFile destination = ( DestinationFile ) Util . makeObjectFromClassName ( Object . class . getName ( ) , "destination" , strDestinationClass ) ; this . process ( sourceList , destination ) ;


signature:
public class Scanner { /** * Move files from the source to the destination . */
public void process ( SourceFileList sourceList , DestinationFile destination ) { } }

implementation:
sourceList . initTransfer ( m_properties ) ; destination . initTransfer ( m_properties ) ; // FilesystemSource ( " c : \ \ My Documents " ) ;
// DebugDestination ( null ) ;
// ZipDestination ( " test . zip " , - 1 ) ;
while ( sourceList . hasNext ( ) ) { SourceFile source = sourceList . next ( ) ; this . moveFile ( source , destination ) ; // ? source . close ( ) ;
// System . out . println ( source . getFileName ( ) ) ;
} destination . finishTransfer ( m_properties ) ; sourceList . finishTransfer ( m_properties ) ;


signature:
public class ObjectQueryPreparer { /** * Prepare to query the given object .
 * @ param obj the object to prepare ; must be annotated appropriately with @ MBeanLocation on the class and
 * @ MBeanAttribute on setter methods .
 * @ return the results of the prepared object .
 * @ throws MalformedObjectNameException
 * @ see com . amlinv . jmxutil . annotation . MBeanLocation
 * @ see com . amlinv . jmxutil . annotation . MBeanAttribute */
public ObjectQueryInfo prepareObjectQuery ( Object obj ) throws MalformedObjectNameException { } }

implementation:
ObjectQueryInfo result ; // Extract the mbean info from the object ( TBD : cache this information ahead of time )
String onamePattern = MBeanAnnotationUtil . getLocationONamePattern ( obj ) ; if ( onamePattern != null ) { // Locate the setters and continue only if at least one was found .
Map < String , Method > attributeSetters = MBeanAnnotationUtil . getAttributes ( obj ) ; if ( attributeSetters . size ( ) > 0 ) { String onameString ; if ( obj instanceof MBeanLocationParameterSource ) { onameString = this . parameterReplacer . replaceObjectNameParameters ( onamePattern , ( MBeanLocationParameterSource ) obj ) ; } else { onameString = onamePattern ; } ObjectName oname = new ObjectName ( onameString ) ; result = new ObjectQueryInfo ( obj , oname , attributeSetters ) ; } else { this . logNoAttributeThrottle . warn ( log , "ignoring attempt to prepare to poll an MBean object with no attributes: onamePattern={}" , onamePattern ) ; result = null ; } } else { log . warn ( "ignoring attempt to prepare to poll object that has no MBeanLocation" ) ; result = null ; } return result ;


signature:
public class Util { /** * replaces slashes with hyphens and removes padding =
 * @ param origin
 * @ return */
public static String replaceSlashWithHyphen ( String origin ) { } }

implementation: char [ ] resulltChars = origin . toCharArray ( ) ; for ( int i = 0 ; i < resulltChars . length - 1 ; i ++ ) { if ( resulltChars [ i ] == '/' ) { resulltChars [ i ] = '-' ; } } return new String ( resulltChars , 0 , resulltChars . length - 1 ) ;


signature:
public class Util { /** * Converts an array of bytes to a string of two digits hex - representations
 * @ param bytes
 * @ return */
public static String bytes2HexString ( byte [ ] bytes ) { } }

implementation: StringBuffer resultBuffer = new StringBuffer ( ) ; for ( int i = 0 ; i < bytes . length ; i ++ ) { resultBuffer . append ( byte2Hex ( bytes [ i ] ) ) ; } return resultBuffer . toString ( ) ;


signature:
public class SrvEntityReaderXml { /** * Read entity ( fill fields ) from a stream ( reader - file or through network ) .
 * It is invoked when it ' s start of & lt ; entity
 * @ param pAddParam additional params
 * @ param pReader reader .
 * @ return entity filled / refreshed .
 * @ throws Exception - an exception */
@ Override public final Object read ( final Map < String , Object > pAddParam , final Reader pReader ) throws Exception { } }

implementation: Map < String , String > attributesMap = readAttributes ( pAddParam , pReader ) ; if ( attributesMap . get ( "class" ) == null ) { throw new ExceptionWithCode ( ExceptionWithCode . CONFIGURATION_MISTAKE , "There is no class attribute for entity!" ) ; } Class entityClass = Class . forName ( attributesMap . get ( "class" ) ) ; @ SuppressWarnings ( "unchecked" ) Constructor constructor = entityClass . getDeclaredConstructor ( ) ; Object entity = constructor . newInstance ( ) ; Map < String , Map < String , String > > fieldsSettingsMap = getMngSettings ( ) . lazFldsSts ( entityClass ) ; for ( Map . Entry < String , Map < String , String > > entry : fieldsSettingsMap . entrySet ( ) ) { if ( "true" . equals ( entry . getValue ( ) . get ( "isEnabled" ) ) && attributesMap . get ( entry . getKey ( ) ) != null ) { ISrvEntityFieldFiller srvEntityFieldFiller = getFieldsFillersMap ( ) . get ( entry . getValue ( ) . get ( "ISrvEntityFieldFiller" ) ) ; if ( srvEntityFieldFiller == null ) { throw new ExceptionWithCode ( ExceptionWithCode . CONFIGURATION_MISTAKE , "There is no ISrvEntityFieldFiller " + entry . getValue ( ) . get ( "ISrvEntityFieldFiller" ) + " for " + entityClass + " / " + entry . getKey ( ) ) ; } srvEntityFieldFiller . fill ( pAddParam , entity , entry . getKey ( ) , attributesMap . get ( entry . getKey ( ) ) ) ; } } return entity ;


signature:
public class SrvEntityReaderXml { /** * Read entity attributes from stream .
 * @ param pAddParam additional params
 * @ param pReader reader .
 * @ return attributes map
 * @ throws Exception - an exception */
@ Override public final Map < String , String > readAttributes ( final Map < String , Object > pAddParam , final Reader pReader ) throws Exception { } }

implementation: return this . utilXml . readAttributes ( pReader , pAddParam ) ;


signature:
public class NamedParameterStatement { /** * Returns the indexes for a parameter .
 * @ param name parameter name
 * @ return parameter indexes
 * @ throws IllegalArgumentException if the parameter does not exist */
private List < Integer > getIndexes ( String name ) { } }

implementation: List < Integer > indexes = nameIndexMap . get ( name ) ; if ( indexes == null ) { throw new IllegalArgumentException ( "Parameter not found: " + name ) ; } return indexes ;


signature:
public class NamedParameterStatement { /** * Parses a sql with named parameters . The parameter - index mappings
 * are put into the map , and the parsed sql is returned .
 * @ param sql sql with named parameters
 * @ return the parsed sql */
private static String parseNamedSql ( String sql , Map < String , List < Integer > > nameIndexMap ) { } }

implementation:
// I was originally using regular expressions , but they didn ' t work well for ignoring
// parameter - like strings inside quotes .
int length = sql . length ( ) ; StringBuffer parsedSql = new StringBuffer ( length ) ; boolean inSingleQuote = false ; boolean inDoubleQuote = false ; int index = 1 ; for ( int i = 0 ; i < length ; i ++ ) { char c = sql . charAt ( i ) ; if ( inSingleQuote ) { if ( c == '\'' ) { inSingleQuote = false ; } } else if ( inDoubleQuote ) { if ( c == '"' ) { inDoubleQuote = false ; } } else { if ( c == '\'' ) { inSingleQuote = true ; } else if ( c == '"' ) { inDoubleQuote = true ; } else if ( c == ':' && i + 1 < length && Character . isJavaIdentifierStart ( sql . charAt ( i + 1 ) ) ) { int j = i + 2 ; while ( j < length && Character . isJavaIdentifierPart ( sql . charAt ( j ) ) ) { j ++ ; } String name = sql . substring ( i + 1 , j ) ; c = '?' ; // replace the parameter with a question mark
i += name . length ( ) ; // skip past the end if the parameter
List < Integer > indexList = nameIndexMap . get ( name ) ; if ( indexList == null ) { indexList = new LinkedList < Integer > ( ) ; nameIndexMap . put ( name , indexList ) ; } indexList . add ( index ) ; index ++ ; } } parsedSql . append ( c ) ; } return parsedSql . toString ( ) ;


signature:
public class RequestContext { /** * - - - - parameters - - - - - */
public < T > T getForm ( T form ) { } }

implementation: RequestIntrospectUtils . introspect ( form , request ) ; return form ;


signature:
public class RequestContext { /** * - - - - model - - - - - */
public Model getModel ( ) { } }

implementation: Model model = ( Model ) request . getAttribute ( Model . NAME_IN_REQUEST ) ; if ( model == null ) { model = new Model ( ) ; request . setAttribute ( Model . NAME_IN_REQUEST , model ) ; } return model ;


signature: public class DefaultLogicalArea { @ Override public LogicalArea findArea ( Area area ) { } }

implementation:
LogicalArea ret = null ; // scan the subtree
for ( int i = 0 ; i < getChildCount ( ) && ret == null ; i ++ ) { ret = getChildAt ( i ) . findArea ( area ) ; } // not in the subtree - - is it this area ?
if ( ret == null && getAreas ( ) . contains ( area ) ) ret = this ; // in our area nodes
return ret ;


signature:
public class FilterPersistableBaseImmutable { /** * Filter for immutable entities of type APersistableBase .
 * @ param pEntityClass Entity Class
 * @ param pAddParam additional params ( must present requestedDatabaseId
 * of String type ( WEB parameter ) )
 * @ return filter e . g . " ( ITSID > 0 and IDDATABASEBIRTH = 2135 ) "
 * @ throws Exception - an exception */
@ Override public final String makeFilter ( final Class < ? > pEntityClass , final Map < String , Object > pAddParam ) throws Exception { } }

implementation: if ( ! APersistableBase . class . isAssignableFrom ( pEntityClass ) ) { throw new ExceptionWithCode ( ExceptionWithCode . CONFIGURATION_MISTAKE , "This class not descendant of APersistableBase: " + pEntityClass ) ; } int requestedDatabaseId ; try { requestedDatabaseId = Integer . parseInt ( pAddParam . get ( "requestedDatabaseId" ) . toString ( ) ) ; } catch ( Exception e ) { throw new ExceptionWithCode ( ExceptionWithCode . WRONG_PARAMETER , "Wrong or missing parameter requestedDatabaseId (in pAddParam): " + pAddParam . get ( "requestedDatabaseId" ) ) ; } String queryMaxIdBirth = "select max(IDBIRTH) as MAX_IDBIRTH from " + pEntityClass . getSimpleName ( ) . toUpperCase ( ) + " where IDDATABASEBIRTH=" + requestedDatabaseId + ";" ; Long maxIdBirth = this . srvDatabase . evalLongResult ( queryMaxIdBirth , "MAX_IDBIRTH" ) ; if ( maxIdBirth == null ) { maxIdBirth = 0L ; } String tblNm = pEntityClass . getSimpleName ( ) . toUpperCase ( ) ; return "(" + tblNm + ".ITSID>" + maxIdBirth + " and " + tblNm + ".IDDATABASEBIRTH=" + requestedDatabaseId + ")" ;


signature:
public class AnnotatedInterfaceArguments { /** * ( non - Javadoc )
 * @ see org . wymiwyg . commons . util . arguments . ArgumentProcessor # process ( java . util . List ) */
public void process ( List argumentList ) throws InvalidArgumentsException { } }

implementation: Set < Method > requiredArguments = new HashSet < Method > ( ) ; NamedAttributeProcessor namedAttributeProcessor = new NamedAttributeProcessor ( ) ; for ( final Method m : annotated . getMethods ( ) ) { if ( m . isAnnotationPresent ( CommandLine . class ) ) { final CommandLine cl = m . getAnnotation ( CommandLine . class ) ; if ( cl . required ( ) ) { requiredArguments . add ( m ) ; } for ( final String longName : cl . longName ( ) ) { namedAttributeProcessor . addLongNameAttributeProcessor ( new MySingleNamedAttributeProcessor ( longName , cl , m ) ) ; } for ( final String shortName : cl . shortName ( ) ) { namedAttributeProcessor . addNamedAttributeProcessor ( new MySingleNamedAttributeProcessor ( shortName , cl , m ) ) ; } } } Set < CommandLine > missingArguments = new HashSet < CommandLine > ( ) ; namedAttributeProcessor . process ( argumentList ) ; for ( Iterator < Method > iter = requiredArguments . iterator ( ) ; iter . hasNext ( ) ; ) { Method current = iter . next ( ) ; if ( ! valueMap . containsKey ( current ) ) { missingArguments . add ( current . getAnnotation ( CommandLine . class ) ) ; } } if ( missingArguments . size ( ) > 0 ) { throw new MissingArgumentException ( missingArguments ) ; }


signature:
public class DummyPasswordAuthenticator { /** * Authenticate a user by validating the user ' s password , returning a Subject with one or more { @ code Principal } s
 * set ( if validation was successful ) , or throw a { @ code LoginException } ( if validation fails )
 * This method checks whether the provided username matches the provided password . This requires a suitable plain
 * text password validator to work , as the actual validation is performed by the provided
 * { @ code PasswordValidator } ) . The method also checks that the domain is not { @ code null } ( but it does allow an
 * empty String value ) .
 * If the validation is successful , a { @ code Subject } is populated with three principals is returned : The
 * user ' s ID as a concatenation of the username with the string " ID : " , and both the user provided domain and the
 * user provided principal ( i . e . the the identifiers used to authenticate the users ) .
 * @ param domain The white label domain in which the username is located
 * @ param userName The username to authenticate with
 * @ param password The password to authenticate with
 * @ param passwordValidator The validator to use for the password
 * @ return a callback for querying subject attributes .
 * @ throws LoginException when this { @ code LoginModule } is unable to perform the authentication . Catch a
 * { @ link javax . security . auth . login . FailedLoginException } to determine if the authentication
 * failed due to an incorrect password */
public final Subject authenticate ( final String domain , final String userName , final char [ ] password , final PasswordValidator passwordValidator ) throws LoginException { } }

implementation:
// make sure the credentials are not null
if ( domain == null ) { throw new LoginException ( "The domain cannot be null" ) ; } if ( userName == null ) { throw new LoginException ( "The username cannot be null" ) ; } if ( password == null ) { throw new LoginException ( "The password cannot be null" ) ; } // no need for defensive copies of Strings , but create a defensive copy of the password
final char [ ] myPassword = password . clone ( ) ; // convert the username string to a char array
final char [ ] myCredential = userName . toCharArray ( ) ; // perform the password validation
if ( ! passwordValidator . validate ( myPassword , myCredential ) ) { final String error = "Invalid password for username '" + userName + "'" ; LOG . info ( error ) ; throw new FailedLoginException ( error ) ; } // The authentication was successful !
// Create the subject and clean up confidential data as far as possible .
// clear the char representation of the credential
Cleanser . wipe ( myCredential ) ; // clear the defensive copy of the password created earlier
Cleanser . wipe ( myPassword ) ; // create a principal that includes the username and domain name that were used to authenticate the user
final UserPrincipal userPrincipal = new UserPrincipal ( "ID:" + userName , domain , userName ) ; // wrap the principal in a Subject
final Subject subject = new Subject ( ) ; subject . getPrincipals ( ) . add ( userPrincipal ) ; return subject ;


signature:
public class DatabaseReaderSyncStdXml { /** * Read entities from stream ( by given reader ) and synchronize them
 * into DB .
 * @ param pAddParam additional params
 * @ param pReader Reader
 * @ throws Exception - an exception */
@ Override public final void readAndStoreEntities ( final Map < String , Object > pAddParam , final Reader pReader ) throws Exception { } }

implementation: try { this . srvDatabase . setIsAutocommit ( false ) ; this . srvDatabase . setTransactionIsolation ( ISrvDatabase . TRANSACTION_READ_UNCOMMITTED ) ; this . srvDatabase . beginTransaction ( ) ; while ( this . utilXml . readUntilStart ( pReader , "entity" ) ) { Object entity = this . srvEntityReader . read ( pAddParam , pReader ) ; String nameEntitySync = this . mngSettings . lazClsSts ( entity . getClass ( ) ) . get ( "ISrvEntitySync" ) ; ISrvEntitySync srvEntitySync = this . srvEntitySyncMap . get ( nameEntitySync ) ; if ( srvEntitySync == null ) { throw new ExceptionWithCode ( ExceptionWithCode . CONFIGURATION_MISTAKE , "There is no ISrvEntitySync " + nameEntitySync + " for " + entity . getClass ( ) ) ; } boolean isNew = srvEntitySync . sync ( pAddParam , entity ) ; if ( isNew ) { this . srvOrm . insertEntity ( pAddParam , entity ) ; } else { this . srvOrm . updateEntity ( pAddParam , entity ) ; } } this . srvDatabase . commitTransaction ( ) ; } catch ( Exception ex ) { this . srvDatabase . rollBackTransaction ( ) ; throw ex ; } finally { this . srvDatabase . releaseResources ( ) ; }


signature:
public class HttpDestination { /** * Set up everything to start processing */
public void init ( Properties properties ) { } }

implementation: super . init ( properties ) ; if ( client == null ) client = new HttpClient ( ) ; String strBaseURL = properties . getProperty ( BASE_URL_PARAM ) ; if ( strBaseURL == null ) { strBaseURL = "http://localhost/uploads/" ; properties . setProperty ( BASE_URL_PARAM , strBaseURL ) ; }


signature:
public class HttpDestination { /** * Set up everything to start processing */
public void initTransfer ( Properties properties ) { } }

implementation: super . initTransfer ( properties ) ; String strBaseURL = properties . getProperty ( BASE_URL_PARAM ) ; if ( strBaseURL . length ( ) > 0 ) if ( strBaseURL . lastIndexOf ( '/' ) != strBaseURL . length ( ) - 1 ) strBaseURL += '/' ; m_strBaseURL = strBaseURL ;


signature:
public class HttpDestination { /** * Add this file to the destination .
 * Note : Only supply the file or the stream , not both . Supply the object that is easier , given
 * the source . This dual option is given to allow destinations that require File objects from
 * ( such as FTP or HTTP ) Having to write the inStream to a physical file before processing it .
 * @ param file Source file .
 * @ param inStream Source stream .
 * @ param strpath Full path of the source file ( including the filename ) .
 * @ param strFilename Filename .
 * @ param lStreamLength Length of the stream ( - 1 if unknown ) . */
public long addNextFile ( SourceFile source ) { } }

implementation: String strPath = source . getFilePath ( ) ; long lStreamLength = source . getStreamLength ( ) ; HttpClient client = new HttpClient ( ) ; File fileIn = source . makeInFile ( ) ; String furl = m_strBaseURL + this . encodeURL ( strPath ) ; PutMethod put = new PutMethod ( furl ) ; try { RequestEntity entity = new InputStreamRequestEntity ( new FileInputStream ( fileIn ) ) ; put . setRequestEntity ( entity ) ; int response = client . executeMethod ( put ) ; if ( response != 201 ) System . out . println ( "Error Response: " + response ) ; } catch ( HttpException e ) { e . printStackTrace ( ) ; } catch ( FileNotFoundException ex ) { ex . printStackTrace ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return lStreamLength ;


signature:
public class HttpDestination { /** * Convert the URL to the proper format . */
public String encodeURL ( String strURL ) { } }

implementation: String furl = JBackupConstants . BLANK ; try { int iStart = 0 ; for ( int i = iStart ; i <= strURL . length ( ) ; i ++ ) { if ( ( i == strURL . length ( ) ) || ( strURL . charAt ( i ) == '/' ) ) { if ( iStart != i ) furl += URLEncoder . encode ( strURL . substring ( iStart , i ) , ENCODING ) ; if ( i != strURL . length ( ) ) furl += '/' ; iStart = i + 1 ; } } } catch ( UnsupportedEncodingException ex ) { ex . printStackTrace ( ) ; } return furl ;


signature:
public class SqlDialect { /** * 哪些数据库字段运行指定长度 .
 * @ param type 具体的数据库字段类型 */
public boolean supportsColumnLength ( String type ) { } }

implementation: Set < String > columnSet = new HashSet < String > ( ) ; columnSet . add ( "char" ) ; columnSet . add ( "nchar" ) ; columnSet . add ( "varchar" ) ; columnSet . add ( "nvarchar" ) ; columnSet . add ( "varchar2" ) ; columnSet . add ( "nvarchar2" ) ; columnSet . add ( "number" ) ; columnSet . add ( "numeric" ) ; columnSet . add ( "dec" ) ; columnSet . add ( "decimal" ) ; return columnSet . contains ( type . toLowerCase ( ) ) ;


signature:
public class SqlDialect { /** * 哪些数据库字段运行指定精度 .
 * @ param type 具体的数据库字段类型 */
public boolean supportsColumnScale ( String type ) { } }

implementation: Set < String > columnSet = new HashSet < String > ( ) ; columnSet . add ( "number" ) ; columnSet . add ( "numeric" ) ; columnSet . add ( "dec" ) ; columnSet . add ( "decimal" ) ; return columnSet . contains ( type . toLowerCase ( ) ) ;


signature:
public class SqlDialect { /** * 将数据库无关的 SubStyleType 转换成具体数据库的字段名称 。 特殊的字段类型由子类实现 。
 * @ param type 数据库无关的字段名称 , 参考 { @ link SubStyleType } */
public String asSqlType ( String type , Integer length , Integer scale ) { } }

implementation: if ( SubStyleType . UID . equals ( type ) ) { return "bigint" ; } else if ( SubStyleType . UUID . equals ( type ) ) { return "char(16)" ; } else if ( SubStyleType . ENUM . equals ( type ) ) { return "integer" ; } else if ( SubStyleType . INT . equals ( type ) ) { return "integer" ; } else if ( SubStyleType . LONG . equals ( type ) ) { return "bigint" ; } else if ( SubStyleType . BIGINT . equals ( type ) ) { return "decimal(38, 0)" ; } else if ( SubStyleType . DOUBLE . equals ( type ) ) { return "double" ; } else if ( SubStyleType . DECIMAL . equals ( type ) ) { return new SqlType ( "decimal" , length , scale ) . toString ( ) ; } else if ( SubStyleType . CHAR . equals ( type ) ) { return new SqlType ( "char" , length , null ) . toString ( ) ; } else if ( SubStyleType . VARCHAR . equals ( type ) ) { return new SqlType ( "varchar" , length , null ) . toString ( ) ; } else if ( SubStyleType . TEXT . equals ( type ) ) { return new SqlType ( "longvarchar" , Integer . MAX_VALUE , null ) . toString ( ) ; } else if ( SubStyleType . BOOLEAN . equals ( type ) ) { return "tinyint(1)" ; } else if ( SubStyleType . DATETIME_STRING . equals ( type ) ) { return "char(19)" ; } else if ( SubStyleType . DATE_STRING . equals ( type ) ) { return "char(10)" ; } else if ( SubStyleType . TIME_STRING . equals ( type ) ) { return "char(8)" ; } else if ( SubStyleType . DATETIME . equals ( type ) ) { return "timestamp" ; } else if ( SubStyleType . TIMESTAMP . equals ( type ) ) { return "timestamp" ; } else if ( SubStyleType . DATE . equals ( type ) ) { return "date" ; } else if ( SubStyleType . TIME . equals ( type ) ) { return "time" ; } else if ( SubStyleType . CLOB . equals ( type ) ) { return "clob" ; } else if ( SubStyleType . BLOB . equals ( type ) ) { return "blob" ; } else if ( SubStyleType . INPUTSTREAM . equals ( type ) ) { return "longvarbinary" ; } else { return new SqlType ( type , length , scale ) . toString ( ) ; }


signature:
public class SqlDialect { /** * 将字段名 / 表名与SQL保留字冲突的名称进行 Wrapper */
public String getIdentifier ( String name ) { } }

implementation: String upperCaseName = name . toUpperCase ( ) ; if ( iso_reservedWords . contains ( upperCaseName ) ) { return getQuotedIdentifier ( name ) ; } if ( reservedWords . contains ( upperCaseName ) ) { return getQuotedIdentifier ( name ) ; } return name ;


signature:
public class ExecutableUtils { /** * 查找完全匹配的方法或者构造函数 .
 * @ param executables - 带查找的 list
 * @ param name - 方法名称 ( 如果查找构造函数 , 那么name可以是null )
 * @ param parameterTypes - 方法或者构造函数参数 ( 完全匹配 )
 * @ return 找到的方法或者构造函数 , 找不到返回 null . */
public static < T extends Executable > T getExecutable ( List < T > executables , String name , Class < ? > ... parameterTypes ) { } }

implementation: for ( T info : executables ) { if ( name == null || info . getName ( ) . equals ( name ) ) { Class < ? > [ ] types = info . getParameterTypes ( ) ; if ( parameterTypes . length == types . length ) { boolean match = true ; for ( int i = 0 ; i < parameterTypes . length ; i ++ ) { if ( types [ i ] != parameterTypes [ i ] ) { match = false ; break ; } } if ( match ) { return info ; } } } } return null ;


signature:
public class ExecutableUtils { /** * 查找最佳匹配的方法或者构造函数 。
 * @ param executables - 带查找的 list
 * @ param name - 方法名称 ( 如果查找构造函数 , 那么name可以是null )
 * @ param parameterTypes - 方法或者构造函数参数 ( 支持类型转换 )
 * @ return 找到的方法或者构造函数 , 找不到返回 null . */
public static < T extends Executable > T searchExecutable ( List < T > executables , String name , Class < ? > ... parameterTypes ) { } }

implementation:
T best = null ; Class < ? > [ ] bestParametersTypes = null ; for ( T execute : executables ) { if ( name != null && ! execute . getName ( ) . equals ( name ) ) continue ; Class < ? > [ ] types = execute . getParameterTypes ( ) ; if ( isParameterTypesCompatible ( types , parameterTypes , execute . isVarArgs ( ) , false ) ) { // 可能有多个方法与实际参数类型兼容 。 采用就近兼容原则 。
if ( best == null ) { best = execute ; bestParametersTypes = types ; } else if ( best . isVarArgs ( ) && ( ! execute . isVarArgs ( ) ) ) { best = execute ; // 不可变参数的函数优先
bestParametersTypes = types ; } else if ( ( ! best . isVarArgs ( ) ) && execute . isVarArgs ( ) ) { // no change
} else { if ( isParameterTypesCompatible ( bestParametersTypes , types , best . isVarArgs ( ) , execute . isVarArgs ( ) ) ) { best = execute ; bestParametersTypes = types ; } } } } return best ;


signature:
public class ExecutableUtils { /** * 判断参数列表是否兼容 , 支持可变参数 .
 * @ param lhs - left operand
 * @ param rhs - right operand
 * @ param lhsVarArgs - lhs 是否是可变参数
 * @ param rhsVarArgs - rhs 是否是可变参数
 * @ return 是否兼容 */
public static boolean isParameterTypesCompatible ( Class < ? > [ ] lhs , Class < ? > [ ] rhs , boolean lhsVarArgs , boolean rhsVarArgs ) { } }

implementation:
if ( lhs == null ) { return rhs == null || rhs . length == 0 ; } if ( rhs == null ) { return lhs . length == 0 ; } if ( lhsVarArgs && rhsVarArgs ) { if ( lhs . length != rhs . length ) { return false ; } // 校验前面的固定参数
for ( int i = 0 ; i < lhs . length - 1 ; i ++ ) { if ( ! ClassUtils . isAssignable ( lhs [ i ] , rhs [ i ] ) ) { return false ; } } // 校验最后一个可变参数
Class < ? > c1 = lhs [ lhs . length - 1 ] . getComponentType ( ) ; Class < ? > c2 = rhs [ rhs . length - 1 ] . getComponentType ( ) ; if ( ! ClassUtils . isAssignable ( c1 , c2 ) ) { return false ; } } else if ( lhsVarArgs ) { if ( lhs . length - 1 > rhs . length ) { return false ; } // 校验前面的固定参数
for ( int i = 0 ; i < lhs . length - 1 ; i ++ ) { if ( ! ClassUtils . isAssignable ( lhs [ i ] , rhs [ i ] ) ) { return false ; } } // 校验最后一个可变参数
Class < ? > varType = lhs [ lhs . length - 1 ] . getComponentType ( ) ; for ( int i = lhs . length - 1 ; i < rhs . length ; i ++ ) { if ( ! ClassUtils . isAssignable ( varType , rhs [ i ] ) ) { return false ; } } } else { if ( lhs . length != rhs . length ) { return false ; } for ( int i = 0 ; i < lhs . length ; i ++ ) { if ( ! ClassUtils . isAssignable ( lhs [ i ] , rhs [ i ] ) ) { return false ; } } } return true ;


signature:
public class IndentWriter { /** * / * ( non - Javadoc )
 * @ see java . io . Writer # write ( char [ ] , int , int ) */
public void write ( char [ ] cbuf , int off , int len ) throws IOException { } }

implementation: int posInSeparatorChars = 0 ; for ( int i = 0 ; i < len ; i ++ ) { if ( identBeforeNextChar ) { base . write ( '\t' ) ; identBeforeNextChar = false ; } base . write ( cbuf [ i ] ) ; if ( cbuf [ i ] == separatorChars [ posInSeparatorChars ] ) { posInSeparatorChars ++ ; if ( posInSeparatorChars == separatorChars . length ) { identBeforeNextChar = true ; posInSeparatorChars = 0 ; } } else { posInSeparatorChars = 0 ; } }


signature:
public class PathUtils { /** * Returns normalized < code > path < / code > ( or simply the < code > path < / code > if
 * it is already in normalized form ) . Normalized path does not contain any
 * empty or " . " segments or " . . " segments preceded by other segment than
 * @ param path path to normalize
 * @ return normalize path */
public static String normalize ( final String path ) { } }

implementation:
if ( path == null ) { return null ; } if ( path . indexOf ( '.' ) == - 1 && path . indexOf ( '/' ) == - 1 ) { return path ; } boolean wasNormalized = true ; // 1 . count number of nonempty segments in path
// Note that this step is not really necessary because we could simply
// estimate the number of segments as path . length ( ) and do the empty
// segment check in step two ; - ) .
int numSegments = 0 ; int lastChar = path . length ( ) - 1 ; for ( int src = lastChar ; src >= 0 ; ) { int slash = path . lastIndexOf ( '/' , src ) ; if ( slash != - 1 ) { // empty segment ? ( two adjacent slashes ? )
if ( slash == src ) { if ( src != lastChar ) { // ignore the first slash occurence
// ( when numSegments = = 0)
wasNormalized = false ; } } else { numSegments ++ ; } } else { numSegments ++ ; } src = slash - 1 ; } // 2 . split path to segments skipping empty segments
int [ ] segments = new int [ numSegments ] ; char [ ] chars = new char [ path . length ( ) ] ; path . getChars ( 0 , chars . length , chars , 0 ) ; numSegments = 0 ; for ( int src = 0 ; src < chars . length ; ) { // skip empty segments
while ( src < chars . length && chars [ src ] == '/' ) { src ++ ; } if ( src < chars . length ) { // note the segment start
segments [ numSegments ++ ] = src ; // seek to the end of the segment
while ( src < chars . length && chars [ src ] != '/' ) { src ++ ; } } } // assert ( numSegments = = segments . length ) ;
// 3 . scan segments and remove all " . " segments and " foo " , " . . " segment pairs
final int DELETED = - 1 ; for ( int segment = 0 ; segment < numSegments ; segment ++ ) { int src = segments [ segment ] ; if ( chars [ src ++ ] == '.' ) { if ( src == chars . length || chars [ src ] == '/' ) { // " . " or " . / "
// delete the " . " segment
segments [ segment ] = DELETED ; wasNormalized = false ; } else { // " . something "
if ( chars [ src ++ ] == '.' && ( src == chars . length || chars [ src ] == '/' ) ) { // " . . " or " . . / "
// we have the " . . " segment scan backwards for segment to delete together with " . . "
for ( int toDelete = segment - 1 ; toDelete >= 0 ; toDelete -- ) { if ( segments [ toDelete ] != DELETED ) { if ( chars [ segments [ toDelete ] ] != '.' ) { // delete the two segments
segments [ toDelete ] = DELETED ; segments [ segment ] = DELETED ; wasNormalized = false ; } break ; } } } } } } // 4 . join the result , if necessary
if ( wasNormalized ) { // already normalized ? nothing to do . . .
return path ; } else { // join the resulting normalized path , retain the leading and ending slash
int dst = ( chars [ 0 ] == '/' ) ? 1 : 0 ; for ( int segment = 0 ; segment < numSegments ; segment ++ ) { int segmentStart = segments [ segment ] ; if ( segmentStart != DELETED ) { // if we remembered segment lengths in step 2 , we could use
// System . arraycopy method now but we had to allocate one
// more array
for ( int src = segmentStart ; src < chars . length ; src ++ ) { char ch = chars [ src ] ; chars [ dst ++ ] = ch ; if ( ch == '/' ) { break ; } } } } return new String ( chars , 0 , dst ) ; }


signature:
public class PathUtils { /** * 组合路径 . */
public static String concat ( final String parent , final String child ) { } }

implementation: if ( parent == null ) { return normalize ( child ) ; } if ( child == null ) { return normalize ( parent ) ; } return normalize ( parent + '/' + child ) ;


signature:
public class PathUtils { /** * 计算相对路径 . */
public static String getRelativePath ( final String path , final String relativePath ) { } }

implementation: if ( relativePath . startsWith ( "/" ) ) { return normalize ( relativePath ) ; } int separatorIndex = path . lastIndexOf ( '/' ) ; if ( separatorIndex != - 1 ) { String newPath = path . substring ( 0 , separatorIndex + 1 ) ; return normalize ( newPath + relativePath ) ; } else { return normalize ( relativePath ) ; }


signature:
public class PathUtils { /** * 转为 Unix 样式的路径 . */
public static String separatorsToUnix ( String path ) { } }

implementation: if ( path == null || path . indexOf ( '\\' ) == - 1 ) { return path ; } return path . replace ( '\\' , '/' ) ;


signature:
public class PathUtils { /** * 转为 Windows 样式的路径 . */
public static String separatorsToWindows ( String path ) { } }

implementation: if ( path == null || path . indexOf ( '/' ) == - 1 ) { return path ; } return path . replace ( '/' , '\\' ) ;


signature:
public class PathUtils { /** * 转为系统默认样式的路径 . */
public static String separatorsToSystem ( String path ) { } }

implementation: if ( path == null ) { return null ; } if ( File . separatorChar == '\\' ) { return separatorsToWindows ( path ) ; } return separatorsToUnix ( path ) ;


signature:
public class KlassInfo { /** * 将 Class 对象转成 KlassInfo 对象 ( 有缓存 ) .
 * @ param clazz - 原始对象
 * @ return KlassInfo 对象 */
public static KlassInfo create ( final Class < ? > clazz ) { } }

implementation: KlassInfo klass = pool . get ( clazz ) ; if ( klass == null ) { klass = new KlassInfo ( clazz ) ; KlassInfo old = pool . putIfAbsent ( clazz , klass ) ; if ( old != null ) { klass = old ; } } return klass ;


signature:
public class KlassInfo { /** * 根据目标参数类型 , 查找完全匹配的构造函数 .
 * @ param parameterTypes - 匹配的构造函数参数
 * @ return 找到的构造函数对象 , 找不到返回 null . */
public ConstructorInfo getDeclaredConstructor ( Class < ? > ... parameterTypes ) { } }

implementation: return ExecutableUtils . getExecutable ( declaredConstructorsGetter . get ( ) , null , parameterTypes ) ;


signature:
public class KlassInfo { /** * 根据目标参数类型 , 查找最佳匹配的构造函数 .
 * @ param parameterTypes - 匹配的构造函数参数
 * @ return 找到的构造函数对象 , 找不到返回 null . */
public ConstructorInfo searchDeclaredConstructor ( Class < ? > ... parameterTypes ) { } }

implementation: ConstructorInfo constructor = ExecutableUtils . getExecutable ( declaredConstructorsGetter . get ( ) , null , parameterTypes ) ; if ( constructor == null ) { constructor = ExecutableUtils . searchExecutable ( declaredConstructorsGetter . get ( ) , null , parameterTypes ) ; } return constructor ;


signature:
public class KlassInfo { /** * 根据目标参数类型 , 查找完全匹配的方法 .
 * @ param parameterTypes - 匹配的方法参数
 * @ return 找到的方法对象 , 找不到返回 null . */
public MethodInfo getMethod ( String name , Class < ? > ... parameterTypes ) { } }

implementation: return ExecutableUtils . getExecutable ( methodsGetter . get ( ) , name , parameterTypes ) ;


signature:
public class KlassInfo { /** * 根据目标参数类型 , 查找最佳匹配的方法 .
 * @ param parameterTypes - 匹配的方法参数
 * @ return 找到的方法对象 , 找不到返回 null . */
public MethodInfo searchMethod ( String name , Class < ? > ... parameterTypes ) { } }

implementation: MethodInfo method = ExecutableUtils . getExecutable ( methodsGetter . get ( ) , name , parameterTypes ) ; if ( method == null ) { method = ExecutableUtils . searchExecutable ( methodsGetter . get ( ) , name , parameterTypes ) ; } return method ;


signature:
public class KlassInfo { /** * 反射调用计数器 , 超过阈值 , 则使用 ASM 字节码增强技术 */
protected ASMAccessor getASMAccessor ( ) { } }

implementation: if ( asmAccessor == null ) { if ( asmCallNumber >= ASMFactory . getThreshold ( ) ) { asmAccessor = ASMFactory . generateAccessor ( this ) ; } else { asmCallNumber ++ ; } } return asmAccessor ;


signature:
public class KlassInfo { /** * 调用默认的构造函数生成对象实例 .
 * @ return 生成的对象实例 .
 * @ throws IllegalStateException - 如果找不到默认的构造函数或者没有访问权限 , 那么抛出该异常 . */
public Object newInstance ( ) throws IllegalStateException { } }

implementation: ASMAccessor accessor = getASMAccessor ( ) ; if ( accessor == null ) { ConstructorInfo ctor = getDefaultConstructor ( ) ; if ( ctor != null ) { return ctor . newInstance ( ) ; } throw new IllegalStateException ( "No default constructor" ) ; } else { return accessor . newInstance ( ) ; }


signature:
public class ProtobufSerializer { /** * Returns the field value from the supplied < code > pojo < / code > object . If a < code > pojoGetter < / code has been set in the
 * { @ link ProtobufAttribute } , then use that , otherwise , try getting the field value directly .
 * @ param pojo - POJO Object
 * @ param protobufAttribute
 * @ param field
 * @ return Object - the resulting object after calling the POJO ' s getter
 * @ throws ProtobufAnnotationException */
private static final Object getPojoFieldValue ( Object pojo , ProtobufAttribute protobufAttribute , Field field ) throws ProtobufAnnotationException { } }

implementation: final String getter = protobufAttribute . pojoGetter ( ) ; Object value = null ; if ( ! getter . isEmpty ( ) ) { try { return JReflectionUtils . runMethod ( pojo , getter ) ; } catch ( Exception e ) { throw new ProtobufAnnotationException ( "Could not get a value for field " + field . getName ( ) + " using configured getter of " + getter , e ) ; } } try { value = JReflectionUtils . runGetter ( pojo , field ) ; } catch ( Exception ee ) { throw new ProtobufAnnotationException ( "Could not execute getter " + getter + " on class " + pojo . getClass ( ) . getCanonicalName ( ) + ": " + ee , ee ) ; } if ( value == null && protobufAttribute . required ( ) ) { throw new ProtobufAnnotationException ( "Required field " + field . getName ( ) + " on class " + pojo . getClass ( ) . getCanonicalName ( ) + " is null" ) ; } return value ;


signature:
public class ProtobufSerializer { /** * Create a new serializer and serializes the supplied object / attribute .
 * @ param pojo - the POJO object
 * @ return Object - the resulting GPB object
 * @ throws JException */
private static final Object serializeToProtobufEntity ( Object pojo ) throws JException { } }

implementation: final ProtobufEntity protoBufEntity = ProtobufSerializerUtils . getProtobufEntity ( pojo . getClass ( ) ) ; if ( protoBufEntity == null ) { return pojo ; } return new ProtobufSerializer ( ) . toProtobuf ( pojo ) ;


signature:
public class ProtobufSerializer { /** * Create a new serializer and ( de ) serializes the supplied Protobu / attribute to a POJO of type < i > pojoClazz < / i > .
 * @ param protoBuf
 * @ param pojoClazz
 * @ return
 * @ throws JException */
private static final Object serializeFromProtobufEntity ( Message protoBuf , Class < ? > pojoClazz ) throws JException { } }

implementation: final ProtobufEntity protoBufEntity = ProtobufSerializerUtils . getProtobufEntity ( pojoClazz ) ; if ( protoBufEntity == null ) { return protoBuf ; } return new ProtobufSerializer ( ) . fromProtobuf ( protoBuf , pojoClazz ) ;


signature:
public class ProtobufSerializer { /** * This method does the actual " set " on the Protobuf builder . If the user specified a converter ,
 * then use that right before we actually try and set the value .
 * @ param protobufAttribute - ProtobufAttribute
 * @ param protoObjBuilder - G . Builder
 * @ param setter - String
 * @ param fieldValue - POJO ' s filed Object
 * @ throws NoSuchMethodException
 * @ throws SecurityException
 * @ throws ProtobufAnnotationException
 * @ throws InstantiationException
 * @ throws IllegalAccessException
 * @ throws IllegalArgumentException
 * @ throws InvocationTargetException */
private static final void setProtobufFieldValue ( ProtobufAttribute protobufAttribute , Builder protoObjBuilder , String setter , Object fieldValue ) throws NoSuchMethodException , SecurityException , ProtobufAnnotationException , InstantiationException , IllegalAccessException , IllegalArgumentException , InvocationTargetException { } }

implementation:
Class < ? extends Object > fieldValueClass = fieldValue . getClass ( ) ; Class < ? extends Object > gpbClass = fieldValueClass ; final Class < ? extends IProtobufConverter > converterClazz = protobufAttribute . converter ( ) ; if ( converterClazz != NullConverter . class ) { final IProtobufConverter protoBufConverter = ( IProtobufConverter ) converterClazz . newInstance ( ) ; fieldValue = protoBufConverter . convertToProtobuf ( fieldValue ) ; gpbClass = fieldValue . getClass ( ) ; fieldValueClass = gpbClass ; } // Need to convert the argument class from non - primitives to primitives , as Protobuf uses these .
gpbClass = ProtobufSerializerUtils . getProtobufClass ( fieldValue , gpbClass ) ; final Method gpbMethod = protoObjBuilder . getClass ( ) . getDeclaredMethod ( setter , gpbClass ) ; gpbMethod . invoke ( protoObjBuilder , fieldValue ) ;


signature:
public class FileExtensionFilter { /** * Tests whether or not the specified abstract pathname should be
 * included in a pathname list .
 * @ param pathname The abstract pathname to be tested
 * @ return < code > true < / code > if and only if < code > pathname < / code >
 * should be included */
public boolean accept ( File pathname ) { } }

implementation:
String name = pathname . getName ( ) ; int iLastDot = name . lastIndexOf ( '.' ) ; String strExtension = "" ; if ( ( iLastDot != - 1 ) && ( iLastDot != name . length ( ) - 1 ) ) strExtension = name . substring ( iLastDot + 1 ) ; if ( m_rgstrIncludeExtensions != null ) { for ( int i = 0 ; i < m_rgstrIncludeExtensions . length ; i ++ ) { if ( m_rgstrIncludeExtensions [ i ] . equalsIgnoreCase ( strExtension ) ) return true ; // Accept
} return false ; // Not in included - return
} if ( m_rgstrExcludeExtensions != null ) { for ( int i = 0 ; i < m_rgstrExcludeExtensions . length ; i ++ ) { if ( m_rgstrExcludeExtensions [ i ] . equalsIgnoreCase ( strExtension ) ) return false ; // Don ' t accept
} } return true ; // Accept this file


signature:
public class PlainTextPasswordValidator { /** * { @ inheritDoc } */
@ Override // It would be pretty dumb to use varargs for the credential . . .
@ SuppressWarnings ( "PMD.UseVarargs" ) public final boolean validate ( final char [ ] providedPassword , final char [ ] storedCredential ) { } }

implementation: if ( providedPassword == null || storedCredential == null ) { return false ; } else { return Arrays . equals ( providedPassword , storedCredential ) ; }


signature:
public class DatabaseReaderIdenticalXml { /** * Read entities from stream ( by given reader ) and insert them
 * into DB with no changes . DB must be emptied before coping .
 * @ param pAddParam additional params
 * @ param pReader Reader
 * @ throws Exception - an exception */
@ Override public final void readAndStoreEntities ( final Map < String , Object > pAddParam , final Reader pReader ) throws Exception { } }

implementation: try { this . srvDatabase . setIsAutocommit ( false ) ; this . srvDatabase . setTransactionIsolation ( ISrvDatabase . TRANSACTION_READ_UNCOMMITTED ) ; this . srvDatabase . beginTransaction ( ) ; while ( this . utilXml . readUntilStart ( pReader , "entity" ) ) { Object entity = this . srvEntityReader . read ( pAddParam , pReader ) ; this . srvOrm . insertEntity ( pAddParam , entity ) ; } this . srvDatabase . commitTransaction ( ) ; } catch ( Exception ex ) { this . srvDatabase . rollBackTransaction ( ) ; throw ex ; } finally { this . srvDatabase . releaseResources ( ) ; }


signature:
public class JdbcLogResultSet { /** * Creates a logging version of a ResultSet
 * @ param rs - the ResultSet to proxy
 * @ return - the ResultSet with logging */
public static ResultSet getInstance ( ResultSet rs ) { } }

implementation: InvocationHandler handler = new JdbcLogResultSet ( rs ) ; ClassLoader cl = ResultSet . class . getClassLoader ( ) ; return ( ResultSet ) Proxy . newProxyInstance ( cl , new Class [ ] { ResultSet . class } , handler ) ;


signature:
public class StateParser { /** * Produces a mapping of label to index for use in parsing state values to the appropriate slot in the state object . */
private static Map < ExpectedLabels , Integer > mapLabels ( final List < String > labels ) { } }

implementation: final Map < ExpectedLabels , Integer > map = new EnumMap < > ( ExpectedLabels . class ) ; final List < ExpectedLabels > unusedLabels = new ArrayList < > ( Arrays . asList ( ExpectedLabels . values ( ) ) ) ; for ( int index = 0 ; index < labels . size ( ) ; index ++ ) { final String next = labels . get ( index ) ; ExpectedLabels labelValue ; try { labelValue = ExpectedLabels . valueOf ( next ) ; unusedLabels . remove ( labelValue ) ; if ( map . containsKey ( labelValue ) ) { LOGGER . warn ( "Duplicate state label: {} ({})" , next , labels ) ; } map . put ( labelValue , index ) ; } catch ( final IllegalArgumentException e ) { LOGGER . warn ( "Unexpected state label: {}" , next ) ; } } for ( final ExpectedLabels label : unusedLabels ) { LOGGER . warn ( "Unused label: {}" , label ) ; } return map ;


signature:
public class StateParser { /** * Uses the provided label - index mapping to extract state values and create a new State object . */
private static State extractValues ( final List < Object > values , final Map < ExpectedLabels , Integer > map ) { } }

implementation: final ZonedDateTime time = ZonedDateTime . parse ( ( String ) values . get ( map . get ( ExpectedLabels . time ) ) ) ; final int temp = safeInt ( ( Integer ) values . get ( map . get ( ExpectedLabels . temp ) ) ) ; final int pressure = safeInt ( ( Integer ) values . get ( map . get ( ExpectedLabels . pressure ) ) ) ; final int humidity = safeInt ( ( Integer ) values . get ( map . get ( ExpectedLabels . humidity ) ) ) ; final int voc = safeInt ( ( Integer ) values . get ( map . get ( ExpectedLabels . voc ) ) ) ; final int light = safeInt ( ( Integer ) values . get ( map . get ( ExpectedLabels . light ) ) ) ; final int noise = safeInt ( ( Integer ) values . get ( map . get ( ExpectedLabels . noise ) ) ) ; final int noisedba = safeInt ( ( Integer ) values . get ( map . get ( ExpectedLabels . noisedba ) ) ) ; final int battery = safeInt ( ( Integer ) values . get ( map . get ( ExpectedLabels . battery ) ) ) ; final boolean shake = safeBoolean ( ( Boolean ) values . get ( map . get ( ExpectedLabels . shake ) ) ) ; final boolean cable = safeBoolean ( ( Boolean ) values . get ( map . get ( ExpectedLabels . cable ) ) ) ; final int vocResistance = safeInt ( ( Integer ) values . get ( map . get ( ExpectedLabels . voc_resistance ) ) ) ; final int rssi = safeInt ( ( Integer ) values . get ( map . get ( ExpectedLabels . rssi ) ) ) ; return new State ( time , temp , pressure , humidity , voc , light , noise , noisedba , battery , shake , cable , vocResistance , rssi ) ;


signature:
public class SrvClearDatabase { /** * < p > It will clear current database . < / p >
 * @ param pAddParams additional params
 * @ throws Exception - an exception */
@ Override public final void make ( final Map < String , Object > pAddParams ) throws Exception { } }

implementation: ArrayList < Class < ? > > classesArr = new ArrayList < Class < ? > > ( this . mngSettings . getClasses ( ) ) ; try { this . srvDatabase . setIsAutocommit ( false ) ; this . srvDatabase . setTransactionIsolation ( ISrvDatabase . TRANSACTION_READ_UNCOMMITTED ) ; this . srvDatabase . beginTransaction ( ) ; this . logger . info ( null , SrvClearDatabase . class , "Start clear database." ) ; for ( int i = classesArr . size ( ) - 1 ; i >= 0 ; i -- ) { Class < ? > entityClass = classesArr . get ( i ) ; this . srvDatabase . executeDelete ( entityClass . getSimpleName ( ) . toUpperCase ( ) , null ) ; } this . srvDatabase . commitTransaction ( ) ; Writer htmlWriter = ( Writer ) pAddParams . get ( "htmlWriter" ) ; if ( htmlWriter != null ) { htmlWriter . write ( "<h4>" + new Date ( ) . toString ( ) + ", " + SrvClearDatabase . class . getSimpleName ( ) + ", database has been cleared" + "</h4>" ) ; } this . logger . info ( null , SrvClearDatabase . class , "Finish clear database." ) ; } catch ( Exception ex ) { this . srvDatabase . rollBackTransaction ( ) ; throw ex ; } finally { this . srvDatabase . releaseResources ( ) ; }


signature:
public class TypeResolverUtils { /** * Returns raw class for given < code > type < / code > when implementation class is known
 * and it makes difference .
 * @ param type - given type
 * @ param implClass - implementation clas
 * @ return raw class
 * @ see # resolveVariable ( java . lang . reflect . TypeVariable , Class ) */
public static Class < ? > getRawType ( Type type , Class < ? > implClass ) { } }

implementation: if ( type instanceof Class ) { return ( Class < ? > ) type ; } if ( type instanceof ParameterizedType ) { ParameterizedType pType = ( ParameterizedType ) type ; return getRawType ( pType . getRawType ( ) , implClass ) ; } if ( type instanceof WildcardType ) { WildcardType wType = ( WildcardType ) type ; Type [ ] lowerTypes = wType . getLowerBounds ( ) ; if ( lowerTypes . length > 0 ) { return getRawType ( lowerTypes [ 0 ] , implClass ) ; } Type [ ] upperTypes = wType . getUpperBounds ( ) ; if ( upperTypes . length != 0 ) { return getRawType ( upperTypes [ 0 ] , implClass ) ; } return Object . class ; } if ( type instanceof GenericArrayType ) { Type genericComponentType = ( ( GenericArrayType ) type ) . getGenericComponentType ( ) ; Class < ? > rawType = getRawType ( genericComponentType , implClass ) ; return Array . newInstance ( rawType , 0 ) . getClass ( ) ; } if ( type instanceof TypeVariable ) { TypeVariable < ? > varType = ( TypeVariable < ? > ) type ; if ( implClass != null ) { Type resolvedType = resolveVariable ( varType , implClass ) ; if ( resolvedType != null ) { return getRawType ( resolvedType , null ) ; } } Type [ ] boundsTypes = varType . getBounds ( ) ; if ( boundsTypes . length == 0 ) { return Object . class ; } return getRawType ( boundsTypes [ 0 ] , implClass ) ; } return null ;


signature:
public class TypeResolverUtils { /** * Resolves < code > TypeVariable < / code > with given implementation class .
 * @ param variable - variable
 * @ param implClass - implementation class
 * @ return resolved type */
public static Type resolveVariable ( TypeVariable < ? > variable , Class < ? > implClass ) { } }

implementation: Class < ? > rawType = getRawType ( implClass , null ) ; int index = ArrayUtils . indexOf ( rawType . getTypeParameters ( ) , variable ) ; if ( index >= 0 ) { return variable ; } Class < ? > [ ] interfaces = rawType . getInterfaces ( ) ; Type [ ] genericInterfaces = rawType . getGenericInterfaces ( ) ; for ( int i = 0 ; i <= interfaces . length ; i ++ ) { Class < ? > rawInterface ; if ( i < interfaces . length ) { rawInterface = interfaces [ i ] ; } else { rawInterface = rawType . getSuperclass ( ) ; if ( rawInterface == null ) { continue ; } } Type resolved = resolveVariable ( variable , rawInterface ) ; if ( resolved instanceof Class || resolved instanceof ParameterizedType ) { return resolved ; } if ( resolved instanceof TypeVariable ) { TypeVariable < ? > typeVariable = ( TypeVariable < ? > ) resolved ; index = ArrayUtils . indexOf ( rawInterface . getTypeParameters ( ) , typeVariable ) ; if ( index < 0 ) { throw new IllegalArgumentException ( "Can't resolve type variable:" + typeVariable ) ; } Type type = i < genericInterfaces . length ? genericInterfaces [ i ] : rawType . getGenericSuperclass ( ) ; if ( type instanceof Class ) { return Object . class ; } if ( type instanceof ParameterizedType ) { return ( ( ParameterizedType ) type ) . getActualTypeArguments ( ) [ index ] ; } throw new IllegalArgumentException ( "Unsupported type: " + type ) ; } } return null ;


signature:
public class TypeResolverUtils { /** * Returns the component type of the given type .
 * Returns < code > null < / code > if given type does not have a single
 * component type . For example the following types all have the
 * component - type MyClass :
 * < ul >
 * < li > MyClass [ ] < / li >
 * < li > List & lt ; MyClass & gt ; < / li >
 * < li > Foo & lt ; ? extends MyClass & gt ; < / li >
 * < li > Bar & lt ; ? super MyClass & gt ; < / li >
 * < li > & lt ; T extends MyClass & gt ; T [ ] < / li >
 * < / ul >
 * Index represents the index of component type , when class supports more then one .
 * For example , < code > Map & lt ; A , B & gt ; < / code > has 2 component types . If index is 0 or positive ,
 * than it represents order of component type . If the value is negative , then it represents
 * component type counted from the end ! Therefore , the default value of < code > - 1 < / code >
 * always returns the < b > last < / b > component type .
 * @ param type - type
 * @ param implClass - implementation class
 * @ param index - index of component type
 * @ return component type */
public static Class < ? > getComponentType ( Type type , Class < ? > implClass , int index ) { } }

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


signature:
public class TypeResolverUtils { /** * Returns generic supertype for given class and 0 - based index .
 * @ see # getComponentType ( java . lang . reflect . Type , int ) */
public static Class < ? > getGenericSupertype ( Class < ? > type , int index ) { } }

implementation: return getComponentType ( type . getGenericSuperclass ( ) , null , index ) ;


signature:
public class SrvEntityFieldHasIdStringRepl { /** * Fill given field of given entity according value represented as
 * string .
 * @ param pAddParam additional params
 * @ param pEntity Entity .
 * @ param pFieldName Field Name
 * @ param pFieldStrValue Field value
 * @ throws Exception - an exception */
@ Override public final void fill ( final Map < String , Object > pAddParam , final Object pEntity , final String pFieldName , final String pFieldStrValue ) throws Exception { } }

implementation: Field rField = getUtlReflection ( ) . retrieveField ( pEntity . getClass ( ) , pFieldName ) ; rField . setAccessible ( true ) ; if ( ! AHasIdString . class . isAssignableFrom ( rField . getType ( ) ) ) { throw new ExceptionWithCode ( ExceptionWithCode . CONFIGURATION_MISTAKE , "It's wrong service to fill that field: " + pEntity + "/" + pFieldName + "/" + pFieldStrValue ) ; } if ( "NULL" . equals ( pFieldStrValue ) ) { rField . set ( pEntity , null ) ; return ; } try { @ SuppressWarnings ( "unchecked" ) Constructor constructor = rField . getType ( ) . getDeclaredConstructor ( ) ; Object ownedEntity = constructor . newInstance ( ) ; ( ( AHasIdString ) ownedEntity ) . setItsId ( pFieldStrValue ) ; rField . set ( pEntity , ownedEntity ) ; } catch ( Exception ex ) { throw new ExceptionWithCode ( ExceptionWithCode . WRONG_PARAMETER , "Can not fill field: " + pEntity + "/" + pFieldName + "/" + pFieldStrValue + ", " + ex . getMessage ( ) , ex ) ; }


signature:
public class MultiPathNode { /** * / * ( non - Javadoc )
 * @ see org . wymiwyg . commons . util . dirbrowser . PathNode # getLastModified ( ) */
public Date getLastModified ( ) { } }

implementation: Date lastModified = null ; for ( int i = 0 ; i < nodes . length ; i ++ ) { PathNode node = nodes [ i ] ; Date currentLastModified = node . getLastModified ( ) ; if ( currentLastModified != null ) { if ( ( lastModified == null ) || ( currentLastModified . after ( lastModified ) ) ) { lastModified = currentLastModified ; } } } return lastModified ;


signature:
public class FtpDestination { /** * Get everything ready . */
public void init ( Properties properties ) { } }

implementation: super . init ( properties ) ; String strHost = properties . getProperty ( FTP_HOST ) ; if ( strHost == null ) properties . setProperty ( FTP_HOST , "localhost" ) ; String strUsername = properties . getProperty ( USER_NAME ) ; if ( strUsername == null ) properties . setProperty ( USER_NAME , "anonymous" ) ; String strPassword = properties . getProperty ( PASSWORD ) ; if ( strPassword == null ) properties . setProperty ( PASSWORD , "name@mailhost.com" ) ; String m_strRootFTPDirectory = properties . getProperty ( ROOT_DIR ) ; if ( m_strRootFTPDirectory == null ) properties . setProperty ( ROOT_DIR , DEFAULT_ROOT_DIR ) ;


signature:
public class FtpDestination { /** * Set up everything to start processing */
public void initTransfer ( Properties properties ) { } }

implementation:
super . initTransfer ( properties ) ; FTPClient client = new FTPClient ( ) ; if ( DEBUG ) System . out . println ( "Connecting" ) ; String strHost = properties . getProperty ( FTP_HOST , "hd2-12.irv.zyan.com" ) ; String strPort = properties . getProperty ( FTP_PORT , "21" ) ; int port = Integer . parseInt ( strPort ) ; String strUsername = properties . getProperty ( USER_NAME , "anonymous" ) ; String strPassword = properties . getProperty ( PASSWORD , "doncorley@zyan.com" ) ; m_strRootFTPDirectory = properties . getProperty ( ROOT_DIR , DEFAULT_ROOT_DIR ) ; if ( m_strRootFTPDirectory . endsWith ( "/" ) ) m_strRootFTPDirectory = m_strRootFTPDirectory . substring ( 0 , m_strRootFTPDirectory . length ( ) - 1 ) ; if ( m_strRootFTPDirectory . startsWith ( "/" ) ) m_strRootFTPDirectory = m_strRootFTPDirectory . substring ( 1 ) ; properties . setProperty ( FTP_HOST , strHost ) ; properties . setProperty ( USER_NAME , strUsername ) ; properties . setProperty ( PASSWORD , strPassword ) ; properties . setProperty ( ROOT_DIR , m_strRootFTPDirectory ) ; try { client . connect ( strHost , port ) ; if ( DEBUG ) System . out . println ( "Connected to " + strHost + "." ) ; // After connection attempt , you should check the reply code to verify
// success .
int reply = client . getReplyCode ( ) ; if ( FTPReply . isPositiveCompletion ( reply ) ) { client . login ( strUsername , strPassword ) ; client . enterLocalPassiveMode ( ) ; m_client = client ; // Flag success
} else { // Error
if ( DEBUG ) System . out . println ( "FTP connect Error: " + reply ) ; client . disconnect ( ) ; } } catch ( IOException e ) { e . printStackTrace ( ) ; }


signature:
public class FtpDestination { /** * Cleanup . */
public void finishTransfer ( Properties properties ) { } }

implementation: if ( DEBUG ) System . out . println ( "Disconnecting" ) ; try { if ( m_client != null ) m_client . disconnect ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } m_client = null ; super . finishTransfer ( properties ) ;


signature:
public class FtpDestination { /** * Add this file to the destination .
 * Note : Only supply the file or the stream , not both . Supply the object that is easier , given
 * the source . This dual option is given to allow destinations that require File objects from
 * ( such as FTP or HTTP ) Having to write the inStream to a physical file before processing it .
 * @ param file Source file .
 * @ param inStream Source stream .
 * @ param strpath Full path of the source file ( including the filename ) .
 * @ param strFilename Filename .
 * @ param lStreamLength Length of the stream ( - 1 if unknown ) . */
public long addNextFile ( SourceFile source ) { } }

implementation:
String strPath = source . getFilePath ( ) ; String strFilename = source . getFileName ( ) ; long lStreamLength = source . getStreamLength ( ) ; if ( m_client != null ) { // Success
try { int reply = this . changeDirectory ( strPath ) ; if ( ! FTPReply . isPositiveCompletion ( reply ) ) { System . out . println ( "Error on change dir: " + reply ) ; } else { File fileIn = source . makeInFile ( false ) ; FileInputStream inStream = new FileInputStream ( fileIn ) ; if ( DEBUG ) System . out . println ( "Sending File: " + strFilename ) ; if ( m_client . storeFile ( strFilename , inStream ) ) // Upload this file
{ // Success
} else { // Error
} inStream . close ( ) ; } } catch ( FileNotFoundException e ) { e . printStackTrace ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return lStreamLength ;


signature:
public class FtpDestination { /** * Change to this directory . */
public int changeDirectory ( String strPath ) throws IOException { } }

implementation:
int iLastSlash = strPath . lastIndexOf ( '/' ) ; if ( iLastSlash != - 1 ) strPath = strPath . substring ( 0 , iLastSlash ) ; else strPath = "" ; String strFTPPath = "" ; if ( m_strRootFTPDirectory . length ( ) > 0 ) { if ( ! strFTPPath . startsWith ( File . separator ) ) strFTPPath = File . separator + m_strRootFTPDirectory ; if ( strPath . length ( ) > 0 ) if ( ! strFTPPath . endsWith ( File . separator ) ) strFTPPath += File . separator ; } strFTPPath += strPath ; if ( strFTPPath . equals ( m_strLastPath ) ) return FTPReply . COMMAND_OK ; // Already in the current directory .
if ( DEBUG ) System . out . println ( "Change working directory to: " + strFTPPath ) ; int iError = FTPReply . COMMAND_OK ; if ( ! m_client . changeWorkingDirectory ( strFTPPath ) ) { if ( ! m_client . makeDirectory ( strFTPPath ) ) iError = FTPReply . FILE_ACTION_NOT_TAKEN ; else if ( ! m_client . changeWorkingDirectory ( strFTPPath ) ) iError = FTPReply . FILE_ACTION_NOT_TAKEN ; } m_strLastPath = strFTPPath ; return iError ;


signature:
public class JmxAttributePoller { /** * Poll the configured objects now and store the results in the objects themselves .
 * @ throws IOException */
public void poll ( ) throws IOException { } }

implementation:
synchronized ( this ) { // Make sure not to check and create a connection if shutting down .
if ( shutdownInd ) { return ; } // Atomically indicate polling is active now so a caller can determine with certainty whether polling is
// completely shutdown .
pollActiveInd = true ; } try { this . checkConnection ( ) ; this . concurrencyTestHooks . beforePollProcessorStart ( ) ; if ( this . mBeanAccessConnection instanceof MBeanBatchCapableAccessConnection ) { this . batchPollProcessor . pollBatch ( ( MBeanBatchCapableAccessConnection ) this . mBeanAccessConnection , this . polledObjects ) ; } else { this . pollIndividually ( ) ; } } catch ( IOException ioExc ) { this . safeClose ( this . mBeanAccessConnection ) ; this . mBeanAccessConnection = null ; throw ioExc ; } finally { this . concurrencyTestHooks . afterPollProcessorFinish ( ) ; synchronized ( this ) { pollActiveInd = false ; this . notifyAll ( ) ; } }