Ejemplo n.º 1
0
  /** Creates new PostTable */
  protected PostTable(final DirectoryEntry de, final DataInput di) throws IOException {
    this.de = (DirectoryEntry) de.clone();
    version = di.readInt();
    italicAngle = di.readInt();
    underlinePosition = di.readShort();
    underlineThickness = di.readShort();
    isFixedPitch = di.readInt();
    minMemType42 = di.readInt();
    maxMemType42 = di.readInt();
    minMemType1 = di.readInt();
    maxMemType1 = di.readInt();

    if (version == 0x00020000) {
      numGlyphs = di.readUnsignedShort();
      glyphNameIndex = new int[numGlyphs];
      for (int i = 0; i < numGlyphs; i++) {
        glyphNameIndex[i] = di.readUnsignedShort();
      }
      int h = highestGlyphNameIndex();
      if (h > 257) {
        h -= 257;
        psGlyphName = new String[h];
        for (int i = 0; i < h; i++) {
          final int len = di.readUnsignedByte();
          final byte[] buf = new byte[len];
          di.readFully(buf);
          psGlyphName[i] = new String(buf);
        }
      }
      // } else if (version == 0x00025000) {
      // } else if (version == 0x00030000) {
    }
  }
Ejemplo n.º 2
0
  /** Creates new ResourceMap */
  public ResourceMap(DataInput di) throws IOException {
    di.readFully(headerCopy);
    nextResourceMap = di.readInt();
    fileReferenceNumber = di.readUnsignedShort();
    attributes = di.readUnsignedShort();
    int typeOffset = di.readUnsignedShort();
    int nameOffset = di.readUnsignedShort();
    int typeCount = di.readUnsignedShort() + 1;

    // Read types
    types = new ResourceType[typeCount];
    for (int i = 0; i < typeCount; i++) {
      types[i] = new ResourceType(di);
    }

    // Read the references
    for (int i = 0; i < typeCount; i++) {
      types[i].readRefs(di);
    }

    // Read the names
    for (int i = 0; i < typeCount; i++) {
      types[i].readNames(di);
    }
  }
Ejemplo n.º 3
0
 /**
  * Construct object from file stream.
  *
  * @param file Input stream
  * @throws IOException
  */
 InnerClass(DataInput file) throws IOException {
   this(
       file.readUnsignedShort(),
       file.readUnsignedShort(),
       file.readUnsignedShort(),
       file.readUnsignedShort());
 }
Ejemplo n.º 4
0
 void read(DataInput in) throws IOException {
   setStartPc(in.readUnsignedShort());
   setLength(in.readUnsignedShort());
   setNameIndex(in.readUnsignedShort());
   setTypeIndex(in.readUnsignedShort());
   setLocal(in.readUnsignedShort());
 }
Ejemplo n.º 5
0
  public void read(DataInput in) throws InvalidByteCodeException, IOException {

    startPc = in.readUnsignedShort();
    endPc = in.readUnsignedShort();
    handlerPc = in.readUnsignedShort();
    catchType = in.readUnsignedShort();
    if (debug) debug("read ");
  }
Ejemplo n.º 6
0
 private void readVersion(final DataInput di) throws IOException {
   // sequence: minor version, major version (argument_index is 1-based)
   if (DEBUG) {
     print("Java Class version %2$d.%1$d", di.readUnsignedShort(), di.readUnsignedShort());
   } else {
     di.skipBytes(4);
   }
 }
Ejemplo n.º 7
0
  public void read(DataInput in) throws InvalidByteCodeException, IOException {

    innerClassInfoIndex = in.readUnsignedShort();
    outerClassInfoIndex = in.readUnsignedShort();
    innerNameIndex = in.readUnsignedShort();
    innerClassAccessFlags = in.readUnsignedShort();

    if (debug) debug("read ");
  }
Ejemplo n.º 8
0
 /**
  * Construct object from file stream.
  *
  * @param file Input stream
  * @throws IOException
  */
 LocalVariable(DataInput file, ConstantPool constant_pool) throws IOException {
   this(
       file.readUnsignedShort(),
       file.readUnsignedShort(),
       file.readUnsignedShort(),
       file.readUnsignedShort(),
       file.readUnsignedShort(),
       constant_pool);
 }
