nl.gx.webmanager.services.contentrepresentation
Class ContentRepresentations

java.lang.Object
  extended by nl.gx.webmanager.services.contentrepresentation.ContentRepresentations

public final class ContentRepresentations
extends java.lang.Object

This is a utility class to create ContentRepresentation instances and ContentRepresentationEntry instances via the #create(String, Collection), createEntry(String, List) and createRefEntry(String, List) methods respectively.

This class also has methods to write ContentRepresentation instances to Strings and vice versa. The created String is an XML representation which includes a version number for future extensions and compatibility.


Method Summary
static ContentRepresentation create(java.lang.String contentType, WmId wmId, java.util.Set<java.lang.String> interfaceNames, java.util.Collection<ContentRepresentationEntry> data)
          Creates a ContentRepresentation from the given values.
static ContentRepresentationValueEntry createEntry(java.lang.String name, java.util.List<java.lang.String> values)
          Creates a ContentRepresentationEntry instance from the given values.
static ContentRepresentationReferenceEntry createRefEntry(java.lang.String name, java.util.List<ContentRepresentation> values)
          Creates a ContentRepresentationEntry instance from the given values.
static ContentRepresentation fromXml(java.lang.String representation)
          Converts a String representation to a ContentRepresentation instance.
static java.lang.String toXml(ContentRepresentation representation)
          Flattens the given ContentRepresentation to an XML String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

create

public static ContentRepresentation create(java.lang.String contentType,
                                           WmId wmId,
                                           java.util.Set<java.lang.String> interfaceNames,
                                           java.util.Collection<ContentRepresentationEntry> data)
Creates a ContentRepresentation from the given values. Note that the names of the ContentRepresentationEntry instances in the given Collection should be unique. If they are not unique, then entries get lost in the returned representation.

Parameters:
contentType - the content type
data - the collection of ContentRepresentationEntrys which must have unique names
wmId - the wmId of the represented content item
interfaceNames - the names of the interfaces that the represented content item implements
Returns:
an immutable ContentRepresentation instance

createEntry

public static ContentRepresentationValueEntry createEntry(java.lang.String name,
                                                          java.util.List<java.lang.String> values)
Creates a ContentRepresentationEntry instance from the given values.

Parameters:
name - the name of the entry, not null
values - the values of the entry, not null
Returns:
an immutable ContentRepresentationEntry instance for the given values

createRefEntry

public static ContentRepresentationReferenceEntry createRefEntry(java.lang.String name,
                                                                 java.util.List<ContentRepresentation> values)
Creates a ContentRepresentationEntry instance from the given values.

Parameters:
name - the name of the entry
values - the reference values of the entry
Returns:
an immutable ContentRepresentationEntry instance for the given values

toXml

public static java.lang.String toXml(ContentRepresentation representation)
Flattens the given ContentRepresentation to an XML String. This String representation can be converted back to a ContentRepresentation instance using the fromXml(String) method.

Note that this method assumes a tree-structure and does not check for cycles.

Parameters:
representation - the ContentRepresentation to flatten
Returns:
an String representation in XML format

fromXml

public static ContentRepresentation fromXml(java.lang.String representation)
                                     throws ContentRepresentationException
Converts a String representation to a ContentRepresentation instance. Use in combination with toXml(ContentRepresentation).

Parameters:
representation - the String representation
Returns:
a ContentRepresentation instance of the given String
Throws:
ContentRepresentationException - on error


Copyright © 2007-2011 GX Software BV. All Rights Reserved.