|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.wicket.Resource org.apache.wicket.markup.html.WebResource org.apache.wicket.markup.html.PackageResource
public class PackageResource
Represents a localizable static resource.
Use like eg:
PackageResource IMG_UNKNOWN = PackageResource.get(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. |
Field Summary | |
---|---|
static java.util.regex.Pattern |
EXTENSION_CSS
Deprecated. Will be removed in 2.0; contribute resources one by one instead |
static java.util.regex.Pattern |
EXTENSION_JS
Deprecated. Will be removed in 2.0; contribute resources one by one instead |
Fields inherited from interface org.apache.wicket.IResourceListener |
---|
INTERFACE |
Constructor Summary | |
---|---|
protected |
PackageResource(java.lang.Class scope,
java.lang.String path,
java.util.Locale locale,
java.lang.String style)
Hidden constructor. |
Method Summary | |
---|---|
boolean |
accept(java.lang.Class scope,
java.lang.String path)
Whether the package resource that can be reached using the provided parameters may be accessed. |
static void |
bind(Application application,
java.lang.Class scope,
java.util.regex.Pattern pattern)
Deprecated. Since Wicket 1.2.1 this method is effectively a no-op. package resources are automatically tried and bound as shared resources so that
they don't have to be pre-registered anymore. Will be removed in 2.0 |
static void |
bind(Application application,
java.lang.Class scope,
java.util.regex.Pattern pattern,
boolean recurse)
Deprecated. Since Wicket 1.2.1 this method is effectively a no-op. package resources are automatically tried and bound as shared resources so that
they don't have to be pre-registered anymore. Will be removed in 2.0 |
static void |
bind(Application application,
java.lang.Class scope,
java.lang.String name)
Binds a resource to the given application object. |
static void |
bind(Application application,
java.lang.Class scope,
java.lang.String name,
java.util.Locale locale)
Binds a resource to the given application object. |
static void |
bind(Application application,
java.lang.Class scope,
java.lang.String name,
java.util.Locale locale,
java.lang.String style)
Binds a resource to the given application object. |
static boolean |
exists(java.lang.Class scope,
java.lang.String path,
java.util.Locale locale,
java.lang.String style)
Gets whether a resource for a given set of criteria exists. |
static PackageResource[] |
get(java.lang.Class scope,
java.util.regex.Pattern pattern)
Deprecated. Will be removed in 2.0; contribute resources one by one instead |
static PackageResource[] |
get(java.lang.Class scope,
java.util.regex.Pattern pattern,
boolean recurse)
Deprecated. Will be removed in 2.0; contribute resources one by one instead |
static PackageResource |
get(java.lang.Class scope,
java.lang.String path)
Gets a non-localized resource for a given set of criteria. |
static PackageResource |
get(java.lang.Class scope,
java.lang.String path,
java.util.Locale locale,
java.lang.String style)
Gets the resource for a given set of criteria. |
java.lang.String |
getAbsolutePath()
Gets the absolute path of the resource. |
java.util.Locale |
getLocale()
Gets the locale. |
java.lang.String |
getPath()
Gets the path this resource was created with. |
IResourceStream |
getResourceStream()
|
IResourceStream |
getResourceStream(boolean failOnError)
|
java.lang.Class |
getScope()
Gets the scoping class, used for class loading and to determine the package. |
java.lang.String |
getStyle()
Gets the style. |
Time |
lastModifiedTime()
Returns the last modified time of resource |
protected static PackageResource |
newPackageResource(java.lang.Class scope,
java.lang.String path,
java.util.Locale locale,
java.lang.String style)
Create a new PackageResource |
Methods inherited from class org.apache.wicket.markup.html.WebResource |
---|
configureResponse, getCacheDuration, setHeaders |
Methods inherited from class org.apache.wicket.Resource |
---|
getParameters, invalidate, isCacheable, onResourceRequested, setCacheable, setParameters |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.util.regex.Pattern EXTENSION_CSS
public static final java.util.regex.Pattern EXTENSION_JS
Constructor Detail |
---|
protected PackageResource(java.lang.Class scope, java.lang.String path, java.util.Locale locale, java.lang.String style)
scope
- This argument will be used to get the class loader for loading the package
resource, and to determine what package it is inpath
- The path to the resourcelocale
- The locale of the resourcestyle
- The style of the resourceMethod Detail |
---|
public static void bind(Application application, java.lang.Class scope, java.util.regex.Pattern pattern)
package resources
are automatically tried and bound as shared resources so that
they don't have to be pre-registered anymore. Will be removed in 2.0
application
- The application to bind to.scope
- The scope of the resource.pattern
- A regular expression to match against the contents of the package of the provided
scope class (eg ".\*\.js" will add all the files with extension
"js" from that package).public static void bind(Application application, java.lang.Class scope, java.util.regex.Pattern pattern, boolean recurse)
package resources
are automatically tried and bound as shared resources so that
they don't have to be pre-registered anymore. Will be removed in 2.0
application
- The application to bind to.scope
- The scope of the resource.pattern
- A regular expression to match against the contents of the package of the provided
scope class (eg ".\*\.js" will add all the files with extension
"js" from that package).recurse
- Whether this method should recurse into sub packagespublic static void bind(Application application, java.lang.Class scope, java.lang.String name)
application
- The application to bind to.scope
- The scope of the resource.name
- The name of the resource (like "myfile.js")public static void bind(Application application, java.lang.Class scope, java.lang.String name, java.util.Locale locale)
application
- The application to bind to.scope
- The scope of the resource.name
- The name of the resource (like "myfile.js")locale
- The locale of the resource.public static void bind(Application application, java.lang.Class scope, java.lang.String name, java.util.Locale locale, java.lang.String style)
application
- The application to bind to.scope
- The scope of the resource.name
- The name of the resource (like "myfile.js")locale
- The locale of the resource.style
- The style of the resource.public static boolean exists(java.lang.Class scope, java.lang.String path, java.util.Locale locale, java.lang.String style)
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
)
public static PackageResource[] get(java.lang.Class scope, java.util.regex.Pattern pattern)
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 calling
class/ the class in which you call this methodpattern
- Regexp pattern to match resources
public static PackageResource[] get(java.lang.Class scope, java.util.regex.Pattern pattern, boolean recurse)
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 calling
class/ the class in which you call this methodpattern
- Regexp pattern to match resourcesrecurse
- Whether this method should recurse into sub packages
public static PackageResource get(java.lang.Class scope, java.lang.String path)
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 calling
class/ the class in which you call this methodpath
- The path to the resource
public static PackageResource get(java.lang.Class scope, java.lang.String path, java.util.Locale locale, java.lang.String style)
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
)
protected static PackageResource newPackageResource(java.lang.Class scope, java.lang.String path, java.util.Locale locale, java.lang.String style)
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
)
public final java.lang.String getAbsolutePath()
public final java.util.Locale getLocale()
public final java.lang.String getPath()
public IResourceStream getResourceStream()
getResourceStream
in class Resource
public IResourceStream getResourceStream(boolean failOnError)
failOnError
- throw an AbortException when resource does not exist
public final java.lang.Class getScope()
public final java.lang.String getStyle()
public Time lastModifiedTime()
lastModifiedTime
in interface IModifiable
public boolean accept(java.lang.Class scope, java.lang.String path)
IPackageResourceGuard
accept
in interface IPackageResourceGuard
scope
- This argument will be used to get the class loader for loading the package
resource, and to determine what package it is inpath
- The path to the resource
IPackageResourceGuard.accept(java.lang.Class,
java.lang.String)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |