|
ehsbe CommonsTM Version 1.1.0rc3 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ehsbe.commons.util.Stax
public class Stax
Stax utilities.
Field Summary | |
---|---|
protected static SimpleDateFormat |
dateFormatter
formatter to be used for date formatting |
protected static SimpleDateFormat |
dateTimeTimezoneFormatter
formatter to be used for datetime formatting |
protected static TimeZone |
gmtTimeZone
timezone to be used for date formatting/parsing |
protected static Locale |
locale
locale to be used for date formatting/parsing |
protected static SimpleDateFormat |
stdDateTimeFormat
formatter to be used for datetime formatting without timezone |
Constructor Summary | |
---|---|
Stax()
|
Method Summary | |
---|---|
static String |
asString(Calendar cal)
Get the date the given calendar represents as an XML Schema Part 2: Datatypes Second Edition GMT formatted dateTime string (e.g., 2004-08-04T19:09:02.768Z). |
static String |
asString(Date date)
Format the given date as date string 'yyyy-MM-dd'. |
static void |
fastForwardToEndOfElement(XMLStreamReader reader)
Forward the cursor of the stream to the end of the current start element. |
static void |
forwardToNextChildOrEOE(XMLStreamReader reader)
Forward the cursor of the stream to the start of the next element. |
static IdentityHashMap<String,String> |
getAttributes(XMLStreamReader in)
Get all all attributes of the element, where the cursor currently points to. |
static Calendar |
getCalendar(String dateTimeStr)
Convert the given XML Schema Part 2: Datatypes Second Edition formatted dateTime string (i.e. |
static Date |
getDate(String dateStr)
Convert the given GMT date string ('yyyy-MM-dd') into a date. |
static XMLResolver |
getIgnoringXMLResolver()
Get an XMLResolver, which always returns an empty InputStream, to make braindead Stax Implementations (e.g. from SUN) happy. |
static StreamSource |
getInputSourceByFile(File path,
boolean gzip)
Boilerplate: Get a stream source from the given file. |
static StreamSource |
getInputSourceByResource(String resourceName)
Get a StreamSource from the given resource. |
static InputStream |
getNullInputStream()
Get an InputStream whoms read method always returns -1 . |
static XMLStreamReader |
getReader(StreamSource src,
String root)
Create a none-validating XMLStreamReader for the given InputStream and position the cursor at the first root element with the given name. |
static XMLStreamReader |
getReader(StreamSource src,
String root,
boolean namespaceAware)
Create an none-validating XMLStreamReader for the given InputStream and position the cursor at the first root element with the given name. |
static String |
location2string(Location loc)
Helper to map a Stream Location into a String in a standardized way. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final Locale locale
protected static final TimeZone gmtTimeZone
protected static final SimpleDateFormat dateFormatter
protected static final SimpleDateFormat dateTimeTimezoneFormatter
protected static final SimpleDateFormat stdDateTimeFormat
Constructor Detail |
---|
public Stax()
Method Detail |
---|
public static StreamSource getInputSourceByResource(String resourceName)
resourceName
- name of the resource.
null
if the resource cannot be found, the
StreamSource otherwise.
NullPointerException
- if resourceName is null
.public static StreamSource getInputSourceByFile(File path, boolean gzip) throws IOException
The underlying stream is an InputStream. So to finally free the resources
allocated by the source one should call close on
StreamSource.getInputStream()
.
path
- file to read.gzip
- if true
the file is gzipped.
IOException
- if path does not exist or is not readable or
the is not in gzipped format when gzip option is set.public static void fastForwardToEndOfElement(XMLStreamReader reader) throws XMLStreamException
reader
- a reader, whoms cursor points to an start element
XMLStreamException
public static String location2string(Location loc)
loc
- stream location to convert
???
if location is null
, a String
which describes the location otherwise.public static final XMLStreamReader getReader(StreamSource src, String root)
src
- xml stream source to read fromroot
- name of the document root element
null
if one of the parameters are null
or the given root element could not be found, the reader otherwise.public static final InputStream getNullInputStream()
-1
.
getIgnoringXMLResolver()
public static final XMLResolver getIgnoringXMLResolver()
getNullInputStream()
public static final XMLStreamReader getReader(StreamSource src, String root, boolean namespaceAware)
src
- xml stream source to read fromroot
- name of the document root element. If null
,
the cursor gets positioned at the start of the first element
encountered in the stream.namespaceAware
- if true
the returned reader is
XML Namespace aware, otherwise not.
null
if one of the parameters are null
or the given root element could not be found, the reader otherwise.public static final String asString(Calendar cal)
cal
- calendar to use to retrieve the time
public static final Calendar getCalendar(String dateTimeStr) throws ParseException
dateTimeStr
- string to convert
ParseException
- if the dateTimeStr is not correctly
formatted
IndexOutOfBoundsException
- same as for parse exceptionpublic static final String asString(Date date)
date
- date to format
public static final Date getDate(String dateStr) throws ParseException
dateStr
- string to convert
ParseException
- if the given parameter has not the appropriate
format.public static final void forwardToNextChildOrEOE(XMLStreamReader reader) throws XMLStreamException
reader
- a reader, whoms cursor points to an start element
XMLStreamException
public static final IdentityHashMap<String,String> getAttributes(XMLStreamReader in)
in
- reader, whoms cursor is at the start of an element
|
ehsbe CommonsTM Version 1.1.0rc3 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |