Exemple #1
0
  /**
   * Accessor for the binary data
   *
   * @return the binary data
   */
  byte[] getData() {
    numProperties = properties.size();
    setInstance(numProperties);

    data = new byte[numProperties * 6];
    int pos = 0;

    // Add in the root data
    for (Iterator i = properties.iterator(); i.hasNext(); ) {
      Property p = (Property) i.next();
      int val = p.id & 0x3fff;

      if (p.blipId) {
        val |= 0x4000;
      }

      if (p.complex) {
        val |= 0x8000;
      }

      IntegerHelper.getTwoBytes(val, data, pos);
      IntegerHelper.getFourBytes(p.value, data, pos + 2);
      pos += 6;
    }

    // Add in any complex data
    for (Iterator i = properties.iterator(); i.hasNext(); ) {
      Property p = (Property) i.next();

      if (p.complex && p.stringValue != null) {
        byte[] newData = new byte[data.length + p.stringValue.length() * 2];
        System.arraycopy(data, 0, newData, 0, data.length);
        StringHelper.getUnicodeBytes(p.stringValue, newData, data.length);
        data = newData;
      }
    }

    return setHeaderData(data);
  }
Exemple #2
0
  /** Reads the properties */
  private void readProperties() {
    properties = new ArrayList();
    int pos = 0;
    byte[] bytes = getBytes();

    for (int i = 0; i < numProperties; i++) {
      int val = IntegerHelper.getInt(bytes[pos], bytes[pos + 1]);
      int id = val & 0x3fff;
      int value =
          IntegerHelper.getInt(bytes[pos + 2], bytes[pos + 3], bytes[pos + 4], bytes[pos + 5]);
      Property p = new Property(id, (val & 0x4000) != 0, (val & 0x8000) != 0, value);
      pos += 6;
      properties.add(p);
    }

    for (Iterator i = properties.iterator(); i.hasNext(); ) {
      Property p = (Property) i.next();
      if (p.complex) {
        p.stringValue = StringHelper.getUnicodeString(bytes, p.value / 2, pos);
        pos += p.value;
      }
    }
  }