KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > xml2 > InternQName


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  *
23  * Free Software Foundation, Inc.
24  * 59 Temple Place, Suite 330
25  * Boston, MA 02111-1307 USA
26  *
27  * @author Scott Ferguson
28  */

29
30 package com.caucho.xml2;
31
32 import com.caucho.util.L10N;
33 import com.caucho.vfs.ReadStream;
34 import com.caucho.vfs.TempCharBuffer;
35 import com.caucho.vfs.Vfs;
36 import com.caucho.xml.ExtendedLocator;
37 import com.caucho.xml.QName;
38 import com.caucho.xml.XmlChar;
39
40 import org.xml.sax.*;
41
42 import java.io.IOException JavaDoc;
43 import java.io.InputStream JavaDoc;
44 import java.io.Reader JavaDoc;
45 import java.util.HashMap JavaDoc;
46
47 public final class InternQName {
48   final InternQName _next;
49     
50   final char []_buf;
51   final int _colon;
52
53   String JavaDoc _name;
54   String JavaDoc _prefix;
55   String JavaDoc _localName;
56
57   InternQName(InternQName next,
58           char []buf, int offset, int length,
59           int colon)
60   {
61     _next = next;
62       
63     _buf = new char[length];
64     System.arraycopy(buf, offset, _buf, 0, length);
65
66     _colon = colon - offset;
67   }
68
69   public final boolean match(char []buf, int offset, int length)
70   {
71     if (length != _buf.length)
72       return false;
73
74     char []entryBuf = _buf;
75       
76     for (length--; length >= 0; length--) {
77       if (entryBuf[length] != buf[offset + length])
78     return false;
79     }
80
81     return true;
82   }
83
84   public final String JavaDoc getName()
85   {
86     if (_name == null)
87       _name = new String JavaDoc(_buf, 0, _buf.length);
88
89     return _name;
90   }
91
92   public final String JavaDoc getNamespaceURI()
93   {
94     return "";
95   }
96
97   public final String JavaDoc getLocalName()
98   {
99     if (_localName == null) {
100       if (_colon == 0)
101     _localName = _name;
102       else
103     _localName = new String JavaDoc(_buf, _colon + 1, _buf.length - _colon - 1);
104     }
105
106     return _localName;
107   }
108 }
109
Popular Tags