本文整理汇总了Java中java.io.ObjectInputValidation类的典型用法代码示例。如果您正苦于以下问题:Java ObjectInputValidation类的具体用法?Java ObjectInputValidation怎么用?Java ObjectInputValidation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ObjectInputValidation类属于java.io包,在下文中一共展示了ObjectInputValidation类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readObject
import java.io.ObjectInputValidation; //导入依赖的package包/类
/**
* @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
);
}
示例2: pasteObject
import java.io.ObjectInputValidation; //导入依赖的package包/类
@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$
}
}
示例3: readObject
import java.io.ObjectInputValidation; //导入依赖的package包/类
/**
* 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);
}
示例4: readObject
import java.io.ObjectInputValidation; //导入依赖的package包/类
private void readObject (ObjectInputStream ois) throws ClassNotFoundException, IOException {
ois.defaultReadObject ();
ois.registerValidation(new ObjectInputValidation() {
public void validateObject() throws InvalidObjectException {
warnedFiles.add(getFileImpl());
}
}, 0);
}
示例5: createObjectInputStream
import java.io.ObjectInputValidation; //导入依赖的package包/类
/**
* 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);
}
示例6: createObjectInputStream
import java.io.ObjectInputValidation; //导入依赖的package包/类
/**
* 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);
}
示例7: readObject
import java.io.ObjectInputValidation; //导入依赖的package包/类
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);
}
示例8: createObjectInputStream
import java.io.ObjectInputValidation; //导入依赖的package包/类
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);
}
示例9: createObjectInputStream
import java.io.ObjectInputValidation; //导入依赖的package包/类
/**
* 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();
}
});
}
示例10: registerValidation
import java.io.ObjectInputValidation; //导入依赖的package包/类
void registerValidation(ObjectInputValidation validation, int priority)
throws NotActiveException, InvalidObjectException;
示例11: registerValidation
import java.io.ObjectInputValidation; //导入依赖的package包/类
public final synchronized void registerValidation(ObjectInputValidation obj,
int prio)
throws NotActiveException, InvalidObjectException{
// XXX I18N, logging needed.
throw new Error("Method registerValidation not supported");
}
示例12: registerValidation
import java.io.ObjectInputValidation; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public void registerValidation(ObjectInputValidation obj, int pri) {
// No-op.
}
示例13: registerValidation
import java.io.ObjectInputValidation; //导入依赖的package包/类
public void registerValidation(ObjectInputValidation paramObjectInputValidation, int paramInt)
{
peekCallback().registerValidation(paramObjectInputValidation, paramInt);
}