public class EntityReference extends Object implements Cloneable, Serializable
EntityProvider
responsible for handling the Entity. It optionally provides the entity id which
uniquely identifies an entity locally within the prefix space.
It also provides for all parsing methods for
entity references (always of the form /prefix or /prefix/id)| Modifier and Type | Field and Description |
|---|---|
protected String |
originalReference |
static char |
PERIOD |
String |
prefix
An entity prefix, should match with the prefix handled in an
EntityProvider,
uniquely identifies an entity space or entity typeWARNING: use the getPrefix() method rather than referring to this directly |
static char |
SEPARATOR |
static long |
serialVersionUID |
| Constructor and Description |
|---|
EntityReference() |
EntityReference(String reference)
Constructor which takes an entity reference,
this is the most common way to construct an entity reference object
|
EntityReference(String prefix,
String id)
Convenience constructor for when you know the prefix and/or id
|
| Modifier and Type | Method and Description |
|---|---|
protected static void |
checkPrefixId(String prefix,
String id)
Checks this prefix and id to see if they are valid format, throw exceptions if they aren't
|
protected static void |
checkReference(String reference)
Check if a reference is basically valid
|
protected Object |
clone() |
EntityReference |
copy() |
static EntityReference |
copy(EntityReference ref)
Creates a copy of an entity reference
|
protected static String |
findId(String reference)
Get the local entity id based on a full entity reference
|
protected static String |
findPrefix(String reference)
Get the entity prefix based on an entity reference
|
String |
getId()
A local entity id, represents an entity uniquely in a tool/webapp,
could match with the actual id of a model data object,
this will be null if this reference refers to an entity space only
|
static String |
getIdFromRef(String reference)
Will convert a reference into an id (even if it is not a reference)
|
static String |
getIdFromRefByKey(String reference,
String key)
Get the id value out of a reference by the key that preceeds it
|
String |
getOriginalReference()
This is a special method and should not normally be used,
use
toString() or getReference() |
String |
getPrefix() |
static String |
getPrefix(String reference)
Get the entity prefix based on an entity reference string,
WARNING: this is meant for internal use,
use
EntityReference(String) and
the methods in EntityBroker to parse references |
String |
getReference()
Get the string reference for this entity reference object,
same as calling
toString() |
protected static int |
getSeparatorPos(String reference,
int number) |
String |
getSpaceReference()
Get the space reference for this entity reference,
this ignored any id and only returns the reference to the entity space
|
boolean |
isEmpty() |
protected String |
makeEntityId()
Override this if you are making a new class to define your entity reference,
called by public
getId() method |
protected String |
makeEntityPrefix()
Override this if you are making a new class to define your entity reference,
called by public
getPrefix() method |
protected String |
makeEntityReference(boolean spaceOnly)
Override this if you are making a new class to define your entity reference
|
protected void |
setOriginalReference(String reference) |
String |
toString() |
public static final long serialVersionUID
public static final transient char SEPARATOR
public static final transient char PERIOD
protected transient String originalReference
public String prefix
EntityProvider,
uniquely identifies an entity space or entity typegetPrefix() method rather than referring to this directlypublic EntityReference()
public EntityReference(String reference)
reference - a globally unique reference to an entity,
consists of the entity prefix and optional path segmentspublic String getOriginalReference()
toString() or getReference()protected void setOriginalReference(String reference)
public String getPrefix()
public String getId()
public boolean isEmpty()
protected String makeEntityReference(boolean spaceOnly)
spaceOnly - if this is true then only return the entity space reference (e.g. /prefix),
otherwise return the full reference (e.g. /prefix/id)protected String makeEntityPrefix()
getPrefix() methodprotected String makeEntityId()
getId() methodpublic String getReference()
toString()public String getSpaceReference()
public String toString()
protected Object clone() throws CloneNotSupportedException
clone in class ObjectCloneNotSupportedExceptionpublic EntityReference copy()
copy(EntityReference)public static String getPrefix(String reference)
EntityReference(String) and
the methods in EntityBroker to parse referencesreference - an entity reference or entity URLpublic static String getIdFromRef(String reference)
reference - an entity reference (e.g. /user/aaronz)public static String getIdFromRefByKey(String reference, String key)
reference - an entity reference (e.g. /site/siteId/group/groupId)key - the key to get the id from (e.g. 'group' yields groupId)protected static String findPrefix(String reference)
reference - a globally unique reference to an entity,
consists of the entity prefix and optional idprotected static String findId(String reference)
reference - a globally unique reference to an entity,
consists of the entity prefix and optional idprotected static int getSeparatorPos(String reference, int number)
reference - a globally unique reference to an entity,
consists of the entity prefix and optional idnumber - this is the separator to get,
0 would return the first one found, 1 would return the secondprotected static void checkReference(String reference)
reference - IllegalArgumentException - if the reference is not even basically validprotected static void checkPrefixId(String prefix, String id)
public static EntityReference copy(EntityReference ref)
ref - an entity reference objectIllegalArgumentException - if the ref is invalid OR nullCopyright © 2003–2022 Sakai Project. All rights reserved.