/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* or packager/legal/LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at packager/legal/LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
/*
**
** This Module contains replacements for various types of print statements used for
** debugging purposes.
** Example:
** Replace this
** System.out.println("test message");
** With this
** Print.println("test message");
** or
** Print.dprintln("test message");
** The advantage of using Print.println is that the message ("test message") can be
** pre-pended with the actual location of the print statement itself. For instance,
** Issuing a call to 'Print.dprintln("hello world")' may print a console message
** similar to the following:
** [MyCustomClass.doSomething:291] hello world
** This indicates that the 'Print.dprintln' is located in the method 'doSomething'
** in the class 'MyCustomClass' at source file line number 291. This will help
** show the precise location of various debug message print statements that should
** be removed prior to FCS. (Note: the package is remove from the class before
** printing the stack frame to avoid creating a print line which is excessively long)
**
** Difference between 'println' and 'dprintln':
** Each 'printXXX' method in this module has a corresponding 'dprintXXX' method.
** The 'dprintXXX' methods will only print their specified message if the System
** property "ri.debugMode" is true. Additionally, 'dprintXXX' methods will always
** prepend the location (stackframe) of the 'Print.dprintXXX' call.
** The 'printXXX' methods always print their specified message to the console.
** However, the default is to _not_ include the location (stackframe) of the print
** statement unless the System property "ri.print.showStackFrame" is true. The
** location of all print statements can then be exposed by setting this system
** property to true.
**
** Replacements:
** Old method New Method
** System.out.println("hello") => Print.println("hello")
** <Throwable>.printStackTrace() => Print.printStackTrace("Error", <Throwable>)
** Thread.dumpStack() => Print.printStackTrace("Stack Trace");
** if (debug) System.out.println("x") => Print.dprintln("x"); // not optimized
** if (debug) System.out.println("x") => if (debug) Print.println("x");
**
** To turn on debug mode (to allow 'dprintXXX' to print), include system property:
** -Dri.debugMode=true
**
** To turn have 'printXXX' methods print the stack frame location, include system property:
** -Dri.print.showStackFrame=true
**
** -----------------------------------------------------------------------------
** @author Martin D. Flynn
*/
public class Print
{
/* -------------------------------------------------------------------------
*/
/* System property keys */
/* Throwable instance used to obtain stack information */
/* by default the source file name is not printed in the location */
private static boolean showStackFrameSource = false;
/* -------------------------------------------------------------------------
*/
/* Set the debug mode
** @param specified debug state
*/
{
}
/* Return the current debug mode state
** @return debug state
*/
public static boolean isDebugMode()
{
}
/* -------------------------------------------------------------------------
*/
/* Set the state to force prepending the stack frame to 'print' statements
** @param specified printStackFrame state
*/
{
}
/* return the current state of including the stack frame in 'print' statements
** @return printStackFrame state
*/
public static boolean printStackFrame()
{
}
/* -------------------------------------------------------------------------
*/
/* Set the state to include the module source file rather than the normal stack frame
** @param specified showStackFrameSource state
*/
{
}
/* -------------------------------------------------------------------------
*/
/* Return the specified StackTraceElement
** @return the @see java.lang.StackTraceElement for the specified stack frame
** @param the specified stack frame to retrieve.
*/
{
}
/* Return the String form of the current StackTraceElement
** @return the @see java.lang.String version of the specified stack frame
** @param the specified stack frame to retrieve.
*/
{
}
/* Return the String form of the current StackTraceElement
** @return the @see java.lang.String version of the specified stack frame
** @param the StackTraceElement to convert to a string.
*/
{
}
/* Return the String form of the current StackTraceElement
** @return the @see java.lang.String version of the specified stack frame
** @param the specified stack frame to retrieve.
** @param indicator whether the String should include the module source file name
*/
{
}
/* Return the String form of the current StackTraceElement
** @return the @see java.lang.String version of the specified stack frame
** @param the StackTraceElement to convert to a string.
** @param indicator whether the String should include the module source file name
*/
{
if (showSrc) {
if (s != null) {
} else {
int p = c.lastIndexOf(".");
}
} else {
int p = c.lastIndexOf(".");
}
}
}
/* -------------------------------------------------------------------------
*/
/* Internal print statement
** @param output @see java.io.PrintStream
** @param the stack frame location of the real 'print' statement.
** @param the message to print.
*/
{
}
/* -------------------------------------------------------------------------
*/
/* Print message to specified PrintStream (default to System.out)
** Does not include a linefeed at the end of the message.
** @param output @see java.io.PrintStream
** @param the message to print.
*/
{
}
/* Print message to specified PrintStream (default to System.out)
** Prints message only if debugMode system property is true.
** Does not include a linefeed at the end of the message.
** @param output @see java.io.PrintStream
** @param the message to print.
*/
{
if (isDebugMode()) {
}
}
/* Print message to specified System.out
** Does not include a linefeed at the end of the message.
** @param the message to print.
*/
{
}
/* Print message to specified System.out
** Prints message only if debugMode system property is true.
** Does not include a linefeed at the end of the message.
** @param the message to print.
*/
{
if (isDebugMode()) {
}
}
/* Print message to specified PrintStream (default to System.out)
** StackFrame information is included if the specified frame is >= 0, or if
** the showStackFrame system property is true. To force the stack frame info to
** print, set the frameNum to '0' [eg.' Print.println(null, 0, "This location");']
** Message is terminated with a linefeed
** @param output @see java.io.PrintStream
** @param the stack frame location of the real 'print' statement.
** @param the message to print.
*/
{
}
/* Print message to specified PrintStream (default to System.out)
** Prints message only if debugMode system property is true.
** StackFrame information is included.
** Message is terminated with a linefeed
** @param output @see java.io.PrintStream
** @param the stack frame location of the real 'print' statement.
** @param the message to print.
*/
{
if (isDebugMode()) {
}
}
/* Print message to System.out
** StackFrame information is included if the specified frame is >= 0, or if
** the showStackFrame system property is true. To force the stack frame info to
** print, set the frameNum to '0' [eg.' Print.println(0, "This location");']
** Message is terminated with a linefeed
** @param the stack frame location of the real 'print' statement.
** @param the message to print.
*/
{
}
/* Print message to System.out
** Prints message only if debugMode system property is true.
** StackFrame information is included.
** Message is terminated with a linefeed
** @param the stack frame location of the real 'print' statement.
** @param the message to print.
*/
{
if (isDebugMode()) {
}
}
/* Print message to specified PrintStream (default to System.out)
** StackFrame information is included if the showStackFrame system property is true.
** Message is terminated with a linefeed
** @param output @see java.io.PrintStream
** @param the message to print.
*/
{
}
/* Print message to specified PrintStream (default to System.out)
** Prints message only if debugMode system property is true.
** StackFrame information is included.
** Message is terminated with a linefeed
** @param output @see java.io.PrintStream
** @param the message to print.
*/
{
if (isDebugMode()) {
}
}
/* Print message to System.out
** StackFrame information is included if the showStackFrame system property is true.
** Message is terminated with a linefeed
** @param the message to print.
*/
{
}
/* Print message to System.out
** Prints message only if debugMode system property is true.
** StackFrame information is included.
** Message is terminated with a linefeed
** @param the message to print.
*/
{
if (isDebugMode()) {
}
}
/* -------------------------------------------------------------------------
*/
/* Set default output file for logging stack traces (logging defaults to System.out)
** @param the output file to log stack traces
*/
{
/* close old log file */
if (printStackTrace_Stream != null) {
}
/* open new log file */
try {
} catch (IOException ioe) {
}
}
}
/* Format and print stack trace information
** @param output @see java.io.PrintStream
** @param the stack frame location of the real 'print' statement.
** @param the title of the stack trace.
** @param the message to print.
** @param the Throwable containing the stack trace to print.
*/
private static void _printStackTrace(PrintStream out, int frame, String title, String msg, Throwable excp)
{
/* header vars */
/* default PrintStream */
}
/* header */
/* stack trace */
} else {
t.fillInStackTrace();
t.printStackTrace(ps);
}
/* final dashed line */
}
/* Print stack trace information to specified PrintStream.
** @param output @see java.io.PrintStream
** @param the stack frame location of the real 'print' statement.
** @param the title of the stack trace.
** @param the message to print.
** @param the Throwable containing the stack trace to print.
*/
public static void printStackTrace(PrintStream out, int frame, String title, String msg, Throwable excp)
{
}
} else {
}
if (printStackTrace_LogFile != null) {
}
}
}
/* Print stack trace information to specified PrintStream.
** Prints stack trace only if debugMode system property is true.
** @param output @see java.io.PrintStream
** @param the stack frame location of the real 'print' statement.
** @param the title of the stack trace.
** @param the message to print.
** @param the Throwable containing the stack trace to print.
*/
public static void dprintStackTrace(PrintStream out, int frame, String title, String msg, Throwable excp)
{
if (isDebugMode()) {
}
}
}
/* Print stack trace information to default PrintStream.
** @param the title of the stack trace.
** @param the message to print.
** @param the Throwable containing the stack trace to print.
*/
{
}
/* Print stack trace information to default PrintStream.
** Prints stack trace only if debugMode system property is true.
** @param the title of the stack trace.
** @param the message to print.
** @param the Throwable containing the stack trace to print.
*/
{
if (isDebugMode()) {
}
}
/* Print stack trace information to default PrintStream.
** Use this method instead of '<Throwable>.printStackTrace'
** @param the message to print.
** @param the Throwable containing the stack trace to print.
*/
{
}
/* Print stack trace information to default PrintStream.
** Prints stack trace only if debugMode system property is true.
** Use this method instead of '<Throwable>.printStackTrace'
** @param the message to print.
** @param the Throwable containing the stack trace to print.
*/
{
if (isDebugMode()) {
}
}
/* Print stack trace information to default PrintStream.
** Use this method instead of 'Thread.dumpStack'
** @param the message to print.
*/
{
}
/* Print stack trace information to default PrintStream.
** Prints stack trace only if debugMode system property is true.
** Use this method instead of 'Thread.dumpStack'
** @param the message to print.
*/
{
if (isDebugMode()) {
}
}
/* Print stack trace information to default PrintStream.
** Allows specifying frame
** @param the stack frame to print.
** @param the message to print.
*/
{
}
/* Print stack trace information to default PrintStream.
** Prints stack trace only if debugMode system property is true.
** Allows specifying frame
** @param the stack frame to print.
** @param the message to print.
*/
{
if (isDebugMode()) {
}
}
{
t.fillInStackTrace();
printWriter.close();
return stackTrace;
}
}