Package com.dd.plist
Class NSString
java.lang.Object
com.dd.plist.NSObject
com.dd.plist.NSString
- All Implemented Interfaces:
Cloneable,Comparable<NSObject>
The NSString class is a wrapper for a string.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static CharsetEncoderprivate Stringprivate static CharsetEncoderprivate static CharsetEncoderFields inherited from class com.dd.plist.NSObject
ASCII_LINE_LENGTH, NEWLINE -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new NSString instance from its binary representation.Creates a new NSString instance from its binary representation.Creates a new NSString instance with the specified content. -
Method Summary
Modifier and TypeMethodDescriptionvoidAppends a string to this string.voidAppends a string to this string.booleanGets the boolean value of this string.clone()Creates and returns a deep copy of this instance.intdoubleGets the floating-point value (double precision) of this string.boolean(package private) static StringEscapes a string for use in ASCII property lists.(package private) static StringfloatGets the floating-point value of this string.Gets the string content of this instance.inthashCode()intintValue()Gets the integer value of this string.voidPrepends a string to this string.voidPrepends a string to this string.voidsetContent(String c) Sets the string content of this instance.protected voidtoASCII(StringBuilder ascii, int level) Generates the ASCII representation of this object.protected voidtoASCIIGnuStep(StringBuilder ascii, int level) Generates the ASCII representation of this object in the GnuStep format.voidGenerates the binary representation of the object.Converts this NSObject into an equivalent object of the Java Runtime Environment.toString()(package private) voidtoXML(StringBuilder xml, int level) Generates the XML representation of the object (without XML headers or enclosing plist-tags).Methods inherited from class com.dd.plist.NSObject
assignIDs, fromJavaObject, indent, toJavaObject, toXMLPropertyList
-
Field Details
-
asciiEncoder
-
utf16beEncoder
-
utf8Encoder
-
-
-
Constructor Details
-
NSString
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
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
Gets the string content of this instance.- Returns:
- This string contained in this instance.
-
setContent
Sets the string content of this instance.- Parameters:
c- The new content of this string object.
-
append
Appends a string to this string.- Parameters:
s- The string to append.
-
append
Appends a string to this string.- Parameters:
s- The string to append.
-
prepend
Prepends a string to this string.- Parameters:
s- The string to prepend.
-
prepend
Prepends a string to this string.- Parameters:
s- The string to prepend.
-
equals
-
hashCode
public int hashCode() -
clone
Description copied from class:NSObjectCreates and returns a deep copy of this instance. -
toString
-
toJavaObject
Description copied from class:NSObjectConverts this NSObject into an equivalent object of the Java Runtime Environment.NSArrayobjects are converted to arrays.NSDictionaryobjects are converted to objects extending theMapclass.NSSetobjects are converted to objects extending theSetclass.NSNumberobjects are converted to primitive number values (int, long, double or boolean).NSStringobjects are converted toStringobjects.NSDataobjects are converted to byte arrays.NSDateobjects are converted toDateobjects.UIDobjects are converted to byte arrays.
- Specified by:
toJavaObjectin classNSObject- Returns:
- A native java object representing this NSObject's value.
-
toXML
Description copied from class:NSObjectGenerates the XML representation of the object (without XML headers or enclosing plist-tags).- Specified by:
toXMLin classNSObject- Parameters:
xml- TheStringBuilderonto which the XML representation is appended.level- The indentation level of the object.
-
toBinary
Description copied from class:NSObjectGenerates the binary representation of the object.- Specified by:
toBinaryin classNSObject- 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
Description copied from class:NSObjectGenerates 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:
toASCIIin classNSObject- Parameters:
ascii- TheStringBuilderonto which the ASCII representation is appended.level- The indentation level of the object.
-
toASCIIGnuStep
Description copied from class:NSObjectGenerates the ASCII representation of this object in the GnuStep format. The generated ASCII representation does not end with a newline.- Specified by:
toASCIIGnuStepin classNSObject- Parameters:
ascii- TheStringBuilderonto which the ASCII representation is appended.level- The indentation level of the object.
-
compareTo
-
escapeStringForASCII
Escapes a string for use in ASCII property lists.- Parameters:
s- The unescaped string.- Returns:
- The escaped string.
-
escapeStringForXml
-