package votorola.a; // Copyright 2008-2009, 2012, Michael Allan. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Votorola Software"), to deal in the Votorola Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicence, and/or sell copies of the Votorola Software, and to permit persons to whom the Votorola Software is furnished to do so, subject to the following conditions: The preceding copyright notice and this permission notice shall be included in all copies or substantial portions of the Votorola Software. THE VOTOROLA SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE VOTOROLA SOFTWARE OR THE USE OR OTHER DEALINGS IN THE VOTOROLA SOFTWARE. import java.io.*; import java.util.*; import javax.xml.stream.*; import votorola.g.io.*; import votorola.g.lang.*; import votorola.g.sql.*; import votorola.g.util.*; /** The input store of a voter service. The input store contains service input, such as * voter registrations, votes and administrative configuration. It includes both file * data and relational data. */ public interface InputStore { // - I n p u t - S t o r e ------------------------------------------------------------ /** The relational store of voter input for this service. It is a table named * "in_something", located in the vote-server's voter-input database. * * @see VoteServer.Run#database() */ public VoterInputTable voterInputTable(); // ==================================================================================== /** Input store utilities. */ public static @ThreadSafe final class U { private U() {} /** All mirror source directories, each directory (S) located at * ~/votorola/in/vomir/S. */ public static Iterable mirrorSourceDirectories( final VoteServer voteServer ) { return new Iterable() { public Iterator iterator() { return new IteratorA() { private int d; private final File[] directoryArray = FileX.listFilesNoNull( new File( voteServer.inDirectory(), "vomir" ), FileFilterX.DIR ); public boolean hasNext() { return d < directoryArray.length; } public File next() { if( d >= directoryArray.length ) throw new NoSuchElementException(); return directoryArray[d++]; } }; } }; } /** Constructs a stream reader configured to read the input files for * vote-mirroring and such. */ public static XMLStreamReader newXMLStreamReader( final Reader reader ) throws XMLStreamException { return XMLColumnAppender.newStreamReader( reader ); } /** Constructs a stream reader configured to read the input files for * vote-mirroring and such. */ public static XMLStreamReader newXMLStreamReader( final String systemId, final Reader reader ) throws XMLStreamException { return XMLColumnAppender.newStreamReader( systemId, reader ); } } }