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

Method parseLine

code/src/java/pcgen/persistence/lst/KitLoader.java:92–193  ·  view source on GitHub ↗
(LoadContext context, Kit target, String inputLine, SourceEntry source)

Source from the content-addressed store, hash-verified

90 }
91
92 @Override
93 public Kit parseLine(LoadContext context, Kit target, String inputLine, SourceEntry source)
94 throws PersistenceLayerException
95 {
96 if (inputLine.startsWith("STARTPACK:"))
97 {
98 if (target != null)
99 {
100 completeObject(context, source, target);
101 }
102 StringTokenizer st = new StringTokenizer(inputLine, "\t");
103 String firstToken = st.nextToken();
104 int colonLoc = firstToken.indexOf(':');
105 target = context.getReferenceContext().constructCDOMObject(Kit.class,
106 firstToken.substring(colonLoc + 1));
107 target.put(ObjectKey.SOURCE_CAMPAIGN, source.getCampaign());
108 target.setSourceURI(source.getURI());
109 context.addStatefulInformation(target);
110 while (st.hasMoreTokens())
111 {
112 String token = st.nextToken().trim();
113 int cLoc = token.indexOf(':');
114 if (cLoc == -1)
115 {
116 Logging.errorPrint("Invalid Token - " + "does not contain a colon: '" + token + "' on line :"
117 + inputLine + " in " + source.getURI());
118 continue;
119 }
120 else if (cLoc == 0)
121 {
122 Logging.errorPrint("Invalid Token - starts with a colon: '" + token + "' on line :" + inputLine
123 + " in " + source.getURI());
124 continue;
125 }
126
127 String key = token.substring(0, cLoc);
128 String value = (cLoc == token.length() - 1) ? null : token.substring(cLoc + 1);
129 if (context.processToken(target, key, value))
130 {
131 context.commit();
132 }
133 else
134 {
135 context.rollback();
136 Logging.replayParsedMessages();
137 }
138 }
139 }
140 else if (inputLine.startsWith("REGION:"))
141 {
142 String value = inputLine.substring(7);
143 context.clearStatefulInformation();
144 if (!value.isEmpty())
145 {
146 StringTokenizer st = new StringTokenizer(value, "\t");
147
148 String region = st.nextToken();
149 if (!region.equalsIgnoreCase(Constants.LST_NONE))

Callers

nothing calls this directly

Calls 15

errorPrintMethod · 0.95
replayParsedMessagesMethod · 0.95
clearParseMessagesMethod · 0.95
completeObjectMethod · 0.80
nextTokenMethod · 0.80
constructCDOMObjectMethod · 0.80
hasMoreTokensMethod · 0.80
trimMethod · 0.80
equalsIgnoreCaseMethod · 0.80
indexOfMethod · 0.65
getReferenceContextMethod · 0.65
putMethod · 0.65

Tested by

no test coverage detected