org.apache.wicket.markup
Class MarkupResourceStream

java.lang.Object
  extended by org.apache.wicket.markup.MarkupResourceStream
All Implemented Interfaces:
java.io.Closeable, java.io.Serializable, IClusterable, IFixedLocationResourceStream, IResourceStream, IModifiable

public class MarkupResourceStream
extends java.lang.Object
implements IResourceStream, IFixedLocationResourceStream

An IResourceStream implementation with specific extensions for markup resource streams.

Author:
Juergen Donnerstag
See Also:
Serialized Form

Constructor Summary
MarkupResourceStream(IResourceStream resourceStream)
          Construct.
MarkupResourceStream(IResourceStream resourceStream, ContainerInfo containerInfo, java.lang.Class<?> markupClass)
          Construct.
 
Method Summary
 void close()
          Closes the resource.
 Markup getBaseMarkup()
          In case of markup inheritance, the base markup resource.
 MarkupResourceStream getBaseMarkupResourceStream()
          Get the resource stream containing the base markup (markup inheritance)
 java.lang.String getCacheKey()
          Gets cacheKey.
 ContainerInfo getContainerInfo()
          Get the container info associated with the markup
 java.lang.String getContentType()
          Gets the mime type of this resource
 java.lang.String getEncoding()
          Gets the markup encoding.
 java.io.InputStream getInputStream()
          Gets the resource stream.
 java.util.Locale getLocale()
           
 java.lang.Class<? extends Component> getMarkupClass()
          Get the actual component class the markup is directly associated with.
 IResourceStream getResource()
          Gets the resource that contains this markup
 java.lang.String getWicketId()
           
 java.lang.String getWicketNamespace()
          Get the wicket namespace valid for this specific markup
 java.lang.String getXmlDeclaration()
          Return the XML declaration string, in case if found in the markup.
 Time lastModifiedTime()
          Gets the last time this modifiable thing changed.
 long length()
          Gets the size of this resource in bytes TODO 1.5: rename to lengthInBytes() or let it return some sort of size object
 java.lang.String locationAsString()
           
 void setBaseMarkup(Markup baseMarkup)
          In case of markup inheritance, the base markup.
 void setCacheKey(java.lang.String cacheKey)
          Set the cache key
 void setLocale(java.util.Locale locale)
          This method shouldn't be used for the outside, It is used by the Loaders to set the resolved locale.
 void setWicketNamespace(java.lang.String wicketNamespace)
          Sets wicketNamespace.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MarkupResourceStream

public MarkupResourceStream(IResourceStream resourceStream)
Construct.

Parameters:
resourceStream -

MarkupResourceStream

public MarkupResourceStream(IResourceStream resourceStream,
                            ContainerInfo containerInfo,
                            java.lang.Class<?> markupClass)
Construct.

Parameters:
resourceStream -
containerInfo -
markupClass -
Method Detail

locationAsString

public java.lang.String locationAsString()
Specified by:
locationAsString in interface IFixedLocationResourceStream
Returns:
The fixed location as a string, e.g. the file name or the URL. Return null to avoid caching the markup.
See Also:
IFixedLocationResourceStream.locationAsString()

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
Throws:
java.io.IOException
See Also:
IResourceStream.close()

getContentType

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

Specified by:
getContentType in interface IResourceStream
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:
IResourceStream.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
Returns:
Returns the inputStream.
Throws:
ResourceStreamNotFoundException
See Also:
IResourceStream.getInputStream()

getLocale

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

lastModifiedTime

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

Specified by:
lastModifiedTime in interface IModifiable
Returns:
the last modification Time
See Also:
IModifiable.lastModifiedTime()

length

public long length()
Description copied from interface: IResourceStream
Gets the size of this resource in bytes TODO 1.5: rename to lengthInBytes() or let it return some sort of size object

Specified by:
length in interface IResourceStream
Returns:
The size of this resource in the number of bytes, or -1 if unknown
See Also:
IResourceStream.length()

setLocale

public void setLocale(java.util.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
Parameters:
locale - The Locale where this stream did resolve to.
See Also:
IResourceStream.setLocale(java.util.Locale)

getMarkupClass

public java.lang.Class<? extends Component> getMarkupClass()
Get the actual component class the markup is directly associated with. Note: it not necessarily must be the container class.

Returns:
The directly associated class

getContainerInfo

public ContainerInfo getContainerInfo()
Get the container info associated with the markup

Returns:
ContainerInfo

getCacheKey

public final java.lang.String getCacheKey()
Gets cacheKey.

Returns:
cacheKey

setCacheKey

public final void setCacheKey(java.lang.String cacheKey)
Set the cache key

Parameters:
cacheKey -

getResource

public IResourceStream getResource()
Gets the resource that contains this markup

Returns:
The resource where this markup came from

getXmlDeclaration

public java.lang.String getXmlDeclaration()
Return the XML declaration string, in case if found in the markup.

Returns:
Null, if not found.

getEncoding

public java.lang.String getEncoding()
Gets the markup encoding. A markup encoding may be specified in a markup file with an XML encoding specifier of the form <?xml ... encoding="..." ?>.

Returns:
Encoding, or null if not found.

getWicketNamespace

public java.lang.String getWicketNamespace()
Get the wicket namespace valid for this specific markup

Returns:
wicket namespace

getWicketId

public final java.lang.String getWicketId()
Returns:
usually it is "wicket:id"

setWicketNamespace

public final void setWicketNamespace(java.lang.String wicketNamespace)
Sets wicketNamespace.

Parameters:
wicketNamespace - wicketNamespace

getBaseMarkupResourceStream

public MarkupResourceStream getBaseMarkupResourceStream()
Get the resource stream containing the base markup (markup inheritance)

Returns:
baseMarkupResource Null, if not base markup

setBaseMarkup

public void setBaseMarkup(Markup baseMarkup)
In case of markup inheritance, the base markup.

Parameters:
baseMarkup - The base markup

getBaseMarkup

public Markup getBaseMarkup()
In case of markup inheritance, the base markup resource.

Returns:
The base markup

toString

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


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