KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > databinding > util > Policy


1 /*******************************************************************************
2  * Copyright (c) 2004, 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  * Chris Gross (schtoo@schtoo.com) - support for ILogger added
11  * (bug 49497 [RCP] JFace dependency on org.eclipse.core.runtime enlarges standalone JFace applications)
12  * Brad Reynolds - bug 164653
13  *******************************************************************************/

14 package org.eclipse.core.databinding.util;
15
16 import org.eclipse.core.runtime.IStatus;
17
18 /**
19  * The Policy class handles settings for behaviour, debug flags and logging
20  * within JFace Data Binding.
21  *
22  * @since 1.1
23  */

24 public class Policy {
25
26     /**
27      * Constant for the the default setting for debug options.
28      */

29     public static final boolean DEFAULT = false;
30
31     /**
32      * The unique identifier of the JFace plug-in.
33      */

34     public static final String JavaDoc JFACE_DATABINDING = "org.eclipse.core.databinding";//$NON-NLS-1$
35

36     private static ILogger log;
37
38     /**
39      * Returns the dummy log to use if none has been set
40      */

41     private static ILogger getDummyLog() {
42         return new ILogger() {
43             public void log(IStatus status) {
44                 System.err.println(status.getMessage());
45             }
46         };
47     }
48
49     /**
50      * Sets the logger used by JFace Data Binding to log errors.
51      *
52      * @param logger
53      * the logger to use, or <code>null</code> to use the default
54      * logger
55      */

56     public static synchronized void setLog(ILogger logger) {
57         log = logger;
58     }
59
60     /**
61      * Returns the logger used by JFace Data Binding to log errors.
62      * <p>
63      * The default logger prints the status to <code>System.err</code>.
64      * </p>
65      *
66      * @return the logger
67      */

68     public static synchronized ILogger getLog() {
69         if (log == null) {
70             log = getDummyLog();
71         }
72         return log;
73     }
74
75 }
76
Popular Tags