public class Encoder extends Object
Encoder
是一类可用于创建文件或流的编码集JavaBeans国家在其公共API。的
Encoder
,与其坚持代表一起,是负责把对象图分解为一系列
Statements
s和
Expression
s可以用来创建它。子类通常提供一种语法,这些词语的使用一些人类可读的形式像java源代码或XML。
Constructor and Description |
---|
Encoder() |
Modifier and Type | Method and Description |
---|---|
Object |
get(Object oldInstance)
返回的流创建的环境
oldInstance 临时值。
|
ExceptionListener |
getExceptionListener()
获取此流的异常处理程序。
|
PersistenceDelegate |
getPersistenceDelegate(类<?> type)
返回给定类型的持久化委托。
|
Object |
remove(Object oldInstance)
移除此实例的条目,返回旧的条目。
|
void |
setExceptionListener(ExceptionListener exceptionListener)
设置此流
exceptionListener 异常处理程序。
|
void |
setPersistenceDelegate(类<?> type, PersistenceDelegate delegate)
将指定的持久化委托与给定类型关联关联。
|
void |
writeExpression(Expression oldExp)
执行第一个检查,看看是否有这个值的表达式已经被写入。
|
protected void |
writeObject(Object o)
将指定的对象写入输出流。
|
void |
writeStatement(Statement oldStm)
声明
oldStm 写入到流。
|
protected void writeObject(Object o)
o
-要写入流对象。
XMLDecoder.readObject()
public void setExceptionListener(ExceptionListener exceptionListener)
exceptionListener
异常处理,异常处理程序时被通知此流捕捉收回的例外。
exceptionListener
-该流的异常处理程序;如果
null
默认侦听器将使用异常。
getExceptionListener()
public ExceptionListener getExceptionListener()
setExceptionListener(java.beans.ExceptionListener)
public PersistenceDelegate getPersistenceDelegate(类<?> type)
setPersistenceDelegate(java.lang.Class<?>, java.beans.PersistenceDelegate)
方法返回有关。Bean
坚持代表应该命名为BeanPersistenceDelegate
和位于同一个包。公共类豆…}公共课beanpersistencedelegate {…}的
BeanPersistenceDelegate
类的实例返回的Bean
类。null
,共享内部持久委托返回编码null
价值。枚举
宣言,共享内部持久委托返回编码这个枚举常量的名字。Proxy.newProxyInstance(java.lang.ClassLoader, java.lang.Class<?>[], java.lang.reflect.InvocationHandler)
方法。BeanInfo
已经定义了一个“persistencedelegate”属性BeanDescriptor
,此命名属性的返回值。Introspector
类。默认构造函数的参数是有ConstructorProperties
注释最多的构造函数。如果构造函数没有ConstructorProperties
注释,那么默认构造函数(不带参数的构造函数)将被使用。例如,下面的代码片段中,为Foo
类的默认构造函数将被使用,而两个参数的构造函数的类将用于Bar
。公共类Foo {公共foo() {…}公共foo(int x){…}}公共类酒吧公共bar() {…}“constructorproperties({“x”})公共酒吧(int x){…}“constructorproperties({“X”、“Y”})公共酒吧(x,y){…}}
type
-类的对象
setPersistenceDelegate(java.lang.Class<?>, java.beans.PersistenceDelegate)
,
Introspector.getBeanInfo(java.lang.Class<?>)
,
BeanInfo.getBeanDescriptor()
public void setPersistenceDelegate(类<?> type, PersistenceDelegate delegate)
type
-该类的对象,指定委托适用于持久性
delegate
为给定类型的实例的持久性代表
getPersistenceDelegate(java.lang.Class<?>)
,
Introspector.getBeanInfo(java.lang.Class<?>)
,
BeanInfo.getBeanDescriptor()
public Object remove(Object oldInstance)
oldInstance
-应删除的条目。
get(java.lang.Object)
public Object get(Object oldInstance)
oldInstance
临时值。一个持久的代表可以利用其
mutatesTo
方法确定这个值可能被初始化的输出或是一个新的对象必须重新形成的等效对象的实例化。如果流尚未看到此值,则返回空值。
oldInstance
-实例要抬头。
public void writeStatement(Statement oldStm)
oldStm
写入到流。的
oldStm
应该完全在调用者环境写的,即目标和所有参数应该被写入部分对象图。这些表达式代表了一系列的“发生了什么”的表达式,它告诉输出流如何产生一个像原来的对象图。
该方法的实现将产生一个第二个表达式,以表示在流读取时将存在的环境中的相同的表达式。这是通过调用writeObject
对目标和所有的争论和建设成果的新表达的实现。
oldStm
-被写入到流中的表达。
public void writeExpression(Expression oldExp)
writeStatement
,和这个表达式的值是调和的克隆表达的值通过调用
writeObject
。
oldExp
-被写入到流中的表达。
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.