001: /*
002:
003: Derby - Class org.apache.derby.impl.sql.execute.rts.RealNoRowsResultSetStatistics
004:
005: Licensed to the Apache Software Foundation (ASF) under one or more
006: contributor license agreements. See the NOTICE file distributed with
007: this work for additional information regarding copyright ownership.
008: The ASF licenses this file to you under the Apache License, Version 2.0
009: (the "License"); you may not use this file except in compliance with
010: the License. You may obtain a copy of the License at
011:
012: http://www.apache.org/licenses/LICENSE-2.0
013:
014: Unless required by applicable law or agreed to in writing, software
015: distributed under the License is distributed on an "AS IS" BASIS,
016: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: See the License for the specific language governing permissions and
018: limitations under the License.
019:
020: */
021:
022: package org.apache.derby.impl.sql.execute.rts;
023:
024: import org.apache.derby.iapi.services.io.Formatable;
025: import org.apache.derby.iapi.services.i18n.MessageService;
026: import org.apache.derby.iapi.reference.SQLState;
027:
028: import java.io.ObjectOutput;
029: import java.io.ObjectInput;
030: import java.io.IOException;
031:
032: import java.util.Vector;
033:
034: /**
035: ResultSetStatistics implemenation for NoPutResultSetImpl.
036:
037: @author jerry
038:
039: */
040: abstract class RealNoRowsResultSetStatistics implements
041: ResultSetStatistics {
042:
043: /* Leave these fields public for object inspectors */
044:
045: /* fields used for formating run time statistics output */
046: protected String indent;
047: protected String subIndent;
048: protected int sourceDepth;
049: public ResultSetStatistics sourceResultSetStatistics;
050: protected long executeTime;
051:
052: // variables to implement the inspectable interface.
053: // Do these have to be public?
054: public long inspectOverall;
055: public long inspectNum;
056: public String inspectDesc;
057:
058: // CONSTRUCTORS
059:
060: /**
061: * Initializes the time spent in NoRowsResultSet minus the source
062: * result set.
063: */
064: public RealNoRowsResultSetStatistics(long executeTime,
065: ResultSetStatistics sourceRS) {
066: if (sourceRS instanceof RealBasicNoPutResultSetStatistics)
067: this .executeTime = executeTime
068: - ((RealBasicNoPutResultSetStatistics) sourceRS)
069: .getTotalTime();
070: }
071:
072: /**
073: * Initialize the format info for run time statistics.
074: */
075: protected void initFormatInfo(int depth) {
076: char[] indentchars = new char[depth];
077: char[] subIndentchars = new char[depth + 1];
078: sourceDepth = depth + 1;
079:
080: /*
081: ** Form an array of tab characters for indentation.
082: */
083: subIndentchars[depth] = '\t';
084: while (depth > 0) {
085: subIndentchars[depth - 1] = '\t';
086: indentchars[depth - 1] = '\t';
087: depth--;
088: }
089:
090: indent = new String(indentchars);
091: subIndent = new String(subIndentchars);
092: }
093:
094: /**
095: * Dump out the time information for run time stats.
096: *
097: * @return String to be printed out.
098: */
099: protected String dumpTimeStats(String indent) {
100: return indent
101: + MessageService
102: .getTextMessage(SQLState.RTS_EXECUTE_TIME)
103: + " = " + executeTime + "\n";
104: }
105:
106: /**
107: * Get the objects to be displayed when this tree object is expanded.
108: * <P>
109: * The objects returned can be of any type, including addtional Inspectables.
110: *
111: * @return java.util.Vector A vector of objects.
112: */
113: public Vector getChildren() {
114: Vector children = new Vector();
115: children.addElement(sourceResultSetStatistics);
116: return children;
117: }
118:
119: /**
120: * Format for display, a name for this node.
121: *
122: */
123: public abstract String getNodeName();
124:
125: /**
126: * Get the estimated row count for the number of rows returned
127: * by the associated query or statement.
128: *
129: * @return The estimated number of rows returned by the associated
130: * query or statement.
131: */
132: public double getEstimatedRowCount() {
133: return 0.0;
134: }
135: }
|