yarfraw.utils
Class CommonUtils

java.lang.Object
  extended by yarfraw.utils.CommonUtils

public class CommonUtils
extends Object

Utilities methods.

Author:
jliang

Field Summary
static String ATOM03_JAXB_CONTEXT
           
static String ATOM10_JAXB_CONTEXT
           
static String ISO_8601_LVL1_PATTERN
           
static String ISO_8601_LVL2_PATTERN
           
static String ISO_8601_LVL3_PATTERN
           
static String ISO_8601_LVL4_PATTERN
           
static String ISO_8601_LVL5_PATTERN
           
static String ISO_8601_LVL6_PATTERN
           
static String ISO8601DATE_PATTERN
           
static String NON_STANDARD_PATTERN1
           
static String NON_STANDARD_PATTERN2
           
static String NON_STANDARD_PATTERN3
           
static String NON_STANDARD_PATTERN4
           
static String NON_STANDARD_PATTERN5
           
static String NON_STANDARD_PATTERN6
           
static String NON_STANDARD_PATTERN7
           
static String RFC822DATE_PATTERN
           
static String RSS10_JAXB_CONTEXT
           
static String RSS20_JAXB_CONTEXT
           
 
Method Summary
static Integer calculateTtl(UpdatePeriodEnum updatePeriod, BigInteger updateFrequency)
          calculate the ttl value from updatePeriod and updateFrequency
static String formatDate(Date date, FeedFormat format)
          Format a Date object to string based on the input FeedFormat.
static boolean isDateFormatValid(String dateString, FeedFormat format)
          Determines whether the input dateString is valid based on the input FeedFormat.
static Date tryParseDate(String dateString)
          Parse a date string using both ISO and RFC formats and some non standard formats.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RSS20_JAXB_CONTEXT

public static final String RSS20_JAXB_CONTEXT
See Also:
Constant Field Values

RSS10_JAXB_CONTEXT

public static final String RSS10_JAXB_CONTEXT
See Also:
Constant Field Values

ATOM10_JAXB_CONTEXT

public static final String ATOM10_JAXB_CONTEXT
See Also:
Constant Field Values

ATOM03_JAXB_CONTEXT

public static final String ATOM03_JAXB_CONTEXT
See Also:
Constant Field Values

RFC822DATE_PATTERN

public static final String RFC822DATE_PATTERN
See Also:
Constant Field Values

ISO8601DATE_PATTERN

public static final String ISO8601DATE_PATTERN
See Also:
Constant Field Values

ISO_8601_LVL1_PATTERN

public static final String ISO_8601_LVL1_PATTERN
See Also:
Constant Field Values

ISO_8601_LVL2_PATTERN

public static final String ISO_8601_LVL2_PATTERN
See Also:
Constant Field Values

ISO_8601_LVL3_PATTERN

public static final String ISO_8601_LVL3_PATTERN
See Also:
Constant Field Values

ISO_8601_LVL4_PATTERN

public static final String ISO_8601_LVL4_PATTERN
See Also:
Constant Field Values

ISO_8601_LVL5_PATTERN

public static final String ISO_8601_LVL5_PATTERN
See Also:
Constant Field Values

ISO_8601_LVL6_PATTERN

public static final String ISO_8601_LVL6_PATTERN
See Also:
Constant Field Values

NON_STANDARD_PATTERN1

public static final String NON_STANDARD_PATTERN1
See Also:
Constant Field Values

NON_STANDARD_PATTERN2

public static final String NON_STANDARD_PATTERN2
See Also:
Constant Field Values

NON_STANDARD_PATTERN3

public static final String NON_STANDARD_PATTERN3
See Also:
Constant Field Values

NON_STANDARD_PATTERN4

public static final String NON_STANDARD_PATTERN4
See Also:
Constant Field Values

NON_STANDARD_PATTERN5

public static final String NON_STANDARD_PATTERN5
See Also:
Constant Field Values

NON_STANDARD_PATTERN6

public static final String NON_STANDARD_PATTERN6
See Also:
Constant Field Values

NON_STANDARD_PATTERN7

public static final String NON_STANDARD_PATTERN7
See Also:
Constant Field Values
Method Detail

isDateFormatValid

public static boolean isDateFormatValid(String dateString,
                                        FeedFormat format)
Determines whether the input dateString is valid based on the input FeedFormat.

Parameters:
dateString -
format -
Returns:

tryParseDate

public static Date tryParseDate(String dateString)
Parse a date string using both ISO and RFC formats and some non standard formats.

Parameters:
dateString -
Returns:
Date representation of the input string. null if unable to parse input string.

formatDate

public static String formatDate(Date date,
                                FeedFormat format)
Format a Date object to string based on the input FeedFormat. For Atom 1.0 and RSS 1.0 it will be formatted as ISO8601 Level 5 string.
http://www.w3.org/TR/NOTE-datetime
For RSS 2.0, it will be formatted as RFC 822 date string.
http://www.faqs.org/rfcs/rfc822.html

Parameters:
date - any date
format - any FeedFormat
Returns:
null if either input is null. Formatted date string otherwise.

calculateTtl

public static Integer calculateTtl(UpdatePeriodEnum updatePeriod,
                                   BigInteger updateFrequency)
calculate the ttl value from updatePeriod and updateFrequency

Returns:
null if anything unexpcted occurs


Copyright © 2008. All Rights Reserved.