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:
Closeable, 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
 String asString()
          Returns the decorated contents as a String.
 String asString(Map<String,Object> variables)
          Returns the decorated contents as a String.
 void close()
          Closes the resource.
 boolean equals(Object obj)
           
abstract  String getAfterTemplateContents()
          Retrieves the String to put after the actual template contents, for example:
abstract  String getBeforeTemplateContents()
          Retrieves the String to put before the actual template contents, for example:
 String getContentType()
          Gets the mime type of this resource
 InputStream getInputStream()
          Gets the resource stream.
 Locale getLocale()
           
 String getString()
          Retrieves the String resource.
 int hashCode()
           
 Time lastModifiedTime()
          Gets the last time this modifiable thing changed.
 void setCharset(Charset charset)
          Sets the character set used for reading this resource.
 void setLastModified(Time lastModified)
           
 void setLocale(Locale locale)
          This method shouldn't be used for the outside, It is used by the Loaders to set the resolved locale.
 String toString()
           
 
Methods inherited from class org.apache.wicket.util.template.TextTemplate
interpolate
 
Methods inherited from class org.apache.wicket.util.resource.AbstractStringResourceStream
length
 
Methods inherited from class org.apache.wicket.util.resource.AbstractResourceStream
getCharset
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

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 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 String asString(Map<String,Object> 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 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 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 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 Closeable
Specified by:
close in interface IResourceStream
Overrides:
close in class AbstractStringResourceStream
Throws:
IOException
See Also:
AbstractStringResourceStream.close()

equals

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

getContentType

public 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 ResourceStreamRequestTarget handle the Content-Type automatically
See Also:
AbstractStringResourceStream.getContentType()

getInputStream

public 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 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 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
See Also:
AbstractStringResourceStream.lastModifiedTime()

setCharset

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

Specified by:
setCharset in interface IStringResourceStream
Overrides:
setCharset in class AbstractResourceStream
Parameters:
charset - Charset for component
See Also:
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(Locale locale)
Description copied from interface: IResourceStream
This method shouldn't be used for 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 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 String toString()
Overrides:
toString in class Object
See Also:
Object.toString()


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