Java Code Examples for java.io.DataInput#readUnsignedShort()

The following examples show how to use java.io.DataInput#readUnsignedShort() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: coming   File: Cardumen_00136_s.java    License: MIT License 5 votes vote down vote up
static PrecalculatedZone readFrom(DataInput in, String id) throws IOException {
    // Read string pool.
    int poolSize = in.readUnsignedShort();
    String[] pool = new String[poolSize];
    for (int i=0; i<poolSize; i++) {
        pool[i] = in.readUTF();
    }

    int size = in.readInt();
    long[] transitions = new long[size];
    int[] wallOffsets = new int[size];
    int[] standardOffsets = new int[size];
    String[] nameKeys = new String[size];
    
    for (int i=0; i<size; i++) {
        transitions[i] = readMillis(in);
        wallOffsets[i] = (int)readMillis(in);
        standardOffsets[i] = (int)readMillis(in);
        try {
            int index;
            if (poolSize < 256) {
                index = in.readUnsignedByte();
            } else {
                index = in.readUnsignedShort();
            }
            nameKeys[i] = pool[index];
        } catch (ArrayIndexOutOfBoundsException e) {
            throw new IOException("Invalid encoding");
        }
    }

    DSTZone tailZone = null;
    if (in.readBoolean()) {
        tailZone = DSTZone.readFrom(in, id);
    }

    return new PrecalculatedZone
        (id, transitions, wallOffsets, standardOffsets, nameKeys, tailZone);
}
 
Example 2
Source Project: coming   File: jKali_0040_s.java    License: MIT License 5 votes vote down vote up
static PrecalculatedZone readFrom(DataInput in, String id) throws IOException {
    // Read string pool.
    int poolSize = in.readUnsignedShort();
    String[] pool = new String[poolSize];
    for (int i=0; i<poolSize; i++) {
        pool[i] = in.readUTF();
    }

    int size = in.readInt();
    long[] transitions = new long[size];
    int[] wallOffsets = new int[size];
    int[] standardOffsets = new int[size];
    String[] nameKeys = new String[size];
    
    for (int i=0; i<size; i++) {
        transitions[i] = readMillis(in);
        wallOffsets[i] = (int)readMillis(in);
        standardOffsets[i] = (int)readMillis(in);
        try {
            int index;
            if (poolSize < 256) {
                index = in.readUnsignedByte();
            } else {
                index = in.readUnsignedShort();
            }
            nameKeys[i] = pool[index];
        } catch (ArrayIndexOutOfBoundsException e) {
            throw new IOException("Invalid encoding");
        }
    }

    DSTZone tailZone = null;
    if (in.readBoolean()) {
        tailZone = DSTZone.readFrom(in, id);
    }

    return new PrecalculatedZone
        (id, transitions, wallOffsets, standardOffsets, nameKeys, tailZone);
}
 
Example 3
Source Project: coming   File: jMutRepair_0045_t.java    License: MIT License 5 votes vote down vote up
static PrecalculatedZone readFrom(DataInput in, String id) throws IOException {
    // Read string pool.
    int poolSize = in.readUnsignedShort();
    String[] pool = new String[poolSize];
    for (int i=0; i<poolSize; i++) {
        pool[i] = in.readUTF();
    }

    int size = in.readInt();
    long[] transitions = new long[size];
    int[] wallOffsets = new int[size];
    int[] standardOffsets = new int[size];
    String[] nameKeys = new String[size];
    
    for (int i=0; i<size; i++) {
        transitions[i] = readMillis(in);
        wallOffsets[i] = (int)readMillis(in);
        standardOffsets[i] = (int)readMillis(in);
        try {
            int index;
            if (poolSize < 256) {
                index = in.readUnsignedByte();
            } else {
                index = in.readUnsignedShort();
            }
            nameKeys[i] = pool[index];
        } catch (ArrayIndexOutOfBoundsException e) {
            throw new IOException("Invalid encoding");
        }
    }

    DSTZone tailZone = null;
    if (in.readBoolean()) {
        tailZone = DSTZone.readFrom(in, id);
    }

    return new PrecalculatedZone
        (id, transitions, wallOffsets, standardOffsets, nameKeys, tailZone);
}
 
