org.esa.beam.util.Debug.isEnabled()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(127)

本文整理了Java中org.esa.beam.util.Debug.isEnabled()方法的一些代码示例,展示了Debug.isEnabled()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Debug.isEnabled()方法的具体详情如下:
包路径:org.esa.beam.util.Debug
类名称:Debug
方法名:isEnabled

Debug.isEnabled介绍

[英]Checks whether the debugging functionality is enabled or not.
[中]检查调试功能是否已启用。

代码示例

代码示例来源:origin: bcdev/beam

/**
 * Gets the current writer that will used for debugging output. If no writer was explicitely set by the user, the
 * default writer is returned.
 *
 * @return the current writer, or <code>null</code> if debugging is disabled
 */
public static PrintWriter getWriter() {
  if (isEnabled() && _writer == null) {
    _writer = getDefaultWriter();
  }
  return _writer;
}

代码示例来源:origin: bcdev/beam

/**
 * Gets the default writer used for debugging output.
 *
 * @return the default writer, or <code>null</code> if debugging is disabled
 */
public static PrintWriter getDefaultWriter() {
  if (isEnabled() && _defaultWriter == null) {
    _defaultWriter = createPrintWriter(System.out);
  }
  return _defaultWriter;
}

代码示例来源:origin: bcdev/beam

/**
 * Sets the current writer that will be used for debugging output.
 *
 * @param writer the new writer
 */
public static void setWriter(Writer writer) {
  if (isEnabled() && writer != null) {
    _writer = createPrintWriter(writer);
  }
}

代码示例来源:origin: bcdev/beam

@Override
protected void setUp() {
  _oldDebugState = Debug.isEnabled();
}

代码示例来源:origin: bcdev/beam

/**
 * Sets the current writer for the given stream that will be used for debugging output.
 *
 * @param stream the stream that will be used for debugging output
 */
public static void setWriter(OutputStream stream) {
  if (isEnabled() && stream != null) {
    _writer = createPrintWriter(stream);
  }
}

代码示例来源:origin: bcdev/beam

/**
 * Prints the given property change event to the current writer if and only if the debugging class functionality is
 * enabled.
 */
public static void trace(PropertyChangeEvent event) {
  if (isEnabled() && event != null) {
    PrintWriter w = getWriter();
    w.print("property ");
    w.print(event.getPropertyName());
    w.print(" changed from ");
    w.print(event.getOldValue());
    w.print(" to ");
    w.print(event.getNewValue());
    w.println();
  }
}

代码示例来源:origin: bcdev/beam

/**
 * If the given object is null, and the debugging functionality is enabled, this method throws an
 * <code>AssertionFailure</code> in order to signal that an internal program post- or pre-condition failed.
 * <p/>
 * <p> Use this method whenever a valid state must be ensured within your sourcecode in order to safely continue the
 * program.
 * <p/>
 * <p> For example, the method can be used to ensure valid arguments passed to private and protected methods.
 *
 * @param object the object to test for non-null condition
 *
 * @throws AssertionFailure if <code>object</code> is null and the debugging functionality is enabled
 */
public static void assertNotNull(Object object) throws AssertionFailure {
  if (isEnabled()) {
    if (object == null) {
      handleAssertionFailed(UtilConstants.MSG_OBJECT_NULL);
    }
  }
}

代码示例来源:origin: bcdev/beam

/**
 * If the <code>condition</code> is NOT true, and the debugging functionality is enabled, this method throws an
 * <code>AssertionFailure</code> in order to signal that an internal program post- or pre-condition failed.
 * <p/>
 * <p> Use this method whenever a valid state must be ensured within your sourcecode in order to safely continue the
 * program.
 * <p/>
 * <p> For example, the method can be used to ensure valid arguments passed to private and protected methods.
 *
 * @param condition the assert condition
 *
 * @throws AssertionFailure if <code>condition</code> evaluates to false and the debugging functionality is enabled
 */
public static void assertTrue(boolean condition) throws AssertionFailure {
  if (isEnabled()) {
    if (!condition) {
      handleAssertionFailed(null);
    }
  }
}

代码示例来源:origin: bcdev/beam

/**
 * Prints the given message string to the current writer if and only if the debugging class functionality is
 * enabled.
 */
public static void trace(String message) {
  if (isEnabled() && message != null) {
    PrintWriter w = getWriter();
    w.print(_tracePrefix);
    w.println(message);
    log(message);
  }
}

代码示例来源:origin: bcdev/beam

/**
 * If the given String is null or empty, and the debugging functionality is enabled, this method throws an
 * <code>AssertionFailure</code> in order to signal that an internal program post- or pre-condition failed.
 * <p/>
 * <p> Use this method whenever a valid state must be ensured within your sourcecode in order to safely continue the
 * program.
 * <p/>
 * <p> For example, the method can be used to ensure valid arguments passed to private and protected methods.
 *
 * @param string the String to test for non-null and not empty condition
 *
 * @throws AssertionFailure if <code>String</code> is null or empty and the debugging functionality is enabled
 */
