MCPcopy Create free account
hub / github.com/antlr/codebuff / replaceEscapedRightAngle

Method replaceEscapedRightAngle

output/java8/1.4.12/Misc.java:144–170  ·  view source on GitHub ↗

Replace >\> with >> in s. Replace \>> unless prefix of \>>> with >>. Do NOT replace if it's <\\>

(String s)

Source from the content-addressed store, hash-verified

142 */
143
144 public static String replaceEscapedRightAngle(String s) {
145 StringBuilder buf = new StringBuilder();
146 int i = 0;
147 while ( i < s.length() ) {
148 char c = s.charAt(i);
149 if ( c=='<'&& s.substring(i).startsWith("<\\\\>") ) {
150 buf.append("<\\\\>");
151 i += "<\\\\>".length();
152 continue;
153 }
154
155 if ( c=='>'&& s.substring(i).startsWith(">\\>") ) {
156 buf.append(">>");
157 i += ">\\>".length();
158 continue;
159 }
160
161 if ( c=='\\'&& s.substring(i).startsWith("\\>>") && !s.substring(i).startsWith("\\>>>") ) {
162 buf.append(">>");
163 i += "\\>>".length();
164 continue;
165 }
166 buf.append(c);
167 i++;
168 }
169 return buf.toString();
170 }
171
172 public static boolean urlExists(URL url) {
173 try {

Callers

nothing calls this directly

Calls 3

toStringMethod · 0.65
lengthMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected