com.adobe.icomm.assetplacement.model
Class PackageDefinition

java.lang.Object
  extended by com.adobe.icomm.assetplacement.model.PackageDefinition

public class PackageDefinition
extends java.lang.Object

The "model" for the package is the XML document contained within the PackageDefinition object.


Nested Class Summary
static class PackageDefinition.PackageType
          The possible package types.
 
Field Summary
static java.lang.String ALTTEXT_ATTR
          XML attribute "altText".
static java.lang.String ASSETS_ELEMENT
          XML element "assets".
static java.lang.String ATTACHMENT_ELEMENT
          XML element "attachment".
static java.lang.String ATTACHMENTLOADER_ELEMENT
          The AttachmentLoader controller.
static java.lang.String ATTACHMENTS_ELEMENT
          XML element "attachments".
static java.lang.String CONTENTTYPE_ATTR
          XML attribute "contentType".
static java.lang.String CONTROLLER_ATTR
          XML attribute "controller".
static java.lang.String CONTROLLER_NS
          The controller namespace.
static java.lang.String CONTROLLERS_ELEMENT
          XML element "controllers".
static java.lang.String DATA_ELEMENT
          XML element "data".
static java.lang.String DEFAULT_LOCALE
          Default locale.
static java.lang.String DELAY_ELEMENT
          XML element "delay".
static java.lang.String DESCRIPTION_ATTR
          XML attribute "description".
static java.lang.String EXPIRATION_ATTR
          XML attribute "expiration".
static java.lang.String HEIGHT_ATTR
          XML attribute "height".
static java.lang.String ID_ATTR
          XML attribute "id".
static java.lang.String INTERACTIVEDOCUMENT_DATA_ID
          The default id used for interactive document data.
static java.lang.String LOCALE_ATTR
          XML attribute "locale".
static java.lang.String NAME_ATTR
          XML attribute "name".
static java.lang.String NAV_PACKAGE_TYPE
          XML attribute "nav".
static java.lang.String PACKAGE_ELEMENT
          XML element "package".
static java.lang.String PACKAGE_FILE_NAME
          The package definition file name.
static java.lang.String PACKAGE_NS
          The package namespace.
static java.lang.Float PACKAGE_VERSION_1_0
          The package 1.0.
static java.lang.Float PACKAGE_VERSION_2_0
          The package version 2.0.
static java.lang.Float PACKAGE_VERSION_CURRENT
          The current package version.
static java.lang.String PRINTDOCUMENT_ID
          The default id used for a print version of the interactive document.
static java.lang.String PROMOIMAGE_ELEMENT
          The PromoImage controller.
static java.lang.String PROMOIMAGESLIDESHOW_ELEMENT
          The PromoImageSlideShow controller.
static java.lang.String PROMOMODULELOADER_ELEMENT
          The PromoModuleLoader controller.
static java.lang.String PROMOSWFLOADER_ELEMENT
          The PromoSWFLoader controller.
static java.lang.String RESOURCE_ELEMENT
          XML element "resource".
static java.lang.String RESOURCES_ELEMENT
          XML element "resources".
static java.lang.String SCALINGMETHOD_ATTR
          XML attribute "scalingMethod".
static java.lang.String SOURCE_ATTR
          XML attribute "source".
static java.lang.String TARGETURL_ATTR
          XML attribute "targetURL".
static java.lang.String TYPE_ATTR
          XML attribute "type".
static java.lang.String VERSION_ATTR
          XML attribute "version".
static java.lang.String WIDTH_ATTR
          XML attribute "width".
static java.lang.String XFA_PACKAGE_TYPE
          XML attribute "xfa".
static java.lang.String XMLDATALOADER_ELEMENT
          The XMLDataLoader controller.
 
Constructor Summary
PackageDefinition()
          Creates a new empty package definition.
PackageDefinition(org.w3c.dom.Document doc)
          Constructs a package given an Document.
PackageDefinition(java.io.InputStream stream)
          Constructs a package definition from an InputStream that will read from a package.xml.
 
