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

Method createFromLst

code/src/java/pcgen/core/SpecialProperty.java:48–110  ·  view source on GitHub ↗
(final String input)

Source from the content-addressed store, hash-verified

46 //It really shouldn't be in the core layer, but it's this, or have the same code in 10 places.....
47 //TODO: get this into the persistance layer
48 public static SpecialProperty createFromLst(final String input)
49 {
50 final StringTokenizer tok = new StringTokenizer(input, Constants.PIPE, false);
51 final SpecialProperty sp = new SpecialProperty();
52
53 if (!tok.hasMoreTokens())
54 {
55 return sp;
56 }
57
58 String spName = tok.nextToken();
59 if (PreParserFactory.isPreReqString(spName))
60 {
61 Logging.errorPrint("Leading PRExxx found in SPROP: " + input);
62 return null;
63 }
64
65 StringBuilder sb = new StringBuilder(100);
66 sb.append(spName);
67 boolean hitPre = false;
68 boolean warnedPre = false;
69 while (tok.hasMoreTokens())
70 {
71 final String cString = tok.nextToken();
72
73 // Check to see if it's a PRExxx: tag
74 if (PreParserFactory.isPreReqString(cString))
75 {
76 hitPre = true;
77 try
78 {
79 final PreParserFactory factory = PreParserFactory.getInstance();
80 final Prerequisite prereq = factory.parse(cString);
81 sp.addPrerequisite(prereq);
82 }
83 catch (PersistenceLayerException ple)
84 {
85 Logging.errorPrint(ple.getMessage(), ple);
86 return null;
87 }
88 }
89 else
90 {
91 if (hitPre && !warnedPre)
92 {
93 warnedPre = true;
94 Logging.deprecationPrint("Found PRExxx in middle of" + "SPROP value: " + input);
95 Logging.deprecationPrint("PRExxx should be at the end");
96 }
97 sb.append(Constants.PIPE);
98 sb.append(cString);
99 }
100
101 if (Constants.LST_DOT_CLEAR.equals(cString))
102 {
103 Logging.errorPrint("Invalid/Embedded .CLEAR found in SPROP: " + input);
104 return null;
105 }

Callers 7

getConstantMethod · 0.95
setNameMethod · 0.95
setSPropMethod · 0.95
loadMethod · 0.95

Calls 13

isPreReqStringMethod · 0.95
errorPrintMethod · 0.95
getInstanceMethod · 0.95
parseMethod · 0.95
deprecationPrintMethod · 0.95
hasMoreTokensMethod · 0.80
nextTokenMethod · 0.80
addPrerequisiteMethod · 0.65
getMessageMethod · 0.65
equalsMethod · 0.65
setNameMethod · 0.65
toStringMethod · 0.65

Tested by 1

getConstantMethod · 0.76