Package com.dd.plist

Class NSString

All Implemented Interfaces:
Cloneable, Comparable<NSObject>

public class NSString extends NSObject
The NSString class is a wrapper for a string.
See Also:
  • Field Details

  • Constructor Details

    • NSString

      public NSString(byte[] bytes, String encoding) throws UnsupportedEncodingException
      Creates a new NSString instance from its binary representation.
      Parameters:
      bytes - The binary representation.
      encoding - The string encoding (name of the charset).
      Throws:
      UnsupportedEncodingException - When the given encoding is not supported by the JRE.
      See Also:
    • NSString

      public NSString(byte[] bytes, int startIndex, int endIndex, String encoding) throws UnsupportedEncodingException
      Creates a new NSString instance from its binary representation.
      Parameters:
      bytes - An array containing the binary representation of the string.
      startIndex - The offset inside the array at which the string data starts.
      endIndex - The offset inside the array at which the string data ends.
      encoding - The string encoding (name of the charset).
      Throws:
      UnsupportedEncodingException - When the given encoding is not supported by the JRE.
      See Also:
    • NSString

      public NSString(String string)
      Creates a new NSString instance with the specified content.
      Parameters:
      string - The string that will be contained in the NSString.
  • Method Details

    • intValue

      public int intValue()
      Gets the integer value of this string.
      Returns:
      The integer value of this string, assuming a decimal representation and skipping whitespace at the beginning of the string. If the string does not contain a valid decimal representation of a number, 0 is returned. If the string contains an integer larger than Integer.MAX_VALUE, Integer.MAX_VALUE is returned. If the string contains an integer less than Integer.MIN_VALUE, Integer.MIN_VALUE is returned.
    • floatValue

      public float floatValue()
      Gets the floating-point value of this string.
      Returns:
      The floating-point value of this string, assuming a decimal representation and skipping whitespace at the beginning of the string. If the string does not contain a valid decimal representation of a number, 0 is returned. If the string contains an integer larger than Float.MAX_VALUE, Float.MAX_VALUE is returned. If the string contains an integer less than -Float.MAX_VALUE, -Float.MAX_VALUE is returned.
    • doubleValue

      public double doubleValue()
      Gets the floating-point value (double precision) of this string.
      Returns:
      The floating-point value of this string, assuming a decimal representation and skipping whitespace at the beginning of the string. If the string does not contain a valid decimal representation of a floating-point number, 0 is returned.
    • boolValue

      public boolean boolValue()
      Gets the boolean value of this string.
      Returns:
      The boolean value of this string. Leading whitespaces are ignored. Any + or - sign and leading zeroes are ignored. If the remaining string starts with 'Y', 'y', 'T', 't' or a positive digit (1-9), true is returned. Otherwise, false is returned.

      Examples: "YES" is true "true" is true " YES" is true "+1" is true "-9" is true " +01" is true "0" is false "false" is false "no" is false "1FALSE" is true "0TRUE" is true "FALSE1" is false

    • getContent

      public String getContent()
      Gets the string content of this instance.
      Returns:
      This string contained in this instance.
    • setContent

      public void setContent(String c)
      Sets the string content of this instance.
      Parameters:
      c - The new content of this string object.
    • append

      public void append(NSString s)
      Appends a string to this string.
      Parameters:
      s - The string to append.
    • append

      public void append(String s)
      Appends a string to this string.
      Parameters:
      s - The string to append.
    • prepend

      public void prepend(String s)
      Prepends a string to this string.
      Parameters:
      s - The string to prepend.
    • prepend

      public void prepend(NSString s)
      Prepends a string to this string.
      Parameters:
      s - The string to prepend.
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • clone

      public NSString clone()
      Description copied from class: NSObject
      Creates and returns a deep copy of this instance.
      Specified by:
      clone in class NSObject
      Returns:
      A clone of this instance.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toJavaObject

      public Object toJavaObject()
      Description copied from class: NSObject
      Converts this NSObject into an equivalent object of the Java Runtime Environment.
      • NSArray objects are converted to arrays.
      • NSDictionary objects are converted to objects extending the Map class.
      • NSSet objects are converted to objects extending the Set class.
      • NSNumber objects are converted to primitive number values (int, long, double or boolean).
      • NSString objects are converted to String objects.
      • NSData objects are converted to byte arrays.
      • NSDate objects are converted to Date objects.
      • UID objects are converted to byte arrays.
      Specified by:
      toJavaObject in class NSObject
      Returns:
      A native java object representing this NSObject's value.
    • toXML

      void toXML(StringBuilder xml, int level)
      Description copied from class: NSObject
      Generates the XML representation of the object (without XML headers or enclosing plist-tags).
      Specified by:
      toXML in class NSObject
      Parameters:
      xml - The StringBuilder onto which the XML representation is appended.
      level - The indentation level of the object.
    • toBinary

      public void toBinary(BinaryPropertyListWriter out) throws IOException
      Description copied from class: NSObject
      Generates the binary representation of the object.
      Specified by:
      toBinary in class NSObject
      Parameters:
      out - The output stream to serialize the object to.
      Throws:
      IOException - If an I/O error occurs while writing to the stream or the object structure contains data that cannot be saved.
    • toASCII

      protected void toASCII(StringBuilder ascii, int level)
      Description copied from class: NSObject
      Generates the ASCII representation of this object. The generated ASCII representation does not end with a newline. Complies with the Old-Style ASCII Property Lists definition.
      Specified by:
      toASCII in class NSObject
      Parameters:
      ascii - The StringBuilder onto which the ASCII representation is appended.
      level - The indentation level of the object.
    • toASCIIGnuStep

      protected void toASCIIGnuStep(StringBuilder ascii, int level)
      Description copied from class: NSObject
      Generates the ASCII representation of this object in the GnuStep format. The generated ASCII representation does not end with a newline.
      Specified by:
      toASCIIGnuStep in class NSObject
      Parameters:
      ascii - The StringBuilder onto which the ASCII representation is appended.
      level - The indentation level of the object.
    • compareTo

      public int compareTo(NSObject o)
    • escapeStringForASCII

      static String escapeStringForASCII(String s)
      Escapes a string for use in ASCII property lists.
      Parameters:
      s - The unescaped string.
      Returns:
      The escaped string.
    • escapeStringForXml

      static String escapeStringForXml(String s)