org.xwiki.model.reference
Class DocumentReference

java.lang.Object
  extended by org.xwiki.model.reference.EntityReference
      extended by org.xwiki.model.reference.DocumentReference
All Implemented Interfaces:
Serializable, Cloneable, Comparable<EntityReference>

public class DocumentReference
extends EntityReference

Represents a reference to a document (wiki, space and page names).

Since:
2.2M1
Version:
$Id: d8ee9872095473617b4010f33b95ccc40da79b35 $
See Also:
Serialized Form

Constructor Summary
  DocumentReference(EntityReference reference)
          Special constructor that transforms a generic entity reference into a DocumentReference.
protected DocumentReference(EntityReference reference, EntityReference oldReference, EntityReference newReference)
          Clone an DocumentReference, but replace one of the parent in the chain by a new one.
  DocumentReference(EntityReference reference, Locale locale)
          Clone the provided reference and change the Locale.
  DocumentReference(String wikiName, List<String> spaceNames, String pageName)
          Create a new Document reference from wiki name, spaces names and page name.
  DocumentReference(String wikiName, List<String> spaceNames, String pageName, Locale locale)
          Create a new Document reference from wiki name, spaces names, page name and locale.
  DocumentReference(String pageName, SpaceReference parent)
          Create a new Document reference from document name and parent space.
  DocumentReference(String pageName, SpaceReference parent, Locale locale)
          Create a new Document reference from document name, parent space and locale.
  DocumentReference(String wikiName, String spaceName, String pageName)
          Create a new Document reference from wiki, space and page name.
  DocumentReference(String wikiName, String spaceName, String pageName, Locale locale)
          Create a new Document reference from wiki name, space name, page name and locale.
  DocumentReference(String wikiName, String spaceName, String pageName, String language)
          Create a new Document reference from wiki name, space name, page name and language.
 
Method Summary
 SpaceReference getLastSpaceReference()
           
 Locale getLocale()
           
 List<SpaceReference> getSpaceReferences()
           
 WikiReference getWikiReference()
           
 DocumentReference replaceParent(EntityReference oldParent, EntityReference newParent)
          Return a clone of this reference, but with one of its parent replaced by another one.
protected  void setLocale(Locale locale)
          Set the locale of this document reference.
protected  void setParent(EntityReference parent)
          Entity reference are immutable since 3.3M2, so this method is now protected.
protected  void setType(EntityType type)
          Entity reference are immutable since 3.3M2, so this method is now protected.
 
Methods inherited from class org.xwiki.model.reference.EntityReference
appendParent, compareTo, equals, extractReference, getName, getParameter, getParent, getReversedReferenceChain, getRoot, getType, hashCode, removeParent, setName, setParameter, setParameters, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DocumentReference

public DocumentReference(EntityReference reference)
Special constructor that transforms a generic entity reference into a DocumentReference. It checks the validity of the passed reference (ie correct type and correct parent).

Parameters:
reference - the reference to convert
Throws:
IllegalArgumentException - if the passed reference is not a valid document reference

DocumentReference

protected DocumentReference(EntityReference reference,
                            EntityReference oldReference,
                            EntityReference newReference)
Clone an DocumentReference, but replace one of the parent in the chain by a new one.

Parameters:
reference - the reference that is cloned
oldReference - the old parent that will be replaced
newReference - the new parent that will replace oldReference in the chain
Since:
3.3M2

DocumentReference

public DocumentReference(EntityReference reference,
                         Locale locale)
Clone the provided reference and change the Locale.

Parameters:
reference - the reference to clone
locale - the new locale for this reference, if null, locale is removed
Throws:
IllegalArgumentException - if the passed reference is not a valid document reference

DocumentReference

public DocumentReference(String wikiName,
                         String spaceName,
                         String pageName)
Create a new Document reference from wiki, space and page name.

Parameters:
wikiName - the name of the wiki containing the document, must not be null
spaceName - the name of the space containing the document, must not be null
pageName - the name of the document

