idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
29,800
public static HashMap traverseToPoint ( HashMap m , String p ) { HashMap pointer = m ; String [ ] base = p . split ( "[@]" ) ; String [ ] b = base [ 0 ] . split ( "[:]" ) ; int bl = b . length ; for ( int i = 0 ; i < bl ; i ++ ) { pointer = ( HashMap ) pointer . get ( b [ i ] ) ; } return pointer ; }
A helper method to help traverse to a certain point in the map .
29,801
public static String getEventDateVar ( String event , String var ) { var = var . toLowerCase ( ) ; if ( event == null || var . endsWith ( "date" ) || var . endsWith ( "dat" ) ) return var ; if ( event . equals ( "planting" ) ) { var = "pdate" ; } else if ( event . equals ( "irrigation" ) ) { var = "idate" ; } else if ( event . equals ( "fertilizer" ) ) { var = "fedate" ; } else if ( event . equals ( "tillage" ) ) { var = "tdate" ; } else if ( event . equals ( "harvest" ) ) { var = "hadat" ; } else if ( event . equals ( "organic_matter" ) ) { var = "omdat" ; } else if ( event . equals ( "chemicals" ) ) { var = "cdate" ; } else if ( event . equals ( "mulch-apply" ) ) { var = "mladat" ; } else if ( event . equals ( "mulch-remove" ) ) { var = "mlrdat" ; } return var ; }
Renames a date variable from an event
29,802
public T call ( ) throws Exception { logger . debug ( "task '{}' starting" , id ) ; try { return task . execute ( ) ; } finally { logger . debug ( "task '{}' is complete (queue size: {})" , id , queue . size ( ) ) ; queue . offer ( id ) ; } }
Actual thread s workhorse method ; it implements a code around pattern and delegates actual business logic to subclasses while retaining the logic necessary to signal completion to the caller .
29,803
static void configureLog4j ( ) { org . apache . log4j . LogManager . resetConfiguration ( ) ; org . apache . log4j . Logger . getRootLogger ( ) . addAppender ( new org . apache . log4j . Appender ( ) { private String name ; public void setName ( String name ) { this . name = name ; } public void setLayout ( org . apache . log4j . Layout layout ) { } public void setErrorHandler ( org . apache . log4j . spi . ErrorHandler errorHandler ) { } public boolean requiresLayout ( ) { return false ; } public String getName ( ) { return name ; } public org . apache . log4j . Layout getLayout ( ) { return null ; } public org . apache . log4j . spi . Filter getFilter ( ) { return null ; } public org . apache . log4j . spi . ErrorHandler getErrorHandler ( ) { return null ; } public void doAppend ( org . apache . log4j . spi . LoggingEvent event ) { Logger logger = Logging . getLogger ( event . getLoggerName ( ) ) ; logger . genericLog ( event . getMessage ( ) + "" , event . getThrowableInformation ( ) == null ? null : event . getThrowableInformation ( ) . getThrowable ( ) , convertPriority ( event . getLevel ( ) ) ) ; } private Priority convertPriority ( org . apache . log4j . Level level ) { switch ( level . toInt ( ) ) { case org . apache . log4j . Level . ALL_INT : return Priority . ALL ; case org . apache . log4j . Level . TRACE_INT : return Priority . VERBOSE ; case org . apache . log4j . Level . DEBUG_INT : return Priority . DEBUG ; case org . apache . log4j . Level . WARN_INT : return Priority . WARN ; case org . apache . log4j . Level . INFO_INT : return Priority . INFO ; case org . apache . log4j . Level . ERROR_INT : return Priority . ERROR ; case org . apache . log4j . Level . FATAL_INT : return Priority . FATAL ; } return Priority . OFF ; } public void close ( ) { } public void clearFilters ( ) { } public void addFilter ( org . apache . log4j . spi . Filter newFilter ) { } } ) ; }
Called during Logging init potentially resets log4j to follow the settings configured by pelzer . util .
29,804
public static InputStream fromURL ( URL url ) throws IOException { if ( url != null ) { return url . openStream ( ) ; } return null ; }
Opens an input stream to the given URL .
29,805
public static InputStream fromFile ( String filepath ) throws FileNotFoundException { if ( Strings . isValid ( filepath ) ) { return fromFile ( new File ( filepath ) ) ; } return null ; }
Returns an input stream from a string representing its path .
29,806
public static void safelyClose ( OutputStream stream ) { if ( stream != null ) { try { stream . close ( ) ; } catch ( IOException e ) { logger . warn ( "error closing internal output stream, this may lead to a stream leak" , e ) ; } } }
Tries to close the given stream ; if any exception is thrown in the process it suppresses it .
29,807
private IXADataRecorder createXADataRecorder ( ) { try { long xaDataRecorderId = this . messageSeqGenerator . generate ( ) ; IDataLogger dataLogger = this . dataLoggerFactory . instanciateLogger ( Long . toString ( xaDataRecorderId ) ) ; XADataLogger xaDataLogger = new XADataLogger ( dataLogger ) ; PhynixxXADataRecorder xaDataRecorder = PhynixxXADataRecorder . openRecorderForWrite ( xaDataRecorderId , xaDataLogger , this ) ; synchronized ( this ) { addXADataRecorder ( xaDataRecorder ) ; } LOG . info ( "IXADataRecord " + xaDataRecorderId + " created in [" + Thread . currentThread ( ) + "]" ) ; return xaDataRecorder ; } catch ( Exception e ) { throw new DelegatedRuntimeException ( e ) ; } }
opens a new Recorder for writing . The recorder gets a new ID .
29,808
private void rollLog ( ) { final File file = currentFile ; if ( file == null ) { throw new IllegalStateException ( "currentFile is null" ) ; } final OutputStream stream = currentStream ; if ( stream == null ) { throw new IllegalStateException ( "currentStream is null" ) ; } this . currentFile = null ; this . currentStream = null ; if ( compressor == null ) { return ; } final Thread compressingThread = new Thread ( new Runnable ( ) { public void run ( ) { log . trace ( "Closing output stream of target file={}" , file ) ; try { stream . close ( ) ; } catch ( IOException e ) { log . error ( "Unable to properly close output stream" , e ) ; } compressFileContents ( compressor , file ) ; currentCompressingThread = null ; } } ) ; compressingThread . run ( ) ; currentCompressingThread = compressingThread ; }
Writes older log into the file and updates current output stream
29,809
public void setAttribute ( String key , String value ) { if ( nodeAttributes == null ) { nodeAttributes = new Properties ( ) ; } nodeAttributes . setProperty ( key , value ) ; }
Sets a name - value pair that appears as attribute in the opening tag
29,810
public void parse ( String xmlInput , boolean strict ) throws ParseException { if ( xmlInput == null ) { throw new IllegalArgumentException ( "input can not be null" ) ; } ArrayList splitContents = split ( xmlInput , interpreteAsXHTML , true ) ; build ( splitContents , interpreteAsXHTML ) ; }
parses input adds contents
29,811
public static boolean setInitFilePath ( String filePath ) { if ( filePath != null ) { if ( init ( filePath ) ) { return true ; } String defaultPath = System . getProperty ( GlobalFileProperties . class . getName ( ) + ".DefaultPath" ) ; String newPath = defaultPath + File . separator + filePath ; if ( init ( newPath ) ) { return true ; } } String defaultPath = System . getProperty ( GlobalFileProperties . class . getName ( ) + ".DefaultPath" ) ; if ( init ( defaultPath ) ) { return true ; } else { log . error ( GlobalFileProperties . class . getName ( ) + " No initialized width path:" + filePath + " try to set the path in System propertyes:" + GlobalFileProperties . class . getName ( ) + ".DefaultPath" ) ; return false ; } }
The read only file where global properties are stored .
29,812
private synchronized static void loadAll ( ) throws DaoManagerException { if ( setImpl == null ) { long implLastModifiedTime = impl . getLastModified ( ) ; if ( lastModified < implLastModifiedTime ) { Map < String , PropertyDescriptor > staticValues = impl . getAll ( ) ; synchronized ( cache ) { cache . clear ( ) ; cache . putAll ( staticValues ) ; } lastModified = System . currentTimeMillis ( ) ; notifyPropertiesChangedListers ( lastModified ) ; } } else { long implLastModifiedTime = impl . getLastModified ( ) ; long setImplLastModifiedTime = setImpl . getLastModified ( ) ; if ( lastModified < implLastModifiedTime || lastModified < setImplLastModifiedTime ) { Map < String , PropertyDescriptor > staticValues = impl . getAll ( ) ; Map < String , PropertyDescriptor > dynamicValues = setImpl . getAll ( ) ; synchronized ( cache ) { cache . clear ( ) ; cache . putAll ( staticValues ) ; cache . putAll ( dynamicValues ) ; } lastModified = System . currentTimeMillis ( ) ; notifyPropertiesChangedListers ( lastModified ) ; } } }
Thread exclusion zone .
29,813
private static String getFilePath ( String defaultPath , String filePath ) { return defaultPath + File . separator + filePath ; }
Crea el path para el fichero a partir del path por defecto
29,814
public static < T extends Closeable > T close ( T toClose , Logger logExceptionTo , Object name ) { if ( toClose == null ) return null ; try { toClose . close ( ) ; } catch ( IOException e ) { ( logExceptionTo == null ? logger : logExceptionTo ) . warn ( "IOException closing " + ( name == null ? toClose . toString ( ) : name ) + " ignored." , e ) ; } return null ; }
Handle closing .
29,815
protected void onFirstOutput ( ) throws IOException { if ( prefix != null && prefix . length ( ) > 0 ) { print ( prefix ) ; prefix = null ; } }
Writes out the prefix .
29,816
public void resolveDependencies ( ) { if ( dependenciesResolved ) { throw new Error ( "Can resolve dependencies only once" ) ; } dependenciesResolved = true ; for ( ClassModel classModel : classes . values ( ) ) { classModel . resolveOuterClass ( ) ; } for ( ClassModel classModel : classes . values ( ) ) { classModel . resolveUsedClasses ( ) ; if ( classModel . outerClass == null ) { classModel . resolveModule ( ) ; } } for ( ClassModel classModel : new ArrayList < > ( classes . values ( ) ) ) { if ( classModel . outerClass != null ) { classModel . getToplevelClass ( ) . usesClasses . addAll ( classModel . usesClasses ) ; classes . remove ( classModel . getQualifiedName ( ) ) ; } } for ( ModuleModel moduleModel : modules . values ( ) ) { moduleModel . resolveDependencies ( ) ; } calculateModuleDepenendencies ( ) ; }
Resolve class names recorded during parsing to the actual model objects and calculate transitive closures .
29,817
public void checkDependencyCycles ( List < String > errors ) { if ( ! dependenciesResolved ) { throw new Error ( "Call resolveDependencies() first" ) ; } SimpleDirectedGraph < ModuleModel , Edge > g = buildModuleDependencyGraph ( ) ; CycleDetector < ModuleModel , Edge > detector = new CycleDetector < > ( g ) ; Set < ModuleModel > cycleModules = detector . findCycles ( ) ; if ( ! cycleModules . isEmpty ( ) ) { errors . add ( "Found cycle in module dependency graph. Involved modules: " + cycleModules ) ; } }
Check if there are any cycles in the dependencies of the modules .
29,818
private SimpleDirectedGraph < ModuleModel , Edge > buildModuleDependencyGraph ( ) { SimpleDirectedGraph < ModuleModel , Edge > g = buildExportGraph ( ) ; for ( ModuleModel module : modules . values ( ) ) { for ( ModuleModel imported : module . importedModules ) { g . addEdge ( module , imported ) ; } } return g ; }
Build a graph containing all module dependencies
29,819
public void checkClassAccessibility ( List < String > errors ) { for ( ClassModel clazz : classes . values ( ) ) { clazz . checkAccessibilityOfUsedClasses ( errors ) ; } }
Check if all classes respect the accessibility boundaries defined by the modules .
29,820
public void checkAllClassesInModule ( List < String > errors ) { for ( ClassModel clazz : classes . values ( ) ) { if ( clazz . getModule ( ) == null ) { errors . add ( "Class " + clazz + " is in no module" ) ; } } }
Check if all classes belong to a module
29,821
public synchronized void cleanup ( ) { String pattern = MessageFormat . format ( LOGGER_SYSTEM_FORMAT_PATTERN , this . loggerSystemName ) ; LogFilenameMatcher matcher = new LogFilenameMatcher ( pattern ) ; LogFileTraverser . ICollectorCallback cb = new LogFileTraverser . ICollectorCallback ( ) { public void match ( File file , LogFilenameMatcher . LogFilenameParts parts ) { boolean success = file . delete ( ) ; if ( LOGGER . isDebugEnabled ( ) ) { LOGGER . debug ( "Deleting " + file + " success=" + success ) ; } } } ; new LogFileTraverser ( matcher , FileChannelDataLoggerFactory . this . getLoggingDirectory ( ) , cb ) ; }
destroys a logfiles
29,822
@ SuppressWarnings ( "unchecked" ) public static < T extends Message > T copy ( final T message ) { return message == null ? null : ( T ) message . copy ( ) ; }
Returns a deep copy of a pdef message .
29,823
public static < T > List < T > copy ( final List < T > list ) { if ( list == null ) { return null ; } TypeEnum elementType = null ; List < T > copy = new ArrayList < T > ( ) ; for ( T element : list ) { T elementCopy = null ; if ( element != null ) { if ( elementType == null ) { elementType = TypeEnum . dataTypeOf ( element . getClass ( ) ) ; } elementCopy = copy ( element , elementType ) ; } copy . add ( elementCopy ) ; } return copy ; }
Returns a deep copy of a pdef list .
29,824
public static < T > Set < T > copy ( final Set < T > set ) { if ( set == null ) { return null ; } TypeEnum elementType = null ; Set < T > copy = new HashSet < T > ( ) ; for ( T element : set ) { T elementCopy = null ; if ( element != null ) { if ( elementType == null ) { elementType = TypeEnum . dataTypeOf ( element . getClass ( ) ) ; } elementCopy = copy ( element , elementType ) ; } copy . add ( elementCopy ) ; } return copy ; }
Returns a deep copy of a pdef set .
29,825
public static < K , V > Map < K , V > copy ( final Map < K , V > map ) { if ( map == null ) { return null ; } TypeEnum keyType = null ; TypeEnum valueType = null ; Map < K , V > copy = new HashMap < K , V > ( ) ; for ( Map . Entry < K , V > entry : map . entrySet ( ) ) { K key = entry . getKey ( ) ; V value = entry . getValue ( ) ; K keyCopy = null ; if ( key != null ) { if ( keyType == null ) { keyType = TypeEnum . dataTypeOf ( key . getClass ( ) ) ; } keyCopy = copy ( key , keyType ) ; } V valueCopy = null ; if ( value != null ) { if ( valueType == null ) { valueType = TypeEnum . dataTypeOf ( value . getClass ( ) ) ; } valueCopy = copy ( value , valueType ) ; } copy . put ( keyCopy , valueCopy ) ; } return copy ; }
Returns a deep copy of a pdef map .
29,826
private void setup ( ) { super . setMapperClass ( Mapper . class ) ; super . setMapOutputKeyClass ( Key . class ) ; super . setMapOutputValueClass ( Value . class ) ; super . setPartitionerClass ( SimplePartitioner . class ) ; super . setGroupingComparatorClass ( SimpleGroupingComparator . class ) ; super . setSortComparatorClass ( SimpleSortComparator . class ) ; super . setReducerClass ( Reducer . class ) ; super . setOutputKeyClass ( Key . class ) ; super . setOutputValueClass ( Value . class ) ; }
Default job settings .
29,827
public String encode ( Object source ) { return net . arnx . jsonic . JSON . encode ( source , true ) ; }
Encodes a object into a JSON string .
29,828
public void encode ( Object source , File file ) throws IOException , ParserException { Writer writer = null ; try { writer = new Writer ( file ) ; net . arnx . jsonic . JSON . encode ( source , writer , true ) ; } catch ( net . arnx . jsonic . JSONException e ) { throw new ParserException ( e . getMessage ( ) ) ; } finally { if ( writer != null ) writer . close ( ) ; } }
Encodes a object into a JSON string and outputs a file .
29,829
public String encode ( XML xml ) throws ParserException , SAXException , IOException { DocumentBuilderFactory dbFactory = DocumentBuilderFactory . newInstance ( ) ; DocumentBuilder builder = null ; InputSource is = new InputSource ( new StringReader ( xml . toString ( ) ) ) ; try { builder = dbFactory . newDocumentBuilder ( ) ; Document doc = builder . parse ( is ) ; return net . arnx . jsonic . JSON . encode ( doc , true ) ; } catch ( SAXException e ) { throw new ParserException ( e . getMessage ( ) ) ; } catch ( ParserConfigurationException e ) { throw new ParserException ( e . getMessage ( ) ) ; } }
Convert a XML object to a JSON string .
29,830
public < T > T decode ( String source , Class < ? extends T > cls ) { return net . arnx . jsonic . JSON . decode ( source , cls ) ; }
Decodes a JSON string into a typed object .
29,831
public < T > T decode ( File file , Class < ? extends T > cls ) throws ParserException , IOException { return decode ( new Reader ( file ) , cls ) ; }
Decodes a JSON file into a typed object .
29,832
public < T > T decode ( Reader reader , Class < ? extends T > cls ) throws ParserException , IOException { try { return net . arnx . jsonic . JSON . decode ( reader , cls ) ; } catch ( net . arnx . jsonic . JSONException e ) { throw new ParserException ( e . getMessage ( ) ) ; } }
Decodes a JSON reader into a typed object .
29,833
public boolean isInstanceOfTag ( Tag tag ) { return tag != null && getTag ( ) . filter ( t -> t . isInstance ( tag ) ) . isPresent ( ) ; }
Determines if this annotation s tag is an instance of the given tag .
29,834
public static Failure copy ( Failure failure ) { if ( failure == null ) { return null ; } Failure result = new Failure ( ) ; result . code = failure . code ; result . details = failure . details ; result . title = failure . title ; return result ; }
Creates a new copy of failure descriptor .
29,835
public static Failure parse ( String failure ) { Failure result = new Failure ( ) ; int dash = failure . indexOf ( '-' ) ; int leftBracet = failure . indexOf ( '(' ) ; int rightBracet = failure . indexOf ( ')' ) ; result . title = failure . substring ( 0 , leftBracet ) . trim ( ) ; result . code = failure . substring ( leftBracet + 1 , rightBracet ) . trim ( ) ; if ( dash > 0 ) { result . details = failure . substring ( dash + 1 ) . trim ( ) ; } return result ; }
Creates a new failure descriptor based on its string presentation .
29,836
public Logger createLogger ( InjectionPoint injectionPoint ) { Logging annotation = injectionPoint . getAnnotated ( ) . getAnnotation ( Logging . class ) ; String name = annotation . name ( ) ; if ( name == null || name . isEmpty ( ) ) { return this . createClassLogger ( injectionPoint ) ; } Resolver resolverAnnotation = annotation . resolver ( ) ; ResolverWrapper wrapper = new ResolverAnnotationWrapper ( resolverAnnotation ) ; PropertyResolver resolver = this . resolverFactory . createPropertyResolver ( wrapper ) ; Map < Object , Object > bootstrapMap = this . resolverFactory . getBootstrapProperties ( wrapper ) ; Map < Object , Object > defaultMap = this . resolverFactory . getDefaultProperties ( wrapper ) ; String resolvedName = resolver . resolveProperties ( name , bootstrapMap , defaultMap ) ; return Logger . getLogger ( resolvedName ) ; }
Creates a Logger with using the class name of the injection point .
29,837
private Logger createClassLogger ( InjectionPoint injectionPoint ) { return Logger . getLogger ( injectionPoint . getMember ( ) . getDeclaringClass ( ) . getName ( ) ) ; }
Utility for creating class logger from injection point
29,838
public static Version valueOf ( final String value ) { final Optional < Instant > time = parse ( value ) ; if ( time . isPresent ( ) ) { return new Version ( time . get ( ) ) ; } return null ; }
Create a Version object from a string value
29,839
public static boolean isDuplicated ( final String input ) { int len = input . length ( ) ; if ( len % 2 == 0 ) { int half = len / 2 ; if ( hasEqualParts ( input , half , half ) ) { return true ; } if ( input . substring ( half , half + 1 ) . equals ( " " ) && input . substring ( half - 1 , half ) . matches ( "[;,]" ) ) { return hasEqualParts ( input , half - 1 , half + 1 ) ; } } else { int half = len / 2 ; String middlePart = input . substring ( half - 1 , half + 2 ) ; if ( isSpaceCommaSpace ( middlePart ) ) { return hasEqualParts ( input , half - 1 , half + 2 ) ; } else if ( isCommaInTheMiddle ( middlePart ) || isLineBreakInTheMiddle ( middlePart ) ) { return hasEqualParts ( input , half , half + 1 ) ; } } return false ; }
Checks if the string is a duplication is a substring .
29,840
private static boolean hasEqualParts ( final String input , final int beginTo , final int endFrom ) { String begin = input . substring ( 0 , beginTo ) ; String end = input . substring ( endFrom ) ; return begin . equals ( end ) ; }
Checks if a string s beginning and end are equal .
29,841
public static Object getProperty ( final Object src , final String propertyName ) { if ( src == null ) { throw new IllegalArgumentException ( "no source object specified" ) ; } if ( propertyName == null ) { throw new IllegalArgumentException ( "no property specified" ) ; } Class < ? > clazz = src . getClass ( ) ; PropertyAccessor accessor = _findAccessor ( clazz , propertyName ) ; if ( accessor == null ) { throw new IllegalStateException ( "getter not found: class=" + clazz . getName ( ) + ", property=" + propertyName ) ; } return accessor . getProperty ( src ) ; }
Returns the property value of the specified object . If the object has no such property it is notified with an exception .
29,842
public static void setProperty ( final Object dst , final String propertyName , final Object value ) { if ( dst == null ) { throw new IllegalArgumentException ( "no destination object specified" ) ; } if ( propertyName == null ) { throw new IllegalArgumentException ( "no property specified" ) ; } Class < ? > clazz = dst . getClass ( ) ; PropertyAccessor accessor = _findAccessor ( clazz , propertyName ) ; if ( accessor == null ) { throw new IllegalStateException ( "setter not found: class=" + clazz . getName ( ) + ", property=" + propertyName ) ; } accessor . setProperty ( dst , value ) ; }
Sets the property value of the specified object . If the object has no such property it is notified with an exception .
29,843
public static boolean isPropertyGettable ( final Object src , final String propertyName ) { if ( src == null ) { throw new IllegalArgumentException ( "no source object specified" ) ; } return isPropertyGettable ( src . getClass ( ) , propertyName ) ; }
Tests if the property value of the specified object can be got .
29,844
public static boolean isPropertyGettable ( final Class < ? > clazz , final String propertyName ) { if ( clazz == null ) { throw new IllegalArgumentException ( "no class specified" ) ; } if ( propertyName == null ) { throw new IllegalArgumentException ( "no property specified" ) ; } PropertyAccessor accessor = _findAccessor ( clazz , propertyName ) ; return ( accessor == null ? false : accessor . isGettable ( ) ) ; }
Tests if the property value of the specified class can be got .
29,845
public static boolean isPropertySettable ( final Object dst , final String propertyName ) { if ( dst == null ) { throw new IllegalArgumentException ( "no destination object specified" ) ; } return isPropertySettable ( dst . getClass ( ) , propertyName ) ; }
Tests if the property value of the specified object can be set .
29,846
public static boolean isPropertySettable ( final Class < ? > clazz , final String propertyName ) { if ( clazz == null ) { throw new IllegalArgumentException ( "no class specified" ) ; } if ( propertyName == null ) { throw new IllegalArgumentException ( "no property specified" ) ; } PropertyAccessor accessor = _findAccessor ( clazz , propertyName ) ; return ( accessor == null ? false : accessor . isSettable ( ) ) ; }
Tests if the property value of the specified class can be set .
29,847
public static Collection < String > getPropertyNames ( final Object object ) { if ( object == null ) { throw new IllegalArgumentException ( "no object specified" ) ; } return getPropertyNames ( object . getClass ( ) ) ; }
Returns all the property names of the specified object .
29,848
public static Collection < String > getPropertyNames ( final Class < ? > clazz ) { if ( clazz == null ) { throw new IllegalArgumentException ( "no class specified" ) ; } Map < String , PropertyAccessor > accessors = _getAccessors ( clazz ) ; return accessors . keySet ( ) ; }
Returns all the property names of the specified class .
29,849
public static int copyProperty ( final Object dst , final Object src , final String propertyName ) { int count = 0 ; if ( isPropertyGettable ( src , propertyName ) && isPropertySettable ( dst , propertyName ) ) { Object value = getProperty ( src , propertyName ) ; setProperty ( dst , propertyName , value ) ; count ++ ; } return count ; }
Copies the property from the object to the other object .
29,850
private static Map < String , PropertyAccessor > _getAccessors ( final Class < ? > clazz ) { Map < String , PropertyAccessor > accessors = null ; synchronized ( _ACCESSORS_REG_ ) { accessors = _ACCESSORS_REG_ . get ( clazz ) ; if ( accessors == null ) { accessors = PropertyAccessor . findAll ( clazz ) ; _ACCESSORS_REG_ . put ( clazz , accessors ) ; } } return accessors ; }
Returns an accessor list for the specified class . The result list is cached for future use .
29,851
public static Value parse ( Reader reader ) throws JSONException { try { return new Parser ( reader ) . parse ( ) ; } finally { try { reader . close ( ) ; } catch ( IOException e ) { } } }
Parses JSON data .
29,852
public static String serialize ( Value value ) throws JSONException { StringWriter writer = new StringWriter ( ) ; Serializer . serialize ( value , writer ) ; return writer . toString ( ) ; }
Serializes a JSON value to a string .
29,853
public static void serialize ( Value value , Writer writer ) throws JSONException { Serializer . serialize ( value , writer ) ; }
Serializes a JSON value to a writer .
29,854
public Mapper < K , V > constraint ( Restraint < K , V > constraint ) { return addConstraint ( constraint ) ; }
Add a specified constraint to this map
29,855
public Mapper < K , V > uniqueKey ( ) { return addConstraint ( new Restraint < K , V > ( ) { public void checkKeyValue ( K key , V value ) { checkArgument ( ! delegate . get ( ) . containsKey ( key ) , "The key: %s is already exist." , key ) ; } } ) ; }
Add a unique key constraint to this map
29,856
public Gather < Entry < K , V > > entryGather ( ) { return Gather . from ( delegate . get ( ) . entrySet ( ) ) ; }
Returns delegate map instance as a entry Gather
29,857
public Mapper < K , V > filter ( Decision < Entry < K , V > > decision ) { delegate = Optional . of ( Maps . filterEntries ( delegate . get ( ) , decision ) ) ; return this ; }
Filter map with a special decision
29,858
private Mapper < K , V > addConstraint ( MapConstraint < K , V > constraint ) { this . delegate = Optional . of ( MapConstraints . constrainedMap ( delegate . get ( ) , constraint ) ) ; return this ; }
Add a constrained view of the delegate map using the specified constraint
29,859
public void buildGroup ( ComponentGroup group , BuilderT builder , Context context ) { for ( Component component : group . getComponents ( ) ) { buildAny ( component , builder , context ) ; } }
Appends a chain of Components to the builder
29,860
protected final void buildAny ( Component component , BuilderT builder , Context context ) { if ( component instanceof ResolvedMacro ) { buildResolved ( ( ResolvedMacro ) component , builder , context ) ; } else if ( component instanceof UnresolvableMacro ) { buildUnresolvable ( ( UnresolvableMacro ) component , builder , context ) ; } else if ( component instanceof TextComponent ) { buildText ( ( TextComponent ) component , builder , context ) ; } else if ( component instanceof ComponentGroup ) { buildGroup ( ( ComponentGroup ) component , builder , context ) ; } else { buildOther ( component , builder , context ) ; } }
Appends a Component to the builder
29,861
private Request bindThreadToRequest ( Thread thread , EntryPoint entryPoint ) { StandardRequest boundRequest ; int threadId = thread . hashCode ( ) ; synchronized ( requestsByThreadId ) { StandardRequest previouslyBoundRequest = ( StandardRequest ) requestsByThreadId . get ( threadId ) ; if ( previouslyBoundRequest == null ) { boundRequest = new StandardRequest ( entryPoint , this ) ; requestsByThreadId . put ( threadId , boundRequest ) ; } else { previouslyBoundRequest . increaseTimesEntered ( ) ; boundRequest = previouslyBoundRequest ; } } return boundRequest ; }
Internal bind implementation .
29,862
public void register ( Authenticator authenticator ) { if ( this . authenticator == null ) { this . authenticator = authenticator ; } else if ( ! authenticator . getClass ( ) . getSimpleName ( ) . equals ( this . authenticator . getClass ( ) . getSimpleName ( ) ) ) { throw new ConfigurationException ( "attempt to replace authenticator " + this . authenticator . getClass ( ) . getSimpleName ( ) + " by " + authenticator . getClass ( ) . getSimpleName ( ) ) ; } }
Used to register any first available authenticator within cluster .
29,863
public StandardSession getSessionByToken ( String token ) { StandardSession session ; synchronized ( sessions ) { session = ( StandardSession ) sessions . get ( token ) ; if ( session != null ) { session . updateLastAccessedTime ( ) ; } } return session ; }
Returns a session if found and updates the last time it was accessed .
29,864
private Session getCurrentSession ( ) { synchronized ( requestsByThreadId ) { StandardRequest request = ( StandardRequest ) requestsByThreadId . get ( Thread . currentThread ( ) . hashCode ( ) ) ; if ( request != null ) { return request . getSession ( false ) ; } } return null ; }
Returns current session which only exists if request was bound previously passing a valid session token .
29,865
public StandardSession createSession ( Properties defaultUserSettings ) { StandardSession session = new StandardSession ( this , sessionTimeout , defaultUserSettings ) ; synchronized ( sessions ) { synchronized ( sessionsMirror ) { sessions . put ( session . getToken ( ) , session ) ; sessionsMirror . put ( session . getToken ( ) , session ) ; } } System . out . println ( new LogEntry ( "session " + session + " created" ) ) ; return session ; }
Creates and registers a session .
29,866
private void destroySessionByToken ( String id ) { System . out . println ( new LogEntry ( "destroying session " + id ) ) ; synchronized ( sessions ) { synchronized ( sessionsMirror ) { StandardSession session = ( StandardSession ) sessions . get ( id ) ; if ( session != null ) { session . onDestruction ( ) ; sessions . remove ( id ) ; sessionsMirror . remove ( id ) ; } } } }
Unregisters a session from all collections so that it becomes eligible for garbage collection .
29,867
public void onPageEvent ( long officialTime ) { ArrayList garbage = new ArrayList ( sessionsMirror . size ( ) ) ; Iterator i ; StandardSession session ; synchronized ( sessionsMirror ) { i = sessionsMirror . values ( ) . iterator ( ) ; while ( i . hasNext ( ) ) { session = ( StandardSession ) i . next ( ) ; if ( session . isExpired ( ) ) { garbage . add ( session ) ; } } } i = garbage . iterator ( ) ; while ( i . hasNext ( ) ) { session = ( StandardSession ) i . next ( ) ; System . out . println ( new LogEntry ( "session " + session . getToken ( ) + " expired..." ) ) ; this . destroySessionByToken ( session . getToken ( ) ) ; } }
Cleans up expired sessions .
29,868
public < T > void register ( AgentFactory < T > agentFactory ) { agentFactoriesByAgentId . put ( agentFactory . getAgentId ( ) , agentFactory ) ; }
Used for injection of factories that create session - bound agents .
29,869
public static List < String > tagsFromCSV ( String tags ) { ArrayList < String > list = new ArrayList < String > ( ) ; for ( String tag : tags . split ( "," ) ) { list . add ( tag ) ; } return list ; }
Load tags from String with CSV
29,870
public static < T > Iterator < T > getArrayIterator ( T ... array ) { if ( array == null || array . length == 0 ) return getEmptyIterator ( ) ; return new ArrayIterator < T > ( array ) ; }
Create an non - modifiable iterator that iterates over an array . Note that this does NOT make a copy of the array so changes to the passed array may cause issues with iteration .
29,871
public void moveToEnd ( ) throws IOException { int bytes ; while ( remaining > 0 ) { bytes = ( int ) inner . skip ( remaining ) ; if ( bytes < 0 ) { break ; } remaining -= bytes ; } }
Skips over the remainder of the available bytes .
29,872
public static File createPathAndGetFile ( File root , String relativePathToCreate ) { File target = new File ( root , relativePathToCreate ) ; if ( ! target . exists ( ) ) { if ( target . mkdirs ( ) ) { return target ; } else { log . warn ( "No se ha podido crear el directorio:'" + target . getAbsolutePath ( ) + "'" ) ; return null ; } } else { return target ; } }
Crea el directorio y devuelve el objeto File asociado devuelve null si no se ha podido crear
29,873
public static boolean verifyDir ( File dir , Logger logger ) { if ( dir == null ) { logger . error ( "El directorio es nulo." ) ; return false ; } String fileName = dir . getAbsolutePath ( ) ; if ( fileName == null ) { return false ; } if ( ! dir . exists ( ) ) { logger . error ( "El path '" + fileName + "' no existe." ) ; return false ; } if ( ! dir . isDirectory ( ) ) { logger . error ( "El path '" + fileName + "' no es un directorio." ) ; return false ; } if ( ! dir . canRead ( ) ) { logger . error ( "No tenemos permisos de lectura en el path '" + fileName + "'." ) ; return false ; } if ( ! dir . canWrite ( ) ) { logger . error ( "No tenemos permisos de escritura en el path '" + fileName + "'." ) ; return false ; } return true ; }
Verifica que el directorio existe que es un directorio y que tenemos permisos de lectura y escritura . En caso de error devuelve false y escribe un log
29,874
public static boolean copyFile ( File source , File dest ) { try { FileInputStream in = new FileInputStream ( source ) ; FileOutputStream out = new FileOutputStream ( dest ) ; try { FileChannel canalFuente = in . getChannel ( ) ; FileChannel canalDestino = out . getChannel ( ) ; long count = 0 ; long size = canalFuente . size ( ) ; while ( ( count += canalDestino . transferFrom ( canalFuente , count , size - count ) ) < size ) ; } catch ( IOException e ) { log . error ( "copiando ficheros orig:'" + source . getAbsolutePath ( ) + "' destino:'" + dest . getAbsolutePath ( ) + "'" , e ) ; return false ; } finally { IOUtils . closeQuietly ( in ) ; IOUtils . closeQuietly ( out ) ; } } catch ( FileNotFoundException e ) { log . error ( "copiando ficheros orig:'" + source . getAbsolutePath ( ) + "' destino:'" + dest . getAbsolutePath ( ) + "'" , e ) ; return false ; } return true ; }
Copia un archivo a un directorio
29,875
public static boolean moveFilesFromDirectoryToDirectory ( File origDir , File destDir , File baseDir ) { if ( ! origDir . exists ( ) ) { return false ; } if ( ! baseDir . exists ( ) ) { return false ; } if ( ! destDir . exists ( ) ) { destDir . mkdirs ( ) ; } File array [ ] = origDir . listFiles ( ) ; if ( array != null ) { for ( File file : array ) { File destFile = new File ( destDir , file . getName ( ) ) ; if ( file . isDirectory ( ) ) { moveFilesFromDirectoryToDirectory ( file , destFile , baseDir ) ; } else { if ( ! copyFile ( file , destFile ) ) { return false ; } } } } else { return false ; } if ( deleteFilesOfDir ( origDir ) ) { cleanParentDirectories ( origDir , baseDir ) ; return true ; } else { return false ; } }
Mueve los directorios y ficheros de la carpeta origen hasta la carpeta destino . En el path de destino crea los directorios que sean necesarios . Despues borra todos los directorios padre de la carpeta origen hasta la carpeta basDir siempre que estos esten vacios .
29,876
public static boolean copyFilesFromDirectoryToDirectory ( File origDir , File destDir ) { if ( ! origDir . exists ( ) ) { return false ; } if ( ! destDir . exists ( ) ) { destDir . mkdirs ( ) ; } File array [ ] = origDir . listFiles ( ) ; if ( array != null ) { for ( File file : array ) { File destFile = new File ( destDir , file . getName ( ) ) ; if ( file . isDirectory ( ) ) { copyFilesFromDirectoryToDirectory ( file , destFile ) ; } else { if ( ! copyFile ( file , destFile ) ) { return false ; } } } } else { return false ; } return true ; }
Copya los directorios y ficheros de la carpeta origen hasta la carpeta destino . En el path de destino crea los directorios que sean necesarios .
29,877
public static boolean deleteFilesOfDir ( File dir ) { if ( ! dir . exists ( ) || ! dir . isDirectory ( ) ) { log . warn ( "El directorio:'" + dir . getAbsolutePath ( ) + "' no existe o no es un directorio" ) ; return false ; } boolean succed = true ; File listFile [ ] = dir . listFiles ( ) ; for ( File file : listFile ) { if ( ! file . delete ( ) ) { log . warn ( "No se ha podido borrar el fichero:'" + file . getAbsolutePath ( ) + "'" ) ; succed = false ; } } return succed ; }
Borra todos los ficheros contenidos en el directorio . Parra borrar los directorios estos tienen que estar vacios
29,878
public static boolean deleteDirRecursively ( File dir ) { if ( ! dir . exists ( ) || ! dir . isDirectory ( ) ) { log . warn ( "El directorio:'" + dir . getAbsolutePath ( ) + "' no existe o no es un directorio" ) ; return false ; } boolean succed = true ; File listFile [ ] = dir . listFiles ( ) ; for ( File file : listFile ) { if ( file . isDirectory ( ) ) { deleteDirRecursively ( file ) ; } else { if ( ! file . delete ( ) ) { log . warn ( "No se ha podido borrar el fichero:'" + file . getAbsolutePath ( ) + "'" ) ; succed = false ; } } } if ( ! dir . delete ( ) ) { log . warn ( "No se ha podido borrar el fichero:'" + dir . getAbsolutePath ( ) + "'" ) ; succed = false ; } return succed ; }
Borra este directorio y todo lo que haya dentro . Si esto no es un directorio sale .
29,879
public static void deleteChilsDirsIfEmpty ( File dir ) { File childs [ ] = getChildDirs ( dir ) ; for ( File file : childs ) { deleteChilsDirsIfEmpty ( file ) ; if ( ! file . delete ( ) ) { log . info ( "No se ha podido borrar el directorio " + file . getAbsolutePath ( ) ) ; } } }
This delete the child dirs of the current dir only if the child dirs are empty or contains other dirs only
29,880
public static void cleanParentDirectories ( File currentPathFile , File basePathFile ) { if ( currentPathFile == null ) { log . warn ( "El path inicial es nulo" ) ; return ; } if ( basePathFile == null ) { log . warn ( "El path final es nulo" ) ; return ; } try { if ( ! basePathFile . equals ( currentPathFile ) ) { if ( currentPathFile . isDirectory ( ) && currentPathFile . list ( ) . length == 0 ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "Borrando el directorio vacio:'" + currentPathFile . getAbsolutePath ( ) + "'" ) ; } if ( currentPathFile . delete ( ) ) { cleanParentDirectories ( currentPathFile . getParentFile ( ) , basePathFile ) ; } } } } catch ( Exception e ) { log . error ( "Borando los directorios desde :" + currentPathFile . getAbsolutePath ( ) + " hasta:" + basePathFile . getAbsolutePath ( ) + "." ) ; return ; } }
Metodo encargado de limpiar la estructura de directorios temporales . Esta metodo va borrando del currentPathDir hasta el basePathFile siempre que los directorios esten vacios .
29,881
public static boolean esPDF ( File file ) { boolean ret = false ; FileReader reader = null ; try { reader = new FileReader ( file ) ; char [ ] buffer = new char [ 4 ] ; reader . read ( buffer , 0 , 4 ) ; ret = ( "%PDF" . equals ( String . valueOf ( buffer ) ) ) ; } catch ( FileNotFoundException e ) { log . error ( "Error: no se encuentra el fichero " + file . getAbsolutePath ( ) ) ; } catch ( IOException e ) { log . error ( "Error leyendo el fichero " + file . getAbsolutePath ( ) ) ; } finally { try { reader . close ( ) ; } catch ( IOException e ) { log . error ( "Error cerrando el fichero " + file . getAbsolutePath ( ) ) ; } } return ret ; }
Nos dice si un fichero es un PDF
29,882
public static boolean iterateOnChildDirs ( File parentDir , FileIterator iterator ) { if ( parentDir == null ) { log . warn ( "Parent dir is null" ) ; return true ; } String message = verifyReadDir ( parentDir ) ; if ( message != null ) { log . warn ( message ) ; return true ; } File childs [ ] = parentDir . listFiles ( DIR_FILTER ) ; if ( childs == null ) { log . info ( "Parent dir:" + parentDir . getAbsolutePath ( ) + " do not have child dirs" ) ; return true ; } else { for ( File child : childs ) { boolean iteratorRet = iterator . iterate ( child ) ; if ( iteratorRet == false ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "Iterator returns false. Iteration on:" + parentDir . getAbsolutePath ( ) + " stopped." ) ; } return false ; } } return true ; } }
Iterate only on the childs of the parent folder Iterates on the folder pased on parameter only if the content can be readed . Return false if the iterator returns false on a file .
29,883
public static String getExtension ( String fileName ) { if ( fileName == null ) { return null ; } else { int number = fileName . lastIndexOf ( '.' ) ; if ( number >= 0 ) { return fileName . substring ( number + 1 , fileName . length ( ) ) ; } else { return null ; } } }
If the file is like name . extension This function returns extension for filename = name . this returns for filemane = name this retuns null ; for filemane = . extension this retuns extension ; for filemane = . this retuns ;
29,884
public static String getFileNameWithoutExtenxion ( String fileName ) { if ( fileName == null ) { return null ; } else { int number = fileName . lastIndexOf ( '.' ) ; if ( number >= 0 ) { return fileName . substring ( 0 , number ) ; } else { return fileName ; } } }
If the file is like name . extension This function returns name for filename = name . this returns name for filemane = name this retuns name ; for filemane = . extension this retuns ; for filemane = . this retuns ;
29,885
private static IRating createRatingFromActivity ( JSONObject verb ) throws JSONException { Rating rating = new Rating ( ) ; JSONObject measure = verb . getJSONObject ( "measure" ) ; if ( measure == null ) return null ; rating . setMin ( measure . getInt ( "scaleMin" ) ) ; rating . setMax ( measure . getInt ( "scaleMax" ) ) ; rating . setRating ( measure . getInt ( "value" ) ) ; return rating ; }
Create a rating object
29,886
private static IRatings createRatingsFromActivity ( JSONObject verb ) throws JSONException { Ratings ratings = new Ratings ( ) ; JSONObject measure = verb . getJSONObject ( "measure" ) ; if ( measure == null ) return null ; ratings . setMin ( measure . getInt ( "scaleMin" ) ) ; ratings . setMax ( measure . getInt ( "scaleMax" ) ) ; ratings . setAverage ( measure . getDouble ( "value" ) ) ; ratings . setSample ( measure . getInt ( "sampleSize" ) ) ; return ratings ; }
Create a composite ratings object
29,887
private static IReview createReviewFromActivity ( JSONObject activity ) throws JSONException { Review review = new Review ( ) ; review . setComment ( activity . getString ( "content" ) ) ; return review ; }
Create a review object
29,888
private synchronized boolean isUsed ( final T candidate ) { LOG . debug ( "Checking if used: " + candidate ) ; LOG . debug ( "Used? " + m_usedServerIds . contains ( candidate ) ) ; return ( m_usedServerIds . contains ( candidate ) ) ; }
Returns whether a given server is already in use .
29,889
private Optional < T > getServerIdToTry ( ) { if ( m_serverIdsToTry . isEmpty ( ) ) { final Collection < T > moreCandidates = getMoreCandidates ( ) ; if ( moreCandidates . isEmpty ( ) ) { m_sleepBeforeTryingToGetMoreCandidates = true ; return ( new NoneImpl < T > ( ) ) ; } else { m_sleepBeforeTryingToGetMoreCandidates = false ; m_serverIdsToTry . addAll ( moreCandidates ) ; return ( new SomeImpl < T > ( m_serverIdsToTry . remove ( 0 ) ) ) ; } } else { return ( new SomeImpl < T > ( m_serverIdsToTry . remove ( 0 ) ) ) ; } }
Returns a server identifier to try .
29,890
private Collection < T > getMoreCandidates ( ) { final Predicate < T > unusedPredicate = new UnusedServer ( ) ; final Collection < T > servers = new LinkedList < T > ( ) ; int tries = 0 ; while ( servers . isEmpty ( ) && ( tries < 3 ) ) { LOG . debug ( "Trying to find candidate servers" ) ; if ( m_sleepBeforeTryingToGetMoreCandidates ) { LOG . debug ( "Long sleep..." ) ; ThreadUtils . safeSleep ( 60000 ) ; } else if ( ! m_firstRun ) { LOG . debug ( "Short sleep..." ) ; ThreadUtils . safeSleep ( 10000 ) ; } m_firstRun = false ; final Collection < T > candidates = m_candidateProvider . getCandidates ( ) ; LOG . debug ( "Found candidates..." ) ; final Collection < T > unusedCandidates = m_collectionUtils . select ( candidates , unusedPredicate ) ; servers . addAll ( unusedCandidates ) ; ++ tries ; } LOG . debug ( "Found this many candidate servers: " + servers . size ( ) ) ; return servers ; }
Returns a collection of more candidates that can be tried for connections .
29,891
private void establish ( final T serverId ) { LOG . debug ( "Connecting to: " + serverId ) ; final ConnectionMaintainerListener < ServerT > listener = new MyListener ( serverId ) ; synchronized ( this ) { ++ m_outstanding ; m_usedServerIds . add ( serverId ) ; } m_establisher . establish ( serverId , listener ) ; }
Establishes a connection to a given server making sure to update all of the bookkeeping associated with doing so .
29,892
private void tryConnecting ( ) { LOG . debug ( "Trying to connect" ) ; final Optional < T > optionalServerIdToTry = getServerIdToTry ( ) ; final OptionalVisitor < Void , T > serverToTryVisitor = new OptionalVisitor < Void , T > ( ) { public Void visitNone ( final None < T > none ) { LOG . debug ( "No connections to try..." ) ; return null ; } public Void visitSome ( final Some < T > some ) { LOG . debug ( "Establishing connection..." ) ; establish ( some . object ( ) ) ; return null ; } } ; optionalServerIdToTry . accept ( serverToTryVisitor ) ; }
Tries connecting to a server . This method is called when we need to try to establish a connection to a server .
29,893
public static Either < String , String > getBuildVersion ( ) { Class clazz = BuildNumberCommand . class ; String className = clazz . getSimpleName ( ) + ".class" ; String classPath = clazz . getResource ( className ) . toString ( ) ; if ( ! classPath . startsWith ( "jar" ) ) { return Either . right ( "Cannot determine build version when not running from JAR." ) ; } String manifestPath = classPath . substring ( 0 , classPath . lastIndexOf ( '!' ) + 1 ) + "/META-INF/MANIFEST.MF" ; try { Manifest manifest = new Manifest ( new URL ( manifestPath ) . openStream ( ) ) ; String build = manifest . getMainAttributes ( ) . getValue ( BUILD_VERSION ) ; if ( build == null ) { return Either . right ( String . format ( "Cannot determine build version when %s missing from JAR manifest %s" , BUILD_VERSION , MANIFEST ) ) ; } else { return Either . left ( build ) ; } } catch ( IOException e ) { return Either . right ( String . format ( "Cannot access %s: %s" , manifestPath , e ) ) ; } }
Return build number as indicated by git SHA embedded in JAR MANIFEST . MF
29,894
public String getDocUrl ( String className ) { if ( ! cache . containsKey ( className ) ) { String url = resolveDocByClass ( className ) ; if ( url == null ) { url = resolveDocByPackage ( className ) ; } cache . put ( className , url ) ; } return cache . get ( className ) ; }
Returns a HTTP URL for a class .
29,895
private String resolveDocByClass ( String className ) { String urlBase = doc . getProperty ( className ) ; if ( urlBase != null ) { return urlBase + className . replace ( "." , "/" ) + ".html" ; } return null ; }
Return JavaDoc URL for class .
29,896
private String resolveDocByPackage ( String className ) { int index = className . lastIndexOf ( "." ) ; String packageName = className ; while ( index > 0 ) { packageName = packageName . substring ( 0 , index ) ; String urlBase = doc . getProperty ( packageName ) ; if ( urlBase != null ) { return urlBase + className . replace ( "." , "/" ) + ".html" ; } index = packageName . lastIndexOf ( "." ) ; } return null ; }
Return JavaDoc URL for package . Check package names recursively per dot starting with the most specific package .
29,897
public static Set < Field > getInstanceFields ( Class < ? > clazz , Filter < Field > filter ) { return getFields ( clazz , new And < Field > ( filter != null ? filter : new True < Field > ( ) , new Not < Field > ( new IsStatic < Field > ( ) ) , new Not < Field > ( new IsOverridden < Field > ( ) ) ) ) ; }
Returns the filtered set of instance fields of the given class including those inherited from the super - classes .
29,898
public static Set < Method > getInstanceMethods ( Class < ? > clazz , Filter < Method > filter ) { return getMethods ( clazz , new And < Method > ( filter != null ? filter : new True < Method > ( ) , new Not < Method > ( new IsStatic < Method > ( ) ) , new Not < Method > ( new IsOverridden < Method > ( ) ) ) ) ; }
Returns the filtered set of instance methods of the given class including those inherited from the super - classes .
29,899
public static Set < Field > getFields ( Class < ? > clazz , Filter < Field > filter ) { Set < Field > fields = new HashSet < Field > ( ) ; Class < ? > cursor = clazz ; while ( cursor != null && cursor != Object . class ) { fields . addAll ( Filter . apply ( filter , cursor . getDeclaredFields ( ) ) ) ; cursor = cursor . getSuperclass ( ) ; } return fields ; }
Returns the filtered set of fields of the given class including those inherited from the super - classes ; if provided complex filter criteria can be applied .