Method Summary
 Attachment addAttachment(java.lang.String controllerID, java.lang.String name)
          Finds.
 AssetLoaderController addAttachmentLoader(java.lang.String id)
          Adds a new AttachmentLoader to the package definition.
 Controller addController(java.lang.String namespaceURI, java.lang.String tagName, java.lang.String id)
          Adds a new controller to the package definition with the given namespace,tagname and id.
 PromoImageController addPromoImage(java.lang.String id)
          Adds a new PromoImage to the package definition.
 PromoImageSlideShowController addPromoImageSlideShow(java.lang.String id)
          Adds a new PromoImageSlideShow to the package definition.
 PromoModuleLoaderController addPromoModuleLoader(java.lang.String id)
          Adds a new PromoModuleLoaderController to the package definition.
 PromoSWFLoaderController addPromoSWFLoader(java.lang.String id)
          Adds a new PromoSWFLoaderController to the package definition.
 Resource addResource(java.lang.String controllerID)
          Finds the <resources> entry with the given controller id and adds a new <resource> child with the given name.
 AssetLoaderController addXMLDataLoader(java.lang.String id)
          Adds a new XMLDataLoader to the package definition.
 java.util.List getAttachmentLoaders()
          Returns a list of all AttachmentLoader controllers.
 java.util.List getAttachments()
          Gets the list of attachments defined in this package, one for every <attachment> node in the document.
 Controller getController(java.lang.String controllerID)
          Returns the controller with the given id.
 java.util.List getControllers()
          Gets the list of controllers defined in this package.
 java.util.List getControllersNS(java.lang.String namespaceURI, java.lang.String tagName)
          Returns a list of controllers matching a given namespace and tagname.
 AssetLoaderController getDocumentDataLoader()
          Finds and returns the XML Data controller that is associated with the interactive document's data.
 java.lang.String getPackageLocale()
          Returns the package definition locale value.
 java.lang.String getPackageSource()
          Returns the package definition source value, as in <package source="" >.
 PackageDefinition.PackageType getPackageType()
          Returns the package definition type value.
 java.lang.Float getPackageVersion()
          Returns the package definition version, as in <package version="" >.
 AssetLoaderController getPrintDocumentLoader()
          Finds and returns the XML Data controller that is associated the printDocument resource entry.
 java.util.List getPromoImages()
          Returns a list of all PromoImage controllers.
 java.util.List getPromoImageSlideShows()
          Returns a list of all PromoImageSlideShow controllers.
 java.util.List getPromoModuleLoaders()
          Returns a list of all PromoModuleLoaderController controllers.
 java.util.List getPromoSWFLoaders()
          Returns a list of all PromoSWFLoader controllers.
 java.util.List getResources()
          Gets the list of resources defined in this package, one for every <resource> node in the document.
 java.util.List getXMLDataLoaders()
          Returns a list of all XMLDataLoader controllers.
 void removeAttachments(java.lang.String controllerID)
          Removes all <attachments> associated with the given controller id from the package definition.
 void removeController(java.lang.String controllerID)
          Removes any and all controllers with the specified id.
 void removeResources(java.lang.String controllerID)
          Removes all <resources> associated with the given controller id from the package definition.
 java.lang.String saveXML()
          Returns the package definition XML.
 byte[] serialize()
          Returns a serialized package definition XML.
 void setPackageLocale(java.lang.String locale)
          Sets the package definition locale value.
 void setPackageSource(java.lang.String val)
          Sets the package definition source value, as in <package source="" >.
 void setPackageType(PackageDefinition.PackageType type)
          Sets the package definition type value by modifying the <package type=""> attribute.
 void setPackageVersion(java.lang.Float version)
          Sets the package definition version value.
 void validate(Validator validator)
          Attempt to validate this package definition element (not sub-elements).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PACKAGE_ELEMENT

public static final java.lang.String PACKAGE_ELEMENT
XML element "package".

See Also:
Constant Field Values

ASSETS_ELEMENT

public static final java.lang.String ASSETS_ELEMENT
XML element "assets".

See Also:
Constant Field Values

ATTACHMENTS_ELEMENT

public static final java.lang.String ATTACHMENTS_ELEMENT
XML element "attachments".

See Also:
Constant Field Values

ATTACHMENT_ELEMENT

public static final java.lang.String ATTACHMENT_ELEMENT
XML element "attachment".

See Also:
Constant Field Values

CONTROLLERS_ELEMENT

public static final java.lang.String CONTROLLERS_ELEMENT
XML element "controllers".

See Also:
Constant Field Values

DELAY_ELEMENT

public static final java.lang.String DELAY_ELEMENT
XML element "delay".

See Also:
Constant Field Values

DATA_ELEMENT

public static final java.lang.String DATA_ELEMENT
XML element "data".

See Also:
Constant Field Values

RESOURCES_ELEMENT

public static final java.lang.String RESOURCES_ELEMENT
XML element "resources".

See Also:
Constant Field Values

RESOURCE_ELEMENT

