pbsw-code.net : pbsw-PropertyList

pbsw-PropertyList

A set of classes for maintaining a property list (plist), including reading and generating the plist from and to the standard XML based plist format.

The classes handle all the standard plist types: (array, data, date, dict, integer, string, true, false)




Class: pbsw_PropertyList Superclass: None Interfaces: None
This is the main class - it represents the whole list of properties - represented by subclasses of pbsw_PropertyCore
It has a "root" property, that is a dict property holding all the others.


Methods
Add(theKey as string, theValue as integer) [Public]
Creates a new "integer" property with key: theKey and value: theValue and adds it to the list.
NOTE: There can only be one item with a particular key in the [top level of the] list.
If you add another item with the same key, the existing one will be removed.
Add(theKey as string, theValue as string) [Public]
Creates a new "string" property with key: theKey and value: theValue and adds it to the list
NOTE: There can only be one item with a particular key in the [top level of the] list.
If you add another item with the same key, the existing one will be removed
Add(theKey as string, theValue as double) [Public]
Creates a new "real" property with key: theKey and value: theValue and adds it to the list
NOTE: There can only be one item with a particular key in the [top level of the] list.
If you add another item with the same key, the existing one will be removed
Add(theKey as string, theValue as boolean) [Public]
Creates a new "boolean" property with key: theKey and value: theValue and adds it to the list
NOTE: There can only be one item with a particular key in the [top level of the] list.
If you add another item with the same key, the existing one will be removed
Add(theKey as string, theValue as pbsw_PropertyCore) [Public]
Adds theProperty to the list with key: theKey
NOTE: There can only be one item with a particular key in the [top level of the] list.
If you add another item with the same key, the existing one will be removed
Add(theKey as string, theValue as date) [Public]
Creates a new "date" property with key: theKey and value: theValue and adds it to the list
NOTE: There can only be one item with a particular key in the [top level of the] list.
If you add another item with the same key, the existing one will be removed
Clear() [Public]
Removes all the items from the list
Constructor() [Public]
Default constructor - creates an empty list
Constructor(theXMLString as string) [Public]
Creates the Property List from an XML string - conforming to Apple's plist dtd 1.0
Contains(theProperty as pbsw_PropertyCore) as boolean [Public]
Returns true if "theProperty" exists inside the list (at any depth)
Count() as integer [Public]
returns the number of items in the list
GetItem(index as integer) as pbsw_PropertyCore [Public]
Returns the property at position: index
GetItem(theKey as string) as pbsw_PropertyCore [Public]
Returns the property with key: theKey
GetItemAsString(index as integer) as string [Public]
Returns the value of the item at position: index as a string
GetItemAsString(theKey as string) as string [Public]
Returns the value of the item with key: theKey as a string
GetKey(index as integer) as string [Public]
Returns the key of the item at position: index
GetXMLString() as string [Public]
Returns the Property List as an XML string - according to Apple's plist dtd 1.0
HasKey(theKey as string) as boolean [Public]
Returns true if a property with key: theKey is in the [top level] of the list
Remove(theKey as string) [Public]
Removes the item with key: theKey from the [top level] of the list (if it exists)


Class: pbsw_PropertyCore Superclass: None Interfaces: None
The abstract class that is the superclass of all the other property classes.
(You do not work with this class directly, only its subclasses)


Methods
Contains(theProperty as pbsw_PropertyCore) as boolean [Public]
Returns true if "theProperty" exists inside the property (at any depth)
GetTypeAsString() as string [Public]
Returns the type of the property as a string
GetValueAsString() as string [Public]
Returns the value of the property as a string
GetValueAsXMLElement(theXMLDoc as XmlDocument, loopControl as Dictionary = nil, theLevel as integer = 1) as XMLElement [Public]
Returns the XML representation of the property as an XMLElement
theXMLDoc is the XMLDocument to generate the XMLElement with
theLevel is the indent level (tabs will be added where appropriate to keep this level)
loopControl is a Dictionary used to avoid infinite loops caused by circular references in the plist structure


Class: pbsw_ArrayProperty Superclass: pbsw_PropertyCore Interfaces: None
A property that holds an ordered list of other properties


