org.tbee.flv
Class FLVFileParser

java.lang.Object
  extended by org.tbee.flv.FLVFileParser

public class FLVFileParser
extends Object

This class provides file level access to the FLV parser. It requires an input stream, where it will read lines upto the max length of all fields and then use the StringParser to split it into fields. This parser allowes for the columns to be separated (ColumnSeparator), making the file more readable. So instead of 12345 you can have 12|3|45. The same goes for the lines (LineSeparator). So instead of 123451234512345, you can have 12345\n12345\n12345. Therefore the length of one "line" is defined as the sum of: - the length of all fields - (number of fields - 1) * the length of the column separator - length of the line separator Note that the last line also must have a line separator, since it is added to the end of the blocksize. Ofcourse any character may be used as column or line separator, since effectively they are simply skipped. The first line may contain header, but is still bound by the sizes set in the StringParser. So if a field is only 1 character, the header can also be only one character. When parsing the header, when the corresponding type has no name (null), the header is set as the name. Usage is straight forward: FLVFileParser lFLVFileParser = new FLVFileParser(); lFLVFileParser.addField( new FLVString(2) ); ... lFLVFileParser.setFirstLineContainsHeader(true); lFLVFileParser.getStringParser().setColumnSeparator(1); lFLVFileParser.setReader( new FileReader(...) ); while (lFLVFileParser.readNextLine() >= 0) { lFLVFileParser.getString(1); lFLVFileParser.getString("F1"); ... }

Version:
$Revision: 1.10 $
Author:
$Author: toeukpap $

Field Summary
static String SOURCECODE_VERSION
          Standard variable for determining version of a class file.
 
Constructor Summary
FLVFileParser()
          Just the basic constructor Note that a inputstream must be set before the parse method is called
FLVFileParser(InputStream pInputStream)
          Usually there is a stream that is parsed This need not be a file inputstream
FLVFileParser(Reader pReader)
          Usually there is a stream that is parsed This need not be a file inputstream
 
Method Summary
 void addField(FLVString type)
          wrappers for the type methods
 void configure(Collection sortedMap)
          add fields according to the colleection
 void configure(nl.knowledgeplaza.util.ConfigurationProperties configurationProperties, String id)
          Find all matching properties in ConfigurationProperties and configure me.
 void configure(Properties properties)
          Find all matching properties in Properties and configure me.
 Date getDate(int idx)
           
 Date getDate(String name)
           
 int getFileTerminatorWidth()
          The file terminator.
 boolean getFirstLineContainsHeader()
          The first line may contain header information
 String getHeader(int idx)
          headers
 long getLineNumber()
          a line counter
 int getLineSeparatorWidth()
          The line separator.
 BigDecimal getNumber(int idx)
           
 BigDecimal getNumber(String name)
           
 Reader getReader()
          The stream to be parsed
 String getString(int idx)
          wrappers for the type methods
 String getString(String name)
          wrappers for the named-type methods
 FLVStringParser getStringParser()
          The FLVStringParser used to split up the lines
static void main(String[] args)
           
 int readNextLine()
          Read the next line This method will skip comment lines
 void setFileTerminatorWidth(int value)
           
 void setFirstLineContainsHeader(boolean value)
           
 void setInputStream(InputStream value)
          convenience method
 void setLineSeparatorWidth(int value)
           
 void setReader(Reader value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SOURCECODE_VERSION

public static final String SOURCECODE_VERSION
Standard variable for determining version of a class file.

See Also:
Constant Field Values
Constructor Detail

FLVFileParser

public FLVFileParser()
Just the basic constructor Note that a inputstream must be set before the parse method is called


FLVFileParser

public FLVFileParser(InputStream pInputStream)
Usually there is a stream that is parsed This need not be a file inputstream


FLVFileParser

public FLVFileParser(Reader pReader)
Usually there is a stream that is parsed This need not be a file inputstream

Method Detail

getReader

public Reader getReader()
The stream to be parsed


setReader

public void setReader(Reader value)

getStringParser

public FLVStringParser getStringParser()
The FLVStringParser used to split up the lines


setInputStream

public void setInputStream(InputStream value)
convenience method


getLineSeparatorWidth

public int getLineSeparatorWidth()
The line separator. Default: 1


setLineSeparatorWidth

public void setLineSeparatorWidth(int value)

getFileTerminatorWidth

public int getFileTerminatorWidth()
The file terminator. Default: 0


setFileTerminatorWidth

public void setFileTerminatorWidth(int value)

getFirstLineContainsHeader

public boolean getFirstLineContainsHeader()
The first line may contain header information


setFirstLineContainsHeader

public void setFirstLineContainsHeader(boolean value)

getHeader

public String getHeader(int idx)
headers


getLineNumber

public long getLineNumber()
a line counter


readNextLine

public int readNextLine()
                 throws IOException
Read the next line This method will skip comment lines

Throws:
IOException

addField

public void addField(FLVString type)
wrappers for the type methods


getString

public String getString(int idx)
wrappers for the type methods


getNumber

public BigDecimal getNumber(int idx)

getDate

public Date getDate(int idx)

getString

public String getString(String name)
wrappers for the named-type methods


getNumber

public BigDecimal getNumber(String name)

getDate

public Date getDate(String name)

configure

public void configure(nl.knowledgeplaza.util.ConfigurationProperties configurationProperties,
                      String id)
Find all matching properties in ConfigurationProperties and configure me. File parser setting are set as: org.tbee.flv.SOMEID.fileTerminatorWidth=0 org.tbee.flv.SOMEID.lineSeparatorWidth=1 org.tbee.flv.SOMEID.firstLineContainsHeader=true String parser setting are set as: org.tbee.flv.SOMEID.line.columnSeparatorWidth=1 Fields are defined as: org.tbee.flv.SOMEID.fields.1=string|name=Field1|length=2 org.tbee.flv.SOMEID.fields.2=number|name=Field2|length=4 org.tbee.flv.SOMEID.fields.3=date|name=Field3|format=yyyyMMdd


configure

public void configure(Properties properties)
Find all matching properties in Properties and configure me. File parser setting are set as: fileTerminatorWidth=1 lineSeparatorWidth=2 firstLineContainsHeader=true String parser setting are set as: columnSeparatorWidth=1 Fields are defined as: fields.1=string|name=Field1|length=2 fields.2=number|name=Field2|length=4 fields.3=date|name=Field3|format=yyyyMMdd


configure

public void configure(Collection sortedMap)
add fields according to the colleection


main

public static void main(String[] args)


Copyright © 2011 KnowledgePlaza. All Rights Reserved.