1 27 package org.htmlparser.util; 28 29 import java.io.Serializable ; 30 31 39 public class DefaultParserFeedback 40 implements 41 ParserFeedback, 42 Serializable 43 { 44 47 public static final int QUIET = 0; 48 49 52 public static final int NORMAL = 1; 53 54 57 public static final int DEBUG = 2; 58 59 68 protected int mMode; 69 70 81 public DefaultParserFeedback (int mode) 82 { 83 if (mode<QUIET||mode>DEBUG) 84 throw new IllegalArgumentException ( 85 "illegal mode (" 86 + mode 87 + "), must be one of: QUIET, NORMAL, DEBUG"); 88 mMode = mode; 89 } 90 91 94 public DefaultParserFeedback () 95 { 96 this (NORMAL); 97 } 98 99 103 public void info (String message) 104 { 105 if (QUIET != mMode) 106 System.out.println ("INFO: " + message); 107 } 108 109 113 public void warning (String message) 114 { 115 if (QUIET != mMode) 116 System.out.println ("WARNING: " + message); 117 } 118 119 124 public void error (String message, ParserException exception) 125 { 126 if (QUIET != mMode) 127 { 128 System.out.println ("ERROR: " + message); 129 if (DEBUG == mMode && (null != exception)) 130 exception.printStackTrace (); 131 } 132 } 133 } 134 135 | Popular Tags |