Methods
Append(theValue as integer) [Public]
Creates a new "integer" property with value: theValue and appends it to the end of the array
Append(theValue as string) [Public]
Creates a new "string" property with value: theValue and appends it to the end of the array
Append(theValue as double) [Public]
Creates a new "real" property with value: theValue and appends it to the end of the array
Append(theValue as boolean) [Public]
Creates a new "boolean" property with value: theValue and appends it to the end of the array
Append(theProperty as pbsw_PropertyCore) [Public]
Appends the property: theProperty to the end of the array
Append(theValue as date) [Public]
Creates a new "date" property with value: theValue and appends it to the end of the array
Clear() [Public]
Removes all the items from the array
Constructor(e as XmlElement) [Public]
Creates the dict from an XMLElement (which is normally retreived from the XML based representation of the plist)
Constructor() [Public]
the default constructor - creates an empty array
Count() as integer [Public]
returns the number of items in the array
GetItem(index as integer) as pbsw_PropertyCore [Public]
Returns the item number: index
The array is 1-based (the first item has an index of 1)
GetTypeAsString() as string [Public]
Returns the type of the property as a string ("array")
GetValueAsXMLElement(theXMLDoc as XmlDocument, loopControl as Dictionary = nil, theLevel as integer = 1) as XMLElement [Public]
Returns the XML representation of the property as an XMLElement
theXMLDoc is the XMLDocument to generate the XMLElement with
theLevel is the indent level (tabs will be added where appropriate to keep this level)
loopControl is a Dictionary used to avoid infinite loops caused by circular references in the plist structure
the array property and all contained properties will be added to loopControl
if a property is already in loopControl, it will not be processed, and an error comment will be produced in the XML
Insert(index as integer, theValue as integer) [Public]
Creates a new "integer" property with value: theValue and inserts it at position: index
All other items after this position move down 1
The array is 1-based (the first item has an index of 1)
Insert(index as integer, theValue as string) [Public]
Creates a new "string" property with value: theValue and inserts it at position: index
All other items after this position move down 1
The array is 1-based (the first item has an index of 1)
Insert(index as integer, theValue as double) [Public]
Creates a new "real" property with value: theValue and inserts it at position: index
All other items after this position move down 1
The array is 1-based (the first item has an index of 1)
Insert(index as integer, theValue as boolean) [Public]
Creates a new "boolean" property with value: theValue and inserts it at position: index
All other items after this position move down 1
The array is 1-based (the first item has an index of 1)
Insert(index as integer, theValue as date) [Public]
Creates a new "date" property with value: theValue and inserts it at position: index
All other items after this position move down 1
The array is 1-based (the first item has an index of 1)
Insert(index as integer, theProperty as pbsw_PropertyCore) [Public]
Inserts "theProperty" at position: index
All other items after this position move down 1
The array is 1-based (the first item has an index of 1)
Remove(index as integer) [Public]
Removes the property at position: index
All other items after this position move up 1
The array is 1-based (the first item has an index of 1)


Class: pbsw_BooleanProperty Superclass: pbsw_PropertyCore Interfaces: None
A property that holds a boolean value (true or false)


Methods
Constructor(theValue as boolean) [Public]
Creates the property with theValue
GetTypeAsString() as string [Public]
Returns the type of the property as a string ("boolean")
GetValue() as boolean [Public]
Returns the value of the property
GetValueAsString() as string [Public]
Returns the value of the property as a string
GetValueAsXMLElement(theXMLDoc as XmlDocument, loopControl as Dictionary = nil, theLevel as integer = 1) as XMLElement [Public]
Returns the XML representation of the property as an XMLElement
theXMLDoc is the XMLDocument to generate the XMLElement with
theLevel is the indent level (tabs will be added where appropriate to keep this level)
loopControl is a Dictionary used to avoid infinite loops caused by circular references in the plist structure
the property will be added to loopControl
SetValue(theValue as boolean) [Public]
Sets the value of the property to theValue


Class: pbsw_CommentProperty Superclass: pbsw_PropertyCore Interfaces: None
This is not an actual property:
It is used for creating error comments in the produced XML
(Future use as a placeholder for XML comments so that they can be preserved)
(NOTE: preserving of comments is not yet implemented)


Methods
Constructor(theCommentText as string) [Public]
Creates the "property" with theCommentText
GetTypeAsString() as string [Public]
Returns the type of the "property" as a string ("XMLComment")
GetValueAsString() as string [Public]
Returns the "value" (actually, the comment text)
GetValueAsXMLComment(theXMLDoc as XmlDocument) as XMLComment [Public]
Returns the XML representation of the "property" as an XMLComment
theXMLDoc is the XMLDocument to generate the XMLComment with
SetValue(theCommentText as string) [Public]
Sets the "value" (actually, the comment text) to : theCommentText


Class: pbsw_DataProperty Superclass: pbsw_PropertyCore Interfaces: None
A property that holds a chunk of binary data as a Base64 encoded string


Methods
Constructor(theData as string, alreadyEncoded as boolean = false) [Public]
Creates the property with theValue
If alreadyEncoded is true, it is assumed that the value is already Base64 encoded, and will not be encoded further.
GetDecodedValueAsString() as string [Public]
Returns the decoded value of the property
GetTypeAsString() as string [Public]
Returns the type of the property as a string ("data")
GetValueAsString() as string [Public]
Returns the value of the property as a string
GetValueAsXMLElement(theXMLDoc as XmlDocument, loopControl as Dictionary = nil, theLevel as integer = 1) as XMLElement [Public]
Returns the XML representation of the property as an XMLElement
theXMLDoc is the XMLDocument to generate the XMLElement with
theLevel is the indent level (tabs will be added where appropriate to keep this level)
loopControl is a Dictionary used to avoid infinite loops caused by circular references in the plist structure
the property will be added to loopControl
SetValue(theValue as string, alreadyEncoded as boolean = false) [Public]
Sets the value of the property to theValue
If alreadyEncoded is true, it is assumed that the value is already Base64 encoded, and will not be encoded further.


Class: pbsw_DateProperty Superclass: pbsw_PropertyCore Interfaces: None
A property that holds a date value


Methods
Constructor(theValue as Date) [Public]
Creates the property with theValue
Constructor(theString as string) [Public]
Creates the property by extracting the value from theDateString
theDateString is in the Format: "YYYY-MM-DDTHH:MM:SSZ"
where YYYY is the year, MM is the month, DD is the day
HH is the hours, MM is the minutes, and SS is the seconds.
GetTypeAsString() as string [Public]
Returns the type of the property as a string ("date")
GetValue() as date [Public]
Returns the value of the property
GetValueAsString() as string [Public]
Returns the value of the property as a string
(in the SQLDateTime format)
GetValueAsXMLElement(theXMLDoc as XmlDocument, loopControl as Dictionary = nil, theLevel as integer = 1) as XMLElement [Public]
Returns the XML representation of the property as an XMLElement
theXMLDoc is the XMLDocument to generate the XMLElement with
theLevel is the indent level (tabs will be added where appropriate to keep this level)
loopControl is a Dictionary used to avoid infinite loops caused by circular references in the plist structure
the property will be added to loopControl
SetValue(theValue as date) [Public]
Sets the value of the property to theValue
SetValue(theDateString as string) [Public]
Extracts the value from theDateString
theDateString is in the Format: "YYYY-MM-DDTHH:MM:SSZ"
where YYYY is the year, MM is the month, DD is the day
HH is the hours, MM is the minutes, and SS is the seconds.


Class: pbsw_DictProperty Superclass: pbsw_PropertyCore Interfaces: None
A property that holds a collection of other properties, each with a unique "Key" string to identify them


