com.adobe.icomm.assetplacement.model
Class PackageDefinition

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

public class PackageDefinition
extends 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 String ALTTEXT_ATTR
          XML attribute "altText".
static String ASSETS_ELEMENT
          XML element "assets".
static String ATTACHMENT_ELEMENT
          XML element "attachment".
static String ATTACHMENTLOADER_ELEMENT
          The AttachmentLoader controller.
static String ATTACHMENTS_ELEMENT
          XML element "attachments".
static String CONTENTTYPE_ATTR
          XML attribute "contentType".
static String CONTROLLER_ATTR
          XML attribute "controller".
static String CONTROLLER_NS
          The controller namespace.
static String CONTROLLERS_ELEMENT
          XML element "controllers".
static String DATA_ELEMENT
          XML element "data".
static String DEFAULT_LOCALE
          Default locale.
static String DELAY_ELEMENT
          XML element "delay".
static String DESCRIPTION_ATTR
          XML attribute "description".
static String EXPIRATION_ATTR
          XML attribute "expiration".
static String HEIGHT_ATTR
          XML attribute "height".
static String ID_ATTR
          XML attribute "id".
static String INTERACTIVEDOCUMENT_DATA_ID
          The default id used for interactive document data.
static String LOCALE_ATTR
          XML attribute "locale".
static String NAME_ATTR
          XML attribute "name".
static String NAV_PACKAGE_TYPE
          XML attribute "nav".
static String PACKAGE_ELEMENT
          XML element "package".
static String PACKAGE_FILE_NAME
          The package definition file name.
static String PACKAGE_NS
          The package namespace.
static Float PACKAGE_VERSION_1_0
          The package 1.0.
static Float PACKAGE_VERSION_2_0
          The package version 2.0.
static Float PACKAGE_VERSION_CURRENT
          The current package version.
static String PRINTDOCUMENT_ID
          The default id used for a print version of the interactive document.
static String PROMOIMAGE_ELEMENT
          The PromoImage controller.
static String PROMOIMAGESLIDESHOW_ELEMENT
          The PromoImageSlideShow controller.
static String PROMOMODULELOADER_ELEMENT
          The PromoModuleLoader controller.
static String PROMOSWFLOADER_ELEMENT
          The PromoSWFLoader controller.
static String RESOURCE_ELEMENT
          XML element "resource".
static String RESOURCES_ELEMENT
          XML element "resources".
static String SCALINGMETHOD_ATTR
          XML attribute "scalingMethod".
static String SOURCE_ATTR
          XML attribute "source".
static String TARGETURL_ATTR
          XML attribute "targetURL".
static String TYPE_ATTR
          XML attribute "type".
static String VERSION_ATTR
          XML attribute "version".
static String WIDTH_ATTR
          XML attribute "width".
static String XFA_PACKAGE_TYPE
          XML attribute "xfa".
static String XMLDATALOADER_ELEMENT
          The XMLDataLoader controller.
 
Constructor Summary
PackageDefinition()
          Creates a new empty package definition.
PackageDefinition(Document doc)
          Constructs a package given an Document.
PackageDefinition(InputStream stream)
          Constructs a package definition from an InputStream that will read from a package.xml.
 
