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

Method decode

code/src/java/pcgen/io/EntityEncoder.java:83–125  ·  view source on GitHub ↗

decode characters. {@literal "\n" <- "&nl;" "\r" <- "&cr;" "\f" <- "&lf;" ":" <- "&colon;" "|" <- "&pipe;" "[" <- "&lbracket;" "]" <- "&rbracket;" "&" <- "&amp;" } author: Thomas Behr 09-09-02 @param s the String to decode @return the decoded String

(String s)

Source from the content-addressed store, hash-verified

81 * @return the decoded String
82 */
83 public static String decode(String s)
84 {
85 final StringBuilder buffer = new StringBuilder();
86 final StringTokenizer tokens = new StringTokenizer(s, "&;", true);
87
88 while (tokens.hasMoreTokens())
89 {
90 String cToken = tokens.nextToken();
91
92 if ("&".equals(cToken))
93 {
94 String tok1 = null;
95 String tok2 = null;
96
97 try
98 {
99 tok1 = tokens.nextToken();
100 tok2 = tokens.nextToken();
101 buffer.append(ENTITIES.get(cToken + tok1 + tok2));
102 }
103 catch (NoSuchElementException exc)
104 {
105 buffer.append(cToken);
106
107 if (tok1 != null)
108 {
109 buffer.append(tok1);
110
111 if (tok2 != null)
112 {
113 buffer.append(tok2);
114 }
115 }
116 }
117 }
118 else
119 {
120 buffer.append(cToken);
121 }
122 }
123
124 return buffer.toString();
125 }
126
127 /**
128 * encode characters.

Callers 15

parseNonEmptyTokenMethod · 0.95
parseAspectMethod · 0.95
parseNonEmptyTokenMethod · 0.95
parseBirthdayLineMethod · 0.95
parseBirthplaceLineMethod · 0.95
parseCatchPhraseLineMethod · 0.95

Calls 6

hasMoreTokensMethod · 0.80
nextTokenMethod · 0.80
equalsMethod · 0.65
getMethod · 0.65
toStringMethod · 0.65
appendMethod · 0.45