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

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

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

Debug.assertNotNull介绍

[英]If the given object is null, and the debugging functionality is enabled, this method throws an AssertionFailure in order to signal that an internal program post- or pre-condition failed.

Use this method whenever a valid state must be ensured within your sourcecode in order to safely continue the program.

For example, the method can be used to ensure valid arguments passed to private and protected methods.
[中]

代码示例

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

/**
 * 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;
}

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

private static float resolveGadsValueFloat(String gadsRef, String gadsName, Record gadsRecord)
    throws DDDBException {
  Debug.assertNotNullOrEmpty(gadsRef);
  try {
    if (gadsName != null && gadsRef.startsWith(gadsName + ".")) {
      Debug.assertNotNull(gadsRecord);
      FieldRef fieldRef = FieldRef.parse(gadsRef);
      return gadsRecord.getFieldAt(fieldRef.getFieldIndex()).getElemFloat(fieldRef.getElemIndex());
    } else {
      return Float.parseFloat(gadsRef);
    }
  } catch (Exception e) {
    throw new DDDBException("failed to resolve GADS reference '" + gadsRef + "': " + e.getMessage()); /*I18N*/
  }
}

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

private static boolean isValidDataLine(String[] tokens) {
  Debug.assertNotNull(tokens);
  return tokens.length > 0 && !tokens[0].startsWith("#");
}

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

/**
 * Checks if a vector of value objects is contained in the valueset defined bay the parameter. If not, the error
 * handler passed in is invoked.
 *
 * @param parameter the Parameter defining the valueset
 * @param values    vector of objects to be checked
 */
protected void validateThatValuesAreInValueSet(Parameter parameter, Object[] values) throws ParamValidateException {
  Debug.assertNotNull(parameter);
  Debug.assertNotNull(values);
  for (int i = 0; i < values.length; i++) {
    validateThatValueIsInValueSet(parameter, values[i]);
  }
}

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

private static <T extends ProductIOPlugIn> Iterator<T> getProductIOPlugIns(Set<T> ioPlugIns, String formatName) {
  Debug.assertNotNull(ioPlugIns);
  Debug.assertNotNull(formatName);
  List<T> validPlugins = new ArrayList<T>();
  for (T plugIn : ioPlugIns) {
    String[] formatNames = plugIn.getFormatNames();
    for (String otherFormatName : formatNames) {
      if (otherFormatName.equalsIgnoreCase(formatName)) {
        validPlugins.add(plugIn);
      }
    }
  }
  return validPlugins.iterator();
}

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

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());
  }
}

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

/**
 * Tests if the given text is an allowed zero-length text string for the given parameter.
 *
 * @param parameter the parameter
 * @param text      the text to test
 *
 * @return <code>true</code> if so
 */
protected static boolean isAllowedNullText(Parameter parameter, String text) {
  Debug.assertNotNull(parameter);
  Debug.assertNotNull(text);
  return text.trim().length() == 0
      && parameter.getProperties().isNullValueAllowed();
}

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

private static CsvReader openCsvReader(URL url) throws DDDBException {
  Debug.assertNotNull(url);
  try {
    return new CsvReader(new InputStreamReader(url.openStream()),
               FIELD_SEPARATORS);
  } catch (IOException e) {
    StringBuffer sb = new StringBuffer();
    sb.append("failed to open DDDB resource: "); /*I18N*/
    sb.append(e.getMessage());
    sb.append(": file ");
    sb.append(url);
    throw new DDDBException(sb.toString());
  }
}

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

private String[] readCsvRecord(CsvReader csvReader, URL url) throws DDDBException {
  Debug.assertNotNull(csvReader);
  Debug.assertNotNull(url);
  try {
    return csvReader.readRecord();
  } catch (IOException e) {
    closeCsvReader(csvReader, url);
    StringBuffer sb = new StringBuffer();
    sb.append("failed to read from DDDB resource: "); /*I18N*/
    sb.append(e.getMessage());
    sb.append(": file ");
    sb.append(url);
    throw new DDDBException(sb.toString());
  }
}

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

/**
 * Gets the file path for the record info file which describes the record structure for the specified dataset.
 *
 * @param productType the product type identifier, e.g. "MER_FR__2P"
 * @param datasetName the dataset name, never <code>null</code>
 *
 * @return the file path for the record info file which describes the record structure for the specified dataset
 *
 * @throws org.esa.beam.dataio.envisat.DDDBException
 *          if a database I/O error occurs
 */
private String getRecordInfoFilePath(String productType, String datasetName)
    throws DDDBException {
  DatasetInfo datasetInfo = getDatasetInfo(productType, datasetName);
  Debug.assertNotNull(datasetInfo);
  return datasetInfo.recordInfoFilePath;
}

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

/**
 * Gets the name of the DSD (as internally used in product data files) for the dataset with the given name.
 * <p/>
 * <p>Note that the dataset name must not necessarily match the internally used DSD name.
 *
 * @param productType the product type identifier, e.g. "MER_FR__2P"
 * @param datasetName the dataset name
 *
 * @return the internal DSD name corresponding to the given dataset name, never <code>null</code>
 *
 * @throws org.esa.beam.dataio.envisat.DDDBException
 *          if a database I/O error occurs
 */
public String getDSDName(String productType, String datasetName)
    throws DDDBException {
  DatasetInfo datasetInfo = getDatasetInfo(productType, datasetName);
  Debug.assertNotNull(datasetInfo);
  return datasetInfo.dsdName;
}

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

/**
 * Gets the product description string for the given product type identifier.
 *
 * @param productType the product type identifier, e.g. "MER_FR__2P"
 *
 * @return the description string for products of the given type
 *
 * @throws java.lang.IllegalArgumentException
 *          if the product type is null
 * @throws org.esa.beam.dataio.envisat.DDDBException
 *          if a database I/O error occurs
 */
public String getProductDescription(String productType)
    throws DDDBException {
  ProductInfo productInfo = getProductInfo(productType);
  Debug.assertNotNull(productInfo);
  return productInfo.description;
}

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

/**
 * Tests if the given object is an allowed null value for the given parameter.
 *
 * @param parameter the parameter
 * @param value     the value to test
 *
 * @return <code>true</code> if so
 */
protected static boolean isAllowedNullValue(Parameter parameter, Object value) {
  Debug.assertNotNull(parameter);
  return value == null
      && parameter.getProperties().isNullValueAllowed();
}

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

protected boolean setParameterValue(JTextComponent textComponent) {
  Debug.assertNotNull(textComponent);
  return getParameter().setValueAsText(textComponent.getText(), getExceptionHandler());
}

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

private void initInput() throws IOException {
  if (getInput() instanceof String) {
    inputFile = new File((String) getInput());
  } else if (getInput() instanceof File) {
    inputFile = (File) getInput();
  } else {
    throw new IllegalArgumentException("unsupported input source: " + getInput());  /*I18N*/
  }
  Debug.assertNotNull(inputFile); // super.readProductNodes should have checked getInput() != null already
  inputDir = inputFile.getParentFile();
  if (inputDir == null) {
    inputDir = new File(".");
  }
}

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

SpectrumGraph(Placemark placemark, Band[] bands) {
  Debug.assertNotNull(bands);
  this.placemark = placemark;
  this.bands = bands;
  energyRange = new Range();
  wavelengthRange = new Range();
  setBands(bands);
}

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

/**
 * Tests if the value passed in is null, and if so, if this is an allowed value defined by the parameter. When this
 * is not the case, the errorhandle passed in is invoked.
 *
 * @param parameter the Parameter defining the null value behaviour
 * @param value     the value to be checked
 */
protected void validateThatNullValueIsAllowed(Parameter parameter, Object value) throws ParamValidateException {
  Debug.assertNotNull(parameter);
  if (value == null
    && !parameter.getProperties().isNullValueAllowed()) {
    throw new ParamValidateException(parameter, "Value must not be null."); /*I18N*/
  }
}

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

/**
 * Ensures that raster data exists
 */
public void ensureRasterData() {
  if (!hasRasterData()) {
    setRasterData(createCompatibleRasterData());
  }
  Debug.assertNotNull(getRasterData());
}

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

/**
 * Checks if a value object is contained in the valueset defined by the parameter. If not, the error handler passed
 * in is invoked.
 *
 * @param parameter the Parameter defining the valueset
 * @param value     object to be checked
 */
protected void validateThatValueIsInValueSet(Parameter parameter, Object value) throws ParamValidateException {
  Debug.assertNotNull(parameter);
  if (parameter.getProperties().getValueSet() != null
    && parameter.getProperties().isValueSetBound()
    && !isValueContainedInValueSet(parameter, value)) {
    throw new ParamValidateException(parameter, "Value is not allowed.");/*I18N*/
  }
}

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

private void addMetadataElements(final MetadataElement[] elementes, final Element mdElem) { //Übernommen
  if (elementes == null) {
    return;
  }
  Debug.assertNotNull(mdElem);
  for (MetadataElement element : elementes) {
    final Element newElem = new Element(DimapProductConstants.TAG_METADATA_ELEMENT);
    newElem.setAttribute(DimapProductConstants.ATTRIB_NAME, element.getName());
    final String description = element.getDescription();
    if (description != null) {
      newElem.setAttribute(DimapProductConstants.ATTRIB_DESCRIPTION, description);
    }
    addMetadataAttributes(element.getAttributes(), newElem);
    addMetadataElements(element.getElements(), newElem);
    mdElem.addContent(newElem);
  }
}

相关文章