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

Method replaceEscapedRightAngle

output/java/1.4.17/Misc.java:146–173  ·  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("\\>>") &&
164 !s.substring(i).startsWith("\\>>>") ) {
165 buf.append(">>");
166 i += "\\>>".length();
167 continue;
168 }
169 buf.append(c);
170 i++;
171 }
172 return buf.toString();
173 }
174
175 public static boolean urlExists(URL url) {
176 try {

Callers

nothing calls this directly

Calls 3

toStringMethod · 0.65
lengthMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected