KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jalisto > se > impl > meta > IndexDescription


1 /*
2  * Jalisto - JAva LIght STOrage
3  * Copyright (C) 2000-2005 Xcalia http://www.xcalia.com
4  *
5  * This library 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 library 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 library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
18  *
19  * Xcalia
20  * 71, rue Desnouettes
21  * 75014 Paris - France
22  * http://www.xcalia.com
23  */

24 package org.objectweb.jalisto.se.impl.meta;
25
26 import org.objectweb.jalisto.se.api.query.Index;
27 import org.objectweb.jalisto.se.exception.JalistoException;
28 import org.objectweb.jalisto.se.impl.InFileAddress;
29 import org.objectweb.jalisto.se.impl.server.page.LeafPage;
30 import org.objectweb.jalisto.se.impl.server.page.NodePage;
31
32 import java.io.Serializable JavaDoc;
33
34 public class IndexDescription implements Serializable JavaDoc {
35
36     public IndexDescription(FieldDescriptionImpl fieldDescription) {
37         this.fieldDescription = fieldDescription;
38         this.nodePageSize = NodePage.DEFAULT_SIZE;
39         this.leafPageSize = LeafPage.DEFAULT_SIZE;
40         this.nodeSize = Index.NODE_DEFAULT_SIZE;
41     }
42
43     public boolean hasIndex() {
44         return (valueIndexIfa != null);
45     }
46
47     public FieldDescriptionImpl getFieldDescription() {
48         return fieldDescription;
49     }
50
51     public short getLeafPageSize() {
52         return leafPageSize;
53     }
54
55     public void setLeafPageSize(short leafPageSize) {
56         this.leafPageSize = leafPageSize;
57     }
58
59     public short getNodePageSize() {
60         return nodePageSize;
61     }
62
63     public void setNodePageSize(short nodePageSize) {
64         this.nodePageSize = nodePageSize;
65     }
66
67     public short getNodeSize() {
68         return nodeSize;
69     }
70
71     public void setNodeSize(short nodeSize) {
72         this.nodeSize = nodeSize;
73     }
74
75     public boolean isIndexDefined() {
76         return (valueIndexIfa != null);
77     }
78
79     public InFileAddress getValueIndexIfa() {
80         if (!fieldDescription.getType().isBasicType()) {
81             throw new JalistoException("cannot use or define index on none basic type field : " + fieldDescription);
82         }
83         return valueIndexIfa;
84     }
85
86     public void setValueIndexIfa(InFileAddress valueIndexIfa) {
87         if (!fieldDescription.getType().isBasicType()) {
88             throw new JalistoException("cannot use or define index on none basic type field : " + fieldDescription);
89         }
90         this.valueIndexIfa = valueIndexIfa;
91     }
92
93     public short getValueIndexType() {
94         return valueIndexType;
95     }
96
97     public void setValueIndexType(short valueIndexType) {
98         this.valueIndexType = valueIndexType;
99     }
100
101     public boolean equals(Object JavaDoc o) {
102         try {
103             IndexDescription candidate = (IndexDescription) o;
104             return (candidate.valueIndexIfa.equals(this.valueIndexIfa) &&
105                     (candidate.valueIndexType == this.valueIndexType) &&
106                     (candidate.nodeSize == this.nodeSize) &&
107                     (candidate.nodePageSize == this.nodePageSize) &&
108                     (candidate.leafPageSize == this.leafPageSize));
109         } catch (Exception JavaDoc e) {
110         }
111         return false;
112     }
113
114     private FieldDescriptionImpl fieldDescription;
115     private InFileAddress valueIndexIfa;
116     private short valueIndexType;
117     private short nodeSize;
118     private short nodePageSize;
119     private short leafPageSize;
120
121
122     static final long serialVersionUID = -6989377087964761459L;
123 }
124
Popular Tags