Ejemplo n.º 9
0
 protected MinMax(int minMaxOffset) throws IOException {
   DataInput di = getDataInputForOffset(minMaxOffset);
   _minCoordOffset = di.readUnsignedShort();
   _maxCoordOffset = di.readUnsignedShort();
   _featMinMaxCount = di.readUnsignedShort();
   _featMinMaxRecord = new FeatMinMaxRecord[_featMinMaxCount];
   for (int i = 0; i < _featMinMaxCount; ++i) {
     _featMinMaxRecord[i] = new FeatMinMaxRecord(di);
   }
 }
Ejemplo n.º 10
0
 public void readFrom(DataInput din) throws IOException {
   if (!isHeadless()) {
     setTransactionID(din.readUnsignedShort());
     setProtocolID(din.readUnsignedShort());
     m_DataLength = din.readUnsignedShort();
   }
   setUnitID(din.readUnsignedByte());
   setFunctionCode(din.readUnsignedByte());
   readData(din);
 } // readFrom
Ejemplo n.º 11
0
 protected Axis(int axisOffset) throws IOException {
   _thisOffset = axisOffset;
   DataInput di = getDataInputForOffset(axisOffset);
   _baseTagListOffset = di.readUnsignedShort();
   _baseScriptListOffset = di.readUnsignedShort();
   if (_baseTagListOffset != 0) {
     _baseTagList = new BaseTagList(axisOffset + _baseTagListOffset);
   }
   if (_baseScriptListOffset != 0) {
     _baseScriptList = new BaseScriptList(axisOffset + _baseScriptListOffset);
   }
 }
Ejemplo n.º 12
0
  static Attribute define(ConstantPool cp, String name, int length, DataInput din)
      throws IOException {

    LineNumberTableAttr lineNumbers = new LineNumberTableAttr(cp);

    int size = din.readUnsignedShort();
    for (int i = 0; i < size; i++) {
      int start_pc = din.readUnsignedShort();
      int line_number = din.readUnsignedShort();

      lineNumbers.addEntry(new FixedLocation(start_pc), line_number);
    }

    return lineNumbers;
  }
Ejemplo n.º 13
0
  private void readAnnotations(final DataInput di, final char reporterType) throws IOException {

    // the number of Runtime(In)VisibleAnnotations
    final int count = di.readUnsignedShort();
    if (DEBUG) {
      print("annotation count (%s) = %d", reporterType, count);
    }
    for (int i = 0; i < count; ++i) {
      final String rawTypeName = readAnnotation(di);
      final Class<? extends Annotation> type = annotations.get(rawTypeName);
      if (type == null) {
        continue;
      }
      final String externalTypeName = typeName.replace('/', '.');
      switch (reporterType) {
        case 'T':
          typeReporter.reportTypeAnnotation(type, externalTypeName);
          break;
        case 'F':
          fieldReporter.reportFieldAnnotation(type, externalTypeName, memberName);
          break;
        case 'M':
          methodReporter.reportMethodAnnotation(type, externalTypeName, memberName);
          break;
        default:
          throw new AssertionError("reporterType=" + reporterType);
      }
    }
  }
Ejemplo n.º 14
0
  @Override
  public void parseFromDataInput(DataInput read) throws IOException {
    this.buildVersion = read.readUTF();
    this.gameId = read.readInt();
    this.guid = read.readUTF();
    this.password = read.readUTF();
    secret = read.readUTF();
    keyTime = read.readInt();
    int size = read.readUnsignedShort();
    if (size > 0) {
      key = new byte[size];
      read.readFully(key);
    }

    size = read.readInt();
    if (size > 0) {
      byte[] buf = new byte[size];
      read.readFully(buf);
      unkStr = new String(buf, Charset.forName("UTF-8"));
    }

    pk = read.readUTF();
    Tq = read.readUTF();
    H = read.readUTF();
    playPlatform = read.readUTF();
  }
