org.jafer.osid
Class ModsUtils

java.lang.Object
  extended by org.jafer.osid.ModsUtils

public class ModsUtils
extends java.lang.Object

Extracts a set of fields from a DOM document in MODS 3.0 format and returns them in a Map for display purposes. We should load this class in a factory so it can be customised for different implementations (later if required)


Constructor Summary
ModsUtils()
           
 
Method Summary
static org.w3c.dom.Node addAnnotation(org.w3c.dom.Node docroot, java.lang.String annotation)
           
static org.w3c.dom.Node addModCollection(org.w3c.dom.Document doc)
          Creates a mods collection element in the document
private  void dumpNodeList(org.w3c.dom.NodeList list)
           
static java.lang.String getField(java.util.Map fields, java.lang.String fieldName)
           
static java.util.Map getFields(org.w3c.dom.Element modsroot)
          Extract Mods 3.0 Reource fields from DOM object and return as a Map
private static java.lang.String getOwner(org.w3c.dom.Element modsroot)
          Retrieves the owner's displayForm or namePart if exists.
static java.util.List getRelatedDocIds(org.w3c.dom.Element mdcroot)
          Retrieves RL's constituent docId's as relatedItems.
static java.lang.String stripLastChar(java.lang.String str)
           
static java.lang.String toModsRecordXml(java.util.Map fields, java.lang.String docId, java.lang.String origin, java.lang.String mdctype, java.util.List refDocIds)
          Generates a mods record.
static void updateAnnotation(org.w3c.dom.Element modsElement, java.lang.String annotation)
          Updates the mods records first annotation with supplied text or creates one if none found
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModsUtils

public ModsUtils()
Method Detail

getFields

public static java.util.Map getFields(org.w3c.dom.Element modsroot)
Extract Mods 3.0 Reource fields from DOM object and return as a Map


stripLastChar

public static java.lang.String stripLastChar(java.lang.String str)

addModCollection

public static org.w3c.dom.Node addModCollection(org.w3c.dom.Document doc)
Creates a mods collection element in the document

Parameters:
doc -
Returns:
the created mods collection

updateAnnotation

public static void updateAnnotation(org.w3c.dom.Element modsElement,
                                    java.lang.String annotation)
Updates the mods records first annotation with supplied text or creates one if none found

Parameters:
modsElement - the mods element to update
annotation - The new annotation text to set

addAnnotation

public static org.w3c.dom.Node addAnnotation(org.w3c.dom.Node docroot,
                                             java.lang.String annotation)

toModsRecordXml

public static java.lang.String toModsRecordXml(java.util.Map fields,
                                               java.lang.String docId,
                                               java.lang.String origin,
                                               java.lang.String mdctype,
                                               java.util.List refDocIds)
Generates a mods record.

Parameters:
fields - - fields to generate
docId - - the docId representing this mods document's db identifier
origin - - value identifying the mods record source (i.e. which collection it comes from)
mdctype - - enumerated mdc type signifying mdc record type (header or list item)
refDocIds - - a list of consituent docid's if this mods record is a RL header (may be null if not)

dumpNodeList

private void dumpNodeList(org.w3c.dom.NodeList list)

getOwner

private static java.lang.String getOwner(org.w3c.dom.Element modsroot)
Retrieves the owner's displayForm or namePart if exists.


getRelatedDocIds

public static java.util.List getRelatedDocIds(org.w3c.dom.Element mdcroot)
Retrieves RL's constituent docId's as relatedItems.


getField

public static java.lang.String getField(java.util.Map fields,
                                        java.lang.String fieldName)