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

implementation: super . controlsToProperties ( ) ; String strPathname = m_tfRootPathname . getText ( ) ; m_properties . setProperty ( DEST_ROOT_PATHNAME_PARAM , strPathname ) ;


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

implementation: super . propertiesToControls ( ) ; String strPathname = m_properties . getProperty ( DEST_ROOT_PATHNAME_PARAM ) ; m_tfRootPathname . setText ( strPathname ) ;


signature:
public class ArgumentHandler { /** * This methods uses < code > AnnotatedInterfaceArguments < / code > to return an
 * instance of the specified class with methods returning values from the
 * arguments of this Handler .
 * Note that the interface must be annotated using < code > CommandLine < / code > .
 * @ param < I > the type of the interface
 * @ param interfaceClass a class instance for I , i . e . < em > I < / em > . class
 * @ return an object of type I
 * @ throws InvalidArgumentsException thrown when the argument - list doesn ' t match the definition in the interface annotations */
public < I > I getInstance ( Class < I > interfaceClass ) throws InvalidArgumentsException { } }

implementation: I instance ; instance = AnnotatedInterfaceArguments . getInstance ( interfaceClass , this ) . getValueObject ( ) ; return instance ;


signature:
public class ArgumentHandler { /** * Returns an instance of A if the arguments could be correctly parsed
 * and A was not a subclass of ArgumentsWithHelp or no help was requested , null
 * otherwise .
 * @ param < A >
 * @ param interfaceClass
 * @ param args
 * @ return */
public static < A > A readArguments ( Class < A > interfaceClass , String [ ] args ) { } }

implementation: A result = null ; try { final ArgumentHandler argumentHandler = new ArgumentHandler ( args ) ; result = argumentHandler . getInstance ( interfaceClass ) ; argumentHandler . processArguments ( new ArgumentProcessor ( ) { @ Override public void process ( List < String > remaining ) throws InvalidArgumentsException { if ( remaining . size ( ) > 0 ) { throw new InvalidArgumentsException ( "The following arguments could not be understood: " + remaining ) ; } } } ) ; } catch ( InvalidArgumentsException e ) { System . out . println ( e . getMessage ( ) ) ; showUsage ( interfaceClass ) ; result = null ; } if ( result instanceof ArgumentsWithHelp ) { if ( ( ( ArgumentsWithHelp ) result ) . getHelp ( ) ) { showUsage ( interfaceClass ) ; result = null ; } } return result ;


signature:
public class GreedyPreReadingInputStream { /** * ( non - Javadoc )
 * @ see java . io . InputStream # read ( ) */
public int read ( ) throws IOException { } }

implementation: if ( currentReader == null ) { try { getNextReader ( ) ; } catch ( StreamFinishedException e ) { return - 1 ; } } int result = currentReader . read ( ) ; while ( result == - 1 ) { try { getNextReader ( ) ; } catch ( StreamFinishedException e ) { return - 1 ; } result = currentReader . read ( ) ; } return result ;


signature:
public class BidiMapImpl { /** * / * ( non - Javadoc )
 * @ see java . util . Map # put ( K , V ) */
public V put ( K key , V value ) { } }

implementation:
// remove possible existing with same value
if ( backward . containsKey ( value ) ) { K oldKey = backward . get ( value ) ; forward . remove ( oldKey ) ; } if ( forward . containsKey ( key ) ) { V oldValue = forward . get ( key ) ; backward . remove ( oldValue ) ; } backward . put ( value , key ) ; return forward . put ( key , value ) ;


signature:
public class BidiMapImpl { /** * / * ( non - Javadoc )
 * @ see java . util . Map # remove ( java . lang . Object ) */
public V remove ( Object key ) { } }

implementation: V value = forward . remove ( key ) ; backward . remove ( value ) ; return value ;


signature:
public class ProtobufSerializerUtils { /** * Retrieve the ProtobufClass based on the POJO value . The returned value may get converted ,
 * as the Protobuf builders / setters use primitives . For example , if user has declared < code > Integer < / code > ,
 * this get ' s converted to < code > int < / code > .
 * @ param value - POJO object
 * @ param protobufClass - the Protobuf class
 * @ return Class & lt ; ? extends Object & gt ; - actual Protobuf class to use in setter */
public static final Class < ? extends Object > getProtobufClass ( Object value , Class < ? extends Object > protobufClass ) { } }

implementation: if ( value instanceof Integer ) { return Integer . TYPE ; } if ( value instanceof Boolean ) { return Boolean . TYPE ; } if ( value instanceof Double ) { return Double . TYPE ; } if ( value instanceof Long || value instanceof Date ) { return Long . TYPE ; } if ( value instanceof List ) { return Iterable . class ; } return protobufClass ;


signature:
public class ProtobufSerializerUtils { /** * Return a ProtobufEntity annotation from any object sent , null if there is none .
 * @ param clazz - any Class
 * @ return ProtobufEntity annotation
 * @ see ca . jeb . protobuf . ProtobufEntity */
public static final ProtobufEntity getProtobufEntity ( Class < ? > clazz ) { } }

implementation: final ProtobufEntity protoBufEntity = clazz . getAnnotation ( ProtobufEntity . class ) ; if ( protoBufEntity != null ) { return protoBufEntity ; } return null ;


signature:
public class ProtobufSerializerUtils { /** * Returns true if there is a ProtobufEntity annotation on this class .
 * @ param clazz - any Class
 * @ return boolean - true , if there is a ProtobufEntity annotation , else , false
 * @ see ProtobufEntity */
public static final boolean isProtbufEntity ( Class < ? > clazz ) { } }

implementation: final ProtobufEntity protoBufEntity = getProtobufEntity ( clazz ) ; if ( protoBufEntity != null ) { return true ; } return false ;


signature:
public class ProtobufSerializerUtils { /** * Return the Protobuf Class based on the pojo class , i . e . grab the value from the ProtobufEntity annotation .
 * @ param clazz - any Class
 * @ return Class & lt ; ? extends GeneratedMessage & gt ; */
public static final Class < ? extends GeneratedMessage > getProtobufClassFromPojoAnno ( Class < ? > clazz ) { } }

implementation: final ProtobufEntity annotation = getProtobufEntity ( clazz ) ; final Class < ? extends GeneratedMessage > gpbClazz = ( Class < ? extends GeneratedMessage > ) annotation . value ( ) ; if ( gpbClazz == null ) { return null ; } return gpbClazz ;


signature:
public class ProtobufSerializerUtils { /** * Returns a full mapping of all Protobuf fields from the POJO class .
 * Essentially , the only fields that will be returned if they have
 * the ProtobufAttribute annotation .
 * @ param fromClazz - Class & lt ; ? extends Object & gt ;
 * @ return Map & lt ; Field , ProtobufAttribute & gt ; */
public static final Map < Field , ProtobufAttribute > getAllProtbufFields ( Class < ? extends Object > fromClazz ) { } }

implementation:
Map < Field , ProtobufAttribute > protoBufFields = CLASS_TO_FIELD_MAP_CACHE . get ( fromClazz . getCanonicalName ( ) ) ; if ( protoBufFields != null ) { return protoBufFields ; } else { protoBufFields = new HashMap < > ( ) ; } final List < Field > fields = JReflectionUtils . getAllFields ( new ArrayList < Field > ( ) , fromClazz ) ; for ( Field field : fields ) { final Annotation annotation = field . getAnnotation ( ProtobufAttribute . class ) ; if ( annotation == null ) { continue ; } final ProtobufAttribute gpbAnnotation = ( ProtobufAttribute ) annotation ; protoBufFields . put ( field , gpbAnnotation ) ; } // Caching to increase speed
CLASS_TO_FIELD_MAP_CACHE . put ( fromClazz . getCanonicalName ( ) , protoBufFields ) ; return protoBufFields ;


signature:
public class ProtobufSerializerUtils { /** * Return the setter for the Protobuf builder . < br >
 * 1 . Defaults to just " set " + upper case the first character of the fieldName .
 * 2 . If it ' s a collection , use the " addAll " type method Protobuf has
 * 3 . Otherwise , use the override value from the user ' s ProtobufAttribute annotation < br >
 * @ param protobufAttribute - { @ link ProtobufAttribute }
 * @ param field - String
 * @ param fieldValue - POJO ' s filed Object
 * @ return String - the setter to be used on Protobuf builder */
public static final String getProtobufSetter ( ProtobufAttribute protobufAttribute , Field field , Object fieldValue ) { } }

implementation:
final String fieldName = field . getName ( ) ; final String upperClassName = field . getDeclaringClass ( ) . getCanonicalName ( ) ; // Look at the cache first
Map < String , String > map = CLASS_TO_FIELD_SETTERS_MAP_CACHE . get ( upperClassName ) ; if ( map != null ) { if ( ! map . isEmpty ( ) && map . containsKey ( fieldName ) ) { return map . get ( fieldName ) ; } } else { map = new ConcurrentHashMap < > ( ) ; } String setter = "set" + JStringUtils . upperCaseFirst ( fieldName ) ; if ( fieldValue instanceof Collection ) { setter = "addAll" + JStringUtils . upperCaseFirst ( fieldName ) ; } // Finally override setter with a value that is configured in ProtobufAttribute annotation
final String configedSetter = protobufAttribute . protobufSetter ( ) ; if ( ! configedSetter . equals ( JStringUtils . EMPTY ) ) { setter = configedSetter ; } map . put ( fieldName , setter ) ; CLASS_TO_FIELD_SETTERS_MAP_CACHE . put ( upperClassName , map ) ; return setter ;


signature:
public class ProtobufSerializerUtils { /** * Retrieve the getter against the Protobuf class ; default is to is " get " plus upper case first character of the field name .
 * @ param protobufAttribute - { @ link ProtobufAttribute }
 * @ param field - { @ link Field }
 * @ return String */
public static final String getProtobufGetter ( ProtobufAttribute protobufAttribute , Field field ) { } }

implementation:
final String fieldName = field . getName ( ) ; final String upperClassName = field . getDeclaringClass ( ) . getCanonicalName ( ) ; // Look at the cache first
Map < String , String > map = CLASS_TO_FIELD_GETTERS_MAP_CACHE . get ( upperClassName ) ; if ( map != null ) { if ( ! map . isEmpty ( ) && map . containsKey ( fieldName ) ) { return map . get ( fieldName ) ; } } else { map = new ConcurrentHashMap < > ( ) ; } final String upperCaseFirstFieldName = JStringUtils . upperCaseFirst ( field . getName ( ) ) ; String getter = "get" + upperCaseFirstFieldName ; if ( Collection . class . isAssignableFrom ( field . getType ( ) ) ) { getter += "List" ; } if ( ! protobufAttribute . protobufGetter ( ) . isEmpty ( ) ) { return protobufAttribute . protobufGetter ( ) ; } map . put ( fieldName , getter ) ; CLASS_TO_FIELD_GETTERS_MAP_CACHE . put ( upperClassName , map ) ; return getter ;


signature:
public class ProtobufSerializerUtils { /** * Retrieve the setter on the POJO class ; default is to is " set " plus upper case first character of the field name .
 * @ param protobufAttribute - { @ link ProtobufAttribute }
 * @ param field - { @ link Field }
 * @ return String - the name of the POJO setter */
public static final String getPojoSetter ( ProtobufAttribute protobufAttribute , Field field ) { } }

implementation:
final String fieldName = field . getName ( ) ; final String upperClassName = field . getDeclaringClass ( ) . getCanonicalName ( ) ; // Look at the cache first
Map < String , String > map = CLASS_TO_FIELD_SETTERS_MAP_CACHE . get ( upperClassName ) ; if ( map != null ) { if ( ! map . isEmpty ( ) && map . containsKey ( fieldName ) ) { return map . get ( fieldName ) ; } } else { map = new ConcurrentHashMap < > ( ) ; } final String upperCaseFirstFieldName = JStringUtils . upperCaseFirst ( field . getName ( ) ) ; String setter = "set" + upperCaseFirstFieldName ; if ( ! protobufAttribute . pojoSetter ( ) . isEmpty ( ) ) { return protobufAttribute . pojoSetter ( ) ; } map . put ( fieldName , setter ) ; CLASS_TO_FIELD_SETTERS_MAP_CACHE . put ( upperClassName , map ) ; return setter ;


