Project Wonder 5.0

er.rest
Class ERXRestRequestNode

java.lang.Object
  extended by er.rest.ERXRestRequestNode
All Implemented Interfaces:
com.webobjects.foundation.NSKeyValueCoding, com.webobjects.foundation.NSKeyValueCodingAdditions

public class ERXRestRequestNode
extends java.lang.Object
implements com.webobjects.foundation.NSKeyValueCoding, com.webobjects.foundation.NSKeyValueCodingAdditions

ERXRestRequestNode provides a model of a REST request. Because the incoming document format can vary (XML, JSON, etc), we needed a document model that is more abstract than just an org.w3c.dom. Or, rather, one that isn't obnoxious to use.

Author:
mschrag

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.webobjects.foundation.NSKeyValueCodingAdditions
com.webobjects.foundation.NSKeyValueCodingAdditions.DefaultImplementation, com.webobjects.foundation.NSKeyValueCodingAdditions.Utility
 
Nested classes/interfaces inherited from interface com.webobjects.foundation.NSKeyValueCoding
com.webobjects.foundation.NSKeyValueCoding._BooleanFieldBinding, com.webobjects.foundation.NSKeyValueCoding._BooleanMethodBinding, com.webobjects.foundation.NSKeyValueCoding._FieldBinding, com.webobjects.foundation.NSKeyValueCoding._ForwardingBinding, com.webobjects.foundation.NSKeyValueCoding._KeyBinding, com.webobjects.foundation.NSKeyValueCoding._KeyBindingCreation, com.webobjects.foundation.NSKeyValueCoding._MethodBinding, com.webobjects.foundation.NSKeyValueCoding._NumberFieldBinding, com.webobjects.foundation.NSKeyValueCoding._NumberMethodBinding, com.webobjects.foundation.NSKeyValueCoding._ReflectionKeyBindingCreation, com.webobjects.foundation.NSKeyValueCoding.ErrorHandling, com.webobjects.foundation.NSKeyValueCoding.Null, com.webobjects.foundation.NSKeyValueCoding.UnknownKeyException, com.webobjects.foundation.NSKeyValueCoding.ValueAccessor
 
Field Summary
 
Fields inherited from interface com.webobjects.foundation.NSKeyValueCodingAdditions
_CLASS, _KeyPathSeparatorChar, KeyPathSeparator
 
Fields inherited from interface com.webobjects.foundation.NSKeyValueCoding
NullValue
 
Constructor Summary
ERXRestRequestNode(java.lang.String name, boolean rootNode)
          Construct a node with the given name
ERXRestRequestNode(java.lang.String name, java.lang.Object value, boolean rootNode)
          Construct a node with the given name and value.
 
Method Summary
protected  void _addAttributeNodeForKeyInObject(ERXKey<?> key, java.lang.Object obj, ERXKeyFilter keyFilter)
           
protected  void _addAttributesAndRelationshipsForObjectOfEntity(java.lang.Object obj, com.webobjects.eocontrol.EOClassDescription classDescription, ERXKeyFilter keyFilter, IERXRestDelegate delegate, java.util.Set<java.lang.Object> visitedObjects)
           
protected  void _addToManyRelationshipNodeForKeyOfEntityInObject(ERXKey<?> key, com.webobjects.eocontrol.EOClassDescription destinationEntity, java.lang.Object obj, ERXKeyFilter keyFilter, IERXRestDelegate delegate, java.util.Set<java.lang.Object> visitedObjects)
           
protected  void _addToOneRelationshipNodeForKeyInObject(ERXKey<?> key, java.lang.Object obj, com.webobjects.eocontrol.EOClassDescription destinationEntity, ERXKeyFilter keyFilter, IERXRestDelegate delegate, java.util.Set<java.lang.Object> visitedObjects)
           
protected  void _fillInWithObjectAndFilter(java.lang.Object obj, com.webobjects.eocontrol.EOClassDescription classDescription, ERXKeyFilter keyFilter, IERXRestDelegate delegate, java.util.Set<java.lang.Object> visitedObjects)
           
protected  void _safeDidSkipValueForKey(ERXKeyFilter keyFilter, java.lang.Object target, java.lang.Object value, java.lang.String key)
           
protected  void _safeDidTakeValueForKey(ERXKeyFilter keyFilter, java.lang.Object target, java.lang.Object value, java.lang.String key)
           
