org.ceryle.ui
Class MetadataUtils

java.lang.Object
  extended by org.ceryle.ui.MetadataUtils

public class MetadataUtils
extends Object

A class containing static methods used for processing and displaying document metadata. This class is designed to work particularly with the EditorPanel.

Version:
$Id: MetadataUtils.java,v 3.17 2007-06-20 04:40:28 altheim Exp $
Author:
Murray Altheim

Field Summary
static String CLASS_BIBREF
          The default class attribute value indicating the bibliographic reference field.
static String[] DCMI_NAMES
          An array of Strings containing the DCMI element type names in the order in which they will appear in auto-generated metadata renditions.
static boolean isDCMES11
          Determines which RDF (DCMES) markup is produced.
static String[] META_FORMATS
          An array of metadata format identifiers: XHTML, HTML, RDF, XML (DCDot), RSS 1.0, Atom Feed, and Atom Entry.
static boolean useSemicolonDelimiter
          When true, semicolons within metadata values force separation into separate fields.
 
Constructor Summary
MetadataUtils()
           
 
Method Summary
static void displayMetadata(EditorPanel editor, String cid, XNode xnode)
          Updates the editor display of XNode metadata, such as ID, creation and modification date, etc., provided with the Collection ID cid and the XNode.
 void generateAtomEntry()
          Generate an Atom <entry> from the available metadata.
 void generateAtomFeed()
          Generate an Atom <feed> from the available metadata.
static String generateMetadata(Map metadata, int format, String langcode)
          Generates metadata according to the format (HTML, XHTML, RDF or XML (DCDot)), with to the format and language popups.
 void generateRSS1()
          Generate RSS 1.0 from the available metadata.
static String[] getLanguageCodes()
          Returns a String array containing the natural language codes supported by the metadata utility.
static String[] getLanguageNames()
          Returns a String array containing the names of the natural languages supported by the metadata utility.
static Map getMetadata(EditorPanel editor)
          Returns a Map containing name-value pairs for various Dublin Core-based editor metadata.
static Map getMetadata(EditorPanel editor, boolean all)
          Returns a Map containing name-value pairs for various Dublin-Core based editor metadata.
static String parseBibRef(String creator, String date)
          Parses the supplied creator and date Strings to return a bibliographic reference String.
static String[] scanFormMetadata(Element elt)
          Scans the provided Element (which is expected to be an XHTML-based form), returning a three element String array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

isDCMES11

public static boolean isDCMES11
Determines which RDF (DCMES) markup is produced. When true (the default), the generateMetadata(Map,int,String) method will produce XML markup (when called upon to deliver "RDF") conformant with the non-standard DCMES 1.1 DTD, which allows for DC element refinement values. If false, the markup is DCMES 1.0 compliant, with the refinement values included as XML comments.


useSemicolonDelimiter

public static boolean useSemicolonDelimiter
When true, semicolons within metadata values force separation into separate fields. Since this is not a standard behaviour the default is false.


META_FORMATS

public static final String[] META_FORMATS
An array of metadata format identifiers: XHTML, HTML, RDF, XML (DCDot), RSS 1.0, Atom Feed, and Atom Entry.


CLASS_BIBREF

public static String CLASS_BIBREF
The default class attribute value indicating the bibliographic reference field. Default "CF.BibRef".


DCMI_NAMES

public static final String[] DCMI_NAMES
An array of Strings containing the DCMI element type names in the order in which they will appear in auto-generated metadata renditions.

Constructor Detail

MetadataUtils

public MetadataUtils()
Method Detail

displayMetadata

public static void displayMetadata(EditorPanel editor,
                                   String cid,
                                   XNode xnode)
                            throws ProcessException
Updates the editor display of XNode metadata, such as ID, creation and modification date, etc., provided with the Collection ID cid and the XNode. This is somewhat forgiving, in trying deprecated term names. This uses a UK Dublin Core refinement DC.identifier.version.

If xnode is null, will clear all node metadata fields. If cid is null, clears the Collection ID field.

Throws:
ProcessException

getMetadata

public static Map getMetadata(EditorPanel editor)
Returns a Map containing name-value pairs for various Dublin Core-based editor metadata. Calls getMetadata(EditorPanel,boolean) with a false value for all (the default).


getMetadata

public static Map getMetadata(EditorPanel editor,
                              boolean all)
Returns a Map containing name-value pairs for various Dublin-Core based editor metadata. The keys are Strings from the DCMI class, e.g., DCMI.DC_title. This includes:

Notes


getLanguageNames

public static String[] getLanguageNames()
Returns a String array containing the names of the natural languages supported by the metadata utility. The index to this array controls the format provided by getMetadata(EditorPanel,boolean). This array is lazily created from a property.


getLanguageCodes

public static String[] getLanguageCodes()
Returns a String array containing the natural language codes supported by the metadata utility. These are the ISO 639 language codes mirroring the array of language names supplied by getLanguageNames(). This array is lazily created from a property.


generateMetadata

public static String generateMetadata(Map metadata,
                                      int format,
                                      String langcode)
Generates metadata according to the format (HTML, XHTML, RDF or XML (DCDot)), with to the format and language popups. The format value is an index into the META_FORMATS array: {XHTML,HTML,RDF,XML}. If the format is RDF, the Map must contain a value for DC.Identifier, otherwise the rdf:about attribute will be an empty string. This method will silently produce such markup, but something RDF downwind will probably barf.


generateRSS1

public void generateRSS1()
Generate RSS 1.0 from the available metadata. (Unimplemented)


generateAtomFeed

public void generateAtomFeed()
Generate an Atom <feed> from the available metadata. (Unimplemented)


generateAtomEntry

public void generateAtomEntry()
Generate an Atom <entry> from the available metadata. (Unimplemented)


scanFormMetadata

public static String[] scanFormMetadata(Element elt)
Scans the provided Element (which is expected to be an XHTML-based form), returning a three element String array. The Element will be queried for <p> elements, which are then scanned for class attributes. The character data contents of the paragraph Element are used when a match occurs. The contents of the returned array are designated by the displayed class values for reference, title, creator (author), and date: { CF.BibRef, DC.Title, DC.Creator, DC.Date }, e.g., { "Mishima 1968", "Spring Snow", "Mishima, Yukio", "1968" }. Any missing metadata Strings are returned as nulls.

Subsequent instances of the queried attributes overwrite earlier ones, except in the case of DC.Creator (author), which creates a comma-separated list.

Note: this does not return the Dublin Core metadata from the document's <meta> content in <head>, it returns a scan of the contents of the XHTML form data.


parseBibRef

public static String parseBibRef(String creator,
                                 String date)
Parses the supplied creator and date Strings to return a bibliographic reference String. E.g., "Mishima, Yukio" and "September 1968" returns "Mishima 1968". If either the creator or date are provided as nulls or empty Strings, or parse as nulls or empty Strings, or the date cannot be parsed, null is returned.



The Ceryle Project. Copyright ©2001-2007 Murray Altheim, All Rights Reserved. See LICENSE included with distribution.