⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 charset.java

📁 java源代码 请看看啊 提点宝贵的意见
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
                    ++i;                }                if (i < chars.length() && i % 2 == 0 && c2.charAt(j) == chars.charAt(i)) {                    ++i;                }            }        }        return result;    }    /**     * Returns a CharSet containing all the characters in "this" that     * aren't also in "that"     */    public CharSet difference(CharSet that) {        return new CharSet(doIntersection(that.doComplement().toString()).toString());    }    /**     * Removes from "this" all the characters that are also in "that"     */    private void internalDifference(CharSet that) {        chars = doIntersection(that.doComplement().toString()).toString();    }    /**     * Returns a CharSet containing all the characters which are not     * in "this"     */    public CharSet complement() {        return new CharSet(doComplement().toString());    }    /**     * Complements "this".  All the characters it contains are removed,     * and all the characters it doesn't contain are added.     */    private void internalComplement() {        chars = doComplement().toString();    }    /**     * The internal implementation function for the complement routines     */    private StringBuffer doComplement() {        // the complement of an empty CharSet is one containing everything        if (empty()) {            return new StringBuffer("\u0000\uffff");        }        StringBuffer result = new StringBuffer();        int i = 0;        // the result begins with \u0000 unless the original CharSet does        if (chars.charAt(0) != '\u0000') {            result.append('\u0000');        }        // walk through the characters in this CharSet.  Append a pair of        // characters the first of which is one less than the first        // character we see and the second of which is one plus the second        // character we see (don't write the first character if it's \u0000,        // and don't write the second character if it's \uffff.        while (i < chars.length()) {            if (chars.charAt(i) != '\u0000') {                result.append((char)(chars.charAt(i) - 1));            }            if (chars.charAt(i + 1) != '\uffff') {                result.append((char)(chars.charAt(i + 1) + 1));            }            i += 2;        }        // add \uffff to the end of the result, unless it was in        // the original set        if (chars.charAt(chars.length() - 1) != '\uffff') {            result.append('\uffff');        }        return result;    }    /**     * Returns true if this CharSet contains the specified character     * @param c The character we're testing for set membership     */    public boolean contains(char c) {        // search for the first range endpoint that is greater than or        // equal to c        int i = 1;        while (i < chars.length() && chars.charAt(i) < c) {            i += 2;        }        // if we've walked off the end, we don't contain c        if (i == chars.length()) {            return false;        }        // otherwise, we contain c if the beginning of the range is less        // than or equal to c        return chars.charAt(i - 1) <= c;    }    /**     * Returns true if "that" is another instance of CharSet containing     * the exact same characters as this one     */    public boolean equals(Object that) {        return (that instanceof CharSet) && chars.equals(((CharSet)that).chars);    }    /**     * Creates a new CharSet that is equal to this one     */    public Object clone() {        return new CharSet(chars);    }    /**     * Returns true if this CharSet contains no characters     */    public boolean empty() {        return chars.length() == 0;    }    /**     * Returns a textual representation of this CharSet.  If the result     * of calling this function is passed to CharSet.parseString(), it     * will produce another CharSet that is equal to this one.     */    public String toString() {        StringBuffer result = new StringBuffer();        // the result begins with an opening bracket        result.append('[');        // iterate through the ranges in the CharSet        for (int i = 0; i < chars.length(); i += 2) {            // for a range with the same beginning and ending point,            // output that character            if (chars.charAt(i) == chars.charAt(i + 1)) {                result.append(chars.charAt(i));            }            // otherwise, output the start and end points of the range            // separated by a dash            else {                result.append(chars.charAt(i) + "-" + chars.charAt(i + 1));            }        }        // the result ends with a closing bracket        result.append(']');        return result.toString();    }    /**     * Returns a String representing the contents of this CharSet     * in the same form in which they're stored internally: as pairs     * of characters representing the start and end points of ranges     */    public String getRanges() {        return chars;    }    /**     * Returns an Enumeration that will return the ranges of characters     * contained in this CharSet one at a time     */    public Enumeration getChars() {        return new Enumeration(this);    }    //==========================================================================    // CharSet.Enumeration    //==========================================================================    /**     * An Enumeration that can be used to extract the character ranges     * from a CharSet one at a time     */    public class Enumeration implements java.util.Enumeration {        /**         * Initializes a CharSet.Enumeration         */        Enumeration(CharSet cs) {            this.chars = cs.chars;            p = 0;        }        /**         * Returns true if the enumeration hasn't yet returned         * all the ranges in the CharSet         */        public boolean hasMoreElements() {            return p < chars.length();        }        /**         * Returns the next range in the CarSet         */        public Object nextElement() {            char[] result = new char[2];            result[0] = chars.charAt(p);            result[1] = chars.charAt(p + 1);            p += 2;            return result;        }        int p;        String chars;    }    //==========================================================================    // tables for charSetForCategory()    //==========================================================================    /**     * Table used with charSetFromCategory.  This is an array of pairs     * of Strings.  The first column of Strings is Unicode character category     * codes as defined in the Unicode database.  The second column is the     * internal storage for a CharSet containing the characters in that     * category.     */    private static final String[][] categoryMap = {        { "Ll", "az\u00AA\u00AA\u00B5\u00B5\u00BA\u00BA\u00DF\u00F6\u00F8"          + "\u00FF\u0101\u0101\u0103\u0103\u0105\u0105\u0107\u0107\u0109"          + "\u0109\u010B\u010B\u010D\u010D\u010F\u010F\u0111\u0111\u0113"          + "\u0113\u0115\u0115\u0117\u0117\u0119\u0119\u011B\u011B\u011D"          + "\u011D\u011F\u011F\u0121\u0121\u0123\u0123\u0125\u0125\u0127"          + "\u0127\u0129\u0129\u012B\u012B\u012D\u012D\u012F\u012F\u0131"          + "\u0131\u0133\u0133\u0135\u0135\u0137\u0138\u013A\u013A\u013C"          + "\u013C\u013E\u013E\u0140\u0140\u0142\u0142\u0144\u0144\u0146"          + "\u0146\u0148\u0149\u014B\u014B\u014D\u014D\u014F\u014F\u0151"          + "\u0151\u0153\u0153\u0155\u0155\u0157\u0157\u0159\u0159\u015B"          + "\u015B\u015D\u015D\u015F\u015F\u0161\u0161\u0163\u0163\u0165"          + "\u0165\u0167\u0167\u0169\u0169\u016B\u016B\u016D\u016D\u016F"          + "\u016F\u0171\u0171\u0173\u0173\u0175\u0175\u0177\u0177\u017A"          + "\u017A\u017C\u017C\u017E\u0180\u0183\u0183\u0185\u0185\u0188"          + "\u0188\u018C\u018D\u0192\u0192\u0195\u0195\u0199\u019B\u019E"          + "\u019E\u01A1\u01A1\u01A3\u01A3\u01A5\u01A5\u01A8\u01A8\u01AA"          + "\u01AB\u01AD\u01AD\u01B0\u01B0\u01B4\u01B4\u01B6\u01B6\u01B9"          + "\u01BA\u01BD\u01BF\u01C6\u01C6\u01C9\u01C9\u01CC\u01CC\u01CE"          + "\u01CE\u01D0\u01D0\u01D2\u01D2\u01D4\u01D4\u01D6\u01D6\u01D8"          + "\u01D8\u01DA\u01DA\u01DC\u01DD\u01DF\u01DF\u01E1\u01E1\u01E3"          + "\u01E3\u01E5\u01E5\u01E7\u01E7\u01E9\u01E9\u01EB\u01EB\u01ED"          + "\u01ED\u01EF\u01F0\u01F3\u01F3\u01F5\u01F5\u01F9\u01F9\u01FB"          + "\u01FB\u01FD\u01FD\u01FF\u01FF\u0201\u0201\u0203\u0203\u0205"          + "\u0205\u0207\u0207\u0209\u0209\u020B\u020B\u020D\u020D\u020F"          + "\u020F\u0211\u0211\u0213\u0213\u0215\u0215\u0217\u0217\u0219"          + "\u0219\u021B\u021B\u021D\u021D\u021F\u021F\u0223\u0223\u0225"          + "\u0225\u0227\u0227\u0229\u0229\u022B\u022B\u022D\u022D\u022F"          + "\u022F\u0231\u0231\u0233\u0233\u0250\u02AD\u0390\u0390\u03AC"          + "\u03CE\u03D0\u03D1\u03D5\u03D7\u03DB\u03DB\u03DD\u03DD\u03DF"          + "\u03DF\u03E1\u03E1\u03E3\u03E3\u03E5\u03E5\u03E7\u03E7\u03E9"          + "\u03E9\u03EB\u03EB\u03ED\u03ED\u03EF\u03F3\u0430\u045F\u0461"          + "\u0461\u0463\u0463\u0465\u0465\u0467\u0467\u0469\u0469\u046B"          + "\u046B\u046D\u046D\u046F\u046F\u0471\u0471\u0473\u0473\u0475"          + "\u0475\u0477\u0477\u0479\u0479\u047B\u047B\u047D\u047D\u047F"          + "\u047F\u0481\u0481\u048D\u048D\u048F\u048F\u0491\u0491\u0493"          + "\u0493\u0495\u0495\u0497\u0497\u0499\u0499\u049B\u049B\u049D"          + "\u049D\u049F\u049F\u04A1\u04A1\u04A3\u04A3\u04A5\u04A5\u04A7"          + "\u04A7\u04A9\u04A9\u04AB\u04AB\u04AD\u04AD\u04AF\u04AF\u04B1"          + "\u04B1\u04B3\u04B3\u04B5\u04B5\u04B7\u04B7\u04B9\u04B9\u04BB"          + "\u04BB\u04BD\u04BD\u04BF\u04BF\u04C2\u04C2\u04C4\u04C4\u04C8"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -