MCPcopy Create free account
hub / github.com/PCGen/pcgen / parseLine

Method parseLine

code/src/java/pcgen/persistence/lst/AbilityLoader.java:39–112  ·  view source on GitHub ↗
(LoadContext context, Ability ability, String lstLine, SourceEntry source)

Source from the content-addressed store, hash-verified

37 private static final Class<AbilityCategory> ABILITY_CATEGORY_CLASS = AbilityCategory.class;
38
39 @Override
40 public Ability parseLine(LoadContext context, Ability ability, String lstLine, SourceEntry source)
41 throws PersistenceLayerException
42 {
43 Ability anAbility = ability;
44
45 boolean isnew = false;
46 if (anAbility == null)
47 {
48 anAbility = new Ability();
49 isnew = true;
50 }
51
52 final StringTokenizer colToken = new StringTokenizer(lstLine, SystemLoader.TAB_DELIM);
53
54 if (colToken.hasMoreTokens())
55 {
56 anAbility.setName(colToken.nextToken());
57 anAbility.put(ObjectKey.SOURCE_CAMPAIGN, source.getCampaign());
58 anAbility.setSourceURI(source.getURI());
59 List<String> additionalTokens = new ArrayList<>();
60 boolean foundCategory = false;
61 while (colToken.hasMoreTokens())
62 {
63 String token = colToken.nextToken();
64 if (token.startsWith("CATEGORY:"))
65 {
66 if (foundCategory)
67 {
68 Logging.errorPrint("Ignoring CATEGORY which appeared twice on original line of an Ability ("
69 + anAbility.getDisplayName() + ")", context);
70 continue;
71 }
72 foundCategory = true;
73 if (isnew)
74 {
75 final Category<Ability> cat = context.getReferenceContext()
76 .silentlyGetConstructedCDOMObject(ABILITY_CATEGORY_CLASS, token.substring(9));
77 if (cat == null)
78 {
79 Logging.errorPrint("Ignoring Ability " + anAbility.getKeyName()
80 + ", due to: Cannot find Ability Category: " + token.substring(9), context);
81 break;
82 }
83 else
84 {
85 anAbility.setCDOMCategory(cat);
86 }
87 }
88 else
89 {
90 Logging.errorPrint("Ignoring CATEGORY which is not on original line of an Ability ("
91 + anAbility.getDisplayName() + ")", context);
92 }
93 }
94 else
95 {
96 additionalTokens.add(token);

Callers 3

testNoChoiceBonusMethod · 0.95
testNoSubsChoiceBonusMethod · 0.95

Calls 15

errorPrintMethod · 0.95
setCDOMCategoryMethod · 0.95
processTokenMethod · 0.95
hasMoreTokensMethod · 0.80
nextTokenMethod · 0.80
importObjectMethod · 0.80
completeObjectMethod · 0.80
setNameMethod · 0.65
putMethod · 0.65
getCampaignMethod · 0.65
setSourceURIMethod · 0.65

Tested by 3

testNoChoiceBonusMethod · 0.76
testNoSubsChoiceBonusMethod · 0.76