commons-lite-1.12

16:34:50.585 INFO  jd.cli.Main - Decompiling commons-lite-1.12.jar
package org.apache.xmlgraphics.image.codec.util;

import java.io.DataInput;
import java.io.DataInputStream;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;

public abstract class SeekableStream
  extends InputStream
  implements DataInput
{
  protected long markPos = -1L;
  
  public abstract int read()
    throws IOException;
  
  public abstract int read(byte[] paramArrayOfByte, int paramInt1, int paramInt2)
    throws IOException;
  
  public synchronized void mark(int readLimit)
  {
    try
    {
      markPos = getFilePointer();
    }
    catch (IOException e)
    {
      markPos = -1L;
    }
  }
  
  public synchronized void reset()
    throws IOException
  {
    if (markPos != -1L) {
      seek(markPos);
    }
  }
  
  public boolean markSupported()
  {
    return canSeekBackwards();
  }
  
  public boolean canSeekBackwards()
  {
    return false;
  }
  
  public abstract long getFilePointer()
    throws IOException;
  
  public abstract void seek(long paramLong)
    throws IOException;
  
  public final void readFully(byte[] b)
    throws IOException
  {
    readFully(b, 0, b.length);
  }
  
  public final void readFully(byte[] b, int off, int len)
    throws IOException
  {
    int n = 0;
    do
    {
      int count = read(b, off + n, len - n);
      if (count < 0) {
        throw new EOFException();
      }
      n += count;
    } while (n < len);
  }
  
  public int skipBytes(int n)
    throws IOException
  {
    if (n <= 0) {
      return 0;
    }
    return (int)skip(n);
  }
  
  public final boolean readBoolean()
    throws IOException
  {
    int ch = read();
    if (ch < 0) {
      throw new EOFException();
    }
    return ch != 0;
  }
  
  public final byte readByte()
    throws IOException
  {
    int ch = read();
    if (ch < 0) {
      throw new EOFException();
    }
    return (byte)ch;
  }
  
  public final int readUnsignedByte()
    throws IOException
  {
    int ch = read();
    if (ch < 0) {
      throw new EOFException();
    }
    return ch;
  }
  
  public final short readShort()
    throws IOException
  {
    int ch1 = read();
    int ch2 = read();
    if ((ch1 | ch2) < 0) {
      throw new EOFException();
    }
    return (short)((ch1 << 8) + (ch2 << 0));
  }
  
  public final short readShortLE()
    throws IOException
  {
    int ch1 = read();
    int ch2 = read();
    if ((ch1 | ch2) < 0) {
      throw new EOFException();
    }
    return (short)((ch2 << 8) + (ch1 << 0));
  }
  
  public final int readUnsignedShort()
    throws IOException
  {
    int ch1 = read();
    int ch2 = read();
    if ((ch1 | ch2) < 0) {
      throw new EOFException();
    }
    return (ch1 << 8) + (ch2 << 0);
  }
  
  public final int readUnsignedShortLE()
    throws IOException
  {
    int ch1 = read();
    int ch2 = read();
    if ((ch1 | ch2) < 0) {
      throw new EOFException();
    }
    return (ch2 << 8) + (ch1 << 0);
  }
  
  public final char readChar()
    throws IOException
  {
    int ch1 = read();
    int ch2 = read();
    if ((ch1 | ch2) < 0) {
      throw new EOFException();
    }
    return (char)((ch1 << 8) + (ch2 << 0));
  }
  
  public final char readCharLE()
    throws IOException
  {
    int ch1 = read();
    int ch2 = read();
    if ((ch1 | ch2) < 0) {
      throw new EOFException();
    }
    return (char)((ch2 << 8) + (ch1 << 0));
  }
  
  public final int readInt()
    throws IOException
  {
    int ch1 = read();
    int ch2 = read();
    int ch3 = read();
    int ch4 = read();
    if ((ch1 | ch2 | ch3 | ch4) < 0) {
      throw new EOFException();
    }
    return (ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0);
  }
  
  public final int readIntLE()
    throws IOException
  {
    int ch1 = read();
    int ch2 = read();
    int ch3 = read();
    int ch4 = read();
    if ((ch1 | ch2 | ch3 | ch4) < 0) {
      throw new EOFException();
    }
    return (ch4 << 24) + (ch3 << 16) + (ch2 << 8) + (ch1 << 0);
  }
  
  public final long readUnsignedInt()
    throws IOException
  {
    long ch1 = read();
    long ch2 = read();
    long ch3 = read();
    long ch4 = read();
    if ((ch1 | ch2 | ch3 | ch4) < 0L) {
      throw new EOFException();
    }
    return (ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0);
  }
  
  private byte[] ruileBuf = new byte[4];
  
  public final long readUnsignedIntLE()
    throws IOException
  {
    readFully(ruileBuf);
    long ch1 = ruileBuf[0] & 0xFF;
    long ch2 = ruileBuf[1] & 0xFF;
    long ch3 = ruileBuf[2] & 0xFF;
    long ch4 = ruileBuf[3] & 0xFF;
    
    return (ch4 << 24) + (ch3 << 16) + (ch2 << 8) + (ch1 << 0);
  }
  
  public final long readLong()
    throws IOException
  {
    return (readInt() << 32) + (readInt() & 0xFFFFFFFF);
  }
  
  public final long readLongLE()
    throws IOException
  {
    int i1 = readIntLE();
    int i2 = readIntLE();
    return (i2 << 32) + (i1 & 0xFFFFFFFF);
  }
  
  public final float readFloat()
    throws IOException
  {
    return Float.intBitsToFloat(readInt());
  }
  
  public final float readFloatLE()
    throws IOException
  {
    return Float.intBitsToFloat(readIntLE());
  }
  
  public final double readDouble()
    throws IOException
  {
    return Double.longBitsToDouble(readLong());
  }
  
  public final double readDoubleLE()
    throws IOException
  {
    return Double.longBitsToDouble(readLongLE());
  }
  
  public final String readLine()
    throws IOException
  {
    StringBuffer input = new StringBuffer();
    int c = -1;
    boolean eol = false;
    while (!eol)
    {
      c = read();
      switch (c)
      {
      case -1: 
      case 10: 
        eol = true;
        break;
      case 13: 
        eol = true;
        long cur = getFilePointer();
        if (read() != 10) {
          seek(cur);
        }
        break;
      default: 
        input.append((char)c);
      }
    }
    if ((c == -1) && (input.length() == 0)) {
      return null;
    }
    return input.toString();
  }
  
  public final String readUTF()
    throws IOException
  {
    return DataInputStream.readUTF(this);
  }
  
  protected void finalize()
    throws Throwable
  {
    super.finalize();
    close();
  }
}

/* Location:
 * Qualified Name:     org.apache.xmlgraphics.image.codec.util.SeekableStream
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.xmlgraphics.image.codec.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

public final class MemoryCacheSeekableStream
  extends SeekableStream
{
  private InputStream src;
  private long pointer = 0L;
  private static final int SECTOR_SHIFT = 9;
  private static final int SECTOR_SIZE = 512;
  private static final int SECTOR_MASK = 511;
  private List data = new ArrayList();
  int sectors = 0;
  int length = 0;
  boolean foundEOS = false;
  
  public MemoryCacheSeekableStream(InputStream src)
  {
    this.src = src;
  }
  
  private long readUntil(long pos)
    throws IOException
  {
    if (pos < length) {
      return pos;
    }
    if (foundEOS) {
      return length;
    }
    int sector = (int)(pos >> 9);
    
    int startSector = length >> 9;
    for (int i = startSector; i <= sector; i++)
    {
      byte[] buf = new byte['?'];
      data.add(buf);
      
      int len = 512;
      int off = 0;
      while (len > 0)
      {
        int nbytes = src.read(buf, off, len);
        if (nbytes == -1)
        {
          foundEOS = true;
          return length;
        }
        off += nbytes;
        len -= nbytes;
        
        length += nbytes;
      }
    }
    return length;
  }
  
  public boolean canSeekBackwards()
  {
    return true;
  }
  
  public long getFilePointer()
  {
    return pointer;
  }
  
  public void seek(long pos)
    throws IOException
  {
    if (pos < 0L) {
      throw new IOException("MemoryCacheSeekableStream0");
    }
    pointer = pos;
  }
  
  public int read()
    throws IOException
  {
    long next = pointer + 1L;
    long pos = readUntil(next);
    if (pos >= next)
    {
      byte[] buf = (byte[])data.get((int)(pointer >> 9));
      
      return buf[((int)(pointer++ & 0x1FF))] & 0xFF;
    }
    return -1;
  }
  
  public int read(byte[] b, int off, int len)
    throws IOException
  {
    if (b == null) {
      throw new NullPointerException();
    }
    if ((off < 0) || (len < 0) || (off + len > b.length)) {
      throw new IndexOutOfBoundsException();
    }
    if (len == 0) {
      return 0;
    }
    long pos = readUntil(pointer + len);
    if (pos <= pointer) {
      return -1;
    }
    byte[] buf = (byte[])data.get((int)(pointer >> 9));
    int nbytes = Math.min(len, 512 - (int)(pointer & 0x1FF));
    System.arraycopy(buf, (int)(pointer & 0x1FF), b, off, nbytes);
    
    pointer += nbytes;
    return nbytes;
  }
}

/* Location:
 * Qualified Name:     org.apache.xmlgraphics.image.codec.util.MemoryCacheSeekableStream
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.io;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class FileUtils
{
  public static final String LINE_SEPARATOR;
  
  static
  {
    StringWriter buf = new StringWriter(4);
    PrintWriter out = new PrintWriter(buf);
    out.println();
    LINE_SEPARATOR = buf.toString();
    out.close();
  }
  
  public static byte[] readFileToByteArray(File file)
    throws IOException
  {
    InputStream in = null;
    try
    {
      in = openInputStream(file);
      return IOUtils.toByteArray(in);
    }
    finally
    {
      IOUtils.closeQuietly(in);
    }
  }
  
  public static FileInputStream openInputStream(File file)
    throws IOException
  {
    if (file.exists())
    {
      if (file.isDirectory()) {
        throw new IOException("File '" + file + "' exists but is a directory");
      }
      if (!file.canRead()) {
        throw new IOException("File '" + file + "' cannot be read");
      }
    }
    else
    {
      throw new FileNotFoundException("File '" + file + "' does not exist");
    }
    return new FileInputStream(file);
  }
  
  public static FileOutputStream openOutputStream(File file)
    throws IOException
  {
    if (file.exists())
    {
      if (file.isDirectory()) {
        throw new IOException("File '" + file + "' exists but is a directory");
      }
      if (!file.canWrite()) {
        throw new IOException("File '" + file + "' cannot be written to");
      }
    }
    else
    {
      File parent = file.getParentFile();
      if ((parent != null) && (!parent.exists()) && 
        (!parent.mkdirs())) {
        throw new IOException("File '" + file + "' could not be created");
      }
    }
    return new FileOutputStream(file);
  }
  
  public static void writeLines(File file, String encoding, Collection<String> lines)
    throws IOException
  {
    if (lines == null) {
      return;
    }
    OutputStream output = null;
    try
    {
      output = openOutputStream(file);
      for (Object line : lines)
      {
        if (line != null) {
          output.write(line.toString().getBytes(encoding));
        }
        output.write(LINE_SEPARATOR.getBytes(encoding));
      }
    }
    finally
    {
      IOUtils.closeQuietly(output);
    }
  }
  
  public static Collection<File> listFiles(File dir, String[] exts, boolean r)
  {
    if (exts.length == 0) {
      return Collections.EMPTY_LIST;
    }
    Set<String> set = new HashSet(exts.length);
    for (String ext : exts) {
      set.add("." + ext);
    }
    List<File> list = new ArrayList();
    doFind(dir, set, list, r);
    return list;
  }
  
  private static void doFind(File dir, Set<String> exts, List<File> list, boolean r)
  {
    File[] fs = dir.listFiles();
    if (fs == null) {
      return;
    }
    for (File f : fs)
    {
      String name;
      if (f.isFile())
      {
        name = f.getName();
        for (String ext : exts) {
          if (name.endsWith(ext))
          {
            list.add(f);
            break;
          }
        }
      }
      else if (r)
      {
        doFind(f, exts, list, r);
      }
    }
  }
  
  public static void writeByteArrayToFile(File file, byte[] data)
    throws IOException
  {
    OutputStream out = null;
    try
    {
      out = openOutputStream(file);
      out.write(data);
    }
    finally
    {
      IOUtils.closeQuietly(out);
    }
  }
  
  public static void writeStringToFile(File file, String str, String encoding)
    throws IOException
  {
    writeByteArrayToFile(file, str.getBytes(encoding));
  }
  
  public static String readFileToString(File file, String charset)
    throws IOException
  {
    return new String(readFileToByteArray(file), charset);
  }
  
  public static List<String> readLines(File file, String encoding)
    throws IOException
  {
    BufferedReader reader = new BufferedReader(new InputStreamReader(openInputStream(file), encoding));
    try
    {
      List<String> list = new ArrayList();
      String line = reader.readLine();
      while (line != null)
      {
        list.add(line);
        line = reader.readLine();
      }
      return list;
    }
    finally
    {
      IOUtils.closeQuietly(reader);
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.io.FileUtils
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.io;

public class FilenameUtils
{
  public static String getBaseName(String n)
  {
    n = n.replace('\\', '/');
    int i = n.lastIndexOf('/');
    if (i >= 0) {
      n = n.substring(i + 1);
    }
    i = n.lastIndexOf('.');
    if (i >= 0) {
      n = n.substring(0, i);
    }
    return n;
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.io.FilenameUtils
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.io;

import java.io.ByteArrayOutputStream;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class IOUtils
{
  private static final int DEFAULT_BUFFER_SIZE = 4096;
  
  public static long copyLarge(InputStream input, OutputStream output)
    throws IOException
  {
    byte[] buffer = new byte['?'];
    long count = 0L;
    int n = 0;
    while (-1 != (n = input.read(buffer)))
    {
      output.write(buffer, 0, n);
      count += n;
    }
    return count;
  }
  
  public static int copy(InputStream input, OutputStream output)
    throws IOException
  {
    return (int)copyLarge(input, output);
  }
  
  public static byte[] toByteArray(InputStream input)
    throws IOException
  {
    ByteArrayOutputStream output = new ByteArrayOutputStream(51200);
    copyLarge(input, output);
    return output.toByteArray();
  }
  
  public static void closeQuietly(Closeable closeable)
  {
    try
    {
      if (closeable != null) {
        closeable.close();
      }
    }
    catch (IOException ioe) {}
  }
  
  public static void closeQuietly(OutputStream closeable)
  {
    try
    {
      if (closeable != null) {
        closeable.close();
      }
    }
    catch (IOException ioe) {}
  }
  
  public static void closeQuietly(InputStream closeable)
  {
    try
    {
      if (closeable != null) {
        closeable.close();
      }
    }
    catch (IOException ioe) {}
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.io.IOUtils
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.codec.binary;

public class Hex
{
  private static final char[] DIGITS_LOWER = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
  
  public static char[] encodeHex(byte[] data)
  {
    return encodeHex(data, DIGITS_LOWER);
  }
  
  protected static char[] encodeHex(byte[] data, char[] toDigits)
  {
    int l = data.length;
    char[] out = new char[l << 1];
    
    int i = 0;
    for (int j = 0; i < l; i++)
    {
      out[(j++)] = toDigits[((0xF0 & data[i]) >>> 4)];
      out[(j++)] = toDigits[(0xF & data[i])];
    }
    return out;
  }
  
  public static byte[] decodeHex(char[] data)
  {
    int len = data.length;
    if ((len & 0x1) != 0) {
      throw new RuntimeException("Odd number of characters.");
    }
    byte[] out = new byte[len >> 1];
    
    int i = 0;
    for (int j = 0; j < len; i++)
    {
      int f = toDigit(data[j], j) << 4;
      j++;
      f |= toDigit(data[j], j);
      j++;
      out[i] = ((byte)(f & 0xFF));
    }
    return out;
  }
  
  protected static int toDigit(char ch, int index)
  {
    int digit = Character.digit(ch, 16);
    if (digit == -1) {
      throw new RuntimeException("Illegal hexadecimal character " + ch + " at index " + index);
    }
    return digit;
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.codec.binary.Hex
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.collections;

public abstract interface Transformer
{
  public abstract Object transform(Object paramObject);
}

/* Location:
 * Qualified Name:     org.apache.commons.collections.Transformer
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.commons.collections.map;

import java.util.AbstractMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.apache.commons.collections.Transformer;

public class LazyMap<K, V>
  extends AbstractMap<K, V>
{
  private Map<K, V> map;
  private Transformer factory;
  
  public LazyMap(Map<K, V> map, Transformer factor)
  {
    this.map = map;
    factory = factor;
  }
  
  public static <K, V> Map<K, V> decorate(Map<K, V> map, Transformer factory)
  {
    return new LazyMap(map, factory);
  }
  
  public Set<Map.Entry<K, V>> entrySet()
  {
    throw new UnsupportedOperationException();
  }
  
  public V get(Object key)
  {
    if (!map.containsKey(key))
    {
      V value = factory.transform(key);
      map.put(key, value);
      return value;
    }
    return (V)map.get(key);
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.collections.map.LazyMap
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
1

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-2019. Infinite Loop Ltd