Example 4
Source Project: coming   File: jMutRepair_0051_s.java    License: MIT License 5 votes vote down vote up
static PrecalculatedZone readFrom(DataInput in, String id) throws IOException {
    // Read string pool.
    int poolSize = in.readUnsignedShort();
    String[] pool = new String[poolSize];
    for (int i=0; i<poolSize; i++) {
        pool[i] = in.readUTF();
    }

    int size = in.readInt();
    long[] transitions = new long[size];
    int[] wallOffsets = new int[size];
    int[] standardOffsets = new int[size];
    String[] nameKeys = new String[size];
    
    for (int i=0; i<size; i++) {
        transitions[i] = readMillis(in);
        wallOffsets[i] = (int)readMillis(in);
        standardOffsets[i] = (int)readMillis(in);
        try {
            int index;
            if (poolSize < 256) {
                index = in.readUnsignedByte();
            } else {
                index = in.readUnsignedShort();
            }
            nameKeys[i] = pool[index];
        } catch (ArrayIndexOutOfBoundsException e) {
            throw new IOException("Invalid encoding");
        }
    }

    DSTZone tailZone = null;
    if (in.readBoolean()) {
        tailZone = DSTZone.readFrom(in, id);
    }

    return new PrecalculatedZone
        (id, transitions, wallOffsets, standardOffsets, nameKeys, tailZone);
}
 
Example 5
Source Project: coming   File: Cardumen_0069_t.java    License: MIT License 5 votes vote down vote up
static PrecalculatedZone readFrom(DataInput in, String id) throws IOException {
    // Read string pool.
    int poolSize = in.readUnsignedShort();
    String[] pool = new String[poolSize];
    for (int i=0; i<poolSize; i++) {
        pool[i] = in.readUTF();
    }

    int size = in.readInt();
    long[] transitions = new long[size];
    int[] wallOffsets = new int[size];
    int[] standardOffsets = new int[size];
    String[] nameKeys = new String[size];
    
    for (int i=0; i<size; i++) {
        transitions[i] = readMillis(in);
        wallOffsets[i] = (int)readMillis(in);
        standardOffsets[i] = (int)readMillis(in);
        try {
            int index;
            if (poolSize < 256) {
                index = in.readUnsignedByte();
            } else {
                index = in.readUnsignedShort();
            }
            nameKeys[i] = pool[index];
        } catch (ArrayIndexOutOfBoundsException e) {
            throw new IOException("Invalid encoding");
        }
    }

    DSTZone tailZone = null;
    if (in.readBoolean()) {
        tailZone = DSTZone.readFrom(in, id);
    }

    return new PrecalculatedZone
        (id, transitions, wallOffsets, standardOffsets, nameKeys, tailZone);
}
 
Example 6
Source Project: Bytecoder   File: LineNumberTable.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Construct object from input stream.
 * @param name_index Index of name
 * @param length Content length in bytes
 * @param input Input stream
 * @param constant_pool Array of constants
 * @throws IOEXception if an I/O Exception occurs in readUnsignedShort
 */
LineNumberTable(final int name_index, final int length, final DataInput input, final ConstantPool constant_pool)
        throws IOException {
    this(name_index, length, (LineNumber[]) null, constant_pool);
    final int line_number_table_length = input.readUnsignedShort();
    line_number_table = new LineNumber[line_number_table_length];
    for (int i = 0; i < line_number_table_length; i++) {
        line_number_table[i] = new LineNumber(input);
    }
}
 
Example 7
Source Project: coming   File: JGenProg2017_00141_t.java    License: MIT License 5 votes vote down vote up
static PrecalculatedZone readFrom(DataInput in, String id) throws IOException {
    // Read string pool.
    int poolSize = in.readUnsignedShort();
    String[] pool = new String[poolSize];
    for (int i=0; i<poolSize; i++) {
        pool[i] = in.readUTF();
    }

    int size = in.readInt();
    long[] transitions = new long[size];
    int[] wallOffsets = new int[size];
    int[] standardOffsets = new int[size];
    String[] nameKeys = new String[size];
    
    for (int i=0; i<size; i++) {
        transitions[i] = readMillis(in);
        wallOffsets[i] = (int)readMillis(in);
        standardOffsets[i] = (int)readMillis(in);
        try {
            int index;
            if (poolSize < 256) {
                index = in.readUnsignedByte();
            } else {
                index = in.readUnsignedShort();
            }
            nameKeys[i] = pool[index];
        } catch (ArrayIndexOutOfBoundsException e) {
            throw new IOException("Invalid encoding");
        }
    }

    DSTZone tailZone = null;
    if (in.readBoolean()) {
        tailZone = DSTZone.readFrom(in, id);
    }

    return new PrecalculatedZone
        (id, transitions, wallOffsets, standardOffsets, nameKeys, tailZone);
}
 
