private static DiskFileItem makePayload(int thresh, String repoPath, String filePath, byte[] data) throws IOException, Exception { // if thresh < written length, delete outputFile after copying to repository temp file // otherwise write the contents to repository temp file File repository = new File(repoPath); DiskFileItem diskFileItem = new DiskFileItem("test", "application/octet-stream", false, "test", 100000, repository, null); File outputFile = new File(filePath); DeferredFileOutputStream dfos = new DeferredFileOutputStream(thresh, outputFile); OutputStream os = (OutputStream) Reflections.getFieldValue(dfos, "memoryOutputStream"); os.write(data); Reflections.getField(ThresholdingOutputStream.class, "written").set(dfos, data.length); Reflections.setFieldValue(diskFileItem, "dfos", dfos); Reflections.setFieldValue(diskFileItem, "sizeThreshold", 0); return diskFileItem; }
/** * @see java.io.ObjectInputStream#defaultReadObject() */ public void defaultReadObject() throws IOException, ClassNotFoundException { Object currentObject = stack.peek(); if (!defaultRead.contains(currentObject)) { defaultRead.add(currentObject); currentStreamHandler.readFields(this, currentObject); } }
/** * @see java.io.ObjectOutputStream#defaultWriteObject() */ public void defaultWriteObject() throws IOException { if (!defaultWrite.contains(curObject)) { defaultWrite.add(curObject); classHandler.writeFields(this, curObject); } }
/** * * @return line and column number */ private String getLineAndColumnText() { return " (line " + input.getLineNumber() + ", column " + input.getColumnNumber() + ")"; }
/** * Read all the data from the resource into memory. * * @param reader * The source reader to load the data from * @throws IOException */ public FullyBufferedReader(final Reader reader) throws IOException { this(Streams.readString(reader)); }
/** * Calls the write(byte[]) method. * * @see java.io.OutputStream#write(int) */ @Override public synchronized void write(final int b) { write(new byte[] { (byte)b }, 0, 1); }
@Override public final CharSequence getInput(final int fromPos, final int toPos) { return input.getSubstring(fromPos, toPos); }
@Override public final void setPositionMarker() { input.setPositionMarker(input.getPosition()); }
@Override public String toString() { return input.toString(); }
@Override public void close() throws IOException { // getInputStream() is not always called (WICKET-790) IOUtils.close(in); }
/** * * @see org.apache.wicket.markup.parser.IXmlPullParser#getXmlDeclaration() */ public String getXmlDeclaration() { return xmlReader.getXmlDeclaration(); }
/** * Return the BOM charset Name - {@link ByteOrderMark#getCharsetName()}. * * @return The BOM charset Name or null if no BOM found * @throws IOException * if an error reading the first bytes of the stream occurs * */ public String getBOMCharsetName() throws IOException { getBOM(); return byteOrderMark == null ? null : byteOrderMark.getCharsetName(); }
/** * @see org.apache.wicket.util.io.IObjectStreamFactory#newObjectInputStream(java.io.InputStream) */ public ObjectInputStream newObjectInputStream(InputStream in) throws IOException { return new WicketObjectInputStream(in); }
/** * Construct. * * @param message * @param cause */ public WicketSerializeableException(String message, Throwable cause) { this(message); initCause(cause); }
/** * Pushes an item onto the top of this stack. * * @param item * the item to be pushed onto this stack. */ public final void push(final T item) { add(item); }
/** * * @return line and column number */ private String getLineAndColumnText() { return " (line " + input.getLineNumber() + ", column " + input.getColumnNumber() + ")"; }
/** * Calls the write(byte[]) method. * * @see java.io.OutputStream#write(int) */ @Override public synchronized void write(int b) { write(new byte[] { (byte)b }, 0, 1); }
@Override public final CharSequence getInputFromPositionMarker(final int toPos) { return input.getSubstring(toPos); }
@Override public String toString() { return input.toString(); }
/** * * @see org.apache.wicket.markup.parser.IXmlPullParser#getInput(int, int) */ public final CharSequence getInput(final int fromPos, final int toPos) { return input.getSubstring(fromPos, toPos); }