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

📄 streammessage.java

📁 一个类似于openJMS分布在ObjectWeb之下的JMS消息中间件。
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
      jE.setLinkedException(ioE);      throw jE;    }  }  /**    * API method.   *   * @exception MessageNotWriteableException  If the message body is read-only.   * @exception JMSException  If the value could not be written on the stream.   */    public void writeShort(short value)     throws JMSException {    prepareWrite();    try {      outputStream.writeByte(SHORT);      outputStream.writeShort((int) value);    } catch (IOException ioE) {      JMSException jE = new JMSException("Error while writing the value.");      jE.setLinkedException(ioE);      throw jE;    }  }   /**    * API method.   *   * @exception MessageNotWriteableException  If the message body is read-only.   * @exception JMSException  If the value could not be written on the stream.   */     public void writeString(String value)     throws JMSException {    prepareWrite();        try {      if (value == null)        outputStream.writeByte(NULL);      else {        outputStream.writeByte(STRING);        outputStream.writeUTF(value);      }    } catch (IOException ioE) {      JMSException jE = new JMSException("Error while writing the value.");      jE.setLinkedException(ioE);      throw jE;    }  }   /**    * API method.   *   * @exception MessageNotWriteableException  If the message body is read-only.   * @exception MessageFormatException  If the value type is invalid.   * @exception JMSException  If the value could not be written on the stream.   */   public void writeObject(Object value)     throws JMSException {    prepareWrite();    if (value == null) {      try {        outputStream.writeByte(NULL);      } catch (IOException ioE) {        JMSException jE = new JMSException("Error while writing the value.");        jE.setLinkedException(ioE);        throw jE;      }    } else if (value instanceof Boolean) {      writeBoolean(((Boolean) value).booleanValue());    } else if (value instanceof Character) {      writeChar(((Character) value).charValue());    } else if (value instanceof Byte) {      writeByte(((Byte) value).byteValue());    } else if (value instanceof Short) {       writeShort(((Short) value).shortValue());    } else if (value instanceof Integer) {       writeInt(((Integer) value).intValue());    } else if (value instanceof Long) {       writeLong(((Long) value).longValue());    } else if (value instanceof Float) {       writeFloat(((Float) value).floatValue());    } else if (value instanceof Double) {       writeDouble(((Double) value).doubleValue());    } else if (value instanceof String) {      writeString((String) value);    } else if (value instanceof byte[]) {      writeBytes((byte[]) value);    } else      throw new MessageFormatException("Can't write non Java primitive type"                                       + " as a bytes array.");  }      /**   * API method.   *   * @exception MessageNotReadableException  If the message body is write-only.   * @exception MessageFormatException       If reading the expected type is   *                                         not possible.   * @exception MessageEOFException          Unexpected end of bytes array.   * @exception JMSException                 internal error   */  public boolean readBoolean()     throws JMSException {    if (WObody)      throw new MessageNotReadableException("Can't read the message body as"                                            + " it is write-only.");    try {      byte type = inputStream.readByte();      if (type == BOOLEAN)        return inputStream.readBoolean();      else if (type == STRING)        return Boolean.valueOf(inputStream.readUTF()).booleanValue();      else        throw new MessageFormatException("type read: " + type + " is not a boolean or a String.");    } catch (EOFException e1) {      MessageEOFException exc = new MessageEOFException("end of message " + e1);      exc.setLinkedException(e1);      throw exc;    } catch (IOException e2) {      JMSException exc = new JMSException("IOException");      exc.setLinkedException(e2);      throw exc;    }                                                               }  /**   * API method.   *   * @exception MessageNotReadableException  If the message body is write-only.   * @exception MessageFormatException       If reading the expected type is   *                                         not possible.   * @exception MessageEOFException          Unexpected end of bytes array.   * @exception JMSException                 internal error   */  public byte readByte() throws JMSException {    if (WObody)      throw new MessageNotReadableException("Can't read the message body as"                                            + " it is write-only.");    try {      inputStream.mark(inputStream.available());      byte type = inputStream.readByte();      if (type == BYTE)        return inputStream.readByte();      else if (type == STRING)        return Byte.valueOf(inputStream.readUTF()).byteValue();      else        throw new MessageFormatException("type read: " + type + " is not a byte or a String.");    } catch (EOFException e1) {      MessageEOFException exc = new MessageEOFException("end of message " + e1);      exc.setLinkedException(e1);      throw exc;    } catch (IOException e2) {      JMSException exc = new JMSException("IOException");      exc.setLinkedException(e2);      throw exc;    } catch (NumberFormatException e3) {      try {        inputStream.reset();      } catch (Exception e) {}      throw e3;    }             }   /**   * API method.   *   * @exception MessageNotReadableException  If the message body is write-only.   * @exception MessageFormatException       If reading the expected type is   *                                         not possible.   * @exception MessageEOFException          Unexpected end of bytes array.   * @exception JMSException                 internal error   */  public short readShort() throws JMSException {    if (WObody)      throw new MessageNotReadableException("Can't read the message body as"                                            + " it is write-only.");    try {      byte type = inputStream.readByte();      if (type == SHORT)        return inputStream.readShort();      else if (type == BYTE)        return inputStream.readByte();      else if (type == STRING)        return Short.valueOf(inputStream.readUTF()).shortValue();      else        throw new MessageFormatException("type read: " + type + " is not a short, a byte or a String.");    } catch (EOFException e1) {      MessageEOFException exc = new MessageEOFException("end of message " + e1);      exc.setLinkedException(e1);      throw exc;    } catch (IOException e2) {      JMSException exc = new JMSException("IOException");      exc.setLinkedException(e2);      throw exc;    }   }  /**   * API method.   *   * @exception MessageNotReadableException  If the message body is write-only.   * @exception MessageFormatException       If reading the expected type is   *                                         not possible.   * @exception MessageEOFException          Unexpected end of bytes array.   * @exception JMSException                 internal error   */  public char readChar() throws JMSException {    if (WObody)      throw new MessageNotReadableException("Can't read the message body as"                                            + " it is write-only.");    try {      byte type = inputStream.readByte();      if (type == CHAR)        return inputStream.readChar();//        else if (type == STRING)//          return inputStream.readUTF().charAt(0);      else if (type == NULL)        throw new NullPointerException("null is not a char.");      else        throw new MessageFormatException("type read: " + type + " is not a char.");    } catch (EOFException e1) {      MessageEOFException exc = new MessageEOFException("end of message " + e1);      exc.setLinkedException(e1);      throw exc;    } catch (IOException e2) {      JMSException exc = new JMSException("IOException");      exc.setLinkedException(e2);      throw exc;    }   }  /**   * API method.   *   * @exception MessageNotReadableException  If the message body is write-only.   * @exception MessageFormatException       If reading the expected type is   *                                         not possible.   * @exception MessageEOFException          Unexpected end of bytes array.   * @exception JMSException                 internal error   */  public int readInt() throws JMSException {    if (WObody)      throw new MessageNotReadableException("Can't read the message body as"                                            + " it is write-only.");    try {      byte type = inputStream.readByte();      if (type == INT)        return inputStream.readInt();      else if (type == SHORT)        return inputStream.readShort();      else if (type == BYTE)        return inputStream.readByte();      else if (type == STRING)        return Integer.valueOf(inputStream.readUTF()).intValue();      else        throw new MessageFormatException("type read: " + type +                                          " is not a int, a short, a byte or a String.");    } catch (EOFException e1) {      MessageEOFException exc = new MessageEOFException("end of message " + e1);      exc.setLinkedException(e1);      throw exc;    } catch (IOException e2) {      JMSException exc = new JMSException("IOException");      exc.setLinkedException(e2);      throw exc;    }   }  /**   * API method.   *   * @exception MessageNotReadableException  If the message body is write-only.   * @exception MessageFormatException       If reading the expected type is   *                                         not possible.   * @exception MessageEOFException          Unexpected end of bytes array.   * @exception JMSException                 internal error   */  public long readLong() throws JMSException {    if (WObody)      throw new MessageNotReadableException("Can't read the message body as"                                            + " it is write-only.");    try {      byte type = inputStream.readByte();      if (type == LONG)        return inputStream.readLong();      else if (type == INT)        return inputStream.readInt();      else if (type == SHORT)        return inputStream.readShort();      else if (type == BYTE)        return inputStream.readByte();      else if (type == STRING)        return Long.valueOf(inputStream.readUTF()).longValue();      else        throw new MessageFormatException("type read: " + type +                                          " is not a int, a short, a byte or a String.");    } catch (EOFException e1) {      MessageEOFException exc = new MessageEOFException("end of message " + e1);      exc.setLinkedException(e1);      throw exc;    } catch (IOException e2) {      JMSException exc = new JMSException("IOException");      exc.setLinkedException(e2);      throw exc;    }   }  /**   * API method.   *   * @exception MessageNotReadableException  If the message body is write-only.   * @exception MessageFormatException       If reading the expected type is   *                                         not possible.   * @exception MessageEOFException          Unexpected end of bytes array.   * @exception JMSException                 internal error   */  public float readFloat() throws JMSException {    if (WObody)      throw new MessageNotReadableException("Can't read the message body as"                                            + " it is write-only.");

⌨️ 快捷键说明

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