public abstract class AbstractParser extends Object
Modifier and Type | Field and Description |
---|---|
protected Map<String,Block> |
allBlockLookUp
All blocks in the survey (including sub-blocks).
|
static String |
ANSWER
The expected response column header/JSON key.
|
static String |
BLOCK
The block column header/JSON key.
|
static String |
BRANCH
The branch column/JSON key.
|
static String |
CORRELATION
The correlation column header/JSON key.
|
protected Map<String,List<Question>> |
correlationMap
A map from correlation labels to their associated set of questions.
|
static String |
CUSTOM_ID
The identifier used for ad hoc responses (e.g., timing information).
|
static HashMap<String,Boolean> |
defaultValues
Holds a map from the column name to its default value.
|
static String |
EXCLUSIVE
The exclusive column header/JSON key.
|
static String |
FREETEXT
The freetext column header/JSON key.
|
static String |
INPUT_SCHEMA
The schema against which JSON input is validated.
|
static String[] |
knownHeaders
An array of semantically meaningful column headers.
|
protected static org.apache.logging.log4j.spi.ExtendedLogger |
LOGGER |
static String |
OPTIONS
The options column header/JSON key.
|
static String |
ORDERED
The ordered column header/JSON key.
|
static String |
PERMIT_BREAKOFF
Whether breakoff is premitted for the survey as a whole.
|
static String |
QUESTION
The question column header/JSON key.
|
static String |
RANDOMIZE
The randomize column header/JSON key.
|
static String |
RESOURCE
Deprecated.
|
protected List<Block> |
topLevelBlocks
The top-level blocks in the survey.
|
Constructor and Description |
---|
AbstractParser() |
Modifier and Type | Method and Description |
---|---|
protected static void |
addPhantomBlocks(Map<String,Block> blockLookUp)
Creates intermediate blocks that may not have been explicitly specified.
|
protected static boolean |
boolType(String thing,
String col)
Returns the internal boolean representation of a boolean-valued input to CSV or JSON.
|
protected void |
initializeAllOneBlock(Survey survey)
Initializes a block-less survey as a survey of one block.
|
abstract Survey |
parse()
The main entry point.
|
protected static Boolean |
parseBool(Boolean bool,
String col,
String entry,
int lineNo,
int colNo)
Parses the boolean input and ensures that boolean values are consistent across option entries.
|
static SurveyDatum |
parseComponent(String contents,
int row,
int col,
int index)
Parses Question and Option column data into the internal representation.
|
protected void |
propagateBranchParadigm(Block b)
Traverses the structure of the block and its sub-blocks to ensure that the block/branch type is properly set.
|
protected void |
propagateBranchParadigms(Survey survey)
Iterates over the top-level blocks of the survey and calls
propagateBranchParadigm(edu.umass.cs.surveyman.survey.Block) . |
public static final HashMap<String,Boolean> defaultValues
public static final String QUESTION
public static final String BLOCK
public static final String OPTIONS
@Deprecated public static final String RESOURCE
public static final String EXCLUSIVE
true
.public static final String ORDERED
false
.public static final String RANDOMIZE
true
.public static final String BRANCH
public static final String FREETEXT
false
.public static final String CORRELATION
public static final String ANSWER
public static final String PERMIT_BREAKOFF
public static final String INPUT_SCHEMA
public static final String[] knownHeaders
public static final String CUSTOM_ID
protected static final org.apache.logging.log4j.spi.ExtendedLogger LOGGER
protected Map<String,Block> allBlockLookUp
protected static boolean boolType(String thing, String col) throws SurveyException
thing
- The raw text being parsed.col
- The associated column/key (used for debugging).SurveyException
protected static Boolean parseBool(Boolean bool, String col, String entry, int lineNo, int colNo) throws SurveyException
bool
- The Boolean whose data must be consistent across entries.col
- The column name.entry
- The data in that column.lineNo
- The line number (row) of the data.colNo
- The column position in the input.SurveyException
public static SurveyDatum parseComponent(String contents, int row, int col, int index)
contents
- The input data.row
- The line number (row) of the data.col
- The column position of the data.SurveyDatum
internal representation of the data.protected static void addPhantomBlocks(Map<String,Block> blockLookUp)
blockLookUp
- Map of all blocks.protected void propagateBranchParadigm(Block b) throws SurveyException
Block.BranchParadigm
for a detailed explanation of the block/branch
type lattice.b
- A block whose type needs to be set.SurveyException
protected void propagateBranchParadigms(Survey survey) throws SurveyException
propagateBranchParadigm(edu.umass.cs.surveyman.survey.Block)
.
See Block.BranchParadigm
for a detailed explanation of the block/branch
type lattice.survey
- A block whose type needs to be set.SurveyException
protected void initializeAllOneBlock(Survey survey)
survey
- A flat, fully randomizable survey.public abstract Survey parse() throws SurveyException
SurveyException
Copyright © 2015. All rights reserved.