KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > commands > util > Tracing


1 /*******************************************************************************
2  * Copyright (c) 2005, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.core.commands.util;
13
14 /**
15  * <p>
16  * A utility class for printing tracing output to the console.
17  * </p>
18  * <p>
19  * Clients must not extend or instantiate this class.
20  * </p>
21  *
22  * @since 3.2
23  */

24 public final class Tracing {
25
26     /**
27      * The separator to place between the component and the message.
28      */

29     public static final String JavaDoc SEPARATOR = " >>> "; //$NON-NLS-1$
30

31     /**
32      * <p>
33      * Prints a tracing message to standard out. The message is prefixed by a
34      * component identifier and some separator. See the example below.
35      * </p>
36      *
37      * <pre>
38      * BINDINGS &gt;&gt; There are 4 deletion markers
39      * </pre>
40      *
41      * @param component
42      * The component for which this tracing applies; may be
43      * <code>null</code>
44      * @param message
45      * The message to print to standard out; may be <code>null</code>.
46      */

47     public static final void printTrace(final String JavaDoc component,
48             final String JavaDoc message) {
49         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
50         if (component != null) {
51             buffer.append(component);
52         }
53         if ((component != null) && (message != null)) {
54             buffer.append(SEPARATOR);
55         }
56         if (message != null) {
57             buffer.append(message);
58         }
59         System.out.println(buffer.toString());
60     }
61
62     /**
63      * This class is not intended to be instantiated.
64      */

65     private Tracing() {
66         // Do nothing.
67
}
68 }
69
Popular Tags