java – Document类之间的区别
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了java – Document类之间的区别,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2549字,纯文字阅读大概需要4分钟。
内容图文
![java – Document类之间的区别](/upload/InfoBanner/zyjiaocheng/729/0f67cafdcc0a41bf82a570b0f06742a7.jpg)
我一直在阅读javadocs试图掌握swing文档API,但我无法从中得到一些明智的东西,因为有很多类:Document,StyledDocument,AbstractDocument,DefaultStyledDocument,PlainDocument,HTMLDocument,还有人提到了DocumentFilter.这个问题更多的是一般性的,所以有人可以概述实现之间的差异以及不同的接口和摘要的用途吗?
对于我的具体情况,我想要实现的是一个数据结构,它将:
>只保留三行文字.和
>属性不能是每行或文档.我会在其他一些结构中有几千个这样的
>开销很重要.
我能用于此的任何东西,还是扩展一些东西更好?如果是这样,什么?
解决方法:
您列出的所有Document类都具有相同的基本功能,并且每个类都基于需要填充的利基进行扩展.真的,这只是意识到你需要做什么并使用适当的文档类型.例如,如果我正在编辑HTML文件,那么我将使用HTMLDocument类.
我在下面的问题中列出了您要求的每个文档类的简要说明.
The Document interface represents the
entire HTML or XML document.
Conceptually, it is the root of the
document tree, and provides the
primary access to the document’s data.
这是所有其他Document类型将继承的接口.它提供了要遵循的所有其他文档类型的合同.
This class implements a locking
mechanism for the document it allows
multiple readers or one writer, and
writers must wait until all observers
of the document have been notified of
a previous change before beginning
another mutation to the document.
此类允许您使用不同类型的文档并使用非常丢失的规则集.这个类更难实现,因为它非常通用.
另一个为所有样式文档提供合同的界面. DefaultStyledDocument实现了这个接口,所以我们接下来会这样做.
A document that can be marked up with
character and paragraph styles in a
manner similar to the Rich Text
Format. The element structure for this
document represents style crossings
for style runs. These style runs are
mapped into a paragraph element
structure (which may reside in some
other structure). The style runs break
at paragraph boundaries since logical
styles are assigned to paragraph
boundaries.
DefaultStyledDocument允许您在文档中放置特殊字符以帮助格式化等…当您考虑DefaultStyledDocument时,请考虑Microsoft Word.
hen a Document containing a
DocumentFilter is modified (either
through insert or remove), it forwards
the appropriate method invocation to
the DocumentFilter.
这是一个非常有用的类,它“监听”针对您的文档发生的事件(即修改),并在每个事件发生时执行操作.
实现AbstractDocument并且不包含任何类型的格式化特殊字符(Think notepad vs. Word).当你只想存储文本(日志文件等)时,你应该使用它
A document that models HTML. The
purpose of this model is to support
both browsing and editing.
在创建/修改包含HTML代码并且要在浏览器中查看的文档时,应使用HTMLDocument.
内容总结
以上是互联网集市为您收集整理的java – Document类之间的区别全部内容,希望文章能够帮你解决java – Document类之间的区别所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。