Ejemplo n.º 15
0
  /** Return {@code true} if a double slot is read (in case of Double or Long constant). */
  private boolean readConstantPoolEntry(final DataInput di, final int index) throws IOException {

    final int tag = di.readUnsignedByte();
    switch (tag) {
      case CP_METHOD_TYPE:
        di.skipBytes(2); // readUnsignedShort()
        return false;
      case CP_METHOD_HANDLE:
        di.skipBytes(3);
        return false;
      case CP_INTEGER:
      case CP_FLOAT:
      case CP_REF_FIELD:
      case CP_REF_METHOD:
      case CP_REF_INTERFACE:
      case CP_NAME_AND_TYPE:
      case CP_INVOKE_DYNAMIC:
        di.skipBytes(4); // readInt() / readFloat() / readUnsignedShort() * 2
        return false;
      case CP_LONG:
      case CP_DOUBLE:
        di.skipBytes(8); // readLong() / readDouble()
        return true;
      case CP_UTF8:
        constantPool[index] = di.readUTF();
        return false;
      case CP_CLASS:
      case CP_STRING:
        // reference to CP_UTF8 entry. The referenced index can have a higher number!
        constantPool[index] = di.readUnsignedShort();
        return false;
      default:
        throw new ClassFormatError("Unkown tag value for constant pool entry: " + tag);
    }
  }
Ejemplo n.º 16
0
 /**
  * @param file Input stream
  * @param constant_pool Array of constants
  */
 Annotations(DataInput file, ConstantPool constant_pool) throws IOException {
   final int annotation_table_length = (file.readUnsignedShort());
   annotation_table = new AnnotationEntry[annotation_table_length];
   for (int i = 0; i < annotation_table_length; i++) {
     annotation_table[i] = new AnnotationEntry(file, constant_pool);
   }
 }
Ejemplo n.º 17
0
  protected Os2Table(DirectoryEntry de, DataInput di) throws IOException {
    this._de = (DirectoryEntry) de.clone();
    _version = di.readUnsignedShort();
    _xAvgCharWidth = di.readShort();
    _usWeightClass = di.readUnsignedShort();
    _usWidthClass = di.readUnsignedShort();
    _fsType = di.readShort();
    _ySubscriptXSize = di.readShort();
    _ySubscriptYSize = di.readShort();
    _ySubscriptXOffset = di.readShort();
    _ySubscriptYOffset = di.readShort();
    _ySuperscriptXSize = di.readShort();
    _ySuperscriptYSize = di.readShort();
    _ySuperscriptXOffset = di.readShort();
    _ySuperscriptYOffset = di.readShort();
    _yStrikeoutSize = di.readShort();
    _yStrikeoutPosition = di.readShort();
    _sFamilyClass = di.readShort();
    byte[] buf = new byte[10];
    di.readFully(buf);
    _panose = new Panose(buf);
    _ulUnicodeRange1 = di.readInt();
    _ulUnicodeRange2 = di.readInt();
    _ulUnicodeRange3 = di.readInt();
    _ulUnicodeRange4 = di.readInt();
    _achVendorID = di.readInt();
    _fsSelection = di.readShort();
    _usFirstCharIndex = di.readUnsignedShort();
    _usLastCharIndex = di.readUnsignedShort();
    _sTypoAscender = di.readShort();
    _sTypoDescender = di.readShort();
    _sTypoLineGap = di.readShort();
    _usWinAscent = di.readUnsignedShort();
    _usWinDescent = di.readUnsignedShort();
    _ulCodePageRange1 = di.readInt();
    _ulCodePageRange2 = di.readInt();

    // OpenType 1.3
    if (_version == 2) {
      _sxHeight = di.readShort();
      _sCapHeight = di.readShort();
      _usDefaultChar = di.readUnsignedShort();
      _usBreakChar = di.readUnsignedShort();
      _usMaxContext = di.readUnsignedShort();
    }
  }
Ejemplo n.º 18
0
 protected BaseScript(int baseScriptOffset) throws IOException {
   _thisOffset = baseScriptOffset;
   DataInput di = getDataInputForOffset(baseScriptOffset);
   _baseValuesOffset = di.readUnsignedShort();
   _defaultMinMaxOffset = di.readUnsignedShort();
   _baseLangSysCount = di.readUnsignedShort();
   _baseLangSysRecord = new BaseLangSysRecord[_baseLangSysCount];
   for (int i = 0; i < _baseLangSysCount; ++i) {
     _baseLangSysRecord[i] = new BaseLangSysRecord(di);
   }
   if (_baseValuesOffset > 0) {
     _baseValues = new BaseValues(baseScriptOffset + _baseValuesOffset);
   }
   for (int i = 0; i < _baseLangSysCount; ++i) {
     _minMax[i] = new MinMax(baseScriptOffset + _baseLangSysRecord[i].getMinMaxOffset());
   }
 }
