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

📄 transformer.java

📁 linux下建立JAVA虚拟机的源码KAFFE
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    wired = null;    inBuffer.reset();    outBuffer.reset();    tail.reset(); // reset tail last  }  /**   * Convenience method that calls the method with same name and three   * arguments, using a byte array of length <code>1</code> whose contents are   * the designated byte.   *   * @param b the byte to process.   * @return the result of transformation.   * @throws IllegalStateException if the instance is not initialised.   * @throws TransformerException if a transformation-related exception occurs   * during the operation.   * @see #update(byte[], int, int)   */  public byte[] update(byte b) throws TransformerException  {    return update(new byte[] { b }, 0, 1);  }  /**   * Convenience method that calls the same method with three arguments. All   * bytes in <code>in</code>, starting from index position <code>0</code> are   * considered.   *   * @param in the input data bytes.   * @return the result of transformation.   * @throws IllegalStateException if the instance is not initialised.   * @throws TransformerException if a transformation-related exception occurs   * during the operation.   * @see #update(byte[], int, int)   */  public byte[] update(byte[] in) throws TransformerException  {    return update(in, 0, in.length);  }  /**   * Processes a designated number of bytes from a given byte array.   *   * @param in the input data bytes.   * @param offset index of <code>in</code> from which to start considering   * data.   * @param length the count of bytes to process.   * @return the result of transformation.   * @throws IllegalStateException if the instance is not initialised.   * @throws TransformerException if a transformation-related exception occurs   * during the operation.   */  public byte[] update(byte[] in, int offset, int length)      throws TransformerException  {    if (wired == null)      {        throw new IllegalStateException();      }    byte[] result = (wired == Direction.FORWARD ? forwardUpdate(in, offset,                                                                length)                                               : inverseUpdate(in, offset,                                                               length));    return result;  }  /**   * Convenience method that calls the same method with three arguments. A   * zero-long byte array is used.   *   * @return the result of transformation.   * @throws IllegalStateException if the instance is not initialised.   * @throws TransformerException if a transformation-related exception occurs   * during the operation.   * @see #lastUpdate(byte[], int, int)   */  public byte[] lastUpdate() throws TransformerException  {    byte[] result = (wired == Direction.FORWARD ? lastForwardUpdate()                                               : lastInverseUpdate());    if (inBuffer.size() != 0)      { // we still have some buffered bytes        throw new TransformerException("lastUpdate(): input buffer not empty");      }    return result;  }  /**   * Convenience method that calls the method with same name and three   * arguments, using a byte array of length <code>1</code> whose contents are   * the designated byte.   *   * @param b the byte to process.   * @return the result of transformation.   * @throws IllegalStateException if the instance is not initialised.   * @throws TransformerException if a transformation-related exception occurs   * during the operation.   * @see #lastUpdate(byte[], int, int)   */  public byte[] lastUpdate(byte b) throws TransformerException  {    return lastUpdate(new byte[] { b }, 0, 1);  }  /**   * Convenience method that calls the same method with three arguments. All   * bytes in <code>in</code>, starting from index position <code>0</code> are   * considered.   *   * @param in the input data bytes.   * @return the result of transformation.   * @throws IllegalStateException if the instance is not initialised.   * @throws TransformerException if a transformation-related exception occurs   * during the operation.   * @see #lastUpdate(byte[], int, int)   */  public byte[] lastUpdate(byte[] in) throws TransformerException  {    return lastUpdate(in, 0, in.length);  }  /**   * Processes a designated number of bytes from a given byte array and   * signals, at the same time, that this is the last <i>push</i> operation on   * this <code>Transformer</code>.   *   * @param in the input data bytes.   * @param offset index of <code>in</code> from which to start considering   * data.   * @param length the count of bytes to process.   * @return the result of transformation.   * @throws IllegalStateException if the instance is not initialised.   * @throws TransformerException if a transformation-related exception occurs   * during the operation.   */  public byte[] lastUpdate(byte[] in, int offset, int length)      throws TransformerException  {    byte[] result = update(in, offset, length);    byte[] rest = lastUpdate();    if (rest.length > 0)      {        byte[] newResult = new byte[result.length + rest.length];        System.arraycopy(result, 0, newResult, 0, result.length);        System.arraycopy(rest, 0, newResult, result.length, rest.length);        result = newResult;      }    return result;  }  // helper methods ----------------------------------------------------------  private byte[] forwardUpdate(byte[] in, int off, int len)      throws TransformerException  {    return (isPreProcessing() ? preTransform(in, off, len) : postTransform(in,                                                                           off,                                                                           len));  }  private byte[] inverseUpdate(byte[] in, int off, int len)      throws TransformerException  {    return (isPreProcessing() ? postTransform(in, off, len) : preTransform(in,                                                                           off,                                                                           len));  }  private byte[] preTransform(byte[] in, int off, int len)      throws TransformerException  {    byte[] result = updateDelegate(in, off, len);    result = tail.update(result);    return result;  }  private byte[] postTransform(byte[] in, int off, int len)      throws TransformerException  {    byte[] result = tail.update(in, off, len);    result = updateDelegate(result, 0, result.length);    return result;  }  private byte[] lastForwardUpdate() throws TransformerException  {    return (isPreProcessing() ? preLastTransform() : postLastTransform());  }  private byte[] lastInverseUpdate() throws TransformerException  {    return (isPreProcessing() ? postLastTransform() : preLastTransform());  }  private byte[] preLastTransform() throws TransformerException  {    byte[] result = lastUpdateDelegate();    result = tail.lastUpdate(result);    return result;  }  private byte[] postLastTransform() throws TransformerException  {    byte[] result = tail.lastUpdate();    result = updateDelegate(result, 0, result.length);    byte[] rest = lastUpdateDelegate();    if (rest.length > 0)      {        byte[] newResult = new byte[result.length + rest.length];        System.arraycopy(result, 0, newResult, 0, result.length);        System.arraycopy(rest, 0, newResult, result.length, rest.length);        result = newResult;      }    return result;  }  // abstract methods to be implemented by concrete subclasses ---------------  abstract void initDelegate(Map attributes) throws TransformerException;  abstract int delegateBlockSize();  abstract void resetDelegate();  abstract byte[] updateDelegate(byte[] in, int off, int len)      throws TransformerException;  abstract byte[] lastUpdateDelegate() throws TransformerException;}

⌨️ 快捷键说明

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