Package org.apache.harmony.archive.internal.pack200

Examples of org.apache.harmony.archive.internal.pack200.RunCodec


    for(int i=0;i<fields.length;i++) {
      // write method info
    }
    dos.writeShort(attributes.length);
    for(int i=0;i<attributes.length;i++) {
      Attribute a = attributes[i];
      a.write(dos);
    }
  }
View Full Code Here


    classFile.superClass = cp.indexOf(cfSuper);
    // TODO placate format of file for writing purposes
    classFile.interfaces = new int[0];
    classFile.fields = new int[0];
    classFile.methods = new int[0];
    SourceFile sf;
    classFile.attributes = new ClassFileEntry.Attribute[] { sf = new ClassFileEntry.SourceFile(classThis[classNum+ ".java") };
    cp.add(sf);

    // sort CP according to cp_All
    cp.resolve();
View Full Code Here


public abstract class ClassFileEntry {
  static abstract class Attribute extends ClassFileEntry {
    public Attribute(String attributeName) {
      this.attributeName = new UTF8(attributeName);
    }
View Full Code Here

  static class SourceFile extends Attribute {
    private UTF8 name;
    public int nameIndex;
    public SourceFile(String name) {
      super("SourceFile"); //$NON-NLS-1$
      this.name = new UTF8(name);
    }
View Full Code Here

  public Object getValue(long value, Segment segment) throws Pack200Exception {
    if (layout.startsWith("R")) {
      // references
      if (layout.indexOf('N') != -1)
        value--;
      SegmentConstantPool pool = segment.getConstantPool();
      if (layout.startsWith("RU")) {
        return pool.getValue(SegmentConstantPool.UTF_8, value);
      } else if (layout.startsWith("RS")) {
        return pool.getValue(SegmentConstantPool.SIGNATURE, value);
      }
    }
    throw new Pack200Exception("Unknown layout encoding: " + layout);
  }
View Full Code Here

        assertFalse(byte2s.encodes(192));
        assertFalse(byte2s.encodes(256));
    }

    public void testRunCodec() throws Exception {
        RunCodec runCodec = new RunCodec(1, Codec.UNSIGNED5, Codec.BYTE1);
        ByteArrayInputStream bais = new ByteArrayInputStream(new byte[] {
                (byte) 192, 0, (byte) 192, 0 });
        assertEquals(192, runCodec.decode(bais));
        assertEquals(192, runCodec.decode(bais));
        assertEquals(0, runCodec.decode(bais));
        assertEquals(0, bais.available());
        runCodec = new RunCodec(1, Codec.BYTE1, Codec.UNSIGNED5);
        bais = new ByteArrayInputStream(new byte[] { (byte) 192, 0, (byte) 192,
                0 });
        assertEquals(192, runCodec.decode(bais));
        assertEquals(0, runCodec.decode(bais));
        assertEquals(192, runCodec.decode(bais));
        assertEquals(0, bais.available());
    }
View Full Code Here

    assertFalse(byte2s.encodes(192));
    assertFalse(byte2s.encodes(256));   
  }

  public void testRunCodec() throws Exception {
    RunCodec runCodec = new RunCodec(1,Codec.UNSIGNED5,Codec.BYTE1);
    ByteArrayInputStream bais = new ByteArrayInputStream(new byte[]{ (byte) 192,0,(byte) 192,0});
    assertEquals(192,runCodec.decode(bais));
    assertEquals(192,runCodec.decode(bais));
    assertEquals(0,runCodec.decode(bais));
    assertEquals(0,bais.available());
    runCodec = new RunCodec(1,Codec.BYTE1,Codec.UNSIGNED5);
    bais = new ByteArrayInputStream(new byte[]{ (byte) 192,0,(byte) 192,0});
    assertEquals(192,runCodec.decode(bais));
    assertEquals(0,runCodec.decode(bais));
    assertEquals(192,runCodec.decode(bais));
    assertEquals(0,bais.available());
  }
View Full Code Here

        assertFalse(byte2s.encodes(192));
        assertFalse(byte2s.encodes(256));
    }

    public void testRunCodec() throws Exception {
        RunCodec runCodec = new RunCodec(1, Codec.UNSIGNED5, Codec.BYTE1);
        ByteArrayInputStream bais = new ByteArrayInputStream(new byte[] {
                (byte) 192, 0, (byte) 192, 0 });
        assertEquals(192, runCodec.decode(bais));
        assertEquals(192, runCodec.decode(bais));
        assertEquals(0, runCodec.decode(bais));
        assertEquals(0, bais.available());
        runCodec = new RunCodec(1, Codec.BYTE1, Codec.UNSIGNED5);
        bais = new ByteArrayInputStream(new byte[] { (byte) 192, 0, (byte) 192,
                0 });
        assertEquals(192, runCodec.decode(bais));
        assertEquals(0, runCodec.decode(bais));
        assertEquals(192, runCodec.decode(bais));
        assertEquals(0, bais.available());
    }
View Full Code Here

        assertFalse(byte2s.encodes(192));
        assertFalse(byte2s.encodes(256));
    }

    public void testRunCodec() throws Exception {
        RunCodec runCodec = new RunCodec(1, Codec.UNSIGNED5, Codec.BYTE1);
        ByteArrayInputStream bais = new ByteArrayInputStream(new byte[] {
                (byte) 192, 0, (byte) 192, 0 });
        assertEquals(192, runCodec.decode(bais));
        assertEquals(192, runCodec.decode(bais));
        assertEquals(0, runCodec.decode(bais));
        assertEquals(0, bais.available());
        runCodec = new RunCodec(1, Codec.BYTE1, Codec.UNSIGNED5);
        bais = new ByteArrayInputStream(new byte[] { (byte) 192, 0, (byte) 192,
                0 });
        assertEquals(192, runCodec.decode(bais));
        assertEquals(0, runCodec.decode(bais));
        assertEquals(192, runCodec.decode(bais));
        assertEquals(0, bais.available());
    }
View Full Code Here

    assertFalse(byte2s.encodes(192));
    assertFalse(byte2s.encodes(256));
  }

  public void testRunCodec() throws Exception {
    RunCodec runCodec = new RunCodec(1,Codec.UNSIGNED5,Codec.BYTE1);
    ByteArrayInputStream bais = new ByteArrayInputStream(new byte[]{ (byte) 192,0,(byte) 192,0});
    assertEquals(192,runCodec.decode(bais));
    assertEquals(192,runCodec.decode(bais));
    assertEquals(0,runCodec.decode(bais));
    assertEquals(0,bais.available());
    runCodec = new RunCodec(1,Codec.BYTE1,Codec.UNSIGNED5);
    bais = new ByteArrayInputStream(new byte[]{ (byte) 192,0,(byte) 192,0});
    assertEquals(192,runCodec.decode(bais));
    assertEquals(0,runCodec.decode(bais));
    assertEquals(192,runCodec.decode(bais));
    assertEquals(0,bais.available());
  }
View Full Code Here

TOP

Related Classes of org.apache.harmony.archive.internal.pack200.RunCodec

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.