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

Method replaceEscapedRightAngle

output/java/1.4.13/Misc.java:146–172  ·  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

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

Callers

nothing calls this directly

Calls 3

toStringMethod · 0.65
lengthMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected