org.openliberty.xmltooling
Class OpenLibertyHelpers

java.lang.Object
  extended by org.openliberty.xmltooling.OpenLibertyHelpers

public class OpenLibertyHelpers
extends java.lang.Object


Field Summary
private static java.lang.String defaultDateFormat
           
private static org.joda.time.format.DateTimeFormatter defaultDateFormatter
           
static java.lang.String FALSE_STR
           
private static org.apache.log4j.Logger log
           
protected static org.opensaml.xml.io.MarshallerFactory marshallerFactory
          XMLObject marshaller factory.
static java.lang.String TRUE_STR
           
protected static org.opensaml.xml.io.UnmarshallerFactory unmarshallerFactory
          XMLObject marshaller factory.
 
Constructor Summary
OpenLibertyHelpers()
           
 
Method Summary
static java.lang.Boolean booleanFromString(java.lang.String booleanString)
          Safely create a Boolean from a String
static org.opensaml.xml.XMLObject cloneXMLObject(org.opensaml.xml.XMLObject xmlObject)
          Clone an XMLObject
static org.joda.time.DateTime dateTimeForString(java.lang.String dateTimeString)
          Attempt to convert a String into a DateTime object
static org.joda.time.format.DateTimeFormatter getDefaultDateFormatter()
          Returns a joda DateTimeFormatter for parsing and printing a DateTime
static java.lang.Integer integerFromString(java.lang.String integerString)
          Safely create an Integer from a String
static org.joda.time.DateTime prepareForAssignment(org.joda.time.DateTime oldValue, org.joda.time.DateTime newValue, org.joda.time.format.DateTimeFormatter formatter, org.opensaml.xml.AbstractXMLObject abstractXMLObject)
          Compares DateTime objects looking for change, using the specified DateTimeFormatter.
static java.lang.Integer prepareForAssignment(java.lang.Integer oldValue, java.lang.Integer newValue, org.opensaml.xml.AbstractXMLObject abstractXMLObject)
          Compares Integer values, releasing the DOM when oldValue and newValue are not equivalent
static java.lang.String prepareForAssignment(java.lang.String oldStringValue, java.lang.String newStringValue, org.opensaml.xml.AbstractXMLObject abstractXMLObject)
          Use this utility method to reset the DOM if required based on a change to the objects (element value or attribute value)
static
<T> T
prepareForAssignment(T oldValue, T newValue, org.opensaml.xml.AbstractXMLObject abstractXMLObject)
          Compares two objects.
static java.lang.String prettyPrintXMLObject(org.opensaml.xml.XMLObject xmlObject)
          Takes an XMLObject as a parameter, marshalls it, and returns a pretty printed version of the generated XML.
static java.lang.String stringForDateTime(org.joda.time.DateTime dateTime)
          Attempt to convert a DateTime object into a String
static java.lang.String stringFromBoolean(java.lang.Boolean b, java.lang.String defaultString)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static org.apache.log4j.Logger log

FALSE_STR

public static java.lang.String FALSE_STR

TRUE_STR

public static java.lang.String TRUE_STR

defaultDateFormat

private static java.lang.String defaultDateFormat

defaultDateFormatter

private static org.joda.time.format.DateTimeFormatter defaultDateFormatter

marshallerFactory

protected static org.opensaml.xml.io.MarshallerFactory marshallerFactory
XMLObject marshaller factory.


unmarshallerFactory

protected static org.opensaml.xml.io.UnmarshallerFactory unmarshallerFactory
XMLObject marshaller factory.

Constructor Detail

OpenLibertyHelpers

public OpenLibertyHelpers()
Method Detail

stringForDateTime

public static java.lang.String stringForDateTime(org.joda.time.DateTime dateTime)
Attempt to convert a DateTime object into a String

Parameters:
dateTime -
Returns:

dateTimeForString

public static org.joda.time.DateTime dateTimeForString(java.lang.String dateTimeString)
Attempt to convert a String into a DateTime object

Parameters:
dateTimeString -
Returns:

integerFromString

public static java.lang.Integer integerFromString(java.lang.String integerString)
Safely create an Integer from a String

Parameters:
integerString -
Returns:

booleanFromString

public static java.lang.Boolean booleanFromString(java.lang.String booleanString)
Safely create a Boolean from a String

Parameters:
booleanString -
Returns:

stringFromBoolean

public static java.lang.String stringFromBoolean(java.lang.Boolean b,
                                                 java.lang.String defaultString)

prepareForAssignment

public static java.lang.String prepareForAssignment(java.lang.String oldStringValue,
                                                    java.lang.String newStringValue,
                                                    org.opensaml.xml.AbstractXMLObject abstractXMLObject)
Use this utility method to reset the DOM if required based on a change to the objects (element value or attribute value)

Parameters:
oldValue -
newValue -
abstractXMLObject -
Returns:

prepareForAssignment

public static <T> T prepareForAssignment(T oldValue,
                                         T newValue,
                                         org.opensaml.xml.AbstractXMLObject abstractXMLObject)
Compares two objects. Use this utility method for comparing enums or other objects

Parameters:
oldValue -
newValue -
abstractXMLObject -
Returns:

prepareForAssignment

public static org.joda.time.DateTime prepareForAssignment(org.joda.time.DateTime oldValue,
                                                          org.joda.time.DateTime newValue,
                                                          org.joda.time.format.DateTimeFormatter formatter,
                                                          org.opensaml.xml.AbstractXMLObject abstractXMLObject)
Compares DateTime objects looking for change, using the specified DateTimeFormatter. If no DateTimeFormatter is specified, the test is done on the DateTime objects themselves.

Parameters:
oldValue -
newValue -
formatter - optional, used to compare the eventual xml output based on formatting
abstractXMLObject - required and must be Non null
Returns:

prepareForAssignment

public static java.lang.Integer prepareForAssignment(java.lang.Integer oldValue,
                                                     java.lang.Integer newValue,
                                                     org.opensaml.xml.AbstractXMLObject abstractXMLObject)
Compares Integer values, releasing the DOM when oldValue and newValue are not equivalent

Parameters:
oldValue -
newValue -
abstractXMLObject -
Returns:

getDefaultDateFormatter

public static org.joda.time.format.DateTimeFormatter getDefaultDateFormatter()
Returns a joda DateTimeFormatter for parsing and printing a DateTime

Returns:

cloneXMLObject

public static org.opensaml.xml.XMLObject cloneXMLObject(org.opensaml.xml.XMLObject xmlObject)
Clone an XMLObject

Parameters:
xmlObject -
Returns:

prettyPrintXMLObject

public static java.lang.String prettyPrintXMLObject(org.opensaml.xml.XMLObject xmlObject)
Takes an XMLObject as a parameter, marshalls it, and returns a pretty printed version of the generated XML.

Parameters:
xmlObject -
Returns: