org.apache.wicket.request.resource
Class ResourceReference

java.lang.Object
  extended by org.apache.wicket.request.resource.ResourceReference
All Implemented Interfaces:
Serializable, IClusterable
Direct Known Subclasses:
ConcatResourceBundleReference, ContextRelativeResourceReference, PackageResourceReference, ResourceBundleReference, SharedResourceReference, TextTemplateResourceReference, UrlResourceReference

public abstract class ResourceReference
extends Object
implements IClusterable

Reference to a resource. Can be used to reference global resources.

Even though resource reference is just a factory for resources, it still needs to be identified by a globally unique identifier, combination of scope and name. Those are used to generate URLs for resource references. locale, style and variation are optional fields to allow having specific references for individual locales, styles and variations.

Author:
Matej Knopp, Juergen Donnerstag
See Also:
Serialized Form

Nested Class Summary
static class ResourceReference.Key
          A (re-usable) data store for all relevant ResourceReference data
static class ResourceReference.UrlAttributes
           
 
Constructor Summary
ResourceReference(Class<?> scope, String name)
          Creates new ResourceReference instance.
ResourceReference(Class<?> scope, String name, Locale locale, String style, String variation)
          Creates new ResourceReference instance.
ResourceReference(ResourceReference.Key key)
          Creates new ResourceReference instance.
ResourceReference(String name)
          Construct.
 
Method Summary
 boolean canBeRegistered()
          Can be used to disable registering certain resource references in ResourceReferenceRegistry.
 boolean equals(Object obj)
           
 Iterable<? extends HeaderItem> getDependencies()
           
 String getExtension()
          returns extension of the resource reference
 ResourceReference.Key getKey()
           
 Locale getLocale()
           
 String getName()
           
abstract  IResource getResource()
          Returns the resource.
 Class<?> getScope()
           
 String getStyle()
           
 ResourceReference.UrlAttributes getUrlAttributes()
          Allows to specify which locale, style and variation values will the generated URL for this resource reference have.
 String getVariation()
           
 int hashCode()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ResourceReference

public ResourceReference(ResourceReference.Key key)
Creates new ResourceReference instance.

Parameters:
key - The data making up the resource reference

ResourceReference

public ResourceReference(Class<?> scope,
                         String name,
                         Locale locale,
                         String style,
                         String variation)
Creates new ResourceReference instance.

Parameters:
scope - mandatory parameter
name - mandatory parameter
locale - resource locale
style - resource style
variation - resource variation

ResourceReference

public ResourceReference(Class<?> scope,
                         String name)
Creates new ResourceReference instance.

Parameters:
scope - mandatory parameter
name - mandatory parameter

ResourceReference

public ResourceReference(String name)
Construct.

Parameters:
name - resource name
Method Detail

getKey

public final ResourceReference.Key getKey()
Returns:
Gets the data making up the resource reference. They'll be use by ResourceReferenceRegistry to make up the key under which the resource reference gets stored.

getName

public String getName()
Returns:
name

getExtension

public final String getExtension()
returns extension of the resource reference

Returns:
extension of the resource's name in lower-case or null if there is no extension

getScope

public Class<?> getScope()
Returns:
scope

getLocale

public Locale getLocale()
Returns:
locale

getStyle

public String getStyle()
Returns:
style

getVariation

public String getVariation()
Returns:
variation

canBeRegistered

public boolean canBeRegistered()
Can be used to disable registering certain resource references in ResourceReferenceRegistry.

Returns:
true if this reference can be registered, false otherwise.

equals

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

hashCode

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

getResource

public abstract IResource getResource()
Returns the resource.

Returns:
resource instance

getUrlAttributes

public ResourceReference.UrlAttributes getUrlAttributes()
Allows to specify which locale, style and variation values will the generated URL for this resource reference have.

Returns:
url attributes

toString

public String toString()
Overrides:
toString in class Object

getDependencies

public Iterable<? extends HeaderItem> getDependencies()
Returns:
the resources this ResourceReference depends on.


Copyright © 2006–2016 Apache Software Foundation. All rights reserved.