EMMA Coverage Report (generated Wed Jun 28 22:15:27 PDT 2006)
[all classes][org.apache.derby.impl.sql]

COVERAGE SUMMARY FOR SOURCE FILE [CursorInfo.java]

nameclass, %method, %block, %line, %
CursorInfo.java100% (1/1)83%  (5/6)34%  (57/169)50%  (21/42)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class CursorInfo100% (1/1)83%  (5/6)34%  (57/169)50%  (21/42)
CursorInfo (): void 100% (1/1)100% (3/3)100% (2/2)
CursorInfo (int, ExecCursorTableReference, ResultColumnDescriptor [], String ... 100% (1/1)100% (15/15)100% (6/6)
getTypeFormatId (): int 100% (1/1)100% (2/2)100% (1/1)
readExternal (ObjectInput): void 100% (1/1)56%  (20/36)64%  (7/11)
toString (): String 0%   (0/1)0%   (0/96)0%   (0/17)
writeExternal (ObjectOutput): void 100% (1/1)100% (17/17)100% (5/5)

1/*
2 
3   Derby - Class org.apache.derby.impl.sql.CursorInfo
4 
5   Copyright 1999, 2004 The Apache Software Foundation or its licensors, as applicable.
6 
7   Licensed under the Apache License, Version 2.0 (the "License");
8   you may not use this file except in compliance with the License.
9   You may obtain a copy of the License at
10 
11      http://www.apache.org/licenses/LICENSE-2.0
12 
13   Unless required by applicable law or agreed to in writing, software
14   distributed under the License is distributed on an "AS IS" BASIS,
15   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   See the License for the specific language governing permissions and
17   limitations under the License.
18 
19 */
20 
21package org.apache.derby.impl.sql;
22 
23import org.apache.derby.iapi.sql.ResultColumnDescriptor;
24import org.apache.derby.iapi.sql.execute.ExecCursorTableReference;
25import org.apache.derby.iapi.services.sanity.SanityManager;
26 
27import org.apache.derby.iapi.services.io.ArrayUtil;
28import org.apache.derby.iapi.services.io.StoredFormatIds;
29import org.apache.derby.iapi.services.io.FormatIdUtil;
30import org.apache.derby.iapi.services.io.Formatable;
31 
32import java.io.ObjectOutput;
33import java.io.ObjectInput;
34import java.io.IOException;
35/**
36 * A basic holder for information about cursors
37 * for execution.
38 * 
39 * @author jamie
40 */
41public class CursorInfo
42        implements Formatable
43{
44 
45        /********************************************************
46        **
47        **        This class implements Formatable. That means that it
48        **        can write itself to and from a formatted stream. If
49        **        you add more fields to this class, make sure that you
50        **        also write/read them with the writeExternal()/readExternal()
51        **        methods.
52        **
53        **        If, inbetween releases, you add more fields to this class,
54        **        then you should bump the version number emitted by the getTypeFormatId()
55        **        method.
56        **
57        ********************************************************/
58 
59        ExecCursorTableReference        targetTable; 
60        ResultColumnDescriptor[]        targetColumns; 
61        String[]                                         updateColumns; 
62        int                                                 updateMode;
63 
64        /**
65         * Niladic constructor for Formatable
66         */
67        public CursorInfo()
68        {
69        }
70 
71        /**
72         *
73         */
74        public CursorInfo
75        (
76                int                                                        updateMode,
77                ExecCursorTableReference        targetTable,
78                ResultColumnDescriptor[]        targetColumns,
79                String[]                                        updateColumns
80        )
81        {
82                this.updateMode = updateMode;
83                this.targetTable = targetTable;
84                this.targetColumns = targetColumns;
85                this.updateColumns = updateColumns;
86        }
87 
88        //////////////////////////////////////////////
89        //
90        // FORMATABLE
91        //
92        //////////////////////////////////////////////
93        /**
94         * Write this object out
95         *
96         * @param out write bytes here
97         *
98          * @exception IOException thrown on error
99         */
100        public void writeExternal(ObjectOutput out) throws IOException
101        {
102                out.writeInt(updateMode);
103                out.writeObject(targetTable);
104                ArrayUtil.writeArray(out, targetColumns);
105                ArrayUtil.writeArray(out, updateColumns);
106        }
107 
108        /**
109         * Read this object from a stream of stored objects.
110         *
111         * @param in read this.
112         *
113         * @exception IOException                                        thrown on error
114         * @exception ClassNotFoundException                thrown on error
115         */
116        public void readExternal(ObjectInput in)
117                throws IOException, ClassNotFoundException
118        {
119                updateMode = in.readInt();
120                targetTable = (ExecCursorTableReference)in.readObject();
121                int len = ArrayUtil.readArrayLength(in);
122                if (len != 0)
123                {
124                        targetColumns = new ResultColumnDescriptor[len];
125                        ArrayUtil.readArrayItems(in, targetColumns);
126                }
127                len = ArrayUtil.readArrayLength(in);
128                if (len != 0)
129                {
130                        updateColumns = new String[len];
131                        ArrayUtil.readArrayItems(in, updateColumns);
132                }
133        }
134        
135        /**
136         * Get the formatID which corresponds to this class.
137         *
138         *        @return        the formatID of this class
139         */
140        public        int        getTypeFormatId()        { return StoredFormatIds.CURSOR_INFO_V01_ID; }
141 
142        public String toString()
143        {
144                if (SanityManager.DEBUG)
145                {
146                        StringBuffer strbuf = new StringBuffer();
147                
148                        strbuf.append("CursorInfo"+
149                                "\n\tupdateMode: "+updateMode+
150                                "\n\ttargetTable: "+targetTable+
151                                "\n\tupdateColumns: ");
152 
153                        if (updateColumns == null)
154                        {
155                                strbuf.append("NULL\n");
156                        }
157                        else
158                        {
159                                strbuf.append("{");
160                                for (int i = 0; i < updateColumns.length; i++)
161                                {
162                                        if (i > 0)
163                                                strbuf.append(",");
164                                        strbuf.append(updateColumns[i]);
165                                }
166                                strbuf.append(")\n");
167                        }
168 
169                        strbuf.append("\tTargetColumnDescriptors: \n");
170                        if (targetColumns == null)
171                        {
172                                strbuf.append("NULL");
173                        }
174                        else
175                        {
176                                for (int i = 0; i < targetColumns.length; i++)
177                                {
178                                        strbuf.append(targetColumns[i]);
179                                }
180                                strbuf.append("\n");
181                        }
182                        return strbuf.toString();        
183                }
184                else
185                {
186                        return "";
187                }
188        }
189}

[all classes][org.apache.derby.impl.sql]
EMMA 2.0.5312 (C) Vladimir Roubtsov