org.jwat.warc
Class WarcFieldParsers

java.lang.Object
  extended by org.jwat.warc.WarcFieldParsers

public class WarcFieldParsers
extends Object

Separate class containing all the different types of field parser. Including validating parsers for strings, integers, longs, content-types, IP's, URI's, WARC dates, and WARC digests.

Author:
nicl

Field Summary
protected  Diagnostics<Diagnosis> diagnostics
          Diagnostics used to report diagnoses.
 
Constructor Summary
WarcFieldParsers()
           
 
Method Summary
protected  void addEmptyWarning(String entity)
          Add a warning diagnosis on the given entity stating that it is empty.
protected  void addInvalidExpectedError(String entity, String... information)
          Add an error diagnosis on the given entity stating that it is invalid and something else was expected.
protected  ContentType parseContentType(String contentTypeStr, String field)
          Parse and validate content-type string with optional parameters.
protected  Date parseDate(String dateStr, String field)
          Parses WARC record date.
protected  WarcDigest parseDigest(String labelledDigest, String field)
          Parse and validate WARC digest string.
protected  Integer parseInteger(String intStr, String field)
          Returns an Integer object holding the value of the specified string.
protected  InetAddress parseIpAddress(String ipAddress, String field)
          Parses WARC record IP address.
protected  Long parseLong(String longStr, String field)
          Returns a Long object holding the value of the specified string.
protected  String parseString(String str, String field)
          Parses a string.
protected  URI parseUri(String uriStr, String field)
          Returns an URL object holding the value of the specified string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

diagnostics

protected Diagnostics<Diagnosis> diagnostics
Diagnostics used to report diagnoses. Must be set prior to calling the various methods.

Constructor Detail

WarcFieldParsers

public WarcFieldParsers()
Method Detail

addInvalidExpectedError

protected void addInvalidExpectedError(String entity,
                                       String... information)
Add an error diagnosis on the given entity stating that it is invalid and something else was expected. The optional information should provide more details and/or format information.

Parameters:
entity - entity examined
information - optional extra information

addEmptyWarning

protected void addEmptyWarning(String entity)
Add a warning diagnosis on the given entity stating that it is empty.

Parameters:
entity - entity examined

parseString

protected String parseString(String str,
                             String field)
Parses a string.

Parameters:
str - the value to parse
field - field name
Returns:
the parsed value

parseInteger

protected Integer parseInteger(String intStr,
                               String field)
Returns an Integer object holding the value of the specified string.

Parameters:
intStr - the value to parse.
field - field name
Returns:
an integer object holding the value of the specified string

parseLong

protected Long parseLong(String longStr,
                         String field)
Returns a Long object holding the value of the specified string.

Parameters:
longStr - the value to parse.
field - field name
Returns:
a long object holding the value of the specified string

parseContentType

protected ContentType parseContentType(String contentTypeStr,
                                       String field)
Parse and validate content-type string with optional parameters.

Parameters:
contentTypeStr - content-type string to parse
field - field name
Returns:
content-type wrapper object or null

parseIpAddress

protected InetAddress parseIpAddress(String ipAddress,
                                     String field)
Parses WARC record IP address.

Parameters:
ipAddress - the IP address to parse
field - field name
Returns:
the IP address

parseUri

protected URI parseUri(String uriStr,
                       String field)
Returns an URL object holding the value of the specified string.

Parameters:
uriStr - the URL to parse
field - field name
Returns:
an URL object holding the value of the specified string

parseDate

protected Date parseDate(String dateStr,
                         String field)
Parses WARC record date.

Parameters:
dateStr - the date to parse.
field - field name
Returns:
the formatted date.

parseDigest

protected WarcDigest parseDigest(String labelledDigest,
                                 String field)
Parse and validate WARC digest string.

Parameters:
labelledDigest - WARC digest string to parse
field - field name
Returns:
digest wrapper object or null


Copyright © 2011-2012. All Rights Reserved.