Search in sources :

Example 1 with DatasetVariable

use of pcgen.cdom.content.DatasetVariable in project pcgen by PCGen.

the class VariableLoader method parseLine.

public final void parseLine(LoadContext context, String lstLine, SourceEntry source) throws PersistenceLayerException {
    final StringTokenizer colToken = new StringTokenizer(lstLine, SystemLoader.TAB_DELIM);
    //Need the IF so that it is not an empty line causing issues
    if (colToken.hasMoreTokens()) {
        String tok = colToken.nextToken().intern();
        if (tok.indexOf(':') == -1) {
            tok = "GLOBAL:" + tok;
        }
        DatasetVariable po = new DatasetVariable();
        boolean success = LstUtils.processToken(context, po, source, tok);
        if (!success) {
            Logging.errorPrint("Failed to parse first token on Variable Line: " + "ignoring rest of line");
            return;
        }
        po.setSourceURI(source.getURI());
        while (colToken.hasMoreTokens()) {
            LstUtils.processToken(context, po, source, colToken.nextToken());
        }
    }
}
Also used : StringTokenizer(java.util.StringTokenizer) DatasetVariable(pcgen.cdom.content.DatasetVariable)

Example 2 with DatasetVariable

use of pcgen.cdom.content.DatasetVariable in project pcgen by PCGen.

the class ExplanationTokenTest method testDisplayNameRequired.

@Test
public void testDisplayNameRequired() throws PersistenceLayerException {
    DatasetVariable dv = new DatasetVariable();
    ParseResult pr = token.parseToken(primaryContext, dv, "Try Me!");
    assertFalse(pr.passed());
    assertNoSideEffects();
}
Also used : DatasetVariable(pcgen.cdom.content.DatasetVariable) ParseResult(pcgen.rules.persistence.token.ParseResult) Test(org.junit.Test)

Example 3 with DatasetVariable

use of pcgen.cdom.content.DatasetVariable in project pcgen by PCGen.

the class GlobalTokenTest method testDisplayNameProhibited.

@Test
public void testDisplayNameProhibited() throws PersistenceLayerException {
    DatasetVariable dv = new DatasetVariable();
    dv.setName("FirstName");
    ParseResult pr = token.parseToken(primaryContext, dv, "VarName");
    assertFalse(pr.passed());
    assertNoSideEffects();
}
Also used : DatasetVariable(pcgen.cdom.content.DatasetVariable) ParseResult(pcgen.rules.persistence.token.ParseResult) Test(org.junit.Test)

Example 4 with DatasetVariable

use of pcgen.cdom.content.DatasetVariable in project pcgen by PCGen.

the class LocalTokenTest method testInvalidDupeVarName.

@Test
public void testInvalidDupeVarName() throws PersistenceLayerException {
    DatasetVariable dv = new DatasetVariable();
    ParseResult pr = token.parseToken(primaryContext, dv, "EQUIPMENT|MyVar");
    assertTrue(pr.passed());
    assertFalse(parse("EQUIPMENT|STRING=MyVar"));
    assertNoSideEffects();
}
Also used : DatasetVariable(pcgen.cdom.content.DatasetVariable) ParseResult(pcgen.rules.persistence.token.ParseResult) Test(org.junit.Test)

Example 5 with DatasetVariable

use of pcgen.cdom.content.DatasetVariable in project pcgen by PCGen.

the class LocalTokenTest method testDisplayNameProhibited.

@Test
public void testDisplayNameProhibited() throws PersistenceLayerException {
    DatasetVariable dv = new DatasetVariable();
    dv.setName("FirstName");
    ParseResult pr = token.parseToken(primaryContext, dv, "VarName");
    assertFalse(pr.passed());
    assertNoSideEffects();
}
Also used : DatasetVariable(pcgen.cdom.content.DatasetVariable) ParseResult(pcgen.rules.persistence.token.ParseResult) Test(org.junit.Test)

Aggregations

DatasetVariable (pcgen.cdom.content.DatasetVariable)6 Test (org.junit.Test)5 ParseResult (pcgen.rules.persistence.token.ParseResult)5 StringTokenizer (java.util.StringTokenizer)1