Ejemplo n.º 19
0
 @Override
 public int readUnsignedShort() {
   try {
     return input.readUnsignedShort();
   } catch (IOException e) {
     throw new IllegalStateException(e);
   }
 }
Ejemplo n.º 20
0
  /**
   * Creates a new instance of MessagePackageHeader. Used for incoming messages.
   *
   * @param in The stream from which the headers will be read.
   * @throws java.io.IOException if an io error occurs.
   */
  public MessagePackageHeader(InputStream in) throws IOException {
    boolean sawEmpty = false;
    boolean sawLength = false;
    boolean sawType = false;
    DataInput di = new DataInputStream(in);

    // todo 20021014 [email protected] A framing signature would help here.

    do {
      byte headerNameLength = di.readByte();

      if (0 == headerNameLength) {
        sawEmpty = true;
      } else {
        byte[] headerNameBytes = new byte[headerNameLength];

        di.readFully(headerNameBytes);

        String headerNameString = new String(headerNameBytes, "UTF-8");

        if (headerNameString.equalsIgnoreCase(CONTENT_LENGTH)) {
          if (sawLength) {
            throw new IOException("Duplicate content-length header");
          }
          sawLength = true;
        }

        if (headerNameString.equalsIgnoreCase(CONTENT_TYPE)) {
          if (sawType) {
            throw new IOException("Duplicate content-type header");
          }
          sawType = true;
        }

        int headerValueLength = di.readUnsignedShort();

        byte[] headerValueBytes = new byte[headerValueLength];

        di.readFully(headerValueBytes);

        headers.add(new Header(headerNameString, headerValueBytes));
      }
    } while (!sawEmpty);

    if (!sawLength) {
      if (Logging.SHOW_WARNING && LOG.isLoggable(Level.WARNING)) {
        LOG.warning("Content Length header was missing");
      }
      throw new IOException("Content Length header was missing");
    }

    if (!sawType) {
      if (Logging.SHOW_WARNING && LOG.isLoggable(Level.WARNING)) {
        LOG.warning("Content Type header was missing");
      }
      throw new IOException("Content Type header was missing");
    }
  }
 private Object[] processConstantPool(DataInput in, int size) throws IOException {
   Object[] constant_pool = new Object[size];
   for (int i = 1; i < size; ++i) { // CP slot 0 is unused
     byte b = in.readByte();
     switch (b) {
       case jq_ClassFileConstants.CONSTANT_Integer:
         in.readInt();
         break;
       case jq_ClassFileConstants.CONSTANT_Float:
         in.readFloat();
         break;
       case jq_ClassFileConstants.CONSTANT_Long:
         ++i;
         in.readLong();
         break;
       case jq_ClassFileConstants.CONSTANT_Double:
         ++i;
         in.readDouble();
         break;
       case jq_ClassFileConstants.CONSTANT_Utf8:
         {
           byte utf[] = new byte[in.readUnsignedShort()];
           in.readFully(utf);
           constant_pool[i] = Utf8.get(utf);
           break;
         }
       case jq_ClassFileConstants.CONSTANT_Class:
         constant_pool[i] = new Integer(in.readUnsignedShort());
         break;
       case jq_ClassFileConstants.CONSTANT_String:
         in.readUnsignedShort();
         break;
       case jq_ClassFileConstants.CONSTANT_NameAndType:
       case jq_ClassFileConstants.CONSTANT_FieldRef:
       case jq_ClassFileConstants.CONSTANT_MethodRef:
       case jq_ClassFileConstants.CONSTANT_InterfaceMethodRef:
         in.readUnsignedShort();
         in.readUnsignedShort();
         break;
       default:
         throw new ClassFormatError("bad constant pool entry tag: entry=" + i + ", tag=" + b);
     }
   }
   return constant_pool;
 }
Ejemplo n.º 22
0
 protected BaseTagList(int baseTagListOffset) throws IOException {
   _thisOffset = baseTagListOffset;
   DataInput di = getDataInputForOffset(baseTagListOffset);
   _baseTagCount = di.readUnsignedShort();
   _baselineTag = new int[_baseTagCount];
   for (int i = 0; i < _baseTagCount; ++i) {
     _baselineTag[i] = di.readInt();
   }
 }
 public ConstantValueAttr(ConstantPool cp, String name, int length, DataInput din)
     throws IOException {
   super(cp, name);
   int index = din.readUnsignedShort();
   if ((length -= 2) > 0) {
     din.skipBytes(length);
   }
   mConstant = cp.getConstant(index);
 }
