xpointerhandler.java

来自「JAVA 所有包」· Java 代码 · 共 1,245 行 · 第 1/4 页

JAVA
1,245
字号
        if (!fIsXPointerResolved) {            fIsXPointerResolved = resolved;        }        return resolved;    }    /**     * Returns true if the Node fragment is resolved.     *      * @see com.sun.org.apache.xerces.internal.xpointer.XPointerProcessor#isFragmentResolved()     */    public boolean isFragmentResolved() throws XNIException {        boolean resolved = (fXPointerPart != null) ? fXPointerPart.isFragmentResolved()                : false;                if (!fIsXPointerResolved) {            fIsXPointerResolved = resolved;        }                return resolved;    }    /**     * Returns true if the XPointer expression resolves to a non-element child     * of the current resource fragment.            *      * @see com.sun.org.apache.xerces.internal.xpointer.XPointerPart#isChildFragmentResolved()     *        */    public boolean isChildFragmentResolved() throws XNIException {    	boolean resolved = (fXPointerPart != null) ? fXPointerPart				.isChildFragmentResolved() : false;		return resolved;    }    /**     * Returns true if the XPointer successfully found a sub-resource .     *      * @see com.sun.org.apache.xerces.internal.xpointer.XPointerProcessor#isFragmentResolved()     */    public boolean isXPointerResolved() throws XNIException {        return fIsXPointerResolved;    }        /**     * Returns the pointer part used to resolve the document fragment.     *      * @return String - The pointer part used to resolve the document fragment.     */    public XPointerPart getXPointerPart() {        return fXPointerPart;    }    /**     * Reports XPointer Errors     *      */    private void reportError(String key, Object[] arguments)            throws XNIException {        /*         fXPointerErrorReporter.reportError(                XPointerMessageFormatter.XPOINTER_DOMAIN, key, arguments,                XMLErrorReporter.SEVERITY_ERROR);        */            	throw new XNIException((fErrorReporter				.getMessageFormatter(XPointerMessageFormatter.XPOINTER_DOMAIN))				.formatMessage(fErrorReporter.getLocale(), key, arguments));    }    /**     * Reports XPointer Warnings     *      */    private void reportWarning(String key, Object[] arguments)            throws XNIException {        fXPointerErrorReporter.reportError(                XPointerMessageFormatter.XPOINTER_DOMAIN, key, arguments,                XMLErrorReporter.SEVERITY_WARNING);    }    /**     * Initializes error handling objects     *      */    protected void initErrorReporter() {        if (fXPointerErrorReporter == null) {            fXPointerErrorReporter = new XMLErrorReporter();        }        if (fErrorHandler == null) {            fErrorHandler = new XPointerErrorHandler();        }        /*         fXPointerErrorReporter.setProperty(Constants.XERCES_PROPERTY_PREFIX         + Constants.ERROR_HANDLER_PROPERTY, fErrorHandler);         */        fXPointerErrorReporter.putMessageFormatter(                XPointerMessageFormatter.XPOINTER_DOMAIN,                new XPointerMessageFormatter());    }    /**     * Initializes the XPointer Processor;     */    protected void init() {        fXPointerParts.clear();        fXPointerPart = null;        fFoundMatchingPtrPart = false;        fIsXPointerResolved = false;        //fFixupBase = false;        //fFixupLang = false;        initErrorReporter();    }    /**     * Returns a Vector of XPointerPart objects     *      * @return A Vector of XPointerPart objects.     */    public Vector getPointerParts() {        return fXPointerParts;    }    /**     * List of XPointer Framework tokens.     *      * @xerces.internal     *      */    private final class Tokens {        /**         * XPointer Framework tokens         * [1] Pointer     ::= Shorthand | SchemeBased          * [2] Shorthand   ::= NCName          * [3] SchemeBased ::= PointerPart (S? PointerPart)*          * [4] PointerPart ::= SchemeName '(' SchemeData ')'          * [5] SchemeName  ::= QName          * [6] SchemeData  ::= EscapedData*          * [7] EscapedData ::= NormalChar | '^(' | '^)' | '^^' | '(' SchemeData ')'          * [8] NormalChar  ::= UnicodeChar - [()^]          * [9] UnicodeChar ::= [#x0-#x10FFFF]         *           */        private static final int XPTRTOKEN_OPEN_PAREN = 0,                XPTRTOKEN_CLOSE_PAREN = 1, XPTRTOKEN_SHORTHAND = 2,                XPTRTOKEN_SCHEMENAME = 3, XPTRTOKEN_SCHEMEDATA = 4;        // Token names        private final String[] fgTokenNames = { "XPTRTOKEN_OPEN_PAREN",                "XPTRTOKEN_CLOSE_PAREN", "XPTRTOKEN_SHORTHAND",                "XPTRTOKEN_SCHEMENAME", "XPTRTOKEN_SCHEMEDATA" };        // Token count        private static final int INITIAL_TOKEN_COUNT = 1 << 8;        private int[] fTokens = new int[INITIAL_TOKEN_COUNT];        private int fTokenCount = 0;        // Current token position        private int fCurrentTokenIndex;        private SymbolTable fSymbolTable;        private Hashtable fTokenNames = new Hashtable();        /**         * Constructor          *          * @param symbolTable SymbolTable         */        private Tokens(SymbolTable symbolTable) {            fSymbolTable = symbolTable;            fTokenNames.put(new Integer(XPTRTOKEN_OPEN_PAREN),                    "XPTRTOKEN_OPEN_PAREN");            fTokenNames.put(new Integer(XPTRTOKEN_CLOSE_PAREN),                    "XPTRTOKEN_CLOSE_PAREN");            fTokenNames.put(new Integer(XPTRTOKEN_SHORTHAND),                    "XPTRTOKEN_SHORTHAND");            fTokenNames.put(new Integer(XPTRTOKEN_SCHEMENAME),                    "XPTRTOKEN_SCHEMENAME");            fTokenNames.put(new Integer(XPTRTOKEN_SCHEMEDATA),                    "XPTRTOKEN_SCHEMEDATA");        }        /**         * Returns the token String          * @param token The index of the token         * @return String The token string         */        private String getTokenString(int token) {            return (String) fTokenNames.get(new Integer(token));        }        /**         * Add the specified string as a token         *           * @param token The token string         */        private void addToken(String tokenStr) {            Integer tokenInt = (Integer) fTokenNames.get(tokenStr);            if (tokenInt == null) {                tokenInt = new Integer(fTokenNames.size());                fTokenNames.put(tokenInt, tokenStr);            }            addToken(tokenInt.intValue());        }        /**         * Add the specified int token         *           * @param token The int specifying the token         */        private void addToken(int token) {            try {                fTokens[fTokenCount] = token;            } catch (ArrayIndexOutOfBoundsException ex) {                int[] oldList = fTokens;                fTokens = new int[fTokenCount << 1];                System.arraycopy(oldList, 0, fTokens, 0, fTokenCount);                fTokens[fTokenCount] = token;            }            fTokenCount++;        }        /**         * Resets the current position to the head of the token list.         */        private void rewind() {            fCurrentTokenIndex = 0;        }        /**         * Returns true if the {@link #getNextToken()} method         * returns a valid token.         */        private boolean hasMore() {            return fCurrentTokenIndex < fTokenCount;        }        /**         * Obtains the token at the current position, then advance         * the current position by one.         *          * throws If there's no such next token, this method throws         * <tt>new XNIException("XPointerProcessingError");</tt>.         */        private int nextToken() throws XNIException {            if (fCurrentTokenIndex == fTokenCount) {                reportError("XPointerProcessingError", null);            }            return fTokens[fCurrentTokenIndex++];        }        /**         * Obtains the token at the current position, without advancing         * the current position.         *          * If there's no such next token, this method throws         * <tt>new XNIException("XPointerProcessingError");</tt>.         */        private int peekToken() throws XNIException {            if (fCurrentTokenIndex == fTokenCount) {                reportError("XPointerProcessingError", null);            }            return fTokens[fCurrentTokenIndex];        }        /**         * Obtains the token at the current position as a String.         *          * If there's no current token or if the current token         * is not a string token, this method throws          * If there's no such next token, this method throws         * <tt>new XNIException("XPointerProcessingError");</tt>.         */        private String nextTokenAsString() throws XNIException {            String tokenStrint = getTokenString(nextToken());            if (tokenStrint == null) {                reportError("XPointerProcessingError", null);            }            return tokenStrint;        }    }    /**     *      * The XPointer expression scanner.  Scans the XPointer framework expression.     *      * @xerces.internal     *      */    private class Scanner {        /**         * 7-bit ASCII subset         *         *  0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F         *  0,  0,  0,  0,  0,  0,  0,  0,  0, HT, LF,  0,  0, CR,  0,  0,  // 0         *  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 1         * SP,  !,  ",  #,  $,  %,  &,  ',  (,  ),  *,  +,  ,,  -,  .,  /,  // 2         *  0,  1,  2,  3,  4,  5,  6,  7,  8,  9,  :,  ;,  <,  =,  >,  ?,  // 3         *  @,  A,  B,  C,  D,  E,  F,  G,  H,  I,  J,  K,  L,  M,  N,  O,  // 4         *  P,  Q,  R,  S,  T,  U,  V,  W,  X,  Y,  Z,  [,  \,  ],  ^,  _,  // 5         *  `,  a,  b,  c,  d,  e,  f,  g,  h,  i,  j,  k,  l,  m,  n,  o,  // 6         *  p,  q,  r,  s,  t,  u,  v,  w,  x,  y,  z,  {,  |,  },  ~, DEL  // 7         */        private static final byte CHARTYPE_INVALID = 0, // invalid XML character

⌨️ 快捷键说明

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