com.sage.orion.sdata.servlet
Class SDataResourceElement

java.lang.Object
  extended by com.sage.orion.sdata.servlet.SDataResourceElement

public class SDataResourceElement
extends java.lang.Object

The new replacement for the ResourceEntity and all the other stuff that goes with it.

TODO Test for xsi:nil on all elements; complain if it makes no sense

TODO Allow for xsi to be some other name for the same namespace

TODO Remove linefeed/space in text? Maybe not. TODO Maybe it is about time this was refactored to a set of classes


Nested Class Summary
static class SDataResourceElement.CDataCreator
          Creator for the CData type of SDataResourceElement
static class SDataResourceElement.FieldCreator
          Creator for the Field resource type.
static class SDataResourceElement.ReferenceCreator
          Creator for the Field resource type.
static class SDataResourceElement.ReferenceListCreator
          Creator for the Reference List type of resource.
static class SDataResourceElement.Type
          TODO: Fill in Javadoc for Type.
 
Field Summary
static java.lang.String DEFAULT_NAMESPACE
           
static java.lang.String NAMESPACE_SEPARATOR
           
static java.lang.String XSI_NIL
           
 
Constructor Summary
SDataResourceElement(java.lang.String textCDATA)
           
SDataResourceElement(java.lang.String name, java.util.List<SDataResourceElement> contents)
          Construct a reference SDataResourceElement for a list of resources or a resource that has no key
SDataResourceElement(java.lang.String name, java.util.List<SDataResourceElement> contents, java.lang.String key, java.lang.String url)
          Construct a reference one for a single resource (a foreign resource or each child of a list)
SDataResourceElement(java.lang.String name, java.lang.String value)
          Construct a FIELD SDataResourceElement.Type SDataResourceElement given name and value
 
Method Summary
 java.util.Map<java.lang.String,SDataResourceElement> getContentMap()
          Gets the contents in the form of a map.
 java.util.List<SDataResourceElement> getContents()
          Get the list of SDataResourceElement contents associated with this SDataResourceElement
 boolean getDeleteMissing()
          Gets whether to delete missing resources or resources not included in the payload.
 boolean getIsDeleted()
          Gets the isDeleted value of this resource.
 java.lang.String getKey()
          get the key
 java.lang.String getName()
          get the name
 java.util.List<SDataRelatedResource> getRelatedEntries()
          Gets the list of related entries for the children that are not actually included
 SDataResourceElement.Type getType()
          get the type
 java.lang.String getUrl()
          get the url
 java.lang.String getValue()
          return the value
static SDataResourceElement newChildrenList(java.lang.String name, java.lang.String url, java.util.List<SDataResourceElement> contents)
          Constructs a reference type instance of the SDataResourceElement class that corresponds to a child list related resource
static SDataResourceElement newReferenceListResource(java.lang.String name, java.util.List<SDataResourceElement> contents, boolean deleteMissing)
          Construct a reference SDataResourceElement for a list of resources or a resource that has no key and specify whether missing entries are to be deleted.
static SDataResourceElement newReferenceResource(java.lang.String name, java.util.List<SDataResourceElement> contents, java.lang.String key, java.lang.String url, boolean isDeleted)
          Factory method to create SDataResourceElement representing a reference for a single resource (a foreign resource or each child of a list) and allow whether to be deleted.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_NAMESPACE

public static final java.lang.String DEFAULT_NAMESPACE
See Also:
Constant Field Values

NAMESPACE_SEPARATOR

public static final java.lang.String NAMESPACE_SEPARATOR
See Also:
Constant Field Values

XSI_NIL

public static final java.lang.String XSI_NIL
See Also:
Constant Field Values
Constructor Detail

SDataResourceElement

public SDataResourceElement(java.lang.String name,
                            java.lang.String value)
Construct a FIELD SDataResourceElement.Type SDataResourceElement given name and value

Parameters:
name - of the field
value - of the field

SDataResourceElement

public SDataResourceElement(java.lang.String name,
                            java.util.List<SDataResourceElement> contents,
                            java.lang.String key,
                            java.lang.String url)