public static final java.lang.String RESOURCE_ELEMENT
XML element "resource".

See Also:
Constant Field Values

CONTENTTYPE_ATTR

public static final java.lang.String CONTENTTYPE_ATTR
XML attribute "contentType".

See Also:
Constant Field Values

TYPE_ATTR

public static final java.lang.String TYPE_ATTR
XML attribute "type".

See Also:
Constant Field Values

NAME_ATTR

public static final java.lang.String NAME_ATTR
XML attribute "name".

See Also:
Constant Field Values

SCALINGMETHOD_ATTR

public static final java.lang.String SCALINGMETHOD_ATTR
XML attribute "scalingMethod".

See Also:
Constant Field Values

SOURCE_ATTR

public static final java.lang.String SOURCE_ATTR
XML attribute "source".

See Also:
Constant Field Values

VERSION_ATTR

public static final java.lang.String VERSION_ATTR
XML attribute "version".

See Also:
Constant Field Values

ALTTEXT_ATTR

public static final java.lang.String ALTTEXT_ATTR
XML attribute "altText".

See Also:
Constant Field Values

TARGETURL_ATTR

public static final java.lang.String TARGETURL_ATTR
XML attribute "targetURL".

See Also:
Constant Field Values

EXPIRATION_ATTR

public static final java.lang.String EXPIRATION_ATTR
XML attribute "expiration".

See Also:
Constant Field Values

WIDTH_ATTR

public static final java.lang.String WIDTH_ATTR
XML attribute "width".

See Also:
Constant Field Values

HEIGHT_ATTR

public static final java.lang.String HEIGHT_ATTR
XML attribute "height".

See Also:
Constant Field Values

ID_ATTR

public static final java.lang.String ID_ATTR
XML attribute "id".

See Also:
Constant Field Values

DESCRIPTION_ATTR

public static final java.lang.String DESCRIPTION_ATTR
XML attribute "description".

See Also:
Constant Field Values

CONTROLLER_ATTR

public static final java.lang.String CONTROLLER_ATTR
XML attribute "controller".

See Also:
Constant Field Values

NAV_PACKAGE_TYPE

public static final java.lang.String NAV_PACKAGE_TYPE
XML attribute "nav".

See Also:
Constant Field Values

XFA_PACKAGE_TYPE

public static final java.lang.String XFA_PACKAGE_TYPE
XML attribute "xfa".

See Also:
Constant Field Values

LOCALE_ATTR

public static final java.lang.String LOCALE_ATTR
XML attribute "locale".

See Also:
Constant Field Values

DEFAULT_LOCALE

public static final java.lang.String DEFAULT_LOCALE
Default locale.

See Also:
Constant Field Values

CONTROLLER_NS

public static final java.lang.String CONTROLLER_NS
The controller namespace.

See Also:
Constant Field Values

PACKAGE_NS

public static final java.lang.String PACKAGE_NS
The package namespace.

See Also:
Constant Field Values

PACKAGE_VERSION_1_0

public static final java.lang.Float PACKAGE_VERSION_1_0
The package 1.0.


PACKAGE_VERSION_2_0

public static final java.lang.Float PACKAGE_VERSION_2_0
The package version 2.0.


PACKAGE_VERSION_CURRENT

public static final java.lang.Float PACKAGE_VERSION_CURRENT
The current package version.


PACKAGE_FILE_NAME

public static final java.lang.String PACKAGE_FILE_NAME
The package definition file name.

See Also:
Constant Field Values

INTERACTIVEDOCUMENT_DATA_ID

public static final java.lang.String INTERACTIVEDOCUMENT_DATA_ID
The default id used for interactive document data.

See Also:
Constant Field Values

PRINTDOCUMENT_ID

public static final java.lang.String PRINTDOCUMENT_ID
The default id used for a print version of the interactive document.

See Also:
Constant Field Values

PROMOIMAGE_ELEMENT

public static final java.lang.String PROMOIMAGE_ELEMENT
The PromoImage controller.

See Also:
Constant Field Values

PROMOIMAGESLIDESHOW_ELEMENT

public static final java.lang.String PROMOIMAGESLIDESHOW_ELEMENT
The PromoImageSlideShow controller.

See Also:
Constant Field Values

XMLDATALOADER_ELEMENT

public static final java.lang.String XMLDATALOADER_ELEMENT
The XMLDataLoader controller.

See Also:
Constant Field Values

ATTACHMENTLOADER_ELEMENT