Ejemplo n.º 24
0
 private void readConstantPoolEntries(final DataInput di) throws IOException {
   final int count = di.readUnsignedShort();
   constantPool = new Object[count];
   for (int i = 1; i < count; ++i) {
     if (readConstantPoolEntry(di, i)) {
       // double slot
       ++i;
     }
   }
 }
 public void readData(DataInput din) throws IOException {
   m_Reference = din.readUnsignedShort();
   if (din.readByte() == Modbus.COIL_ON) {
     m_Coil = true;
   } else {
     m_Coil = false;
   }
   // skip last byte
   din.readByte();
 } // readData
Ejemplo n.º 26
0
  /**
   * Constructs an sub-attribute list of CodeInfo from a class file stream
   *
   * @param in the stream to read from
   * @param cp the constant pool
   * @param insns (sparse) array of instructions
   * @exception java.io.IOException an io problem has occured
   * @exception ClassFileFormatException attempt to write a bad classfile info
   */
  AttributeList(DataInput in, ConstantPool cp, Instruction[] insns)
      throws IOException, ClassFileFormatException {
    int count = in.readUnsignedShort();

    Vector<Attribute> attributes = new Vector<Attribute>(count);
    for (int i = 0; i < count; i += 1) {
      attributes.addElement(Attribute.readCodeInfoAttribute(in, cp, insns));
    }
    this.attributes = (Attribute[]) Utils.toArray(attributes, Attribute.class);
  }
  public void read(DataInput in) throws InvalidByteCodeException, IOException {

    int localVariableTypeTableLength = in.readUnsignedShort();
    localVariableTable = new LocalVariableTypeTableEntry[localVariableTypeTableLength];
    for (int i = 0; i < localVariableTypeTableLength; i++) {
      localVariableTable[i] = LocalVariableTypeTableEntry.create(in, classFile);
    }

    if (debug) debug("read ");
  }
Ejemplo n.º 28
0
  public void read(DataInput in) throws InvalidByteCodeException, IOException {
    super.read(in);

    int elementValueEntriesLength = in.readUnsignedShort();
    elementValueEntries = new ElementValue[elementValueEntriesLength];
    for (int i = 0; i < elementValueEntries.length; i++) {
      elementValueEntries[i] = ElementValue.create(in, classFile);
    }

    if (debug) debug("read ");
  }
Ejemplo n.º 29
0
  /** Creates a new instance of BaseTable */
  protected BaseTable(DirectoryEntry de, DataInput di) throws IOException {
    _de = (DirectoryEntry) de.clone();

    // Load entire table into a buffer, and create another input stream
    _buf = new byte[de.getLength()];
    di.readFully(_buf);
    DataInput di2 = getDataInputForOffset(0);

    _version = di2.readInt();
    _horizAxisOffset = di2.readUnsignedShort();
    _vertAxisOffset = di2.readUnsignedShort();
    if (_horizAxisOffset != 0) {
      _horizAxis = new Axis(_horizAxisOffset);
    }
    if (_vertAxisOffset != 0) {
      _vertAxis = new Axis(_vertAxisOffset);
    }

    // Let go of the buffer
    _buf = null;
  }
Ejemplo n.º 30
0
  static Attribute define(ConstantPool cp, String name, int length, DataInput din)
      throws IOException {

    InnerClassesAttr innerClasses = new InnerClassesAttr(cp);

    int size = din.readUnsignedShort();
    for (int i = 0; i < size; i++) {
      int inner_index = din.readUnsignedShort();
      int outer_index = din.readUnsignedShort();
      int name_index = din.readUnsignedShort();
      int af = din.readUnsignedShort();

      ConstantClassInfo inner;
      if (inner_index == 0) {
        inner = null;
      } else {
        inner = (ConstantClassInfo) cp.getConstant(inner_index);
      }

      ConstantClassInfo outer;
      if (outer_index == 0) {
        outer = null;
      } else {
        outer = (ConstantClassInfo) cp.getConstant(outer_index);
      }

      ConstantUTFInfo innerName;
      if (name_index == 0) {
        innerName = null;
      } else {
        innerName = (ConstantUTFInfo) cp.getConstant(name_index);
      }

      Info info = new Info(inner, outer, innerName, af);
      innerClasses.mInnerClasses.add(info);
    }

    return innerClasses;
  }