📄 nativestring.java
字号:
} // split target with separator or re int[] ip = { 0 }; int match; int len = 0; boolean[] matched = { false }; String[][] parens = { null }; int version = cx.getLanguageVersion(); while ((match = find_split(cx, scope, target, separator, version, reProxy, re, ip, matchlen, matched, parens)) >= 0) { if ((limited && len >= limit) || (match > target.length())) break; String substr; if (target.length() == 0) substr = target; else substr = target.substring(ip[0], match); result.put(len, result, substr); len++; /* * Imitate perl's feature of including parenthesized substrings * that matched part of the delimiter in the new array, after the * split substring that was delimited. */ if (re != null && matched[0] == true) { int size = parens[0].length; for (int num = 0; num < size; num++) { if (limited && len >= limit) break; result.put(len, result, parens[0][num]); len++; } matched[0] = false; } ip[0] = match + matchlen[0]; if (version < Context.VERSION_1_3 && version != Context.VERSION_DEFAULT) { /* * Deviate from ECMA to imitate Perl, which omits a final * split unless a limit argument is given and big enough. */ if (!limited && ip[0] == target.length()) break; } } return result; } /* * See ECMA 15.5.4.15 */ private static String js_substring(Context cx, String target, Object[] args) { int length = target.length(); double start = ScriptRuntime.toInteger(args, 0); double end; if (start < 0) start = 0; else if (start > length) start = length; if (args.length <= 1 || args[1] == Undefined.instance) { end = length; } else { end = ScriptRuntime.toInteger(args[1]); if (end < 0) end = 0; else if (end > length) end = length; // swap if end < start if (end < start) { if (cx.getLanguageVersion() != Context.VERSION_1_2) { double temp = start; start = end; end = temp; } else { // Emulate old JDK1.0 java.lang.String.substring() end = start; } } } return target.substring((int)start, (int)end); } int getLength() { return string.length(); } /* * Non-ECMA methods. */ private static String js_substr(String target, Object[] args) { if (args.length < 1) return target; double begin = ScriptRuntime.toInteger(args[0]); double end; int length = target.length(); if (begin < 0) { begin += length; if (begin < 0) begin = 0; } else if (begin > length) { begin = length; } if (args.length == 1) { end = length; } else { end = ScriptRuntime.toInteger(args[1]); if (end < 0) end = 0; end += begin; if (end > length) end = length; } return target.substring((int)begin, (int)end); } /* * Python-esque sequence operations. */ private static String js_concat(String target, Object[] args) { int N = args.length; if (N == 0) { return target; } else if (N == 1) { String arg = ScriptRuntime.toString(args[0]); return target.concat(arg); } // Find total capacity for the final string to avoid unnecessary // re-allocations in StringBuffer int size = target.length(); String[] argsAsStrings = new String[N]; for (int i = 0; i != N; ++i) { String s = ScriptRuntime.toString(args[i]); argsAsStrings[i] = s; size += s.length(); } StringBuffer result = new StringBuffer(size); result.append(target); for (int i = 0; i != N; ++i) { result.append(argsAsStrings[i]); } return result.toString(); } private static String js_slice(String target, Object[] args) { if (args.length != 0) { double begin = ScriptRuntime.toInteger(args[0]); double end; int length = target.length(); if (begin < 0) { begin += length; if (begin < 0) begin = 0; } else if (begin > length) { begin = length; } if (args.length == 1) { end = length; } else { end = ScriptRuntime.toInteger(args[1]); if (end < 0) { end += length; if (end < 0) end = 0; } else if (end > length) { end = length; } if (end < begin) end = begin; } return target.substring((int)begin, (int)end); } return target; }// #string_id_map# protected int findPrototypeId(String s) { int id;// #generated# Last update: 2007-05-01 22:11:49 EDT L0: { id = 0; String X = null; int c; L: switch (s.length()) { case 3: c=s.charAt(2); if (c=='b') { if (s.charAt(0)=='s' && s.charAt(1)=='u') {id=Id_sub; break L0;} } else if (c=='g') { if (s.charAt(0)=='b' && s.charAt(1)=='i') {id=Id_big; break L0;} } else if (c=='p') { if (s.charAt(0)=='s' && s.charAt(1)=='u') {id=Id_sup; break L0;} } break L; case 4: c=s.charAt(0); if (c=='b') { X="bold";id=Id_bold; } else if (c=='l') { X="link";id=Id_link; } break L; case 5: switch (s.charAt(4)) { case 'd': X="fixed";id=Id_fixed; break L; case 'e': X="slice";id=Id_slice; break L; case 'h': X="match";id=Id_match; break L; case 'k': X="blink";id=Id_blink; break L; case 'l': X="small";id=Id_small; break L; case 't': X="split";id=Id_split; break L; } break L; case 6: switch (s.charAt(1)) { case 'e': X="search";id=Id_search; break L; case 'h': X="charAt";id=Id_charAt; break L; case 'n': X="anchor";id=Id_anchor; break L; case 'o': X="concat";id=Id_concat; break L; case 'q': X="equals";id=Id_equals; break L; case 't': X="strike";id=Id_strike; break L; case 'u': X="substr";id=Id_substr; break L; } break L; case 7: switch (s.charAt(1)) { case 'a': X="valueOf";id=Id_valueOf; break L; case 'e': X="replace";id=Id_replace; break L; case 'n': X="indexOf";id=Id_indexOf; break L; case 't': X="italics";id=Id_italics; break L; } break L; case 8: c=s.charAt(4); if (c=='r') { X="toString";id=Id_toString; } else if (c=='s') { X="fontsize";id=Id_fontsize; } else if (c=='u') { X="toSource";id=Id_toSource; } break L; case 9: c=s.charAt(0); if (c=='f') { X="fontcolor";id=Id_fontcolor; } else if (c=='s') { X="substring";id=Id_substring; } break L; case 10: X="charCodeAt";id=Id_charCodeAt; break L; case 11: switch (s.charAt(2)) { case 'L': X="toLowerCase";id=Id_toLowerCase; break L; case 'U': X="toUpperCase";id=Id_toUpperCase; break L; case 'n': X="constructor";id=Id_constructor; break L; case 's': X="lastIndexOf";id=Id_lastIndexOf; break L; } break L; case 13: X="localeCompare";id=Id_localeCompare; break L; case 16: X="equalsIgnoreCase";id=Id_equalsIgnoreCase; break L; case 17: c=s.charAt(8); if (c=='L') { X="toLocaleLowerCase";id=Id_toLocaleLowerCase; } else if (c=='U') { X="toLocaleUpperCase";id=Id_toLocaleUpperCase; } break L; } if (X!=null && X!=s && !X.equals(s)) id = 0; break L0; }// #/generated# return id; } private static final int ConstructorId_fromCharCode = -1, Id_constructor = 1, Id_toString = 2, Id_toSource = 3, Id_valueOf = 4, Id_charAt = 5, Id_charCodeAt = 6, Id_indexOf = 7, Id_lastIndexOf = 8, Id_split = 9, Id_substring = 10, Id_toLowerCase = 11, Id_toUpperCase = 12, Id_substr = 13, Id_concat = 14, Id_slice = 15, Id_bold = 16, Id_italics = 17, Id_fixed = 18, Id_strike = 19, Id_small = 20, Id_big = 21, Id_blink = 22, Id_sup = 23, Id_sub = 24, Id_fontsize = 25, Id_fontcolor = 26, Id_link = 27, Id_anchor = 28, Id_equals = 29, Id_equalsIgnoreCase = 30, Id_match = 31, Id_search = 32, Id_replace = 33, Id_localeCompare = 34, Id_toLocaleLowerCase = 35, Id_toLocaleUpperCase = 36, MAX_PROTOTYPE_ID = 36;// #/string_id_map# private static final int ConstructorId_charAt = -Id_charAt, ConstructorId_charCodeAt = -Id_charCodeAt, ConstructorId_indexOf = -Id_indexOf, ConstructorId_lastIndexOf = -Id_lastIndexOf, ConstructorId_split = -Id_split, ConstructorId_substring = -Id_substring, ConstructorId_toLowerCase = -Id_toLowerCase, ConstructorId_toUpperCase = -Id_toUpperCase, ConstructorId_substr = -Id_substr, ConstructorId_concat = -Id_concat, ConstructorId_slice = -Id_slice, ConstructorId_equalsIgnoreCase = -Id_equalsIgnoreCase, ConstructorId_match = -Id_match, ConstructorId_search = -Id_search, ConstructorId_replace = -Id_replace, ConstructorId_localeCompare = -Id_localeCompare, ConstructorId_toLocaleLowerCase = -Id_toLocaleLowerCase; private String string;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -