⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 push.java

📁 java解析flash。对于flash在java上应用非常有帮助。比如解析flash到服务器端
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
     *
     * @param value a double value
     */
    public void setDouble(double value) {
      this.doubleValue   = value;
      type               = TYPE_DOUBLE;
    }

    /**
     * Returns the double the push value is set to. If the value type is not
     * TYPE_DOUBLE, an IllegalStateException is thrown.
     *
     * @return push value as double
     *
     * @throws IllegalStateException if type is not TYPE_DOUBLE
     */
    public double getDouble() {
      if (type != TYPE_DOUBLE) {
        throw new IllegalStateException("Value type is not TYPE_DOUBLE!");
      }
      return doubleValue;
    }

    /**
     * Sets the push value to a (single-precision) float, and the type to
     * TYPE_FLOAT.
     *
     * @param value a float value
     */
    public void setFloat(float value) {
      this.floatValue   = value;
      type              = TYPE_FLOAT;
    }

    /**
     * Returns the float the push value is set to. If the value type is not
     * TYPE_FLOAT, an IllegalStateException is thrown.
     *
     * @return push value as float
     *
     * @throws IllegalStateException if type is not TYPE_FLOAT
     */
    public float getFloat() {
      if (type != TYPE_FLOAT) {
        throw new IllegalStateException("Value type is not TYPE_FLOAT!");
      }
      return floatValue;
    }

    /**
     * Sets the push value to an integer, and the type to TYPE_INTEGER.
     *
     * @param value an integer value (of type <code>long</code>)
     */
    public void setInteger(long value) {
      this.integerValue   = value;
      type                = TYPE_INTEGER;
    }

    /**
     * Returns the integer the push value is set to. If the value type is not
     * TYPE_INTEGER, an IllegalStateException is thrown.
     *
     * @return push value as integer
     *
     * @throws IllegalStateException if type is not TYPE_INTEGER
     */
    public long getInteger() {
      if (type != TYPE_INTEGER) {
        throw new IllegalStateException("Value type is not TYPE_INTEGER!");
      }
      return integerValue;
    }

    /**
     * Sets the type to <code>TYPE_NULL</code> (i.e. the push value is
     * <code>null</code>).
     */
    public void setNull() {
      type = TYPE_NULL;
    }

    /**
     * Checks if the push value is <code>null</code>.
     *
     * @return true if <code>null</code>, else false.
     */
    public boolean isNull() {
      return (type == TYPE_NULL);
    }

    /**
     * Sets the push value to a register number, and the type to TYPE_REGISTER.
     *
     * @param value a register number
     */
    public void setRegisterNumber(short value) {
      this.registerNumber   = value;
      type                  = TYPE_REGISTER;
    }

    /**
     * Returns the register number the push value is set to. If the value type
     * is not TYPE_REGISTER, an IllegalStateException is thrown.
     *
     * @return push value as register number
     *
     * @throws IllegalStateException if type is not TYPE_REGISTER
     */
    public short getRegisterNumber() {
      if (type != TYPE_REGISTER) {
        throw new IllegalStateException("Value type is not TYPE_REGISTER!");
      }
      return registerNumber;
    }

    /**
     * Sets the push value to a string, and the type to TYPE_STRING
     *
     * @param value a string value
     */
    public void setString(String value) {
      this.string   = value;
      type          = TYPE_STRING;
    }

    /**
     * Returns the string the push value is set to. If the value type is not
     * TYPE_STRING, an IllegalStateException is thrown
     *
     * @return push value as string
     *
     * @throws IllegalStateException if type is not TYPE_STRING
     */
    public String getString() {
      if (type != TYPE_STRING) {
        throw new IllegalStateException("Value type is not TYPE_STRING!");
      }
      return string;
    }

    /**
     * Returns the type of the push value. The type is one of the constants
     * <code>TYPE_BOOLEAN, TYPE_CONSTANT_8, TYPE_CONSTANT_16, TYPE_DOUBLE,
     * TYPE_FLOAT, TYPE_INTEGER, TYPE_NULL, TYPE_REGISTER, TYPE_STRING,
     * TYPE_UNDEFINED</code>.
     *
     * @return type of push value
     */
    public short getType() {
      return type;
    }

    /**
     * Sets the type to <code>TYPE_UNDEFINED</code> (i.e. the push value is
     * <code>undefined</code>).
     */
    public void setUndefined() {
      type = TYPE_UNDEFINED;
    }

    /**
     * Checks if the push value is <code>undefined</code>.
     *
     * @return true if <code>undefined</code>, else false.
     */
    public boolean isUndefined() {
      return (type == TYPE_UNDEFINED);
    }

    /**
     * Returs a short description of the push value (type and value)
     *
     * @return type and value
     */
    public String toString() {
      String result = "";
      switch (type) {
        case TYPE_STRING:
          result += ("string: '" + string + "'");
          break;
        case TYPE_FLOAT:
          result += ("float: " + floatValue);
          break;
        case TYPE_REGISTER:
          result += ("register: " + registerNumber);
          break;
        case TYPE_BOOLEAN:
          result += ("boolean: " + booleanValue);
          break;
        case TYPE_DOUBLE:
          result += ("double: " + doubleValue);
          break;
        case TYPE_INTEGER:
          result += ("integer: " + integerValue);
          break;
        case TYPE_CONSTANT_8:
          result += ("c8[" + constant8 + "]");
          break;
        case TYPE_CONSTANT_16:
          result += ("c16[" + constant16 + "]");
          break;
        case TYPE_UNDEFINED:
          result += "undefined";
          break;
        case TYPE_NULL:
          result += "null";
          break;
      }
      return result;
    }

    int getSize() {
      int size = 1; // type
      switch (type) {
        case TYPE_STRING:
          try {
            size += (string.getBytes("UTF-8").length + 1);
          } catch (UnsupportedEncodingException e) {
            // UTF-8 should be available. If not, we have a big problem anyway
          }
          break;
        case TYPE_FLOAT:
          size += 4;
          break;
        case TYPE_REGISTER:
          size++;
          break;
        case TYPE_BOOLEAN:
          size++;
          break;
        case TYPE_DOUBLE:
          size += 8;
          break;
        case TYPE_INTEGER:
          size += 4;
          break;
        case TYPE_CONSTANT_8:
          size++;
          break;
        case TYPE_CONSTANT_16:
          size += 2;
          break;
      }
      return size;
    }

    void write(OutputBitStream outStream) throws IOException {
      outStream.writeUI8(type);
      switch (type) {
        case TYPE_STRING:
          outStream.writeString(string);
          break;
        case TYPE_FLOAT:
          outStream.writeFloat(floatValue);
          break;
        case TYPE_REGISTER:
          outStream.writeUI8(registerNumber);
          break;
        case TYPE_BOOLEAN:
          outStream.writeUI8((short) (booleanValue ? 1 : 0));
          break;
        case TYPE_DOUBLE:
          outStream.writeDouble(doubleValue);
          break;
        case TYPE_INTEGER:
          outStream.writeUI32(integerValue);
          break;
        case TYPE_CONSTANT_8:
          outStream.writeUI8(constant8);
          break;
        case TYPE_CONSTANT_16:
          outStream.writeUI16(constant16);
          break;
      }
    }
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -