001: /*
002: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: *
023: * Free Software Foundation, Inc.
024: * 59 Temple Place, Suite 330
025: * Boston, MA 02111-1307 USA
026: *
027: * @author Scott Ferguson
028: */
029:
030: package com.caucho.xml2;
031:
032: import com.caucho.util.L10N;
033: import com.caucho.vfs.ReadStream;
034: import com.caucho.vfs.TempCharBuffer;
035: import com.caucho.vfs.Vfs;
036: import com.caucho.xml.ExtendedLocator;
037: import com.caucho.xml.QName;
038: import com.caucho.xml.XmlChar;
039:
040: import org.xml.sax.*;
041:
042: import java.io.IOException;
043: import java.io.InputStream;
044: import java.io.Reader;
045: import java.util.HashMap;
046:
047: public final class InternQName {
048: final InternQName _next;
049:
050: final char[] _buf;
051: final int _colon;
052:
053: String _name;
054: String _prefix;
055: String _localName;
056:
057: InternQName(InternQName next, char[] buf, int offset, int length,
058: int colon) {
059: _next = next;
060:
061: _buf = new char[length];
062: System.arraycopy(buf, offset, _buf, 0, length);
063:
064: _colon = colon - offset;
065: }
066:
067: public final boolean match(char[] buf, int offset, int length) {
068: if (length != _buf.length)
069: return false;
070:
071: char[] entryBuf = _buf;
072:
073: for (length--; length >= 0; length--) {
074: if (entryBuf[length] != buf[offset + length])
075: return false;
076: }
077:
078: return true;
079: }
080:
081: public final String getName() {
082: if (_name == null)
083: _name = new String(_buf, 0, _buf.length);
084:
085: return _name;
086: }
087:
088: public final String getNamespaceURI() {
089: return "";
090: }
091:
092: public final String getLocalName() {
093: if (_localName == null) {
094: if (_colon == 0)
095: _localName = _name;
096: else
097: _localName = new String(_buf, _colon + 1, _buf.length
098: - _colon - 1);
099: }
100:
101: return _localName;
102: }
103: }
|