signature:
public class PasswordValidatorFactory { /** * Return a singleton , fully initialized instance of a { @ link PasswordValidator } class to use for
 * JAAS authentication .
 * Retrieving a singleton by this method will cause the factory to keep state , and store a reference to the
 * singleton for later use . You may reset the factory state using the { @ code reset ( ) } method to retrieve a new
 * / different singleton the next time this method is called . .
 * Note that any properties of the singleton ( e . g . configuration ) cannot necessarily be changed easily . You may call
 * the singleton ' s { @ code init ( ) } method , but depending on the implementation provided by the respective class , this
 * may or may not have the expected effect .
 * If you need tight control over the singleton , including its lifecycle and configuration , or you require more than
 * one singleton that are different in their internal state ( e . g . with different configurations ) , then you should
 * create such objects with the { @ code getInstance ( ) } method and maintain their state as " singletons " in your
 * application ' s business logic .
 * Classes implementing the { @ link PasswordValidator } interface < b > must < / b > be thread safe .
 * @ param className The name of a class that implements the PasswordValidator interface
 * @ param properties The properties to initialize the instance with
 * @ return An instance of a class implementing the { @ code PasswordValidator } interface
 * @ throws FactoryException When the class cannot be instantiated
 * @ throws NullPointerException When the { @ code className } or { @ code properties } are { @ code null }
 * @ throws IllegalArgumentException When { @ code className } is empty */
@ SuppressWarnings ( "PMD.NonThreadSafeSingleton" ) public static PasswordValidator getSingleton ( final String className , final CommonProperties properties ) throws FactoryException { } }

implementation: Validate . notBlank ( className , "The validated character sequence 'className' is null or empty" ) ; Validate . notNull ( properties , "The validated object 'properties' is null" ) ; if ( passwordValidatorInstance == null ) { synchronized ( PasswordValidatorFactory . class ) { if ( passwordValidatorInstance == null ) { passwordValidatorInstance = getInstance ( className , properties ) ; } } } return passwordValidatorInstance ;


signature:
public class FilterLastVersionChanged { /** * Filter that make SQL WHERE filter for entities
 * with < b > itsVersion < / b > and < b > changed time < / b > algorithm .
 * @ param pEntityClass Entity Class
 * @ param pAddParam additional params
 * @ return filter e . g . " ITSVERSION > 12312432300012"
 * @ throws Exception - an exception */
@ Override public final String makeFilter ( final Class < ? > pEntityClass , final Map < String , Object > pAddParam ) throws Exception { } }

implementation: return pEntityClass . getSimpleName ( ) . toUpperCase ( ) + ".ITSVERSION>" + this . lastReplicatedDateEvaluator . evalData ( pAddParam ) . getTime ( ) ;


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

implementation: super . controlsToProperties ( ) ; String strPathname = m_tfRootPathname . getText ( ) ; m_properties . setProperty ( BASE_URL_PARAM , strPathname ) ;


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

implementation: super . propertiesToControls ( ) ; String strPathname = m_properties . getProperty ( BASE_URL_PARAM ) ; m_tfRootPathname . setText ( strPathname ) ;


signature:
public class ChinesePinyin { /** * 得到字符串对应的拼音 ( 默认小写 , 不带声调 ) , 不可识别的字符原样返回 . */
public String getFullPinyin ( String str ) { } }

implementation: if ( str == null ) return null ; StringBuffer sb = new StringBuffer ( ) ; String [ ] item = null ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { char ch = str . charAt ( i ) ; item = getPinyinFromChar ( ch ) ; if ( item == null ) { sb . append ( ch ) ; } else { sb . append ( item [ 0 ] . substring ( 0 , item [ 0 ] . length ( ) - 1 ) ) ; } } return sb . toString ( ) ;


signature:
public class JsonUtil { /** * return a ObjectMapper if exist , else new ObjectMapper
 * @ return ObjectMapper */
public static ObjectMapper getMapper ( ) { } }

implementation: ObjectMapper mapper = threadMapper . get ( ) ; if ( mapper == null ) { mapper = initMapper ( ) ; threadMapper . set ( mapper ) ; } return mapper ;


signature:
public class JsonUtil { /** * Initialize mapper
 * @ return initialized { @ link ObjectMapper } */
private static ObjectMapper initMapper ( ) { } }

implementation:
ObjectMapper mapper = new ObjectMapper ( ) ; // to enable standard indentation ( " pretty - printing " ) :
mapper . enable ( SerializationFeature . INDENT_OUTPUT ) ; // to allow serialization of " empty " POJOs ( no properties to serialize )
// ( without this setting , an exception is thrown in those cases )
mapper . disable ( SerializationFeature . FAIL_ON_EMPTY_BEANS ) ; // set writer flush after writer value
mapper . enable ( SerializationFeature . FLUSH_AFTER_WRITE_VALUE ) ; // ObjectMapper will call close ( ) and root values that implement
// java . io . Closeable ;
// including cases where exception is thrown and serialization does not
// completely succeed .
mapper . enable ( SerializationFeature . CLOSE_CLOSEABLE ) ; // to write java . util . Date , Calendar as number ( timestamp ) :
mapper . disable ( SerializationFeature . WRITE_DATES_AS_TIMESTAMPS ) ; // disable default date to timestamp
mapper . disable ( SerializationFeature . WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS ) ; // DeserializationFeature for changing how JSON is read as POJOs :
// to prevent exception when encountering unknown property :
mapper . disable ( DeserializationFeature . FAIL_ON_UNKNOWN_PROPERTIES ) ; // disable default date to timestamp
mapper . disable ( DeserializationFeature . READ_DATE_TIMESTAMPS_AS_NANOSECONDS ) ; // to allow coercion of JSON empty String ( " " ) to null Object value :
mapper . enable ( DeserializationFeature . ACCEPT_EMPTY_STRING_AS_NULL_OBJECT ) ; DateFormat df = new SimpleDateFormat ( "yyyyMMddHHmmssSSS" ) ; // Set Default date fromat
mapper . setDateFormat ( df ) ; return mapper ;


signature:
public class JsonUtil { /** * return a JsonFactory if exist , else new JsonFactory
 * @ return JsonFactory */
public static JsonFactory getJsonFactory ( ) { } }

implementation:
JsonFactory jsonFactory = threadJsonFactory . get ( ) ; if ( jsonFactory == null ) { jsonFactory = new JsonFactory ( ) ; // JsonParser . Feature for configuring parsing settings :
// to allow C / C + + style comments in JSON ( non - standard , disabled by
// default )
jsonFactory . enable ( JsonParser . Feature . ALLOW_COMMENTS ) ; // to allow ( non - standard ) unquoted field names in JSON :
jsonFactory . disable ( JsonParser . Feature . ALLOW_UNQUOTED_FIELD_NAMES ) ; // to allow use of apostrophes ( single quotes ) , non standard
jsonFactory . disable ( JsonParser . Feature . ALLOW_SINGLE_QUOTES ) ; // JsonGenerator . Feature for configuring low - level JSON generation :
// no escaping of non - ASCII characters :
jsonFactory . disable ( JsonGenerator . Feature . ESCAPE_NON_ASCII ) ; threadJsonFactory . set ( jsonFactory ) ; } return jsonFactory ;


signature:
public class JsonUtil { /** * Json string to java bean < br >
 * List , Array , Map
 * < pre >
 * clazz = new TypeReference & lt ; List & lt ; MyBean & gt ; & gt ; ( ) { } ;
 * e . g :
 * toBean ( jsonStr , new TypeReference & lt ; List & lt ; MyBean & gt ; & gt ; ( ) { } )
 * toBean ( jsonStr , MyBean [ ] )
 * toBean ( jsonStr , new TypeReference & lt ; Map & lt ; String , Map & lt ; String , MyBean & gt ; & gt ; ( ) { } )
 * < / pre >
 * @ param jsonStr json String
 * @ param valueTypeRef value type ref
 * @ param < T > t
 * @ return bean */
public static < T > T toBean ( String jsonStr , TypeReference < T > valueTypeRef ) { } }

implementation: if ( valueTypeRef == null || jsonStr == null ) return null ; return toBean ( new MyJsonParser ( jsonStr ) , valueTypeRef ) ;


signature:
public class JsonUtil { /** * Json string to java bean < br >
 * List , Array , Map
 * < pre >
 * clazz = new TypeReference & lt ; List & lt ; MyBean & gt ; & gt ; ( ) { } ;
 * e . g :
 * toBean ( jsonBytes , new TypeReference & lt ; List & lt ; MyBean & gt ; & gt ; ( ) { } )
 * toBean ( jsonBytes , MyBean [ ] )
 * toBean ( jsonBytes , new TypeReference & lt ; Map & lt ; String , Map & lt ; String , MyBean & gt ; & gt ; ( ) { } )
 * < / pre >
 * @ param jsonBytes json bytes
 * @ param valueTypeRef value type ref
 * @ param < T > t
 * @ return bean */
public static < T > T toBean ( byte [ ] jsonBytes , TypeReference < T > valueTypeRef ) { } }

implementation: if ( valueTypeRef == null || jsonBytes == null ) return null ; return toBean ( new MyJsonParser ( jsonBytes ) , valueTypeRef ) ;


signature:
public class JsonUtil { /** * Json string to java bean < br >
 * List , Array , Map
 * < pre >
 * clazz = new TypeReference & lt ; List & lt ; MyBean & gt ; & gt ; ( ) { } ;
 * e . g :
 * toBean ( jsonReader , new TypeReference & lt ; List & lt ; MyBean & gt ; & gt ; ( ) { } )
 * toBean ( jsonReader , MyBean [ ] )
 * toBean ( jsonReader , new TypeReference & lt ; Map & lt ; String , Map & lt ; String , MyBean & gt ; & gt ; ( ) { } )
 * < / pre >
 * @ param jsonReader json reader
 * @ param valueTypeRef value type ref
 * @ param < T > t
 * @ return bean */
public static < T > T toBean ( Reader jsonReader , TypeReference < T > valueTypeRef ) { } }

implementation: if ( valueTypeRef == null || jsonReader == null ) return null ; return toBean ( new MyJsonParser ( jsonReader ) , valueTypeRef ) ;


signature:
public class JsonUtil { /** * Json string to java bean < br >
 * List , Array , Map
 * < pre >
 * clazz = new TypeReference & lt ; List & lt ; MyBean & gt ; & gt ; ( ) { } ;
 * e . g :
 * toBean ( jsonURL , new TypeReference & lt ; List & lt ; MyBean & gt ; & gt ; ( ) { } )
 * toBean ( jsonURL , MyBean [ ] )
 * toBean ( jsonURL , new TypeReference & lt ; Map & lt ; String , Map & lt ; String , MyBean & gt ; & gt ; ( ) { } )
 * < / pre >
 * @ param jsonURL json url
 * @ param valueTypeRef value type ref
 * @ param < T > t
 * @ return bean */
public static < T > T toBean ( URL jsonURL , TypeReference < T > valueTypeRef ) { } }

implementation: if ( valueTypeRef == null || jsonURL == null ) return null ; return toBean ( new MyJsonParser ( jsonURL ) , valueTypeRef ) ;


signature:
public class JsonUtil { /** * Json string to java bean < br >
 * List , Array , Map
 * < pre >
 * clazz = new TypeReference & lt ; List & lt ; MyBean & gt ; & gt ; ( ) { } ;
 * e . g :
 * toBean ( jsonFile , new TypeReference & lt ; List & lt ; MyBean & gt ; & gt ; ( ) { } )
 * toBean ( jsonFile , MyBean [ ] )
 * toBean ( jsonFile , new TypeReference & lt ; Map & lt ; String , Map & lt ; String , MyBean & gt ; & gt ; ( ) { } )
 * < / pre >
 * @ param jsonFile josn file
 * @ param valueTypeRef value type ref
 * @ param < T > t
 * @ return bean */
public static < T > T toBean ( File jsonFile , TypeReference < T > valueTypeRef ) { } }

implementation: if ( valueTypeRef == null || jsonFile == null ) return null ; return toBean ( new MyJsonParser ( jsonFile ) , valueTypeRef ) ;


signature:
public class JsonUtil { /** * Json string to java bean < br >
 * call { @ link MyJsonParser # getJsonParser ( ) } return a JsonParser
 * @ param myJsonParser custom json parser
 * @ param valueTypeRef value type ref
 * @ see # toBean ( JsonParser , TypeReference )
 * @ param < T > t
 * @ return bean */
protected static < T > T toBean ( MyJsonParser myJsonParser , TypeReference < T > valueTypeRef ) { } }

implementation: if ( myJsonParser . getJsonParser ( ) == null ) return null ; return toBean ( myJsonParser . getJsonParser ( ) , valueTypeRef ) ;


signature:
public class JsonUtil { /** * Json string to java bean < br >
 * e . g :
 * < pre >
 * { " id " : idValue , " name " : nameValue , " aBean " : { " aBeanId " : aBeanIdValue , . . . } }
 * < / pre >
 * List , Array , Map . . . see { @ link # toBean ( String , TypeReference ) }
 * @ param jsonStr json String
 * @ param clazz class
 * @ param < T > t
 * @ return bean */
public static < T > T toBean ( String jsonStr , Class < T > clazz ) { } }

