KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ws > jaxme > sqls > db2 > TableSpaceImpl


1 /*
2  * Copyright 2003, 2004 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.
15
16  */

17 package org.apache.ws.jaxme.sqls.db2;
18
19 import java.util.ArrayList JavaDoc;
20 import java.util.Iterator JavaDoc;
21 import java.util.List JavaDoc;
22
23 import org.apache.ws.jaxme.sqls.impl.SQLFactoryImpl;
24
25
26 /** <p>Default implementation of a DB2 tablespace.</p>
27  *
28  * @author <a HREF="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
29  */

30 public class TableSpaceImpl implements TableSpace {
31   public static class NameImpl extends SQLFactoryImpl.IdentImpl
32       implements TableSpace.Name {
33     public NameImpl(String JavaDoc pName) { super(pName); }
34   }
35
36   public static class SystemManagedContainerImpl implements TableSpace.SystemManagedContainer {
37     private String JavaDoc file;
38     public boolean isSystemManaged() { return true; }
39     public boolean isDatabaseManaged() { return false; }
40     public String JavaDoc getFile() { return file; }
41     public void setFile(String JavaDoc pFile) { file = pFile; }
42   }
43
44   public static class DatabaseManagedContainerImpl implements TableSpace.DatabaseManagedContainer {
45     private String JavaDoc file;
46     private String JavaDoc device;
47     private long numPages;
48     public boolean isSystemManaged() { return false; }
49     public boolean isDatabaseManaged() { return true; }
50     public void setFile(String JavaDoc pFile) { file = pFile; }
51     public String JavaDoc getFile() { return file; }
52     public void setDevice(String JavaDoc pDevice) { device = pDevice; }
53     public String JavaDoc getDevice() { return device; }
54     public long getNumOfPages() { return numPages; }
55     public void setNumOfPages(long pNumOfPages) { numPages = pNumOfPages; }
56   }
57
58   private DB2SQLFactory sqlFactory;
59   private BufferPool bufferPool;
60   private TableSpace.Name name;
61   private TableSpace.Type type;
62   private List JavaDoc containers = new ArrayList JavaDoc();
63   private Long JavaDoc extentSize, prefetchSize;
64   private PageSize pageSize;
65   private Number JavaDoc overhead, transferRate;
66   private Boolean JavaDoc droppedTableRecovery;
67
68   protected TableSpaceImpl(DB2SQLFactory pFactory, TableSpace.Name pName,
69                             TableSpace.Type pType) {
70     sqlFactory = pFactory;
71     name = pName;
72     type = pType;
73   }
74
75   public DB2SQLFactory getSQLFactory() { return sqlFactory; }
76   public TableSpace.Name getName() { return name; }
77   public TableSpace.Type getType() { return type; }
78   public PageSize getPageSize() {
79      BufferPool bPool = getBufferPool();
80      return bPool == null ? pageSize : bPool.getPageSize();
81   }
82   public void setPageSize(PageSize pSize) { pageSize = pSize; }
83   public Long JavaDoc getExtentSize() { return extentSize; }
84   public void setExtentSize(Long JavaDoc pSize) { extentSize = pSize; }
85   public Long JavaDoc getPrefetchSize() { return prefetchSize; }
86   public void setPrefetchSize(Long JavaDoc pSize) { prefetchSize = pSize; }
87   public Number JavaDoc getOverhead() { return overhead; }
88   public void setOverhead(Number JavaDoc pOverhead) { overhead = pOverhead; }
89   public Number JavaDoc getTransferRate() { return transferRate; }
90   public void setTransferRate(Number JavaDoc pTransferRate) { transferRate = pTransferRate; }
91   public Boolean JavaDoc hasDroppedTableRecovery() { return droppedTableRecovery; }
92   public void setDroppedTableRecovery(Boolean JavaDoc pRecoverable) { droppedTableRecovery = pRecoverable; }
93   public boolean isPredefined() { return false; }
94
95   public Container newSystemManagedContainer(String JavaDoc pFile) {
96     SystemManagedContainerImpl container = new SystemManagedContainerImpl();
97     container.setFile(pFile);
98     containers.add(container);
99     return container;
100   }
101
102   public Container newDatabaseManagedContainerInFile(String JavaDoc pFile, long pNumPages) {
103     DatabaseManagedContainerImpl container = new DatabaseManagedContainerImpl();
104     container.setFile(pFile);
105     container.setNumOfPages(pNumPages);
106     containers.add(container);
107     return container;
108   }
109
110   public Container newDatabaseManagedContainerInDevice(String JavaDoc pDevice, long pNumPages) {
111     DatabaseManagedContainerImpl container = new DatabaseManagedContainerImpl();
112     container.setDevice(pDevice);
113     container.setNumOfPages(pNumPages);
114     containers.add(container);
115     return container;
116   }
117
118   public Iterator JavaDoc getContainers() {
119     return containers.iterator();
120   }
121
122   public void setBufferPool(BufferPool pBufferPool) {
123     bufferPool = pBufferPool;
124   }
125
126   public BufferPool getBufferPool() {
127     return bufferPool;
128   }
129 }
130
Popular Tags