DocumentReference

public DocumentReference(String wikiName,
                         String spaceName,
                         String pageName,
                         Locale locale)
Create a new Document reference from wiki name, space name, page name and locale.

Parameters:
wikiName - the name of the wiki containing the document, must not be null
spaceName - the name of the space containing the document, must not be null
pageName - the name of the document
locale - the locale of the document reference, may be null

DocumentReference

public DocumentReference(String wikiName,
                         String spaceName,
                         String pageName,
                         String language)
Create a new Document reference from wiki name, space name, page name and language. This is an helper function during transition from language to locale, it will be deprecated ASAP.

Parameters:
wikiName - the name of the wiki containing the document, must not be null
spaceName - the name of the space containing the document, must not be null
pageName - the name of the document
language - the language of the document reference, may be null

DocumentReference

public DocumentReference(String wikiName,
                         List<String> spaceNames,
                         String pageName)
Create a new Document reference from wiki name, spaces names and page name.

Parameters:
wikiName - the name of the wiki containing the document, must not be null
spaceNames - an ordered list of the names of the spaces containing the document from root space to last one, must not be null
pageName - the name of the document

DocumentReference

public DocumentReference(String wikiName,
                         List<String> spaceNames,
                         String pageName,
                         Locale locale)
Create a new Document reference from wiki name, spaces names, page name and locale.

Parameters:
wikiName - the name of the wiki containing the document, must not be null
spaceNames - an ordered list of the names of the spaces containing the document from root space to last one, must not be null
pageName - the name of the document reference
locale - the locale of the document reference, may be null

DocumentReference

public DocumentReference(String pageName,
                         SpaceReference parent)
Create a new Document reference from document name and parent space.

Parameters:
pageName - the name of the document
parent - the parent space for the document

DocumentReference

public DocumentReference(String pageName,
                         SpaceReference parent,
                         Locale locale)
Create a new Document reference from document name, parent space and locale.

Parameters:
pageName - the name of the document
parent - the parent space for the document
locale - the locale of the document reference, may be null
Method Detail

setParent

protected void setParent(EntityReference parent)
Entity reference are immutable since 3.3M2, so this method is now protected. Overridden in order to verify the validity of the passed parent.

Overrides:
setParent in class EntityReference
Parameters:
parent - the parent for this entity, may be null for a root entity.
Throws:
IllegalArgumentException - if the passed parent is not a valid document reference parent (ie a space reference)
See Also:
EntityReference.setParent(EntityReference)

setType

protected void setType(EntityType type)
Entity reference are immutable since 3.3M2, so this method is now protected. Overridden in order to verify the validity of the passed type.

Overrides:
setType in class EntityReference
Parameters:
type - the type for this entity
Throws:
IllegalArgumentException - if the passed type is not a document type
See Also:
EntityReference.setType(org.xwiki.model.EntityType)

setLocale

protected void setLocale(Locale locale)
Set the locale of this document reference.

Parameters:
locale - the locale of this document reference

getLocale

public Locale getLocale()
Returns:
the locale of this document reference

getWikiReference

public WikiReference getWikiReference()
Returns:
the wiki reference of this document reference

getLastSpaceReference

public SpaceReference getLastSpaceReference()
Returns:
the space reference of the last space containing this document

getSpaceReferences

public List<SpaceReference> getSpaceReferences()
Returns:
space references of this document in an ordered list

replaceParent

public DocumentReference replaceParent(EntityReference oldParent,
                                       EntityReference newParent)
Description copied from class: EntityReference
Return a clone of this reference, but with one of its parent replaced by another one.

Overrides:
replaceParent in class EntityReference
Parameters:
oldParent - the old parent that will be replaced
newParent - the new parent that will replace oldParent in the chain. If the same as oldParent, this is returned.
Returns:
a new reference with a amended parent chain


Copyright © 2004-2012 XWiki. All Rights Reserved.