public static final java.lang.String ATTACHMENTLOADER_ELEMENT
The AttachmentLoader controller.

See Also:
Constant Field Values

PROMOSWFLOADER_ELEMENT

public static final java.lang.String PROMOSWFLOADER_ELEMENT
The PromoSWFLoader controller.

See Also:
Constant Field Values

PROMOMODULELOADER_ELEMENT

public static final java.lang.String PROMOMODULELOADER_ELEMENT
The PromoModuleLoader controller.

See Also:
Constant Field Values
Constructor Detail

PackageDefinition

public PackageDefinition()
Creates a new empty package definition.

Throws:
javax.xml.parsers.ParserConfigurationException
java.io.IOException
org.xml.sax.SAXException

PackageDefinition

public PackageDefinition(java.io.InputStream stream)
                  throws InvalidPackageException,
                         java.io.IOException
Constructs a package definition from an InputStream that will read from a package.xml.

Parameters:
stream - The package definition file.
Throws:
org.xml.sax.SAXException
java.io.IOException
javax.xml.parsers.ParserConfigurationException
InvalidPackageException

PackageDefinition

public PackageDefinition(org.w3c.dom.Document doc)
                  throws InvalidPackageException,
                         java.io.IOException
Constructs a package given an Document.

Parameters:
doc - The parsed package document
Throws:
InvalidPackageException
java.io.IOException
Method Detail

setPackageSource

public void setPackageSource(java.lang.String val)
Sets the package definition source value, as in <package source="" >.

Parameters:
val - The package definition source value.

setPackageLocale

public void setPackageLocale(java.lang.String locale)
Sets the package definition locale value. If the locale value is null or empty, the locale attribute is removed and the default locale "en_US" is assumed.

Parameters:
locale - the locale value.

getPackageSource

public java.lang.String getPackageSource()
Returns the package definition source value, as in <package source="" >.

Returns:
The source value.

getPackageLocale

public java.lang.String getPackageLocale()
Returns the package definition locale value.

Returns:
the locale value.

getPackageVersion

public java.lang.Float getPackageVersion()
Returns the package definition version, as in <package version="" >. The schema defines this value as a decimal. The default is "1.0".

Returns:
An instance of Float representing the package definition version. If no value is specified in the package definition then the default is returned. If an invalid version is specifed in the package definition then the default is returned.

setPackageVersion

public void setPackageVersion(java.lang.Float version)
Sets the package definition version value. Passing in null or empty value removes the version attribute from package definition. Passing in an invalid version throws a InvalidParameterException exception.

Parameters:
version - A Float representing the package version. Currently only '1.0' or '2.0' are recognized.
Throws:
java.security.InvalidParameterException

validate

public void validate(Validator validator)
Attempt to validate this package definition element (not sub-elements). Validation messages discovered are added to the validator instance passed in.

Parameters:
validator - the validator

setPackageType

public void setPackageType(PackageDefinition.PackageType type)
Sets the package definition type value by modifying the <package type=""> attribute.

Parameters:
type - One of the supported enumerated types

getPackageType

public PackageDefinition.PackageType getPackageType()
Returns the package definition type value. Default is NAV.

Returns:
The package type.

getResources

public java.util.List getResources()
Gets the list of resources defined in this package, one for every <resource> node in the document.

Returns:
A list of Resource objects

getControllers

public java.util.List getControllers()
Gets the list of controllers defined in this package. This includes one for every child of <controllers>, regardless of namespace.

Returns:
A list of Controller objects

getController

public Controller getController(java.lang.String controllerID)
Returns the controller with the given id.

Parameters:
controllerID - The controller id value to look for
Returns:
The first controller with the matching id, null if none.

getAttachments

public java.util.List getAttachments()
Gets the list of attachments defined in this package, one for every <attachment> node in the document.

Returns:
A list of Attachment objects

getControllersNS

public java.util.List getControllersNS(java.lang.String namespaceURI,
                                       java.lang.String tagName)
Returns a list of controllers matching a given namespace and tagname.

Parameters:
namespaceURI - The namespace of the controllers to be returned
tagName - The tag name of the controller object. Passing "*" will return all controllers under the given namespace.
Returns:
List of Controller objects

getPromoImages

public java.util.List getPromoImages()
Returns a list of all PromoImage controllers.

Returns:
A List of Controller objects.

getPromoImageSlideShows

public java.util.List getPromoImageSlideShows()
Returns a list of all PromoImageSlideShow controllers.

Returns:
A List of Controller objects.

getXMLDataLoaders

public java.util.List getXMLDataLoaders()
Returns a list of all XMLDataLoader controllers.

Returns:
A List of Controller objects.

getAttachmentLoaders

public java.util.List getAttachmentLoaders()
Returns a list of all AttachmentLoader controllers.

Returns:
A List of Controller objects.

getPromoModuleLoaders

public java.util.List getPromoModuleLoaders()
Returns a list of all PromoModuleLoaderController controllers.

Returns:
A List of PromoModuleLoaderController objects.

getPromoSWFLoaders

public java.util.List getPromoSWFLoaders()
Returns a list of all PromoSWFLoader controllers.

Returns:
A List of PromoSWFLoaderController objects.

addController

public Controller addController(java.lang.String namespaceURI,
                                java.lang.String tagName,
                                java.lang.String id)
Adds a new controller to the package definition with the given namespace,tagname and id.

Parameters:
namespaceURI - The namespace for the new controller
tagName - The controller name
id - The controller id
Returns:
The newly added Controller object

addPromoImage

public PromoImageController addPromoImage(java.lang.String id)
Adds a new PromoImage to the package definition.

Parameters:
id - The id value of the controller
Returns:
The new controller

addPromoImageSlideShow

public PromoImageSlideShowController addPromoImageSlideShow(java.lang.String id)
Adds a new PromoImageSlideShow to the package definition.

Parameters:
id - The id value of the controller
Returns:
The new controller

addPromoSWFLoader

public PromoSWFLoaderController addPromoSWFLoader(java.lang.String id)
Adds a new PromoSWFLoaderController to the package definition.

Parameters:
id - The id value of the controller
Returns:
The new controller

addPromoModuleLoader

public PromoModuleLoaderController addPromoModuleLoader(java.lang.String id)
Adds a new PromoModuleLoaderController to the package definition.

Parameters:
id - The id value of the controller
Returns:
The new controller

addXMLDataLoader

public AssetLoaderController addXMLDataLoader(java.lang.String id)
Adds a new XMLDataLoader to the package definition.

Parameters:
id - The id value of the controller
Returns:
The new controller

addAttachmentLoader

public AssetLoaderController addAttachmentLoader(java.lang.String id)
Adds a new AttachmentLoader to the package definition.

Parameters:
id - The id value of the controller
Returns:
The new controller

addResource

public Resource addResource(java.lang.String controllerID)
Finds the <resources> entry with the given controller id and adds a new <resource> child with the given name. Creates a <resources> node if one cannot be found.

Parameters:
controllerID - The id of the controller for which this resource is associated with.
Returns:
A Resource object

addAttachment

public Attachment addAttachment(java.lang.String controllerID,
                                java.lang.String name)
Finds. the <attachments> associated with the given controller id and add a new <attachment> child with the given name. Creates the <attachments> node if one cannot be found.

Parameters:
name - The name of the new attachment
controllerID - The id of the controller for which this attachment is associated with.
Returns:
an Attachment object

getDocumentDataLoader

public AssetLoaderController getDocumentDataLoader()
Finds and returns the XML Data controller that is associated with the interactive document's data.

Returns:
Controller for the for the first XMLDataLoader with id="data". null if none.

getPrintDocumentLoader

public AssetLoaderController getPrintDocumentLoader()
Finds and returns the XML Data controller that is associated the printDocument resource entry.

Returns:
Controller for the for the first XMLDataLoader with id="printDocument". null if none.

removeController

public void removeController(java.lang.String controllerID)
Removes any and all controllers with the specified id.

Parameters:
controllerID - The id of the controller to be removed

removeAttachments

public void removeAttachments(java.lang.String controllerID)
Removes all <attachments> associated with the given controller id from the package definition. This includes all it's <attachment> children.

Parameters:
controllerID - The id of the controller associated with the attachments being removed.

removeResources

public void removeResources(java.lang.String controllerID)
Removes all <resources> associated with the given controller id from the package definition. This includes all it's <resource> children.

Parameters:
controllerID - The id of the controller associated with the resources being removed

saveXML

public java.lang.String saveXML()
                         throws javax.xml.transform.TransformerException
Returns the package definition XML.

Returns:
An xml string representation of the package definition
Throws:
javax.xml.transform.TransformerException

serialize

public byte[] serialize()
                 throws javax.xml.transform.TransformerException
Returns a serialized package definition XML.

Returns:
byte[] serialization of a package definition.
Throws:
javax.xml.transform.TransformerException


[an error occurred while processing this directive] [an error occurred while processing this directive]