com.ibm.xdms.utils
Class URITemplate

java.lang.Object
  extended by com.ibm.xdms.utils.URITemplate

public class URITemplate
extends java.lang.Object

Class used to represent the URI Template as described in the OMA XDM Core specification. See example templates in Appendix D.1.


Field Summary
static char[] ALPHA_NUMERIC
           
static java.util.Random random
           
protected  java.util.regex.Pattern regexPattern
           
protected  java.lang.String regexUriTemplate
           
static java.lang.String TEMPLATE_ID
           
static java.lang.String TEMPLATE_USER
           
static java.lang.String TEMPLATE_XUI
           
protected  java.lang.String uriTemplate
           
 
Constructor Summary
URITemplate(java.lang.String uriTemplate)
          Creates an instance of the URI Template
 
Method Summary
static java.lang.String generateRandomID(int length)
          Generates an alpha numeric ID with a given length
 java.lang.String generateURI(int randomIDLength, XcapServerRequest xcapServerRequest)
          Generates a URI based on the URI template.
 java.lang.String generateURI(java.lang.String id, java.lang.String xui)
          Generates a URI based on the URI template.
 java.lang.String generateURI(java.lang.String id, java.lang.String user, java.lang.String xui)
          Generates a URI based on the URI template
 java.lang.String generateURI(java.lang.String id, XcapServerRequest xcapServerRequest)
          Generates a URI based on the URI template
 java.lang.String getURITemplateAsString()
          Returns the URI template as a String
protected  java.lang.String getUserPartFromURI(java.lang.String uri)
          Used to extract the user part of the URI
 boolean isValidURI(java.lang.String uri)
          Validates whether a URI matches the URI Template
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TEMPLATE_ID

public static final java.lang.String TEMPLATE_ID
See Also:
Constant Field Values

TEMPLATE_USER

public static final java.lang.String TEMPLATE_USER
See Also:
Constant Field Values

TEMPLATE_XUI

public static final java.lang.String TEMPLATE_XUI
See Also:
Constant Field Values

random

public static final java.util.Random random

ALPHA_NUMERIC

public static final char[] ALPHA_NUMERIC

uriTemplate

protected java.lang.String uriTemplate

regexUriTemplate

protected java.lang.String regexUriTemplate

regexPattern

protected java.util.regex.Pattern regexPattern
Constructor Detail

URITemplate

public URITemplate(java.lang.String uriTemplate)
Creates an instance of the URI Template

Parameters:
uriTemplate -
Method Detail

generateRandomID

public static java.lang.String generateRandomID(int length)
Generates an alpha numeric ID with a given length

Parameters:
length - The length of the ID
Returns:
Returns a random alpha numeric ID of some length

generateURI

public java.lang.String generateURI(java.lang.String id,
                                    java.lang.String user,
                                    java.lang.String xui)
Generates a URI based on the URI template

Parameters:
id - The portion of the URI template
user - The portion of the URI template
xui - The portion of the URI template
Returns:
Returns a URI that complies with the URI template

getUserPartFromURI

protected java.lang.String getUserPartFromURI(java.lang.String uri)
Used to extract the user part of the URI

Parameters:
uri -
Returns:

generateURI

public java.lang.String generateURI(java.lang.String id,
                                    java.lang.String xui)
Generates a URI based on the URI template. Will extract the from the XUI.

Parameters:
id - The portion of the URI template
xui - The portion of the URI template
Returns:
Returns a URI that complies with the URI template

generateURI

public java.lang.String generateURI(java.lang.String id,
                                    XcapServerRequest xcapServerRequest)
Generates a URI based on the URI template

Parameters:
id - The portion of the URI template
xcapServerRequest - The XcapServerRequest to find the and portion of the URI template
Returns:
Returns a URI that complies with the URI template

generateURI

public java.lang.String generateURI(int randomIDLength,
                                    XcapServerRequest xcapServerRequest)
Generates a URI based on the URI template. The id is random.

Parameters:
randomIDLength - The length of the random ID
xcapServerRequest - The XcapServerRequest to find the and portion of the URI template
Returns:
Returns a URI that complies with the URI template

isValidURI

public boolean isValidURI(java.lang.String uri)
Validates whether a URI matches the URI Template

Parameters:
uri - The URI to compare against
Returns:
Returns true if valid otherwise false.

getURITemplateAsString

public java.lang.String getURITemplateAsString()
Returns the URI template as a String

Returns:
Returns the URI template as a String