KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > xquark > mapper > metadata > ExtraNode


1 /*
2  * This file belongs to the XQuark distribution.
3  * Copyright (C) 2003 Universite de Versailles Saint-Quentin.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307.
18  * You can also get it at http://www.gnu.org/licenses/lgpl.html
19  *
20  * For more information on this software, see http://www.xquark.org.
21  */

22
23 package org.xquark.mapper.metadata;
24
25 import org.xquark.mapper.util.RecyclingStack;
26 import org.xquark.schema.SchemaConstants;
27
28 /**
29  * Data structure that corresponds to XML extra-data nodes (PI, comments & prefix definition).
30  *
31  */

32 public class ExtraNode implements Cloneable JavaDoc, RecyclingStack.StackObject
33 {
34     private static final String JavaDoc RCSRevision = "$Revision: 1.1 $";
35     private static final String JavaDoc RCSName = "$Name: $";
36     
37     public long anchor = -1;
38     public short rowNum = 0;
39     public short path = -2; // -1 is ROOT path ID !
40

41     /* Code for setting the type of node */
42     public short type = -1;
43     public short position = 0;
44     public int offset = 0;
45     public String JavaDoc data =null;
46     
47     public ExtraNode()
48     {}
49     
50 /* public ExtraNode(int anchorOID, short path, short type)
51     {
52         set(anchorOID, path, type);
53     }
54  */

55     public ExtraNode(long anchorOID, short rowNum, short path, short type, short position)
56     {
57         set(anchorOID, rowNum, path, type, position);
58     }
59     
60     public ExtraNode(long anchorOID, short rowNum, short path, short type, short position, int offset, String JavaDoc data)
61     {
62         set(anchorOID, rowNum, path, type, position, offset, data);
63     }
64     
65     /**
66      * This method is for recycling objects. This method is prefered to the constructor call.
67      */

68     public void set(long anchorOID, short path, short type, short position)
69     {
70         this.anchor = anchorOID;
71         this.path = path;
72         this.type = type;
73         this.position = position;
74     }
75     /**
76      * This method is for recycling objects. This method is prefered to the constructor call.
77      */

78     public void set(long anchorOID, short rowNum, short path, short type, short position)
79     {
80         set(anchorOID, path, type, position);
81         this.rowNum = rowNum;
82     }
83     
84     public void set(long anchorOID, short rowNum, short path, short type, short position, int offset, String JavaDoc data)
85     {
86         set(anchorOID, rowNum, path, type, position);
87         this.data = data;
88         this.offset = offset;
89     }
90     
91     public boolean isNil()
92     {
93         return (type == RepositoryConstants.XSI_NIL)
94                     && data.equalsIgnoreCase(SchemaConstants.TRUE_VALUE);
95     }
96     
97     public void clear()
98     {
99         anchor = -1;
100         path = -2; // -1 is ROOT path ID !
101
type = -1;
102         position = 0;
103         offset = 0;
104         data = null;
105     }
106     
107     public String JavaDoc toString()
108     {
109         return "[" + anchor + ", " + path+ ", " + type + ", " + position
110                 + ", " + offset + ", " + data + "]";
111     }
112     
113     public Object JavaDoc clone()
114     {
115         Object JavaDoc o = null;
116         try {
117             o = super.clone();
118         }
119         catch (CloneNotSupportedException JavaDoc e) {
120         }
121         return o;
122     }
123 }
124
Popular Tags