org.eclipse.ecf.provider.rss.channel
Class ParserUtils

java.lang.Object
  extended by org.eclipse.ecf.provider.rss.channel.ParserUtils

public class ParserUtils
extends java.lang.Object

Utility class providing convenience methods to (XML) parsing mechanisms.

Author:
Sergey Yakovlev

Field Summary
static boolean DEBUG
          A DEBUG flag
 
Constructor Summary
ParserUtils()
           
 
Method Summary
static java.lang.String formatDate(java.util.Date date)
          Formats a Date into a date/time string.
static boolean getBool(java.lang.String strBoolean)
          Parses the string argument as a boolean.
static java.util.Date getDate(java.lang.String strDate)
          Converts text from the beginning of the given string to produce a date.
static java.util.Date getDate(java.lang.String strDate, java.util.Date defaultValue)
          Converts text from the beginning of the given string to produce a date.
static int getInt(java.lang.String strInt)
          Parses the string argument as a signed decimal integer.
static int getInt(java.lang.String strInt, int defaultValue)
          Parses the string argument as a signed decimal integer.
static java.net.URL getURL(java.lang.String strURL)
          Parses the string argument as a URL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

public static boolean DEBUG
A DEBUG flag

Constructor Detail

ParserUtils

public ParserUtils()
Method Detail

getDate

public static java.util.Date getDate(java.lang.String strDate)
Converts text from the beginning of the given string to produce a date. The method may not use the entire text of the given string.

Parameters:
strDate - - A String whose beginning should be parsed.
Returns:
A Date converted from the string.

getDate

public static java.util.Date getDate(java.lang.String strDate,
                                     java.util.Date defaultValue)
Converts text from the beginning of the given string to produce a date. The method returns the default value argument if the text cannot be converted. The method may not use the entire text of the given string.

Parameters:
strDate - - A String whose beginning should be parsed.
defaultValue - - a default value.
Returns:
A Date converted from the string.

formatDate

public static java.lang.String formatDate(java.util.Date date)
Formats a Date into a date/time string.

Parameters:
date - - the date value to be formatted into a date string.
Returns:
the formatted date string.

getInt

public static int getInt(java.lang.String strInt)
Parses the string argument as a signed decimal integer. The characters in the string must all be decimal digits, except that the first character may be an ASCII minus sign '-' ('-') to indicate a negative value.

Parameters:
strInt - - a String containing the int representation to be parsed.
Returns:
the integer value represented by the argument in decimal.

getInt

public static int getInt(java.lang.String strInt,
                         int defaultValue)
Parses the string argument as a signed decimal integer. The method returns the default value argument if the string cannot be parsed.

Parameters:
strInt - - a String containing the int representation to be parsed.
defaultValue - - a default value.
Returns:
the integer value represented by the argument in decimal.

getURL

public static java.net.URL getURL(java.lang.String strURL)
Parses the string argument as a URL.

Parameters:
strURL - - the String to parse as a URL.
Returns:
A URL converted from the string.

getBool

public static boolean getBool(java.lang.String strBoolean)
Parses the string argument as a boolean. The boolean returned represents the value true if the string argument is not null and is equal, ignoring case, to the string "true".

Parameters:
strBoolean - - the String containing the boolean representation to be parsed.
Returns:
the boolean represented by the string argument.