|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.ObjectVoterInputTable<S>
@ThreadSafe public abstract class VoterInputTable<S extends VoterService>
The input table of a voter service, storing its voter input in a relational form. Multiple services may share a single physical table. The columnar structure is fixed by the use of a single 'xml' column, as required by the synchronization interface.
| Nested Class Summary | |
|---|---|
static class |
VoterInputTable.BadInputException
Thrown when voter input is unacceptable for storage. |
| Field Summary | |
|---|---|
protected Database |
database
|
static int |
MAX_INPUT_LENGTH
Maximum length of a single input string, in characters. |
protected String |
statementKeyBase
|
protected String |
tableName
|
protected S |
voterService
|
| Constructor Summary | |
|---|---|
protected |
VoterInputTable(S _voterService,
String _tableName)
Partially constructs a VoterInputTable. |
| Method Summary | |
|---|---|
static void |
appendAttribute(String nameA,
String value,
StringBuilder xmlB)
Serializes the string value of an attribute and appends it to a string builder, destined for writing to the 'xml' column. |
static String |
booleanToString(boolean b)
Returns a non-empty string if b is true; null otherwise. |
static String |
checkedDelimiterless(String dataString)
Throws a runtime exception if the specified data string contains a serialization delimiter character (tab or newline), making it invalid for storage in a voter input table. |
static boolean |
containsDelimiter(String dataString)
Returns true if the specified data string contains a serialization delimiter character (tab or newline), making it invalid for storage in a voter input table. |
Database |
database()
The database in which this table is stored. |
protected boolean |
exists()
Returns true if this table exists; false otherwise. |
String |
get(String voterEmail)
Retrieves a voter's data from the 'xml' column. |
void |
init()
Finishes constructing a VoterInputTable, physical creating it if it does not already exist. |
static String |
lengthConstrained(String inputString)
Throws a BadInputException if the input string is longer than MAX_INPUT_LENGTH; otherwise returns the same input string. |
static String |
longToString(long n)
Returns null if n is 0L, otherwise the standard string representation of n. |
VotorolaRuntimeException |
newUnparseableInputException(String voterEmail,
String xml,
XMLStreamException nestedException)
Constructs an exception that complains about "unparseable data from input table...". |
static XMLStreamReader |
newXMLStreamReader(Reader reader)
Constructs a new stream reader that is configured to read the data of the 'xml' column. |
static XMLStreamReader |
newXMLStreamReader(String systemId,
Reader reader)
Constructs a new stream reader that is configured to read the data of the 'xml' column. |
void |
put(String voterEmail,
String xml,
Pollserver.UserSession userSession)
Stores a voter's data to the 'xml' column. |
void |
put(String voterEmail,
String xml,
Pollserver.UserSession userSession,
boolean toBypassSecurityFailsafe)
Stores a voter's data to the 'xml' column. |
void |
remove(String voterEmail)
Removes a voter's data from the table, if any is stored there. |
static boolean |
stringToBoolean(String s)
Returns true if s is non-null and non-empty; false otherwise. |
static long |
stringToLong(String s)
Returns 0L if s is null or empty, otherwise the parsed value of s. |
String |
tableName()
The name of this table (relation). |
static void |
testAccessAllowed(String voterEmail,
Pollserver.UserSession userSession)
Throws a VotorolaSecurityException if voterEmail is unequal to userSession.userEmail(). |
S |
voterService()
Returns the service whose voter input this table stores. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final Database database
public static final int MAX_INPUT_LENGTH
protected final String tableName
protected final S extends VoterService voterService
protected final String statementKeyBase
| Constructor Detail |
|---|
protected VoterInputTable(S _voterService,
String _tableName)
tableName(),
voterService(),
init()| Method Detail |
|---|
public void init()
throws SQLException
SQLException
public static void appendAttribute(String nameA,
String value,
StringBuilder xmlB)
throws VoterInputTable.BadInputException
nameA - attribute's archival name, a valid XML namevalue - whose toString()
is escaped where necessary with XML character entities,
and used as the attribute value; or null to append nothing
VoterInputTable.BadInputException - if the attribute value is longer
than the allowed limitpublic static String booleanToString(boolean b)
stringToBoolean(String)public static boolean stringToBoolean(String s)
booleanToString(boolean)public static String checkedDelimiterless(String dataString)
containsDelimiter(String)public static boolean containsDelimiter(String dataString)
It's only the register that still has this constraint, polls now serialize in proper XML format and can handle any characters.
checkedDelimiterless(String)@Warning(value="thread restricted object") public final Database database()
Pollserver.Run.voterInputDatabase()
public String get(String voterEmail)
throws SQLException
SQLException
public static String lengthConstrained(String inputString)
throws VoterInputTable.BadInputException
VoterInputTable.BadInputExceptionpublic static String longToString(long n)
stringToLong(String)public static long stringToLong(String s)
longToString(long)
public static XMLStreamReader newXMLStreamReader(Reader reader)
throws XMLStreamException
XMLStreamException
public static XMLStreamReader newXMLStreamReader(String systemId,
Reader reader)
throws XMLStreamException
XMLStreamException
public final VotorolaRuntimeException newUnparseableInputException(String voterEmail,
String xml,
XMLStreamException nestedException)
public final void put(String voterEmail,
String xml,
Pollserver.UserSession userSession)
throws VoterInputTable.BadInputException,
SQLException
xml - data to store
VotorolaSecurityException - if voterEmail is unequal
to userSession.userEmail() (failsafe bug trap)
VoterInputTable.BadInputException
SQLException
public void put(String voterEmail,
String xml,
Pollserver.UserSession userSession,
boolean toBypassSecurityFailsafe)
throws VoterInputTable.BadInputException,
SQLException
xml - data to store
VotorolaSecurityException - if toBypassSecurityFailsafe is false,
and voterEmail is unequal to userSession.userEmail() (failsafe bug trap)
VoterInputTable.BadInputException
SQLException
public void remove(String voterEmail)
throws SQLException
SQLExceptionpublic final String tableName()
public static void testAccessAllowed(String voterEmail,
Pollserver.UserSession userSession)
throws VotorolaSecurityException
VotorolaSecurityExceptionpublic S voterService()
protected boolean exists()
throws SQLException
SQLException
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||