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

📄 bytesmessage.java

📁 一个类似于openJMS分布在ObjectWeb之下的JMS消息中间件。
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    }    catch (Exception e) {      JMSException jE = null;      if (e instanceof EOFException)        jE = new MessageEOFException("Unexpected end of bytes array.");      else if (e instanceof IOException)        jE = new JMSException("Could not read the bytes array.");      jE.setLinkedException(e);      throw jE;    }  }  /**   * API method.   *   * @exception MessageNotReadableException  If the message body is write-only.   * @exception JMSException  If an exception occurs while reading the bytes.   */  public int readUnsignedByte() throws JMSException  {    if (WObody)      throw new MessageNotReadableException("Can't read the message body as"                                            + " it is write-only.");    try {      return inputStream.readUnsignedByte();    }    catch (Exception e) {      JMSException jE = null;      if (e instanceof EOFException)        jE = new MessageEOFException("Unexpected end of bytes array.");      else if (e instanceof IOException)        jE = new JMSException("Could not read the bytes array.");      jE.setLinkedException(e);      throw jE;    }  }  /**   * API method.   *   * @exception MessageNotReadableException  If the message body is write-only.   * @exception JMSException  If an exception occurs while reading the bytes.   */  public short readShort() throws JMSException  {    if (WObody)      throw new MessageNotReadableException("Can't read the message body as"                                            + " it is write-only.");    try {      return inputStream.readShort();    }    catch (Exception e) {      JMSException jE = null;      if (e instanceof EOFException)        jE = new MessageEOFException("Unexpected end of bytes array.");      else if (e instanceof IOException)        jE = new JMSException("Could not read the bytes array.");      jE.setLinkedException(e);      throw jE;    }  }    /**   * API method.   *   * @exception MessageNotReadableException  If the message body is write-only.   * @exception JMSException  If an exception occurs while reading the bytes.   */  public int readUnsignedShort() throws JMSException  {    if (WObody)      throw new MessageNotReadableException("Can't read the message body as"                                            + " it is write-only.");    try {      return inputStream.readUnsignedShort();    }    catch (Exception e) {      JMSException jE = null;      if (e instanceof EOFException)        jE = new MessageEOFException("Unexpected end of bytes array.");      else if (e instanceof IOException)        jE = new JMSException("Could not read the bytes array.");      jE.setLinkedException(e);      throw jE;    }  }  /**   * API method.   *   * @exception MessageNotReadableException  If the message body is write-only.   * @exception JMSException  If an exception occurs while reading the bytes.   */  public char readChar() throws JMSException  {    if (WObody)      throw new MessageNotReadableException("Can't read the message body as"                                            + " it is write-only.");    try {      return inputStream.readChar();    }    catch (Exception e) {      JMSException jE = null;      if (e instanceof EOFException)        jE = new MessageEOFException("Unexpected end of bytes array.");      else if (e instanceof IOException)        jE = new JMSException("Could not read the bytes array.");      jE.setLinkedException(e);      throw jE;    }  }  /**   * API method.   *   * @exception MessageNotReadableException  If the message body is write-only.   * @exception JMSException  If an exception occurs while reading the bytes.   */  public int readInt() throws JMSException  {    if (WObody)      throw new MessageNotReadableException("Can't read the message body as"                                            + " it is write-only.");    try {      return inputStream.readInt();    }    catch (Exception e) {      JMSException jE = null;      if (e instanceof EOFException)        jE = new MessageEOFException("Unexpected end of bytes array.");      else if (e instanceof IOException)        jE = new JMSException("Could not read the bytes array.");      jE.setLinkedException(e);      throw jE;    }  }  /**   * API method.   *   * @exception MessageNotReadableException  If the message body is write-only.   * @exception JMSException  If an exception occurs while reading the bytes.   */  public long readLong() throws JMSException  {    if (WObody)      throw new MessageNotReadableException("Can't read the message body as"                                            + " it is write-only.");    try {      return inputStream.readLong();    }    catch (Exception e) {      JMSException jE = null;      if (e instanceof EOFException)        jE = new MessageEOFException("Unexpected end of bytes array.");      else if (e instanceof IOException)        jE = new JMSException("Could not read the bytes array.");      jE.setLinkedException(e);      throw jE;    }  }  /**   * API method.   *   * @exception MessageNotReadableException  If the message body is write-only.   * @exception JMSException  If an exception occurs while reading the bytes.   *///    public float readFloat() throws JMSException//    {//      if (WObody)//        throw new MessageNotReadableException("Can't read the message body as"//                                              + " it is write-only.");//      try {//        return inputStream.readFloat();//      }//      catch (Exception e) {//        JMSException jE = null;//        if (e instanceof EOFException)//          jE = new MessageEOFException("Unexpected end of bytes array.");//        else if (e instanceof IOException)//          jE = new JMSException("Could not read the bytes array.");//        jE.setLinkedException(e);//        throw jE;//      }//    }  /**   * API method.   *   * @exception MessageNotReadableException  If the message body is write-only.   * @exception JMSException  If an exception occurs while reading the bytes.   *///    public double readDouble() throws JMSException//    {//      if (WObody)//        throw new MessageNotReadableException("Can't read the message body as"//                                              + " it is write-only.");//      try {//        return inputStream.readDouble();//      }//      catch (Exception e) {//        JMSException jE = null;//        if (e instanceof EOFException)//          jE = new MessageEOFException("Unexpected end of bytes array.");//        else if (e instanceof IOException)//          jE = new JMSException("Could not read the bytes array.");//        jE.setLinkedException(e);//        throw jE;//      }//    }  /**   * API method.   *   * @exception MessageNotReadableException  If the message body is write-only.   * @exception JMSException  If an exception occurs while reading the bytes.   */  public int readBytes(byte[] value) throws JMSException  {    if (WObody)      throw new MessageNotReadableException("Can't read the message body as"                                            + " it is write-only.");    int counter = 0;    try {      for (int i = 0; i < value.length; i ++) {        value[i] = inputStream.readByte();        counter++;      }    }    // End of array has been reached:    catch (EOFException eofE) {}    // An error has occured!    catch (IOException ioE) {      JMSException jE = null;      jE = new JMSException("Could not read the bytes array.");      jE.setLinkedException(ioE);      throw jE;    }    if (counter == 0)      return -1;    return counter;  }  /**   * API method.   *   * @exception MessageNotReadableException  If the message body is write-only.   * @exception JMSException  If an exception occurs while reading the bytes.   */  public int readBytes(byte[] value, int length) throws JMSException  {    if (WObody)      throw new MessageNotReadableException("Can't read the message body as"                                            + " it is write-only.");    if (length > value.length || length < 0)      throw new IndexOutOfBoundsException("Invalid length parameter: "                                          + length);    int counter = 0;    try {      for (int i = 0; i < length; i ++) {        value[i] = inputStream.readByte();        counter++;      }    }    // End of array has been reached:    catch (EOFException eofE) {}    // An error has occured!    catch (IOException ioE) {      JMSException jE = null;      jE = new JMSException("Could not read the bytes array.");      jE.setLinkedException(ioE);      throw jE;    }    if (counter == 0)      return -1;    return counter;  }  /**   * API method.   *   * @exception MessageNotReadableException  If the message body is write-only.   * @exception JMSException  If an exception occurs while reading the bytes.   */  public String readUTF() throws JMSException  {    if (WObody)      throw new MessageNotReadableException("Can't read the message body as"                                            + " it is write-only.");    try {      return inputStream.readUTF();    }    catch (Exception e) {      JMSException jE = null;      if (e instanceof EOFException)        jE = new MessageEOFException("Unexpected end of bytes array.");      else if (e instanceof IOException)        jE = new JMSException("Could not read the bytes array.");      jE.setLinkedException(e);      throw jE;    }  }    /**    * API method.   *   * @exception JMSException  If an error occurs while closing the output   *              stream.   */  public void reset() throws JMSException  {    try {      if (WObody) {        outputStream.flush();        bytes = outputBuffer.toByteArray();      }      else        inputStream.close();            inputStream = new DataInputStream(new ByteArrayInputStream(bytes));      RObody = true;      WObody = false;    }    catch (IOException iE) {      JMSException jE =        new JMSException("Error while manipulating the stream facilities.");      jE.setLinkedException(iE);      throw jE;    }  }  /**   * Method actually preparing the message for sending by transfering the   * local body into the wrapped MOM message.   *   * @exception Exception  If an error occurs while serializing.   */  protected void prepare() throws Exception  {    super.prepare();    if (WObody) {      outputStream.flush();      bytes = outputBuffer.toByteArray();      prepared = true;    }    momMsg.clearBody();    momMsg.setBytes(bytes);  } }

⌨️ 快捷键说明

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