@Override public void dockableFrameFloating(DockableFrameEvent dockableFrameEvent) { Debug.trace("dockableFrameEvent = " + dockableFrameEvent); ensurePageComponentControlCreated(); }
@Override protected void setUp() { //_oldDebugState = Debug.setEnabled(true); _oldDebugState = Debug.setEnabled(false); }
private static void closeCsvReader(CsvReader csvReader, URL url) { Debug.assertNotNull(csvReader); Debug.assertNotNull(url); try { csvReader.close(); } catch (IOException e) { Debug.trace("DDDB: I/O warning: failed to close DDDB file: " /*I18N*/ + url + ": " + e.getMessage()); } }
/** * 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; }
/** * 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); } }
/** * 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); } } }
/** * Creates an appropriate validator for this parameter info. * * @return a validator, never <code>null</code> */ public ParamValidator createValidator() { ParamValidator validator = null; Class validatorClass = getValidatorClass(); if (validatorClass != null) { try { validator = (ParamValidator) validatorClass.newInstance(); } catch (Exception e) { // @todo 1 nf/nf - throw exception ??? I think so! Debug.trace(e); } } if (validator == null) { validator = ParamValidatorRegistry.getValidator(getValueType()); } Debug.assertTrue(validator != null); return validator; }
/** * Constructs a new dataset reader for ENVISAT products. * * @param productFile the product file which is creating this reader * @param dsd the DSD which describes the dataset to be read * @param recordInfo the description of the record structure of which the dataset is composed of */ RecordReader(ProductFile productFile, DSD dsd, RecordInfo recordInfo) { Debug.assertNotNull(productFile); Debug.assertNotNull(dsd); Debug.assertNotNull(recordInfo); _productFile = productFile; _dsd = dsd; _recordInfo = recordInfo; }
/** * Constructs a new data item info from the supplied parameters. * * @param itemName the item name, must not be null or empty * @param dataType the internal data type. Must be one of the multiple <code>org.esa.beam.framework.datamodel.ProductData.TYPE_</code>X * constants * @param physicalUnit the item's physical unit (optional, can be null) * @param description the item's description (optional, can be null) * * @see org.esa.beam.framework.datamodel.ProductData */ protected DataItemInfo(String itemName, int dataType, String physicalUnit, String description) { super(itemName, description); Debug.assertTrue(dataType != ProductData.TYPE_UNDEFINED, "undefined field data type"); /*I18N*/ _dataType = dataType; _physicalUnit = physicalUnit; }
public void testAssertWidthoutMessage() { Debug.setEnabled(false); try { Debug.assertTrue(true); } catch (AssertionFailure e) { fail("no AssertionFailure expected"); } try { Debug.assertTrue(false); } catch (AssertionFailure e) { fail("no AssertionFailure expected"); } Debug.setEnabled(true); java.io.StringWriter sw = new java.io.StringWriter(); Debug.setWriter(sw); try { Debug.assertTrue(true); } catch (AssertionFailure e) { fail("no AssertionFailure expected"); } try { Debug.assertTrue(false); fail("AssertionFailure expected"); } catch (AssertionFailure e) { } String assertionFailureMsg = sw.getBuffer().toString(); String expectedContent = Debug.class.getName(); assertEquals(true, assertionFailureMsg.indexOf(expectedContent) >= 0); }
public static String[] createTags(int indent, String name, String[][] attributes) { Debug.assertNotNullOrEmpty(name); Debug.assertNotNull(attributes); final StringBuffer tag = new StringBuffer(); final String indentWs = getIndentWhiteSpace(indent); tag.append(indentWs); tag.append("<"); tag.append(name); for (int i = 0; i < attributes.length; i++) { final String[] att_val = attributes[i]; if (att_val.length > 1) { final String attribute = att_val[0]; final String value = att_val[1]; if (attribute != null && attribute.length() > 0) { tag.append(" " + attribute + "=\""); if (value != null) { tag.append(encode(value)); } tag.append("\""); } } } tag.append(">"); final String[] tags = new String[2]; tags[0] = tag.toString(); tags[1] = indentWs + "</" + name + ">"; return tags; }
public void testAssertNotNull() { Debug.setEnabled(false); try { Debug.assertNotNull(new Object()); } catch (AssertionFailure e) { fail("no AssertionFailure expected"); } try { Debug.assertNotNull(null); } catch (AssertionFailure e) { fail("no AssertionFailure expected"); } Debug.setEnabled(true); Debug.setWriter(new java.io.StringWriter()); try { Debug.assertNotNull(new Object()); } catch (AssertionFailure e) { fail("no AssertionFailure expected"); } try { Debug.assertNotNull(null); fail("AssertionFailure expected"); } catch (AssertionFailure e) { } }
private static boolean isDebugClassTestable() { boolean oldDebugState = Debug.isEnabled(); Debug.setEnabled(true); boolean newDebugState = Debug.isEnabled(); Debug.setEnabled(oldDebugState); return newDebugState; }
public void testAssertNotNullOrEmpty() { Debug.setEnabled(false); try { Debug.assertNotNullOrEmpty(null); } catch (AssertionFailure e) { fail("no AssertionFailure expected"); Debug.assertNotNullOrEmpty(""); } catch (AssertionFailure e) { fail("no AssertionFailure expected"); Debug.setEnabled(true); Debug.setWriter(new java.io.StringWriter()); try { Debug.assertNotNullOrEmpty("a"); } catch (AssertionFailure e) { fail("no AssertionFailure expected"); Debug.assertNotNullOrEmpty(null); fail("AssertionFailure expected"); } catch (AssertionFailure e) { Debug.assertNotNullOrEmpty(""); fail("AssertionFailure expected"); } catch (AssertionFailure e) {
/** * 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); } }
/** * 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()); } } }
/** * 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(); } }
/** * 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); } } }