WebObjects 5.4.2

com.webobjects.foundation
Class NSPropertyListSerialization

java.lang.Object
  extended by com.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:
NSPropertyListSerialization.booleanForString(java.lang.String), NSPropertyListSerialization.intForString(java.lang.String)

Field Summary
static boolean ForceXML
          Convenience for methods to convert to xml plist.
static boolean Indents
          Convenience for methods to convert to plist.
static boolean NoIndents
          Convenience for methods to convert to plist.
 
Method Summary
static NSArray arrayForString(String value)
          Parses the property list representation string and returns the resulting property list as an NSArray.
static NSArray arrayForString(String value, boolean forceXML)
          Parses the property list representation string and returns the resulting property list as an NSArray.
static NSArray arrayWithPathURL(URL url)
          Converts a java.net.URL into a property list and returns the resulting property list as an NSArray.
static NSArray arrayWithPathURL(URL url, boolean forceXML)
          Converts a java.net.URL into a property list and returns the resulting property list as an NSArray.
static boolean booleanForString(String value)
          Parses a given string for boolean value according to the table below.
static NSData dataFromPropertyList(Object plist)
          Deprecated. Use dataFromPropertyList(Object object, String encoding) instead.
static NSData dataFromPropertyList(Object plist, 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 value)
          Parses the property list representation string and returns the resulting property list as an NSDictionary.
static NSDictionary dictionaryForString(String value, boolean forceXML)
          Parses the property list representation string and returns the resulting property list as an NSDictionary.
static NSDictionary dictionaryWithPathURL(URL url)
          Converts a java.net.URL into a property list and returns the resulting property list as an NSDictionary.
static NSDictionary dictionaryWithPathURL(URL url, boolean forceXML)
          Converts a java.net.URL into a property list and returns the resulting property list as an NSDictionary.
static int intForString(String value)
          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 propertyListFromString(String string, boolean forceXML)
          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 Object propertyListWithPathURL(URL url, boolean forceXML)
          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 (old style plist) and returns it.
static String stringFromPropertyList(Object plist, boolean indents)
          Converts a property list object into a string (old style plist) and returns it.
static String xmlStringFromPropertyList(Object plist)
          Converts a property list object into an XML string and returns it.
static String xmlStringFromPropertyList(Object plist, boolean indents)
          Converts a property list object into an XML string and returns it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

Indents

public static final boolean Indents
Convenience for methods to convert to plist. Returns true..

See Also:
Constant Field Values

NoIndents

public static final boolean NoIndents
Convenience for methods to convert to plist. Returns false.

See Also:
Constant Field Values

ForceXML

public static final boolean ForceXML
Convenience for methods to convert to xml plist. Returns true..

See Also:
Constant Field Values
Method Detail

stringFromPropertyList

public static String stringFromPropertyList(Object plist)
Converts a property list object into a string (old style plist) and returns it. All entries are indented.

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

stringFromPropertyList

public static String stringFromPropertyList(Object plist,
                                            boolean indents)
Converts a property list object into a string (old style plist) and returns it.

Parameters:
plist - the property list to convert
indents - if true the resulting plist is indented (tabs and CR) if false no tabs anc CR are inserted in the result
Returns:
plist as a string
Since:
5.4
See Also:
NSPropertyListSerialization.propertyListFromString(java.lang.String)

xmlStringFromPropertyList

public static String xmlStringFromPropertyList(Object plist)
Converts a property list object into an XML string and returns it. All entries are indented.

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

xmlStringFromPropertyList

public static String xmlStringFromPropertyList(Object plist,
                                               boolean indents)
Converts a property list object into an XML string and returns it.

Parameters:
plist - the property list to convert
indents - if true the resulting plist is indented (tabs and CR) if false no tabs anc CR are inserted in the result
Returns:
plist as a string
Since:
5.4
See Also:
NSPropertyListSerialization.propertyListFromString(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:
NSPropertyListSerialization.stringFromPropertyList(java.lang.Object)

propertyListFromString

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

Parameters:
string - the string to convert to a property list
forceXML - force xml decoding
Returns:
string as a property list
Since:
5.4
See Also:
NSPropertyListSerialization.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:
NSPropertyListSerialization.stringFromPropertyList(java.lang.Object)

propertyListWithPathURL

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

Parameters:
url - the java.net.URL to convert to a property list
forceXML - force xml decoding
Returns:
the content at url as a property list
Since:
5.4
See Also:
NSPropertyListSerialization.stringFromPropertyList(java.lang.Object)

dataFromPropertyList

@Deprecated
public static NSData dataFromPropertyList(Object plist)
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:
plist - property list object
Returns:
object converted to an NSData
See Also:
NSPropertyListSerialization.propertyListFromData(NSData, java.lang.String)

dataFromPropertyList

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

Parameters:
plist - 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:
NSPropertyListSerialization.propertyListFromData(NSData, java.lang.String)

propertyListFromData

@Deprecated
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:
NSPropertyListSerialization.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:
NSPropertyListSerialization.dataFromPropertyList(Object, java.lang.String)

booleanForString

public static boolean booleanForString(String value)
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:
value - the string to be parsed for boolean value
Returns:
the parsed boolean value

intForString

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

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

arrayWithPathURL

public static NSArray arrayWithPathURL(URL url)
Converts a java.net.URL into a property list and returns the resulting property list as an NSArray.

Parameters:
url - the java.net.URL to convert to a property list
Returns:
Returns resulting property list as an NSArray
Since:
5.4
See Also:
NSPropertyListSerialization.stringFromPropertyList(java.lang.Object)

arrayWithPathURL

public static NSArray arrayWithPathURL(URL url,
                                       boolean forceXML)
Converts a java.net.URL into a property list and returns the resulting property list as an NSArray.

Parameters:
url - the java.net.URL to convert to a property list
forceXML - force xml decoding
Returns:
Returns resulting property list as an NSArray
Since:
5.4
See Also:
NSPropertyListSerialization.stringFromPropertyList(java.lang.Object)

arrayForString

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

Parameters:
value - input property list representation string
Returns:
Returns resulting property list as an NSArray
See Also:
NSPropertyListSerialization.dictionaryForString(String)

arrayForString

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

Parameters:
value - input property list representation string
forceXML - force xml decoding
Returns:
Returns resulting property list as an NSArray
Since:
5.4
See Also:
NSPropertyListSerialization.dictionaryForString(String)

dictionaryWithPathURL

public static NSDictionary dictionaryWithPathURL(URL url)
Converts a java.net.URL into a property list and returns the resulting property list as an NSDictionary.

Parameters:
url - the java.net.URL to convert to a property list
Returns:
string as an NSDictionary
Since:
5.4
See Also:
NSPropertyListSerialization.stringFromPropertyList(java.lang.Object)

dictionaryWithPathURL

public static NSDictionary dictionaryWithPathURL(URL url,
                                                 boolean forceXML)
Converts a java.net.URL into a property list and returns the resulting property list as an NSDictionary.

Parameters:
url - the java.net.URL to convert to a property list
forceXML - force xml decoding
Returns:
string as an NSDictionary
Since:
5.4
See Also:
NSPropertyListSerialization.stringFromPropertyList(java.lang.Object)

dictionaryForString

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

Parameters:
value - property list representated as a string
Returns:
string as an NSDictionary
See Also:
NSPropertyListSerialization.arrayForString(String)

dictionaryForString

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

Parameters:
value - property list representated as a string
forceXML - force xml decoding
Returns:
string as an NSDictionary
Since:
5.4
See Also:
NSPropertyListSerialization.arrayForString(String)

Last updated June 2008

Copyright © 2000-2008 Apple Inc.