org.apache.wicket.util.template
Class TextTemplateDecorator

java.lang.Object
  extended by org.apache.wicket.util.resource.AbstractResourceStream
      extended by org.apache.wicket.util.resource.AbstractStringResourceStream
          extended by org.apache.wicket.util.template.TextTemplate
              extended by org.apache.wicket.util.template.TextTemplateDecorator
All Implemented Interfaces:
java.io.Closeable, java.io.Serializable, IClusterable, IResourceStream, IStringResourceStream, IModifiable
Direct Known Subclasses:
CssTemplate, JavaScriptTemplate

public abstract class TextTemplateDecorator
extends TextTemplate

Provides the ability to 'decorate' the actual template contents before it is contributed to the header. For example, to embed it inside a JavaScript tag pair.

Since:
1.2.6
Author:
Eelco Hillenius
See Also:
Serialized Form

Field Summary
protected  TextTemplate decorated
          The decorated TextTemplate.
 
Fields inherited from class org.apache.wicket.util.resource.AbstractStringResourceStream
DEFAULT_CONTENT_TYPE
 
Constructor Summary
TextTemplateDecorator(TextTemplate textTemplate)
          Constructor.
 
Method Summary
 java.lang.String asString()
          Returns the decorated contents as a String.
 java.lang.String asString(java.util.Map<java.lang.String,?> variables)
          Returns the decorated contents as a String.
 void close()
          Closes the resource.
 boolean equals(java.lang.Object obj)
           
abstract  java.lang.String getAfterTemplateContents()
          Retrieves the String to put after the actual template contents, for example:
abstract  java.lang.String getBeforeTemplateContents()
          Retrieves the String to put before the actual template contents, for example:
 java.lang.String getContentType()
          Gets the mime type of this resource
 java.io.InputStream getInputStream()
          Gets the resource stream.
 java.util.Locale getLocale()
           
 java.lang.String getString()
          Retrieves the String resource.
 int hashCode()
           
 Time lastModifiedTime()
          Gets the last time this modifiable thing changed.
 void setCharset(java.nio.charset.Charset charset)
          Sets the character set used for reading this resource.
 void setLastModified(Time lastModified)
           
 void setLocale(java.util.Locale locale)
          This method shouldn't be used from the outside.
 java.lang.String toString()
           
 
Methods inherited from class org.apache.wicket.util.template.TextTemplate
interpolate
 
Methods inherited from class org.apache.wicket.util.resource.AbstractStringResourceStream
getCharset, length
 
Methods inherited from class org.apache.wicket.util.resource.AbstractResourceStream
getStyle, getVariation, setStyle, setVariation
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.wicket.util.resource.IResourceStream
getStyle, getVariation, setStyle, setVariation
 

Field Detail

decorated

protected final TextTemplate decorated
The decorated TextTemplate.

Constructor Detail

TextTemplateDecorator

public TextTemplateDecorator(TextTemplate textTemplate)
Constructor.

Parameters:
textTemplate - a TextTemplate to decorate
Method Detail

asString

public java.lang.String asString()
Returns the decorated contents as a String.

Specified by:
asString in interface IStringResourceStream
Overrides:
asString in class TextTemplate
Returns:
the contents decorated with getBeforeTemplateContents() and getAfterTemplateContents()
See Also:
TextTemplate.asString()

asString

public java.lang.String asString(java.util.Map<java.lang.String,?> variables)
Returns the decorated contents as a String.

Overrides:
asString in class TextTemplate
Parameters:
variables - the variables to interpolate
Returns:
the contents decorated with getBeforeTemplateContents() and getAfterTemplateContents().
See Also:
TextTemplate.asString(java.util.Map)

getBeforeTemplateContents

public abstract java.lang.String getBeforeTemplateContents()
Retrieves the String to put before the actual template contents, for example:
    <script type="text/javascript">
 

Returns:
the String to put before the actual template contents

getAfterTemplateContents

public abstract java.lang.String getAfterTemplateContents()
Retrieves the String to put after the actual template contents, for example:
    </script>
 

Returns:
the String to put after the actual template contents

close

public void close()
           throws java.io.IOException
Description copied from interface: IResourceStream
Closes the resource. Normally, this includes closing any underlying input stream returned by getInputStream().

Specified by:
close in interface java.io.Closeable
Specified by:
close in interface IResourceStream
Overrides:
close in class AbstractStringResourceStream
Throws:
java.io.IOException
See Also:
AbstractStringResourceStream.close()

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object
See Also:
Object.equals(java.lang.Object)

getContentType

public java.lang.String getContentType()
Description copied from interface: IResourceStream
Gets the mime type of this resource

Specified by:
getContentType in interface IResourceStream
Overrides:
getContentType in class AbstractStringResourceStream
Returns:
The mime type of this resource, such as "image/jpeg" or "text/html". Return null to let ResourceStreamRequestHandler handle the Content-Type automatically
See Also:
AbstractStringResourceStream.getContentType()

getInputStream

public java.io.InputStream getInputStream()
                                   throws ResourceStreamNotFoundException
Description copied from interface: IResourceStream
Gets the resource stream. You should not directly close this stream. Instead call the close() method on IResourceStream.

Specified by:
getInputStream in interface IResourceStream
Overrides:
getInputStream in class AbstractStringResourceStream
Returns:
Returns the inputStream.
Throws:
ResourceStreamNotFoundException
See Also:
AbstractStringResourceStream.getInputStream()

getLocale

public java.util.Locale getLocale()
Specified by:
getLocale in interface IResourceStream
Overrides:
getLocale in class AbstractResourceStream
Returns:
The Locale where this stream did resolve to
See Also:
AbstractResourceStream.getLocale()

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object
See Also:
Object.hashCode()

lastModifiedTime

public Time lastModifiedTime()
Description copied from interface: IModifiable
Gets the last time this modifiable thing changed.

Specified by:
lastModifiedTime in interface IModifiable
Overrides:
lastModifiedTime in class AbstractStringResourceStream
Returns:
the last modification Time or null if that information is not available
See Also:
AbstractStringResourceStream.lastModifiedTime()

setCharset

public void setCharset(java.nio.charset.Charset charset)
Description copied from class: AbstractStringResourceStream
Sets the character set used for reading this resource.

Specified by:
setCharset in interface IStringResourceStream
Overrides:
setCharset in class AbstractStringResourceStream
Parameters:
charset - Charset for component
See Also:
org.apache.wicket.util.resource.AbstractResourceStream#setCharset(java.nio.charset.Charset)

setLastModified

public void setLastModified(Time lastModified)
Overrides:
setLastModified in class AbstractStringResourceStream
Parameters:
lastModified - The lastModified to set.
See Also:
AbstractStringResourceStream.setLastModified(org.apache.wicket.util.time.Time)

setLocale

public void setLocale(java.util.Locale locale)
Description copied from interface: IResourceStream
This method shouldn't be used from the outside. It is used by the Loaders to set the resolved locale.

Specified by:
setLocale in interface IResourceStream
Overrides:
setLocale in class AbstractResourceStream
Parameters:
locale - The Locale where this stream did resolve to.
See Also:
AbstractResourceStream.setLocale(java.util.Locale)

getString

public java.lang.String getString()
Description copied from class: TextTemplate
Retrieves the String resource.

Specified by:
getString in class TextTemplate
Returns:
the String resource
See Also:
TextTemplate.getString()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()


Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.