com.arsdigita.kernel
Class Stylesheet

java.lang.Object
  extended bycom.arsdigita.domain.DomainObject
      extended bycom.arsdigita.domain.ObservableDomainObject
          extended bycom.arsdigita.kernel.ACSObject
              extended bycom.arsdigita.kernel.Stylesheet
All Implemented Interfaces:
javax.xml.transform.Templates

public class Stylesheet
extends ACSObject
implements javax.xml.transform.Templates


Nested Class Summary
static class Stylesheet.FileSource
          Composite of a String and a boolean.
 
Field Summary
static String versionId
           
 
Fields inherited from class com.arsdigita.kernel.ACSObject
BASE_DATA_OBJECT_TYPE, CONTAINER, DEFAULT_DOMAIN_CLASS, DISPLAY_NAME, ID, OBJECT_TYPE
 
Constructor Summary
Stylesheet()
          Creates an instance of a stylesheet.
Stylesheet(BigDecimal id)
           
Stylesheet(DataObject dataObject)
           
Stylesheet(OID oid)
           
 
Method Summary
static Stylesheet combineStylesheets(Stylesheet[] ssList)
          Loads a set of stylesheets and combines them into a single stylesheet.
 Stylesheet composeStylesheet(Stylesheet s)
          Producer method that adds the rules of a specified stylesheet to the existing stylesheet object and returns the composed moby-stylesheet.
static Stylesheet createStylesheet(String path)
           
static Stylesheet createStylesheet(String path, Locale locale)
           
 byte[] getAllStylesheetContents(javax.servlet.ServletContext ctx)
          Returns a byte array that is the contents of a JAR file containing all the XSL stylesheets imported by this stylesheet plus the primary stylesheet (the root of the import tree).
protected  String getBaseDataObjectType()
          Returns the base data object type for this domain object class.
static String getDefaultOutputType()
          Gets the default output type for new stylesheets.
 String getDisplayName()
          Returns a display name for this stylesheet.
 List getImports()
          Recurses the list of all stylesheets imported from this stylesheet, and returns a list of files.
 long getLastModified()
          Gets the last modified time of this stylesheet, in Java system time (ms since 1970).
 Locale getLocale()
           
 Properties getOutputProperties()
           
 String getOutputType(String type)
           
 String getPath()
          Returns the pathname that was originally associated with this stylesheet object in the database.
 String getPrimaryStylesheetContents(javax.servlet.ServletContext ctx)
          Returns a string representation of the primary stylesheet.
 List getSources()
          Returns the list of all Filesources (with filenames relative to the context root) that should have contributed some part to this stylesheet.
 List getStylesheetList(javax.servlet.ServletContext ctx)
          Returns a list of all stylesheet files that this stylesheet uses, including imported stylesheets (through xsl:import and xsl:include).
 void initialize()
          Called from base class (DomainObject) constructors.
 void invalidate()
          Marks this stylesheet as invalid.
 boolean isNewerThan(Stylesheet s)
          Determines whether this stylesheet is newer than the specified stylesheet.
 boolean isValid()
          Indicates whether this stylesheet is still "fresh" and valid.
 javax.xml.transform.Transformer newTransformer()
           
 void setLocale(Locale locale)
           
 void setLocale(Locale locale)
           
 void setOutputType(String type)
           
 void setPath(String path)
           
static void setTimeout(long ttl)
          Sets the global lifetime for stylesheets before they are re-read.
 String toString()
          Return the OID plus the flags N,M,D,U depending on whether the object is new, modified, deleted, or unknown.
 
Methods inherited from class com.arsdigita.kernel.ACSObject
assertPrivilege, beforeSave, checkPrivilege, doCreateCheck, doWriteCheck, getContainer, getDefaultDomainClass, getID, getSpecificObjectType, getSpecificOID, gimmeContainer, isContainerModified, setID, setID
 
Methods inherited from class com.arsdigita.domain.ObservableDomainObject
addObserver, getObservers
 
Methods inherited from class com.arsdigita.domain.DomainObject
add, add, addToAssociation, afterDelete, afterSave, beforeDelete, clear, delete, disconnect, equals, get, getObjectType, getOID, getSession, hashCode, isDeleted, isDisconnected, isModified, isNew, isPropertyModified, remove, remove, remove, removeFromAssociation, save, set, setAssociation, setAssociation, specializeDataObject, specializeDataObject
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

versionId

public static final String versionId
See Also:
Constant Field Values
Constructor Detail

Stylesheet

public Stylesheet()
Creates an instance of a stylesheet.

See Also:
DomainObject.DomainObject(String)

Stylesheet

public Stylesheet(DataObject dataObject)

Stylesheet

public Stylesheet(OID oid)
           throws DataObjectNotFoundException

Stylesheet

public Stylesheet(BigDecimal id)
           throws DataObjectNotFoundException
Method Detail

getBaseDataObjectType

protected String getBaseDataObjectType()
Description copied from class: DomainObject
Returns the base data object type for this domain object class. Intended to be overrided by subclasses whenever the subclass will only work if their primary data object is of a certain base type.

Overrides:
getBaseDataObjectType in class ACSObject

