|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.wicket.request.resource.AbstractResource org.apache.wicket.request.resource.PackageResource
public class PackageResource
Represents a localizable static resource.
Use like eg:
MyPackageResource IMG_UNKNOWN = new MyPackageResource(EditPage.class, "questionmark.gif");where the static resource references image 'questionmark.gif' from the the package that EditPage is in to get a package resource. Access to resources can be granted or denied via a
IPackageResourceGuard
. Please see
IResourceSettings.getPackageResourceGuard()
as well.
Nested Class Summary | |
---|---|
static class |
PackageResource.PackageResourceBlockedException
Exception thrown when the creation of a package resource is not allowed. |
Nested classes/interfaces inherited from class org.apache.wicket.request.resource.AbstractResource |
---|
AbstractResource.ResourceResponse, AbstractResource.WriteCallback |
Nested classes/interfaces inherited from interface org.apache.wicket.request.resource.IResource |
---|
IResource.Attributes |
Field Summary |
---|
Fields inherited from class org.apache.wicket.request.resource.AbstractResource |
---|
INTERNAL_HEADERS |
Constructor Summary | |
---|---|
protected |
PackageResource(Class<?> scope,
String name,
Locale locale,
String style,
String variation)
Hidden constructor. |
Method Summary | |
---|---|
boolean |
equals(Object obj)
|
static boolean |
exists(Class<?> scope,
String path,
Locale locale,
String style,
String variation)
Checks whether a resource for a given set of criteria exists. |
static boolean |
exists(ResourceReference.Key key)
Checks whether a resource for a given set of criteria exists. |
IResourceStream |
getCacheableResourceStream()
be aware that method takes the current wicket session's locale and style into account when locating the stream. |
Serializable |
getCacheKey()
get unique caching key for the resource stream produced by IStaticCacheableResource.getCacheableResourceStream() |
boolean |
getCompress()
|
IResourceStream |
getResourceStream()
locate resource stream for current resource |
Class<?> |
getScope()
Gets the scoping class, used for class loading and to determine the package. |
String |
getStyle()
Gets the style. |
String |
getTextEncoding()
get text encoding (intented for character-based resources) |
int |
hashCode()
|
boolean |
isCachingEnabled()
controls whether caching of the resource is enabled or disabled |
protected AbstractResource.ResourceResponse |
newResourceResponse(IResource.Attributes attributes)
creates a new resource response based on the request attributes |
protected byte[] |
processResponse(IResource.Attributes attributes,
byte[] original)
Gives a chance to modify the resource going to be written in the response |
void |
setCachingEnabled(boolean enabled)
|
void |
setCompress(boolean compress)
|
void |
setTextEncoding(String textEncoding)
set text encoding (intented for character-based resources) |
String |
toString()
|
Methods inherited from class org.apache.wicket.request.resource.AbstractResource |
---|
configureCache, flushResponseAfterHeaders, getCachingStrategy, respond, setResponseHeaders |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.apache.wicket.request.resource.IResource |
---|
respond |
Constructor Detail |
---|
protected PackageResource(Class<?> scope, String name, Locale locale, String style, String variation)
scope
- This argument will be used to get the class loader for loading the package
resource, and to determine what package it is inname
- The relative path to the resourcelocale
- The locale of the resourcestyle
- The style of the resourcevariation
- The component's variation (of the style)Method Detail |
---|
public boolean isCachingEnabled()
IStaticCacheableResource
isCachingEnabled
in interface IStaticCacheableResource
public void setCachingEnabled(boolean enabled)
public String getTextEncoding()
null
to use defaultpublic void setTextEncoding(String textEncoding)
textEncoding
- custom encoding or null
to use defaultpublic Serializable getCacheKey()
IStaticCacheableResource
IStaticCacheableResource.getCacheableResourceStream()
getCacheKey
in interface IStaticCacheableResource
#equals(Object)
and
#hashCode()
public final Class<?> getScope()
public final String getStyle()
protected AbstractResource.ResourceResponse newResourceResponse(IResource.Attributes attributes)
newResourceResponse
in class AbstractResource
attributes
- current request attributes from client
protected byte[] processResponse(IResource.Attributes attributes, byte[] original)
attributes
- current request attributes from clientoriginal
- the original response
public IResourceStream getCacheableResourceStream()
getCacheableResourceStream
in interface IStaticCacheableResource
IStaticCacheableResource.getCacheableResourceStream()
,
getResourceStream()
public IResourceStream getResourceStream()
null
if not foundpublic boolean getCompress()
ITextResourceCompressor
can be used to compress the
resource.public void setCompress(boolean compress)
compress
- A flag indicating whether the resource should be compressed.public static boolean exists(ResourceReference.Key key)
key
- The key that contains all attributes about the requested resource
true
if there is a package resource with the given attributespublic static boolean exists(Class<?> scope, String path, Locale locale, String style, String variation)
scope
- This argument will be used to get the class loader for loading the package
resource, and to determine what package it is in. Typically this is the class in
which you call this methodpath
- The path to the resourcelocale
- The locale of the resourcestyle
- The style of the resource (see Session
)variation
- The component's variation (of the style)
true
if a resource could be loaded, false
otherwisepublic String toString()
toString
in class Object
public int hashCode()
hashCode
in class Object
public boolean equals(Object obj)
equals
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |