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

Method createComment

code/src/java/pcgen/io/PCGVer2Creator.java:2539–2571  ·  view source on GitHub ↗

Convenience Method author: Thomas Behr 19-03-02 @param s the String which will be converted into a comment; i.e. '#','\r' will be removed, '\t','\f' will be replaced with ' ', and each line will start with "# " @return the newly created comment

(String s)

Source from the content-addressed store, hash-verified

2537 * @return the newly created comment
2538 */
2539 private static String createComment(String s)
2540 {
2541 String work = s + IOConstants.LINE_SEP;
2542 work = work.replace('\t', ' ');
2543 work = work.replace('\f', ' ');
2544
2545 StringBuilder buffer = new StringBuilder(work.length() + 100);
2546 StringTokenizer tokens = new StringTokenizer(work, "#"); //$NON-NLS-1$
2547
2548 while (tokens.hasMoreTokens())
2549 {
2550 buffer.append(tokens.nextToken());
2551 }
2552
2553 work = buffer.toString();
2554
2555 buffer.setLength(0);
2556
2557 /*
2558 * Need to keep the Windows line separator as newline delimiter to ensure
2559 * cross-platform portability.
2560 *
2561 * author: Thomas Behr 2002-11-13
2562 */
2563 tokens = new StringTokenizer(work, "\r\n"); //$NON-NLS-1$
2564
2565 while (tokens.hasMoreTokens())
2566 {
2567 buffer.append("# ").append(tokens.nextToken()).append(IOConstants.LINE_SEP); //$NON-NLS-1$
2568 }
2569
2570 return buffer.toString();
2571 }
2572
2573 /**
2574 * creates a unique tuple based on the creator and target getName()

Callers 1

appendCommentMethod · 0.95

Calls 5

hasMoreTokensMethod · 0.80
nextTokenMethod · 0.80
toStringMethod · 0.65
replaceMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected