Class deals with COVER Token
| 36 | * Class deals with COVER Token |
| 37 | */ |
| 38 | public class CoverToken extends AbstractTokenWithSeparator<Campaign> |
| 39 | implements CDOMPrimaryToken<Campaign>, InstallLstToken |
| 40 | { |
| 41 | |
| 42 | @Override |
| 43 | public String getTokenName() |
| 44 | { |
| 45 | return "COVER"; |
| 46 | } |
| 47 | |
| 48 | @Override |
| 49 | public boolean parse(Campaign campaign, String value, URI sourceUri) |
| 50 | { |
| 51 | campaign.addToListFor(ListKey.FILE_COVER, CampaignSourceEntry.getNewCSE(campaign, sourceUri, value)); |
| 52 | return true; |
| 53 | } |
| 54 | |
| 55 | @Override |
| 56 | protected char separator() |
| 57 | { |
| 58 | return '|'; |
| 59 | } |
| 60 | |
| 61 | @Override |
| 62 | protected ParseResult parseTokenWithSeparator(LoadContext context, Campaign campaign, String value) |
| 63 | { |
| 64 | CampaignSourceEntry cse = context.getCampaignSourceEntry(campaign, value); |
| 65 | if (cse == null) |
| 66 | { |
| 67 | //Error |
| 68 | return ParseResult.INTERNAL_ERROR; |
| 69 | } |
| 70 | if (!cse.getIncludeItems().isEmpty()) |
| 71 | { |
| 72 | return new ParseResult.Fail(getTokenName() + " does not allow INCLUDE: " + value); |
| 73 | } |
| 74 | if (!cse.getExcludeItems().isEmpty()) |
| 75 | { |
| 76 | return new ParseResult.Fail(getTokenName() + " does not allow EXCLUDE: " + value); |
| 77 | } |
| 78 | context.getObjectContext().addToList(campaign, ListKey.FILE_COVER, cse); |
| 79 | return ParseResult.SUCCESS; |
| 80 | } |
| 81 | |
| 82 | @Override |
| 83 | public String[] unparse(LoadContext context, Campaign campaign) |
| 84 | { |
| 85 | Changes<CampaignSourceEntry> cseChanges = |
| 86 | context.getObjectContext().getListChanges(campaign, ListKey.FILE_COVER); |
| 87 | Collection<CampaignSourceEntry> added = cseChanges.getAdded(); |
| 88 | if (added == null) |
| 89 | { |
| 90 | //empty indicates no token |
| 91 | return null; |
| 92 | } |
| 93 | Set<String> set = new TreeSet<>(); |
| 94 | for (CampaignSourceEntry cse : added) |
| 95 | { |
nothing calls this directly
no outgoing calls
no test coverage detected