KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > daffodilwoods > daffodildb > server > sql99 > dml > declarecursor > Cursor


1 package com.daffodilwoods.daffodildb.server.sql99.dml.declarecursor;
2
3 import com.daffodilwoods.daffodildb.server.sql99.dql.iterator.*;
4
5 /**
6  * Objective of this class is to provide get/set methods to get & set the basic
7  * properties and information of cursor to be declared.
8  * of cursor.
9  * <p>Title: </p>
10  * <p>Description: </p>
11  * <p>Copyright: Copyright (c) 2003</p>
12  * <p>Company: </p>
13  * @author unascribed
14  * @version 1.0
15  */

16 public class Cursor implements _Cursor {
17
18    public String JavaDoc sensitivity, cursorName;
19    boolean holdability, returnability, scrollability, updatabilityClause, state, iteratorState;
20    String JavaDoc[] columnNames;
21    private _Iterator iterator;
22    cursorspecification _cursorSpecification;
23    private boolean isFirstFetchStatementFired = false;
24
25    /**
26     * Constructor: Constructs a new instance of this class with the specified arguments.
27     * @param sensitivty specifies cursor is sensitive & insensitive or asensitive
28     * @param holdablty specifies cursor is readOnly or not
29     * @param returnablty specifies with return or without return
30     * @param scrollablty specifies scrollable or non-scrollable
31     * @param Cname name of the cursor
32     * @param cursorSpec
33     */

34    public Cursor(String JavaDoc sensitivty, boolean holdablty, boolean returnablty, boolean scrollablty, String JavaDoc Cname, cursorspecification cursorSpec) {
35       sensitivity = sensitivty;
36       holdability = holdablty;
37       returnability = returnablty;
38       scrollability = scrollablty;
39       cursorName = Cname;
40       _cursorSpecification = cursorSpec;
41    }
42
43    /**
44     * Sets cursor state depending on fetching is performed first time or not.
45     * @param flag
46     */

47    public void setCursorState(boolean flag) {
48       state = flag;
49    }
50
51    /**
52     * Associates the resultset(iterator) of the query expression specified to
53     * the declared cursor.
54     * @param iter
55     */

56    public void addIterator(_Iterator iter) {
57       iterator = iter;
58    }
59
60    /**
61     * This method provides the cursor specification specified in cursor
62     * declaration, which is used to determine qyery-specification, query-parameters
63     * and query-references.
64     * @return
65     */

66    public Object JavaDoc getCursorSpecification() {
67       return _cursorSpecification;
68    }
69
70    /**
71     * Retruns the current state of cursor.
72     * @return
73     */

74    public boolean getCursorState() {
75       return state;
76    }
77
78    /**
79     * Determines the sensitivity of this cursor.
80     * @return
81     */

82    public String JavaDoc getCursorSensitivity() {
83       return sensitivity;
84    }
85
86    /**
87     * Determines the declared cursor is holdable or not.
88     * @return
89     */

90    public boolean getCursorHoldability() {
91       return holdability;
92    }
93
94    /**
95     * Returns the cursor is scrollable or not.
96     * @return
97     */

98    public boolean getCursorScrollability() {
99       return scrollability;
100    }
101
102    /**
103     * This method sets the updatability and the columns specified in
104     * declaration of the cursor.
105     * @param flag
106     * @param columns
107     */

108    public void setUpdatabilityClause(boolean flag, String JavaDoc[] columns) {
109       updatabilityClause = flag;
110       columnNames = columns;
111    }
112
113    /**
114     * This method is used to close the cursor. It sets the cusrsor state to ]
115     * false and cursorspecification and iterator to null.
116     */

117    public void close() {
118       setCursorState(false);
119       _cursorSpecification = null;
120       iterator = null;
121    }
122
123    /**
124     * Returns the cursor name specified.
125     * @return
126     */

127    public String JavaDoc getCursorName() {
128       return cursorName;
129    }
130
131    /**
132     * Returns an instance of iterator created on the specified query-specification.
133     * @return
134     */

135    public _Iterator getIterator() {
136       return iterator;
137    }
138
139    /**
140     * Determines the cursor is updatable or not.
141     * @return
142     */

143    public boolean getUpdatabilityClause() {
144       return updatabilityClause;
145    }
146
147    public String JavaDoc toString() {
148       return " CURSOR -- [ Name : " + cursorName + " || Holdability : " + holdability + " || Scrollability : " + scrollability + " || Sensitivity : " + sensitivity + " || Returnability : " + returnability + " || Updatability : " + updatabilityClause + " ] ";
149    }
150
151    public void setIteratorState(boolean bool) {
152       iteratorState = bool;
153    }
154
155    public boolean getIteratorState() {
156       return iteratorState;
157    }
158
159    /**
160     * Returns true or false depending fetch statement is fired first or not.
161     * @return
162     */

163    public boolean isFetchStatementFired() {
164       return isFirstFetchStatementFired;
165    }
166
167    /**
168     * Sets the variable isFirstFetchStatementFired, acc. to passed flag.
169     * @param flag
170     */

171    public void setFetchStatementFired(boolean flag) {
172       isFirstFetchStatementFired = flag;
173    }
174 }
175
Popular Tags