KickJava   Java API By Example, From Geeks To Geeks.

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


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 /*
24  * CollectionConfig.java
25  *
26  * Created on 20 juillet 2000, 14:24
27  */

28  
29 package org.xquark.mapper.metadata;
30
31 import org.xquark.mapper.dbms.TableSpecLoader;
32
33 /** Data structure that holds a repository features.
34  */

35
36 public class RepositoryInfo implements Cloneable JavaDoc
37 {
38     private static final String JavaDoc RCSRevision = "$Revision: 1.1 $";
39     private static final String JavaDoc RCSName = "$Name: $";
40     
41     /** Repository logical ID.
42      */

43     protected String JavaDoc name = "XQuark";
44
45     protected byte colIDSize = RepositoryConstants.CID_SIZE_DEFAULT_VALUE;
46     
47     protected String JavaDoc version = TableSpecLoader.REPOSITORY_DATA_VERSION;
48
49     public RepositoryInfo()
50     {
51     }
52     
53     public RepositoryInfo(String JavaDoc name, byte colIDSize)
54     {
55         this.name = name;
56         setColIDSize(colIDSize);
57     }
58
59     /** Builds a String in order to displays the information of this configuration.
60      * @return the string representing the repository features.
61      */

62     public String JavaDoc toString()
63     {
64         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
65
66         buffer.append("\nName :\t");
67         buffer.append(name);
68         buffer.append("\nCollection ID size in bits:\t");
69         buffer.append(colIDSize);
70         buffer.append("\nModel version :\t");
71         buffer.append(version);
72         buffer.append("\n");
73         
74         return buffer.toString();
75     }
76     
77     /** Builds a copy of this object.
78      * @return a CollectionConfig object.
79      */

80     public Object JavaDoc clone()
81     {
82         Object JavaDoc copy = null;
83         try {
84             copy = super.clone();
85         }
86         catch(CloneNotSupportedException JavaDoc e) {
87         }
88         return copy;
89     }
90     
91     public String JavaDoc getName()
92     {
93         return name;
94     }
95     
96     public String JavaDoc getVersion()
97     {
98         return version;
99     }
100     
101     public byte getColIDSize()
102     {
103         return colIDSize;
104     }
105     
106     public short getColIDMaxValue()
107     {
108         return (short)((1 << colIDSize) - 1);
109     }
110     
111     public void setName(String JavaDoc name)
112     {
113         this.name = name;
114     }
115     
116     public void setVersion(String JavaDoc version)
117     {
118         this.version = version;
119     }
120     
121     public void setColIDSize(byte colSize)
122     {
123         if (colSize < RepositoryConstants.CID_SIZE_MIN_VALUE)
124             colIDSize = RepositoryConstants.CID_SIZE_MIN_VALUE;
125         else if (colSize > RepositoryConstants.CID_SIZE_MAX_VALUE)
126             colIDSize = RepositoryConstants.CID_SIZE_MAX_VALUE;
127         else
128             colIDSize = colSize;
129     }
130 }
131
Popular Tags