com.sapportals.wcm.util.uri

Class RID

java.lang.Object
  extended by com.sapportals.wcm.util.uri.RID
All Implemented Interfaces:
Serializable, Comparable

public final class RID
extends Object
implements Comparable, Serializable

A RID is an identifier for a CM resource. It holds all information to identify a CM resource and retrieve it via the CM Framework. Each CM resource has its unique RID. The first pathsegment must be a valid name of a repository (prefix).

A RID has a path-like structure, like a path in a file system and follows the following production:

   RID         ::= '/' pathsegment | '/' pathsegment '?' query
   pathsegment ::= name | name '/' pathsegment | empty
   name        ::= any char except '/'
   query       ::= parameter | parameter '&' query | empty
   parameter   ::= varname | varname '=' value
   varname     ::= any char except '=', '&'
   value       ::= any character except '&'
 
Equality is defined as ignoring trailing '/' characters. Thus, the RIDs "/docs/" and /docs" are considered equal. There is special handling for the root collection "/", which is not equal to the empty RID "".

Copyright (c) SAP AG 2001-2005

See Also:
Serialized Form

Field Summary
static char PATH_SEPARATOR
           
 
Constructor Summary
RID(String uri)
          Deprecated. as of NW04. Use RID.getRID(uri)
RID(String path, String query)
          Deprecated. as of NW04. Use RID.getRID(path, query)
 
Method Summary
 RID add(RID uri)
          Concatenate this RID with the given RID.
 RID add(String uri)
          Concatenate this RID with the given RID.
 RID addPathSegment(String segment)
          Adds a path segment.
 RID addQueryParameter(Properties parameter)
          Deprecated. as of NW04. Use setQueryParameter
 int compareTo(Object o)
           
 RID decode()
          Deprecated. as of NW04. RID objects are never decoded
 RID encode()
          Deprecated. as of NW04. RID objects are never encoded
 boolean endsWithSlash()
          Return if this RID ends with a slash.
 boolean equals(Object other)
          Determine if this RID equals other.
 boolean equals(RID other)
          Determine if this RID equals other.
 boolean equals(String other)
          Determine if this RID equals other.
 String extension()
          Get the extension part of the resource name.
 String getFirstSegment()
          Gets the first (top level) segment of the path.
 String getHashId()
          Returns the hash ID of this RID.
 String getPath()
          Return the path component of this RID.
 String getQuery()
          Return the query component of this RID (null if it does not exist).
 Properties getQueryParameter()
          Get the query parameters of the RID.
static RID getRID(String uri)
           
