idx int64 0 165k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
133,300 | private static ArrayList < FrequencyTableEntry > hashToFreqEntries ( HashMap < String , ArrayList < Integer > > hash ) { ArrayList < FrequencyTableEntry > res = new ArrayList < FrequencyTableEntry > ( ) ; for ( Entry < String , ArrayList < Integer > > e : hash . entrySet ( ) ) { char [ ] payload = e . getKey ( ) . toCh... | Translates the hash table into sortable array of substrings . |
133,301 | private static double distance ( double [ ] subseries , double [ ] series , int from , int to , double nThreshold ) throws Exception { double [ ] subsequence = tp . znorm ( tp . subseriesByCopy ( series , from , to ) , nThreshold ) ; Double sum = 0D ; for ( int i = 0 ; i < subseries . length ; i ++ ) { double tmp = sub... | Calculates the Euclidean distance between two points . Don t use this unless you need that . |
133,302 | public void addShingledSeries ( String key , Map < String , Integer > shingledSeries ) { int [ ] counts = new int [ this . indexTable . size ( ) ] ; for ( String str : shingledSeries . keySet ( ) ) { Integer idx = this . indexTable . get ( str ) ; if ( null == idx ) { throw new IndexOutOfBoundsException ( "the requeste... | Adds a shingled series assuring the proper index . |
133,303 | public static void main ( String [ ] args ) throws Exception { NormalAlphabet na = new NormalAlphabet ( ) ; SAXProcessor sp = new SAXProcessor ( ) ; String dataFileName = args [ 0 ] ; System . out . println ( "data file: " + dataFileName ) ; double [ ] ts = TSProcessor . readFileColumn ( dataFileName , 0 , 0 ) ; System... | Runs the evaluation . |
133,304 | public void markVisited ( int loc ) { if ( checkBounds ( loc ) ) { if ( ZERO == this . registry [ loc ] ) { this . unvisitedCount -- ; } this . registry [ loc ] = ONE ; } else { throw new RuntimeException ( "The location " + loc + " out of bounds [0," + ( this . registry . length - 1 ) + "]" ) ; } } | Marks location visited . If it was unvisited counter decremented . |
133,305 | public void markVisited ( int from , int upTo ) { if ( checkBounds ( from ) && checkBounds ( upTo - 1 ) ) { for ( int i = from ; i < upTo ; i ++ ) { this . markVisited ( i ) ; } } else { throw new RuntimeException ( "The location " + from + "," + upTo + " out of bounds [0," + ( this . registry . length - 1 ) + "]" ) ; ... | Marks as visited a range of locations . |
133,306 | public int getNextRandomUnvisitedPosition ( ) { if ( 0 == this . unvisitedCount ) { return - 1 ; } int i = this . randomizer . nextInt ( this . registry . length ) ; while ( ONE == registry [ i ] ) { i = this . randomizer . nextInt ( this . registry . length ) ; } return i ; } | Get the next random unvisited position . |
133,307 | public boolean isNotVisited ( int loc ) { if ( checkBounds ( loc ) ) { return ( ZERO == this . registry [ loc ] ) ; } else { throw new RuntimeException ( "The location " + loc + " out of bounds [0," + ( this . registry . length - 1 ) + "]" ) ; } } | Check if position is not visited . |
133,308 | public boolean isVisited ( int from , int upTo ) { if ( checkBounds ( from ) && checkBounds ( upTo - 1 ) ) { for ( int i = from ; i < upTo ; i ++ ) { if ( ONE == this . registry [ i ] ) { return true ; } } return false ; } else { throw new RuntimeException ( "The location " + from + "," + upTo + " out of bounds [0," + ... | Check if the interval and its boundaries were visited . |
133,309 | public boolean isVisited ( int loc ) { if ( checkBounds ( loc ) ) { return ( ONE == this . registry [ loc ] ) ; } else { throw new RuntimeException ( "The location " + loc + " out of bounds [0," + ( this . registry . length - 1 ) + "]" ) ; } } | Check if the location specified is visited . |
133,310 | public ArrayList < Integer > getUnvisited ( ) { if ( 0 == this . unvisitedCount ) { return new ArrayList < Integer > ( ) ; } ArrayList < Integer > res = new ArrayList < Integer > ( this . unvisitedCount ) ; for ( int i = 0 ; i < this . registry . length ; i ++ ) { if ( ZERO == this . registry [ i ] ) { res . add ( i ) ... | Get the list of unvisited positions . |
133,311 | public ArrayList < Integer > getVisited ( ) { if ( 0 == ( this . registry . length - this . unvisitedCount ) ) { return new ArrayList < Integer > ( ) ; } ArrayList < Integer > res = new ArrayList < Integer > ( this . registry . length - this . unvisitedCount ) ; for ( int i = 0 ; i < this . registry . length ; i ++ ) {... | Get the list of visited positions . Returns NULL if none are visited . |
133,312 | public static Map < String , List < double [ ] > > readUCRData ( String fileName ) throws IOException , NumberFormatException { Map < String , List < double [ ] > > res = new HashMap < String , List < double [ ] > > ( ) ; BufferedReader br = new BufferedReader ( new FileReader ( new File ( fileName ) ) ) ; String line ... | Reads bunch of series from file . First column treats as a class label . Rest as a real - valued series . |
133,313 | public static String datasetStats ( Map < String , List < double [ ] > > data , String name ) { int globalMinLength = Integer . MAX_VALUE ; int globalMaxLength = Integer . MIN_VALUE ; double globalMinValue = Double . MAX_VALUE ; double globalMaxValue = Double . MIN_VALUE ; for ( Entry < String , List < double [ ] > > e... | Prints the dataset statistics . |
133,314 | public static void saveData ( Map < String , List < double [ ] > > data , File file ) throws IOException { BufferedWriter bw = new BufferedWriter ( new FileWriter ( file ) ) ; for ( Entry < String , List < double [ ] > > classEntry : data . entrySet ( ) ) { String classLabel = classEntry . getKey ( ) ; for ( double [ ]... | Saves the dataset . |
133,315 | public double [ ] readTS ( String dataFileName , int loadLimit ) throws SAXException , IOException { Path path = Paths . get ( dataFileName ) ; if ( ! ( Files . exists ( path ) ) ) { throw new SAXException ( "unable to load data - data source not found." ) ; } BufferedReader reader = Files . newBufferedReader ( path , ... | Read at least N elements from the one - column file . |
133,316 | public double max ( double [ ] series ) { double max = Double . MIN_VALUE ; for ( int i = 0 ; i < series . length ; i ++ ) { if ( max < series [ i ] ) { max = series [ i ] ; } } return max ; } | Finds the maximal value in timeseries . |
133,317 | public double min ( double [ ] series ) { double min = Double . MAX_VALUE ; for ( int i = 0 ; i < series . length ; i ++ ) { if ( min > series [ i ] ) { min = series [ i ] ; } } return min ; } | Finds the minimal value in timeseries . |
133,318 | public double mean ( double [ ] series ) { double res = 0D ; int count = 0 ; for ( double tp : series ) { res += tp ; count += 1 ; } if ( count > 0 ) { return res / ( ( Integer ) count ) . doubleValue ( ) ; } return Double . NaN ; } | Computes the mean value of timeseries . |
133,319 | public double median ( double [ ] series ) { double [ ] clonedSeries = series . clone ( ) ; Arrays . sort ( clonedSeries ) ; double median ; if ( clonedSeries . length % 2 == 0 ) { median = ( clonedSeries [ clonedSeries . length / 2 ] + ( double ) clonedSeries [ clonedSeries . length / 2 - 1 ] ) / 2 ; } else { median =... | Computes the median value of timeseries . |
133,320 | public double stDev ( double [ ] series ) { double num0 = 0D ; double sum = 0D ; int count = 0 ; for ( double tp : series ) { num0 = num0 + tp * tp ; sum = sum + tp ; count += 1 ; } double len = ( ( Integer ) count ) . doubleValue ( ) ; return Math . sqrt ( ( len * num0 - sum * sum ) / ( len * ( len - 1 ) ) ) ; } | Speed - optimized implementation . |
133,321 | public double [ ] znorm ( double [ ] series , double normalizationThreshold ) { double [ ] res = new double [ series . length ] ; double sd = stDev ( series ) ; if ( sd < normalizationThreshold ) { return res ; } double mean = mean ( series ) ; for ( int i = 0 ; i < res . length ; i ++ ) { res [ i ] = ( series [ i ] - ... | Z - Normalize routine . |
133,322 | public char [ ] ts2String ( double [ ] vals , double [ ] cuts ) { char [ ] res = new char [ vals . length ] ; for ( int i = 0 ; i < vals . length ; i ++ ) { res [ i ] = num2char ( vals [ i ] , cuts ) ; } return res ; } | Converts the timeseries into string using given cuts intervals . Useful for not - normal distribution cuts . |
133,323 | public int [ ] ts2Index ( double [ ] series , double [ ] cuts ) throws Exception { int [ ] res = new int [ series . length ] ; for ( int i = 0 ; i < series . length ; i ++ ) { res [ i ] = num2index ( series [ i ] , cuts ) ; } return res ; } | Convert the timeseries into the index using SAX cuts . |
133,324 | public char num2char ( double value , double [ ] cuts ) { int idx = 0 ; if ( value >= 0 ) { idx = cuts . length ; while ( ( idx > 0 ) && ( cuts [ idx - 1 ] > value ) ) { idx -- ; } } else { while ( ( idx < cuts . length ) && ( cuts [ idx ] <= value ) ) { idx ++ ; } } return ALPHABET [ idx ] ; } | Get mapping of a number to char . |
133,325 | public int num2index ( double value , double [ ] cuts ) { int count = 0 ; while ( ( count < cuts . length ) && ( cuts [ count ] <= value ) ) { count ++ ; } return count ; } | Get mapping of number to cut index . |
133,326 | public double [ ] subseriesByCopy ( double [ ] series , int start , int end ) throws IndexOutOfBoundsException { if ( ( start > end ) || ( start < 0 ) || ( end > series . length ) ) { throw new IndexOutOfBoundsException ( "Unable to extract subseries, series length: " + series . length + ", start: " + start + ", end: "... | Extract subseries out of series . |
133,327 | public String seriesToString ( double [ ] series , NumberFormat df ) { StringBuffer sb = new StringBuffer ( ) ; sb . append ( '[' ) ; for ( double d : series ) { sb . append ( df . format ( d ) ) . append ( ',' ) ; } sb . delete ( sb . length ( ) - 2 , sb . length ( ) - 1 ) . append ( "]" ) ; return sb . toString ( ) ;... | Prettyfies the timeseries for screen output . |
133,328 | public double [ ] normOne ( double [ ] data ) { double [ ] res = new double [ data . length ] ; double max = max ( data ) ; for ( int i = 0 ; i < data . length ; i ++ ) { res [ i ] = data [ i ] / max ; } return res ; } | Normalizes data in interval 0 - 1 . |
133,329 | public List < DiscordRecord > getTopHits ( Integer num ) { if ( num >= this . discords . size ( ) ) { return this . discords ; } List < DiscordRecord > res = this . discords . subList ( this . discords . size ( ) - num , this . discords . size ( ) ) ; return res ; } | Returns the number of the top hits . |
133,330 | public void setZValues ( double [ ] [ ] zValues , double low , double high ) { this . zValues = zValues ; this . lowValue = low ; this . highValue = high ; } | Replaces the z - values array . The number of elements should match the number of y - values with each element containing a double array with an equal number of elements that matches the number of x - values . Use this method where the minimum and maximum values possible are not contained within the dataset . |
133,331 | public void setBackgroundColour ( Color backgroundColour ) { if ( backgroundColour == null ) { backgroundColour = Color . WHITE ; } this . backgroundColour = backgroundColour ; } | Sets the colour to be used on the background of the chart . A transparent background can be set by setting a background colour with an alpha value . The transparency will only be effective when the image is saved as a png or gif . |
133,332 | public static double max ( double [ ] [ ] values ) { double max = 0 ; for ( int i = 0 ; i < values . length ; i ++ ) { for ( int j = 0 ; j < values [ i ] . length ; j ++ ) { max = ( values [ i ] [ j ] > max ) ? values [ i ] [ j ] : max ; } } return max ; } | Finds and returns the maximum value in a 2 - dimensional array of doubles . |
133,333 | public static double min ( double [ ] [ ] values ) { double min = Double . MAX_VALUE ; for ( int i = 0 ; i < values . length ; i ++ ) { for ( int j = 0 ; j < values [ i ] . length ; j ++ ) { min = ( values [ i ] [ j ] < min ) ? values [ i ] [ j ] : min ; } } return min ; } | Finds and returns the minimum value in a 2 - dimensional array of doubles . |
133,334 | public int compareTo ( DiscordRecord other ) { if ( null == other ) { throw new NullPointerException ( "Unable compare to null!" ) ; } return Double . compare ( other . getNNDistance ( ) , this . nnDistance ) ; } | The simple comparator based on the distance . Note that discord is better if the NN distance is greater . |
133,335 | public static double gaussian ( ) { double r , x , y ; do { x = uniform ( - 1.0 , 1.0 ) ; y = uniform ( - 1.0 , 1.0 ) ; r = x * x + y * y ; } while ( r >= 1 || r == 0 ) ; return x * Math . sqrt ( - 2 * Math . log ( r ) / r ) ; } | Returns a real number with a standard Gaussian distribution . |
133,336 | public static void shuffle ( double [ ] a ) { int N = a . length ; for ( int i = 0 ; i < N ; i ++ ) { int r = i + uniform ( N - i ) ; double temp = a [ i ] ; a [ i ] = a [ r ] ; a [ r ] = temp ; } } | Rearrange the elements of a double array in random order . |
133,337 | public void dropByIndex ( int idx ) { SAXRecord entry = realTSindex . get ( idx ) ; if ( null != entry ) { realTSindex . remove ( idx ) ; entry . removeIndex ( idx ) ; if ( entry . getIndexes ( ) . isEmpty ( ) ) { records . remove ( String . valueOf ( entry . getPayload ( ) ) ) ; } } } | Drops a single entry . |
133,338 | public void add ( char [ ] str , int idx ) { SAXRecord rr = records . get ( String . valueOf ( str ) ) ; if ( null == rr ) { rr = new SAXRecord ( str , idx ) ; this . records . put ( String . valueOf ( str ) , rr ) ; } else { rr . addIndex ( idx ) ; } this . realTSindex . put ( idx , rr ) ; } | Adds a single string and index entry by creating a SAXRecord . |
133,339 | public void addAll ( SAXRecords records ) { for ( SAXRecord record : records ) { char [ ] payload = record . getPayload ( ) ; for ( Integer i : record . getIndexes ( ) ) { this . add ( payload , i ) ; } } } | Adds all entries from the collection . |
133,340 | public void addAll ( HashMap < Integer , char [ ] > records ) { for ( Entry < Integer , char [ ] > e : records . entrySet ( ) ) { this . add ( e . getValue ( ) , e . getKey ( ) ) ; } } | This adds all to the internal store . Used by the parallel SAX conversion engine . |
133,341 | public String getSAXString ( String separatorToken ) { StringBuffer sb = new StringBuffer ( ) ; ArrayList < Integer > index = new ArrayList < Integer > ( ) ; index . addAll ( this . realTSindex . keySet ( ) ) ; Collections . sort ( index , new Comparator < Integer > ( ) { public int compare ( Integer int1 , Integer int... | Get the SAX string of this whole collection . |
133,342 | public ArrayList < Integer > getAllIndices ( ) { ArrayList < Integer > res = new ArrayList < Integer > ( this . realTSindex . size ( ) ) ; res . addAll ( this . realTSindex . keySet ( ) ) ; Collections . sort ( res ) ; return res ; } | Get all indexes sorted . |
133,343 | public void buildIndex ( ) { this . stringPosToRealPos = new HashMap < Integer , Integer > ( ) ; int counter = 0 ; for ( Integer idx : getAllIndices ( ) ) { this . stringPosToRealPos . put ( counter , idx ) ; counter ++ ; } } | This builds an index that aids in mapping of a SAX word to the real timeseries index . |
133,344 | public void excludePositions ( ArrayList < Integer > positions ) { for ( Integer p : positions ) { if ( realTSindex . containsKey ( p ) ) { SAXRecord rec = realTSindex . get ( p ) ; rec . removeIndex ( p ) ; if ( rec . getIndexes ( ) . isEmpty ( ) ) { this . records . remove ( String . valueOf ( rec . getPayload ( ) ) ... | Removes saxRecord occurrences that correspond to these positions . |
133,345 | public ArrayList < SAXRecord > getSimpleMotifs ( int num ) { ArrayList < SAXRecord > res = new ArrayList < SAXRecord > ( num ) ; DoublyLinkedSortedList < Entry < String , SAXRecord > > list = new DoublyLinkedSortedList < Entry < String , SAXRecord > > ( num , new Comparator < Entry < String , SAXRecord > > ( ) { public... | Get motifs . |
133,346 | public void cancel ( ) { try { executorService . shutdown ( ) ; if ( ! executorService . awaitTermination ( 30 , TimeUnit . MINUTES ) ) { executorService . shutdownNow ( ) ; if ( ! executorService . awaitTermination ( 30 , TimeUnit . MINUTES ) ) { LOGGER . error ( "Pool did not terminate... FATAL ERROR" ) ; throw new R... | Cancels the execution . |
133,347 | public static void main ( String [ ] args ) throws Exception { SAXProcessor sp = new SAXProcessor ( ) ; double [ ] dat = TSProcessor . readFileColumn ( DAT_FNAME , 1 , 0 ) ; LOGGER . info ( "read {} points from {}" , dat . length , DAT_FNAME ) ; String str = "win_width: " + cPoint + "; SAX: W " + SAX_WINDOW_SIZE + ", P... | - pix_fmt yuv420p daimler_man . mp4 |
133,348 | private static double [ ] toDoubleAray ( Integer [ ] intArray , HashSet < Integer > skipIndex ) { double [ ] res = new double [ intArray . length - skipIndex . size ( ) ] ; int skip = 0 ; for ( int i = 0 ; i < intArray . length ; i ++ ) { if ( skipIndex . contains ( i ) ) { skip ++ ; continue ; } res [ i - skip ] = int... | Converts an array into array of doubles skipping specified indeces . |
133,349 | public VirtualFile getFile ( VirtualFile mountPoint , VirtualFile target ) { final String path = target . getPathNameRelativeTo ( mountPoint ) ; return rootNode . getFile ( new Path ( path ) , mountPoint ) ; } | Get the VirtualFile from the assembly . This will traverse VirtualFiles in assembly to find children if needed . |
133,350 | public List < String > getChildNames ( VirtualFile mountPoint , VirtualFile target ) { List < String > names = new LinkedList < String > ( ) ; AssemblyNode targetNode = null ; if ( mountPoint . equals ( target ) ) { targetNode = rootNode ; } else { targetNode = rootNode . find ( target . getPathNameRelativeTo ( mountPo... | Returns a list of all the names of the children in the assembly . |
133,351 | public File createFile ( String relativePath , InputStream sourceData ) throws IOException { final File tempFile = getFile ( relativePath ) ; boolean ok = false ; try { final FileOutputStream fos = new FileOutputStream ( tempFile ) ; try { VFSUtils . copyStream ( sourceData , fos ) ; fos . close ( ) ; sourceData . clos... | Create a file within this temporary directory prepopulating the file from the given input stream . |
133,352 | private static void init ( ) { String pkgs = System . getProperty ( "java.protocol.handler.pkgs" ) ; if ( pkgs == null || pkgs . trim ( ) . length ( ) == 0 ) { pkgs = "org.jboss.net.protocol|org.jboss.vfs.protocol" ; System . setProperty ( "java.protocol.handler.pkgs" , pkgs ) ; } else if ( pkgs . contains ( "org.jboss... | Initialize VFS protocol handlers package property . |
133,353 | public static Closeable mount ( VirtualFile mountPoint , FileSystem fileSystem ) throws IOException { final VirtualFile parent = mountPoint . getParent ( ) ; if ( parent == null ) { throw VFSMessages . MESSAGES . rootFileSystemAlreadyMounted ( ) ; } final String name = mountPoint . getName ( ) ; final Mount mount = new... | Mount a filesystem on a mount point in the VFS . The mount point is any valid file name existent or non - existent . If a relative path is given it will be treated as relative to the VFS root . |
133,354 | protected static void visit ( VirtualFile file , VirtualFileVisitor visitor ) throws IOException { if ( file == null ) { throw VFSMessages . MESSAGES . nullArgument ( "file" ) ; } visitor . visit ( file ) ; } | Visit the virtual file system |
133,355 | static Set < String > getSubmounts ( VirtualFile virtualFile ) { final ConcurrentMap < VirtualFile , Map < String , Mount > > mounts = VFS . mounts ; final Map < String , Mount > mountMap = mounts . get ( virtualFile ) ; if ( mountMap == null ) { return emptyRemovableSet ( ) ; } return new HashSet < String > ( mountMap... | Get all immediate submounts for a path . |
133,356 | public static Closeable mountReal ( File realRoot , VirtualFile mountPoint ) throws IOException { return doMount ( new RealFileSystem ( realRoot ) , mountPoint ) ; } | Create and mount a real file system returning a single handle which will unmount and close the filesystem when closed . |
133,357 | public static Closeable mountTemp ( VirtualFile mountPoint , TempFileProvider tempFileProvider ) throws IOException { boolean ok = false ; final TempDir tempDir = tempFileProvider . createTempDir ( "tmpfs" ) ; try { final MountHandle handle = doMount ( new RealFileSystem ( tempDir . getRoot ( ) ) , mountPoint , tempDir... | Create and mount a temporary file system returning a single handle which will unmount and close the filesystem when closed . |
133,358 | public static Closeable mountZipExpanded ( File zipFile , VirtualFile mountPoint , TempFileProvider tempFileProvider ) throws IOException { boolean ok = false ; final TempDir tempDir = tempFileProvider . createTempDir ( zipFile . getName ( ) ) ; try { final File rootFile = tempDir . getRoot ( ) ; VFSUtils . unzip ( zip... | Create and mount an expanded zip file in a temporary file system returning a single handle which will unmount and close the filesystem when closed . |
133,359 | public static Closeable mountZipExpanded ( InputStream zipData , String zipName , VirtualFile mountPoint , TempFileProvider tempFileProvider ) throws IOException { try { boolean ok = false ; final TempDir tempDir = tempFileProvider . createTempDir ( zipName ) ; try { final File zipFile = File . createTempFile ( zipName... | Create and mount an expanded zip file in a temporary file system returning a single handle which will unmount and close the filesystem when closed . The given zip data stream is closed . |
133,360 | public static Closeable mountAssembly ( VirtualFileAssembly assembly , VirtualFile mountPoint ) throws IOException { return doMount ( new AssemblyFileSystem ( assembly ) , mountPoint ) ; } | Create and mount an assembly file system returning a single handle which will unmount and close the filesystem when closed . |
133,361 | private void closeCurrent ( ) throws IOException { virtualJarInputStream . closeEntry ( ) ; currentEntry . crc = crc . getValue ( ) ; crc . reset ( ) ; } | Close the current entry and calculate the crc value . |
133,362 | private boolean bufferLocalFileHeader ( ) throws IOException { buffer . reset ( ) ; JarEntry jarEntry = virtualJarInputStream . getNextJarEntry ( ) ; if ( jarEntry == null ) { return false ; } currentEntry = new ProcessedEntry ( jarEntry , totalRead ) ; processedEntries . add ( currentEntry ) ; bufferInt ( ZipEntry . L... | Buffer the content of the local file header for a single entry . |
133,363 | private boolean bufferNextCentralFileHeader ( ) throws IOException { buffer . reset ( ) ; if ( currentCentralEntryIdx == processedEntries . size ( ) ) { return false ; } ProcessedEntry entry = processedEntries . get ( currentCentralEntryIdx ++ ) ; JarEntry jarEntry = entry . jarEntry ; bufferInt ( ZipEntry . CENSIG ) ;... | Buffer the central file header record for a single entry . |
133,364 | private void bufferCentralDirectoryEnd ( ) throws IOException { buffer . reset ( ) ; long lengthOfCentral = totalRead - centralOffset ; int count = processedEntries . size ( ) ; bufferInt ( JarEntry . ENDSIG ) ; bufferShort ( 0 ) ; bufferShort ( 0 ) ; bufferShort ( count ) ; bufferShort ( count ) ; bufferInt ( lengthOf... | Write the central file header records . This is repeated until all entries have been added to the central file header . |
133,365 | private void bufferInt ( long i ) { buffer ( ( byte ) ( i & 0xff ) ) ; buffer ( ( byte ) ( ( i >>> 8 ) & 0xff ) ) ; buffer ( ( byte ) ( ( i >>> 16 ) & 0xff ) ) ; buffer ( ( byte ) ( ( i >>> 24 ) & 0xff ) ) ; } | Buffer a 32 - bit integer in little - endian |
133,366 | private void buffer ( byte b ) { if ( buffer . hasCapacity ( ) ) { buffer . put ( b ) ; } else { throw VFSMessages . MESSAGES . bufferDoesntHaveEnoughCapacity ( ) ; } } | Buffer a single byte |
133,367 | String getPathName ( boolean url ) { if ( pathName == null || pathName . isEmpty ( ) ) { VirtualFile [ ] path = getParentFiles ( ) ; final StringBuilder builder = new StringBuilder ( path . length * 30 + 50 ) ; for ( int i = path . length - 1 ; i > - 1 ; i -- ) { final VirtualFile parent = path [ i ] . parent ; if ( pa... | Get the absolute VFS full path name . If this is a URL then directory entries will have a trailing slash . |
133,368 | public long getLastModified ( ) { final SecurityManager sm = System . getSecurityManager ( ) ; if ( sm != null ) { sm . checkPermission ( new VirtualFilePermission ( getPathName ( ) , "read" ) ) ; } final VFS . Mount mount = VFS . getMount ( this ) ; if ( sm != null ) { return AccessController . doPrivileged ( ( Privil... | When the file was last modified |
133,369 | public InputStream openStream ( ) throws IOException { final SecurityManager sm = System . getSecurityManager ( ) ; if ( sm != null ) { sm . checkPermission ( new VirtualFilePermission ( getPathName ( ) , "read" ) ) ; } if ( isDirectory ( ) ) { return new VirtualJarInputStream ( this ) ; } final VFS . Mount mount = VFS... | Access the file contents . |
133,370 | public File getPhysicalFile ( ) throws IOException { final SecurityManager sm = System . getSecurityManager ( ) ; if ( sm != null ) { sm . checkPermission ( new VirtualFilePermission ( getPathName ( ) , "getfile" ) ) ; } final VFS . Mount mount = VFS . getMount ( this ) ; if ( sm != null ) { return doIoPrivileged ( ( )... | Get a physical file for this virtual file . Depending on the underlying file system type this may simply return an already - existing file ; it may create a copy of a file ; or it may reuse a preexisting copy of the file . Furthermore the returned file may or may not have any relationship to other files from the same o... |
133,371 | public List < VirtualFile > getChildren ( ) { if ( ! isDirectory ( ) ) { return Collections . emptyList ( ) ; } final VFS . Mount mount = VFS . getMount ( this ) ; final Set < String > submounts = VFS . getSubmounts ( this ) ; final List < String > names = mount . getFileSystem ( ) . getDirectoryEntries ( mount . getMo... | Get the children . This is the combined list of real children within this directory as well as virtual children created by submounts . |
133,372 | public List < VirtualFile > getChildren ( VirtualFileFilter filter ) throws IOException { if ( ! isDirectory ( ) ) { return Collections . emptyList ( ) ; } if ( filter == null ) { filter = MatchAllVirtualFileFilter . INSTANCE ; } FilterVirtualFileVisitor visitor = new FilterVirtualFileVisitor ( filter , null ) ; visit ... | Get the children |
133,373 | public VirtualFile getChild ( String path ) { if ( path == null ) { throw VFSMessages . MESSAGES . nullArgument ( "path" ) ; } final List < String > pathParts = PathTokenizer . getTokens ( path ) ; VirtualFile current = this ; for ( String part : pathParts ) { if ( PathTokenizer . isReverseToken ( part ) ) { final Virt... | Get a child virtual file . The child may or may not exist in the virtual filesystem . |
133,374 | public static List < String > getTokens ( String path ) { if ( path == null ) { throw MESSAGES . nullArgument ( "path" ) ; } List < String > list = new ArrayList < String > ( ) ; getTokens ( list , path ) ; return list ; } | Get the tokens that comprise this path . |
133,375 | public static void getTokens ( List < String > list , String path ) { int start = - 1 , length = path . length ( ) , state = STATE_INITIAL ; char ch ; for ( int index = 0 ; index < length ; index ++ ) { ch = path . charAt ( index ) ; switch ( ch ) { case '/' : case '\\' : { switch ( state ) { case STATE_INITIAL : { con... | Get the tokens that comprise this path and append them to the list . |
133,376 | public static String applySpecialPaths ( String path ) throws IllegalArgumentException { List < String > tokens = getTokens ( path ) ; if ( tokens == null ) { return null ; } int i = 0 ; for ( int j = 0 ; j < tokens . size ( ) ; j ++ ) { String token = tokens . get ( j ) ; if ( isCurrentToken ( token ) ) { continue ; }... | Apply any . or .. paths in the path param . |
133,377 | public static List < String > applySpecialPaths ( List < String > pathTokens ) throws IllegalArgumentException { final ArrayList < String > newTokens = new ArrayList < String > ( ) ; for ( String pathToken : pathTokens ) { if ( isCurrentToken ( pathToken ) ) { continue ; } else if ( isReverseToken ( pathToken ) ) { fin... | Apply any . or .. paths in the pathTokens parameter returning the minimal token list . |
133,378 | public static String getPathsString ( Collection < VirtualFile > paths ) { if ( paths == null ) { throw MESSAGES . nullArgument ( "paths" ) ; } StringBuilder buffer = new StringBuilder ( ) ; boolean first = true ; for ( VirtualFile path : paths ) { if ( path == null ) { throw new IllegalArgumentException ( "Null path i... | Get the paths string for a collection of virtual files |
133,379 | public static void addManifestLocations ( VirtualFile file , List < VirtualFile > paths ) throws IOException { if ( file == null ) { throw MESSAGES . nullArgument ( "file" ) ; } if ( paths == null ) { throw MESSAGES . nullArgument ( "paths" ) ; } boolean trace = VFSLogger . ROOT_LOGGER . isTraceEnabled ( ) ; Manifest m... | Add manifest paths |
133,380 | public static Manifest getManifest ( VirtualFile archive ) throws IOException { if ( archive == null ) { throw MESSAGES . nullArgument ( "archive" ) ; } VirtualFile manifest = archive . getChild ( JarFile . MANIFEST_NAME ) ; if ( manifest == null || ! manifest . exists ( ) ) { if ( VFSLogger . ROOT_LOGGER . isTraceEnab... | Get a manifest from a virtual file assuming the virtual file is the root of an archive |
133,381 | public static Manifest readManifest ( VirtualFile manifest ) throws IOException { if ( manifest == null ) { throw MESSAGES . nullArgument ( "manifest file" ) ; } InputStream stream = new PaddedManifestStream ( manifest . openStream ( ) ) ; try { return new Manifest ( stream ) ; } finally { safeClose ( stream ) ; } } | Read the manifest from given manifest VirtualFile . |
133,382 | public static String decode ( String path , String encoding ) { try { return URLDecoder . decode ( path , encoding ) ; } catch ( UnsupportedEncodingException e ) { throw MESSAGES . cannotDecode ( path , encoding , e ) ; } } | Decode the path . |
133,383 | public static String getName ( URI uri ) { if ( uri == null ) { throw MESSAGES . nullArgument ( "uri" ) ; } String name = uri . getPath ( ) ; if ( name != null ) { int lastSlash = name . lastIndexOf ( '/' ) ; if ( lastSlash > 0 ) { name = name . substring ( lastSlash + 1 ) ; } } return name ; } | Get the name . |
133,384 | public static URI toURI ( URL url ) throws URISyntaxException { if ( url == null ) { throw MESSAGES . nullArgument ( "url" ) ; } try { return url . toURI ( ) ; } catch ( URISyntaxException e ) { String urispec = url . toExternalForm ( ) ; urispec = urispec . replaceAll ( "%" , "%25" ) ; urispec = urispec . replaceAll (... | Deal with urls that may include spaces . |
133,385 | public static void safeClose ( final Iterable < ? extends Closeable > ci ) { if ( ci != null ) { for ( Closeable closeable : ci ) { safeClose ( closeable ) ; } } } | Safely close some resources without throwing an exception . Any exception will be logged at TRACE level . |
133,386 | public static boolean exists ( File file ) { try { boolean fileExists = file . exists ( ) ; if ( ! forceCaseSensitive || ! fileExists ) { return fileExists ; } String absPath = canonicalize ( file . getAbsolutePath ( ) ) ; String canPath = canonicalize ( file . getCanonicalPath ( ) ) ; return fileExists && absPath . eq... | In case the file system is not case sensitive we compare the canonical path with the absolute path of the file after normalized . |
133,387 | public static boolean recursiveDelete ( VirtualFile root ) { boolean ok = true ; if ( root . isDirectory ( ) ) { final List < VirtualFile > files = root . getChildren ( ) ; for ( VirtualFile file : files ) { ok &= recursiveDelete ( file ) ; } return ok && ( root . delete ( ) || ! root . exists ( ) ) ; } else { ok &= ro... | Attempt to recursively delete a virtual file . |
133,388 | public static void recursiveCopy ( File original , File destDir ) throws IOException { final String name = original . getName ( ) ; final File destFile = new File ( destDir , name ) ; if ( original . isDirectory ( ) ) { destFile . mkdir ( ) ; for ( File file : original . listFiles ( ) ) { recursiveCopy ( file , destFil... | Recursively copy a file or directory from one location to another . |
133,389 | public static void unzip ( File zipFile , File destDir ) throws IOException { final ZipFile zip = new ZipFile ( zipFile ) ; try { final Set < File > createdDirs = new HashSet < File > ( ) ; final Enumeration < ? extends ZipEntry > entries = zip . entries ( ) ; FILES_LOOP : while ( entries . hasMoreElements ( ) ) { fina... | Expand a zip file to a destination directory . The directory must exist . If an error occurs the destination directory may contain a partially - extracted archive so cleanup is up to the caller . |
133,390 | public static File getMountSource ( Closeable handle ) { if ( handle instanceof MountHandle ) { return MountHandle . class . cast ( handle ) . getMountSource ( ) ; } return null ; } | Return the mount source File for a given mount handle . |
133,391 | private static VisitorAttributes checkAttributes ( VirtualFileFilter filter , VisitorAttributes attributes ) { if ( filter == null ) { throw MESSAGES . nullArgument ( "filter" ) ; } if ( attributes != null ) { return attributes ; } if ( filter instanceof VirtualFileFilterWithAttributes ) { return ( ( VirtualFileFilterW... | Check the attributes |
133,392 | protected String getPathName ( VirtualFile file ) { try { return file . toURI ( ) . toString ( ) ; } catch ( Exception e ) { return file . getPathName ( ) ; } } | Get the path name for the VirtualFile . |
133,393 | private static MountConfig getMountConfig ( MountOption [ ] mountOptions ) { final MountConfig config = new MountConfig ( ) ; for ( MountOption option : mountOptions ) { option . applyTo ( config ) ; } return config ; } | Creates a MountConfig and applies the provided mount options |
133,394 | public static boolean addHandle ( VirtualFile owner , Closeable handle ) { RegistryEntry entry = getEntry ( owner ) ; return entry . handles . add ( handle ) ; } | Add handle to owner to be auto closed . |
133,395 | public static boolean removeHandle ( VirtualFile owner , Closeable handle ) { RegistryEntry entry = getEntry ( owner ) ; return entry . handles . remove ( handle ) ; } | Remove handle from owner . |
133,396 | static RegistryEntry getEntry ( VirtualFile virtualFile ) { if ( virtualFile == null ) { throw MESSAGES . nullArgument ( "VirutalFile" ) ; } return rootEntry . find ( virtualFile ) ; } | Get the entry from the tree creating the entry if not present . |
133,397 | public static TempFileProvider create ( final String providerType , final ScheduledExecutorService executor , final boolean cleanExisting ) throws IOException { if ( cleanExisting ) { try { final File possiblyExistingProviderRoot = new File ( TMP_ROOT , providerType ) ; if ( possiblyExistingProviderRoot . exists ( ) ) ... | Create a temporary file provider for a given type . |
133,398 | public TempDir createTempDir ( String originalName ) throws IOException { if ( ! open . get ( ) ) { throw VFSMessages . MESSAGES . tempFileProviderClosed ( ) ; } final String name = createTempName ( originalName + "-" , "" ) ; final File f = new File ( providerRoot , name ) ; for ( int i = 0 ; i < RETRIES ; i ++ ) { if... | Create a temp directory into which temporary files may be placed . |
133,399 | private void openCurrent ( VirtualFile current ) throws IOException { if ( current . isDirectory ( ) ) { currentEntryStream = VFSUtils . emptyStream ( ) ; } else { currentEntryStream = current . openStream ( ) ; } } | Open the current virtual file as the current JarEntry stream . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.