Method Summary
 Attachment addAttachment(String controllerID, String name)
          Finds.
 AssetLoaderController addAttachmentLoader(String id)
          Adds a new AttachmentLoader to the package definition.
 Controller addController(String namespaceURI, String tagName, String id)
          Adds a new controller to the package definition with the given namespace,tagname and id.
 PromoImageController addPromoImage(String id)
          Adds a new PromoImage to the package definition.
 PromoImageSlideShowController addPromoImageSlideShow(String id)
          Adds a new PromoImageSlideShow to the package definition.
 PromoModuleLoaderController addPromoModuleLoader(String id)
          Adds a new PromoModuleLoaderController to the package definition.
 PromoSWFLoaderController addPromoSWFLoader(String id)
          Adds a new PromoSWFLoaderController to the package definition.
 Resource addResource(String controllerID)
          Finds the <resources> entry with the given controller id and adds a new <resource> child with the given name.
 AssetLoaderController addXMLDataLoader(String id)
          Adds a new XMLDataLoader to the package definition.
 List getAttachmentLoaders()
          Returns a list of all AttachmentLoader controllers.
 List getAttachments()
          Gets the list of attachments defined in this package, one for every <attachment> node in the document.
 Controller getController(String controllerID)
          Returns the controller with the given id.
 List getControllers()
          Gets the list of controllers defined in this package.
 List getControllersNS(String namespaceURI, 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.
 String getPackageLocale()
          Returns the package definition locale value.
 String getPackageSource()
          Returns the package definition source value, as in <package source="" >.
 PackageDefinition.PackageType getPackageType()
          Returns the package definition type value.
 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.
 List getPromoImages()
          Returns a list of all PromoImage controllers.
 List getPromoImageSlideShows()
          Returns a list of all PromoImageSlideShow controllers.
 List getPromoModuleLoaders()
          Returns a list of all PromoModuleLoaderController controllers.
 List getPromoSWFLoaders()
          Returns a list of all PromoSWFLoader controllers.
 List getResources()
          Gets the list of resources defined in this package, one for every <resource> node in the document.
 List getXMLDataLoaders()
          Returns a list of all XMLDataLoader controllers.
 void removeAttachments(String controllerID)
          Removes all <attachments> associated with the given controller id from the package definition.
 void removeController(String controllerID)
          Removes any and all controllers with the specified id.
 void removeResources(String controllerID)
          Removes all <resources> associated with the given controller id from the package definition.
 String saveXML()
          Returns the package definition XML.
 byte[] serialize()
          Returns a serialized package definition XML.
 void setPackageLocale(String locale)
          Sets the package definition locale value.
 void setPackageSource(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(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 String PACKAGE_ELEMENT
XML element "package".

See Also:
Constant Field Values

ASSETS_ELEMENT

public static final String ASSETS_ELEMENT
XML element "assets".

See Also:
Constant Field Values

ATTACHMENTS_ELEMENT

public static final String ATTACHMENTS_ELEMENT
XML element "attachments".

See Also:
Constant Field Values

ATTACHMENT_ELEMENT

public static final String ATTACHMENT_ELEMENT
XML element "attachment".

See Also:
Constant Field Values

CONTROLLERS_ELEMENT

public static final String CONTROLLERS_ELEMENT
XML element "controllers".

See Also:
Constant Field Values

DELAY_ELEMENT

public static final String DELAY_ELEMENT
XML element "delay".

See Also:
Constant Field Values

DATA_ELEMENT

public static final String DATA_ELEMENT
XML element "data".

See Also:
Constant Field Values

RESOURCES_ELEMENT

public static final String RESOURCES_ELEMENT
XML element "resources".

See Also:
Constant Field Values

RESOURCE_ELEMENT

public static final String RESOURCE_ELEMENT
XML element "resource".

See Also:
Constant Field Values

CONTENTTYPE_ATTR

public static final String CONTENTTYPE_ATTR
XML attribute "contentType".

See Also:
Constant Field Values

TYPE_ATTR

public static final String TYPE_ATTR
XML attribute "type".

See Also:
Constant Field Values

NAME_ATTR

public static final String NAME_ATTR
XML attribute "name".

See Also:
Constant Field Values

SCALINGMETHOD_ATTR

public static final String SCALINGMETHOD_ATTR
XML attribute "scalingMethod".

See Also:
Constant Field Values

SOURCE_ATTR

public static final String SOURCE_ATTR
XML attribute "source".

See Also:
Constant Field Values

VERSION_ATTR

public static final String VERSION_ATTR
XML attribute "version".

See Also:
Constant Field Values

ALTTEXT_ATTR

public static final String ALTTEXT_ATTR
XML attribute "altText".

See Also:
Constant Field Values

TARGETURL_ATTR

public static final String TARGETURL_ATTR
XML attribute "targetURL".

See Also:
Constant Field Values

EXPIRATION_ATTR

public static final String EXPIRATION_ATTR
XML attribute "expiration".

See Also:
Constant Field Values

WIDTH_ATTR

public static final String WIDTH_ATTR
XML attribute "width".

See Also:
Constant Field Values

HEIGHT_ATTR

public static final String HEIGHT_ATTR
XML attribute "height".

See Also:
Constant Field Values

ID_ATTR

public static final String ID_ATTR
XML attribute "id".

See Also:
Constant Field Values

DESCRIPTION_ATTR

public static final String DESCRIPTION_ATTR
XML attribute "description".

See Also:
Constant Field Values

CONTROLLER_ATTR

public static final String CONTROLLER_ATTR
XML attribute "controller".

See Also:
Constant Field Values

NAV_PACKAGE_TYPE

public static final String NAV_PACKAGE_TYPE
XML attribute "nav".

See Also:
Constant Field Values

XFA_PACKAGE_TYPE

public static final String XFA_PACKAGE_TYPE
XML attribute "xfa".

See Also:
Constant Field Values

LOCALE_ATTR

public static final String LOCALE_ATTR
XML attribute "locale".

See Also:
Constant Field Values

DEFAULT_LOCALE

public static final String DEFAULT_LOCALE
Default locale.

See Also:
Constant Field Values

CONTROLLER_NS

public static final String CONTROLLER_NS
The controller namespace.

See Also:
Constant Field Values

PACKAGE_NS

public static final String PACKAGE_NS
The package namespace.

See Also:
Constant Field Values

PACKAGE_VERSION_1_0

public static final Float PACKAGE_VERSION_1_0
The package 1.0.


PACKAGE_VERSION_2_0

public static final Float PACKAGE_VERSION_2_0
The package version 2.0.


PACKAGE_VERSION_CURRENT

public static final Float PACKAGE_VERSION_CURRENT
The current package version.


PACKAGE_FILE_NAME

public static final String PACKAGE_FILE_NAME
The package definition file name.

See Also:
Constant Field Values

INTERACTIVEDOCUMENT_DATA_ID

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

See Also:
Constant Field Values

PRINTDOCUMENT_ID

public static final 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 String PROMOIMAGE_ELEMENT
The PromoImage controller.

See Also:
Constant Field Values

PROMOIMAGESLIDESHOW_ELEMENT

public static final String PROMOIMAGESLIDESHOW_ELEMENT
The PromoImageSlideShow controller.

See Also:
Constant Field Values

XMLDATALOADER_ELEMENT

public static final String XMLDATALOADER_ELEMENT
The XMLDataLoader controller.

See Also:
Constant Field Values

ATTACHMENTLOADER_ELEMENT

public static final String ATTACHMENTLOADER_ELEMENT
The AttachmentLoader controller.

See Also:
Constant Field Values

PROMOSWFLOADER_ELEMENT

public static final String PROMOSWFLOADER_ELEMENT
The PromoSWFLoader controller.

See Also:
Constant Field Values

PROMOMODULELOADER_ELEMENT

public static final String PROMOMODULELOADER_ELEMENT
The PromoModuleLoader controller.

See Also:
Constant Field Values
Constructor Detail

PackageDefinition

public PackageDefinition()
Creates a new empty package definition.

Throws:
ParserConfigurationException
IOException
SAXException

PackageDefinition

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

Parameters:
stream - The package definition file.
Throws:
SAXException
IOException
ParserConfigurationException
InvalidPackageException

PackageDefinition

public PackageDefinition(Document doc)
                  throws InvalidPackageException,
                         IOException
Constructs a package given an Document.

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

setPackageSource

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

Parameters:
val - The package definition source value.

setPackageLocale

public void setPackageLocale(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 String getPackageSource()
Returns the package definition source value, as in <package source="" >.

Returns:
The source value.

getPackageLocale

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

Returns:
the locale value.

getPackageVersion

public 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(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:
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 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 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(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 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 List getControllersNS(String namespaceURI,
                             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 List getPromoImages()
Returns a list of all PromoImage controllers.

Returns:
A List of Controller objects.

getPromoImageSlideShows

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

Returns:
A List of Controller objects.

getXMLDataLoaders

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

Returns:
A List of Controller objects.

getAttachmentLoaders

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

Returns:
A List of Controller objects.

getPromoModuleLoaders

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

Returns:
A List of PromoModuleLoaderController objects.

getPromoSWFLoaders

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

Returns:
A List of PromoSWFLoaderController objects.

addController

public Controller addController(String namespaceURI,
                                String tagName,
                                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(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(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(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(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(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(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(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(String controllerID,
                                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(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(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(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 String saveXML()
               throws TransformerException
Returns the package definition XML.

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

serialize

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

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


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