Methods
Add(theKey as string, theValue as integer) [Public]
Creates a new "integer" property with key: theKey and value: theValue and adds it to the dict.
NOTE: There can only be one item with a particular key in the dict.
If you add another item with the same key, the existing one will be removed.
Add(theKey as string, theValue as string) [Public]
Creates a new "string" property with key: theKey and value: theValue and adds it to the dict
NOTE: There can only be one item with a particular key in the dict.
If you add another item with the same key, the existing one will be removed
Add(theKey as string, theValue as double) [Public]
Creates a new "real" property with key: theKey and value: theValue and adds it to the dict
NOTE: There can only be one item with a particular key in the dict.
If you add another item with the same key, the existing one will be removed
Add(theKey as string, theValue as boolean) [Public]
Creates a new "boolean" property with key: theKey and value: theValue and adds it to the dict
NOTE: There can only be one item with a particular key in the dict.
If you add another item with the same key, the existing one will be removed
Add(theKey as string, theProperty as pbsw_PropertyCore) [Public]
Adds theProperty to the dict with key: theKey
NOTE: There can only be one item with a particular key in the dict.
If you add another item with the same key, the existing one will be removed
Add(theKey as string, theValue as date) [Public]
Creates a new "date" property with key: theKey and value: theValue and adds it to the dict
NOTE: There can only be one item with a particular key in the dict.
If you add another item with the same key, the existing one will be removed
Clear() [Public]
Removes all the items from the dict
Constructor() [Public]
the default constructor - creates an empty dict
Constructor(e as XmlElement) [Public]
Creates the dict from an XMLElement (which is normally retreived from the XML based representation of the plist
Count() as integer [Public]
returns the number of items in the dict
GetItem(index as integer) as pbsw_PropertyCore [Public]
Returns the property at position: index
GetItem(theKey as string) as pbsw_PropertyCore [Public]
Returns the property with key: theKey
GetItemAsString(index as integer) as string [Public]
Returns the value of the item at position: index as a string
GetItemAsString(theKey as string) as string [Public]
Returns the value of the item with key: theKey as a string
GetKey(index as integer) as string [Public]
Returns the key of the item at position: index
GetTypeAsString() as string [Public]
Returns the type of the property as a string ("dict")
GetValueAsXMLElement(theXMLDoc as XmlDocument, loopControl as Dictionary = nil, theLevel as integer = 1) as XMLElement [Public]
Returns the XML representation of the property as an XMLElement
theXMLDoc is the XMLDocument to generate the XMLElement with
theLevel is the indent level (tabs will be added where appropriate to keep this level)
loopControl is a Dictionary used to avoid infinite loops caused by circular references in the plist structure
the dict property and all contained properties will be added to loopControl
if a property is already in loopControl, it will not be processed, and an error comment will be produced in the XML
HasKey(theKey as string) as boolean [Public]
Returns true if a property with key: theKey is in the [top level] of the dict
Remove(theKey as string) [Public]
Removes the item with key: theKey from the [top level] of the dict (if it exists)


Class: pbsw_IntegerProperty Superclass: pbsw_PropertyCore Interfaces: None
A property that holds an integer value


Methods
Constructor(theValue as integer) [Public]
Creates the property with theValue
GetTypeAsString() as string [Public]
Returns the type of the property as a string ("integer")
GetValue() as integer [Public]
Returns the value of the property
GetValueAsString() as string [Public]
Returns the value of the property as a string
GetValueAsXMLElement(theXMLDoc as XmlDocument, loopControl as Dictionary = nil, theLevel as integer = 1) as XMLElement [Public]
Returns the XML representation of the property as an XMLElement
theXMLDoc is the XMLDocument to generate the XMLElement with
theLevel is the indent level (tabs will be added where appropriate to keep this level)
loopControl is a Dictionary used to avoid infinite loops caused by circular references in the plist structure
the property will be added to loopControl
SetValue(theValue as integer) [Public]
Sets the value of the property to theValue


Class: pbsw_RealProperty Superclass: pbsw_PropertyCore Interfaces: None
A property that holds a real / floating point / double value


Methods
Constructor(theValue as double) [Public]
Creates the property with theValue
GetTypeAsString() as string [Public]
Returns the type of the property as a string ("real")
GetValue() as double [Public]
Returns the value of the property
GetValueAsString() as string [Public]
Returns the value of the property as a string
GetValueAsXMLElement(theXMLDoc as XmlDocument, loopControl as Dictionary = nil, theLevel as integer = 1) as XMLElement [Public]
Returns the XML representation of the property as an XMLElement
theXMLDoc is the XMLDocument to generate the XMLElement with
theLevel is the indent level (tabs will be added where appropriate to keep this level)
loopControl is a Dictionary used to avoid infinite loops caused by circular references in the plist structure
the property will be added to loopControl
SetValue(theValue as double) [Public]
Sets the value of the property to theValue


Class: pbsw_StringProperty Superclass: pbsw_PropertyCore Interfaces: None
A property that holds a string value


Methods
Constructor(theValue as string) [Public]
Creates the property with theValue
GetTypeAsString() as string [Public]
Returns the type of the property as a string ("string")
GetValueAsString() as string [Public]
Returns the value of the property as a string
GetValueAsXMLElement(theXMLDoc as XmlDocument, loopControl as Dictionary = nil, theLevel as integer = 1) as XMLElement [Public]
Returns the XML representation of the property as an XMLElement
theXMLDoc is the XMLDocument to generate the XMLElement with
theLevel is the indent level (tabs will be added where appropriate to keep this level)
loopControl is a Dictionary used to avoid infinite loops caused by circular references in the plist structure
the property will be added to loopControl
SetValue(theValue as string) [Public]
Sets the value of the property to theValue


pbsw-code.net : pbsw-PropertyList