Example 8
Source Project: yGuard   File: BootstrapMethod.java    License: MIT License 5 votes vote down vote up
static BootstrapMethod read( final DataInput din ) throws IOException {
  int methodRef = din.readUnsignedShort();
  int numArguments = din.readUnsignedShort();
  int[] arguments = new int[numArguments];
  for (int i = 0; i < numArguments; ++i) {
    arguments[i] = din.readUnsignedShort();
  }
  return new BootstrapMethod(methodRef, arguments);
}
 
Example 9
/**
 * Reads the ModuleMainClass attribute
 */
private String readModuleMainClassAttribute(DataInput in, ConstantPool cpool)
    throws IOException
{
    int index = in.readUnsignedShort();
    return cpool.getClassName(index);
}
 
Example 10
Source Project: coming   File: Cardumen_00238_t.java    License: MIT License 5 votes vote down vote up
static PrecalculatedZone readFrom(DataInput in, String id) throws IOException {
    // Read string pool.
    int poolSize = in.readUnsignedShort();
    String[] pool = new String[poolSize];
    for (int i=0; i<poolSize; i++) {
        pool[i] = in.readUTF();
    }

    int size = in.readInt();
    long[] transitions = new long[size];
    int[] wallOffsets = new int[size];
    int[] standardOffsets = new int[size];
    String[] nameKeys = new String[size];
    
    for (int i=0; i<size; i++) {
        transitions[i] = readMillis(in);
        wallOffsets[i] = (int)readMillis(in);
        standardOffsets[i] = (int)readMillis(in);
        try {
            int index;
            if (poolSize < 256) {
                index = in.readUnsignedByte();
            } else {
                index = in.readUnsignedShort();
            }
            nameKeys[i] = pool[index];
        } catch (ArrayIndexOutOfBoundsException e) {
            throw new IOException("Invalid encoding");
        }
    }

    DSTZone tailZone = null;
    if (in.readBoolean()) {
        tailZone = DSTZone.readFrom(in, id);
    }

    return new PrecalculatedZone
        (id, transitions, wallOffsets, standardOffsets, nameKeys, tailZone);
}
 
Example 11
Source Project: yGuard   File: ParameterAnnotationInfo.java    License: MIT License 5 votes vote down vote up
private void read(DataInput din) throws java.io.IOException
{
  u2annotationCount = din.readUnsignedShort();
  annotations = new AnnotationInfo[u2annotationCount];
  for (int i = 0; i < u2annotationCount; i++)
  {
    annotations[i] = AnnotationInfo.create(din);
  }
}
 
Example 12
Source Project: spork   File: SedesHelper.java    License: Apache License 2.0 5 votes vote down vote up
public static byte[] readBytes(DataInput in, byte type) throws IOException {
   int sz = 0;
   switch(type) {
   case(BinInterSedes.TINYBYTEARRAY): sz = in.readUnsignedByte(); break;
   case(BinInterSedes.SMALLBYTEARRAY): sz = in.readUnsignedShort(); break;
   case(BinInterSedes.BYTEARRAY): sz = in.readInt(); break;
   }
   byte[] buf = new byte[sz];
   in.readFully(buf);
   return buf;
}
 
Example 13
Source Project: coming   File: Cardumen_00188_t.java    License: MIT License 5 votes vote down vote up
static PrecalculatedZone readFrom(DataInput in, String id) throws IOException {
    // Read string pool.
    int poolSize = in.readUnsignedShort();
    String[] pool = new String[poolSize];
    for (int i=0; i<poolSize; i++) {
        pool[i] = in.readUTF();
    }

    int size = in.readInt();
    long[] transitions = new long[size];
    int[] wallOffsets = new int[size];
    int[] standardOffsets = new int[size];
    String[] nameKeys = new String[size];
    
    for (int i=0; i<size; i++) {
        transitions[i] = readMillis(in);
        wallOffsets[i] = (int)readMillis(in);
        standardOffsets[i] = (int)readMillis(in);
        try {
            int index;
            if (poolSize < 256) {
                index = in.readUnsignedByte();
            } else {
                index = in.readUnsignedShort();
            }
            nameKeys[i] = pool[index];
        } catch (ArrayIndexOutOfBoundsException e) {
            throw new IOException("Invalid encoding");
        }
    }

    DSTZone tailZone = null;
    if (in.readBoolean()) {
        tailZone = DSTZone.readFrom(in, id);
    }

    return new PrecalculatedZone
        (id, transitions, wallOffsets, standardOffsets, nameKeys, tailZone);
}
 