implementation: if ( clazz == null || jsonStr == null ) return null ; return toBean ( new MyJsonParser ( jsonStr ) , clazz ) ;


signature:
public class JsonUtil { /** * Json string to java bean < br >
 * e . g :
 * < pre >
 * { " id " : idValue , " name " : nameValue , " aBean " : { " aBeanId " : aBeanIdValue , . . . } }
 * < / pre >
 * List , Array , Map . . . see { @ link # toBean ( byte [ ] , TypeReference ) }
 * @ param jsonBytes josn bytes
 * @ param clazz class
 * @ param < T > t
 * @ return bean */
public static < T > T toBean ( byte [ ] jsonBytes , Class < T > clazz ) { } }

implementation: if ( clazz == null || jsonBytes == null ) return null ; return toBean ( new MyJsonParser ( jsonBytes ) , clazz ) ;


signature:
public class JsonUtil { /** * Json string to java bean < br >
 * e . g :
 * < pre >
 * { " id " : idValue , " name " : nameValue , " aBean " : { " aBeanId " : aBeanIdValue , . . . } }
 * < / pre >
 * List , Array , Map . . . see { @ link # toBean ( Reader , TypeReference ) }
 * @ param jsonReader json reader
 * @ param clazz class
 * @ param < T > t
 * @ return bean */
public static < T > T toBean ( Reader jsonReader , Class < T > clazz ) { } }

implementation: if ( clazz == null || jsonReader == null ) return null ; return toBean ( new MyJsonParser ( jsonReader ) , clazz ) ;


signature:
public class JsonUtil { /** * Json string to java bean < br >
 * e . g :
 * < pre >
 * { " id " : idValue , " name " : nameValue , " aBean " : { " aBeanId " : aBeanIdValue , . . . } }
 * < / pre >
 * List , Array , Map . . . see { @ link # toBean ( URL , TypeReference ) }
 * @ param jsonURL josn url
 * @ param clazz class
 * @ param < T > t
 * @ return bean */
public static < T > T toBean ( URL jsonURL , Class < T > clazz ) { } }

implementation: if ( clazz == null || jsonURL == null ) return null ; return toBean ( new MyJsonParser ( jsonURL ) , clazz ) ;


signature:
public class JsonUtil { /** * Json string to java bean < br >
 * e . g :
 * < pre >
 * { " id " : idValue , " name " : nameValue , " aBean " : { " aBeanId " : aBeanIdValue , . . . } }
 * < / pre >
 * List , Array , Map . . . see { @ link # toBean ( File , TypeReference ) }
 * @ param jsonFile json file
 * @ param clazz class
 * @ param < T > t
 * @ return bean */
public static < T > T toBean ( File jsonFile , Class < T > clazz ) { } }

implementation: if ( clazz == null || jsonFile == null ) return null ; return toBean ( new MyJsonParser ( jsonFile ) , clazz ) ;


signature:
public class JsonUtil { /** * Json string to java bean < br >
 * call { @ link MyJsonParser # getJsonParser ( ) } return a JsonParser
 * @ param myJsonParser custom json parser
 * @ param clazz class
 * @ see # toBean ( JsonParser , Class )
 * @ param < T > t
 * @ return bean */
protected static < T > T toBean ( MyJsonParser myJsonParser , Class < T > clazz ) { } }

implementation: if ( myJsonParser . getJsonParser ( ) == null ) return null ; return toBean ( myJsonParser . getJsonParser ( ) , clazz ) ;


signature:
public class JsonUtil { /** * Json string to java bean < br >
 * e . g :
 * < pre >
 * { " id " : idValue , " name " : nameValue , " aBean " : { " aBeanId " : aBeanIdValue , . . . } }
 * < / pre >
 * List , Array , Map . . . see { @ link # toBean ( String , TypeReference ) }
 * @ param jsonParser json parser
 * @ param clazz class
 * @ param < T > t
 * @ return bean */
public static < T > T toBean ( JsonParser jsonParser , Class < T > clazz ) { } }

implementation: if ( clazz == null || jsonParser == null ) return null ; T obj = null ; try { obj = getMapper ( ) . readValue ( jsonParser , clazz ) ; } catch ( JsonParseException e ) { log . error ( "{}" , e . getMessage ( ) , e ) ; } catch ( JsonMappingException e ) { log . error ( "{}" , e . getMessage ( ) , e ) ; } catch ( IOException e ) { log . error ( "{}" , e . getMessage ( ) , e ) ; } finally { try { jsonParser . close ( ) ; } catch ( IOException e ) { } } return obj ;


signature:
public class JsonUtil { /** * Bean to json string
 * @ param obj obj
 * bean object
 * @ param < T > t
 * @ return json string */
public static < T > String toJson ( T obj ) { } }

implementation: StringWriter writer = new StringWriter ( ) ; String jsonStr = "" ; JsonGenerator gen = null ; try { gen = getJsonFactory ( ) . createGenerator ( writer ) ; getMapper ( ) . writeValue ( gen , obj ) ; writer . flush ( ) ; jsonStr = writer . toString ( ) ; } catch ( IOException e ) { log . error ( "{}" , e . getMessage ( ) , e ) ; } finally { if ( gen != null ) { try { gen . close ( ) ; } catch ( IOException e ) { } } } return jsonStr ;


signature:
public class DbUtil { /** * Close a { @ code Connection } and log any SQLExceptions that occur .
 * @ param conn Connection to close ( may be { @ code null } ) */
public static void close ( final Connection conn ) { } }

implementation: if ( conn != null ) { try { conn . close ( ) ; } catch ( SQLException e ) { final String error = "Error closing JDBC connection. This may indicate a resource leak." ; LOG . warn ( error , e ) ; } }


signature:
public class DbUtil { /** * Close a { @ code PreparedStatement } and log any SQLExceptions that occur .
 * @ param statement PreparedStatement to close ( may be { @ code null } ) */
public static void close ( final PreparedStatement statement ) { } }

implementation: if ( statement != null ) { try { statement . close ( ) ; } catch ( SQLException e ) { final String error = "Error closing JDBC prepared statement. This may indicate a resource leak." ; LOG . warn ( error , e ) ; } }


signature:
public class DbUtil { /** * Close a { @ code ResultSet } and log any SQLExceptions that occur .
 * @ param resultSet ResultSet to close ( may be { @ code null } ) */
public static void close ( final ResultSet resultSet ) { } }

implementation: if ( resultSet != null ) { try { resultSet . close ( ) ; } catch ( SQLException e ) { final String error = "Error closing JDBC result set. This may indicate a resource leak." ; LOG . warn ( error , e ) ; } }


signature:
public class IocObjectUtils { /** * 注入配置文件中自定义的属性字段 */
public static List < PropertyInjector > doGetPropertyInjectors ( Ioc ioc , KlassInfo klass , Configuration properties ) { } }

implementation: if ( properties == null || properties . size ( ) == 0 ) { return Collections . emptyList ( ) ; } List < PropertyInjector > injectors = new ArrayList < PropertyInjector > ( ) ; for ( String name : properties . keySet ( ) ) { PropertyInfo prop = klass . getProperty ( name ) ; if ( prop == null ) { throw new IllegalStateException ( "Property not found: " + klass + "#" + name ) ; } if ( ! prop . writable ( ) ) { throw new IllegalStateException ( "Property not writable: " + prop ) ; } Object value ; Class < ? > rawType = prop . getRawType ( klass . getType ( ) ) ; if ( List . class . isAssignableFrom ( rawType ) ) { value = properties . getValueList ( prop . getName ( ) , prop . getRawComponentType ( klass . getType ( ) , 0 ) ) ; } else { value = properties . getValue ( prop . getName ( ) , rawType , null ) ; } injectors . add ( new PropertyInjector ( prop , value ) ) ; } return injectors ;


signature:
public class SrvEntityFieldFillerStd { /** * 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 ( "NULL" . equals ( pFieldStrValue ) ) { rField . set ( pEntity , null ) ; return ; } boolean isFilled = true ; try { if ( rField . getType ( ) == Double . class ) { rField . set ( pEntity , Double . valueOf ( pFieldStrValue ) ) ; } else if ( rField . getType ( ) == Float . class ) { rField . set ( pEntity , Float . valueOf ( pFieldStrValue ) ) ; } else if ( rField . getType ( ) == BigDecimal . class ) { rField . set ( pEntity , new BigDecimal ( pFieldStrValue ) ) ; } else if ( rField . getType ( ) == Date . class ) { rField . set ( pEntity , new Date ( Long . parseLong ( pFieldStrValue ) ) ) ; } else if ( Enum . class . isAssignableFrom ( rField . getType ( ) ) ) { Integer intVal = Integer . valueOf ( pFieldStrValue ) ; Enum val = null ; if ( intVal != null ) { val = ( Enum ) rField . getType ( ) . getEnumConstants ( ) [ intVal ] ; } rField . set ( pEntity , val ) ; } else if ( rField . getType ( ) == Boolean . class ) { rField . set ( pEntity , Boolean . valueOf ( pFieldStrValue ) ) ; } else if ( Integer . class == rField . getType ( ) ) { rField . set ( pEntity , Integer . valueOf ( pFieldStrValue ) ) ; } else if ( Long . class == rField . getType ( ) ) { rField . set ( pEntity , Long . valueOf ( pFieldStrValue ) ) ; } else if ( String . class == rField . getType ( ) ) { String unescaped = this . utilXml . unescapeXml ( pFieldStrValue ) ; rField . set ( pEntity , unescaped ) ; } else { isFilled = false ; } } catch ( Exception ex ) { throw new ExceptionWithCode ( ExceptionWithCode . WRONG_PARAMETER , "Can not fill field: " + pEntity + "/" + pFieldName + "/" + pFieldStrValue + ", " + ex . getMessage ( ) , ex ) ; } if ( ! isFilled ) { throw new ExceptionWithCode ( ExceptionWithCode . CONFIGURATION_MISTAKE , "There is no rule to fill field: " + pEntity + "/" + pFieldName + "/" + pFieldStrValue ) ; }


signature:
public class DefaultContentRect { /** * Sets all the border values .
 * @ param top
 * @ param right
 * @ param bottom
 * @ param left */
public void setBorders ( int top , int right , int bottom , int left ) { } }

implementation: setTopBorder ( top ) ; setRightBorder ( right ) ; setBottomBorder ( bottom ) ; setLeftBorder ( left ) ;


signature:
public class ConstructorInfo { /** * 将 Constructor 对象转成 ConstructorInfo 对象 .
 * @ param constructor - 原始对象
 * @ return ConstructorInfo 对象 */
public static ConstructorInfo create ( Constructor < ? > constructor ) { } }

implementation: KlassInfo klass = KlassInfo . create ( constructor . getDeclaringClass ( ) ) ; return klass . getDeclaredConstructor ( constructor ) ;


signature:
public class CubeSensorsUtils { /** * Obtain an access token . If previously a token was created and persisted
 * will be returned after validation ( a real call is made to validate ) .
 * < p > If no token previously persisted , the method will create a new token using
 * the authentication provider ( AuthProvider )
 * @ return the access token . */
public Token getAccessToken ( ) { } }

implementation:
Token accessToken = authPersistence . getToken ( ) ; if ( isTokenValid ( accessToken ) ) { return accessToken ; } // authorize
accessToken = authorize ( ) ; // save
authPersistence . saveToken ( accessToken ) ; return accessToken ;


signature:
public class HttpConn { /** * Send a http request with explicit params
 * @ param target target address
 * @ param method { @ link com . rockagen . commons . http . RequestMethod }
 * @ return result String
 * @ throws IOException if an I / O error occurs */
public static String send ( String target , RequestMethod method ) throws IOException { } }

implementation: return send ( target , "" , method ) ;


signature:
public class HttpConn { /** * Send a http request with explicit params
 * @ param target target address
 * @ param headers headers
 * @ param method { @ link com . rockagen . commons . http . RequestMethod }
 * @ return result String
 * @ throws IOException if an I / O error occurs */
public static String send ( String target , Map < String , String > headers , RequestMethod method ) throws IOException { } }

implementation: return send ( target , ENCODING , headers , method ) ;


signature:
public class HttpConn { /** * Send a http request with explicit params
 * @ param target target address
 * @ param proxy proxy address
 * @ param method { @ link com . rockagen . commons . http . RequestMethod }
 * @ return result String
 * @ throws IOException if an I / O error occurs */
public static String send ( String target , String proxy , RequestMethod method ) throws IOException { } }

implementation: return send ( target , proxy , ENCODING , method ) ;


