KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > impl > sql > execute > rts > RealNoRowsResultSetStatistics


1 /*
2
3    Derby - Class org.apache.derby.impl.sql.execute.rts.RealNoRowsResultSetStatistics
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to you under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21
22 package org.apache.derby.impl.sql.execute.rts;
23
24 import org.apache.derby.iapi.services.io.Formatable;
25 import org.apache.derby.iapi.services.i18n.MessageService;
26 import org.apache.derby.iapi.reference.SQLState;
27
28 import java.io.ObjectOutput JavaDoc;
29 import java.io.ObjectInput JavaDoc;
30 import java.io.IOException JavaDoc;
31
32 import java.util.Vector JavaDoc;
33
34 /**
35   ResultSetStatistics implemenation for NoPutResultSetImpl.
36
37   @author jerry
38
39 */

40 abstract class RealNoRowsResultSetStatistics
41     implements ResultSetStatistics
42 {
43
44
45     /* Leave these fields public for object inspectors */
46
47     /* fields used for formating run time statistics output */
48     protected String JavaDoc indent;
49     protected String JavaDoc subIndent;
50     protected int sourceDepth;
51     public ResultSetStatistics sourceResultSetStatistics;
52     protected long executeTime;
53
54     // variables to implement the inspectable interface.
55
// Do these have to be public?
56
public long inspectOverall;
57     public long inspectNum;
58     public String JavaDoc inspectDesc;
59
60     // CONSTRUCTORS
61

62     /**
63      * Initializes the time spent in NoRowsResultSet minus the source
64      * result set.
65      */

66     public RealNoRowsResultSetStatistics(long executeTime,
67                                          ResultSetStatistics sourceRS)
68     {
69         if (sourceRS instanceof RealBasicNoPutResultSetStatistics)
70             this.executeTime = executeTime -
71                 ((RealBasicNoPutResultSetStatistics)sourceRS).getTotalTime();
72     }
73  
74     /**
75      * Initialize the format info for run time statistics.
76      */

77     protected void initFormatInfo(int depth)
78     {
79         char [] indentchars = new char[depth];
80         char [] subIndentchars = new char[depth + 1];
81         sourceDepth = depth + 1;
82
83         /*
84         ** Form an array of tab characters for indentation.
85         */

86         subIndentchars[depth] = '\t';
87         while (depth > 0)
88         {
89             subIndentchars[depth - 1] = '\t';
90             indentchars[depth - 1] = '\t';
91             depth--;
92         }
93         
94         indent = new String JavaDoc(indentchars);
95         subIndent = new String JavaDoc(subIndentchars);
96     }
97
98     /**
99      * Dump out the time information for run time stats.
100      *
101      * @return String to be printed out.
102      */

103     protected String JavaDoc dumpTimeStats(String JavaDoc indent)
104     {
105         return
106             indent + MessageService.getTextMessage(SQLState.RTS_EXECUTE_TIME) +
107                             " = " + executeTime + "\n";
108     }
109     /**
110      * Get the objects to be displayed when this tree object is expanded.
111      * <P>
112      * The objects returned can be of any type, including addtional Inspectables.
113    *
114      * @return java.util.Vector A vector of objects.
115      */

116   public Vector JavaDoc getChildren(){
117     Vector JavaDoc children = new Vector JavaDoc();
118     children.addElement(sourceResultSetStatistics);
119     return children;
120   }
121
122     /**
123    * Format for display, a name for this node.
124      *
125      */

126   public abstract String JavaDoc getNodeName();
127
128     /**
129      * Get the estimated row count for the number of rows returned
130      * by the associated query or statement.
131      *
132      * @return The estimated number of rows returned by the associated
133      * query or statement.
134      */

135     public double getEstimatedRowCount()
136     {
137         return 0.0;
138     }
139 }
140
Popular Tags