org.xwiki.rendering.listener.reference
Class ResourceReference

java.lang.Object
  extended by org.xwiki.rendering.listener.reference.ResourceReference
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
AttachmentResourceReference, DocumentResourceReference, InterWikiResourceReference

public class ResourceReference
extends Object
implements Cloneable

Represents a reference to a Resource (document, image, attachment, mail, etc). Note that this representation is independent of any wiki syntax.

Since:
2.5RC1
Version:
$Id$

Constructor Summary
ResourceReference(String reference, ResourceType type)
           
 
Method Summary
 void addBaseReference(String baseReference)
           
 void addBaseReferences(List<String> baseReferences)
           
 ResourceReference clone()
          
 boolean equals(Object object)
          
 List<String> getBaseReferences()
           
 String getParameter(String name)
          In order for Resource references to be extensible we allow for extra parameters in addition to the Resource reference.
 Map<String,String> getParameters()
           
 String getReference()
           
 ResourceType getType()
           
 int hashCode()
          
 boolean isTyped()
           
 void removeParameter(String name)
           
 void setParameter(String name, String value)
           
 void setParameters(Map<String,String> parameters)
           
 void setReference(String reference)
           
 void setType(ResourceType type)
           
 void setTyped(boolean isTyped)
           
 String toString()
          
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ResourceReference

public ResourceReference(String reference,
                         ResourceType type)
Parameters:
reference - see getReference()
type - see getType()
Method Detail

setTyped

public void setTyped(boolean isTyped)
Parameters:
isTyped - see isTyped()

isTyped

public boolean isTyped()
Returns:
true if the resource type has been explicitly provided (eg in XWiki Syntax 2.1 if the reference is prefixed with the resource type followed by ":" and then the rest of the reference)

setReference

public void setReference(String reference)
Parameters:
reference - see getReference()

getReference

public String getReference()
Returns:
the reference pointed to by this resource. For example a reference can be a document's name (which depends on the wiki, for example for XWiki the format is "wiki:space.page"), a URI (for example: mailto:john@doe.com), a URL, an Inter Wiki reference, etc
See Also:
getType()

addBaseReference

public void addBaseReference(String baseReference)
Parameters:
baseReference - see getBaseReferences()

addBaseReferences

public void addBaseReferences(List<String> baseReferences)
Parameters:
baseReferences - see getBaseReferences()

getBaseReferences

public List<String> getBaseReferences()
Returns:
the base references to use when we need to compute an absolute reference and getReference() returns a non absolute reference, can be null. When resolving references the list should be evaluated from first to last (the last entries qualifying the entries earlier in the list)

getType

public ResourceType getType()
Returns:
the type of the resource
See Also:
ResourceType

setType

public void setType(ResourceType type)
Parameters:
type - the type of the resource
See Also:
ResourceType

setParameter

public void setParameter(String name,
                         String value)
Parameters:
name - see getParameter(String)
value - see getParameter(String)

setParameters

public void setParameters(Map<String,String> parameters)
Parameters:
parameters - see getParameters()

removeParameter

public void removeParameter(String name)
Parameters:
name - see getParameter(String)

getParameter

public String getParameter(String name)
In order for Resource references to be extensible we allow for extra parameters in addition to the Resource reference. For example this is used in Document Resource References for storing the query string and anchor information, and in InterWiki Resource References to store the InterWiki Alias. Note that supported parameters depend on the Renderer that will be used (i.e. it depends on the target Syntax). For example the XWiki Syntax 2.1 only supports "queryString" and "anchor".

Parameters:
name - the name of the parameter to get
Returns:
the parameter value or null if no such parameter exist

getParameters

public Map<String,String> getParameters()
Returns:
the collections of parameters, see getParameter(String)

toString

public String toString()

The output is syntax independent since this class is used for all syntaxes. Specific syntaxes should extend this class and override this method to perform syntax-dependent formatting.

Overrides:
toString in class Object
See Also:
Object.toString()

clone

public ResourceReference clone()

Overrides:
clone in class Object
See Also:
Object.clone()

hashCode

public int hashCode()

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

equals

public boolean equals(Object object)

Overrides:
equals in class Object
See Also:
Object.equals(Object)


Copyright © 2004-2011 XWiki. All Rights Reserved.