/** * 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; }
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*/ } }
private static boolean isValidDataLine(String[] tokens) { Debug.assertNotNull(tokens); return tokens.length > 0 && !tokens[0].startsWith("#"); }
/** * 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]); } }
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(); }
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()); } }
/** * 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(); }
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()); } }
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()); } }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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(); }
protected boolean setParameterValue(JTextComponent textComponent) { Debug.assertNotNull(textComponent); return getParameter().setValueAsText(textComponent.getText(), getExceptionHandler()); }
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("."); } }
SpectrumGraph(Placemark placemark, Band[] bands) { Debug.assertNotNull(bands); this.placemark = placemark; this.bands = bands; energyRange = new Range(); wavelengthRange = new Range(); setBands(bands); }
/** * 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*/ } }
/** * Ensures that raster data exists */ public void ensureRasterData() { if (!hasRasterData()) { setRasterData(createCompatibleRasterData()); } Debug.assertNotNull(getRasterData()); }
/** * 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*/ } }
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); } }