fedora.common
Class PID

java.lang.Object
  extended byfedora.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]
 
-----------------------------------------------------------------------------

License and Copyright: The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/.

Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License.

The entire file consists of original code. Copyright © 2002-2005 by The Rector and Visitors of the University of Virginia and Cornell University. All rights reserved.

-----------------------------------------------------------------------------

Version:
$Id: PID.java,v 1.10 2005/01/11 20:06:05 cwilper Exp $
Author:
cwilper@cs.cornell.edu

Field Summary
static int MAX_LENGTH
          The maximum length of a PID is 64.
 
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.
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
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.

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.


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.


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