KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2
3    Derby - Class org.apache.derby.impl.sql.execute.rts.RealUpdateResultSetStatistics
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.StoredFormatIds;
25
26 import org.apache.derby.iapi.services.i18n.MessageService;
27 import org.apache.derby.iapi.reference.SQLState;
28
29 import org.apache.derby.iapi.services.io.FormatableHashtable;
30
31 import java.io.ObjectOutput JavaDoc;
32 import java.io.ObjectInput JavaDoc;
33 import java.io.IOException JavaDoc;
34
35 /**
36   ResultSetStatistics implemenation for UpdateResultSet.
37
38   @author jerry
39
40 */

41 public class RealUpdateResultSetStatistics
42     extends RealNoRowsResultSetStatistics
43 {
44
45
46     /* Leave these fields public for object inspectors */
47     public int rowCount;
48     public boolean deferred;
49     public boolean tableLock;
50     public int indexesUpdated;
51
52     // CONSTRUCTORS
53

54     /**
55      *
56      *
57      */

58     public RealUpdateResultSetStatistics(
59                                 int rowCount,
60                                 boolean deferred,
61                                 int indexesUpdated,
62                                 boolean tableLock,
63                                 long executeTime,
64                                 ResultSetStatistics sourceResultSetStatistics
65                                 )
66     {
67         super(executeTime, sourceResultSetStatistics);
68         this.rowCount = rowCount;
69         this.deferred = deferred;
70         this.indexesUpdated = indexesUpdated;
71         this.tableLock = tableLock;
72         this.sourceResultSetStatistics = sourceResultSetStatistics;
73     }
74
75
76     // ResultSetStatistics interface
77

78     /**
79      * Return the statement execution plan as a String.
80      *
81      * @param depth Indentation level.
82      *
83      * @return String The statement execution plan as a String.
84      */

85     public String JavaDoc getStatementExecutionPlanText(int depth)
86     {
87         initFormatInfo(depth);
88
89
90
91         return
92             indent + MessageService.getTextMessage(
93                                             SQLState.RTS_UPDATE_RS_USING,
94                                             MessageService.getTextMessage(
95                                                 tableLock ?
96                                                 SQLState.LANG_TABLE :
97                                                 SQLState.LANG_ROW)
98                                             ) +
99                 ":\n" +
100             indent + MessageService.getTextMessage(SQLState.RTS_DEFERRED) +
101                 ": " + deferred + "\n" +
102             indent + MessageService.getTextMessage(
103                                                 SQLState.RTS_ROWS_UPDATED) +
104                 " = " + rowCount + "\n" +
105             indent + MessageService.getTextMessage(
106                                                 SQLState.RTS_INDEXES_UPDATED) +
107                 " = " + indexesUpdated + "\n" +
108             dumpTimeStats(indent) + ((sourceResultSetStatistics == null) ? "" :
109             sourceResultSetStatistics.getStatementExecutionPlanText(1));
110     }
111
112     /**
113      * Return information on the scan nodes from the statement execution
114      * plan as a String.
115      *
116      * @param depth Indentation level.
117      * @param tableName if not NULL then print information for this table only
118      *
119      * @return String The information on the scan nodes from the
120      * statement execution plan as a String.
121      */

122     public String JavaDoc getScanStatisticsText(String JavaDoc tableName, int depth)
123     {
124         if (sourceResultSetStatistics == null)
125             return "";
126
127         return sourceResultSetStatistics.getScanStatisticsText(tableName, depth);
128     }
129
130     // Formatable methods
131

132
133     // Class implementation
134

135     public String JavaDoc toString()
136     {
137         return getStatementExecutionPlanText(0);
138     }
139     /**
140    * Format for display, a name for this node.
141      *
142      */

143   public String JavaDoc getNodeName(){
144     return MessageService.getTextMessage(SQLState.RTS_UPDATE);
145   }
146 }
147
Popular Tags