MCPcopy Index your code
hub / github.com/antlr/codebuff / replaceEscapedRightAngle

Method replaceEscapedRightAngle

output/java8/1.4.17/Misc.java:142–168  ·  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

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

Callers

nothing calls this directly

Calls 3

toStringMethod · 0.65
lengthMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected