哥哥姐姐们块帮忙呀!

kongxx
博客专家认证
2002-12-16 04:34:43
在Java中怎样将org.apache.xalan.transformer.TransformerImpl对象序列化。
因为这个对象不是从Serializable继承的,现在我需要序列化来提高效率,怎么办?

快帮忙呀!
...全文
47 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
Patrick_DK 2002-12-17
  • 打赏
  • 举报
回复
// 写几句意思意思

public class XXX
implements Serializable
{
private TransformerImpl tfi;
...

public TransformerImpl getTransformerImpl()
{
...
return this.tfi;
}
}
Patrick_DK 2002-12-17
  • 打赏
  • 举报
回复
哥们,你看不见阿

我上面不是写了
kongxx 2002-12-17
  • 打赏
  • 举报
回复
不行,这个类不支持序列化,直接放在Vector中序列化运行时会报错,现在我想在外面包一层,应该怎么包?
Patrick_DK 2002-12-16
  • 打赏
  • 举报
回复
// 写几句意思意思

public class XXX
implements Serializable
{
private TransformerImpl tfi;
...

public TransformerImpl getTransformerImpl()
{
...
return this.tfi;
}
}
longaway 2002-12-16
  • 打赏
  • 举报
回复
java.io

public interface Serializable
Serializability of a class is enabled by the class implementing the java.io.Serializable interface. Classes that do not implement this interface will not have any of their state serialized or deserialized. All subtypes of a serializable class are themselves serializable. The serialization interface has no methods or fields and serves only to identify the semantics of being serializable.

To allow subtypes of non-serializable classes to be serialized, the subtype may assume responsibility for saving and restoring the state of the supertype's public, protected, and (if accessible) package fields. The subtype may assume this responsibility only if the class it extends has an accessible no-arg constructor to initialize the class's state. It is an error to declare a class Serializable if this is not the case. The error will be detected at runtime.
longaway 2002-12-16
  • 打赏
  • 举报
回复
兄弟
所有的类都是从 object 继承来的。
所以,所有的类都是支持 序列化的。

只不过需要 明示的
声明 实现 Serializable 接口。

你非要这样用的话,自己写一个子类好了。

67,512

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