net.sf.jpkgmk
Class AbstractParser<T>

java.lang.Object
  extended by net.sf.jpkgmk.AbstractParser<T>
Type Parameters:
T -
Direct Known Subclasses:
PkgInfoParser, PkgMapParser, PrototypeParser

public abstract class AbstractParser<T>
extends java.lang.Object

Abstract class that provides some convenience methods for parsing files, strings etc. line by line.

Since:
1.0
Version:
$Revision: 2 $ $Date: 2008-08-20 21:14:19 +0200 (Mi, 20 Aug 2008) $
Author:
gommma (gommma AT users.sourceforge.net), Last changed by: $Author: gommma $

Field Summary
static char DEFAULT_LINE_DELIMITER
           
 
Constructor Summary
AbstractParser()
           
 
Method Summary
protected abstract  T createResult()
           
static java.lang.String[] getLineItems(java.lang.String line)
          Returns the items of the given line
 T parse(java.io.File file)
          Parses the data from the given reader and returns the parsed object representing all these data.
 T parse(java.io.Reader data)
          Parses the data from the given reader and returns the parsed object representing all these data.
 T parse(java.lang.String data)
          Parses the data from the given reader and returns the parsed object representing all these data.
protected abstract  void parseAndAddLine(java.lang.String line, T resultObject)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_LINE_DELIMITER

public static final char DEFAULT_LINE_DELIMITER
See Also:
Constant Field Values
Constructor Detail

AbstractParser

public AbstractParser()
Method Detail

parse

public T parse(java.lang.String data)
        throws java.io.IOException
Parses the data from the given reader and returns the parsed object representing all these data.

Parameters:
data - The input to be parsed
Returns:
The created object read from the given input data
Throws:
java.io.IOException - When something goes wrong during the LineCountingReader.readLine() invocation
See Also:
parse(Reader)

parse

public T parse(java.io.File file)
        throws java.io.IOException
Parses the data from the given reader and returns the parsed object representing all these data.

Parameters:
file - The input to be parsed
Returns:
The created object read from the given input data
Throws:
java.io.IOException - When something goes wrong during the LineCountingReader.readLine() invocation
See Also:
parse(Reader)

parse

public T parse(java.io.Reader data)
        throws java.io.IOException
Parses the data from the given reader and returns the parsed object representing all these data.

Parameters:
data - The input to be parsed
Returns:
The created object read from the given input data
Throws:
java.io.IOException - When something goes wrong during the LineCountingReader.readLine() invocation

createResult

protected abstract T createResult()

parseAndAddLine

protected abstract void parseAndAddLine(java.lang.String line,
                                        T resultObject)

getLineItems

public static final java.lang.String[] getLineItems(java.lang.String line)
Returns the items of the given line

Parameters:
line -
Returns:


Copyright © 2007-2008. All Rights Reserved.