Parses the version information from a PCG file. @param line The line containing version information @throws PCGParseException if the line is not a valid version line
(final String line)
| 4451 | * @throws PCGParseException if the line is not a valid version line |
| 4452 | */ |
| 4453 | void parseVersionLine(final String line) throws PCGParseException |
| 4454 | { |
| 4455 | int[] version = {0, 0, 0}; |
| 4456 | |
| 4457 | // Check to make sure that this is a version line |
| 4458 | if (!line.startsWith(IOConstants.TAG_VERSION + IOConstants.TAG_END)) |
| 4459 | { |
| 4460 | throw new PCGParseException("parseVersionLine", line, "Not a Version Line."); //$NON-NLS-1$ |
| 4461 | } |
| 4462 | |
| 4463 | // extract the tokens from the version line |
| 4464 | String[] tokens = line.substring(IOConstants.TAG_VERSION.length() + 1).split("[ \\.-]", 4); //$NON-NLS-1$ |
| 4465 | |
| 4466 | for (int idx = 0; idx < 3 && idx < tokens.length; idx++) |
| 4467 | { |
| 4468 | |
| 4469 | try |
| 4470 | { |
| 4471 | version[idx] = Integer.parseInt(tokens[idx]); |
| 4472 | } |
| 4473 | catch (NumberFormatException e) |
| 4474 | { |
| 4475 | if (idx == 2 && (tokens[idx].startsWith("RC"))) |
| 4476 | { |
| 4477 | pcgenVersionSuffix = tokens[2]; |
| 4478 | } |
| 4479 | else |
| 4480 | { |
| 4481 | // Something in the first 3 digits was not an integer |
| 4482 | throw new PCGParseException("parseVersionLine", line, "Invalid PCGen version.", e); //$NON-NLS-1$ |
| 4483 | } |
| 4484 | } |
| 4485 | } |
| 4486 | if (tokens.length == 4) |
| 4487 | { |
| 4488 | pcgenVersionSuffix = tokens[3]; |
| 4489 | } |
| 4490 | pcgenVersion = version; |
| 4491 | } |
| 4492 | |
| 4493 | /* |
| 4494 | * ############################################################### |