Indivo Framework (iOS)
An iOS framework for Apps connecting to Indivo server
 All Classes Functions Variables Properties Pages
Instance Methods | Class Methods | Protected Attributes | Properties | List of all members
INObject Class Reference

An INObject is a lightweight object representing data in an XML tree. More...

#import <INObject.h>

Inherits NSObject.

Inherited by INAnyURI, INAttr, INBool, INDate, INDecimal, INDocumentStatusNode, INDuration, INParentObject, INString, and INVitalSign.

Instance Methods

(NSString *) - asAttribute
 Returns the value of this node usable as attribute to another node. More...
 
(NSString *) - attributeValue
 Returns the string that goes into the attribute value. More...
 
(NSArray *) - flatXMLPartsWithPrefix:
 Indivo 2.0's ugly flat XML format needs this. More...
 
(id) - initFromNode:
 The designated initializer. More...
 
(NSString *) - innerXML
 Returns the XML of all child nodes. More...
 
(BOOL) - isNull
 An object can decide that it is null, i.e. More...
 
(void) - setFromFlatParent:prefix:
 Handling incoming Indivo 2.0 flat XML IndivoAbstractDocument, a subclass of INObject, uses a slightly more diverse implementation of this method. More...
 
(void) - setFromNode:
 The INObject implementation sets the node name and node type (if a "type" attribute is found in the XML node) from an INXMLNode parsed from Indivo XML This method is called from the designated initializer, subclasses should override it to set custom properties and call [super setFromNode:node]. More...
 
(void) - setWithAttr:fromNode:
 Tries to interpret the attribute string as representing our value. More...
 
(NSString *) - tagString
 Returns the tag name and, if mustDeclareType is YES, the xsi:type-attribute, ready to be used as tag name. More...
 
(NSString *) - xml
 Return an XML representation of the object. More...
 

Class Methods

(NSArray *) + attributeNames
 The properties whose names are returned here are expected to be XML node attributes rather than complete nodes. More...
 
(NSString *) + flatXMLNameForPropertyName:
 Objects have the ability to use a different name from the property name for flat XML "name" attributes. More...
 
(id) + newWithNodeName:
 Returns a fresh node with nodeName set. More...
 
(NSString *) + nodeName
 
(NSString *) + nodeType
 
(id) + objectFromAttribute:inNode:
 This method returns an object created from the string contents of a node attribute. More...
 
(id) + objectFromNode:
 This method returns an object created representing the the node. More...
 

Protected Attributes

NSString * _nodeName
 

Properties

BOOL mustDeclareType
 NO by default. If YES, the XML output should contain "xsi:type". More...
 
NSString * nodeName
 The object's nodeName. More...
 
NSString * nodeType
 The type, e.g. "indivo:ValueAndUnit" or "xs:date". More...
 

Detailed Description

An INObject is a lightweight object representing data in an XML tree.

It knows how to read itself from and write itself to XML, but compared to INXMLNode has no idea about its parent structure.

Subclasses should override -setFromNode: (to set their properties from an XML node+type (to return their respective type) and -xml (to return valid XML representations)

Method Documentation

- (NSString *) asAttribute

Returns the value of this node usable as attribute to another node.

Only some of our subclasses support being used as attributes, obviously.

+ (NSArray *) attributeNames

The properties whose names are returned here are expected to be XML node attributes rather than complete nodes.

XML generation relies on this information, it will not go through the ivar list but only pick properties listed here.

- (NSString *) attributeValue

Returns the string that goes into the attribute value.

+ (NSString *) flatXMLNameForPropertyName: (NSString *)  aName

Objects have the ability to use a different name from the property name for flat XML "name" attributes.

Default implementation just returns the given name.

- (NSArray *) flatXMLPartsWithPrefix: (NSString *)  prefix

Indivo 2.0's ugly flat XML format needs this.

Todo:
WIP AND HIGHLY PRELIMINARY
Todo:
What about False???
- (id) initFromNode: (INXMLNode *)  node

The designated initializer.

- (NSString *) innerXML

Returns the XML of all child nodes.

- (BOOL) isNull

An object can decide that it is null, i.e.

does not carry data. This is useful for creating empty XML nodes instead of omitting the node at all by setting the property to nil.

+ (id) newWithNodeName: (NSString *)  aNodeName

Returns a fresh node with nodeName set.

+ (NSString *) nodeName
+ (NSString *) nodeType
+ (id) objectFromAttribute: (NSString *)  anAttribute
inNode: (INXMLNode *)  aNode 

This method returns an object created from the string contents of a node attribute.

You should use this method instead of using "newFromString:" directly.

+ (id) objectFromNode: (INXMLNode *)  aNode

This method returns an object created representing the the node.

Attention
This method may return a subclass of itself if the node specifies an "xsi:type" attribute representing a subclass.
Parameters
aNodeA node to be used to initialize the object
- (void) setFromFlatParent: (INXMLNode *)  parent
prefix: (NSString *)  prefix 

Handling incoming Indivo 2.0 flat XML IndivoAbstractDocument, a subclass of INObject, uses a slightly more diverse implementation of this method.

INObject only instantiates other INObject, NSString and NSNumber ivars from XML.

- (void) setFromNode: (INXMLNode *)  node

The INObject implementation sets the node name and node type (if a "type" attribute is found in the XML node) from an INXMLNode parsed from Indivo XML This method is called from the designated initializer, subclasses should override it to set custom properties and call [super setFromNode:node].

- (void) setWithAttr: (NSString *)  attrName
fromNode: (INXMLNode *)  aNode 

Tries to interpret the attribute string as representing our value.

The INObject implementation does nothing.

- (NSString *) tagString

Returns the tag name and, if mustDeclareType is YES, the xsi:type-attribute, ready to be used as tag name.

Todo:
Here we remove the namespace prefix based on how we generated the class. Cheap.
- (NSString *) xml

Return an XML representation of the object.

Member Data Documentation

- (NSString*) _nodeName
protected

Property Documentation

- (BOOL) mustDeclareType
readwritenonatomicassign

NO by default. If YES, the XML output should contain "xsi:type".

- (NSString *) nodeName
readwritenonatomiccopy

The object's nodeName.

A class can have a default XML nodeName which will be returned by the instance getter if no specific name is set.

We forward the class method on instance calls unless we have a personal nodeName.

- (NSString *) nodeType
readwritenonatomiccopy

The type, e.g. "indivo:ValueAndUnit" or "xs:date".

This class' type.

We forward the class method on instance calls unless we have our personal nodeType.


The documentation for this class was generated from the following files: