~ubuntu-branches/ubuntu/karmic/libxerces2-java/karmic

« back to all changes in this revision

Viewing changes to src/org/apache/xerces/impl/xs/opti/ElementImpl.java

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2006-12-04 17:37:55 UTC
  • mfrom: (2.1.2 etch)
  • Revision ID: james.westby@ubuntu.com-20061204173755-hb6ybrrrk097zhx7
Tags: 2.8.1-1ubuntu1
* Merge with Debian unstable; remaining changes:
  - Build -gcj package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * The Apache Software License, Version 1.1
3
 
 *
4
 
 *
5
 
 * Copyright (c) 2001, 2002 The Apache Software Foundation.  All rights
6
 
 * reserved.
7
 
 *
8
 
 * Redistribution and use in source and binary forms, with or without
9
 
 * modification, are permitted provided that the following conditions
10
 
 * are met:
11
 
 *
12
 
 * 1. Redistributions of source code must retain the above copyright
13
 
 *    notice, this list of conditions and the following disclaimer.
14
 
 *
15
 
 * 2. Redistributions in binary form must reproduce the above copyright
16
 
 *    notice, this list of conditions and the following disclaimer in
17
 
 *    the documentation and/or other materials provided with the
18
 
 *    distribution.
19
 
 *
20
 
 * 3. The end-user documentation included with the redistribution,
21
 
 *    if any, must include the following acknowledgment:
22
 
 *       "This product includes software developed by the
