Version: 3.5.0

org.generationcp.core
Class LSIDUtils

java.lang.Object
  extended by org.generationcp.core.LSIDUtils

public abstract class LSIDUtils
extends java.lang.Object

A utility class helping with LSIDs.

Version:
$Id: LSIDUtils.java 15872 2009-04-18 19:14:50Z msenger $
Author:
Martin Senger

Constructor Summary
LSIDUtils()
           
 
Method Summary
static java.lang.String createLSID(java.lang.String authority, java.lang.String namespace, java.lang.String objectId, java.lang.String version)
          Creates a well formed LSID from the given parts.
static java.lang.String extractNamespace(java.lang.String lsid)
          Extract and return the "Namespace" part of the given LSID.
static java.lang.String extractObjectId(java.lang.String lsid)
          Extract and return the "Object ID" part of the given LSID.
static java.lang.String removeVersion(java.lang.String lsid)
          Remove the version ("release") form the given 'lsid'.
static java.lang.String resolveAuthority(java.lang.String lsid)
          Extract and return the Authority part of the given LSID.
static java.lang.String resolveNamespace(java.lang.String lsid)
          Extract and return the Namespace part of the given LSID.
static java.lang.String resolveObjectId(java.lang.String lsid)
          Extract and return the Object ID part of the given LSID.
static java.lang.String resolveVersion(java.lang.String lsid)
          Extract and return the Version part of the given LSID.
static java.lang.String[] splitLSID(java.lang.String lsid)
          Split the LSID into component parts.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LSIDUtils

public LSIDUtils()
Method Detail

extractObjectId

public static java.lang.String extractObjectId(java.lang.String lsid)
Extract and return the "Object ID" part of the given LSID. I know that LSIDs are supposed to be opaque but GCP Domain model use cases think otherwise :-)

Parameters:
lsid - to be extracted from
Returns:
an object ID. If the 'lsid' does not follow the LSID structure, it returns the whole 'lsid'.

extractNamespace

public static java.lang.String extractNamespace(java.lang.String lsid)
Extract and return the "Namespace" part of the given LSID.

Parameters:
lsid - to be extracted from
Returns:
a namespace. If the 'lsid' does not follow the LSID structure, it returns the whole 'lsid'.

removeVersion

public static java.lang.String removeVersion(java.lang.String lsid)
Remove the version ("release") form the given 'lsid'.

Parameters:
lsid - to be manipulated
Returns:
the original 'lsid' without its version; if the 'lsid' does not have any version part, it is returned as given

splitLSID

public static java.lang.String[] splitLSID(java.lang.String lsid)
                                    throws java.lang.IllegalArgumentException
Split the LSID into component parts.

Parameters:
lsid - to be split
Returns:
an array [Authority, Namespace, Object Indentifer] with an optional forth element [Version], retrived from the 'lsid'; if the 'lsid is null, it returns null
Throws:
java.lang.IllegalArgumentException - if the 'lsid' has less than three (mandatory) components

resolveAuthority

public static java.lang.String resolveAuthority(java.lang.String lsid)
                                         throws java.lang.IllegalArgumentException
Extract and return the Authority part of the given LSID.

Parameters:
lsid - to be extracted from
Returns:
an authority
Throws:
java.lang.IllegalArgumentException - if the 'lsid' does not have valid LSID structure

resolveNamespace

public static java.lang.String resolveNamespace(java.lang.String lsid)
                                         throws java.lang.IllegalArgumentException
Extract and return the Namespace part of the given LSID. It differs from the extractNamespace(java.lang.String) by throwing an exception if the input is not a valid LSID.

Parameters:
lsid - to be extracted from
Returns:
a namespace
Throws:
java.lang.IllegalArgumentException - if the 'lsid' does not have valid LSID structure

resolveObjectId

public static java.lang.String resolveObjectId(java.lang.String lsid)
                                        throws java.lang.IllegalArgumentException
Extract and return the Object ID part of the given LSID. It differs from the extractObjectId(java.lang.String) by throwing an exception if the input is not a valid LSID.

Parameters:
lsid - to be extracted from
Returns:
an object ID
Throws:
java.lang.IllegalArgumentException - if the 'lsid' does not have valid LSID structure

resolveVersion

public static java.lang.String resolveVersion(java.lang.String lsid)
                                       throws java.lang.IllegalArgumentException
Extract and return the Version part of the given LSID.

Parameters:
lsid - to be extracted from
Returns:
a version; or null if the 'lsid' does not have any version
Throws:
java.lang.IllegalArgumentException - if the 'lsid' does not have valid LSID structure

createLSID

public static java.lang.String createLSID(java.lang.String authority,
                                          java.lang.String namespace,
                                          java.lang.String objectId,
                                          java.lang.String version)
                                   throws java.lang.IllegalArgumentException
Creates a well formed LSID from the given parts.

Parameters:
authority - describes the (database) authority
namespace - is a namespace within given authority
objectId - is the unique identifier of the object in the given namespace of the given authority
version - is optional; if it is null or an empty string, it is ignored
Returns:
well formed LSID
Throws:
java.lang.IllegalArgumentException - if any of authority, namespace or objectId is null or empty

Version: 3.5.0

Submit a bug or feature
Generated: Fri Jul 23 18:24:48 CDT 2010