/** * @param in the input stream to read from * @exception IOException error during read * @exception ClassNotFoundException when class not found */ private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { in.defaultReadObject(); in.registerValidation( new ObjectInputValidation() { public void validateObject() { if (attr.getClass() == DefaultAttributes.class) { Impl impl = new Impl(LocalFileSystem.this); attr = new InnerAttrs(LocalFileSystem.this, impl, impl, impl); } } }, 0 ); }
@SuppressWarnings("unchecked") public T pasteObject() { try { ByteArrayInputStream bai = new ByteArrayInputStream(objectHolder); ObjectInputStream oi = new ObjectInputStream(bai); T resourceList = (T) oi.readObject(); if (resourceList instanceof ObjectInputValidation) { ((ObjectInputValidation) resourceList).validateObject(); } return resourceList; } catch (Exception e) { throw new RuntimeException("Failed To Paste Object", e); //$NON-NLS-1$ } }
/** * Overridden to properly register component documents with the creole * register when this compound is deserialized. */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); // register a validation callback to add our child documents // to the creole register and fire the relevant events. This // is what the Factory would do if the children were loaded in // the normal way. stream.registerValidation(new ObjectInputValidation() { public void validateObject() { for(Document d : documents.values()) { Gate.getCreoleRegister().get(d.getClass().getName()) .addInstantiation(d); Gate.getCreoleRegister().resourceLoaded( new CreoleEvent(d, CreoleEvent.RESOURCE_LOADED)); } } }, 0); }
private void readObject (ObjectInputStream ois) throws ClassNotFoundException, IOException { ois.defaultReadObject (); ois.registerValidation(new ObjectInputValidation() { public void validateObject() throws InvalidObjectException { warnedFiles.add(getFileImpl()); } }, 0); }
/** * Creates an ObjectInputStream that deserializes a stream of objects from a reader using XStream. <h3>Example</h3> * * <pre> * ObjectInputStream in = xstream.createObjectOutputStream(aReader); * int a = out.readInt(); * Object b = out.readObject(); * Object c = out.readObject(); * </pre> * * @see #createObjectOutputStream(com.thoughtworks.xstream.io.HierarchicalStreamWriter, String) * @since 1.0.3 */ public ObjectInputStream createObjectInputStream(final HierarchicalStreamReader reader) throws IOException { return new CustomObjectInputStream(new CustomObjectInputStream.StreamCallback() { @Override public Object readFromStream() throws EOFException { if (!reader.hasMoreChildren()) { throw new EOFException(); } reader.moveDown(); final Object result = unmarshal(reader); reader.moveUp(); return result; } @Override public Map<String, Object> readFieldsFromStream() throws IOException { throw new NotActiveException("not in call to readObject"); } @Override public void defaultReadObject() throws NotActiveException { throw new NotActiveException("not in call to readObject"); } @Override public void registerValidation(final ObjectInputValidation validation, final int priority) throws NotActiveException { throw new NotActiveException("stream inactive"); } @Override public void close() { reader.close(); } }, classLoaderReference); }
/** * Creates an ObjectInputStream that deserializes a stream of objects from a reader using XStream. * * @see #createObjectOutputStream(com.thoughtworks.xstream.io.HierarchicalStreamWriter, String) * @see #createObjectInputStream(com.thoughtworks.xstream.io.HierarchicalStreamReader) * @since 1.4.10 */ public ObjectInputStream createObjectInputStream(final HierarchicalStreamReader reader, final DataHolder dataHolder) throws IOException { return new CustomObjectInputStream(new CustomObjectInputStream.StreamCallback() { @Override public Object readFromStream() throws EOFException { if (!reader.hasMoreChildren()) { throw new EOFException(); } reader.moveDown(); final Object result = unmarshal(reader, dataHolder); reader.moveUp(); return result; } @Override public Map<String, Object> readFieldsFromStream() throws IOException { throw new NotActiveException("not in call to readObject"); } @Override public void defaultReadObject() throws NotActiveException { throw new NotActiveException("not in call to readObject"); } @Override public void registerValidation(final ObjectInputValidation validation, final int priority) throws NotActiveException { throw new NotActiveException("stream inactive"); } @Override public void close() { reader.close(); } }, classLoaderReference); }
private void readObject(ObjectInputStream s) throws IOException { final int LOW_PRIORITY = -5; final int MEDIUM_PRIORITY = 0; final int HIGH_PRIORITY = 5; s.registerValidation(new ObjectInputValidation() { public void validateObject() { log.actual("validateObject() medium priority 1"); } }, MEDIUM_PRIORITY); s.registerValidation(new ObjectInputValidation() { public void validateObject() { log.actual("validateObject() high priority"); } }, HIGH_PRIORITY); s.registerValidation(new ObjectInputValidation() { public void validateObject() { log.actual("validateObject() low priority"); } }, LOW_PRIORITY); s.registerValidation(new ObjectInputValidation() { public void validateObject() { log.actual("validateObject() medium priority 2"); } }, MEDIUM_PRIORITY); }
public ObjectInputStream createObjectInputStream(final HierarchicalStreamReader paramHierarchicalStreamReader) { return new CustomObjectInputStream(new CustomObjectInputStream.StreamCallback() { public void close() { paramHierarchicalStreamReader.close(); } public void defaultReadObject() { throw new NotActiveException("not in call to readObject"); } public Map readFieldsFromStream() { throw new NotActiveException("not in call to readObject"); } public Object readFromStream() { if (!paramHierarchicalStreamReader.hasMoreChildren()) throw new EOFException(); paramHierarchicalStreamReader.moveDown(); Object localObject = XStream.this.unmarshal(paramHierarchicalStreamReader); paramHierarchicalStreamReader.moveUp(); return localObject; } public void registerValidation(ObjectInputValidation paramAnonymousObjectInputValidation, int paramAnonymousInt) { throw new NotActiveException("stream inactive"); } } , this.classLoaderReference); }
/** * Creates an ObjectInputStream that deserializes a stream of objects from a reader using XStream. * * <h3>Example</h3> * <pre>ObjectInputStream in = xstream.createObjectOutputStream(aReader); * int a = out.readInt(); * Object b = out.readObject(); * Object c = out.readObject();</pre> * * @see #createObjectOutputStream(com.thoughtworks.xstream.io.HierarchicalStreamWriter, String) * @since 1.0.3 */ public ObjectInputStream createObjectInputStream( final HierarchicalStreamReader reader) throws IOException { return new CustomObjectInputStream( new CustomObjectInputStream.StreamCallback() { public Object readFromStream() throws EOFException { if (!reader.hasMoreChildren()) { throw new EOFException(); } reader.moveDown(); Object result = unmarshal(reader); reader.moveUp(); return result; } 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"); } public void close() { reader.close(); } }); }
void registerValidation(ObjectInputValidation validation, int priority) throws NotActiveException, InvalidObjectException;
@Override public void registerValidation(final ObjectInputValidation validation, final int priority) throws NotActiveException, InvalidObjectException { peekCallback().registerValidation(validation, priority); }
public final synchronized void registerValidation(ObjectInputValidation obj, int prio) throws NotActiveException, InvalidObjectException{ // XXX I18N, logging needed. throw new Error("Method registerValidation not supported"); }
/** {@inheritDoc} */ @Override public void registerValidation(ObjectInputValidation obj, int pri) { // No-op. }
public void registerValidation(ObjectInputValidation paramObjectInputValidation, int paramInt) { peekCallback().registerValidation(paramObjectInputValidation, paramInt); }
public abstract void registerValidation(ObjectInputValidation paramObjectInputValidation, int paramInt);