1/* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18package com.sun.org.apache.xml.internal.resolver.helpers; 19 20/** 21 * Static debugging/messaging class for Catalogs. 22 * 23 * <p>This class defines a set of static methods that can be called 24 * to produce debugging messages. Messages have an associated "debug 25 * level" and messages below the current setting are not displayed.</p> 26 * 27 * @author Norman Walsh 28 * <a href="mailto:Norman.Walsh@Sun.COM">Norman.Walsh@Sun.COM</a> 29 * 30 */ 31public class Debug { 32 /** The internal debug level. */ 33 protected int debug = 0; 34 35 /** Constructor */ 36 public Debug() { 37 // nop 38 } 39 40 /** Set the debug level for future messages. */ 41 public void setDebug(int newDebug) { 42 debug = newDebug; 43 } 44 45 /** Get the current debug level. */ 46 public int getDebug() { 47 return debug; 48 } 49 50 /** 51 * Print debug message (if the debug level is high enough). 52 * 53 * <p>Prints "the message"</p> 54 * 55 * @param level The debug level of this message. This message 56 * will only be 57 * displayed if the current debug level is at least equal to this 58 * value. 59 * @param message The text of the message. 60 */ 61 public void message(int level, String message) { 62 if (debug >= level) { 63 System.out.println(message); 64 } 65 } 66 67 /** 68 * Print debug message (if the debug level is high enough). 69 * 70 * <p>Prints "the message: spec"</p> 71 * 72 * @param level The debug level of this message. This message 73 * will only be 74 * displayed if the current debug level is at least equal to this 75 * value. 76 * @param message The text of the message. 77 * @param spec An argument to the message. 78 */ 79 public void message(int level, String message, String spec) { 80 if (debug >= level) { 81 System.out.println(message + ": " + spec); 82 } 83 } 84 85 /** 86 * Print debug message (if the debug level is high enough). 87 * 88 * <p>Prints "the message: spec1" and "spec2" indented on the next line.</p> 89 * 90 * @param level The debug level of this message. This message 91 * will only be 92 * displayed if the current debug level is at least equal to this 93 * value. 94 * @param message The text of the message. 95 * @param spec1 An argument to the message. 96 * @param spec2 Another argument to the message. 97 */ 98 public void message(int level, String message, 99 String spec1, String spec2) { 100 if (debug >= level) { 101 System.out.println(message + ": " + spec1); 102 System.out.println("\t" + spec2); 103 } 104 } 105} 106