initialize

public void initialize()
Description copied from class: ACSObject
Called from base class (DomainObject) constructors.

Overrides:
initialize in class ACSObject

isNewerThan

public boolean isNewerThan(Stylesheet s)
Determines whether this stylesheet is newer than the specified stylesheet.

Parameters:
s - the stylesheet to compare against
Returns:
true if this stylesheet's last modified time is after s's or if s is null; false otherwise.

getLastModified

public long getLastModified()
Gets the last modified time of this stylesheet, in Java system time (ms since 1970).

Returns:
the last modified time of this stylesheet.

invalidate

public void invalidate()
Marks this stylesheet as invalid. Subsequent calls to isValid() will return false.


isValid

public boolean isValid()
Indicates whether this stylesheet is still "fresh" and valid.

Overrides:
isValid in class DomainObject
Returns:
true if this stylesheet has not been invalidated and the file sources on disk are all up-to-date. We only check the files on disk every (s_ttl) milliseconds because we don't want to constantly check the filesystem for file modifications.
See Also:
DataObject.isValid()

setTimeout

public static void setTimeout(long ttl)
Sets the global lifetime for stylesheets before they are re-read. Default is 30 seconds. Production systems should bump this up to a longer duration.


combineStylesheets

public static Stylesheet combineStylesheets(Stylesheet[] ssList)
Loads a set of stylesheets and combines them into a single stylesheet.

Parameters:
ssList - the list of stylesheets to combine
Returns:
the combined stylesheet.

setPath

public void setPath(String path)

getPath

public String getPath()
Returns the pathname that was originally associated with this stylesheet object in the database. Will not fully reflect the DOM/Transformer contents of the stylesheet if it is composed with other stylesheets.

Returns:
the pathname originally associated with this stylesheet.

getDisplayName

public String getDisplayName()
Returns a display name for this stylesheet.

Overrides:
getDisplayName in class ACSObject
Returns:
the displayable name for this object.
See Also:
ACSObject.getDisplayName()

getSources

public List getSources()
Returns the list of all Filesources (with filenames relative to the context root) that should have contributed some part to this stylesheet. Attempt to keep them in priority order, but no guarantees.

Returns:
the list of filesources that should have contributed to this stylesheet.
See Also:
Stylesheet.FileSource, Stylesheet.FileSource.isValid()

setOutputType

public void setOutputType(String type)

getOutputType

public String getOutputType(String type)

getLocale

public Locale getLocale()

setLocale

public void setLocale(Locale locale)

setLocale

public void setLocale(Locale locale)

composeStylesheet

public Stylesheet composeStylesheet(Stylesheet s)
Producer method that adds the rules of a specified stylesheet to the existing stylesheet object and returns the composed moby-stylesheet. Gives precedence to the rules in the existing stylesheet object (this) over the input object (s).

Parameters:
s - an XSL stylesheet object
Returns:
a moby-stylesheet with the template rules from this and the template rules from s.

newTransformer

public javax.xml.transform.Transformer newTransformer()
                                               throws javax.xml.transform.TransformerConfigurationException
Specified by:
newTransformer in interface javax.xml.transform.Templates
Throws:
javax.xml.transform.TransformerConfigurationException

getOutputProperties

public Properties getOutputProperties()
Specified by:
getOutputProperties in interface javax.xml.transform.Templates

createStylesheet

public static Stylesheet createStylesheet(String path)

createStylesheet

public static Stylesheet createStylesheet(String path,
                                          Locale locale)

toString

public String toString()
Description copied from class: DomainObject
Return the OID plus the flags N,M,D,U depending on whether the object is new, modified, deleted, or unknown. Unknown is for objects that have been invalidated.

Overrides:
toString in class DomainObject

getDefaultOutputType

public static String getDefaultOutputType()
Gets the default output type for new stylesheets.

Returns:
the default output type for new stylesheets

getPrimaryStylesheetContents

public String getPrimaryStylesheetContents(javax.servlet.ServletContext ctx)
                                    throws IOException
Returns a string representation of the primary stylesheet.

Parameters:
ctx - the current servlet context
Returns:
a string representation of the primary stylesheet.
Throws:
IOException

getAllStylesheetContents

public byte[] getAllStylesheetContents(javax.servlet.ServletContext ctx)
                                throws IOException
Returns a byte array that is the contents of a JAR file containing all the XSL stylesheets imported by this stylesheet plus the primary stylesheet (the root of the import tree).

Parameters:
ctx - the current servlet context
Returns:
a byte[] consisting of a JAR file contents that contains all the XSL stylesheets imported by this stylesheet.
Throws:
IOException

getStylesheetList

public List getStylesheetList(javax.servlet.ServletContext ctx)
                       throws IOException
Returns a list of all stylesheet files that this stylesheet uses, including imported stylesheets (through xsl:import and xsl:include).

Parameters:
ctx - the current servlet context
Returns:
a list of file objects.
Throws:
IOException

getImports

public List getImports()
Recurses the list of all stylesheets imported from this stylesheet, and returns a list of files.

Returns:
the list of stylesheet files (File objects) that are imported by this Stylesheet.


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 21 2004:2337 UTC