MCPcopy Index your code
hub / github.com/PCGen/pcgen / parseLine

Method parseLine

code/src/java/pcgen/persistence/lst/LevelLoader.java:54–129  ·  view source on GitHub ↗

Parse the line from the level.lst file, populating the levelInfo object with the info found. @param gameMode the game mode @param inputLine The line to be parsed @param lineNum The number of the line being parsed.

(GameMode gameMode, String inputLine, int lineNum, URI source, String xpTable)

Source from the content-addressed store, hash-verified

52 * @param lineNum The number of the line being parsed.
53 */
54 public static String parseLine(GameMode gameMode, String inputLine, int lineNum, URI source, String xpTable)
55 {
56 if (gameMode == null)
57 {
58 return "";
59 }
60
61 // Deal with the start of a new XPTable definition
62 if (inputLine.startsWith("XPTABLE:"))
63 {
64 String value = inputLine.substring(8);
65 if (value.indexOf('\t') >= 0)
66 {
67 value = value.substring(0, value.indexOf('\t'));
68 }
69 value = value.trim();
70 if (value.equals(""))
71 {
72 Logging.errorPrint("Error parsing level line \"" + inputLine + "\": empty XPTABLE value.");
73 }
74 else
75 {
76 gameMode.addXPTableName(value);
77 return value;
78 }
79 }
80
81 // Provide a default fallback table name for backwards compatibility
82 if (xpTable.equals(""))
83 {
84 xpTable = "Default";
85 gameMode.addXPTableName(xpTable);
86 }
87
88 final LevelInfo levelInfo = new LevelInfo();
89 final StringTokenizer colToken = new StringTokenizer(inputLine, SystemLoader.TAB_DELIM);
90
91 Map<String, LstToken> tokenMap = TokenStore.inst().getTokenMap(LevelLstToken.class);
92 while (colToken.hasMoreTokens())
93 {
94 final String colString = colToken.nextToken().trim();
95
96 final int idxColon = colString.indexOf(':');
97 String key = "";
98 try
99 {
100 key = colString.substring(0, idxColon);
101 }
102 catch (StringIndexOutOfBoundsException e)
103 {
104 // TODO Handle Exception
105 }
106 LevelLstToken token = (LevelLstToken) tokenMap.get(key);
107
108 if (token != null)
109 {
110 final String value = colString.substring(idxColon + 1);
111 LstUtils.deprecationCheck(token, levelInfo.getLevelString(), source, value);

Callers 2

loadGameModeInfoFileMethod · 0.95
classSetUpMethod · 0.95

Calls 15

errorPrintMethod · 0.95
instMethod · 0.95
deprecationCheckMethod · 0.95
getLevelStringMethod · 0.95
parseMethod · 0.95
validateLevelInfoMethod · 0.95
trimMethod · 0.80
addXPTableNameMethod · 0.80
getTokenMapMethod · 0.80
hasMoreTokensMethod · 0.80
nextTokenMethod · 0.80
indexOfMethod · 0.65

Tested by 1

classSetUpMethod · 0.76