private static NotActiveException notActiveException() { return new NotActiveException("Output not started"); }
public void registerValidation(ObjectInputValidation validation, int priority) throws NotActiveException { throw new NotActiveException("stream inactive"); }
public void writeFieldsToStream(Map fields) throws NotActiveException { throw new NotActiveException("not in call to writeObject"); }
public void defaultWriteObject() throws NotActiveException { throw new NotActiveException("not in call to writeObject"); }
public Map readFieldsFromStream() throws IOException { throw new NotActiveException("not in call to readObject"); }
public void defaultReadObject() throws NotActiveException { throw new NotActiveException("not in call to readObject"); }
public void registerValidation(ObjectInputValidation validation, int priority) throws NotActiveException { throw new NotActiveException("stream inactive"); }
/** {@inheritDoc} */ @Override public void defaultReadObject() throws IOException, ClassNotFoundException { if (curObj == null) throw new NotActiveException("Not in readObject() call."); readFields(curObj, curFields); }
/** {@inheritDoc} */ @Override public ObjectInputStream.GetField readFields() throws IOException, ClassNotFoundException { if (curObj == null) throw new NotActiveException("Not in readObject() call."); return new GetFieldImpl(this); }
/** {@inheritDoc} */ @Override public void defaultWriteObject() throws IOException { if (curObj == null) throw new NotActiveException("Not in writeObject() call."); writeFields(curObj, curFields); }
/** {@inheritDoc} */ @Override public ObjectOutputStream.PutField putFields() throws IOException { if (curObj == null) throw new NotActiveException("Not in writeObject() call or fields already written."); if (curPut == null) curPut = new PutFieldImpl(this); return curPut; }
public void writeFields() throws IOException { final RiverPutField putField = this.putField; if (putField == null) { throw new NotActiveException("no current PutField object"); } if (! compareAndSetState(UNWRITTEN_FIELDS, ON)) { throw new NotActiveException("writeFields() may only be called when the fields have not yet been written"); } this.putField = null; putField.write(marshaller); }
private void checkState() throws IOException { int state = this.state; if (state == ON) { return; } else if (state == OFF) { throw new NotActiveException("Object stream not active"); } else if (state == UNWRITTEN_FIELDS) { this.state = ON; marshaller.doWriteEmptyFields(serializableClass); return; } else { throw new IllegalStateException("Unknown state"); } }
private void checkState() throws IOException { switch (state) { case OFF: throw new NotActiveException("Object stream not active"); case ON: return; case UNREAD_FIELDS: case UNREAD_FIELDS_EOB: discardReadObject(); return; default: throw new IllegalStateException("Unknown state"); } }
/** * Default method to write objects to this stream. Serializable fields * defined in the object's class and superclasses are written to the output * stream. * * @throws IOException * if an error occurs while writing to the target stream. * @throws NotActiveException * if this method is not called from {@code writeObject()}. * @see ObjectInputStream#defaultReadObject */ public void defaultWriteObject() throws IOException { if (currentObject == null) { throw new NotActiveException(); } writeFieldValues(currentObject, currentClass); }
/** * Writes the fields of the object currently being written to the target * stream. The field values are buffered in the currently active {@code * PutField} object, which can be accessed by calling {@code putFields()}. * * @throws IOException * if an error occurs while writing to the target stream. * @throws NotActiveException * if there are no fields to write to the target stream. * @see #putFields */ public void writeFields() throws IOException { // Has to have fields to write if (currentPutField == null) { throw new NotActiveException(); } writeFieldValues(currentPutField); }
/** * Default method to read objects from this stream. Serializable fields * defined in the object's class and superclasses are read from the source * stream. * * @throws ClassNotFoundException * if the object's class cannot be found. * @throws IOException * if an I/O error occurs while reading the object data. * @throws NotActiveException * if this method is not called from {@code readObject()}. * @see ObjectOutputStream#defaultWriteObject */ public void defaultReadObject() throws IOException, ClassNotFoundException, NotActiveException { if (currentObject != null || !mustResolve) { readFieldValues(currentObject, currentClass); } else { throw new NotActiveException(); } }
public void defaultWriteObject() throws IOException { if (! compareAndSetState(UNWRITTEN_FIELDS, ON)) { throw new NotActiveException("writeFields() may only be called when the fields have not yet been written"); } try { marshaller.doWriteFields(serializableClass, current); } finally { putField = null; serializableClass = null; current = null; } }
public void defaultReadObject() throws IOException, ClassNotFoundException { int old = getAndSet(ON); switch (old) { case UNREAD_FIELDS: case UNREAD_FIELDS_EOB: break; default: throw new NotActiveException("readFields() may only be called when the fields have not yet been read"); } try { unmarshaller.readFields(current, serializableClassDescriptor, false); if (old == UNREAD_FIELDS_EOB) { restoreIdx = blockUnmarshaller.tempEndOfStream(); } } finally { serializableClassDescriptor = null; current = null; } }
void discardReadObject() throws IOException { int old = getAndSet(ON); switch (old) { case UNREAD_FIELDS: case UNREAD_FIELDS_EOB: break; default: throw new NotActiveException("readFields() may only be called when the fields have not yet been read"); } try { unmarshaller.discardFields(serializableClassDescriptor); if (old == UNREAD_FIELDS_EOB) { restoreIdx = blockUnmarshaller.tempEndOfStream(); } } finally { serializableClassDescriptor = null; current = null; } }