signature:
public class HttpConn { /** * Send a http request with explicit params
 * @ param upc basic auth { @ link UsernamePasswordCredentials }
 * @ param target target address
 * @ param method { @ link com . rockagen . commons . http . RequestMethod }
 * @ return result String
 * @ throws IOException if an I / O error occurs */
public static String send ( UsernamePasswordCredentials upc , String target , RequestMethod method ) throws IOException { } }

implementation: return send ( upc , target , ENCODING , method ) ;


signature:
public class HttpConn { /** * Send a http request with explicit params
 * @ param upc basic auth { @ link UsernamePasswordCredentials }
 * @ param keystore keyStore InputStream ( Custom SSL )
 * @ param password keyStore password
 * @ param target target address
 * @ param proxy proxy address
 * @ param encoding ( default UTF - 8)
 * @ param headers headers
 * @ param method { @ link com . rockagen . commons . http . RequestMethod }
 * @ return result String
 * @ throws IOException if an I / O error occurs */
public static String send ( UsernamePasswordCredentials upc , InputStream keystore , char [ ] password , String target , String proxy , String encoding , Map < String , String > headers , RequestMethod method ) throws IOException { } }

implementation:
// TargetHost
Object [ ] tmp = resolveUrl ( target ) ; HttpHost targetHost = ( HttpHost ) tmp [ 0 ] ; // URI
String uri = ( String ) tmp [ 1 ] ; // ProxyHost
HttpHost proxyHost = null ; if ( ! CommUtil . isBlank ( proxy ) ) { Object [ ] tmp1 = resolveUrl ( proxy ) ; proxyHost = ( HttpHost ) tmp1 [ 0 ] ; } Header [ ] _headers = null ; if ( headers != null && headers . size ( ) > 0 ) { _headers = new Header [ headers . size ( ) ] ; for ( Map . Entry < String , String > header : headers . entrySet ( ) ) { Header h = new BasicHeader ( header . getKey ( ) , header . getValue ( ) ) ; ArrayUtil . add ( _headers , h ) ; } } return send ( upc , keystore , password , targetHost , uri , proxyHost , encoding , method , _headers ) ;


signature:
public class HttpConn { /** * Send a http request with explicit params
 * @ param upc basic auth { @ link UsernamePasswordCredentials }
 * @ param keystore keyStore InputStream ( Custom SSL )
 * @ param password keyStore password
 * @ param targetHost HttpHost
 * @ param uri URI
 * @ param proxyHost HttpHost
 * @ param encoding ( default UTF - 8)
 * @ param method { @ link com . rockagen . commons . http . RequestMethod }
 * @ param headers headers ( optional )
 * @ return result String
 * @ throws IOException if an I / O error occurs */
public static String send ( UsernamePasswordCredentials upc , InputStream keystore , char [ ] password , HttpHost targetHost , String uri , HttpHost proxyHost , String encoding , RequestMethod method , Header ... headers ) throws IOException { } }

implementation: if ( ! uri . startsWith ( "/" ) ) { uri = "/" + uri ; } HttpRequest hm = getHttpMethod ( method , uri ) ; if ( headers != null && headers . length > 0 ) { hm . setHeaders ( headers ) ; } log . debug ( "url: {} method: {}" , getURL ( targetHost , uri ) , method ) ; return execute ( targetHost , proxyHost , hm , encoding , upc , keystore , password ) ;


signature:
public class HttpConn { /** * Send a http request with implicit params
 * @ param target target address
 * @ param body request body
 * @ return result String
 * @ throws IOException if an I / O error occurs */
public static String sendBody ( String target , byte [ ] body ) throws IOException { } }

implementation: return sendBody ( target , body , RequestMethod . POST ) ;


signature:
public class HttpConn { /** * Send a http request with implicit params
 * @ param target target address
 * @ param body request body
 * @ param proxy proxy address
 * @ param method { @ link com . rockagen . commons . http . RequestMethod }
 * @ return result String
 * @ throws IOException if an I / O error occurs */
public static String sendBody ( String target , byte [ ] body , String proxy , RequestMethod method ) throws IOException { } }

implementation: return sendBody ( target , body , proxy , ENCODING , method ) ;


signature:
public class HttpConn { /** * Send a http request with implicit params
 * @ param keystore keyStore InputStream
 * @ param password keyStore password
 * @ param target target address
 * @ param body request body
 * @ param proxy proxy address
 * @ param method { @ link com . rockagen . commons . http . RequestMethod }
 * @ return result String
 * @ throws IOException if an I / O error occurs */
public static String sendBody ( InputStream keystore , char [ ] password , String target , byte [ ] body , String proxy , RequestMethod method ) throws IOException { } }

implementation: return sendBody ( keystore , password , target , body , proxy , ENCODING , method ) ;


signature:
public class HttpConn { /** * Send a http request with implicit params
 * @ param upc basic auth { @ link UsernamePasswordCredentials }
 * @ param target target address
 * @ param body request body
 * @ param proxy proxy address
 * @ param encoding ( default UTF - 8)
 * @ param headers headers
 * @ param method { @ link com . rockagen . commons . http . RequestMethod }
 * @ return result String
 * @ throws IOException if an I / O error occurs */
public static String sendBody ( UsernamePasswordCredentials upc , String target , byte [ ] body , String proxy , String encoding , Map < String , String > headers , RequestMethod method ) throws IOException { } }

implementation: return sendBody ( upc , null , null , target , body , proxy , encoding , headers , method ) ;


signature:
public class HttpConn { /** * Send a http request with implicit params
 * @ param upc basic auth { @ link UsernamePasswordCredentials }
 * @ param keystore keyStore InputStream
 * @ param password keyStore password
 * @ param targetHost HttpHost
 * @ param uri URI
 * @ param body request body
 * @ param proxyHost HttpHost
 * @ param encoding ( default UTF - 8)
 * @ param method { @ link com . rockagen . commons . http . RequestMethod }
 * @ param headers headers
 * @ return result String
 * @ throws IOException if an I / O error occurs */
public static String sendBody ( UsernamePasswordCredentials upc , InputStream keystore , char [ ] password , HttpHost targetHost , String uri , byte [ ] body , HttpHost proxyHost , String encoding , RequestMethod method , Header ... headers ) throws IOException { } }

implementation: return sendBody ( upc , keystore , password , targetHost , uri , new ByteArrayEntity ( body ) , proxyHost , encoding , method , headers ) ;


signature:
public class HttpConn { /** * Send a http request with implicit params
 * @ param upc basic auth { @ link UsernamePasswordCredentials }
 * @ param keystore keyStore InputStream
 * @ param password keyStore password
 * @ param targetHost HttpHost
 * @ param uri URI
 * @ param params parameters ( ArrayList NameValuePair )
 * @ param proxyHost HttpHost
 * @ param encoding ( default UTF - 8)
 * @ param method { @ link com . rockagen . commons . http . RequestMethod }
 * @ param headers headers
 * @ return result String
 * @ throws IOException if an I / O error occurs */
public static String sendBody ( UsernamePasswordCredentials upc , InputStream keystore , char [ ] password , HttpHost targetHost , String uri , List < NameValuePair > params , HttpHost proxyHost , String encoding , RequestMethod method , Header ... headers ) throws IOException { } }

implementation: return sendBody ( upc , keystore , password , targetHost , uri , new UrlEncodedFormEntity ( params ) , proxyHost , encoding , method , headers ) ;


signature:
public class HttpConn { /** * Send a http request with implicit params
 * @ param upc basic auth { @ link UsernamePasswordCredentials }
 * @ param keystore keyStore InputStream
 * @ param password keyStore password
 * @ param targetHost HttpHost
 * @ param uri URI
 * @ param entity request { @ link HttpEntity }
 * @ param proxyHost HttpHost
 * @ param encoding ( default UTF - 8)
 * @ param method { @ link com . rockagen . commons . http . RequestMethod }
 * @ param headers headers
 * @ return result String
 * @ throws IOException if an I / O error occurs */
public static String sendBody ( UsernamePasswordCredentials upc , InputStream keystore , char [ ] password , HttpHost targetHost , String uri , HttpEntity entity , HttpHost proxyHost , String encoding , RequestMethod method , Header ... headers ) throws IOException { } }

implementation: if ( ! uri . startsWith ( "/" ) ) { uri = "/" + uri ; } HttpEntityEnclosingRequestBase hm = getHttpEntityMethod ( method , uri ) ; if ( headers != null && headers . length > 0 ) { hm . setHeaders ( headers ) ; } if ( entity != null ) { hm . setEntity ( entity ) ; } log . debug ( "url: {} method: {}" , getURL ( targetHost , uri ) , method ) ; return execute ( targetHost , proxyHost , hm , encoding , upc , keystore , password ) ;


signature:
public class HttpConn { /** * Get Http method instance by { @ link com . rockagen . commons . http . RequestMethod }
 * @ param method { @ link RequestMethod }
 * @ param uri the uri
 * @ return { @ link HttpRequestBase } */
private static HttpRequestBase getHttpMethod ( RequestMethod method , String uri ) { } }

implementation: HttpRequestBase hm ; if ( method != null ) { switch ( method ) { case POST : hm = new HttpPost ( uri ) ; break ; case GET : hm = new HttpGet ( uri ) ; break ; case PUT : hm = new HttpPut ( uri ) ; break ; case DELETE : hm = new HttpDelete ( uri ) ; break ; case HEAD : hm = new HttpHead ( uri ) ; break ; case OPTIONS : hm = new HttpOptions ( uri ) ; break ; case TRACE : hm = new HttpTrace ( uri ) ; break ; case PATCH : hm = new HttpPatch ( uri ) ; break ; default : hm = new HttpGet ( uri ) ; break ; } } else hm = new HttpGet ( uri ) ; return hm ;


signature:
public class HttpConn { /** * Get Http method instance by { @ link com . rockagen . commons . http . RequestMethod }
 * @ param method { @ link RequestMethod }
 * @ param uri the uri
 * @ return { @ link HttpEntityEnclosingRequestBase } */
private static HttpEntityEnclosingRequestBase getHttpEntityMethod ( RequestMethod method , String uri ) { } }

implementation: HttpEntityEnclosingRequestBase hm ; if ( method != null ) { switch ( method ) { case POST : hm = new HttpPost ( uri ) ; break ; case PUT : hm = new HttpPut ( uri ) ; break ; case PATCH : hm = new HttpPatch ( uri ) ; break ; default : hm = new HttpPost ( uri ) ; break ; } } else hm = new HttpPost ( uri ) ; return hm ;


signature:
public class HttpConn { /** * Handler main
 * @ param targetHost target { @ link HttpHost }
 * @ param proxyHost proxy { @ link HttpHost }
 * @ param httpRequestMethod HttpGet or HttpPost . . .
 * @ param encoding encoding
 * @ param upc { @ link UsernamePasswordCredentials }
 * @ param keystore keystore stream
 * @ param password keystore password
 * @ return result String
 * @ throws IOException if an I / O error occurs */
protected static String execute ( HttpHost targetHost , HttpHost proxyHost , HttpRequest httpRequestMethod , String encoding , UsernamePasswordCredentials upc , InputStream keystore , char [ ] password ) throws IOException { } }

implementation: HttpClientBuilder hcb = HttpClients . custom ( ) ; hcb . setDefaultRequestConfig ( getRequestConfig ( ) ) ; if ( proxyHost != null ) { hcb . setProxy ( proxyHost ) ; } if ( keystore != null ) { try { KeyStore trustStore = KeyStore . getInstance ( KeyStore . getDefaultType ( ) ) ; trustStore . load ( keystore , password ) ; SSLContext sslcontext = SSLContexts . custom ( ) . loadTrustMaterial ( trustStore , new TrustSelfSignedStrategy ( ) ) . build ( ) ; SSLConnectionSocketFactory ssf = new SSLConnectionSocketFactory ( sslcontext ) ; hcb . setSSLSocketFactory ( ssf ) ; } catch ( KeyStoreException e ) { log . error ( "{}" , e . getMessage ( ) , e ) ; } catch ( CertificateException e ) { log . error ( "{}" , e . getMessage ( ) , e ) ; } catch ( NoSuchAlgorithmException e ) { log . error ( "{}" , e . getMessage ( ) , e ) ; } catch ( KeyManagementException e ) { log . error ( "{}" , e . getMessage ( ) , e ) ; } finally { keystore . close ( ) ; } } if ( upc != null ) { CredentialsProvider cp = new BasicCredentialsProvider ( ) ; AuthScope as = new AuthScope ( targetHost ) ; cp . setCredentials ( as , upc ) ; hcb . setDefaultCredentialsProvider ( cp ) ; } CloseableHttpClient chc = hcb . build ( ) ; try { CloseableHttpResponse response = chc . execute ( targetHost , httpRequestMethod ) ; return getResponse ( response , encoding ) ; } finally { chc . close ( ) ; }


signature:
public class HttpConn { /** * Handle response ( resolve response to String , httpClient close , etc . )
 * @ param response { @ link HttpResponse }
 * @ param encoding the encoding , default is { @ link # ENCODING }
 * @ return result String
 * @ throws IOException if an I / O error occurs */
public static String getResponse ( HttpResponse response , String encoding ) throws IOException { } }

implementation: log . debug ( "status: {}" , response . getStatusLine ( ) . getStatusCode ( ) ) ; HttpEntity entity = response . getEntity ( ) ; String retval = "" ; if ( entity != null ) { try { if ( CommUtil . isBlank ( encoding ) ) { encoding = ENCODING ; } retval = IOUtil . toString ( entity . getContent ( ) , encoding ) ; } finally { EntityUtils . consume ( entity ) ; } } return retval ;


signature:
public class HttpConn { /** * Get UsernamePasswordCredentials
 * @ param usernameSamePassword the same string of username and password
 * @ return UsernamePasswordCredentials */
public static UsernamePasswordCredentials getUPC ( String usernameSamePassword ) { } }

implementation: if ( CommUtil . isBlank ( usernameSamePassword ) ) { return null ; } return new UsernamePasswordCredentials ( usernameSamePassword ) ;


signature:
public class HttpConn { /** * Get UsernamePasswordCredentials
 * @ param username username
 * @ param password password
 * @ return UsernamePasswordCredentials */
public static UsernamePasswordCredentials getUPC ( String username , String password ) { } }

implementation: if ( CommUtil . isBlank ( username ) && CommUtil . isBlank ( password ) ) { return null ; } return new UsernamePasswordCredentials ( username , password ) ;


signature:
public class HttpConn { /** * Get url
 * @ param targetHost target { @ link org . apache . http . HttpHost }
 * @ param uri the uri
 * @ return new url string */
public static String getURL ( HttpHost targetHost , String uri ) { } }

implementation: if ( targetHost != null && ! CommUtil . isBlank ( targetHost . getSchemeName ( ) ) && ! CommUtil . isBlank ( targetHost . getHostName ( ) ) && targetHost . getPort ( ) > 0 ) { return targetHost + uri ; } return "null" + uri ;


signature:
public class HttpConn { /** * Resolve String to Object Array
 * Array length is 2 , by default return http : / / localhost : 80/
 * < li > [ 0 ] - - > HttpHost < / li > < li > [ 1 ] - - > URI < / li >
 * @ param str the http url
 * @ return object array [ 0 ] = HttpHost [ 1 ] = String ( uri ) */
private static Object [ ] resolveUrl ( String str ) { } }

implementation: String scheme = "http" , host = "localhost" , uri = "/" ; int port = 80 ; Object [ ] obj = new Object [ 2 ] ; try { if ( str . length ( ) >= 10 ) { String temp = str . substring ( 0 , str . indexOf ( ":" ) ) ; if ( ! CommUtil . isBlank ( temp ) ) { if ( temp . equalsIgnoreCase ( "HTTP" ) || temp . equalsIgnoreCase ( "HTTPS" ) ) { scheme = temp ; String temp1 = str . substring ( temp . length ( ) + 3 ) ; if ( temp1 . indexOf ( "/" ) > 0 ) { String temp2 = temp1 . substring ( 0 , temp1 . indexOf ( "/" ) ) ; if ( temp2 . indexOf ( ":" ) > 0 ) { String [ ] temp3 = temp2 . split ( ":" ) ; if ( temp3 . length > 1 && temp3 [ 1 ] . matches ( "[0-9]*" ) ) { port = Integer . parseInt ( temp3 [ 1 ] ) ; host = temp3 [ 0 ] ; } } else { host = temp2 ; if ( temp . equalsIgnoreCase ( "HTTP" ) ) { port = 80 ; } else if ( temp . equalsIgnoreCase ( "HTTPS" ) ) { port = 443 ; } } uri = temp1 . substring ( temp2 . length ( ) ) ; } else { if ( temp1 . indexOf ( ":" ) > 0 ) { String [ ] temp3 = temp1 . split ( ":" ) ; if ( temp3 [ 1 ] . matches ( "[0-9]*" ) ) { port = Integer . parseInt ( temp3 [ 1 ] ) ; host = temp3 [ 0 ] ; } } else { host = temp1 ; if ( temp . equalsIgnoreCase ( "HTTP" ) ) { port = 80 ; } else if ( temp . equalsIgnoreCase ( "HTTPS" ) ) { port = 443 ; } } uri = "/" ; } } } } } catch ( Exception e ) { log . error ( "{}" , e . getMessage ( ) , e ) ; } HttpHost targetHost = new HttpHost ( host , port , scheme ) ; obj [ 0 ] = targetHost ; obj [ 1 ] = uri ; log . debug ( "The parsed Object Array {}" , Arrays . toString ( obj ) ) ; return obj ;


signature:
public class ElementFilter { /** * Assumes targetKinds and E are sensible . */
private static < E extends Element , F extends E , C extends Collection < F > > C collectionFilter ( C collection , Iterable < ? extends E > elements , Class < F > clazz , ElementKind ... kinds ) { } }

implementation: for ( E e : elements ) { ElementKind findKind = e . getKind ( ) ; for ( ElementKind kind : kinds ) if ( kind == findKind ) { collection . add ( clazz . cast ( e ) ) ; break ; } } return collection ;


signature:
public class ElementFilter { /** * Assumes targetKinds and E are sensible . */
public static < E extends Element , F extends E > List < F > listFilter ( Iterable < ? extends E > elements , Class < F > clazz , ElementKind ... kinds ) { } }

implementation: return collectionFilter ( new ArrayList < F > ( ) , elements , clazz , kinds ) ;


signature:
public class ElementFilter { /** * Assumes targetKinds and E are sensible . */
public static < E extends Element , F extends E > Set < F > setFilter ( Iterable < ? extends E > elements , Class < F > clazz , ElementKind ... kinds ) { } }

implementation:
// Return set preserving iteration order of input set .
return collectionFilter ( new LinkedHashSet < F > ( ) , elements , clazz ) ;


signature:
public class JdbcPasswordAuthenticator { /** * { @ inheritDoc }
 * See module documentation for a list of available options .
 * @ throws NullPointerException When { @ code properties } is { @ code null } */
@ Override public final void init ( final CommonProperties properties ) { } }

implementation:
Validate . notNull ( properties , "The validated object 'properties' is null" ) ; // no need for defensive copies here , as all internal config values are calculated
// some caching would be nice , but then we would have to allow resets in case the application wants to reload
// its configuration at some point - seems not worth the hassle at this point .
LOG . info ( "Parsing connection properties configuration" ) ; connProps . set ( JaasBasedConnPropsBuilder . build ( properties . getAdditionalProperties ( ) ) ) ; // same statement about caching : )
LOG . info ( "Parsing database properties configuration" ) ; dbProps . set ( JaasBasedDbPropsBuilder . build ( properties . getAdditionalProperties ( ) ) ) ;


