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 (... | 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 . apach... | 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 ) ; PhynixxXADataRecorde... | 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 . currentStr... | 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 ) ... | 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 ( ) ; cac... | 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 ( ) ... | 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 .... | 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 < Mo... | 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 ( Fil... | 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 ( el... | 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 . ... | 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 . g... | 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 . setSortComp... | 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 ( ) ) ; } fi... | 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 . newDocumentBuil... | 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 (... | 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... | 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 ( "[;,]" ) )... | 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 ( ) ; Prope... | 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 = ds... | 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 = _findAcce... | 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 = _findAcce... | 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 ++ ;... | 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_... | 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 , builde... | 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 == ... | 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 repla... | 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 . g... | 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 ... | 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 ( sessio... | 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 ( ) + "'" ) ... | 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."... | 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... | 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 != nul... | 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 ( des... | 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 ... | 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 : listF... | 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 ... | 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 ( "Err... | 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 ... | 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"... | 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 ( "sc... | 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 ... | 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_sleepBeforeTryingToGe... | 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... | 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 ... | 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 . ... | 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 ... | 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 . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.