WebObjects 5.2.3

com.webobjects.foundation
Class NSPropertyListSerialization

java.lang.Object
  extended bycom.webobjects.foundation.NSPropertyListSerialization

public class NSPropertyListSerialization
extends Object

This class provides static methods that convert between property lists and their string representations, which can be either strings or NSData objects. A property list is a structure that represents organized data. It can be built from a combination of NSArray, NSDictionary, String, and NSData objects.

The string representation can be in XML or the ASCII plist format. To distinguish between the two formats, the parser that converts strings to property lists finds out whether the string starts with <?xml. A discussion of the ASCII plist format, A Primer on ASCII Property Lists, is available in the Mac OS X section of the Apple Developer Connection website. A discussion of XML property lists, Property List Services, is also available in the same area of the Apple Developer Connection website.

Some methods do not support XML property list representations, specifically booleanForString and intForString.

The NSPropertyListSerialization class cannot be instantiated.

See Also:
booleanForString(java.lang.String), intForString(java.lang.String)

Constructor Summary
NSPropertyListSerialization()
           
 
Method Summary
static NSArray arrayForString(String string)
          Parses the property list representation string and returns the resulting property list as an NSArray.
static boolean booleanForString(String string)
          Parses a given string for boolean value according to the table below.
static NSData dataFromPropertyList(Object object)
          Deprecated. Use dataFromPropertyList(Object object, String encoding) instead.
static NSData dataFromPropertyList(Object object, String encoding)
          Converts the property list object into a string using a character encoding and returns it as an NSData object.
static NSDictionary dictionaryForString(String string)
          Parses the property list representation string and returns the resulting property list as an NSDictionary.
static int intForString(String string)
          Parses a given string and returns the corresponding integer value.
static Object propertyListFromData(NSData data)
          Deprecated. Use propertyListFromData(NSData data, String encoding)
static Object propertyListFromData(NSData data, String encoding)
          Converts an NSData into a property list using a character encoding and returns it.
static Object propertyListFromString(String string)
          Converts a string into a property list and returns it.
static Object propertyListWithPathURL(URL url)
          Converts a java.net.URL into a property list and returns it.
static String stringFromPropertyList(Object plist)
          Converts a property list object into a string and returns it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NSPropertyListSerialization

public NSPropertyListSerialization()
Method Detail

arrayForString

public static NSArray arrayForString(String string)
Parses the property list representation string and returns the resulting property list as an NSArray.

Parameters:
string - input property list representation string
Returns:
Returns resulting property list as an NSArray
Throws:
ClassCastException - if the root object is not an array
See Also:
dictionaryForString(String)

booleanForString

public static boolean booleanForString(String string)
Parses a given string for boolean value according to the table below.

String Result
"YES" true
"true" true
any other value false

The tests for "YES" and "true" are case insensitive.

Parameters:
string - the string to be parsed for boolean value
Returns:
the parsed boolean value

dataFromPropertyList

public static NSData dataFromPropertyList(Object object)
Deprecated. Use dataFromPropertyList(Object object, String encoding) instead.

Converts the property list object into a string and returns it as an NSData object. This method uses the platform's default character encoding to convert the result string to byte.

Parameters:
object - property list object
Returns:
object converted to an NSData
See Also:
propertyListFromData(NSData, java.lang.String)

dataFromPropertyList

public static NSData dataFromPropertyList(Object object,
                                          String encoding)
Converts the property list object into a string using a character encoding and returns it as an NSData object.

Parameters:
object - the property list object to convert
encoding - encoding used to convert the characters in the result string to byte
Returns:
object converted to an NSData
See Also:
propertyListFromData(NSData, java.lang.String)

dictionaryForString

public static NSDictionary dictionaryForString(String string)
Parses the property list representation string and returns the resulting property list as an NSDictionary.

Parameters:
string - property list representated as a string
Returns:
string as an NSDictionary
Throws:
ClassCastException - if the root object is not a dictionary
See Also:
arrayForString(String)

intForString

public static int intForString(String string)
Parses a given string and returns the corresponding integer value.

Parameters:
string - the string to be parsed for integer value
Returns:
integer value of string; 0 if it is null

propertyListFromData

public static Object propertyListFromData(NSData data)
Deprecated. Use propertyListFromData(NSData data, String encoding)

Converts an NSData into a property list and returns it.

This method uses the platform's default character encoding to convert the bytes in data byte array to characters in a string representation.

Parameters:
data - the byte array to be converted to a property list
Returns:
data as a property list
See Also:
dataFromPropertyList(Object, java.lang.String)

propertyListFromData

public static Object propertyListFromData(NSData data,
                                          String encoding)
Converts an NSData into a property list using a character encoding and returns it.

Parameters:
data - the byte array to be converted to a property list
encoding - encoding to use to convert the bytes in the data byte array to characters in a string representation
Returns:
data as a property list
See Also:
dataFromPropertyList(Object, java.lang.String)

propertyListFromString

public static Object propertyListFromString(String string)
Converts a string into a property list and returns it.

Parameters:
string - the string to convert to a property list
Returns:
string as a property list
See Also:
stringFromPropertyList(java.lang.Object)

propertyListWithPathURL

public static Object propertyListWithPathURL(URL url)
Converts a java.net.URL into a property list and returns it.

Parameters:
url - the java.net.URL to convert to a property list
Returns:
the content at url as a property list
Since:
5.2.2
See Also:
stringFromPropertyList(java.lang.Object)

stringFromPropertyList

public static String stringFromPropertyList(Object plist)
Converts a property list object into a string and returns it.

Parameters:
plist - the property list to convert
Returns:
plist as a string
See Also:
propertyListFromString(java.lang.String)

Last updated Thu Oct 21 15:04:16 PDT 2004.

Copyright © 2004 Apple Computer, Inc.