org.greenstone.fedora.services
Class FedoraCommons

java.lang.Object
  extended by org.greenstone.fedora.services.FedoraCommons

public class FedoraCommons
extends java.lang.Object

Methods common to both Fedora(GS3)Connection and GSearchConnection. Made static here so they can be reused by these classes.

Author:
ak19

Constructor Summary
FedoraCommons()
           
 
Method Summary
static java.lang.String elementToFormattedString(org.w3c.dom.Element e)
          Given an Element, this will return its String representation properly indented for display.
static java.lang.String elementToString(org.w3c.dom.Element e)
          Given an Element, this will return its String representation without indenting it for display.
static org.w3c.dom.Element getResponseAsDOM(javax.xml.parsers.DocumentBuilder builder, java.lang.String XML)
          Turns the XML String into a DOM tree and returns it.
static java.lang.String getValue(org.w3c.dom.Element e)
          Extract the text from an element, if any.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FedoraCommons

public FedoraCommons()
Method Detail

getValue

public static java.lang.String getValue(org.w3c.dom.Element e)
Extract the text from an element, if any.

Parameters:
e - is the element whose value is to be extracted.
Returns:
the text that's nested in an element's body or "" if there's none.

getResponseAsDOM

public static org.w3c.dom.Element getResponseAsDOM(javax.xml.parsers.DocumentBuilder builder,
                                                   java.lang.String XML)
                                            throws org.xml.sax.SAXException,
                                                   java.io.IOException
Turns the XML String into a DOM tree and returns it.

Parameters:
XML - the string to be converted into a DOM tree
builder - is the DocumentBuilder to use to parse the string XML
Returns:
the root element of the document by parsing the string XML
Throws:
org.xml.sax.SAXException
java.io.IOException

elementToString

public static java.lang.String elementToString(org.w3c.dom.Element e)
                                        throws javax.xml.transform.TransformerException
Given an Element, this will return its String representation without indenting it for display.

Parameters:
e - is the element to be converted to its string representation.
Returns:
a string representation of e without formatting it for display.
Throws:
javax.xml.transform.TransformerException

elementToFormattedString

public static java.lang.String elementToFormattedString(org.w3c.dom.Element e)
                                                 throws javax.xml.transform.TransformerException
Given an Element, this will return its String representation properly indented for display.

Parameters:
e - is the element to be converted to its string representation.
Returns:
a string representation of e, formatted for display.
Throws:
javax.xml.transform.TransformerException