signature:
public class JdbcPasswordAuthenticator { /** * CHECKSTYLE : OFF */
@ SuppressWarnings ( { } }

implementation:
"PMD.CyclomaticComplexity" , "PMD.NPathComplexity" } ) // CHECKSTYLE : ON
public final Subject authenticate ( final String domain , final String userName , final char [ ] password , final PasswordValidator passwordValidator ) throws LoginException { // make sure the credentials are not null
if ( domain == null || userName == null || password == null ) { throw new LoginException ( "The credentials cannot be null" ) ; } // SQL query is required
if ( StringUtils . isBlank ( dbProps . get ( ) . getSqlUserQuery ( ) ) ) { final String error = "Invalid SQL user authentication query (query is null or empty)" ; LOG . warn ( error ) ; throw new LoginException ( error ) ; } final UserRecord userRecord = getUserRecord ( domain , userName ) ; if ( userRecord . getUserId ( ) == null || userRecord . getUserId ( ) . length ( ) == 0 ) { final String error = "User ID for username '" + userName + "' is null or empty in the database" ; LOG . warn ( error ) ; throw new LoginException ( error ) ; } if ( userRecord . getCredential ( ) == null || userRecord . getCredential ( ) . length ( ) == 0 ) { final String error = "Credential for username '" + userName + "' / user ID '" + userRecord . getUserId ( ) + "' is null or empty in the database" ; LOG . warn ( error ) ; throw new LoginException ( error ) ; } // no need for defensive copies of Strings , but create a defensive copy of the password
final char [ ] myPassword = password . clone ( ) ; // convert the credential string to a char array
final char [ ] myCredential = userRecord . getCredential ( ) . toCharArray ( ) ; 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 ( userRecord . getUserId ( ) , domain , userName ) ; // wrap the principal in a Subject
final Subject subject = new Subject ( ) ; subject . getPrincipals ( ) . add ( userPrincipal ) ; return subject ;


signature:
public class JdbcPasswordAuthenticator { /** * The SQL statement is retrieved from the configuration , and the admin is trusted */
@ edu . umd . cs . findbugs . annotations . SuppressWarnings ( "SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING" ) private UserRecord getUserRecord ( final String domain , final String userName ) throws LoginException { } }

implementation: String userId ; String credential ; Connection connection = null ; PreparedStatement statement = null ; ResultSet resultSet = null ; try { connection = getDatabaseConnection ( ) ; statement = connection . prepareStatement ( dbProps . get ( ) . getSqlUserQuery ( ) ) ; statement . setString ( 1 , domain ) ; statement . setString ( 2 , userName ) ; resultSet = statement . executeQuery ( ) ; if ( resultSet . next ( ) ) { userId = resultSet . getString ( 1 ) ; credential = resultSet . getString ( 2 ) ; } else { final String error = "Username '" + userName + "' does not exist (query returned zero results)" ; LOG . warn ( error ) ; throw new LoginException ( error ) ; } resultSet . close ( ) ; statement . close ( ) ; } catch ( SQLException e ) { final String error = "Error executing SQL query" ; LOG . warn ( error , e ) ; throw Util . newLoginException ( error , e ) ; } finally { DbUtil . close ( resultSet ) ; DbUtil . close ( statement ) ; DbUtil . close ( connection ) ; } return new UserRecord ( domain , userName , userId , credential ) ;


signature:
public class JdbcPasswordAuthenticator { /** * Obtain a database connection - either a JNDI connection ( directly from the factory ) , or a pooled JDBC connection
 * @ return a pooled database connection
 * @ throws LoginException when the connection cannot be retrieved from JNDI or the connection pool , or the pool
 * cannot be created */
private Connection getDatabaseConnection ( ) throws LoginException { } }

implementation:
Connection connection ; if ( StringUtils . isNotEmpty ( dbProps . get ( ) . getJndiConnectionName ( ) ) ) { try { connection = ConnectionFactory . getConnection ( dbProps . get ( ) . getJndiConnectionName ( ) ) ; } catch ( FactoryException e ) { final String error = "Could not retrieve JNDI database connection" ; LOG . warn ( error , e ) ; throw Util . newLoginException ( error , e ) ; } } else { try { // connection spec is required
if ( connProps . get ( ) == null ) { final String error = "Database connection pool configuration has not been provided or initialized" ; LOG . warn ( error ) ; throw new FactoryException ( error ) ; } // driver is required
if ( StringUtils . isBlank ( connProps . get ( ) . getDriver ( ) ) ) { final String error = "Invalid database driver (driver name is null or empty)" ; LOG . warn ( error ) ; throw new FactoryException ( error ) ; } // url is required
if ( StringUtils . isBlank ( connProps . get ( ) . getUrl ( ) ) ) { final String error = "Invalid database URL (URL is null or empty)" ; LOG . warn ( error ) ; throw new FactoryException ( error ) ; } connection = ConnectionFactory . getConnection ( connProps . get ( ) ) ; } catch ( FactoryException e ) { final String error = "Could not create pooled database connection" ; LOG . warn ( error , e ) ; throw Util . newLoginException ( error , e ) ; } } return connection ;


signature:
public class Arith { /** * add
 * @ param v1 left value
 * @ param v2 right value
 * @ return v1 + v2 */
public static float addF ( final float v1 , final float v2 ) { } }

implementation: BigDecimal b1 = new BigDecimal ( Float . toString ( v1 ) ) ; BigDecimal b2 = new BigDecimal ( Float . toString ( v2 ) ) ; return b1 . add ( b2 ) . floatValue ( ) ;


signature:
public class Arith { /** * sub
 * @ param v1 left value
 * @ param v2 right value
 * @ return v1 - v2 */
public static double sub ( final double v1 , final double v2 ) { } }

implementation: BigDecimal b1 = new BigDecimal ( Double . toString ( v1 ) ) ; BigDecimal b2 = new BigDecimal ( Double . toString ( v2 ) ) ; return b1 . subtract ( b2 ) . doubleValue ( ) ;


signature:
public class Arith { /** * sub
 * @ param v1 left value
 * @ param v2 right value
 * @ return v1 - v2 */
public static float subF ( final float v1 , final float v2 ) { } }

implementation: BigDecimal b1 = new BigDecimal ( Float . toString ( v1 ) ) ; BigDecimal b2 = new BigDecimal ( Float . toString ( v2 ) ) ; return b1 . subtract ( b2 ) . floatValue ( ) ;


signature:
public class Arith { /** * mul
 * @ param v1 left value
 * @ param v2 right value
 * @ return v1 * v2 */
public static double mul ( final double v1 , final double v2 ) { } }

implementation: BigDecimal b1 = new BigDecimal ( Double . toString ( v1 ) ) ; BigDecimal b2 = new BigDecimal ( Double . toString ( v2 ) ) ; return b1 . multiply ( b2 ) . doubleValue ( ) ;


signature:
public class Arith { /** * mul
 * @ param v1 left value
 * @ param v2 right value
 * @ return v1 * v2 */
public static float mul ( final float v1 , final float v2 ) { } }

implementation: BigDecimal b1 = new BigDecimal ( Float . toString ( v1 ) ) ; BigDecimal b2 = new BigDecimal ( Float . toString ( v2 ) ) ; return b1 . multiply ( b2 ) . floatValue ( ) ;


signature:
public class Arith { /** * div
 * @ param v1 left value
 * @ param v2 right value
 * @ param scale precision default { @ link # DIV _ SCALE }
 * @ param roundingMode default { @ link # ROUNDING _ MODE }
 * @ return v1 / v2 */
public static double div ( final double v1 , final double v2 , int scale , int roundingMode ) { } }

implementation: if ( scale < 0 ) { scale = DIV_SCALE ; } if ( roundingMode < 0 ) { roundingMode = ROUNDING_MODE ; } BigDecimal b1 = new BigDecimal ( Double . toString ( v1 ) ) ; BigDecimal b2 = new BigDecimal ( Double . toString ( v2 ) ) ; return b1 . divide ( b2 , scale , roundingMode ) . doubleValue ( ) ;


signature:
public class Arith { /** * div
 * @ param v1 left value
 * @ param v2 right value
 * @ param scale precision default { @ link # DIV _ SCALE }
 * @ param roundingMode default { @ link # ROUNDING _ MODE }
 * @ return v1 / v2 */
public static float div ( final float v1 , final float v2 , int scale , int roundingMode ) { } }

implementation: if ( scale < 0 ) { scale = DIV_SCALE ; } if ( roundingMode < 0 ) { roundingMode = ROUNDING_MODE ; } BigDecimal b1 = new BigDecimal ( Float . toString ( v1 ) ) ; BigDecimal b2 = new BigDecimal ( Float . toString ( v2 ) ) ; return b1 . divide ( b2 , scale , roundingMode ) . floatValue ( ) ;


signature:
public class Arith { /** * random
 * @ param v value
 * @ param scale scale , default is { @ link # DIV _ SCALE }
 * @ param roundingMode default is { @ link # ROUNDING _ MODE }
 * @ return double */
public static double round ( final double v , int scale , int roundingMode ) { } }

implementation: if ( scale < 0 ) { scale = DIV_SCALE ; } if ( roundingMode < 0 ) { roundingMode = ROUNDING_MODE ; } BigDecimal b = new BigDecimal ( Double . toString ( v ) ) ; BigDecimal one = new BigDecimal ( "1" ) ; return b . divide ( one , scale , roundingMode ) . doubleValue ( ) ;


signature:
public class Arith { /** * random
 * @ param v value
 * @ param scale scale , default is { @ link # DIV _ SCALE }
 * @ param roundingMode default is { @ link # ROUNDING _ MODE }
 * @ return round float */
public static float round ( final float v , int scale , int roundingMode ) { } }

implementation: if ( scale < 0 ) { scale = DIV_SCALE ; } if ( roundingMode < 0 ) { roundingMode = ROUNDING_MODE ; } BigDecimal b = new BigDecimal ( Float . toString ( v ) ) ; BigDecimal one = new BigDecimal ( "1" ) ; return b . divide ( one , scale , roundingMode ) . floatValue ( ) ;


signature:
public class Arith { /** * to double
 * @ param d double value
 * @ return double */
public static float toFloat ( final double d ) { } }

implementation: BigDecimal b = new BigDecimal ( Double . toString ( d ) ) ; return b . floatValue ( ) ;


signature:
public class Arith { /** * to float
 * @ param f float value
 * @ return double */
public static double toDouble ( final float f ) { } }

implementation: BigDecimal b = new BigDecimal ( Float . toString ( f ) ) ; return b . doubleValue ( ) ;


signature:
public class RestfulRouter { /** * 根据 annotation , 获取所有的 Action */
@ Override public void registerController ( Class < ? > clazz ) { } }

implementation:
Controller controller = clazz . getAnnotation ( Controller . class ) ; Validate . notNull ( controller ) ; String ctrlPath = ValueConstants . trimToEmpty ( controller . value ( ) ) ; ControllerInfo ctrlInfo = new ControllerInfo ( clazz , controller ) ; ResultHandlerResolver resultHandlerResolver = WebConfig . getInstance ( ) . getResultHandlerResolver ( ) ; KlassInfo klass = KlassInfo . create ( clazz ) ; for ( MethodInfo actionMethod : klass . getMethods ( ) ) { if ( ! klass . isPublic ( ) || actionMethod . isStatic ( ) ) { continue ; } Action action = actionMethod . getAnnotation ( Action . class ) ; if ( action == null ) { continue ; } String actionPath = ValueConstants . defaultValue ( action . value ( ) , actionMethod . getName ( ) ) ; String url = StringUtils . removeEnd ( ctrlPath , "/" ) + StringUtils . prefix ( actionPath , "/" ) ; // validate the action result type
Class < ? > returnClass = actionMethod . getRawReturnType ( clazz ) ; if ( ! resultHandlerResolver . validate ( returnClass ) ) { throw new IllegalStateException ( "Unsupported result class: " + returnClass . getName ( ) + " of " + actionMethod ) ; } HttpMethod [ ] httpMethods = action . method ( ) ; Validate . isTrue ( httpMethods . length > 0 ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( "found action: {} {}" , ArrayUtils . toString ( httpMethods ) , url ) ; } ActionInfo actionInfo = new ActionInfo ( ctrlInfo , actionMethod , url ) ; for ( HttpMethod method : httpMethods ) { RestfulMatcher matcher = matchers [ method . getIndex ( ) ] ; if ( matcher == null ) { matcher = new RestfulMatcher ( ) ; matchers [ method . getIndex ( ) ] = matcher ; } matcher . register ( actionInfo , url ) ; } }


signature:
public class DateUtils { /** * 用尝试多种格式解析日期时间 .
 * @ param date 时间字符串
 * @ return 如果无法解析 , 那么返回 { @ code null } */
public static Date parse ( String date ) { } }

implementation: Date d = parseUsingPatterns ( date , STD_PATTERNS ) ; if ( d == null ) { d = parseRFC822Date ( date ) ; } if ( d == null ) { d = parseW3CDateTime ( date ) ; } if ( d == null ) { try { d = DateFormat . getInstance ( ) . parse ( date ) ; } catch ( ParseException e ) { d = null ; } } return d ;


signature:
public class DateUtils { /** * 用指定的格式解析日期时间 .
 * @ param date 时间字符串
 * @ param pattern see { @ link java . text . SimpleDateFormat }
 * @ return 如果无法解析 , 那么返回 { @ code null } */
public static Date parseUsingPattern ( String date , String pattern ) { } }

implementation: SimpleDateFormat df = new SimpleDateFormat ( pattern ) ; df . setLenient ( false ) ; try { ParsePosition pp = new ParsePosition ( 0 ) ; Date d = df . parse ( date , pp ) ; if ( d != null && pp . getIndex ( ) != date . length ( ) ) { return d ; } } catch ( Exception e ) { } return null ;


signature:
public class AttributeInjector { /** * For a JMX MBean idenfitied by an ObjectName , copy the values of the given attributes into the target object
 * using the specified setter methods mapped by attribute name .
 * @ param target object into which values are injected .
 * @ param jmxAttributeValues values of the attributes to inject .
 * @ param attributeSetters map of attribute name to setter used to determine how to inject each attribute ' s value .
 * @ param objectName name of the MBean involved - used only for logging . */
public void copyOutAttributes ( Object target , List < Attribute > jmxAttributeValues , Map < String , Method > attributeSetters , ObjectName objectName ) { } }

implementation: this . copyOutAttributes ( target , jmxAttributeValues , attributeSetters , "oname" , objectName ) ;


signature:
public class AttributeInjector { /** * Copy the values of the given attributes into the target object using the specified setter methods mapped by
 * attribute name .
 * @ param target object into which values are injected .
 * @ param jmxAttributeValues values of the attributes to inject .
 * @ param attributeSetters map of attribute name to setter used to determine how to inject each attribute ' s value .
 * @ param identifierKey key , or name , of the identifier - used only for logging purposes .
 * @ param identifier identifier to include in the output - used only for logging purposes . */
protected void copyOutAttributes ( Object target , List < Attribute > jmxAttributeValues , Map < String , Method > attributeSetters , String identifierKey , Object identifier ) { } }

implementation:
for ( Attribute oneAttribute : jmxAttributeValues ) { String attributeName = oneAttribute . getName ( ) ; Method setter = attributeSetters . get ( attributeName ) ; Object value = oneAttribute . getValue ( ) ; try { // Automatically down - convert longs to integers as - needed .
if ( ( setter . getParameterTypes ( ) [ 0 ] . isAssignableFrom ( Integer . class ) ) || ( setter . getParameterTypes ( ) [ 0 ] . isAssignableFrom ( int . class ) ) ) { if ( value instanceof Long ) { value = ( ( Long ) value ) . intValue ( ) ; } } setter . invoke ( target , value ) ; } catch ( InvocationTargetException invocationExc ) { this . log . info ( "invocation exception storing mbean results: {}={}; attributeName={}" , identifierKey , identifier , attributeName , invocationExc ) ; } catch ( IllegalAccessException illegalAccessExc ) { this . log . info ( "illegal access exception storing mbean results: {}={}; attributeName={}" , identifierKey , identifier , attributeName , illegalAccessExc ) ; } catch ( IllegalArgumentException illegalArgumentExc ) { this . log . info ( "illegal argument exception storing mbean results: {}={}; attributeName={}" , identifierKey , identifier , attributeName , illegalArgumentExc ) ; } }


signature:
public class SysUtil { /** * @ param url url
 * @ throws Exception exception if occur */
public static void browse ( String url ) throws Exception { } }

implementation:
if ( OS_NAME . startsWith ( "Mac OS" ) ) { Method openURL = ClassUtil . getDeclaredMethod ( Class . forName ( "com.apple.eio.FileManager" ) , true , "openURL" , String . class ) ; openURL . invoke ( null , url ) ; } else if ( OS_NAME . startsWith ( "Windows" ) ) { Runtime . getRuntime ( ) . exec ( "rundll32 url.dll,FileProtocolHandler " + url ) ; } else { // assume Unix or Linux
String [ ] browsers = { "firefox" , "opera" , "konqueror" , "epiphany" , "mozilla" , "netscape" } ; String browser = null ; for ( int count = 0 ; count < browsers . length && browser == null ; count ++ ) if ( Runtime . getRuntime ( ) . exec ( new String [ ] { "which" , browsers [ count ] } ) . waitFor ( ) == 0 ) browser = browsers [ count ] ; if ( browser == null ) throw new NoSuchMethodException ( "Could not find web browser" ) ; else Runtime . getRuntime ( ) . exec ( new String [ ] { browser , url } ) ; }


signature:
public class SourceOrderDeclScanner { /** * Visits a type declaration .
 * @ param d the declaration to visit */
public void visitTypeDeclaration ( TypeDeclaration d ) { } }

implementation: d . accept ( pre ) ; SortedSet < Declaration > decls = new TreeSet < Declaration > ( SourceOrderDeclScanner . comparator ) ; for ( TypeParameterDeclaration tpDecl : d . getFormalTypeParameters ( ) ) { decls . add ( tpDecl ) ; } for ( FieldDeclaration fieldDecl : d . getFields ( ) ) { decls . add ( fieldDecl ) ; } for ( MethodDeclaration methodDecl : d . getMethods ( ) ) { decls . add ( methodDecl ) ; } for ( TypeDeclaration typeDecl : d . getNestedTypes ( ) ) { decls . add ( typeDecl ) ; } for ( Declaration decl : decls ) decl . accept ( this ) ; d . accept ( post ) ;


signature:
public class SrvEntityFieldUserTomcatRepl { /** * 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: if ( ! UserRoleTomcat . class . isAssignableFrom ( pEntity . getClass ( ) ) ) { throw new ExceptionWithCode ( ExceptionWithCode . CONFIGURATION_MISTAKE , "It's wrong service to fill that field: " + pEntity + "/" + pFieldName + "/" + pFieldStrValue ) ; } UserRoleTomcat userRoleTomcat = ( UserRoleTomcat ) pEntity ; if ( "NULL" . equals ( pFieldStrValue ) ) { userRoleTomcat . setItsUser ( null ) ; return ; } try { UserTomcat ownedEntity = new UserTomcat ( ) ; ownedEntity . setItsUser ( pFieldStrValue ) ; userRoleTomcat . setItsUser ( ownedEntity ) ; } catch ( Exception ex ) { throw new ExceptionWithCode ( ExceptionWithCode . WRONG_PARAMETER , "Can not fill field: " + pEntity + "/" + pFieldName + "/" + pFieldStrValue + ", " + ex . getMessage ( ) , ex ) ; }


signature:
public class PathFilter { /** * Accept this file ?
 * @ param dir The directory this file is in .
 * @ param filename The filename . */
public boolean accept ( File dir , String filename ) { } }

implementation: String strPath = dir . getPath ( ) . toLowerCase ( ) ; if ( strPath . indexOf ( m_strOkayPath ) != - 1 ) return true ; return false ;


signature:
public class SampleAuditLogger { /** * { @ inheritDoc }
 * @ throws NullPointerException When the { @ code event } , { @ code domain } or { @ code username } are { @ code null }
 * @ throws IllegalArgumentException When { @ code domain } , { @ code username } is empty */
@ Override // Check is broken [ LOG . info ( ) ] : PMD reports issues although log stmt is guarded . @ todo revisit when upgrading PMD .
@ SuppressWarnings ( "PMD.GuardLogStatementJavaUtil" ) public final void audit ( final Events event , final String domain , final String username ) { } }

implementation:
Validate . notNull ( event , "The validated object 'event' is null" ) ; Validate . notBlank ( domain , "The validated character sequence 'domain' is null or empty" ) ; Validate . notBlank ( username , "The validated character sequence 'username' is null or empty" ) ; // PMD does not recognize the guarded log statement
if ( LOG . isInfoEnabled ( ) ) { LOG . info ( "[AUDIT] " + event . getValue ( ) + ". User name '" + username + "', domain '" + domain + "'" ) ; }


signature: public class ListUtils { public static < T > T [ ] asArray ( Collection < T > items , Class < T > elementType ) { } }

implementation: if ( items == null ) { return null ; } @ SuppressWarnings ( "unchecked" ) T [ ] results = ( T [ ] ) Array . newInstance ( elementType , items . size ( ) ) ; int i = 0 ; for ( T item : items ) { results [ i ++ ] = item ; } return results ;


signature:
public class InstanceFilter { /** * Assumes targetKinds and E are sensible . */
private static < E , F extends E , C extends Collection < F > > C collectionFilter ( C collection , Iterable < ? extends E > elements , Class < F > clazz ) { } }

implementation:
for ( E e : elements ) { // if ( clazz . isAssignableFrom ( e . getClass ( ) ) )
if ( clazz . isInstance ( e ) ) collection . add ( clazz . cast ( e ) ) ; } return collection ;


signature:
public class InstanceFilter { /** * Assumes targetKinds and E are sensible . */
public static < E , F extends E > List < F > listFilter ( Iterable < ? extends E > elements , Class < F > clazz ) { } }

implementation: return collectionFilter ( new ArrayList < F > ( ) , elements , clazz ) ;


signature:
public class InstanceFilter { /** * Assumes targetKinds and E are sensible . */
public static < E , F extends E > Set < F > setFilter ( Iterable < ? extends E > elements , Class < F > clazz ) { } }

implementation:
// Return set preserving iteration order of input set .
return collectionFilter ( new LinkedHashSet < F > ( ) , elements , clazz ) ;


signature:
public class Util { /** * Copy the input stream to the output stream .
 * @ param inStream Input stream .
 * @ param outStream Output stream .
 * @ return Error code , or 0 if no errors . */
public static int copyStream ( InputStream inStream , OutputStream outStream ) throws IOException { } }

implementation: return Util . copyStream ( inStream , outStream , false , false ) ;


signature:
public class Util { /** * Copy the input stream to the output stream .
 * @ param inStream Input stream .
 * @ param outStream Output stream .
 * @ return Error code , or 0 if no errors . */
public static int copyStream ( InputStream inStream , OutputStream outStream , boolean bCountInBytes , boolean bCountOutBytes ) throws IOException { } }

implementation: byte rgBytes [ ] = new byte [ 8192 ] ; int iTotalLength = 0 ; int iStartInByte = 0 ; int iStartOutByte = 0 ; while ( true ) { int iLength = rgBytes . length ; if ( bCountInBytes ) iStartInByte = iTotalLength ; iLength = inStream . read ( rgBytes , iStartInByte , iLength ) ; if ( DEBUG ) System . out . println ( "inLen = " + iLength ) ; if ( iLength <= 0 ) break ; if ( bCountOutBytes ) iStartOutByte = iTotalLength ; outStream . write ( rgBytes , iStartOutByte , iLength ) ; iTotalLength += iLength ; } return iTotalLength ;


signature:
public class Util { /** * Create a new object using this class name .
 * Conform to the standardized classname format : com . tourgeek . terminal . src / dest . name . namesrc / dest */
public static Object makeObjectFromClassName ( String interfaceName , String strPackage , String strClassName ) { } }

implementation:
if ( strClassName == null ) return null ; if ( strClassName . indexOf ( '.' ) == - 1 ) if ( strPackage != null ) { // Use default structure
strClassName = org . jbundle . jbackup . JBackupConstants . ROOT_PACKAGE + "jbackup." + strPackage . toLowerCase ( ) + '.' + strClassName + strPackage . substring ( 0 , 1 ) . toUpperCase ( ) + strPackage . substring ( 1 ) ; } Object objClass = null ; try { if ( strClassName . indexOf ( '.' ) == 0 ) strClassName = org . jbundle . jbackup . JBackupConstants . ROOT_PACKAGE + strClassName . substring ( 1 ) ; Class < ? > c = Class . forName ( strClassName ) ; if ( c != null ) { objClass = c . newInstance ( ) ; } } catch ( Exception ex ) { System . out . println ( "Error on attempt to make class: " + strClassName ) ; ex . printStackTrace ( ) ; System . exit ( 0 ) ; } return objClass ;


signature:
public class Util { /** * Convert this date string to a date object .
 * @ param strDate the date to parse .
 * @ return The date or null if unparseable . */
public static Date stringToDate ( String strDate ) { } }

implementation: Date dateLastBackup = null ; if ( ( strDate != null ) && ( strDate . length ( ) > 0 ) ) { try { dateLastBackup = DateFormat . getInstance ( ) . parse ( strDate ) ; } catch ( ParseException ex ) { dateLastBackup = null ; } } return dateLastBackup ;


signature:
public class Util { /** * Convert this date object to a string .
 * @ param The date or null if unparseable .
 * @ return strDate the date to parse . */
public static String dateToString ( Date date ) { } }

implementation: if ( date == null ) return "" ; try { return DateFormat . getInstance ( ) . format ( date ) ; } catch ( Exception ex ) { } return "" ;


signature:
public class Util { /** * Create a filter from these properties .
 * @ param The properties .
 * @ return The filter . */
public static FilenameFilter makeFilter ( Properties properties ) { } }

implementation: String strFilter = properties . getProperty ( JBackupConstants . FILTER_PARAM ) ; if ( strFilter != null ) if ( strFilter . indexOf ( '.' ) != - 1 ) return ( FilenameFilter ) Util . makeObjectFromClassName ( Object . class . getName ( ) , null , strFilter ) ; else return new PathFilter ( strFilter ) ; return null ; // Add + + + Make the filename filter !


signature:
public class AppRunner { /** * Get property .
 * @ param key
 * @ return */
public String getProperty ( String key ) { } }

implementation: if ( m_properties == null ) return null ; return m_properties . getProperty ( key ) ;


signature:
public class AppRunner { /** * Set property .
 * @ param key
 * @ return */
public void setProperty ( String key , String value ) { } }

implementation: if ( m_properties == null ) m_properties = new Properties ( ) ; m_properties . setProperty ( key , value ) ;


signature:
public class AppRunner { /** * Add this applet to a frame and initialize .
 * @ return */
public JFrame addAppToFrame ( ) { } }

implementation: JFrame frame = new JFrame ( ) ; frame . setTitle ( this . getTitle ( ) ) ; frame . setBackground ( Color . lightGray ) ; frame . getContentPane ( ) . setLayout ( new BorderLayout ( ) ) ; frame . getContentPane ( ) . add ( this , BorderLayout . CENTER ) ; frame . addWindowListener ( new WindowAdapter ( ) { public void windowClosing ( WindowEvent e ) { System . exit ( 0 ) ; } } ) ; frame . pack ( ) ; frame . setSize ( frame . getPreferredSize ( ) . width , frame . getPreferredSize ( ) . height ) ; return frame ;


signature:
public class SoftHashMap { /** * Returns a copy of the key / values in the map at the point of
 * calling . However , setValue still sets the value in the
 * actual SoftHashMap . */
@ Override public Set < Entry < K , V > > entrySet ( ) { } }

implementation: processQueue ( ) ; Set < Entry < K , V > > result = new LinkedHashSet < Entry < K , V > > ( ) ; for ( final Entry < K , SoftValue < V > > entry : map . entrySet ( ) ) { final V value = entry . getValue ( ) . get ( ) ; if ( value != null ) { result . add ( new Entry < K , V > ( ) { @ Override public K getKey ( ) { return entry . getKey ( ) ; } @ Override public V getValue ( ) { return value ; } @ Override public V setValue ( V v ) { entry . setValue ( new SoftValue < V > ( v , entry . getKey ( ) , queue ) ) ; return value ; } } ) ; } } return result ;


signature:
public class ConvertAnnotationValue { /** * Returns the value .
 * The result has one of the following types :
 * < ul > < li > a wrapper class ( such as { @ link Integer } ) for a primitive type
 * < li > { @ code String }
 * < li > { @ code TypeMirror }
 * < li > { @ code EnumConstantDeclaration }
 * < li > { @ code AnnotationMirror }
 * < li > { @ code Collection < AnnotationValue > }
 * ( representing the elements , in order , if the value is an array )
 * internal . getValue returns :
 * * < ul > < li > a wrapper class ( such as { @ link Integer } ) for a primitive type
 * < li > { @ code String }
 * < li > { @ code TypeMirror }
 * < li > { @ code VariableElement } ( representing an enum constant )
 * < li > { @ code AnnotationMirror }
 * < li > { @ code List < ? extends AnnotationValue > }
 * ( representing the elements , in declared order , if the value is an array )
 * < / ul >
 * @ return the value */
@ Override @ SuppressWarnings ( { } }

implementation:
"unchecked" } ) public Object getValue ( ) { Debug . implemented ( "Object" ) ; Object ret = internal . getValue ( ) ; if ( ret instanceof VariableElement && ( ( VariableElement ) ret ) . getKind ( ) == ElementKind . ENUM_CONSTANT ) ret = ConvertDeclaration . convert ( ( VariableElement ) ret ) ; else if ( ret instanceof javax . lang . model . element . AnnotationMirror ) ret = ConvertAnnotationMirror . convert ( ( javax . lang . model . element . AnnotationMirror ) ret ) ; else if ( ret instanceof javax . lang . model . type . TypeMirror ) ret = ConvertTypeMirror . convert ( ( javax . lang . model . type . TypeMirror ) ret ) ; else if ( ret instanceof List ) ret = convert ( ( List < ? extends AnnotationValue > ) ret ) ; // else , we are hoping it ' s a String or wrapper for a primitive type , just return it
if ( Debug . debug ) System . err . println ( "!!!!!!!!!!!!ret: " + ret ) ; return ret ;


signature:
public class CmdUtil { /** * Print the help for < code > options < / code > with the specified command line
 * syntax . This method prints help information to System . out .
 * @ param cmdLineSyntax
 * the syntax for this application
 * @ param header
 * the banner to display at the begining of the help
 * @ param options
 * the Options instance
 * @ param footer
 * the banner to display at the end of the help */
public static void printHelp ( String cmdLineSyntax , String header , Options options , String footer ) { } }

implementation: HelpFormatter hf = new HelpFormatter ( ) ; if ( CommUtil . isBlank ( cmdLineSyntax ) ) { cmdLineSyntax = "Command [options]..." ; } header = header + SysUtil . LINE_SEPARATOR + "Options:" ; footer = SysUtil . LINE_SEPARATOR + footer ; hf . printHelp ( cmdLineSyntax , header , options , footer ) ;


signature:
public class CmdUtil { /** * Return a commandLine object by specifies { @ link Parser } , { @ link Options } ,
 * < code > arguments < / code > , < code > stopAtNonOption < / code >
 * @ param parser
 * see abstract { @ link Parser } , and interface
 * { @ link CommandLineParser }
 * @ param options
 * the < code > Options < / code >
 * @ param arguments
 * the < code > arguments < / code >
 * @ param stopAtNonOption
 * specifies whether to stop interpreting the arguments when a
 * non option has been encountered and to add them to the
 * CommandLines args list .
 * @ return the < code > CommandLine < / code >
 * @ throws ParseException
 * ParseException if an error occurs when parsing the arguments . */
public static CommandLine parse ( Parser parser , Options options , String [ ] arguments , boolean stopAtNonOption ) throws ParseException { } }

implementation: CommandLine line = parser . parse ( options , arguments , stopAtNonOption ) ; return line ;


signature:
public class FilesystemSource { /** * Get ready to start processing . */
public void init ( Properties properties ) { } }

implementation: super . init ( properties ) ; String strPathname = properties . getProperty ( SOURCE_ROOT_PATHNAME_PARAM ) ; if ( strPathname == null ) { strPathname = "c:\\My Documents" ; properties . setProperty ( SOURCE_ROOT_PATHNAME_PARAM , strPathname ) ; }


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

implementation: super . initTransfer ( properties ) ; m_strRootPath = properties . getProperty ( SOURCE_ROOT_PATHNAME_PARAM ) ; m_iCurrentLevel = - 1 ;


signature:
public class FilesystemSource { /** * Returns the next element in the iteration .
 * ( Returns a SourceFileObject ) .
 * @ returns the next element in the iteration .
 * @ exception NoSuchElementException iteration has no more elements . */
public SourceFile next ( ) { } }

implementation:
if ( this . isPend ( ) ) return this . getPend ( ) ; if ( m_iCurrentLevel == - 1 ) { // First time
File fileDir = new File ( m_strRootPath ) ; m_iCurrentLevel ++ ; if ( ! fileDir . isDirectory ( ) ) return null ; // Never / / pend ( don ) Return 1 file ?
m_rgfileCurrentFilelist [ m_iCurrentLevel ] = fileDir . listFiles ( ) ; m_rgstrCurrentPath [ m_iCurrentLevel ] = JBackupConstants . BLANK ; // Root ( relative )
m_rgiCurrentFile [ m_iCurrentLevel ] = 0 ; } while ( true ) { File [ ] fileList = m_rgfileCurrentFilelist [ m_iCurrentLevel ] ; // Current list
int iCurrentIndex = m_rgiCurrentFile [ m_iCurrentLevel ] ; if ( iCurrentIndex >= fileList . length ) { // End of directory , go up a level
m_rgfileCurrentFilelist [ m_iCurrentLevel ] = null ; // Free
m_rgstrCurrentPath [ m_iCurrentLevel ] = null ; m_rgiCurrentFile [ m_iCurrentLevel ] = 0 ; m_iCurrentLevel -- ; // End of directory
if ( m_iCurrentLevel < 0 ) return null ; // End of files !
} else { File file = fileList [ iCurrentIndex ] ; String strPath = m_rgstrCurrentPath [ m_iCurrentLevel ] ; m_rgiCurrentFile [ m_iCurrentLevel ] ++ ; // Bump for next time
if ( file . isDirectory ( ) ) { // This is a directory , go down a level
strPath += file . getName ( ) + gchSeparator ; m_iCurrentLevel ++ ; if ( m_Filter == null ) fileList = file . listFiles ( ) ; else fileList = file . listFiles ( m_Filter ) ; m_rgfileCurrentFilelist [ m_iCurrentLevel ] = fileList ; m_rgstrCurrentPath [ m_iCurrentLevel ] = strPath ; // Relative path to this directory
m_rgiCurrentFile [ m_iCurrentLevel ] = 0 ; if ( fileList == null ) m_iCurrentLevel -- ; // Special case - skip windows linked directory
} else if ( file . isFile ( ) ) { String strName = file . getName ( ) ; if ( m_Filter != null ) { if ( ! m_Filter . accept ( file , strName ) ) continue ; // HACK - The filter should do this
} if ( this . skipFile ( file ) ) continue ; String strRelativeFileName = strPath + strName ; long lStreamLength = file . length ( ) ; return new StreamSourceFile ( file , null , strRelativeFileName , strName , lStreamLength ) ; // Return the file
} } }


signature:
public class PrefAuthPersistence { /** * Save the token using java preferences . */
@ Override public void saveToken ( Token token ) { } }

implementation: set ( ACCESS_TOKEN_TOKEN_PREF , token . getToken ( ) ) ; set ( ACCESS_TOKEN_SECRET_PREF , token . getSecret ( ) ) ;


signature:
public class PrefAuthPersistence { /** * Get the persisted token using java preferences . */
@ Override public Token getToken ( ) { } }

implementation: String token = get ( ACCESS_TOKEN_TOKEN_PREF ) ; String secret = get ( ACCESS_TOKEN_SECRET_PREF ) ; return token != null ? new Token ( token , secret ) : null ;


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

implementation: super . init ( properties ) ; String strPathname = properties . getProperty ( LOG_FILENAME_PARAM ) ; if ( strPathname == null ) { strPathname = "" ; properties . setProperty ( LOG_FILENAME_PARAM , strPathname ) ; } String strGetFileLength = properties . getProperty ( CALC_FILE_LENGTH_PARAM ) ; if ( strGetFileLength == null ) { strGetFileLength = TRUE ; properties . setProperty ( CALC_FILE_LENGTH_PARAM , strGetFileLength ) ; }


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

implementation: super . initTransfer ( properties ) ; String strPathname = properties . getProperty ( LOG_FILENAME_PARAM ) ; if ( strPathname != null ) if ( strPathname . length ( ) > 0 ) { try { FileOutputStream fileOut = new FileOutputStream ( strPathname ) ; streamOut = new PrintStream ( fileOut ) ; } catch ( FileNotFoundException e ) { e . printStackTrace ( ) ; } } if ( streamOut == null ) streamOut = System . out ; String strSelected = properties . getProperty ( CALC_FILE_LENGTH_PARAM ) ; if ( FALSE . equalsIgnoreCase ( strSelected ) ) getFileLength = false ; else getFileLength = true ;


signature:
public class DebugDestination { /** * 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 lTotalLength = 0 ; if ( getFileLength ) { byte rgBytes [ ] = new byte [ 8192 ] ; InputStream inStream = source . makeInStream ( ) ; try { while ( true ) { int iLength = rgBytes . length ; iLength = inStream . read ( rgBytes , 0 , iLength ) ; if ( iLength <= 0 ) break ; lTotalLength += iLength ; } } catch ( IOException ex ) { streamOut . println ( "Error on next file: " + ex . getMessage ( ) ) ; } } streamOut . println ( "Filename: " + strFilename + " Path: " + strPath + " length: " + lTotalLength ) ; return lTotalLength ;


signature:
public class FtpDestinationPropertyView { /** * 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 ( 5 , 2 ) ) ; panelMain . add ( new JLabel ( "Ftp Host: " , JLabel . RIGHT ) ) ; panelMain . add ( m_tfHost = new JTextField ( ) ) ; panelMain . add ( new JLabel ( "Ftp Port: " , JLabel . RIGHT ) ) ; panelMain . add ( m_tfPort = new JTextField ( ) ) ; panelMain . add ( new JLabel ( "User name: " , JLabel . RIGHT ) ) ; panelMain . add ( m_tfUser = new JTextField ( ) ) ; panelMain . add ( new JLabel ( "Password: " , JLabel . RIGHT ) ) ; panelMain . add ( m_tfPassword = new JTextField ( ) ) ; panelMain . add ( new JLabel ( "Initial directory: " , JLabel . RIGHT ) ) ; panelMain . add ( m_tfDir = new JTextField ( ) ) ; JPanel panelSub = this . makeNewPanel ( panel , BorderLayout . SOUTH ) ; super . addControlsToView ( panelSub ) ;


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

implementation: super . controlsToProperties ( ) ; String strHost = m_tfHost . getText ( ) ; m_properties . setProperty ( FTP_HOST , strHost ) ; String strPort = m_tfPort . getText ( ) ; m_properties . setProperty ( FTP_PORT , strPort ) ; String strUser = m_tfUser . getText ( ) ; m_properties . setProperty ( USER_NAME , strUser ) ; String strPassword = m_tfPassword . getText ( ) ; m_properties . setProperty ( PASSWORD , strPassword ) ; String strDir = m_tfDir . getText ( ) ; m_properties . setProperty ( ROOT_DIR , strDir ) ;


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

implementation: super . propertiesToControls ( ) ; String strHost = m_properties . getProperty ( FTP_HOST ) ; m_tfHost . setText ( strHost ) ; String strPort = m_properties . getProperty ( FTP_PORT ) ; m_tfPort . setText ( strPort ) ; String strUser = m_properties . getProperty ( USER_NAME ) ; m_tfUser . setText ( strUser ) ; String strPassword = m_properties . getProperty ( PASSWORD ) ; m_tfPassword . setText ( strPassword ) ; String strDir = m_properties . getProperty ( ROOT_DIR ) ; if ( strDir == null ) strDir = DEFAULT_ROOT_DIR ; m_tfDir . setText ( strDir ) ;


signature:
public class ClasspathUtils { /** * 根据 classLoader 获取所有的 Classpath URLs . */
public static Collection < URL > getClasspathURLs ( final ClassLoader classLoader ) { } }

implementation:
Collection < URL > urls = new LinkedHashSet < URL > ( 32 ) ; ClassLoader loader = classLoader ; while ( loader != null ) { String className = loader . getClass ( ) . getName ( ) ; if ( EXT_CLASS_LOADER_NAME . equals ( className ) ) { break ; } if ( loader instanceof URLClassLoader ) { for ( URL url : ( ( URLClassLoader ) loader ) . getURLs ( ) ) { urls . add ( url ) ; } } else if ( className . startsWith ( "weblogic.utils.classloaders." ) ) { // 该死的 WebLogic , 只能特殊处理
// GenericClassLoader , FilteringClassLoader , ChangeAwareClassLoader
try { Method method = loader . getClass ( ) . getMethod ( "getClassPath" ) ; Object result = method . invoke ( loader ) ; if ( result != null ) { String [ ] paths = StringUtils . split ( result . toString ( ) , File . pathSeparatorChar ) ; for ( String path : paths ) { urls . add ( URLUtils . fromFile ( path ) ) ; } } } catch ( NoSuchMethodException e ) { } catch ( Exception e ) { throw new RuntimeException ( e ) ; } } else if ( className . startsWith ( "org.jboss.modules.ModuleClassLoader" ) ) { // 该死的 Jboss / Wildfly 8 , 只能特殊处理
try { Set < URL > urlSet = JBossModuleUtils . getClasspathURLs ( loader , false ) ; urls . addAll ( urlSet ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } } loader = loader . getParent ( ) ; } // moved jsp classpath from ServletContext . attributes to System . properties
String jsp_classpath = System . getProperty ( "org.apache.catalina.jsp_classpath" ) ; String classpath = System . getProperty ( "java.class.path" ) ; classpath = StringUtils . trimToEmpty ( classpath ) + File . pathSeparatorChar + StringUtils . trimToEmpty ( jsp_classpath ) ; if ( classpath . length ( ) > 1 ) { String [ ] paths = StringUtils . split ( classpath , File . pathSeparatorChar ) ; for ( String path : paths ) { path = path . trim ( ) ; if ( path . length ( ) > 0 ) { URL url = URLUtils . fromFile ( path ) ; urls . add ( url ) ; } } } // 添加包含所有的 META - INF / MANIFEST . MF 的 jar 文件
try { Enumeration < URL > paths = classLoader . getResources ( "META-INF/MANIFEST.MF" ) ; while ( paths . hasMoreElements ( ) ) { URL url = paths . nextElement ( ) ; File file = URLUtils . toFileObject ( url ) ; urls . add ( file . toURI ( ) . toURL ( ) ) ; } } catch ( Exception e ) { throw new RuntimeException ( e ) ; } // 删除 jdk 自带的 jar
Iterator < URL > it = urls . iterator ( ) ; while ( it . hasNext ( ) ) { String path = it . next ( ) . getPath ( ) ; if ( path . contains ( "/jre/lib/" ) ) { it . remove ( ) ; } } return urls ;