Search in sources :

Example 76 with CampaignSourceEntry

use of pcgen.persistence.lst.CampaignSourceEntry in project pcgen by PCGen.

the class DataTableToken method parseTokenWithSeparator.

@Override
protected ParseResult parseTokenWithSeparator(LoadContext context, Campaign campaign, String value) {
    CampaignSourceEntry cse = context.getCampaignSourceEntry(campaign, value);
    if (cse == null) {
        //Error
        return ParseResult.INTERNAL_ERROR;
    }
    if (!cse.getIncludeItems().isEmpty()) {
        return new ParseResult.Fail(getTokenName() + " does not allow INCLUDE: " + value, context);
    }
    if (!cse.getExcludeItems().isEmpty()) {
        return new ParseResult.Fail(getTokenName() + " does not allow EXCLUDE: " + value, context);
    }
    context.getObjectContext().addToList(campaign, ListKey.FILE_DATATABLE, cse);
    return ParseResult.SUCCESS;
}
Also used : CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry)

Example 77 with CampaignSourceEntry

use of pcgen.persistence.lst.CampaignSourceEntry in project pcgen by PCGen.

the class DynamicToken method parseTokenWithSeparator.

@Override
protected ParseResult parseTokenWithSeparator(LoadContext context, Campaign campaign, String value) {
    CampaignSourceEntry cse = context.getCampaignSourceEntry(campaign, value);
    if (cse == null) {
        //Error
        return ParseResult.INTERNAL_ERROR;
    }
    if (!cse.getIncludeItems().isEmpty()) {
        return new ParseResult.Fail(getTokenName() + " does not support Include");
    }
    if (!cse.getExcludeItems().isEmpty()) {
        return new ParseResult.Fail(getTokenName() + " does not support Exclude");
    }
    if (!cse.getPrerequisites().isEmpty()) {
        return new ParseResult.Fail(getTokenName() + " does not support Prerequisites");
    }
    context.getObjectContext().addToList(campaign, ListKey.FILE_DYNAMIC, cse);
    return ParseResult.SUCCESS;
}
Also used : CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry)

Example 78 with CampaignSourceEntry

use of pcgen.persistence.lst.CampaignSourceEntry in project pcgen by PCGen.

the class LstexcludeToken method parseTokenWithSeparator.

@Override
protected ParseResult parseTokenWithSeparator(LoadContext context, Campaign campaign, String value) {
    final StringTokenizer lstTok = new StringTokenizer(value, Constants.PIPE);
    while (lstTok.hasMoreTokens()) {
        final String lstFilename = lstTok.nextToken();
        CampaignSourceEntry cse = context.getCampaignSourceEntry(campaign, lstFilename);
        if (cse == null) {
            //Error
            return ParseResult.INTERNAL_ERROR;
        }
        /*
			 * No need to check for cse.getIncludeItems or getExcludeItems as
			 * the use of pipe separator would have caused an error in fetching
			 * the CSE
			 */
        context.getObjectContext().addToList(campaign, ListKey.FILE_LST_EXCLUDE, cse);
    }
    return ParseResult.SUCCESS;
}
Also used : CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) StringTokenizer(java.util.StringTokenizer)

Example 79 with CampaignSourceEntry

use of pcgen.persistence.lst.CampaignSourceEntry in project pcgen by PCGen.

the class LstexcludeToken method unparse.

@Override
public String[] unparse(LoadContext context, Campaign campaign) {
    Changes<CampaignSourceEntry> cseChanges = context.getObjectContext().getListChanges(campaign, ListKey.FILE_LST_EXCLUDE);
    Collection<CampaignSourceEntry> added = cseChanges.getAdded();
    if (added == null) {
        //empty indicates no token
        return null;
    }
    Set<String> set = new TreeSet<>();
    for (CampaignSourceEntry cse : added) {
        set.add(cse.getLSTformat());
    }
    return set.toArray(new String[set.size()]);
}
Also used : CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) TreeSet(java.util.TreeSet)

Example 80 with CampaignSourceEntry

use of pcgen.persistence.lst.CampaignSourceEntry in project pcgen by PCGen.

the class PccToken method unparse.

@Override
public String[] unparse(LoadContext context, Campaign campaign) {
    Changes<CampaignSourceEntry> cseChanges = context.getObjectContext().getListChanges(campaign, ListKey.FILE_PCC);
    Collection<CampaignSourceEntry> added = cseChanges.getAdded();
    if (added == null) {
        // empty indicates no token
        return null;
    }
    Set<String> set = new TreeSet<>();
    for (CampaignSourceEntry uri : added) {
        set.add(uri.getLSTformat());
    }
    return set.toArray(new String[set.size()]);
}
Also used : CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) TreeSet(java.util.TreeSet)

Aggregations

CampaignSourceEntry (pcgen.persistence.lst.CampaignSourceEntry)95 URI (java.net.URI)54 Campaign (pcgen.core.Campaign)44 URISyntaxException (java.net.URISyntaxException)27 LoadContext (pcgen.rules.context.LoadContext)25 UnreachableError (pcgen.base.lang.UnreachableError)19 BeforeClass (org.junit.BeforeClass)16 PCClassLoader (pcgen.persistence.lst.PCClassLoader)15 TreeSet (java.util.TreeSet)12 PlayerCharacter (pcgen.core.PlayerCharacter)11 PersistenceLayerException (pcgen.persistence.PersistenceLayerException)11 ArrayList (java.util.ArrayList)9 PCClass (pcgen.core.PCClass)9 File (java.io.File)8 GenericLoader (pcgen.persistence.lst.GenericLoader)8 CDOMReference (pcgen.cdom.base.CDOMReference)7 SourceEntry (pcgen.persistence.lst.SourceEntry)7 Ability (pcgen.core.Ability)6 FeatLoader (pcgen.persistence.lst.FeatLoader)6 AbilityList (pcgen.cdom.list.AbilityList)5