commons-io-1.3.2

16:34:45.749 INFO  jd.cli.Main - Decompiling commons-io-1.3.2.jar
package org.apache.commons.io;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.StringReader;
import java.io.Writer;

/**
 * @deprecated
 */
public class CopyUtils
{
  private static final int DEFAULT_BUFFER_SIZE = 4096;
  
  public static void copy(byte[] input, OutputStream output)
    throws IOException
  {
    output.write(input);
  }
  
  public static void copy(byte[] input, Writer output)
    throws IOException
  {
    ByteArrayInputStream in = new ByteArrayInputStream(input);
    copy(in, output);
  }
  
  public static void copy(byte[] input, Writer output, String encoding)
    throws IOException
  {
    ByteArrayInputStream in = new ByteArrayInputStream(input);
    copy(in, output, encoding);
  }
  
  public static int copy(InputStream input, OutputStream output)
    throws IOException
  {
    byte[] buffer = new byte['?'];
    int count = 0;
    int n = 0;
    while (-1 != (n = input.read(buffer)))
    {
      output.write(buffer, 0, n);
      count += n;
    }
    return count;
  }
  
  public static int copy(Reader input, Writer output)
    throws IOException
  {
    char[] buffer = new char['?'];
    int count = 0;
    int n = 0;
    while (-1 != (n = input.read(buffer)))
    {
      output.write(buffer, 0, n);
      count += n;
    }
    return count;
  }
  
  public static void copy(InputStream input, Writer output)
    throws IOException
  {
    InputStreamReader in = new InputStreamReader(input);
    copy(in, output);
  }
  
  public static void copy(InputStream input, Writer output, String encoding)
    throws IOException
  {
    InputStreamReader in = new InputStreamReader(input, encoding);
    copy(in, output);
  }
  
  public static void copy(Reader input, OutputStream output)
    throws IOException
  {
    OutputStreamWriter out = new OutputStreamWriter(output);
    copy(input, out);
    
    out.flush();
  }
  
  public static void copy(String input, OutputStream output)
    throws IOException
  {
    StringReader in = new StringReader(input);
    OutputStreamWriter out = new OutputStreamWriter(output);
    copy(in, out);
    
    out.flush();
  }
  
