Class StringObject

  • All Implemented Interfaces:
    StringAccessor, java.io.Serializable

    public class StringObject
    extends java.lang.Object
    implements java.io.Serializable, StringAccessor
    A concrete implementation of StringAccessor that uses a java.lang.String object.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) static long serialVersionUID  
      private java.lang.String str
      The java.lang.String object.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private StringObject​(java.lang.String str)
      Constructs the object.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static StringObject fromString​(java.lang.String str)
      Static method that returns a StringObject from the given java.lang.String.
      java.io.Reader getReader()
      Returns a Reader that can read from the string.
      int length()
      Returns the length of the string.
      java.lang.String toString()
      Returns this object as a java.lang.String object (easy!)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • str

        private java.lang.String str
        The java.lang.String object.
    • Constructor Detail

      • StringObject

        private StringObject​(java.lang.String str)
        Constructs the object.
    • Method Detail

      • length

        public int length()
        Returns the length of the string.
        Specified by:
        length in interface StringAccessor
      • getReader

        public java.io.Reader getReader()
        Returns a Reader that can read from the string.
        Specified by:
        getReader in interface StringAccessor
      • toString

        public java.lang.String toString()
        Returns this object as a java.lang.String object (easy!)
        Specified by:
        toString in interface StringAccessor
        Overrides:
        toString in class java.lang.Object
      • fromString

        public static StringObject fromString​(java.lang.String str)
        Static method that returns a StringObject from the given java.lang.String.