![]() |
![]() |
commons-io-2.416:34:46.402 INFO jd.cli.Main - Decompiling commons-io-2.4.jar package org.apache.commons.io; import java.io.Serializable; public class ByteOrderMark implements Serializable { private static final long serialVersionUID = 1L; public static final ByteOrderMark UTF_8 = new ByteOrderMark("UTF-8", new int[] { 239, 187, 191 }); public static final ByteOrderMark UTF_16BE = new ByteOrderMark("UTF-16BE", new int[] { 254, 255 }); public static final ByteOrderMark UTF_16LE = new ByteOrderMark("UTF-16LE", new int[] { 255, 254 }); public static final ByteOrderMark UTF_32BE = new ByteOrderMark("UTF-32BE", new int[] { 0, 0, 254, 255 }); public static final ByteOrderMark UTF_32LE = new ByteOrderMark("UTF-32LE", new int[] { 255, 254, 0, 0 }); private final String charsetName; private final int[] bytes; public ByteOrderMark(String charsetName, int... bytes) { if ((charsetName == null) || (charsetName.length() == 0)) { throw new IllegalArgumentException("No charsetName specified"); } if ((bytes == null) || (bytes.length == 0)) { throw new IllegalArgumentException("No bytes specified"); } this.charsetName = charsetName; this.bytes = new int[bytes.length]; System.arraycopy(bytes, 0, this.bytes, 0, bytes.length); } public String getCharsetName() { return charsetName; } public int length() { return bytes.length; } public int get(int pos) { return bytes[pos]; } public byte[] getBytes() { byte[] copy = new byte[bytes.length]; for (int i = 0; i < bytes.length; i++) { copy[i] = ((byte)bytes[i]); } return copy; } public boolean equals(Object obj) { if (!(obj instanceof ByteOrderMark)) { return false; } ByteOrderMark bom = (ByteOrderMark)obj; if (bytes.length != bom.length()) { return false; } for (int i = 0; i < bytes.length; i++) { if (bytes[i] != bom.get(i)) { return false; } } return true; } public int hashCode() { int hashCode = getClass().hashCode(); for (int b : bytes) { hashCode += b; } return hashCode; } public String toString() { StringBuilder builder = new StringBuilder(); builder.append(getClass().getSimpleName()); builder.append('['); builder.append(charsetName); builder.append(": "); for (int i = 0; i < bytes.length; i++) { if (i > 0) { builder.append(","); } builder.append("0x"); builder.append(Integer.toHexString(0xFF & bytes[i]).toUpperCase()); } builder.append(']'); return builder.toString(); } } /* Location: * Qualified Name: org.apache.commons.io.ByteOrderMark * Java Class Version: 6 (50.0) * JD-Core Version: 0.7.1 */ package org.apache.commons.io; import java.nio.charset.Charset; public class Charsets { public static Charset toCharset(Charset charset) { return charset == null ? Charset.defaultCharset() : charset; } public static Charset toCharset(String charset) { return charset == null ? Charset.defaultCharset() : Charset.forName(charset); } public static final Charset ISO_8859_1 = Charset.forName("ISO-8859-1"); public static final Charset US_ASCII = Charset.forName("US-ASCII"); public static final Charset UTF_16 = Charset.forName("UTF-16"); public static final Charset UTF_16BE = Charset.forName("UTF-16BE"); public static final Charset UTF_16LE = Charset.forName("UTF-16LE"); public static final Charset UTF_8 = Charset.forName("UTF-8"); } /* Location: * Qualified Name: org.apache.commons.io.Charsets * Java Class Version: 6 (50.0) * JD-Core Version: 0.7.1 */ package org.apache.commons.io.comparator; import java.io.File; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.List; abstract class AbstractFileComparator implements Comparator<File> { public File[] sort(File... files) { if (files != null) { Arrays.sort(files, this); } return files; } public List<File> sort(List<File> files) { if (files != null) { Collections.sort(files, this); } return files; } public String toString() { return getClass().getSimpleName(); } } /* Location: * Qualified Name: org.apache.commons.io.comparator.AbstractFileComparator * Java Class Version: 6 (50.0) * JD-Core Version: 0.7.1 */ package org.apache.commons.io.comparator; import java.io.File; import java.io.Serializable; import java.util.ArrayList; import java.util.Comparator; import java.util.List; public class CompositeFileComparator extends AbstractFileComparator implements Serializable { private static final Comparator<?>[] NO_COMPARATORS = new Comparator[0]; private final Comparator<File>[] delegates; public CompositeFileComparator(Comparator<File>... delegates) { if (delegates == null) { this.delegates = ((Comparator[])NO_COMPARATORS); } else { this.delegates = ((Comparator[])new Comparator[delegates.length]); System.arraycopy(delegates, 0, this.delegates, 0, delegates.length); } } public CompositeFileComparator(Iterable<Comparator<File>> delegates) { if (delegates == null) { this.delegates = ((Comparator[])NO_COMPARATORS); } else { List<Comparator<File>> list = new ArrayList(); for (Comparator<File> comparator : delegates) { list.add(comparator); } this.delegates = ((Comparator[])list.toArray(new Comparator[list.size()])); } } public int compare(File file1, File file2) { int result = 0; for (Comparator<File> delegate : delegates) { result = delegate.compare(file1, file2); if (result != 0) { break; } } return result; } public String toString() { StringBuilder builder = new StringBuilder(); builder.append(super.toString()); builder.append('{'); for (int i = 0; i < delegates.length; i++) { if (i > 0) { builder.append(','); } builder.append(delegates[i]); } builder.append('}'); return builder.toString(); } } /* Location: * Qualified Name: org.apache.commons.io.comparator.CompositeFileComparator * Java Class Version: 6 (50.0) * JD-Core Version: 0.7.1 */ package org.apache.commons.io.comparator; import java.io.File; import java.io.Serializable; import java.util.Comparator; public class DefaultFileComparator extends AbstractFileComparator implements Serializable { public static final Comparator<File> DEFAULT_COMPARATOR = new DefaultFileComparator(); public static final Comparator<File> DEFAULT_REVERSE = new ReverseComparator(DEFAULT_COMPARATOR); public int compare(File file1, File file2) { return file1.compareTo(file2); } } /* Location: * Qualified Name: org.apache.commons.io.comparator.DefaultFileComparator * Java Class Version: 6 (50.0) * JD-Core Version: 0.7.1 */ package org.apache.commons.io.comparator; import java.io.File; import java.io.Serializable; import java.util.Comparator; public class DirectoryFileComparator extends AbstractFileComparator implements Serializable { public static final Comparator<File> DIRECTORY_COMPARATOR = new DirectoryFileComparator(); public static final Comparator<File> DIRECTORY_REVERSE = new ReverseComparator(DIRECTORY_COMPARATOR); public int compare(File file1, File file2) { return getType(file1) - getType(file2); } private int getType(File file) { if (file.isDirectory()) { return 1; } return 2; } } /* Location: * Qualified Name: org.apache.commons.io.comparator.DirectoryFileComparator * Java Class Version: 6 (50.0) * JD-Core Version: 0.7.1 */ package org.apache.commons.io.comparator; import java.io.File; import java.io.Serializable; import java.util.Comparator; import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.IOCase; public class ExtensionFileComparator extends AbstractFileComparator implements Serializable { public static final Comparator<File> EXTENSION_COMPARATOR = new ExtensionFileComparator(); public static final Comparator<File> EXTENSION_REVERSE = new ReverseComparator(EXTENSION_COMPARATOR); public static final Comparator<File> EXTENSION_INSENSITIVE_COMPARATOR = new ExtensionFileComparator(IOCase.INSENSITIVE); public static final Comparator<File> EXTENSION_INSENSITIVE_REVERSE = new ReverseComparator(EXTENSION_INSENSITIVE_COMPARATOR); public static final Comparator<File> EXTENSION_SYSTEM_COMPARATOR = new ExtensionFileComparator(IOCase.SYSTEM); public static final Comparator<File> EXTENSION_SYSTEM_REVERSE = new ReverseComparator(EXTENSION_SYSTEM_COMPARATOR); private final IOCase caseSensitivity; public ExtensionFileComparator() { caseSensitivity = IOCase.SENSITIVE; } public ExtensionFileComparator(IOCase caseSensitivity) { this.caseSensitivity = (caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity); } public int compare(File file1, File file2) { String suffix1 = FilenameUtils.getExtension(file1.getName()); String suffix2 = FilenameUtils.getExtension(file2.getName()); return caseSensitivity.checkCompareTo(suffix1, suffix2); } public String toString() { return super.toString() + "[caseSensitivity=" + caseSensitivity + "]"; } } /* Location: * Qualified Name: org.apache.commons.io.comparator.ExtensionFileComparator * Java Class Version: 6 (50.0) * JD-Core Version: 0.7.1 */ package org.apache.commons.io.comparator; import java.io.File; import java.io.Serializable; import java.util.Comparator; public class LastModifiedFileComparator extends AbstractFileComparator implements Serializable { public static final Comparator<File> LASTMODIFIED_COMPARATOR = new LastModifiedFileComparator(); public static final Comparator<File> LASTMODIFIED_REVERSE = new ReverseComparator(LASTMODIFIED_COMPARATOR); public int compare(File file1, File file2) { long result = file1.lastModified() - file2.lastModified(); if (result < 0L) { return -1; } if (result > 0L) { return 1; } return 0; } } /* Location: * Qualified Name: org.apache.commons.io.comparator.LastModifiedFileComparator * Java Class Version: 6 (50.0) * JD-Core Version: 0.7.1 */ package org.apache.commons.io.comparator; import java.io.File; import java.io.Serializable; import java.util.Comparator; import org.apache.commons.io.IOCase; public class NameFileComparator extends AbstractFileComparator implements Serializable { public static final Comparator<File> NAME_COMPARATOR = new NameFileComparator(); public static final Comparator<File> NAME_REVERSE = new ReverseComparator(NAME_COMPARATOR); public static final Comparator<File> NAME_INSENSITIVE_COMPARATOR = new NameFileComparator(IOCase.INSENSITIVE); public static final Comparator<File> NAME_INSENSITIVE_REVERSE = new ReverseComparator(NAME_INSENSITIVE_COMPARATOR); public static final Comparator<File> NAME_SYSTEM_COMPARATOR = new NameFileComparator(IOCase.SYSTEM); public static final Comparator<File> NAME_SYSTEM_REVERSE = new ReverseComparator(NAME_SYSTEM_COMPARATOR); private final IOCase caseSensitivity; public NameFileComparator() { caseSensitivity = IOCase.SENSITIVE; } public NameFileComparator(IOCase caseSensitivity) { this.caseSensitivity = (caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity); } public int compare(File file1, File file2) { return caseSensitivity.checkCompareTo(file1.getName(), file2.getName()); } public String toString() { return super.toString() + "[caseSensitivity=" + caseSensitivity + "]"; } } /* Location: * Qualified Name: org.apache.commons.io.comparator.NameFileComparator * Java Class Version: 6 (50.0) * JD-Core Version: 0.7.1 */ package org.apache.commons.io.comparator; import java.io.File; import java.io.Serializable; import java.util.Comparator; import org.apache.commons.io.IOCase; public class PathFileComparator extends AbstractFileComparator implements Serializable { public static final Comparator<File> PATH_COMPARATOR = new PathFileComparator(); public static final Comparator<File> PATH_REVERSE = new ReverseComparator(PATH_COMPARATOR); public static final Comparator<File> PATH_INSENSITIVE_COMPARATOR = new PathFileComparator(IOCase.INSENSITIVE); public static final Comparator<File> PATH_INSENSITIVE_REVERSE = new ReverseComparator(PATH_INSENSITIVE_COMPARATOR); public static final Comparator<File> PATH_SYSTEM_COMPARATOR = new PathFileComparator(IOCase.SYSTEM); public static final Comparator<File> PATH_SYSTEM_REVERSE = new ReverseComparator(PATH_SYSTEM_COMPARATOR); private final IOCase caseSensitivity; public PathFileComparator() { caseSensitivity = IOCase.SENSITIVE; } public PathFileComparator(IOCase caseSensitivity) { this.caseSensitivity = (caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity); } public int compare(File file1, File file2) { return caseSensitivity.checkCompareTo(file1.getPath(), file2.getPath()); } public String toString() { return super.toString() + "[caseSensitivity=" + caseSensitivity + "]"; } } /* Location: * Qualified Name: org.apache.commons.io.comparator.PathFileComparator * Java Class Version: 6 (50.0) * JD-Core Version: 0.7.1 */ package org.apache.commons.io.comparator; import java.io.File; import java.io.Serializable; import java.util.Comparator; class ReverseComparator extends AbstractFileComparator implements Serializable { private final Comparator<File> delegate; public ReverseComparator(Comparator<File> delegate) { if (delegate == null) { throw new IllegalArgumentException("Delegate comparator is missing"); } this.delegate = delegate; } public int compare(File file1, File file2) { return delegate.compare(file2, file1); } public String toString() { return super.toString() + "[" + delegate.toString() + "]"; } } /* Location: * Qualified Name: org.apache.commons.io.comparator.ReverseComparator * Java Class Version: 6 (50.0) * JD-Core Version: 0.7.1 */ package org.apache.commons.io.comparator; import java.io.File; import java.io.Serializable; import java.util.Comparator; import org.apache.commons.io.FileUtils; public class SizeFileComparator extends AbstractFileComparator implements Serializable { public static final Comparator<File> SIZE_COMPARATOR = new SizeFileComparator(); public static final Comparator<File> SIZE_REVERSE = new ReverseComparator(SIZE_COMPARATOR); public static final Comparator<File> SIZE_SUMDIR_COMPARATOR = new SizeFileComparator(true); public static final Comparator<File> SIZE_SUMDIR_REVERSE = new ReverseComparator(SIZE_SUMDIR_COMPARATOR); private final boolean sumDirectoryContents; public SizeFileComparator() { sumDirectoryContents = false; } public SizeFileComparator(boolean sumDirectoryContents) { this.sumDirectoryContents = sumDirectoryContents; } public int compare(File file1, File file2) { long size1 = 0L; if (file1.isDirectory()) { size1 = (sumDirectoryContents) && (file1.exists()) ? FileUtils.sizeOfDirectory(file1) : 0L; } else { size1 = file1.length(); } long size2 = 0L; if (file2.isDirectory()) { size2 = (sumDirectoryContents) && (file2.exists()) ? FileUtils.sizeOfDirectory(file2) : 0L; } else { size2 = file2.length(); } long result = size1 - size2; if (result < 0L) { return -1; } if (result > 0L) { return 1; } return 0; } public String toString() { return super.toString() + "[sumDirectoryContents=" + sumDirectoryContents + "]"; } } /* Location: * Qualified Name: org.apache.commons.io.comparator.SizeFileComparator * Java Class Version: 6 (50.0) * JD-Core Version: 0.7.1 */ 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: 6 (50.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 final File file; private final int depth; 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: 6 (50.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<T> { 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.or(new IOFileFilter[] { directoryFilter, fileFilter }); } this.depthLimit = depthLimit; } protected final void walk(File startDirectory, Collection<T> 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<T> 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); childFiles = filterDirectoryContents(directory, depth, childFiles); if (childFiles == null) { handleRestricted(directory, childDepth, results); } else { for (File childFile : childFiles) { 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<T> results) throws IOException { if (handleIsCancelled(file, depth, results)) { throw new CancelException(file, depth); } } protected boolean handleIsCancelled(File file, int depth, Collection<T> results) throws IOException { return false; } protected void handleCancelled(File startDirectory, Collection<T> results, CancelException cancel) throws IOException { throw cancel; } protected void handleStart(File startDirectory, Collection<T> results) throws IOException {} protected boolean handleDirectory(File directory, int depth, Collection<T> results) throws IOException { return true; } protected void handleDirectoryStart(File directory, int depth, Collection<T> results) throws IOException {} protected File[] filterDirectoryContents(File directory, int depth, File[] files) throws IOException { return files; } protected void handleFile(File file, int depth, Collection<T> results) throws IOException {} protected void handleRestricted(File directory, int depth, Collection<T> results) throws IOException {} protected void handleDirectoryEnd(File directory, int depth, Collection<T> results) throws IOException {} protected void handleEnd(Collection<T> results) throws IOException {} public static class CancelException extends IOException { private static final long serialVersionUID = 1347339620135041008L; private final File file; private final int depth; 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: 6 (50.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: 6 (50.0) * JD-Core Version: 0.7.1 */ package org.apache.commons.io; import java.io.File; @Deprecated public class FileCleaner { static final FileCleaningTracker theInstance = new FileCleaningTracker(); @Deprecated public static void track(File file, Object marker) { theInstance.track(file, marker); } @Deprecated public static void track(File file, Object marker, FileDeleteStrategy deleteStrategy) { theInstance.track(file, marker, deleteStrategy); } @Deprecated public static void track(String path, Object marker) { theInstance.track(path, marker); } @Deprecated public static void track(String path, Object marker, FileDeleteStrategy deleteStrategy) { theInstance.track(path, marker, deleteStrategy); } @Deprecated public static int getTrackCount() { return theInstance.getTrackCount(); } @Deprecated public static synchronized void exitWhenFinished() { theInstance.exitWhenFinished(); } public static FileCleaningTracker getInstance() { return theInstance; } } /* Location: * Qualified Name: org.apache.commons.io.FileCleaner * Java Class Version: 6 (50.0) * JD-Core Version: 0.7.1 */ package org.apache.commons.io; import java.lang.ref.ReferenceQueue; import java.util.Collection; import java.util.List; final class FileCleaningTracker$Reaper extends Thread { FileCleaningTracker$Reaper(FileCleaningTracker paramFileCleaningTracker) { super("File Reaper"); setPriority(10); setDaemon(true); } public void run() { while ((!this$0.exitWhenFinished) || (this$0.trackers.size() > 0)) { try { FileCleaningTracker.Tracker tracker = (FileCleaningTracker.Tracker)this$0.q.remove(); this$0.trackers.remove(tracker); if (!tracker.delete()) { this$0.deleteFailures.add(tracker.getPath()); } tracker.clear(); } catch (InterruptedException e) {} } } } /* Location: * Qualified Name: org.apache.commons.io.FileCleaningTracker.Reaper * Java Class Version: 6 (50.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<Object> { private final String path; private final FileDeleteStrategy deleteStrategy; FileCleaningTracker$Tracker(String path, FileDeleteStrategy deleteStrategy, Object marker, ReferenceQueue<? super Object> queue) { super(marker, queue); this.path = path; this.deleteStrategy = (deleteStrategy == null ? FileDeleteStrategy.NORMAL : deleteStrategy); } public String getPath() { return path; } public boolean delete() { return deleteStrategy.deleteQuietly(new File(path)); } } /* Location: * Qualified Name: org.apache.commons.io.FileCleaningTracker.Tracker * Java Class Version: 6 (50.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.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.List; public class FileCleaningTracker { ReferenceQueue<Object> q; final Collection<Tracker> trackers; final List<String> deleteFailures; volatile boolean exitWhenFinished; Thread reaper; public FileCleaningTracker() { q = new ReferenceQueue(); trackers = Collections.synchronizedSet(new HashSet()); deleteFailures = Collections.synchronizedList(new ArrayList()); 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 List<String> getDeleteFailures() { return deleteFailures; } 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)) { try { FileCleaningTracker.Tracker tracker = (FileCleaningTracker.Tracker)q.remove(); trackers.remove(tracker); if (!tracker.delete()) { deleteFailures.add(tracker.getPath()); } tracker.clear(); } catch (InterruptedException e) {} } } } private static final class Tracker extends PhantomReference<Object> { private final String path; private final FileDeleteStrategy deleteStrategy; Tracker(String path, FileDeleteStrategy deleteStrategy, Object marker, ReferenceQueue<? super Object> queue) { super(queue); this.path = path; this.deleteStrategy = (deleteStrategy == null ? FileDeleteStrategy.NORMAL : deleteStrategy); } public String getPath() { return path; } public boolean delete() { return deleteStrategy.deleteQuietly(new File(path)); } } } /* Location: * Qualified Name: org.apache.commons.io.FileCleaningTracker * Java Class Version: 6 (50.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: 6 (50.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 + "]"; } 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
|