fedora.common
Class PID

java.lang.Object
  extended by fedora.common.PID

public class PID
extends java.lang.Object

A persistent identifier for Fedora digital objects.

The following describes the syntactic constraints for PIDs in normalized form. The only differences with non-normalized PIDs are that the colon delimiter may be encoded as "%3a" or "%3A", and hex-digits may use lowercase [a-f].

 PID:
   Length : maximum 64
   Syntax : namespace-id ":" object-id

 namespace-id:
   Syntax : ( [A-Z] / [a-z] / [0-9] / "-" / "." ) 1+

 object-id:
   Syntax : ( [A-Z] / [a-z] / [0-9] / "-" / "." / "~" / "_" / escaped-octet ) 1+

 escaped-octet:
   Syntax : "%" hex-digit hex-digit

 hex-digit:
   Syntax : [0-9] / [A-F]
 

Version:
$Id: PID.java 4263 2005-07-20 15:51:38Z eddie $
Author:
cwilper@cs.cornell.edu

Field Summary
static int MAX_LENGTH
          The maximum length of a PID is 64.
static java.lang.String NS_HANDLE
          The reserved handle namespace id
 
Constructor Summary
PID(java.lang.String pidString)
          Construct a PID from a string, throwing a MalformedPIDException if it's not well-formed.
 
Method Summary
static PID fromFilename(java.lang.String filenameString)
          Construct a PID given a filename of the form produced by toFilename(), throwing a MalformedPIDException if it's not well-formed.
static PID getInstance(java.lang.String pidString)
          Alternate constructor that throws an unchecked exception if it's not well-formed.
 java.lang.String getNamespaceId()
           
 java.lang.String getObjectId()
           
static void main(java.lang.String[] args)
          Command-line interactive tester.
static java.lang.String normalize(java.lang.String pidString)
          Return the normalized form of the given pid string, or throw a MalformedPIDException.
 java.lang.String toFilename()
          Return a string representing this PID that can be safely used as a filename on any OS.
 java.lang.String toString()
          Return the normalized form of this PID.
 java.lang.String toURI()
          Return the URI form of this PID.
static java.lang.String toURI(java.lang.String pidString)
          Return the URI form of some PID string, assuming it is well-formed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_LENGTH

public static final int MAX_LENGTH
The maximum length of a PID is 64.

See Also:
Constant Field Values

NS_HANDLE

public static final java.lang.String NS_HANDLE
The reserved handle namespace id

See Also:
Constant Field Values
Constructor Detail

PID

public PID(java.lang.String pidString)
    throws MalformedPIDException
Construct a PID from a string, throwing a MalformedPIDException if it's not well-formed.

Throws:
MalformedPIDException
Method Detail

getInstance

public static PID getInstance(java.lang.String pidString)
Alternate constructor that throws an unchecked exception if it's not well-formed.


fromFilename

public static PID fromFilename(java.lang.String filenameString)
                        throws MalformedPIDException
Construct a PID given a filename of the form produced by toFilename(), throwing a MalformedPIDException if it's not well-formed.

Throws:
MalformedPIDException

normalize

public static java.lang.String normalize(java.lang.String pidString)
                                  throws MalformedPIDException
Return the normalized form of the given pid string, or throw a MalformedPIDException.

Throws:
MalformedPIDException

toString

public java.lang.String toString()
Return the normalized form of this PID.

Overrides:
toString in class java.lang.Object

toURI

public java.lang.String toURI()
Return the URI form of this PID. This is just the PID, prepended with "info:fedora/".


toURI

public static java.lang.String toURI(java.lang.String pidString)
Return the URI form of some PID string, assuming it is well-formed.


toFilename

public java.lang.String toFilename()
Return a string representing this PID that can be safely used as a filename on any OS.


getNamespaceId

public java.lang.String getNamespaceId()

getObjectId

public java.lang.String getObjectId()

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Command-line interactive tester. If one arg given, prints normalized form of that PID and exits. If no args, enters interactive mode.

Throws:
java.lang.Exception