23
 
 *        Apache Software Foundation (http://www.apache.org/)."
24
 
 *    Alternately, this acknowledgment may appear in the software itself,
25
 
 *    if and wherever such third-party acknowledgments normally appear.
26
 
 *
27
 
 * 4. The names "Xerces" and "Apache Software Foundation" must
28
 
 *    not be used to endorse or promote products derived from this
29
 
 *    software without prior written permission. For written
30
 
 *    permission, please contact apache@apache.org.
31
 
 *
32
 
 * 5. Products derived from this software may not be called "Apache",
33
 
 *    nor may "Apache" appear in their name, without prior written
34
 
 *    permission of the Apache Software Foundation.
35
 
 *
36
 
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37
 
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38
 
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39
 
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
40
 
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41
 
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42
 
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43
 
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44
 
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45
 
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46
 
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47
 
 * SUCH DAMAGE.
48
 
 * ====================================================================
49
 
 *
50
 
 * This software consists of voluntary contributions made by many
51
 
 * individuals on behalf of the Apache Software Foundation and was
52
 
 * originally based on software copyright (c) 2001, International
53
 
 * Business Machines, Inc., http://www.apache.org.  For more
54
 
 * information on the Apache Software Foundation, please see
55
 
 * <http://www.apache.org/>.
 
2
 * Copyright 2001,2002,2004,2005 The Apache Software Foundation.
 
3
 * 
 
4
 * Licensed under the Apache License, Version 2.0 (the "License");
 
5
 * you may not use this file except in compliance with the License.
 
6
 * You may obtain a copy of the License at
 
7
 * 
 
8
 *      http://www.apache.org/licenses/LICENSE-2.0
 
9
 * 
 
10
 * Unless required by applicable law or agreed to in writing, software
 
11
 * distributed under the License is distributed on an "AS IS" BASIS,
 
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
13
 * See the License for the specific language governing permissions and
 
14
 * limitations under the License.
56
15
 */
57
16
 
58
17
package org.apache.xerces.impl.xs.opti;
63
22
import org.w3c.dom.Node;
64
23
 
65
24
/**
 
25
 * @xerces.internal  
 
26
 * 
66
27
 * @author Rahul Srivastava, Sun Microsystems Inc.
67
28
 * @author Sandy Gao, IBM
68
29
 *
69
 
 * @version $Id: ElementImpl.java,v 1.5 2003/07/24 15:14:42 neilg Exp $
 
30
 * @version $Id: ElementImpl.java 320582 2005-09-15 22:08:26Z mrglavas $
70
31
 */
71
32
public class ElementImpl extends DefaultElement {
72
 
 
 
33
    
73
34
    SchemaDOM schemaDOM;
74
35
    Attr[] attrs;
75
36
    int row;
78
39
    
79
40
    int line;
80
41
    int column;
81
 
 
 
42
    int charOffset;
 
43
    String fAnnotation;
 
44
    String fSyntheticAnnotation;
 
45
    
 
46
    public ElementImpl(int line, int column, int offset) {
 
47
        row = -1;
 
48
        col = -1;
 
49
        parentRow = -1;
 
50
        nodeType = Node.ELEMENT_NODE;
 
51
        
 
52
        this.line = line;
 
53
        this.column = column;
 
54
        charOffset = offset;
 
55
    }
 
56
    
82
57
    public ElementImpl(int line, int column) {
 
58
        this(line, column, -1);
 
59
    }
 
60
    
 
61
    
 
62
    public ElementImpl(String prefix, String localpart, String rawname,
 
63
            String uri, int line, int column, int offset) {
 
64
        super(prefix, localpart, rawname, uri, Node.ELEMENT_NODE);
83
65
        row = -1;
84
66
        col = -1;
85
67
        parentRow = -1;
86
 
        nodeType = Node.ELEMENT_NODE;
87
68
        
88
69
        this.line = line;
89
70
        this.column = column;
 
71
        charOffset = offset;
90
72
    }
91
73
    
92
 
    
93
74
    public ElementImpl(String prefix, String localpart, String rawname,
94
 
                       String uri, int line, int column) {
95
 
        super(prefix, localpart, rawname, uri, Node.ELEMENT_NODE);
96
 
        row = -1;
97
 
        col = -1;
98
 
        parentRow = -1;
99
 
 
100
 
        this.line = line;
101
 
        this.column = column;
 
75
            String uri, int line, int column) {
 
76
        this(prefix, localpart, rawname, uri, line, column, -1);
102
77
    }
103
 
 
104
 
 
 
78
    
 
79
    
105
80
    //
106
81
    // org.w3c.dom.Node methods
107
82
    //
114
89
    public Node getParentNode() {
115
90
        return schemaDOM.relations[row][0];
116
91
    }
117
 
 
118
 
 
 
92
    
 
93
    
119
94
    public boolean hasChildNodes() {
120
95
        if (parentRow == -1) {
121
96
            return false;
124
99
            return true;
125
100
        }
126
101
    }
127
 
 
128
 
 
 
102
    
 
103
    
129
104
    public Node getFirstChild() {
130
105
        if (parentRow == -1) {
131
106
            return null;
132
107
        }
133
108
        return schemaDOM.relations[parentRow][1];
134
109
    }
135
 
 
136
 
 
 
110
    
 
111
    
137
112
    public Node getLastChild() {
138
113
        if (parentRow == -1) {
139
114
            return null;
149
124
        }
150
125
        return schemaDOM.relations[parentRow][i-1];
151
126
    }
152
 
 
153
 
 
 
127
    
 
128
    
154
129
    public Node getPreviousSibling() {
155
130
        if (col == 1) {
156
131
            return null;
157
132
        }
158
133
        return schemaDOM.relations[row][col-1];
159
134
    }
160
 
 
161
 
 
 
135
    
 
136
    
162
137
    public Node getNextSibling() {
163
138
        if (col == schemaDOM.relations[row].length-1) {
164
139
            return null;
165
140
        }
166
141
        return schemaDOM.relations[row][col+1];
167
142
    }
168
 
 
169
 
 
 
143
    
 
144
    
170
145
    public NamedNodeMap getAttributes() {
171
146
        return new NamedNodeMapImpl(attrs);
172
147
    }
173
 
 
174
 
 
 
148
    
 
149
    
175
150
    public boolean hasAttributes() {
176
151
        return (attrs.length == 0 ? false : true);
177
152
    }
178
153
    
179
 
 
 
154
    
180
155
    
181
156
    //
182
157
    // org.w3c.dom.Element methods
185
160
    public String getTagName() {
186
161
        return rawname;
187
162
    }
188
 
 
189
 
 
 
163
    
 
164
    
190
165
    public String getAttribute(String name) {
191
 
    
 
166
        
192
167
        for (int i=0; i<attrs.length; i++) {
193
168
            if (attrs[i].getName().equals(name)) {
194
169
                return attrs[i].getValue();
196
171
        }
197
172
        return "";
198
173
    }
199
 
 
200
 
 
 
174
    
 
175
    
201
176
    public Attr getAttributeNode(String name) {
202
177
        for (int i=0; i<attrs.length; i++) {
203
178
            if (attrs[i].getName().equals(name)) {
206
181
        }
207
182
        return null;
208
183
    }
209
 
 
210
 
 
 
184
    
 
185
    
211
186
    public String getAttributeNS(String namespaceURI, String localName) {
212
187
        for (int i=0; i<attrs.length; i++) {
213
188
            if (attrs[i].getLocalName().equals(localName) && attrs[i].getNamespaceURI().equals(namespaceURI)) {
216
191
        }
217
192
        return "";
218
193
    }
219
 
 
220
 
 
 
194
    
 
195
    
221
196
    public Attr getAttributeNodeNS(String namespaceURI, String localName) {
222
197
        for (int i=0; i<attrs.length; i++) {
223
198
            if (attrs[i].getName().equals(localName) && attrs[i].getNamespaceURI().equals(namespaceURI)) {
226
201
        }
227
202
        return null;
228
203
    }
229
 
 
230
 
 
 
204
    
 
205
    
231
206
    public boolean hasAttribute(String name) {
232
207
        for (int i=0; i<attrs.length; i++) {
233
208
            if (attrs[i].getName().equals(name)) {
236
211
        }
237
212
        return false;
238
213
    }
239
 
 
240
 
 
 
214
    
 
215
    
241
216
    public boolean hasAttributeNS(String namespaceURI, String localName) {
242
217
        for (int i=0; i<attrs.length; i++) {
243
218
            if (attrs[i].getName().equals(localName) && attrs[i].getNamespaceURI().equals(namespaceURI)) {
256
231
            }
257
232
        }
258
233
    }
259
 
 
 
234
    
260
235
    /** Returns the line number. */
261
236
    public int getLineNumber() {
262
237
        return line;
263
238
    }
264
 
 
 
239
    
265
240
    /** Returns the column number. */
266
241
    public int getColumnNumber() {
267
242
        return column;
268
243
    }
269
 
 
 
244
    
 
245
    /** Returns the character offset. */
 
246
    public int getCharacterOffset() {
 
247
        return charOffset;
 
248
    }
 
249
    
 
250
    public String getAnnotation() {
 
251
        return fAnnotation;
 
252
    }
 
253
    
 
254
    public String getSyntheticAnnotation() {
 
255
        return fSyntheticAnnotation;
 
256
    }
270
257
}