  public static void copy(String input, Writer output)
    throws IOException
  {
    output.write(input);
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.io.CopyUtils
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.io;

import java.io.File;
import java.io.IOException;

public class DirectoryWalker$CancelException
  extends IOException
{
  private static final long serialVersionUID = 1347339620135041008L;
  private File file;
  private int depth = -1;
  
  public DirectoryWalker$CancelException(File file, int depth)
  {
    this("Operation Cancelled", file, depth);
  }
  
  public DirectoryWalker$CancelException(String message, File file, int depth)
  {
    super(message);
    this.file = file;
    this.depth = depth;
  }
  
  public File getFile()
  {
    return file;
  }
  
  public int getDepth()
  {
    return depth;
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.io.DirectoryWalker.CancelException
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.io;

import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import java.util.Collection;
import org.apache.commons.io.filefilter.FileFilterUtils;
import org.apache.commons.io.filefilter.IOFileFilter;
import org.apache.commons.io.filefilter.TrueFileFilter;

public abstract class DirectoryWalker
{
  private final FileFilter filter;
  private final int depthLimit;
  
  protected DirectoryWalker()
  {
    this(null, -1);
  }
  
  protected DirectoryWalker(FileFilter filter, int depthLimit)
  {
    this.filter = filter;
    this.depthLimit = depthLimit;
  }
  
  protected DirectoryWalker(IOFileFilter directoryFilter, IOFileFilter fileFilter, int depthLimit)
  {
    if ((directoryFilter == null) && (fileFilter == null))
    {
      filter = null;
    }
    else
    {
      directoryFilter = directoryFilter != null ? directoryFilter : TrueFileFilter.TRUE;
      fileFilter = fileFilter != null ? fileFilter : TrueFileFilter.TRUE;
      directoryFilter = FileFilterUtils.makeDirectoryOnly(directoryFilter);
      fileFilter = FileFilterUtils.makeFileOnly(fileFilter);
      filter = FileFilterUtils.orFileFilter(directoryFilter, fileFilter);
    }
    this.depthLimit = depthLimit;
  }
  
  protected final void walk(File startDirectory, Collection results)
    throws IOException
  {
    if (startDirectory == null) {
      throw new NullPointerException("Start Directory is null");
    }
    try
    {
      handleStart(startDirectory, results);
      walk(startDirectory, 0, results);
      handleEnd(results);
    }
    catch (CancelException cancel)
    {
      handleCancelled(startDirectory, results, cancel);
    }
  }
  
  private void walk(File directory, int depth, Collection results)
    throws IOException
  {
    checkIfCancelled(directory, depth, results);
    if (handleDirectory(directory, depth, results))
    {
      handleDirectoryStart(directory, depth, results);
      int childDepth = depth + 1;
      if ((depthLimit < 0) || (childDepth <= depthLimit))
      {
        checkIfCancelled(directory, depth, results);
        File[] childFiles = filter == null ? directory.listFiles() : directory.listFiles(filter);
        if (childFiles == null) {
          handleRestricted(directory, childDepth, results);
        } else {
          for (int i = 0; i < childFiles.length; i++)
          {
            File childFile = childFiles[i];
            if (childFile.isDirectory())
            {
              walk(childFile, childDepth, results);
            }
            else
            {
              checkIfCancelled(childFile, childDepth, results);
              handleFile(childFile, childDepth, results);
              checkIfCancelled(childFile, childDepth, results);
            }
          }
        }
      }
      handleDirectoryEnd(directory, depth, results);
    }
    checkIfCancelled(directory, depth, results);
  }
  
  protected final void checkIfCancelled(File file, int depth, Collection results)
    throws IOException
  {
    if (handleIsCancelled(file, depth, results)) {
      throw new CancelException(file, depth);
    }
  }
  
  protected boolean handleIsCancelled(File file, int depth, Collection results)
    throws IOException
  {
    return false;
  }
  
  protected void handleCancelled(File startDirectory, Collection results, CancelException cancel)
    throws IOException
  {
    throw cancel;
  }
  
  protected void handleStart(File startDirectory, Collection results)
    throws IOException
  {}
  
  protected boolean handleDirectory(File directory, int depth, Collection results)
    throws IOException
  {
    return true;
  }
  
  protected void handleDirectoryStart(File directory, int depth, Collection results)
    throws IOException
  {}
  
  protected void handleFile(File file, int depth, Collection results)
    throws IOException
  {}
  
  protected void handleRestricted(File directory, int depth, Collection results)
    throws IOException
  {}
  
  protected void handleDirectoryEnd(File directory, int depth, Collection results)
    throws IOException
  {}
  
  protected void handleEnd(Collection results)
    throws IOException
  {}
  
  public static class CancelException
    extends IOException
  {
    private static final long serialVersionUID = 1347339620135041008L;
    private File file;
    private int depth = -1;
    
    public CancelException(File file, int depth)
    {
      this("Operation Cancelled", file, depth);
    }
    
    public CancelException(String message, File file, int depth)
    {
      super();
      this.file = file;
      this.depth = depth;
    }
    
    public File getFile()
    {
      return file;
    }
    
    public int getDepth()
    {
      return depth;
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.io.DirectoryWalker
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.io;

import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class EndianUtils
{
  public static short swapShort(short value)
  {
    return (short)(((value >> 0 & 0xFF) << 8) + ((value >> 8 & 0xFF) << 0));
  }
  
  public static int swapInteger(int value)
  {
    return ((value >> 0 & 0xFF) << 24) + ((value >> 8 & 0xFF) << 16) + ((value >> 16 & 0xFF) << 8) + ((value >> 24 & 0xFF) << 0);
  }
  
  public static long swapLong(long value)
  {
    return ((value >> 0 & 0xFF) << 56) + ((value >> 8 & 0xFF) << 48) + ((value >> 16 & 0xFF) << 40) + ((value >> 24 & 0xFF) << 32) + ((value >> 32 & 0xFF) << 24) + ((value >> 40 & 0xFF) << 16) + ((value >> 48 & 0xFF) << 8) + ((value >> 56 & 0xFF) << 0);
  }
  
  public static float swapFloat(float value)
  {
    return Float.intBitsToFloat(swapInteger(Float.floatToIntBits(value)));
  }
  
  public static double swapDouble(double value)
  {
    return Double.longBitsToDouble(swapLong(Double.doubleToLongBits(value)));
  }
  
  public static void writeSwappedShort(byte[] data, int offset, short value)
  {
    data[(offset + 0)] = ((byte)(value >> 0 & 0xFF));
    data[(offset + 1)] = ((byte)(value >> 8 & 0xFF));
  }
  
  public static short readSwappedShort(byte[] data, int offset)
  {
    return (short)(((data[(offset + 0)] & 0xFF) << 0) + ((data[(offset + 1)] & 0xFF) << 8));
  }
  
  public static int readSwappedUnsignedShort(byte[] data, int offset)
  {
    return ((data[(offset + 0)] & 0xFF) << 0) + ((data[(offset + 1)] & 0xFF) << 8);
  }
  
  public static void writeSwappedInteger(byte[] data, int offset, int value)
  {
    data[(offset + 0)] = ((byte)(value >> 0 & 0xFF));
    data[(offset + 1)] = ((byte)(value >> 8 & 0xFF));
    data[(offset + 2)] = ((byte)(value >> 16 & 0xFF));
    data[(offset + 3)] = ((byte)(value >> 24 & 0xFF));
  }
  
  public static int readSwappedInteger(byte[] data, int offset)
  {
    return ((data[(offset + 0)] & 0xFF) << 0) + ((data[(offset + 1)] & 0xFF) << 8) + ((data[(offset + 2)] & 0xFF) << 16) + ((data[(offset + 3)] & 0xFF) << 24);
  }
  
  public static long readSwappedUnsignedInteger(byte[] data, int offset)
  {
    long low = ((data[(offset + 0)] & 0xFF) << 0) + ((data[(offset + 1)] & 0xFF) << 8) + ((data[(offset + 2)] & 0xFF) << 16);
    
    long high = data[(offset + 3)] & 0xFF;
    
    return (high << 24) + (0xFFFFFFFF & low);
  }
  
  public static void writeSwappedLong(byte[] data, int offset, long value)
  {
    data[(offset + 0)] = ((byte)(int)(value >> 0 & 0xFF));
    data[(offset + 1)] = ((byte)(int)(value >> 8 & 0xFF));
    data[(offset + 2)] = ((byte)(int)(value >> 16 & 0xFF));
    data[(offset + 3)] = ((byte)(int)(value >> 24 & 0xFF));
    data[(offset + 4)] = ((byte)(int)(value >> 32 & 0xFF));
    data[(offset + 5)] = ((byte)(int)(value >> 40 & 0xFF));
    data[(offset + 6)] = ((byte)(int)(value >> 48 & 0xFF));
    data[(offset + 7)] = ((byte)(int)(value >> 56 & 0xFF));
  }
  
  public static long readSwappedLong(byte[] data, int offset)
  {
    long low = ((data[(offset + 0)] & 0xFF) << 0) + ((data[(offset + 1)] & 0xFF) << 8) + ((data[(offset + 2)] & 0xFF) << 16) + ((data[(offset + 3)] & 0xFF) << 24);
    
    long high = ((data[(offset + 4)] & 0xFF) << 0) + ((data[(offset + 5)] & 0xFF) << 8) + ((data[(offset + 6)] & 0xFF) << 16) + ((data[(offset + 7)] & 0xFF) << 24);
    
    return (high << 32) + (0xFFFFFFFF & low);
  }
  
  public static void writeSwappedFloat(byte[] data, int offset, float value)
  {
    writeSwappedInteger(data, offset, Float.floatToIntBits(value));
  }
  
  public static float readSwappedFloat(byte[] data, int offset)
  {
    return Float.intBitsToFloat(readSwappedInteger(data, offset));
  }
  
  public static void writeSwappedDouble(byte[] data, int offset, double value)
  {
    writeSwappedLong(data, offset, Double.doubleToLongBits(value));
  }
  
  public static double readSwappedDouble(byte[] data, int offset)
  {
    return Double.longBitsToDouble(readSwappedLong(data, offset));
  }
  
  public static void writeSwappedShort(OutputStream output, short value)
    throws IOException
  {
    output.write((byte)(value >> 0 & 0xFF));
    output.write((byte)(value >> 8 & 0xFF));
  }
  
  public static short readSwappedShort(InputStream input)
    throws IOException
  {
    return (short)(((read(input) & 0xFF) << 0) + ((read(input) & 0xFF) << 8));
  }
  
  public static int readSwappedUnsignedShort(InputStream input)
    throws IOException
  {
    int value1 = read(input);
    int value2 = read(input);
    
    return ((value1 & 0xFF) << 0) + ((value2 & 0xFF) << 8);
  }
  
  public static void writeSwappedInteger(OutputStream output, int value)
    throws IOException
  {
    output.write((byte)(value >> 0 & 0xFF));
    output.write((byte)(value >> 8 & 0xFF));
    output.write((byte)(value >> 16 & 0xFF));
    output.write((byte)(value >> 24 & 0xFF));
  }
  
  public static int readSwappedInteger(InputStream input)
    throws IOException
  {
    int value1 = read(input);
    int value2 = read(input);
    int value3 = read(input);
    int value4 = read(input);
    
    return ((value1 & 0xFF) << 0) + ((value2 & 0xFF) << 8) + ((value3 & 0xFF) << 16) + ((value4 & 0xFF) << 24);
  }
  
  public static long readSwappedUnsignedInteger(InputStream input)
    throws IOException
  {
    int value1 = read(input);
    int value2 = read(input);
    int value3 = read(input);
    int value4 = read(input);
    
    long low = ((value1 & 0xFF) << 0) + ((value2 & 0xFF) << 8) + ((value3 & 0xFF) << 16);
    
    long high = value4 & 0xFF;
    
    return (high << 24) + (0xFFFFFFFF & low);
  }
  
  public static void writeSwappedLong(OutputStream output, long value)
    throws IOException
  {
    output.write((byte)(int)(value >> 0 & 0xFF));
    output.write((byte)(int)(value >> 8 & 0xFF));
    output.write((byte)(int)(value >> 16 & 0xFF));
    output.write((byte)(int)(value >> 24 & 0xFF));
    output.write((byte)(int)(value >> 32 & 0xFF));
    output.write((byte)(int)(value >> 40 & 0xFF));
    output.write((byte)(int)(value >> 48 & 0xFF));
    output.write((byte)(int)(value >> 56 & 0xFF));
  }
  
  public static long readSwappedLong(InputStream input)
    throws IOException
  {
    byte[] bytes = new byte[8];
    for (int i = 0; i < 8; i++) {
      bytes[i] = ((byte)read(input));
    }
    return readSwappedLong(bytes, 0);
  }
  
  public static void writeSwappedFloat(OutputStream output, float value)
    throws IOException
  {
    writeSwappedInteger(output, Float.floatToIntBits(value));
  }
  
  public static float readSwappedFloat(InputStream input)
    throws IOException
  {
    return Float.intBitsToFloat(readSwappedInteger(input));
  }
  
  public static void writeSwappedDouble(OutputStream output, double value)
    throws IOException
  {
    writeSwappedLong(output, Double.doubleToLongBits(value));
  }
  
  public static double readSwappedDouble(InputStream input)
    throws IOException
  {
    return Double.longBitsToDouble(readSwappedLong(input));
  }
  
  private static int read(InputStream input)
    throws IOException
  {
    int value = input.read();
    if (-1 == value) {
      throw new EOFException("Unexpected EOF reached");
    }
    return value;
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.io.EndianUtils
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.io;

import java.io.File;

public class FileCleaner
{
  static final FileCleaningTracker theInstance = new FileCleaningTracker();
  
  public static void track(File file, Object marker)
  {
    theInstance.track(file, marker);
  }
  
  public static void track(File file, Object marker, FileDeleteStrategy deleteStrategy)
  {
    theInstance.track(file, marker, deleteStrategy);
  }
  
  public static void track(String path, Object marker)
  {
    theInstance.track(path, marker);
  }
  
  public static void track(String path, Object marker, FileDeleteStrategy deleteStrategy)
  {
    theInstance.track(path, marker, deleteStrategy);
  }
  
  public static int getTrackCount()
  {
    return theInstance.getTrackCount();
  }
  
  public static synchronized void exitWhenFinished()
  {
    theInstance.exitWhenFinished();
  }
  
  public static FileCleaningTracker getInstance()
  {
    return theInstance;
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.io.FileCleaner
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.io;

import java.lang.ref.ReferenceQueue;
import java.util.Collection;

final class FileCleaningTracker$Reaper
  extends Thread
{
  private final FileCleaningTracker this$0;
  
  FileCleaningTracker$Reaper(FileCleaningTracker paramFileCleaningTracker)
  {
    super("File Reaper");this$0 = paramFileCleaningTracker;
    setPriority(10);
    setDaemon(true);
  }
  
  public void run()
  {
    while ((!this$0.exitWhenFinished) || (this$0.trackers.size() > 0))
    {
      FileCleaningTracker.Tracker tracker = null;
      try
      {
        tracker = (FileCleaningTracker.Tracker)this$0.q.remove();
      }
      catch (Exception e) {}
      continue;
      if (tracker != null)
      {
        tracker.delete();
        tracker.clear();
        this$0.trackers.remove(tracker);
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.io.FileCleaningTracker.Reaper
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.io;

import java.io.File;
import java.lang.ref.PhantomReference;
import java.lang.ref.ReferenceQueue;

final class FileCleaningTracker$Tracker
  extends PhantomReference
{
  private final String path;
  private final FileDeleteStrategy deleteStrategy;
  
  FileCleaningTracker$Tracker(String path, FileDeleteStrategy deleteStrategy, Object marker, ReferenceQueue queue)
  {
    super(marker, queue);
    this.path = path;
    this.deleteStrategy = (deleteStrategy == null ? FileDeleteStrategy.NORMAL : deleteStrategy);
  }
  
  public boolean delete()
  {
    return deleteStrategy.deleteQuietly(new File(path));
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.io.FileCleaningTracker.Tracker
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.io;

import java.io.File;
import java.lang.ref.PhantomReference;
import java.lang.ref.ReferenceQueue;
import java.util.Collection;
import java.util.Vector;

public class FileCleaningTracker
{
  ReferenceQueue q;
  final Collection trackers;
  volatile boolean exitWhenFinished;
  Thread reaper;
  
  public FileCleaningTracker()
  {
    q = new ReferenceQueue();
    
    trackers = new Vector();
    
    exitWhenFinished = false;
  }
  
  public void track(File file, Object marker)
  {
    track(file, marker, (FileDeleteStrategy)null);
  }
  
  public void track(File file, Object marker, FileDeleteStrategy deleteStrategy)
  {
    if (file == null) {
      throw new NullPointerException("The file must not be null");
    }
    addTracker(file.getPath(), marker, deleteStrategy);
  }
  
  public void track(String path, Object marker)
  {
    track(path, marker, (FileDeleteStrategy)null);
  }
  
  public void track(String path, Object marker, FileDeleteStrategy deleteStrategy)
  {
    if (path == null) {
      throw new NullPointerException("The path must not be null");
    }
    addTracker(path, marker, deleteStrategy);
  }
  
  private synchronized void addTracker(String path, Object marker, FileDeleteStrategy deleteStrategy)
  {
    if (exitWhenFinished) {
      throw new IllegalStateException("No new trackers can be added once exitWhenFinished() is called");
    }
    if (reaper == null)
    {
      reaper = new Reaper();
      reaper.start();
    }
    trackers.add(new Tracker(path, deleteStrategy, marker, q));
  }
  
  public int getTrackCount()
  {
    return trackers.size();
  }
  
  public synchronized void exitWhenFinished()
  {
    exitWhenFinished = true;
    if (reaper != null) {
      synchronized (reaper)
      {
        reaper.interrupt();
      }
    }
  }
  
  private final class Reaper
    extends Thread
  {
    Reaper()
    {
      super();
      setPriority(10);
      setDaemon(true);
    }
    
    public void run()
    {
      while ((!exitWhenFinished) || (trackers.size() > 0))
      {
        FileCleaningTracker.Tracker tracker = null;
        try
        {
          tracker = (FileCleaningTracker.Tracker)q.remove();
        }
        catch (Exception e) {}
        continue;
        if (tracker != null)
        {
          tracker.delete();
          tracker.clear();
          trackers.remove(tracker);
        }
      }
    }
  }
  
  private static final class Tracker
    extends PhantomReference
  {
    private final String path;
    private final FileDeleteStrategy deleteStrategy;
    
    Tracker(String path, FileDeleteStrategy deleteStrategy, Object marker, ReferenceQueue queue)
    {
      super(queue);
      this.path = path;
      this.deleteStrategy = (deleteStrategy == null ? FileDeleteStrategy.NORMAL : deleteStrategy);
    }
    
    public boolean delete()
    {
      return deleteStrategy.deleteQuietly(new File(path));
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.io.FileCleaningTracker
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.io;

import java.io.File;
import java.io.IOException;

class FileDeleteStrategy$ForceFileDeleteStrategy
  extends FileDeleteStrategy
{
  FileDeleteStrategy$ForceFileDeleteStrategy()
  {
    super("Force");
  }
  
  protected boolean doDelete(File fileToDelete)
    throws IOException
  {
    FileUtils.forceDelete(fileToDelete);
    return true;
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.io.FileDeleteStrategy.ForceFileDeleteStrategy
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.io;

import java.io.File;
import java.io.IOException;

public class FileDeleteStrategy
{
  public static final FileDeleteStrategy NORMAL = new FileDeleteStrategy("Normal");
  public static final FileDeleteStrategy FORCE = new ForceFileDeleteStrategy();
  private final String name;
  
  protected FileDeleteStrategy(String name)
  {
    this.name = name;
  }
  
  public boolean deleteQuietly(File fileToDelete)
  {
    if ((fileToDelete == null) || (!fileToDelete.exists())) {
      return true;
    }
    try
    {
      return doDelete(fileToDelete);
    }
    catch (IOException ex) {}
    return false;
  }
  
  public void delete(File fileToDelete)
    throws IOException
  {
    if ((fileToDelete.exists()) && (!doDelete(fileToDelete))) {
      throw new IOException("Deletion failed: " + fileToDelete);
    }
  }
  
  protected boolean doDelete(File fileToDelete)
    throws IOException
  {
    return fileToDelete.delete();
  }
  
  public String toString()
  {
    return "FileDeleteStrategy[" + name + "]";
  }
  
  static class ForceFileDeleteStrategy
    extends FileDeleteStrategy
  {
    ForceFileDeleteStrategy()
    {
      super();
    }
    
    protected boolean doDelete(File fileToDelete)
      throws IOException
    {
      FileUtils.forceDelete(fileToDelete);
      return true;
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.io.FileDeleteStrategy
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.io.filefilter;

import java.io.File;

public abstract class AbstractFileFilter
  implements IOFileFilter
{
  public boolean accept(File file)
  {
    return accept(file.getParentFile(), file.getName());
  }
  
  public boolean accept(File dir, String name)
  {
    return accept(new File(dir, name));
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.io.filefilter.AbstractFileFilter
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.io.filefilter;

import java.io.File;
import java.util.Date;
import org.apache.commons.io.FileUtils;

public class AgeFileFilter
  extends AbstractFileFilter
{
  private long cutoff;
  private boolean acceptOlder;
  
  public AgeFileFilter(long cutoff)
  {
    this(cutoff, true);
  }
  
  public AgeFileFilter(long cutoff, boolean acceptOlder)
  {
    this.acceptOlder = acceptOlder;
    this.cutoff = cutoff;
  }
  
  public AgeFileFilter(Date cutoffDate)
  {
    this(cutoffDate, true);
  }
  
  public AgeFileFilter(Date cutoffDate, boolean acceptOlder)
  {
    this(cutoffDate.getTime(), acceptOlder);
  }
  
  public AgeFileFilter(File cutoffReference)
  {
    this(cutoffReference, true);
  }
  
  public AgeFileFilter(File cutoffReference, boolean acceptOlder)
  {
    this(cutoffReference.lastModified(), acceptOlder);
  }
  
  public boolean accept(File file)
  {
    boolean newer = FileUtils.isFileNewer(file, cutoff);
    return acceptOlder ? false : !newer ? true : newer;
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.io.filefilter.AgeFileFilter
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.io.filefilter;

import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

public class AndFileFilter
  extends AbstractFileFilter
  implements ConditionalFileFilter
{
  private List fileFilters;
  
  public AndFileFilter()
  {
    fileFilters = new ArrayList();
  }
  
  public AndFileFilter(List fileFilters)
  {
    if (fileFilters == null) {
      this.fileFilters = new ArrayList();
    } else {
      this.fileFilters = new ArrayList(fileFilters);
    }
  }
  
  public AndFileFilter(IOFileFilter filter1, IOFileFilter filter2)
  {
    if ((filter1 == null) || (filter2 == null)) {
      throw new IllegalArgumentException("The filters must not be null");
    }
    fileFilters = new ArrayList();
    addFileFilter(filter1);
    addFileFilter(filter2);
  }
  
  public void addFileFilter(IOFileFilter ioFileFilter)
  {
    fileFilters.add(ioFileFilter);
  }
  
  public List getFileFilters()
  {
    return Collections.unmodifiableList(fileFilters);
  }
  
  public boolean removeFileFilter(IOFileFilter ioFileFilter)
  {
    return fileFilters.remove(ioFileFilter);
  }
  
  public void setFileFilters(List fileFilters)
  {
    this.fileFilters = new ArrayList(fileFilters);
  }
  
  public boolean accept(File file)
  {
    if (fileFilters.size() == 0) {
      return false;
    }
    for (Iterator iter = fileFilters.iterator(); iter.hasNext();)
    {
      IOFileFilter fileFilter = (IOFileFilter)iter.next();
      if (!fileFilter.accept(file)) {
        return false;
      }
    }
    return true;
  }
  
  public boolean accept(File file, String name)
  {
    if (fileFilters.size() == 0) {
      return false;
    }
    for (Iterator iter = fileFilters.iterator(); iter.hasNext();)
    {
      IOFileFilter fileFilter = (IOFileFilter)iter.next();
      if (!fileFilter.accept(file, name)) {
        return false;
      }
    }
    return true;
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.io.filefilter.AndFileFilter
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.io.filefilter;

import java.io.File;

public class CanReadFileFilter
  extends AbstractFileFilter
{
  public static final IOFileFilter CAN_READ = new CanReadFileFilter();
  public static final IOFileFilter CANNOT_READ = new NotFileFilter(CAN_READ);
  public static final IOFileFilter READ_ONLY = new AndFileFilter(CAN_READ, CanWriteFileFilter.CANNOT_WRITE);
  
  public boolean accept(File file)
  {
    return file.canRead();
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.io.filefilter.CanReadFileFilter
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.io.filefilter;

import java.io.File;

public class CanWriteFileFilter
  extends AbstractFileFilter
{
  public static final IOFileFilter CAN_WRITE = new CanWriteFileFilter();
  public static final IOFileFilter CANNOT_WRITE = new NotFileFilter(CAN_WRITE);
  
  public boolean accept(File file)
  {
    return file.canWrite();
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.io.filefilter.CanWriteFileFilter
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.io.filefilter;

import java.util.List;

public abstract interface ConditionalFileFilter
{
  public abstract void addFileFilter(IOFileFilter paramIOFileFilter);
  
  public abstract List getFileFilters();
  
  public abstract boolean removeFileFilter(IOFileFilter paramIOFileFilter);
  
  public abstract void setFileFilters(List paramList);
}

/* Location:
 * Qualified Name:     org.apache.commons.io.filefilter.ConditionalFileFilter
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.io.filefilter;

import java.io.File;
import java.io.FileFilter;
import java.io.FilenameFilter;

public class DelegateFileFilter
  extends AbstractFileFilter
{
  private FilenameFilter filenameFilter;
  private FileFilter fileFilter;
  
  public DelegateFileFilter(FilenameFilter filter)
  {
    if (filter == null) {
      throw new IllegalArgumentException("The FilenameFilter must not be null");
    }
    filenameFilter = filter;
  }
  
  public DelegateFileFilter(FileFilter filter)
  {
    if (filter == null) {
      throw new IllegalArgumentException("The FileFilter must not be null");
    }
    fileFilter = filter;
  }
  
  public boolean accept(File file)
  {
    if (fileFilter != null) {
      return fileFilter.accept(file);
    }
    return super.accept(file);
  }
  
  public boolean accept(File dir, String name)
  {
    if (filenameFilter != null) {
      return filenameFilter.accept(dir, name);
    }
    return super.accept(dir, name);
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.io.filefilter.DelegateFileFilter
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.io.filefilter;

import java.io.File;

public class DirectoryFileFilter
  extends AbstractFileFilter
{
  public static final IOFileFilter DIRECTORY = new DirectoryFileFilter();
  public static final IOFileFilter INSTANCE = DIRECTORY;
  
  public boolean accept(File file)
  {
    return file.isDirectory();
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.io.filefilter.DirectoryFileFilter
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.io.filefilter;

import java.io.File;

public class EmptyFileFilter
  extends AbstractFileFilter
{
  public static final IOFileFilter EMPTY = new EmptyFileFilter();
  public static final IOFileFilter NOT_EMPTY = new NotFileFilter(EMPTY);
  
  public boolean accept(File file)
  {
    if (file.isDirectory())
    {
      File[] files = file.listFiles();
      return (files == null) || (files.length == 0);
    }
    return file.length() == 0L;
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.io.filefilter.EmptyFileFilter
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.io.filefilter;

import java.io.File;

public class FalseFileFilter
  implements IOFileFilter
{
  public static final IOFileFilter FALSE = new FalseFileFilter();
  public static final IOFileFilter INSTANCE = FALSE;
  
  public boolean accept(File file)
  {
    return false;
  }
  
  public boolean accept(File dir, String name)
  {
    return false;
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.io.filefilter.FalseFileFilter
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.io.filefilter;

import java.io.File;

public class FileFileFilter
  extends AbstractFileFilter
{
  public static final IOFileFilter FILE = new FileFileFilter();
  
  public boolean accept(File file)
  {
    return file.isFile();
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.io.filefilter.FileFileFilter
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.io.filefilter;

import java.io.File;
import java.io.FileFilter;
import java.io.FilenameFilter;
import java.util.Date;

public class FileFilterUtils
{
  private static IOFileFilter cvsFilter;
  private static IOFileFilter svnFilter;
  
  public static IOFileFilter prefixFileFilter(String prefix)
  {
    return new PrefixFileFilter(prefix);
  }
  
  public static IOFileFilter suffixFileFilter(String suffix)
  {
    return new SuffixFileFilter(suffix);
  }
  
  public static IOFileFilter nameFileFilter(String name)
  {
    return new NameFileFilter(name);
  }
  
  public static IOFileFilter directoryFileFilter()
  {
    return DirectoryFileFilter.DIRECTORY;
  }
  
  public static IOFileFilter fileFileFilter()
  {
    return FileFileFilter.FILE;
  }
  
  public static IOFileFilter andFileFilter(IOFileFilter filter1, IOFileFilter filter2)
  {
    return new AndFileFilter(filter1, filter2);
  }
  
  public static IOFileFilter orFileFilter(IOFileFilter filter1, IOFileFilter filter2)
  {
    return new OrFileFilter(filter1, filter2);
  }
  
  public static IOFileFilter notFileFilter(IOFileFilter filter)
  {
    return new NotFileFilter(filter);
  }
  
  public static IOFileFilter trueFileFilter()
  {
    return TrueFileFilter.TRUE;
  }
  
  public static IOFileFilter falseFileFilter()
  {
    return FalseFileFilter.FALSE;
  }
  
  public static IOFileFilter asFileFilter(FileFilter filter)
  {
    return new DelegateFileFilter(filter);
  }
  
  public static IOFileFilter asFileFilter(FilenameFilter filter)
  {
    return new DelegateFileFilter(filter);
  }
  
  public static IOFileFilter ageFileFilter(long cutoff)
  {
    return new AgeFileFilter(cutoff);
  }
  
  public static IOFileFilter ageFileFilter(long cutoff, boolean acceptOlder)
  {
    return new AgeFileFilter(cutoff, acceptOlder);
  }
  
  public static IOFileFilter ageFileFilter(Date cutoffDate)
  {
    return new AgeFileFilter(cutoffDate);
  }
  
  public static IOFileFilter ageFileFilter(Date cutoffDate, boolean acceptOlder)
  {
    return new AgeFileFilter(cutoffDate, acceptOlder);
  }
  
  public static IOFileFilter ageFileFilter(File cutoffReference)
  {
    return new AgeFileFilter(cutoffReference);
  }
  
  public static IOFileFilter ageFileFilter(File cutoffReference, boolean acceptOlder)
  {
    return new AgeFileFilter(cutoffReference, acceptOlder);
  }
  
  public static IOFileFilter sizeFileFilter(long threshold)
  {
    return new SizeFileFilter(threshold);
  }
  
  public static IOFileFilter sizeFileFilter(long threshold, boolean acceptLarger)
  {
    return new SizeFileFilter(threshold, acceptLarger);
  }
  
  public static IOFileFilter sizeRangeFileFilter(long minSizeInclusive, long maxSizeInclusive)
  {
    IOFileFilter minimumFilter = new SizeFileFilter(minSizeInclusive, true);
    IOFileFilter maximumFilter = new SizeFileFilter(maxSizeInclusive + 1L, false);
    return new AndFileFilter(minimumFilter, maximumFilter);
  }
  
  public static IOFileFilter makeCVSAware(IOFileFilter filter)
  {
    if (cvsFilter == null) {
      cvsFilter = notFileFilter(andFileFilter(directoryFileFilter(), nameFileFilter("CVS")));
    }
    if (filter == null) {
      return cvsFilter;
    }
    return andFileFilter(filter, cvsFilter);
  }
  
  public static IOFileFilter makeSVNAware(IOFileFilter filter)
  {
    if (svnFilter == null) {
      svnFilter = notFileFilter(andFileFilter(directoryFileFilter(), nameFileFilter(".svn")));
    }
    if (filter == null) {
      return svnFilter;
    }
    return andFileFilter(filter, svnFilter);
  }
  
  public static IOFileFilter makeDirectoryOnly(IOFileFilter filter)
  {
    if (filter == null) {
      return DirectoryFileFilter.DIRECTORY;
    }
    return new AndFileFilter(DirectoryFileFilter.DIRECTORY, filter);
  }
  
  public static IOFileFilter makeFileOnly(IOFileFilter filter)
  {
    if (filter == null) {
      return FileFileFilter.FILE;
    }
    return new AndFileFilter(FileFileFilter.FILE, filter);
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.io.filefilter.FileFilterUtils
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.io.filefilter;

import java.io.File;

public class HiddenFileFilter
  extends AbstractFileFilter
{
  public static final IOFileFilter HIDDEN = new HiddenFileFilter();
  public static final IOFileFilter VISIBLE = new NotFileFilter(HIDDEN);
  
  public boolean accept(File file)
  {
    return file.isHidden();
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.io.filefilter.HiddenFileFilter
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.io.filefilter;

import java.io.File;
import java.io.FileFilter;
import java.io.FilenameFilter;

public abstract interface IOFileFilter
  extends FileFilter, FilenameFilter
{
  public abstract boolean accept(File paramFile);
  
  public abstract boolean accept(File paramFile, String paramString);
}

/* Location:
 * Qualified Name:     org.apache.commons.io.filefilter.IOFileFilter
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.io.filefilter;

import java.io.File;
import java.util.List;
import org.apache.commons.io.IOCase;

public class NameFileFilter
  extends AbstractFileFilter
{
  private String[] names;
  private IOCase caseSensitivity;
  
  public NameFileFilter(String name)
  {
    this(name, null);
  }
  
  public NameFileFilter(String name, IOCase caseSensitivity)
  {
    if (name == null) {
      throw new IllegalArgumentException("The wildcard must not be null");
    }
    names = new String[] { name };
    this.caseSensitivity = (caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity);
  }
  
  public NameFileFilter(String[] names)
  {
    this(names, null);
  }
  
  public NameFileFilter(String[] names, IOCase caseSensitivity)
  {
    if (names == null) {
      throw new IllegalArgumentException("The array of names must not be null");
    }
    this.names = names;
    this.caseSensitivity = (caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity);
  }
  
  public NameFileFilter(List names)
  {
    this(names, null);
  }
  
  public NameFileFilter(List names, IOCase caseSensitivity)
  {
    if (names == null) {
      throw new IllegalArgumentException("The list of names must not be null");
    }
    this.names = ((String[])names.toArray(new String[names.size()]));
    this.caseSensitivity = (caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity);
  }
  
  public boolean accept(File file)
  {
    String name = file.getName();
    for (int i = 0; i < names.length; i++) {
      if (caseSensitivity.checkEquals(name, names[i])) {
        return true;
      }
    }
    return false;
  }
  
  public boolean accept(File file, String name)
  {
    for (int i = 0; i < names.length; i++) {
      if (caseSensitivity.checkEquals(name, names[i])) {
        return true;
      }
    }
    return false;
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.io.filefilter.NameFileFilter
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.io.filefilter;

import java.io.File;

public class NotFileFilter
  extends AbstractFileFilter
{
  private IOFileFilter filter;
  
  public NotFileFilter(IOFileFilter filter)
  {
    if (filter == null) {
      throw new IllegalArgumentException("The filter must not be null");
    }
    this.filter = filter;
  }
  
  public boolean accept(File file)
  {
    return !filter.accept(file);
  }
  
  public boolean accept(File file, String name)
  {
 
1 2 3 4

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd