commons-lite-1.15

16:34:51.041 INFO  jd.cli.Main - Decompiling commons-lite-1.15.jar
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.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 localIOException)
    {
      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.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.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.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);
  }
  
  /* Error */
  public static void writeLines(File file, String encoding, Collection<String> lines)
    throws IOException
  {
    // Byte code:
    //   0: aload_2
    //   1: ifnonnull +4 -> 5
    //   4: return
    //   5: aconst_null
    //   6: astore_3
    //   7: aload_0
    //   8: invokestatic 137	org/apache/commons/io/FileUtils:openOutputStream	(Ljava/io/File;)Ljava/io/FileOutputStream;
    //   11: astore_3
    //   12: aload_2
    //   13: invokeinterface 139 1 0
    //   18: astore 5
    //   20: goto +41 -> 61
    //   23: aload 5
    //   25: invokeinterface 145 1 0
    //   30: astore 4
    //   32: aload 4
    //   34: ifnull +16 -> 50
    //   37: aload_3
    //   38: aload 4
    //   40: invokevirtual 151	java/lang/Object:toString	()Ljava/lang/String;
    //   43: aload_1
    //   44: invokevirtual 152	java/lang/String:getBytes	(Ljava/lang/String;)[B
    //   47: invokevirtual 158	java/io/OutputStream:write	([B)V
    //   50: aload_3
    //   51: getstatic 28	org/apache/commons/io/FileUtils:LINE_SEPARATOR	Ljava/lang/String;
    //   54: aload_1
    //   55: invokevirtual 152	java/lang/String:getBytes	(Ljava/lang/String;)[B
    //   58: invokevirtual 158	java/io/OutputStream:write	([B)V
    //   61: aload 5
    //   63: invokeinterface 164 1 0
    //   68: ifne -45 -> 23
    //   71: goto +12 -> 83
    //   74: astore 6
    //   76: aload_3
    //   77: invokestatic 167	org/apache/commons/io/IOUtils:closeQuietly	(Ljava/io/OutputStream;)V
    //   80: aload 6
    //   82: athrow
    //   83: aload_3
    //   84: invokestatic 167	org/apache/commons/io/IOUtils:closeQuietly	(Ljava/io/OutputStream;)V
    //   87: return
    // Line number table:
    //   Java source line #81	-> byte code offset #0
    //   Java source line #82	-> byte code offset #4
    //   Java source line #84	-> byte code offset #5
    //   Java source line #86	-> byte code offset #7
    //   Java source line #87	-> byte code offset #12
    //   Java source line #88	-> byte code offset #32
    //   Java source line #89	-> byte code offset #37
    //   Java source line #91	-> byte code offset #50
    //   Java source line #87	-> byte code offset #61
    //   Java source line #93	-> byte code offset #74
    //   Java source line #94	-> byte code offset #76
    //   Java source line #95	-> byte code offset #80
    //   Java source line #94	-> byte code offset #83
    //   Java source line #96	-> byte code offset #87
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	88	0	file	File
    //   0	88	1	encoding	String
    //   0	88	2	lines	Collection<String>
    //   6	78	3	output	java.io.OutputStream
    //   30	9	4	line	Object
    //   18	44	5	localIterator	java.util.Iterator
    //   74	7	6	localObject1	Object
    // Exception table:
    //   from	to	target	type
    //   7	74	74	finally
  }
  
  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);
    String[] arrayOfString;
    int j = (arrayOfString = exts).length;
    for (int i = 0; i < j; i++)
    {
      String ext = arrayOfString[i];
      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;
    }
    File[] arrayOfFile1;
    int j = (arrayOfFile1 = fs).length;
    for (int i = 0; i < j; i++)
    {
      File f = arrayOfFile1[i];
      if (f.isFile())
      {
        String name = f.getName();
        for (String ext : exts) {
          if (name.endsWith(ext))
          {
            list.add(f);
            break;
          }
        }
      }
      else if (r)
      {
        doFind(f, exts, list, r);
      }
    }
  }
  
  /* Error */
  public static void writeByteArrayToFile(File file, byte[] data)
    throws IOException
  {
    // Byte code:
    //   0: aconst_null
    //   1: astore_2
    //   2: aload_0
    //   3: invokestatic 137	org/apache/commons/io/FileUtils:openOutputStream	(Ljava/io/File;)Ljava/io/FileOutputStream;
    //   6: astore_2
    //   7: aload_2
    //   8: aload_1
    //   9: invokevirtual 158	java/io/OutputStream:write	([B)V
    //   12: goto +10 -> 22
    //   15: astore_3
    //   16: aload_2
    //   17: invokestatic 167	org/apache/commons/io/IOUtils:closeQuietly	(Ljava/io/OutputStream;)V
    //   20: aload_3
    //   21: athrow
    //   22: aload_2
    //   23: invokestatic 167	org/apache/commons/io/IOUtils:closeQuietly	(Ljava/io/OutputStream;)V
    //   26: return
    // Line number table:
    //   Java source line #133	-> byte code offset #0
    //   Java source line #135	-> byte code offset #2
    //   Java source line #136	-> byte code offset #7
    //   Java source line #137	-> byte code offset #15
    //   Java source line #138	-> byte code offset #16
    //   Java source line #139	-> byte code offset #20
    //   Java source line #138	-> byte code offset #22
    //   Java source line #140	-> byte code offset #26
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	27	0	file	File
    //   0	27	1	data	byte[]
    //   1	22	2	out	java.io.OutputStream
    //   15	6	3	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   2	15	15	finally
  }
  
  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;

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 localIOException) {}
  }
  
  public static void closeQuietly(OutputStream closeable)
  {
    try
    {
      if (closeable != null) {
        closeable.close();
      }
    }
    catch (IOException localIOException) {}
  }
  
  public static void closeQuietly(InputStream closeable)
  {
    try
    {
      if (closeable != null) {
        closeable.close();
      }
    }
    catch (IOException localIOException) {}
  }
}

/* Location:
 * Qualified Name:     org.apache.commons.io.IOUtils
 * 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
 */
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.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
 */
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