1 /* 2 3 Derby - Class org.apache.derby.iapi.services.diag.Diagnosticable 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.iapi.services.diag; 23 24 import org.apache.derby.iapi.error.StandardException; 25 26 import java.util.Properties; 27 28 /** 29 30 The Diagnosticable class implements the Diagnostics protocol, and can 31 be used as the parent class for all other Diagnosticable objects. 32 33 **/ 34 35 public interface Diagnosticable 36 { 37 /* 38 ** Methods of Diagnosticable 39 */ 40 public void init(Object obj); 41 42 /** 43 * Default implementation of diagnostic on the object. 44 * <p> 45 * This routine returns a string with whatever diagnostic information 46 * you would like to provide about this associated object passed in 47 * the init() call. 48 * <p> 49 * This routine should be overriden by a real implementation of the 50 * diagnostic information you would like to provide. 51 * <p> 52 * 53 * @return A string with diagnostic information about the object. 54 * 55 * @exception StandardException Standard cloudscape exception policy 56 **/ 57 public String diag() throws StandardException; 58 59 /** 60 * Default implementation of detail diagnostic on the object. 61 * <p> 62 * This interface provides a way for an object to pass back pieces of 63 * information as requested by the caller. The information is passed 64 * back and forth through the properties argument. It is expected that 65 * the caller knows what kind of information to ask for, and correctly 66 * handles the situation when the diagnostic object can't provide the 67 * information. 68 * <p> 69 * As an example assume an object TABLE exists, and that we have created 70 * an object D_TABLE that knows how to return the number of pages in the 71 * TABLE object. The code to get that information out would looks something 72 * like the following: 73 * <p> 74 * print_num_pages(Object table) 75 * { 76 * Properties prop = new Properties(); 77 * prop.put(Page.DIAG_NUM_PAGES, ""); 78 * 79 * DiagnosticUtil.findDiagnostic(table).diag_detail(prop); 80 * 81 * System.out.println( 82 * "number of pages = " + prop.getProperty(Page.DIAG_NUM_PAGES)); 83 * } 84 * <p> 85 * This routine should be overriden if there is detail diagnostics to 86 * be provided by a real implementation. 87 * <p> 88 * 89 * @exception StandardException Standard cloudscape exception policy 90 **/ 91 public void diag_detail(Properties prop) throws StandardException; 92 } 93