001: /* Licensed to the Apache Software Foundation (ASF) under one or more
002: * contributor license agreements. See the NOTICE file distributed with
003: * this work for additional information regarding copyright ownership.
004: * The ASF licenses this file to You under the Apache License, Version 2.0
005: * (the "License"); you may not use this file except in compliance with
006: * the License. You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package org.apache.harmony.luni.util;
018:
019: import java.io.PrintStream;
020:
021: /**
022: * This exception is thrown by methods that are not currently implemented, so
023: * that programs that call the stubs fail early and predictably.
024: *
025: */
026: public class NotImplementedException extends RuntimeException {
027:
028: /**
029: * Comment for <code>serialVersionUID</code>
030: */
031: private static final long serialVersionUID = 1L;
032:
033: /**
034: * Default constructor.
035: */
036: public NotImplementedException() {
037: this (System.err);
038: }
039:
040: /*
041: * Constructor that prints the message of the exception on the given stream
042: */
043: @SuppressWarnings("nls")
044: public NotImplementedException(PrintStream stream) {
045: super ();
046: stream.println("*** NOT IMPLEMENTED EXCEPTION ***");
047: StackTraceElement thrower = getStackTrace()[0];
048: stream.println("*** thrown from class -> "
049: + thrower.getClassName());
050: stream.println("*** method -> "
051: + thrower.getMethodName());
052:
053: stream.print("*** defined in -> ");
054: if (thrower.isNativeMethod()) {
055: stream.println("a native method");
056: } else {
057: String fileName = thrower.getFileName();
058: if (fileName == null) {
059: stream.println("an unknown source");
060: } else {
061: int lineNumber = thrower.getLineNumber();
062: stream.print("the file \"" + fileName + "\"");
063: if (lineNumber >= 0) {
064: stream.print(" on line #" + lineNumber);
065: }
066: stream.println();
067: }
068: }
069: }
070:
071: /**
072: * Constructor that takes a reason message.
073: *
074: * @param detailMessage
075: */
076: public NotImplementedException(String detailMessage) {
077: super (detailMessage);
078: }
079:
080: /**
081: * Constructor that takes a reason and a wrapped exception.
082: *
083: * @param detailMessage
084: * @param throwable
085: */
086: public NotImplementedException(String detailMessage,
087: Throwable throwable) {
088: super (detailMessage, throwable);
089: }
090:
091: /**
092: * Constructor that takes a wrapped exception.
093: *
094: * @param throwable
095: */
096: public NotImplementedException(Throwable throwable) {
097: super(throwable);
098: }
099:
100: }
|