java类java.io.ObjectInputValidation的实例源码

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


问题


面经


文章

微信
公众号

扫码关注公众号