Package csv.impl
Class XmlReader
java.lang.Object
csv.impl.AbstractTableReader
csv.impl.AbstractStreamTableReader
csv.impl.XmlReader
- All Implemented Interfaces:
TableReader,java.lang.Iterable<java.lang.Object[]>,java.util.Iterator<java.lang.Object[]>
public class XmlReader extends AbstractStreamTableReader
Reads from a XML file.
- Author:
- ralph
-
Field Summary
Fields Modifier and Type Field Description protected static intEND_OF_FILE_INDEX -
Constructor Summary
-
Method Summary
Modifier and Type Method Description voidclose()Closes the stream.protected voiddeliverComments()Handles all comments that were registered for current row.protected voiddeliverComments(int rowIndex)Handles all comments that were registered for current row.java.lang.StringgetColumnNameAttribute()Returns the attribute name of column tag that will contain the attribute name.java.lang.StringgetColumnTagName()Returns the column tag name.java.lang.StringgetColumnTypeAttribute()Returns the attribute name of column tag that contains the type of value.java.lang.StringgetRowTagName()Returns the row tag name.booleanhasNext()Returns true if there are more rows.protected voidinitParser()Initializes the XML parser thread.booleanisUseColumnNameTags()Returns whether column names will be used as column tag names.java.lang.Object[]next()Returns the next row.protected voidreadHeaderRow()Reads the header row.protected voidreadNextRow()Reads the next row.voidreset()Resets the reader.voidsetColumnNameAttribute(java.lang.String columnNameAttribute)Sets the attribute name of column tag that will contain the attribute name.voidsetColumnTagName(java.lang.String columnTagName)Sets the column tag name.voidsetColumnTypeAttribute(java.lang.String columnTypeAttribute)Sets the attribute name of column tag that contains the type of value.voidsetRowTagName(java.lang.String rowTagName)Sets the row tag name.voidsetUseColumnNameTags(boolean useColumnNameTags)Sets whether column names will be used as column tag names.Methods inherited from class csv.impl.AbstractStreamTableReader
createInputStreamReader, createReader, getCharsetDecoder, getInputStream, getReader, remove, setCharset, setCharset, setCharsetDecoder, setInputStreamMethods inherited from class csv.impl.AbstractTableReader
addCommentCallBack, convert, convert, convertArray, convertArray, get, getColumnIndex, getColumnType, getHeaderRow, getLineCount, getMinimumColumnCount, getRowCount, getTypeConversionHandler, hasHeaderRow, incrementLineCount, incrementRowCount, isHeaderRowRead, iterator, notifyComment, open, registerCommentCallBack, registerTypeConversionHandler, removeCommentCallBack, setColumnType, setHasHeaderRow, setHeaderRow, setHeaderRowRead, setMinimumColumnCount, unregisterCommentCallBack, unregisterTypeConversionHandler
-
Field Details
-
END_OF_FILE_INDEX
protected static final int END_OF_FILE_INDEX- See Also:
- Constant Field Values
-
-
Constructor Details
-
XmlReader
public XmlReader()Constructor. -
XmlReader
public XmlReader(java.io.InputStream in)Constructor.- Parameters:
in- stream to read
-
XmlReader
public XmlReader(java.io.File file) throws java.io.FileNotFoundExceptionConstructor.- Parameters:
file- fiel to read- Throws:
java.io.FileNotFoundException- when the file cannot be found
-
XmlReader
public XmlReader(java.lang.String file) throws java.io.FileNotFoundExceptionConstructor.- Parameters:
file- file to read- Throws:
java.io.FileNotFoundException- when the file cannot be found
-
-
Method Details
-
close
public void close()Closes the stream.- Specified by:
closein interfaceTableReader- Overrides:
closein classAbstractStreamTableReader- See Also:
AbstractStreamTableReader.close()
-
reset
public void reset()Resets the reader.- Specified by:
resetin interfaceTableReader- Overrides:
resetin classAbstractStreamTableReader- See Also:
AbstractStreamTableReader.reset()
-
hasNext
public boolean hasNext()Returns true if there are more rows.- See Also:
Iterator.hasNext()
-
next
public java.lang.Object[] next()Returns the next row.- See Also:
Iterator.next()
-
readNextRow
protected void readNextRow()Reads the next row. -
readHeaderRow
protected void readHeaderRow()Reads the header row.- Overrides:
readHeaderRowin classAbstractTableReader- See Also:
AbstractTableReader.readHeaderRow()
-
initParser
protected void initParser()Initializes the XML parser thread. -
deliverComments
protected void deliverComments()Handles all comments that were registered for current row. -
deliverComments
protected void deliverComments(int rowIndex)Handles all comments that were registered for current row.- Parameters:
rowIndex- the index of the row to be processed
-
getRowTagName
public java.lang.String getRowTagName()Returns the row tag name.- Returns:
- the rowTagName
-
setRowTagName
public void setRowTagName(java.lang.String rowTagName)Sets the row tag name.- Parameters:
rowTagName- the rowTagName to set
-
getColumnTagName
public java.lang.String getColumnTagName()Returns the column tag name.- Returns:
- the columnTagName
-
setColumnTagName
public void setColumnTagName(java.lang.String columnTagName)Sets the column tag name.- Parameters:
columnTagName- the columnTagName to set
-
isUseColumnNameTags
public boolean isUseColumnNameTags()Returns whether column names will be used as column tag names.- Returns:
- the useColumnNameTags
-
setUseColumnNameTags
public void setUseColumnNameTags(boolean useColumnNameTags)Sets whether column names will be used as column tag names.- Parameters:
useColumnNameTags- the useColumnNameTags to set
-
getColumnNameAttribute
public java.lang.String getColumnNameAttribute()Returns the attribute name of column tag that will contain the attribute name. This information is required only whenisUseColumnNameTags()returns false.- Returns:
- the columnNameAttribute
-
setColumnNameAttribute
public void setColumnNameAttribute(java.lang.String columnNameAttribute)Sets the attribute name of column tag that will contain the attribute name. This information is required only whenisUseColumnNameTags()returns false.- Parameters:
columnNameAttribute- the columnNameAttribute to set
-
getColumnTypeAttribute
public java.lang.String getColumnTypeAttribute()Returns the attribute name of column tag that contains the type of value. The type is the value class and usually being used for type conversion.- Returns:
- the columnTypeAttribute
-
setColumnTypeAttribute
public void setColumnTypeAttribute(java.lang.String columnTypeAttribute)Sets the attribute name of column tag that contains the type of value. The type is the value class and usually being used for type conversion.- Parameters:
columnTypeAttribute- the columnTypeAttribute to set
-