olg.csv.bean.loader
Class Util

Package class diagram package Util
java.lang.Object
  extended by olg.csv.bean.loader.Util

public final class Util
extends Object

Util in loading objects from XML Documents.


Constructor Summary
private Util()
          private constructor to prevent its instantiation.
 
Method Summary
static
<T> boolean
checkBean(Class<T> beanClass)
          This test checks only if it has a constructor with no argument and is not an array or an enum or a primitive.
static String emptyToNull(String str)
          Convert an empty String to null.
static Object evaluerDOM(Object document, String expression, QName retour)
          Extracts Element from XML Element corresponding to the given XPath expression.
static Locale getLocale(String locale)
          Returns a locale corresponding to one of the available locales supported on the JVM and matches the given parameter.
static Document openDocument(File file)
          Returns the XML Document corresponding to the content of the given file.
static String toString(Document document)
          transforms a XML Document as a String.
static void validate(File file)
          Validate a file as a bean-row XML file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Util

private Util()
private constructor to prevent its instantiation.

Method Detail

evaluerDOM

public static Object evaluerDOM(Object document,
                                String expression,
                                QName retour)
                         throws XPathExpressionException
Extracts Element from XML Element corresponding to the given XPath expression.

Parameters:
document - The context starting
expression - XPath Expression
retour - returned type
Returns:
the Object that is the result of evaluating the expression and converting to the retour
Throws:
XPathExpressionException - If the expression cannot be evaluated

validate

public static void validate(File file)
                     throws SAXException,
                            IOException
Validate a file as a bean-row XML file.

Parameters:
file - the file to validate.
Throws:
SAXException - If any parse errors occur.
IOException - If any IO errors occur.

openDocument

public static Document openDocument(File file)
                             throws ParserConfigurationException,
                                    SAXException,
                                    IOException
Returns the XML Document corresponding to the content of the given file.

Parameters:
file - the file
Returns:
the XML document.
Throws:
ParserConfigurationException - if a DocumentBuilder cannot be created which satisfies the configuration requested.
SAXException - If any parse errors occur.
IOException - If any IO errors occur.

toString

public static String toString(Document document)
                       throws TransformerException
transforms a XML Document as a String.

Parameters:
document - the document.
Returns:
the string.
Throws:
TransformerException - Thrown if it is not possible to create a Transformer instance or if an error occurs during the course of the String transformation

checkBean

public static <T> boolean checkBean(Class<T> beanClass)
This test checks only if it has a constructor with no argument and is not an array or an enum or a primitive.

Type Parameters:
T - the type of the bean.
Parameters:
beanClass - the class
Returns:
true if the given class is identify as a bean.

emptyToNull

public static String emptyToNull(String str)
Convert an empty String to null.

Parameters:
str - String to convert.
Returns:
the string or null if empty.

getLocale

public static Locale getLocale(String locale)
Returns a locale corresponding to one of the available locales supported on the JVM and matches the given parameter.

Parameters:
locale - a locale String representation like "en" or "fr_CH"
Returns:
null if none available locale matches with the given parameter.
See Also:
Locale


Copyright © 2014. All Rights Reserved.