/** * Copy the provided OutputBuffer and overwrite the current instance. */ public synchronized void copy (OutputBuffer b) { if (b._valid) { _valid = true; try { _outputStream = new ByteArrayOutputStream(b.length()); _output = new DataOutputStream(_outputStream); _outputStream.write(b.buffer(), 0, b.length()); initBuffer(); } catch (IOException e) { _valid = false; } } }
/** * Create a new OutputBuffer and initialise its state with a copy of the * provided buffer. */ public OutputBuffer(OutputBuffer copyFrom) { _valid = true; _outputStream = null; _output = null; copy(copyFrom); }
/** * Pack this buffer into that provided. If the buffer is invalid then an * IOException is thrown. */ public synchronized void packInto (OutputBuffer buff) throws IOException { if (buff == null) throw new IOException(tsLogger.i18NLogger.get_state_OutputBuffer_11()); if (_valid) { /* * pack number of bytes and then pack each byte separately. */ buff.packBytes(buffer()); } }
public synchronized void packInto (OutputBuffer buff) throws IOException { buff.packString(imageType); UidHelper.packInto(bufferUid, buff); super.packInto(buff); }
/** * Pack the array of bytes. If the buffer is invalid then an IOException is * thrown. */ public final synchronized void packBytes (byte[] b) throws IOException { if (!_valid) throw new IOException(tsLogger.i18NLogger.get_state_OutputBuffer_2()); packInt(b.length); if (b.length > 0) { _output.write(b, 0, b.length); realign(b.length); } }
/** * Create a new buffer. */ public OutputBuffer() { _valid = true; try { _outputStream = new ByteArrayOutputStream(); _output = new DataOutputStream(_outputStream); initBuffer(); } catch (IOException e) { _valid = false; } }
/** * Clear the OutputBuffer and rewind the pack pointer. */ public final synchronized void reset () throws IOException { _outputStream.reset(); initBuffer(); }
OutputBuffer outputBuffer = new OutputBuffer(); UidHelper.packInto(uid, outputBuffer); outputBuffer.packString(typeName); outputBuffer.packBytes(txData.buffer()); long id = getId(uid, typeName); byte[] data = outputBuffer.buffer();
/** * Pack the short. If the buffer is invalid then an IOException is thrown. */ public final synchronized void packShort (short s) throws IOException { if (!_valid) throw new IOException(tsLogger.i18NLogger.get_state_OutputBuffer_5()); packInt((int) s); }
/** * Pack a byte. If the buffer is invalid then an IOException is thrown. */ public final synchronized void packByte (byte b) throws IOException { if (!_valid) throw new IOException(tsLogger.i18NLogger.get_state_OutputBuffer_1()); packInt((byte) b); }
/** * Pack the character. If the buffer is invalid then an IOException is * thrown. */ public final synchronized void packChar (char c) throws IOException { if (!_valid) throw new IOException(tsLogger.i18NLogger.get_state_OutputBuffer_4()); packInt((int) c); }
public static final void packInto (Uid u, OutputBuffer buff) throws IOException { if ((u == null) || (buff == null)) throw new IllegalArgumentException(); if (u.valid()) buff.packBytes(u.getBytes()); else throw new IllegalArgumentException(); }
public void print (PrintWriter strm) { strm.println("OutputObjectState Uid : "+bufferUid+"\n"); if (imageType != null) strm.println("OutputObjectState Type : "+imageType+"\n"); else strm.println("OutputObjectState Type : null\n"); strm.println("OutputObjectState Size : "+size()+"\n"); strm.println("OutputObjectState Buffer: "); super.print(strm); }
/** * Print out information about this instance. */ public void print (PrintWriter strm) { if (_valid) { strm.println("OutputBuffer : \n"); byte[] b = buffer(); for (int i = 0; i < b.length; i++) strm.write((char) b[i]); } else strm.println("OutputBuffer : invalid."); }
/** * Set the Connector through which this Request was received. * * @param connector The new connector */ public void setConnector(Connector connector) { this.connector = connector; if("AJP/1.3".equals(connector.getProtocol())) { // default size to size of one ajp-packet outputBuffer = new OutputBuffer(8184); } else { outputBuffer = new OutputBuffer(); } outputStream = new CoyoteOutputStream(outputBuffer); writer = new CoyoteWriter(outputBuffer); }
/** * Create a new buffer. */ public OutputBuffer() { _valid = true; try { _outputStream = new ByteArrayOutputStream(); _output = new DataOutputStream(_outputStream); initBuffer(); } catch (IOException e) { _valid = false; } }
/** * Pack the array of bytes. If the buffer is invalid then an IOException is * thrown. */ public final synchronized void packBytes (byte[] b) throws IOException { if (!_valid) throw new IOException(tsLogger.i18NLogger.get_state_OutputBuffer_2()); packInt(b.length); if (b.length > 0) { _output.write(b, 0, b.length); realign(b.length); } }
/** * Clear the OutputBuffer and rewind the pack pointer. */ public final synchronized void reset () throws IOException { _outputStream.reset(); initBuffer(); }
OutputBuffer outputBuffer = new OutputBuffer(); UidHelper.packInto(uid, outputBuffer); outputBuffer.packString(typeName); outputBuffer.packBytes(txData.buffer()); long id = getId(uid, typeName); byte[] data = outputBuffer.buffer();