Example 14
Source Project: coming   File: Arja_0048_s.java    License: MIT License 5 votes vote down vote up
static PrecalculatedZone readFrom(DataInput in, String id) throws IOException {
    // Read string pool.
    int poolSize = in.readUnsignedShort();
    String[] pool = new String[poolSize];
    for (int i=0; i<poolSize; i++) {
        pool[i] = in.readUTF();
    }

    int size = in.readInt();
    long[] transitions = new long[size];
    int[] wallOffsets = new int[size];
    int[] standardOffsets = new int[size];
    String[] nameKeys = new String[size];
    
    for (int i=0; i<size; i++) {
        transitions[i] = readMillis(in);
        wallOffsets[i] = (int)readMillis(in);
        standardOffsets[i] = (int)readMillis(in);
        try {
            int index;
            if (poolSize < 256) {
                index = in.readUnsignedByte();
            } else {
                index = in.readUnsignedShort();
            }
            nameKeys[i] = pool[index];
        } catch (ArrayIndexOutOfBoundsException e) {
            throw new IOException("Invalid encoding");
        }
    }

    DSTZone tailZone = null;
    if (in.readBoolean()) {
        tailZone = DSTZone.readFrom(in, id);
    }

    return new PrecalculatedZone
        (id, transitions, wallOffsets, standardOffsets, nameKeys, tailZone);
}
 
Example 15
Source Project: coming   File: Elixir_0038_s.java    License: MIT License 5 votes vote down vote up
static PrecalculatedZone readFrom(DataInput in, String id) throws IOException {
    // Read string pool.
    int poolSize = in.readUnsignedShort();
    String[] pool = new String[poolSize];
    for (int i=0; i<poolSize; i++) {
        pool[i] = in.readUTF();
    }

    int size = in.readInt();
    long[] transitions = new long[size];
    int[] wallOffsets = new int[size];
    int[] standardOffsets = new int[size];
    String[] nameKeys = new String[size];
    
    for (int i=0; i<size; i++) {
        transitions[i] = readMillis(in);
        wallOffsets[i] = (int)readMillis(in);
        standardOffsets[i] = (int)readMillis(in);
        try {
            int index;
            if (poolSize < 256) {
                index = in.readUnsignedByte();
            } else {
                index = in.readUnsignedShort();
            }
            nameKeys[i] = pool[index];
        } catch (ArrayIndexOutOfBoundsException e) {
            throw new IOException("Invalid encoding");
        }
    }

    DSTZone tailZone = null;
    if (in.readBoolean()) {
        tailZone = DSTZone.readFrom(in, id);
    }

    return new PrecalculatedZone
        (id, transitions, wallOffsets, standardOffsets, nameKeys, tailZone);
}
 
Example 16
Source Project: Bytecoder   File: Bytecode5xClassParser.java    License: Apache License 2.0 4 votes vote down vote up
private void parseConstantPool_CONSTANT_String(final DataInput aDis, final BytecodeConstantPool aConstantPool) throws IOException {
    final int theStringIndex = aDis.readUnsignedShort();
    aConstantPool.registerConstant(new BytecodeStringConstant(new BytecodeStringIndex(theStringIndex), aConstantPool));
}
 
Example 17
Source Project: yGuard   File: TypeAnnotationInfo.java    License: MIT License 4 votes vote down vote up
private void read(DataInput din) throws java.io.IOException {
  u2startPc = din.readUnsignedShort();
  u2length = din.readUnsignedShort();
  u2index = din.readUnsignedShort();
}
 
Example 18
Source Project: commons-bcel   File: ConstantModule.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Initialize instance from file data.
 *
 * @param file Input stream
 * @throws IOException
 */
ConstantModule(final DataInput file) throws IOException {
    this(file.readUnsignedShort());
}
 
Example 19
Source Project: Bytecoder   File: ConstantMethodHandle.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Initialize instance from file data.
 *
 * @param file Input stream
 * @throws IOException
 */
ConstantMethodHandle(final DataInput file) throws IOException {
    this(file.readUnsignedByte(), file.readUnsignedShort());
}
 
Example 20
Source Project: Bytecoder   File: CodeException.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Construct object from file stream.
 * @param file Input stream
 * @throws IOException
 */
CodeException(final DataInput file) throws IOException {
    this(file.readUnsignedShort(), file.readUnsignedShort(), file.readUnsignedShort(), file
            .readUnsignedShort());
}