Java 类java.io.ObjectInputValidation 实例源码

项目:incubator-netbeans    文件:LocalFileSystem.java   
/**
* @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
    );
}
项目:verigreen    文件:ObjectCopier.java   
@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$
    }
}
项目:GettinCRAFTy    文件:AbstractCompoundDocument.java   
/**
 * 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);
}
项目:incubator-netbeans    文件:DataEditorSupport.java   
private void readObject (ObjectInputStream ois) throws ClassNotFoundException, IOException {
    ois.defaultReadObject ();
    ois.registerValidation(new ObjectInputValidation() {
        public void validateObject() throws InvalidObjectException {
            warnedFiles.add(getFileImpl());
        }
    }, 0);
}
项目:lams    文件:XStream.java   
/**
 * 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);
}
项目:xstream    文件:XStream.java   
/**
 * 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);
}
项目:xstream    文件:SerializationCallbackOrderTest.java   
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);
        }
项目:QuizUpWinner    文件:XStream.java   
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);
}
项目:reflexcore    文件:XStream.java   
/**
    * 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();
                }
            });
}
项目:lams    文件:CustomObjectInputStream.java   
void registerValidation(ObjectInputValidation validation, int priority)
throws NotActiveException, InvalidObjectException;
项目:lams    文件:CustomObjectInputStream.java   
@Override
public void registerValidation(final ObjectInputValidation validation, final int priority)
        throws NotActiveException, InvalidObjectException {
    peekCallback().registerValidation(validation, priority);
}
项目:OpenJSharp    文件:IIOPInputStream.java   
public final synchronized void registerValidation(ObjectInputValidation obj,
                                                  int prio)
    throws NotActiveException, InvalidObjectException{
    // XXX I18N, logging needed.
    throw new Error("Method registerValidation not supported");
}
项目:openjdk-jdk10    文件:IIOPInputStream.java   
public final synchronized void registerValidation(ObjectInputValidation obj,
                                                  int prio)
    throws NotActiveException, InvalidObjectException{
    // XXX I18N, logging needed.
    throw new Error("Method registerValidation not supported");
}
项目:openjdk9    文件:IIOPInputStream.java   
public final synchronized void registerValidation(ObjectInputValidation obj,
                                                  int prio)
    throws NotActiveException, InvalidObjectException{
    // XXX I18N, logging needed.
    throw new Error("Method registerValidation not supported");
}
项目:lookaside_java-1.8.0-openjdk    文件:IIOPInputStream.java   
public final synchronized void registerValidation(ObjectInputValidation obj,
                                                  int prio)
    throws NotActiveException, InvalidObjectException{
    // XXX I18N, logging needed.
    throw new Error("Method registerValidation not supported");
}
项目:jdk8u_corba    文件:IIOPInputStream.java   
public final synchronized void registerValidation(ObjectInputValidation obj,
                                                  int prio)
    throws NotActiveException, InvalidObjectException{
    // XXX I18N, logging needed.
    throw new Error("Method registerValidation not supported");
}
项目:xstream    文件:CustomObjectInputStream.java   
void registerValidation(ObjectInputValidation validation, int priority)
throws NotActiveException, InvalidObjectException;
项目:xstream    文件:CustomObjectInputStream.java   
@Override
public void registerValidation(final ObjectInputValidation validation, final int priority)
        throws NotActiveException, InvalidObjectException {
    peekCallback().registerValidation(validation, priority);
}
项目:ignite    文件:OptimizedObjectInputStream.java   
/** {@inheritDoc} */
@Override public void registerValidation(ObjectInputValidation obj, int pri) {
    // No-op.
}
项目:infobip-open-jdk-8    文件:IIOPInputStream.java   
public final synchronized void registerValidation(ObjectInputValidation obj,
                                                  int prio)
    throws NotActiveException, InvalidObjectException{
    // XXX I18N, logging needed.
    throw new Error("Method registerValidation not supported");
}
项目:QuizUpWinner    文件:CustomObjectInputStream.java   
public void registerValidation(ObjectInputValidation paramObjectInputValidation, int paramInt)
{
  peekCallback().registerValidation(paramObjectInputValidation, paramInt);
}
项目:openjdk-source-code-learn    文件:IIOPInputStream.java   
public final synchronized void registerValidation(ObjectInputValidation obj,
                                                  int prio)
    throws NotActiveException, InvalidObjectException{
    // XXX I18N, logging needed.
    throw new Error("Method registerValidation not supported");
}
项目:OLD-OpenJDK8    文件:IIOPInputStream.java   
public final synchronized void registerValidation(ObjectInputValidation obj,
                                                  int prio)
    throws NotActiveException, InvalidObjectException{
    // XXX I18N, logging needed.
    throw new Error("Method registerValidation not supported");
}
项目:openjdk-orb    文件:IIOPInputStream.java   
public final synchronized void registerValidation(ObjectInputValidation obj,
                                                  int prio)
    throws NotActiveException, InvalidObjectException{
    // XXX I18N, logging needed.
    throw new Error("Method registerValidation not supported");
}
项目:openjdk-icedtea7    文件:IIOPInputStream.java   
public final synchronized void registerValidation(ObjectInputValidation obj,
                                                  int prio)
    throws NotActiveException, InvalidObjectException{
    // XXX I18N, logging needed.
    throw new Error("Method registerValidation not supported");
}
项目:QuizUpWinner    文件:CustomObjectInputStream.java   
public abstract void registerValidation(ObjectInputValidation paramObjectInputValidation, int paramInt);