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

Method parseVersionLine

code/src/java/pcgen/io/PCGVer2Parser.java:4453–4491  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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 * ###############################################################

Callers 12

test_1045596_1Method · 0.95
test_1045596_2Method · 0.95
test_1045596_3Method · 0.95
test_1045596_4Method · 0.95
test_1045596_5Method · 0.95
test_1045596_6Method · 0.95
test_1045596_7Method · 0.95
test_1045596_8Method · 0.95
testCurrVersionMethod · 0.95
testCompareVersionToMethod · 0.95
parcePCGSourceOnlyMethod · 0.95
parseCachedLinesMethod · 0.95

Calls 2

parseIntMethod · 0.80
splitMethod · 0.45

Tested by 10

test_1045596_1Method · 0.76
test_1045596_2Method · 0.76
test_1045596_3Method · 0.76
test_1045596_4Method · 0.76
test_1045596_5Method · 0.76
test_1045596_6Method · 0.76
test_1045596_7Method · 0.76
test_1045596_8Method · 0.76
testCurrVersionMethod · 0.76
testCompareVersionToMethod · 0.76