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

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

本文整理了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

  1. /**
  2. * Gets the current writer that will used for debugging output. If no writer was explicitely set by the user, the
  3. * default writer is returned.
  4. *
  5. * @return the current writer, or <code>null</code> if debugging is disabled
  6. */
  7. public static PrintWriter getWriter() {
  8. if (isEnabled() && _writer == null) {
  9. _writer = getDefaultWriter();
  10. }
  11. return _writer;
  12. }

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

  1. /**
  2. * Gets the default writer used for debugging output.
  3. *
  4. * @return the default writer, or <code>null</code> if debugging is disabled
  5. */
  6. public static PrintWriter getDefaultWriter() {
  7. if (isEnabled() && _defaultWriter == null) {
  8. _defaultWriter = createPrintWriter(System.out);
  9. }
  10. return _defaultWriter;
  11. }

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

  1. /**
  2. * Sets the current writer that will be used for debugging output.
  3. *
  4. * @param writer the new writer
  5. */
  6. public static void setWriter(Writer writer) {
  7. if (isEnabled() && writer != null) {
  8. _writer = createPrintWriter(writer);
  9. }
  10. }

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

  1. @Override
  2. protected void setUp() {
  3. _oldDebugState = Debug.isEnabled();
  4. }

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

  1. /**
  2. * Sets the current writer for the given stream that will be used for debugging output.
  3. *
  4. * @param stream the stream that will be used for debugging output
  5. */
  6. public static void setWriter(OutputStream stream) {
  7. if (isEnabled() && stream != null) {
  8. _writer = createPrintWriter(stream);
  9. }
  10. }

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

  1. /**
  2. * Prints the given property change event to the current writer if and only if the debugging class functionality is
  3. * enabled.
  4. */
  5. public static void trace(PropertyChangeEvent event) {
  6. if (isEnabled() && event != null) {
  7. PrintWriter w = getWriter();
  8. w.print("property ");
  9. w.print(event.getPropertyName());
  10. w.print(" changed from ");
  11. w.print(event.getOldValue());
  12. w.print(" to ");
  13. w.print(event.getNewValue());
  14. w.println();
  15. }
  16. }

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

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

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

  1. /**
  2. * If the <code>condition</code> is NOT true, and the debugging functionality is enabled, this method throws an
  3. * <code>AssertionFailure</code> in order to signal that an internal program post- or pre-condition failed.
  4. * <p/>
  5. * <p> Use this method whenever a valid state must be ensured within your sourcecode in order to safely continue the
  6. * program.
  7. * <p/>
  8. * <p> For example, the method can be used to ensure valid arguments passed to private and protected methods.
  9. *
  10. * @param condition the assert condition
  11. *
  12. * @throws AssertionFailure if <code>condition</code> evaluates to false and the debugging functionality is enabled
  13. */
  14. public static void assertTrue(boolean condition) throws AssertionFailure {
  15. if (isEnabled()) {
  16. if (!condition) {
  17. handleAssertionFailed(null);
  18. }
  19. }
  20. }

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

  1. /**
  2. * Prints the given message string to the current writer if and only if the debugging class functionality is
  3. * enabled.
  4. */
  5. public static void trace(String message) {
  6. if (isEnabled() && message != null) {
  7. PrintWriter w = getWriter();
  8. w.print(_tracePrefix);
  9. w.println(message);
  10. log(message);
  11. }
  12. }

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

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

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

  1. /**
  2. * Delegates <code>Debug.trace()</code> calls to the system logger.
  3. *
  4. * @param exception the exception to be logged.
  5. */
  6. protected static void log(Throwable exception) {
  7. if (isEnabled()) {
  8. if (isLogging()) {
  9. final StringWriter stringWriter = new StringWriter();
  10. final PrintWriter printWriter = new PrintWriter(stringWriter);
  11. exception.printStackTrace(printWriter);
  12. log(stringWriter.getBuffer().toString());
  13. }
  14. }
  15. }

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

  1. /**
  2. * If the <code>condition</code> is NOT true, and the debugging functionality is enabled, this method throws an
  3. * <code>AssertionFailure</code> in order to signal that an internal program post- or pre-condition failed. The
  4. * <code>AssertionFailure</code> will be created with the given error message string.
  5. * <p/>
  6. * <p> Use this method whenever a valid state must be ensured within your sourcecode in order to safely continue the
  7. * program.
  8. * <p/>
  9. * <p> For example, the method can be used to ensure valid arguments passed to private and protected methods.
  10. *
  11. * @param condition the assert condition
  12. * @param message an error message
  13. *
  14. * @throws AssertionFailure if <code>condition</code> evaluates to false and the debugging functionality is enabled
  15. */
  16. public static void assertTrue(boolean condition, String message) throws AssertionFailure {
  17. if (isEnabled()) {
  18. if (!condition) {
  19. handleAssertionFailed(message);
  20. }
  21. }
  22. }

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

  1. /**
  2. * Prints a 'method not implemented' message using the given class and method name string to the current writer if
  3. * and only if the debugging class functionality is enabled.
  4. *
  5. * @param clazz the method's class
  6. * @param methodName the method's name
  7. */
  8. public static void traceMethodNotImplemented(Class clazz, String methodName) {
  9. if (isEnabled()) {
  10. PrintWriter w = getWriter();
  11. w.print(_tracePrefix);
  12. w.print(UtilConstants.MSG_METHOD_NOT_IMPLEMENTED);
  13. if (methodName != null) {
  14. if (clazz != null) {
  15. w.print(clazz.getName());
  16. } else {
  17. w.print("<unknown class>");
  18. }
  19. w.print(".");
  20. w.print(methodName);
  21. w.print("()");
  22. w.println();
  23. }
  24. }
  25. }

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

  1. public void trace(String label) {
  2. if (Debug.isEnabled()) {
  3. Debug.trace(label + ": " + getTimeDiffString());
  4. }
  5. }
  6. }

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

  1. /**
  2. * Delegates <code>Debug.trace()</code> calls to the system logger.
  3. *
  4. * @param message the message to be logged.
  5. */
  6. protected static void log(String message) {
  7. if (isEnabled()) {
  8. if (isLogging()) {
  9. if (_logger == null) {
  10. _logger = BeamLogManager.getSystemLogger();
  11. }
  12. _logger.finest(message);
  13. }
  14. }
  15. }

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

  1. /**
  2. * Prints the stack trace for the given exeption to the current writer if and only if the debugging class
  3. * functionality is enabled.
  4. */
  5. public static void trace(Throwable exception) {
  6. if (isEnabled() && exception != null) {
  7. PrintWriter w = getWriter();
  8. w.print(_tracePrefix);
  9. w.println(UtilConstants.MSG_EXCEPTION_OCCURRED);
  10. exception.printStackTrace(w);
  11. log(UtilConstants.MSG_EXCEPTION_OCCURRED);
  12. log(exception);
  13. }
  14. }

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

  1. /**
  2. * Prints the ammount of free memory using the given label string to the current writer if and only if the debugging
  3. * class functionality is enabled.
  4. *
  5. * @param label an optional label, can be null
  6. */
  7. public static void traceMemoryUsage(String label) {
  8. if (isEnabled()) {
  9. String message = createMemoryUsageMessage(label);
  10. PrintWriter w = getWriter();
  11. w.print(_tracePrefix);
  12. w.println(message);
  13. log(message);
  14. }
  15. }

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

  1. if (isEnabled()) {

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

  1. command.add("--log_file");
  2. command.add(BEAMPYUTIL_LOG_FILENAME);
  3. if (Debug.isEnabled()) {
  4. command.add("--log_level");
  5. command.add("DEBUG");

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

  1. private static boolean isDebugClassTestable() {
  2. boolean oldDebugState = Debug.isEnabled();
  3. Debug.setEnabled(true);
  4. boolean newDebugState = Debug.isEnabled();
  5. Debug.setEnabled(oldDebugState);
  6. return newDebugState;
  7. }

相关文章