|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
org.shredzone.repowatch.sync
Class PrimaryParser
java.lang.Objectorg.shredzone.repowatch.sync.PrimaryParser
public class PrimaryParser
- extends Object
- implements Iterable<Version>
- extends Object
This beast parses a primary.xml file. It also takes care for
gunzipping the file and computing the checksum, if desired. The single
Version objects found in the xml file are available via
readNextVersion(), but this class also implements the
Iterable interface, so it can be simply used in a for loop.
Invoke parse() before reading the content. The xml file is
processed on the fly, so the memory footprint is rather small even for
large xml files. Always invoke discard() after processing
or when an exception occured!
- Version:
- $Revision: 323 $
| Constructor Summary | |
|---|---|
PrimaryParser(Repository repository,
DatabaseLocation location)
Creates a new PrimaryParser. |
|
| Method Summary | |
|---|---|
void |
discard()
Frees all resources bound by the parser. |
Iterator<Version> |
iterator()
Returns an iterator over the Version entities found. |
void |
parse()
Parses the database. |
Version |
readNextVersion()
Reads the next Version entity found in the xml file. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
PrimaryParser
public PrimaryParser(Repository repository, DatabaseLocation location)
- Creates a new PrimaryParser. The parser is just created, no network
connection is opened yet.
- Parameters:
repository-Repositoryto parselocation-DatabaseLocationwith details for the database to be read.
| Method Detail |
|---|
parse
public void parse() throws SynchronizerException
- Parses the database. A network connection is opened and the xml file
is read and processed. The content is available by invoking
readNextVersion()or getting an interator byiterator().Always invoke
discard()after completion! Also invokediscard()if an exception occured.- Throws:
SynchronizerException- An error occured while parsing.
readNextVersion
public Version readNextVersion() throws SynchronizerException
- Reads the next
Versionentity found in the xml file. If there are no more entries,nullis returned.Note that a bad checksum is only reported after the last entry was read.
- Returns:
- Next
Versionentity that was found, ornullif the last entity was processed. - Throws:
SynchronizerException- An error occured while reading.
discard
public void discard()
- Frees all resources bound by the parser. Always invoke this method
when you are done reading the xml file. You can safely invoke it
multiple times.
iterator
public Iterator<Version> iterator()
- Returns an iterator over the
Versionentities found.parse()must be invoked prior to this method.- Returns:
- Iterator
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
Copyright © 2007-2011 shredzone.org. All Rights Reserved.
org.shredzone.repowatch.sync.PrimaryParser