美文网首页码农的世界
跟 JDK 学英语(3)- Appendable

跟 JDK 学英语(3)- Appendable

作者: 码语生活 | 来源:发表于2018-10-26 23:50 被阅读1次

    一、原文与翻译

    public interface Appendable

    An object to which char sequences and values can be appended. The Appendable interface must be implemented by any class whose instances are intended to receive formatted output from a Formatter.

    一个可以追加字符序列和值的对象。那些类的实例如果是打算用来从一个 Formatter 对象接收格式化输出的,那么这些类必须实现 Appendable 接口。

    The characters to be appended should be valid Unicode characters as described in Unicode Character Representation. Note that supplementary characters may be composed of multiple 16-bit char values.

    被追加的字符必须是有效的在统一字符表现形式里规定的 Unicode 字符。注意补充的字符可能是由多个 16 位的字符值组成。

    Appendables are not necessarily safe for multithreaded access. Thread safety is the responsibility of classes that extend and implement this interface.

    实现了 Appendable 的类在多线程访问下不一定是线程安全的。线程安全是继承和实现了这个接口的类的责任。

    Since this interface may be implemented by existing classes with different styles of error handling there is no guarantee that errors will be propagated to the invoker.

    由于该接口可能被已存在的带有不同错误处理风格的类所实现,因此无法保证错误会被传播给它的调用者。

    Since: 1.5
    自:1.5

    二、词汇学习

    character: 字符,性格,特征
    supplementary: 补充的
    propagated: 传播,繁殖
    sequence: 序列,顺序
    be composed of: 由...组成

    三、句子分析

    An object to which char sequences and values can be appended.

    这不算一个完整的句子,只是用来描述这是一个什么样的对象。理解的顺序应该是 char sequences and values can be appended to the object.

    四、技术要点

    JDK 实现了 Appendable 接口的类有 BufferedWriter, CharArrayWriter, CharBuffer, FileWriter, FilterWriter, LogStream, OutputStreamWriter, PipedWriter, PrintStream, PrintWriter, StringBuffer, StringBuilder, StringWriter, Writer.

    这些都是操作字符串或字符串输出的类,我们平时拼接字符串,经常会用到该接口的 append 方法。

    须由具体实现类来保证线程安全问题,如 StringBuilder 是非线程安全的,而 StringBuffer 是线程安全的。

    微信公众号.jpg

    相关文章

      网友评论

        本文标题:跟 JDK 学英语(3)- Appendable

        本文链接:https://www.haomeiwen.com/subject/velrtqtx.html