001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.openide;
043:
044: import java.util.Set;
045: import java.util.Collection;
046: import java.util.HashSet;
047: import java.util.Iterator;
048:
049: /**
050: * A stub implementation of org.openide.ErrorManager to enable the tab control
051: * to be used as a standalone jar. Does nothing except print to stderr.
052: *
053: * @author Tim Boudreau
054: */
055: public final class ErrorManager extends Object {
056: private static final ErrorManager INSTANCE = new ErrorManager();
057:
058: // XXX note that these levels accidentally used hex rather than binary,
059: // so it goes 0, 1, 16, 256, ....
060: // Unfortunately too late to change now: public int constants are part of the
061: // API - documented, inlined into compiled code, etc.
062:
063: /**
064: * Undefined severity.
065: * May be used only in {@link #notify(int, Throwable)}
066: * and {@link #annotate(Throwable, int, String, String, Throwable, Date)}.
067: */
068: public static final int UNKNOWN = 0x00000000;
069: /** Message that would be useful for tracing events but which need not be a problem. */
070: public static final int INFORMATIONAL = 0x00000001;
071: /** Something went wrong in the software, but it is continuing and the user need not be bothered. */
072: public static final int WARNING = 0x00000010;
073: /** Something the user should be aware of. */
074: public static final int USER = 0x00000100;
075: /** Something went wrong, though it can be recovered. */
076: public static final int EXCEPTION = 0x00001000;
077: /** Serious problem, application may be crippled. */
078: public static final int ERROR = 0x00010000;
079:
080: public static ErrorManager getDefault() {
081: return INSTANCE;
082: }
083:
084: public Throwable annotate(Throwable t, int severity,
085: String message, String localizedMessage,
086: Throwable stackTrace, java.util.Date date) {
087: if (stackTrace != null) {
088: stackTrace.printStackTrace();
089: }
090: return stackTrace;
091: }
092:
093: public void notify(int severity, Throwable t) {
094: t.printStackTrace();
095: }
096:
097: public final void notify(Throwable t) {
098: notify(UNKNOWN, t);
099: }
100:
101: public void log(int severity, String s) {
102: System.err.println(s);
103: }
104:
105: public final void log(String s) {
106: log(INFORMATIONAL, s);
107: }
108:
109: public boolean isLoggable(int severity) {
110: return true;
111: }
112:
113: public ErrorManager getInstance(String name) {
114: return getDefault();
115: }
116:
117: public final Throwable annotate(Throwable t, String localizedMessage) {
118: return annotate(t, UNKNOWN, null, localizedMessage, null, null);
119: }
120:
121: public final Throwable annotate(Throwable target, Throwable t) {
122: return annotate(target, UNKNOWN, null, null, t, null);
123: }
124:
125: }
|