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;
}
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;
}
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;
}
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()]);
}
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()]);
}
Aggregations