protected  void _safeWillTakeValueForKey(ERXKeyFilter keyFilter, java.lang.Object target, java.lang.Object value, java.lang.String key)
           
 void addChild(ERXRestRequestNode child)
          Adds a child to this node.
 java.lang.Object associatedObject()
          Returns the original object associated with this node.
 java.lang.Object attributeForKey(java.lang.String key)
          Returns the attribute value for the given key.
 java.lang.Object attributeOrChildNodeValue(java.lang.String name)
          Returns the type of this node.
 com.webobjects.foundation.NSDictionary<java.lang.String,java.lang.Object> attributes()
          Returns the attributes dictionary for this node.
 ERXRestRequestNode childNamed(java.lang.String name)
          Returns the first child named 'name'.
 com.webobjects.foundation.NSArray<ERXRestRequestNode> children()
          Returns the children of this node.
 ERXRestRequestNode cloneNode()
          Clones this node.
 java.lang.Object createObjectWithFilter(java.lang.String entityName, ERXKeyFilter keyFilter, IERXRestDelegate delegate)
          Creates a new instance of an object represented by this request node.
protected  void guessNull()
           
 java.lang.Object id()
          Returns the ID associated with this node.
 boolean isArray()
          Return whether or not this node represents an array or to-many relationship.
protected  boolean isClassProperty(com.webobjects.eocontrol.EOClassDescription classDescription, java.lang.String key)
           
 boolean isNull()
          Returns whether or not this node represents a null value.
 boolean isRootNode()
          Returns whether or not this is a root node (a root node is one that would typically have a node name that is an entity name -- the actual root, or elements in an array, for instance).
 java.lang.String name()
          Returns the name of this node.
 java.lang.Object objectWithFilter(java.lang.String entityName, ERXKeyFilter keyFilter, IERXRestDelegate delegate)
          Returns the object that this request node represents.
 java.lang.Object removeAttributeForKey(java.lang.String key)
          Removes the attribute that has the given name.
 java.lang.Object removeAttributeOrChildNodeNamed(java.lang.String name)
          Removes the attribute or child node that has the given name (and returns it).
 ERXRestRequestNode removeChildNamed(java.lang.String name)
          Removes the child name that has the given name.
static ERXRestRequestNode requestNodeWithObjectAndFilter(com.webobjects.eocontrol.EOClassDescription classDescription, java.util.List<?> objects, ERXKeyFilter keyFilter, IERXRestDelegate delegate)
          Creates a hierarchy of ERXRestRequestNodes based off of the given array of objects.
static ERXRestRequestNode requestNodeWithObjectAndFilter(java.lang.Object obj, ERXKeyFilter keyFilter, IERXRestDelegate delegate)
          Creates a hierarchy of ERXRestRequestNodes based off of the given object.
 void setArray(boolean array)
          Sets whether or not this node represents an array or to-many relationship.
 void setAssociatedObject(java.lang.Object associatedObject)
          Sets the original object associated with this node.
 void setAttributeForKey(java.lang.Object attribute, java.lang.String key)
          Sets the attribute value for the given key.
 void setID(java.lang.Object id)
          Sets the ID associated with this node.
 void setName(java.lang.String name)
          Sets the name of this node.
 void setNull(boolean isNull)
          Sets whether or not this node represents a null value.
 void setRootNode(boolean rootNode)
          Sets whether or not this is a root node (a root node is one that would typically have a node name that is an entity name -- the actual root, or elements in an array, for instance).
 void setType(java.lang.String type)
          Sets the type of this node (type as in the Class that it represents).
 void setValue(java.lang.Object value)
          Sets the value for this node.
 void takeValueForKey(java.lang.Object value, java.lang.String key)
           
 void takeValueForKeyPath(java.lang.Object value, java.lang.String keyPath)
           
 java.lang.Object toJavaCollection(ERXRestFormat.Delegate delegate)
          Returns the Java object that corresponds to this node hierarchy.
 java.lang.Object toJavaCollection(ERXRestFormat.Delegate delegate, java.util.Map<java.lang.Object,ERXRestRequestNode> conversionMap)
          Returns the Java object that corresponds to this node hierarchy.
protected  java.lang.Object toJavaCollection(ERXRestFormat.Delegate delegate, java.util.Map<java.lang.Object,ERXRestRequestNode> conversionMap, java.util.Map<java.lang.Object,java.lang.Object> associatedObjects)
          Returns the Java object that corresponds to this node hierarchy.
 java.lang.Object toNSCollection(ERXRestFormat.Delegate delegate)
          Returns the NSCollection/Java object that corresponds to this node hierarchy.
protected  java.lang.Object toNSCollection(ERXRestFormat.Delegate delegate, com.webobjects.foundation.NSMutableDictionary<java.lang.Object,java.lang.Object> associatedObjects)
          Returns the NSCollection/Java object that corresponds to this node hierarchy.
 java.lang.String toString()
           
 java.lang.String toString(ERXRestFormat format)
          Returns a string representation of this request node using the given format.
 java.lang.String toString(IERXRestWriter writer, ERXRestFormat.Delegate delegate)
          Returns a string representation of this request node using the given IERXRestWriter.
protected  void toString(java.lang.StringBuffer sb, int depth)
           
 java.lang.String type()
          Returns the type of this node (type as in the Class that it represents).
 void updateObjectWithFilter(java.lang.Object obj, ERXKeyFilter keyFilter, IERXRestDelegate delegate)
          Updates the given object based on this request node.
 java.lang.Object value()
          Returns the value for this node (or null if it doesn't exist).
 java.lang.Object valueForKey(java.lang.String key)
           
 java.lang.Object valueForKeyPath(java.lang.String keyPath)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ERXRestRequestNode

public ERXRestRequestNode(java.lang.String name,
                          boolean rootNode)
Construct a node with the given name

Parameters:
name - the name of this node
rootNode - if true, the node is the root of a graph

ERXRestRequestNode

public ERXRestRequestNode(java.lang.String name,
                          java.lang.Object value,
                          boolean rootNode)
Construct a node with the given name and value.

Parameters:
name - the name of this node
rootNode - if true, the node is the root of a graph
value - the value of this node
Method Detail

cloneNode

public ERXRestRequestNode cloneNode()
Clones this node.

Returns:
a clone of this node

setRootNode

public void setRootNode(boolean rootNode)
Sets whether or not this is a root node (a root node is one that would typically have a node name that is an entity name -- the actual root, or elements in an array, for instance).

Parameters:
rootNode - whether or not this is a root node

isRootNode

public boolean isRootNode()
Returns whether or not this is a root node (a root node is one that would typically have a node name that is an entity name -- the actual root, or elements in an array, for instance).

Returns:
whether or not this is a root node

toJavaCollection

public java.lang.Object toJavaCollection(ERXRestFormat.Delegate delegate)
Returns the Java object that corresponds to this node hierarchy.

Parameters:
delegate - the format delegate to notify during rendering
Returns:
the Java object that corresponds to this node hierarchy

toJavaCollection

public java.lang.Object toJavaCollection(ERXRestFormat.Delegate delegate,
                                         java.util.Map<java.lang.Object,ERXRestRequestNode> conversionMap)
Returns the Java object that corresponds to this node hierarchy.

Parameters:
delegate - the format delegate to notify during rendering
conversionMap - the conversion map to use to record object => request node mappings
Returns:
the Java object that corresponds to this node hierarchy

toJavaCollection

protected java.lang.Object toJavaCollection(ERXRestFormat.Delegate delegate,
                                            java.util.Map<java.lang.Object,ERXRestRequestNode> conversionMap,
                                            java.util.Map<java.lang.Object,java.lang.Object> associatedObjects)
Returns the Java object that corresponds to this node hierarchy.

Parameters:
delegate - the format delegate to notify during rendering
conversionMap - the conversion map to use to record object => request node mappings
associatedObjects - the associatedObjects map (to prevent infinite loops)
Returns:
the Java object that corresponds to this node hierarchy

toNSCollection

public java.lang.Object toNSCollection(ERXRestFormat.Delegate delegate)
Returns the NSCollection/Java object that corresponds to this node hierarchy.

Returns:
the NSCollection/Java object that corresponds to this node hierarchy

toNSCollection

protected java.lang.Object toNSCollection(ERXRestFormat.Delegate delegate,
                                          com.webobjects.foundation.NSMutableDictionary<java.lang.Object,java.lang.Object> associatedObjects)
Returns the NSCollection/Java object that corresponds to this node hierarchy.

Parameters:
associatedObjects - the associatedObjects map (to prevent infinite loops)
Returns:
NSCollection/Java object that corresponds to this node hierarchy

setArray

public void setArray(boolean array)
Sets whether or not this node represents an array or to-many relationship.

Parameters:
array - whether or not this node represents an array or to-many relationship

isArray

public boolean isArray()
Return whether or not this node represents an array or to-many relationship.

Returns:
whether or not this node represents an array or to-many relationship

setAssociatedObject

public void setAssociatedObject(java.lang.Object associatedObject)
Sets the original object associated with this node.

Parameters:
associatedObject - the original object associated with this node

associatedObject

public java.lang.Object associatedObject()
Returns the original object associated with this node.

Returns:
the original object associated with this node

takeValueForKey

public void takeValueForKey(java.lang.Object value,
                            java.lang.String key)
Specified by:
takeValueForKey in interface com.webobjects.foundation.NSKeyValueCoding

valueForKey

public java.lang.Object valueForKey(java.lang.String key)
Specified by:
valueForKey in interface com.webobjects.foundation.NSKeyValueCoding

valueForKeyPath

public java.lang.Object valueForKeyPath(java.lang.String keyPath)
Specified by:
valueForKeyPath in interface com.webobjects.foundation.NSKeyValueCodingAdditions

takeValueForKeyPath

public void takeValueForKeyPath(java.lang.Object value,
                                java.lang.String keyPath)
Specified by:
takeValueForKeyPath in interface com.webobjects.foundation.NSKeyValueCodingAdditions

childNamed

public ERXRestRequestNode childNamed(java.lang.String name)
Returns the first child named 'name'.

Parameters:
name - the name to look for
Returns:
the first child with this name (or null if not found)

removeChildNamed

public ERXRestRequestNode removeChildNamed(java.lang.String name)
Removes the child name that has the given name.

Parameters:
name - the name of the node to remove
Returns:
the node that was removed

setType

public void setType(java.lang.String type)
Sets the type of this node (type as in the Class that it represents).

Parameters:
type - the type of this node

type

public java.lang.String type()
Returns the type of this node (type as in the Class that it represents).

Returns:
the type of this node

setID

public void setID(java.lang.Object id)
Sets the ID associated with this node.

Parameters:
id - the ID associated with this node

id

public java.lang.Object id()
Returns the ID associated with this node.

Returns:
the ID associated with this node

removeAttributeOrChildNodeNamed

public java.lang.Object removeAttributeOrChildNodeNamed(java.lang.String name)
Removes the attribute or child node that has the given name (and returns it).

Parameters:
name - the name of the attribute or node to remove
Returns:
the removed attribute value

attributeOrChildNodeValue

public java.lang.Object attributeOrChildNodeValue(java.lang.String name)
Returns the type of this node.

Returns:
the type of this node

guessNull

protected void guessNull()

setNull

public void setNull(boolean isNull)
Sets whether or not this node represents a null value.

Parameters:
isNull - whether or not this node represents a null value

isNull

public boolean isNull()
Returns whether or not this node represents a null value.

Returns:
true whether or not this node represents a null value

name

public java.lang.String name()
Returns the name of this node.

Returns:
the name of this node

setName

public void setName(java.lang.String name)
Sets the name of this node.

Parameters:
name - the name of this node

value

public java.lang.Object value()
Returns the value for this node (or null if it doesn't exist).

Returns:
the name of this node

setValue

public void setValue(java.lang.Object value)
Sets the value for this node.

Parameters:
value - the value for this node

setAttributeForKey

public void setAttributeForKey(java.lang.Object attribute,
                               java.lang.String key)
Sets the attribute value for the given key.

Parameters:
attribute - the attribute value
key - the key

removeAttributeForKey

public java.lang.Object removeAttributeForKey(java.lang.String key)
Removes the attribute that has the given name.

Parameters:
key - the name of the attribute to remove
Returns:
the attribute value

attributeForKey

public java.lang.Object attributeForKey(java.lang.String key)
Returns the attribute value for the given key.

Parameters:
key - the key
Returns:
the attribute value

attributes

public com.webobjects.foundation.NSDictionary<java.lang.String,java.lang.Object> attributes()
Returns the attributes dictionary for this node.

Returns:
the attributes dictionary

addChild

public void addChild(ERXRestRequestNode child)
Adds a child to this node.

Parameters:
child - the child to add

children

public com.webobjects.foundation.NSArray<ERXRestRequestNode> children()
Returns the children of this node.

Returns:
the children of this node

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toString

protected void toString(java.lang.StringBuffer sb,
                        int depth)

objectWithFilter

public java.lang.Object objectWithFilter(java.lang.String entityName,
                                         ERXKeyFilter keyFilter,
                                         IERXRestDelegate delegate)
Returns the object that this request node represents.

Parameters:
entityName - the entity name of the object to use
keyFilter - the filter to use for determining which keys can be updated (or null for no update)
delegate - the delegate to use
Returns:
the object that this request node represents

createObjectWithFilter

public java.lang.Object createObjectWithFilter(java.lang.String entityName,
                                               ERXKeyFilter keyFilter,
                                               IERXRestDelegate delegate)
Creates a new instance of an object represented by this request node.

Parameters:
entityName - the entity name of the object to use
keyFilter - the filter to use for determining which keys can be updated (or null for no update)
delegate - the delegate to use
Returns:
a new instance of an object represented by this request node

_addAttributeNodeForKeyInObject

protected void _addAttributeNodeForKeyInObject(ERXKey<?> key,
                                               java.lang.Object obj,
                                               ERXKeyFilter keyFilter)

_addToManyRelationshipNodeForKeyOfEntityInObject

protected void _addToManyRelationshipNodeForKeyOfEntityInObject(ERXKey<?> key,
                                                                com.webobjects.eocontrol.EOClassDescription destinationEntity,
                                                                java.lang.Object obj,
                                                                ERXKeyFilter keyFilter,
                                                                IERXRestDelegate delegate,
                                                                java.util.Set<java.lang.Object> visitedObjects)

_addToOneRelationshipNodeForKeyInObject

protected void _addToOneRelationshipNodeForKeyInObject(ERXKey<?> key,
                                                       java.lang.Object obj,
                                                       com.webobjects.eocontrol.EOClassDescription destinationEntity,
                                                       ERXKeyFilter keyFilter,
                                                       IERXRestDelegate delegate,
                                                       java.util.Set<java.lang.Object> visitedObjects)

_addAttributesAndRelationshipsForObjectOfEntity

protected void _addAttributesAndRelationshipsForObjectOfEntity(java.lang.Object obj,
                                                               com.webobjects.eocontrol.EOClassDescription classDescription,
                                                               ERXKeyFilter keyFilter,
                                                               IERXRestDelegate delegate,
                                                               java.util.Set<java.lang.Object> visitedObjects)

_fillInWithObjectAndFilter

protected void _fillInWithObjectAndFilter(java.lang.Object obj,
                                          com.webobjects.eocontrol.EOClassDescription classDescription,
                                          ERXKeyFilter keyFilter,
                                          IERXRestDelegate delegate,
                                          java.util.Set<java.lang.Object> visitedObjects)

toString

public java.lang.String toString(ERXRestFormat format)
Returns a string representation of this request node using the given format.

Parameters:
format - the format to use
Returns:
a string representation of this request node using the given format

toString

public java.lang.String toString(IERXRestWriter writer,
                                 ERXRestFormat.Delegate delegate)
Returns a string representation of this request node using the given IERXRestWriter.

Parameters:
writer - the writer to use
Returns:
a string representation of this request node using the given IERXRestWriter

isClassProperty

protected boolean isClassProperty(com.webobjects.eocontrol.EOClassDescription classDescription,
                                  java.lang.String key)

_safeWillTakeValueForKey

protected void _safeWillTakeValueForKey(ERXKeyFilter keyFilter,
                                        java.lang.Object target,
                                        java.lang.Object value,
                                        java.lang.String key)

_safeDidTakeValueForKey

protected void _safeDidTakeValueForKey(ERXKeyFilter keyFilter,
                                       java.lang.Object target,
                                       java.lang.Object value,
                                       java.lang.String key)

_safeDidSkipValueForKey

protected void _safeDidSkipValueForKey(ERXKeyFilter keyFilter,
                                       java.lang.Object target,
                                       java.lang.Object value,
                                       java.lang.String key)

updateObjectWithFilter

public void updateObjectWithFilter(java.lang.Object obj,
                                   ERXKeyFilter keyFilter,
                                   IERXRestDelegate delegate)
Updates the given object based on this request node.

Parameters:
obj - the object to update
keyFilter - the filter to use to determine how to update
delegate - the delegate

requestNodeWithObjectAndFilter

public static ERXRestRequestNode requestNodeWithObjectAndFilter(com.webobjects.eocontrol.EOClassDescription classDescription,
                                                                java.util.List<?> objects,
                                                                ERXKeyFilter keyFilter,
                                                                IERXRestDelegate delegate)
Creates a hierarchy of ERXRestRequestNodes based off of the given array of objects.

Parameters:
classDescription - the entity type of the objects in the array
objects - the array to turn into request nodes
keyFilter - the filter to use
Returns:
the root ERXRestRequestNode

requestNodeWithObjectAndFilter

public static ERXRestRequestNode requestNodeWithObjectAndFilter(java.lang.Object obj,
                                                                ERXKeyFilter keyFilter,
                                                                IERXRestDelegate delegate)
Creates a hierarchy of ERXRestRequestNodes based off of the given object.

Parameters:
obj - the object to turn into request nodes
keyFilter - the filter to use
Returns:
the root ERXRestRequestNode

Last updated: Tue, Feb 21, 2017 • 05:45 PM CET

Copyright © 2002 – 2007 Project Wonder.