static RID getRID(String path, String query)
           
 int hashCode()
           
 boolean isAbsolute()
          Return if RID is absolute, e.g. start with a slash.
 boolean isAncestorOf(RID child)
          Determine if this RID is an ancestor (parent or parent's parent, etc.) of the given child RID.
 boolean isAncestorOfOrSelf(RID child)
          Determine if this RID is an ancestor (parent or parent's parent, etc.) of the given child RID or the same.
 boolean isRoot()
          Return if RID is root collection.
 int length()
          Return length of RID in string representation
 RID name()
          Get the name of the resource, designated by this RID.
 RID parent()
          Get the RID of the parent collection of this RID
 RID removeExtension()
          Remove the (optional) extension of the resource name.
 RID removeName()
          Remove the name of the resource, same as parent()
 RID removeRoot()
          Get a new RID with the toplevel collection removed
 RID removeTrailingSlash()
          Remove a possible trailing slash from the RID.
 RID resolveRelativeRID(String uri)
          Resolve relative RIDs
 RID root()
          Get RID of toplevel collection (below root) of this RID.
 RID setQueryParameter(Properties parameter)
          Create a new RID by setting the given parameters as query part of this RID.
 List split()
          Splits the RID into its path components
 String toExternalForm()
           
 String toString()
          Returns string representation of this RID
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

PATH_SEPARATOR

public static final char PATH_SEPARATOR
See Also:
Constant Field Values
Constructor Detail

RID

public RID(String path,
           String query)
Deprecated. as of NW04. Use RID.getRID(path, query)

Create a new RID with given path and query string

Parameters:
path - of RID
query - part or RID (can be null)

RID

public RID(String uri)
Deprecated. as of NW04. Use RID.getRID(uri)

Create a new RID from a string (possibly including a query part).

Method Detail

getRID

public static RID getRID(String path,
                         String query)

getRID

public static RID getRID(String uri)

getHashId

public String getHashId()
Returns the hash ID of this RID.

Returns:
a String representing the hash ID

encode

public RID encode()
Deprecated. as of NW04. RID objects are never encoded


decode

public RID decode()
Deprecated. as of NW04. RID objects are never decoded


toExternalForm

public String toExternalForm()

getPath

public String getPath()
Return the path component of this RID.

Returns:
the path component

getQuery

public String getQuery()
Return the query component of this RID (null if it does not exist).

Returns:
the query component

getQueryParameter

public Properties getQueryParameter()
Get the query parameters of the RID. Will return an empty Properties object if RID has no query part. Modifying the Properties object has no effect on the RID itself.

Returns:
query parameters as Properties

root

public RID root()
Get RID of toplevel collection (below root) of this RID.

The root RID of a toplevel collection is the root collection RID. The root RID of the root RID is the root RID itself.

Returns:
RID of toplevel collection below root

name

public RID name()
Get the name of the resource, designated by this RID. If the RID has query parameter, these are discarded.

Returns:
the name of the resource, designated by this RID

parent

public RID parent()
Get the RID of the parent collection of this RID

Returns:
the RID of the parent collection

extension

public String extension()
Get the extension part of the resource name. Returns the empty string if there is no extension.

Returns:
the extension part of the resource name

removeRoot

public RID removeRoot()
Get a new RID with the toplevel collection removed

Returns:
RID with toplevel collection removed

removeName

public RID removeName()
Remove the name of the resource, same as parent()

Returns:
parent of the resource

removeExtension

public RID removeExtension()
Remove the (optional) extension of the resource name. Query parameters are discarded.

Returns:
uri with extension of name removed

removeTrailingSlash

public RID removeTrailingSlash()
Remove a possible trailing slash from the RID. Query parameters are preserved.

Returns:
RID without trailing slash

isAbsolute

public boolean isAbsolute()
Return if RID is absolute, e.g. start with a slash.

Returns:
if RID is absolute path

isRoot

public boolean isRoot()
Return if RID is root collection.

Returns:
if this is the root collection

isAncestorOf

public boolean isAncestorOf(RID child)
Determine if this RID is an ancestor (parent or parent's parent, etc.) of the given child RID.

Parameters:
child - to test against
Returns:
if this RID is ancestor of child

isAncestorOfOrSelf

public boolean isAncestorOfOrSelf(RID child)
Determine if this RID is an ancestor (parent or parent's parent, etc.) of the given child RID or the same.

Parameters:
child - to test against
Returns:
if this RID is ancestor of child

endsWithSlash

public boolean endsWithSlash()
Return if this RID ends with a slash.

Returns:
if this RID ends with a slash

add

public RID add(String uri)
Concatenate this RID with the given RID. Treats this RID as if it ends with a slash and the parameter RID as if it starts without a slash.

Note: do not use this method to add path segments, as the parameter is parsed as legal RID, not as a legal RID segment; use addPathSegment(String) instead.

Parameters:
uri - to append to this
Returns:
new RID as concatenation

add

public RID add(RID uri)
Concatenate this RID with the given RID. Treats this RID as if it ends with a slash and the parameter RID as if it starts without a slash.

Parameters:
uri - to append to this
Returns:
new RID as concatenation

split

public List split()
Splits the RID into its path components

Returns:
List of Strings

toString

public String toString()
Returns string representation of this RID

Overrides:
toString in class Object
Returns:
this RID as string

equals

public boolean equals(RID other)
Determine if this RID equals other.

Parameters:
other - RID
Returns:
if this RID equals other

equals

public boolean equals(String other)
Determine if this RID equals other.

Parameters:
other - RID (string representation)
Returns:
if this RID equals other

equals

public boolean equals(Object other)
Determine if this RID equals other. Equality is defined for instances of RID only.

Overrides:
equals in class Object
Parameters:
other -
Returns:
if this RID equals other

hashCode

public int hashCode()
Overrides:
hashCode in class Object

length

public int length()
Return length of RID in string representation

Returns:
length of RID in string representation

resolveRelativeRID

public RID resolveRelativeRID(String uri)
Resolve relative RIDs

Parameters:
uri - An RID, which may be relative or absolute

addPathSegment

public RID addPathSegment(String segment)
                   throws WcmException
Adds a path segment.

Parameters:
segment - String containing the new path segment
Returns:
new RID
Throws:
WcmException - if segment contains characters that aren't allowed in path segments

addQueryParameter

public RID addQueryParameter(Properties parameter)
Deprecated. as of NW04. Use setQueryParameter

Create a new RID by setting the given parameters as query part of this RID.

Parameters:
parameter - to set to query
Returns:
new RID with parameter in query

setQueryParameter

public RID setQueryParameter(Properties parameter)
Create a new RID by setting the given parameters as query part of this RID.

Parameters:
parameter - to set to query
Returns:
new RID with parameter in query

getFirstSegment

public String getFirstSegment()
Gets the first (top level) segment of the path. Works like this:
"/a/b/c" becomes "a"
"a/b/c" becomes "a"
"a" becomes "a"
"a?b=c" becomes "a"
Edge cases are:
"" becomes ""
"/" becomes ""

Returns:
first segment of path

compareTo

public int compareTo(Object o)
Specified by:
compareTo in interface Comparable
Access Rights

This class can be accessed from:


SC DC Public Part ACH
[sap.com] KMC-CM [sap.com] tc/km/frwk api EP-KM-CM
[sap.com] KMC-WPC [sap.com] tc/kmc/wpc/wpcfacade api EP-PIN-WPC-WCM


Copyright 2014 SAP AG Complete Copyright Notice