Class Parser
- java.lang.Object
-
- org.openstack4j.openstack.internal.Parser
-
public final class Parser extends Object
Provides common parser routines when dealing with Headers or other non-json payloads- Author:
- Jeremy Unruh, Qin An - Added parser function for Neutron Agent List
-
-
Constructor Summary
Constructors Constructor Description Parser()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Boolean
asBoolean(String bool)
Takes a String Boolean and returns null or as Boolean valuestatic Date
asDate(String date)
Takes a String Date and decodes it into a date.static Long
asLong(String number)
Takes a String Numeric and returns null or the Long valuestatic Long
asLong(String number, Long defaultValue)
Takes a String Numeric and returns null or the Long valuestatic boolean
isContentTypeText(String contentType)
Determines if the specified content type is text/plain or text/html.static Date
parseSimpleDate(String date)
Parse a string with format "yyyy-MM-dd HH:mm:ss" into a Date The string format is used in Neutron Agent-Liststatic String
toISO8601DateFormat(Date date)
static String
toRFC1123(Date date)
Takes a Date and returns it's equivalent in RFC 1123static Date
toRFC822DateParse(String toParse)
Parses a String in RFC 822 format into a Date object
-
-
-
Method Detail
-
asLong
public static Long asLong(String number)
Takes a String Numeric and returns null or the Long value- Parameters:
number
- the number in string form- Returns:
- the Long or null
-
asLong
public static Long asLong(String number, Long defaultValue)
Takes a String Numeric and returns null or the Long value- Parameters:
number
- the number in string formdefaultValue
- the default value if number is null- Returns:
- the Long or null
-
asBoolean
public static Boolean asBoolean(String bool)
Takes a String Boolean and returns null or as Boolean value- Parameters:
bool
- the boolean in String form- Returns:
- the Boolean or null
-
asDate
public static Date asDate(String date)
Takes a String Date and decodes it into a date. Returns null if the date is null- Parameters:
date
- the date in String form- Returns:
- Date or null
-
parseSimpleDate
public static Date parseSimpleDate(String date)
Parse a string with format "yyyy-MM-dd HH:mm:ss" into a Date The string format is used in Neutron Agent-List- Parameters:
date
- - string to be parsed- Returns:
- Date
-
toRFC1123
public static String toRFC1123(Date date)
Takes a Date and returns it's equivalent in RFC 1123- Parameters:
date
- the date to format- Returns:
- the formatted date string
-
toRFC822DateParse
public static Date toRFC822DateParse(String toParse)
Parses a String in RFC 822 format into a Date object- Parameters:
toParse
- the date to parse- Returns:
- the parsed date
-
isContentTypeText
public static boolean isContentTypeText(String contentType)
Determines if the specified content type is text/plain or text/html. If the contentType is null then false is returned.- Parameters:
contentType
- the content type- Returns:
- true if the contentType is text/plain or text/html
-
-