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

Method sourceElementToString

code/src/java/pcgen/io/PCGVer2Parser.java:5260–5302  ·  view source on GitHub ↗
(final PCGElement source)

Source from the content-addressed store, hash-verified

5258 * DEITY=deityname|totallevels
5259 */
5260 private static String sourceElementToString(final PCGElement source)
5261 {
5262 String type = Constants.EMPTY_STRING;
5263 String name = Constants.EMPTY_STRING;
5264 String level = Constants.EMPTY_STRING;
5265 String defined = Constants.EMPTY_STRING;
5266
5267 for (PCGElement child : source.getChildren())
5268 {
5269 final String tag = child.getName();
5270
5271 if (IOConstants.TAG_TYPE.equals(tag))
5272 {
5273 type = child.getText();
5274 }
5275 else if (IOConstants.TAG_NAME.equals(tag))
5276 {
5277 name = child.getText();
5278 }
5279 else if (IOConstants.TAG_LEVEL.equals(tag))
5280 {
5281 level = child.getText();
5282 }
5283 else if (IOConstants.TAG_DEFINED.equals(tag))
5284 {
5285 defined = child.getText().toUpperCase();
5286 }
5287 }
5288
5289 //TODO:gorm - guestimate good starting buffer size
5290 final StringBuilder buffer = new StringBuilder(1000);
5291 buffer.append(type);
5292 buffer.append((IOConstants.VALUE_Y.equals(defined)) ? '=' : '|');
5293 buffer.append(name);
5294
5295 if (!Constants.EMPTY_STRING.equals(level))
5296 {
5297 buffer.append('|');
5298 buffer.append(level);
5299 }
5300
5301 return buffer.toString();
5302 }
5303
5304 /*
5305 * ###############################################################

Callers 1

parseDomainLineMethod · 0.95

Calls 6

getChildrenMethod · 0.65
getNameMethod · 0.65
equalsMethod · 0.65
toStringMethod · 0.65
getTextMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected