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

📄 parserforxmlschema.java

📁 java1.6众多例子参考
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * Copyright 1999-2005 The Apache Software Foundation. *  * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at *  *      http://www.apache.org/licenses/LICENSE-2.0 *  * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package com.sun.org.apache.xerces.internal.impl.xpath.regex;import java.util.Hashtable;import java.util.Locale;/** * A regular expression parser for the XML Schema. *  * @xerces.internal * * @author TAMURA Kent &lt;kent@trl.ibm.co.jp&gt; * @version $Id: ParserForXMLSchema.java,v 1.2.6.1 2005/09/06 11:46:32 neerajbj Exp $ */class ParserForXMLSchema extends RegexParser {    public ParserForXMLSchema() {        //this.setLocale(Locale.getDefault());    }    public ParserForXMLSchema(Locale locale) {        //this.setLocale(locale);    }    Token processCaret() throws ParseException {        this.next();        return Token.createChar('^');    }    Token processDollar() throws ParseException {        this.next();        return Token.createChar('$');     }    Token processLookahead() throws ParseException {        throw ex("parser.process.1", this.offset);    }    Token processNegativelookahead() throws ParseException {        throw ex("parser.process.1", this.offset);    }    Token processLookbehind() throws ParseException {        throw ex("parser.process.1", this.offset);    }    Token processNegativelookbehind() throws ParseException {        throw ex("parser.process.1", this.offset);    }    Token processBacksolidus_A() throws ParseException {        throw ex("parser.process.1", this.offset);    }    Token processBacksolidus_Z() throws ParseException {        throw ex("parser.process.1", this.offset);    }    Token processBacksolidus_z() throws ParseException {        throw ex("parser.process.1", this.offset);    }    Token processBacksolidus_b() throws ParseException {        throw ex("parser.process.1", this.offset);    }    Token processBacksolidus_B() throws ParseException {        throw ex("parser.process.1", this.offset);    }    Token processBacksolidus_lt() throws ParseException {        throw ex("parser.process.1", this.offset);    }    Token processBacksolidus_gt() throws ParseException {        throw ex("parser.process.1", this.offset);    }    Token processStar(Token tok) throws ParseException {        this.next();        return Token.createClosure(tok);    }    Token processPlus(Token tok) throws ParseException {        // X+ -> XX*        this.next();        return Token.createConcat(tok, Token.createClosure(tok));    }    Token processQuestion(Token tok) throws ParseException {        // X? -> X|        this.next();        Token par = Token.createUnion();        par.addChild(tok);        par.addChild(Token.createEmpty());        return par;    }    boolean checkQuestion(int off) {        return false;    }    Token processParen() throws ParseException {        this.next();        Token tok = Token.createParen(this.parseRegex(), 0);        if (this.read() != T_RPAREN)  throw ex("parser.factor.1", this.offset-1);        this.next();                            // Skips ')'        return tok;    }    Token processParen2() throws ParseException {        throw ex("parser.process.1", this.offset);    }    Token processCondition() throws ParseException {        throw ex("parser.process.1", this.offset);    }    Token processModifiers() throws ParseException {        throw ex("parser.process.1", this.offset);    }    Token processIndependent() throws ParseException {        throw ex("parser.process.1", this.offset);    }    Token processBacksolidus_c() throws ParseException {        this.next();        return this.getTokenForShorthand('c');    }    Token processBacksolidus_C() throws ParseException {        this.next();        return this.getTokenForShorthand('C');    }    Token processBacksolidus_i() throws ParseException {        this.next();        return this.getTokenForShorthand('i');    }    Token processBacksolidus_I() throws ParseException {        this.next();        return this.getTokenForShorthand('I');    }    Token processBacksolidus_g() throws ParseException {        throw this.ex("parser.process.1", this.offset-2);    }    Token processBacksolidus_X() throws ParseException {        throw ex("parser.process.1", this.offset-2);    }    Token processBackreference() throws ParseException {        throw ex("parser.process.1", this.offset-4);    }    int processCIinCharacterClass(RangeToken tok, int c) {        tok.mergeRanges(this.getTokenForShorthand(c));        return -1;    }    /**     * Parses a character-class-expression, not a character-class-escape.     *     * c-c-expression   ::= '[' c-group ']'     * c-group          ::= positive-c-group | negative-c-group | c-c-subtraction     * positive-c-group ::= (c-range | c-c-escape)+     * negative-c-group ::= '^' positive-c-group     * c-c-subtraction  ::= (positive-c-group | negative-c-group) subtraction     * subtraction      ::= '-' c-c-expression     * c-range          ::= single-range | from-to-range     * single-range     ::= multi-c-escape | category-c-escape | block-c-escape | <any XML char>     * cc-normal-c      ::= <any character except [, ], \>     * from-to-range    ::= cc-normal-c '-' cc-normal-c     *     * @param useNrage Ignored.     * @return This returns no NrageToken.     */    protected RangeToken parseCharacterClass(boolean useNrange) throws ParseException {        this.setContext(S_INBRACKETS);        this.next();                            // '['        boolean nrange = false;        boolean wasDecoded = false;     		// used to detect if the last - was escaped.        RangeToken base = null;        RangeToken tok;        if (this.read() == T_CHAR && this.chardata == '^') {            nrange = true;            this.next();                        // '^'            base = Token.createRange();            base.addRange(0, Token.UTF16_MAX);            tok = Token.createRange();        } else {            tok = Token.createRange();        }        int type;        boolean firstloop = true;        while ((type = this.read()) != T_EOF) { // Don't use 'cotinue' for this loop.        	        	wasDecoded = false;            // single-range | from-to-range | subtraction            if (type == T_CHAR && this.chardata == ']' && !firstloop) {                if (nrange) {                    base.subtractRanges(tok);                    tok = base;                }                break;            }            int c = this.chardata;            boolean end = false;            if (type == T_BACKSOLIDUS) {                switch (c) {                  case 'd':  case 'D':                  case 'w':  case 'W':                  case 's':  case 'S':                    tok.mergeRanges(this.getTokenForShorthand(c));                    end = true;                    break;                  case 'i':  case 'I':                  case 'c':  case 'C':                    c = this.processCIinCharacterClass(tok, c);                    if (c < 0)  end = true;                    break;                                      case 'p':                  case 'P':                    int pstart = this.offset;                    RangeToken tok2 = this.processBacksolidus_pP(c);                    if (tok2 == null)  throw this.ex("parser.atom.5", pstart);                    tok.mergeRanges(tok2);                    end = true;                    break;                                    case '-':                 	c = this.decodeEscaped();                 	wasDecoded = true;                 	break;                  default:                    c = this.decodeEscaped();                } // \ + c            } // backsolidus            else if (type == T_XMLSCHEMA_CC_SUBTRACTION && !firstloop) {                                                // Subraction                if (nrange) {                    base.subtractRanges(tok);                    tok = base;                }                RangeToken range2 = this.parseCharacterClass(false);                tok.subtractRanges(range2);                if (this.read() != T_CHAR || this.chardata != ']')                    throw this.ex("parser.cc.5", this.offset);                break;                          // Exit this loop            }

⌨️ 快捷键说明

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