org.xwiki.model.internal.reference
Class RelativeStringEntityReferenceResolver

java.lang.Object
  extended by org.xwiki.model.internal.reference.AbstractStringEntityReferenceResolver
      extended by org.xwiki.model.internal.reference.RelativeStringEntityReferenceResolver
All Implemented Interfaces:
EntityReferenceResolver<java.lang.String>

@Component
@Named(value="relative")
@Singleton
public class RelativeStringEntityReferenceResolver
extends AbstractStringEntityReferenceResolver

Resolve EntityReference objects from its string representations. This implementation doesn't generate absolute references; instead it stores the the representation into an EntityReference object (ie if the representation is a Document reference and it has only a page name specified, then a single EntityReference of type DOCUMENT will be returned, with no Space and Wiki references). This is useful in cases when we need to store a reference relative to another reference (for example for storing Parent references in a Document, since we want these references to stay relative if the user has specified a relative reference, and absolute if the user has specified an absolute reference).

In other words, this implementation just transforms a String representation into a EntityReference representation without resolving any missing parts (space, wiki, etc).

Since:
2.2.3
Version:
$Id$

Constructor Summary
RelativeStringEntityReferenceResolver()
           
 
Method Summary
protected  java.lang.String getDefaultValue(EntityType type, java.lang.Object... parameters)
          
 EntityReference resolve(java.lang.String entityReferenceRepresentation, EntityType type, java.lang.Object... parameters)
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RelativeStringEntityReferenceResolver

public RelativeStringEntityReferenceResolver()
Method Detail

getDefaultValue

protected java.lang.String getDefaultValue(EntityType type,
                                           java.lang.Object... parameters)

Specified by:
getDefaultValue in class AbstractStringEntityReferenceResolver
Parameters:
type - the entity type for which to return the default value to use (since the use has not specified it)
parameters - optional parameters. Their meaning depends on the resolver implementation
Returns:
the default value to use
See Also:
AbstractStringEntityReferenceResolver.getDefaultValue(org.xwiki.model.EntityType, java.lang.Object...)

resolve

public EntityReference resolve(java.lang.String entityReferenceRepresentation,
                               EntityType type,
                               java.lang.Object... parameters)

Specified by:
resolve in interface EntityReferenceResolver<java.lang.String>
Overrides:
resolve in class AbstractStringEntityReferenceResolver
Parameters:
entityReferenceRepresentation - the representation of an entity reference (eg as a String)
type - the type of the Entity (Document, Space, Attachment, Wiki, etc) to resolve out of the representation
parameters - optional parameters. Their meaning depends on the resolver implementation
Returns:
the valid resolved reference as an Object
See Also:
AbstractStringEntityReferenceResolver.resolve(java.lang.String, org.xwiki.model.EntityType, java.lang.Object...)


Copyright © 2004-2011 XWiki. All Rights Reserved.