Construct a reference one for a single resource (a foreign resource or each child of a list)

Parameters:
name - the name of the resource
contents - the contents of the resource; a mix of fields and sub-resources/foreign resources
key - the primary key of the element, in string form. (The value used as the sdata:key and passed as the resource selector value).
url - the url of the element, in string form. (The value used as the sdata:url). This must already be fully percent-encoded.

SDataResourceElement

public SDataResourceElement(java.lang.String name,
                            java.util.List<SDataResourceElement> contents)
Construct a reference SDataResourceElement for a list of resources or a resource that has no key

Parameters:
name - the name of the resource
contents - the contents of the resource. This will be a null reference if the contents are to be excluded.

SDataResourceElement

public SDataResourceElement(java.lang.String textCDATA)
Parameters:
textCDATA - the textCDATA
Method Detail

newReferenceResource

public static SDataResourceElement newReferenceResource(java.lang.String name,
                                                        java.util.List<SDataResourceElement> contents,
                                                        java.lang.String key,
                                                        java.lang.String url,
                                                        boolean isDeleted)
Factory method to create SDataResourceElement representing a reference for a single resource (a foreign resource or each child of a list) and allow whether to be deleted.

Parameters:
name - the name of the resource
contents - the contents of the resource; a mix of fields and sub-resources/foreign resources
key - the primary key of the element, in string form. (The value used as the sdata:key and passed as the resource selector value).
url - the url of the element, in string form. (The value used as the sdata:url). This must already be fully percent-encoded.
isDeleted - determines whether this resource should be deleted
Returns:
SDataResourceElement

newReferenceListResource

public static SDataResourceElement newReferenceListResource(java.lang.String name,
                                                            java.util.List<SDataResourceElement> contents,
                                                            boolean deleteMissing)
Construct a reference SDataResourceElement for a list of resources or a resource that has no key and specify whether missing entries are to be deleted.

Parameters:
name - the name of the resource
contents - the contents of the resource. This will be a null reference if the contents are to be excluded.
deleteMissing - is used to specify whether to delete the missing resources.
Returns:
SDataResourceElement

newChildrenList

public static final SDataResourceElement newChildrenList(java.lang.String name,
                                                         java.lang.String url,
                                                         java.util.List<SDataResourceElement> contents)
Constructs a reference type instance of the SDataResourceElement class that corresponds to a child list related resource

Parameters:
name - the name of the resource
url - the URL that can provide a feed containing the content. The URL must be fully percent-encoded already.
contents - either a null reference (if the actual content is not to be included) or a list of the contents.
Returns:
the corresponding new SDataResourceElement

getName

public java.lang.String getName()
get the name

Returns:
the name.

getKey

public java.lang.String getKey()
get the key

Returns:
the key.

getUrl

public java.lang.String getUrl()
get the url

Returns:
the url.

getType

public SDataResourceElement.Type getType()
get the type

Returns:
the type.

getValue

public java.lang.String getValue()
return the value

Returns:
value of this SDataResourceElement element.
Throws:
java.lang.IllegalStateException - if the type of the element is not one that has a value

getContents

public java.util.List<SDataResourceElement> getContents()
Get the list of SDataResourceElement contents associated with this SDataResourceElement

Returns:
the contents
Throws:
java.lang.IllegalStateException - if the type of the element is not one that has contents

getRelatedEntries

public java.util.List<SDataRelatedResource> getRelatedEntries()
Gets the list of related entries for the children that are not actually included

Returns:
a non-null list of entries

getContentMap

public java.util.Map<java.lang.String,SDataResourceElement> getContentMap()
Gets the contents in the form of a map.

Returns:
a map of the contents.

getDeleteMissing

public boolean getDeleteMissing()
Gets whether to delete missing resources or resources not included in the payload.

Returns:
whether to delete missing resources.

getIsDeleted

public boolean getIsDeleted()
Gets the isDeleted value of this resource.

Returns:
true when this resource is marked for deletion


Copyright © 2011 Sage Software, Inc. All rights reserved.