public static void assertNotNullOrEmpty(String string) throws AssertionFailure {
  if (isEnabled()) {
    if (string == null || string.length() < 1) {
      handleAssertionFailed(UtilConstants.MSG_STRING_NULL_OR_EMPTY);
    }
  }
}

代码示例来源:origin: bcdev/beam

/**
 * Delegates <code>Debug.trace()</code> calls to the system logger.
 *
 * @param exception the exception to be logged.
 */
protected static void log(Throwable exception) {
  if (isEnabled()) {
    if (isLogging()) {
      final StringWriter stringWriter = new StringWriter();
      final PrintWriter printWriter = new PrintWriter(stringWriter);
      exception.printStackTrace(printWriter);
      log(stringWriter.getBuffer().toString());
    }
  }
}

代码示例来源:origin: bcdev/beam

/**
 * If the <code>condition</code> is NOT true, and the debugging functionality is enabled, this method throws an
 * <code>AssertionFailure</code> in order to signal that an internal program post- or pre-condition failed. The
 * <code>AssertionFailure</code> will be created with the given error message string.
 * <p/>
 * <p> Use this method whenever a valid state must be ensured within your sourcecode in order to safely continue the
 * program.
 * <p/>
 * <p> For example, the method can be used to ensure valid arguments passed to private and protected methods.
 *
 * @param condition the assert condition
 * @param message   an error message
 *
 * @throws AssertionFailure if <code>condition</code> evaluates to false and the debugging functionality is enabled
 */
public static void assertTrue(boolean condition, String message) throws AssertionFailure {
  if (isEnabled()) {
    if (!condition) {
      handleAssertionFailed(message);
    }
  }
}

代码示例来源:origin: bcdev/beam

/**
 * Prints a 'method not implemented' message using the given class and method name string to the current writer if
 * and only if the debugging class functionality is enabled.
 *
 * @param clazz      the method's class
 * @param methodName the method's name
 */
public static void traceMethodNotImplemented(Class clazz, String methodName) {
  if (isEnabled()) {
    PrintWriter w = getWriter();
    w.print(_tracePrefix);
    w.print(UtilConstants.MSG_METHOD_NOT_IMPLEMENTED);
    if (methodName != null) {
      if (clazz != null) {
        w.print(clazz.getName());
      } else {
        w.print("<unknown class>");
      }
      w.print(".");
      w.print(methodName);
      w.print("()");
      w.println();
    }
  }
}

代码示例来源:origin: bcdev/beam

public void trace(String label) {
    if (Debug.isEnabled()) {
      Debug.trace(label + ": " + getTimeDiffString());
    }
  }
}

代码示例来源:origin: bcdev/beam

/**
 * Delegates <code>Debug.trace()</code> calls to the system logger.
 *
 * @param message the message to be logged.
 */
protected static void log(String message) {
  if (isEnabled()) {
    if (isLogging()) {
      if (_logger == null) {
        _logger = BeamLogManager.getSystemLogger();
      }
      _logger.finest(message);
    }
  }
}

代码示例来源:origin: bcdev/beam

/**
 * Prints the stack trace for the given exeption to the current writer if and only if the debugging class
 * functionality is enabled.
 */
public static void trace(Throwable exception) {
  if (isEnabled() && exception != null) {
    PrintWriter w = getWriter();
    w.print(_tracePrefix);
    w.println(UtilConstants.MSG_EXCEPTION_OCCURRED);
    exception.printStackTrace(w);
    log(UtilConstants.MSG_EXCEPTION_OCCURRED);
    log(exception);
  }
}

代码示例来源:origin: bcdev/beam

/**
 * Prints the ammount of free memory using the given label string to the current writer if and only if the debugging
 * class functionality is enabled.
 *
 * @param label an optional label, can be null
 */
public static void traceMemoryUsage(String label) {
  if (isEnabled()) {
    String message = createMemoryUsageMessage(label);
    PrintWriter w = getWriter();
    w.print(_tracePrefix);
    w.println(message);
    log(message);
  }
}

代码示例来源:origin: bcdev/beam

if (isEnabled()) {

代码示例来源:origin: bcdev/beam

command.add("--log_file");
command.add(BEAMPYUTIL_LOG_FILENAME);
if (Debug.isEnabled()) {
  command.add("--log_level");
  command.add("DEBUG");

代码示例来源:origin: bcdev/beam

private static boolean isDebugClassTestable() {
  boolean oldDebugState = Debug.isEnabled();
  Debug.setEnabled(true);
  boolean newDebugState = Debug.isEnabled();
  Debug.setEnabled(oldDebugState);
  return newDebugState;
}

相关文章