/** * Returns a string representation of this value which can be used for debugging purposes. */ @Override public String toString() { return getElemString(); }
/** * Returns a textual representation of this field's value. * * @return a character string representing this field's value */ public String getAsString() { return getData().getElemString(); }
public String getValue() { return getData().getElemString(); } }
public String getValue() { return getData().getElemString(); } }
protected String getProductType(String productTypeKey) { final MetadataAttribute product_type = getProductMetadata().getAttribute(productTypeKey); final MetadataAttribute spacecraft_id = getProductMetadata().getAttribute("SPACECRAFT_ID"); final MetadataAttribute sensor_id = getProductMetadata().getAttribute("SENSOR_ID"); final StringBuilder result = new StringBuilder(); result.append(spacecraft_id.getData().getElemString()); result.append("_"); result.append(sensor_id.getData().getElemString()); result.append("_"); result.append(product_type.getData().getElemString()); return result.toString(); }
/** * Returns the string value of the attribute with the given name. <p>The given default value is returned if an * attribute with the given name could not be found in this node. * * @param name the attribute name * @param defaultValue the default value * * @return the attribute value as integer. */ public String getAttributeString(String name, String defaultValue) { final MetadataAttribute attribute = getAttribute(name); if (attribute == null) { return defaultValue; } return attribute.getData().getElemString(); }
/** * Returns the string value of the attribute with the given name. <p>An Exception is thrown if an * attribute with the given name could not be found in this node. * * @param name the attribute name * * @return the attribute value as integer. * * @throws IllegalArgumentException if an attribute with the given name could not be found */ public String getAttributeString(String name) { final MetadataAttribute attribute = getAttribute(name); if (attribute == null) { throw new IllegalArgumentException(getAttributeNotFoundMessage(name)); } return attribute.getData().getElemString(); }
private void writeAttributes(PrintWriter out, MetadataElement element) { final MetadataAttribute[] attributes = element.getAttributes(); for (MetadataAttribute attribute : attributes) { out.print(createAttributeName(attribute) + "\t"); out.print(attribute.getData().getElemString() + "\t"); out.print(attribute.getUnit() + "\t"); out.print(attribute.getDescription() + "\t\n"); } final MetadataElement[] subElements = element.getElements(); for (MetadataElement subElement : subElements) { writeAttributes(out, subElement); } }
/** * Returns the UTC value of the attribute with the given name. * * @param name the attribute name * * @return the attribute value as UTC. * * @throws IllegalArgumentException if an attribute with the given name could not be found */ public ProductData.UTC getAttributeUTC(String name) { try { final MetadataAttribute attribute = getAttribute(name); if (attribute != null) { return ProductData.UTC.parse(attribute.getData().getElemString()); } } catch (ParseException e) { throw new IllegalArgumentException("Unable to parse metadata attribute " + name); } throw new IllegalArgumentException(getAttributeNotFoundMessage(name)); }
/** * Returns the UTC value of the attribute with the given name. <p>The given default value is returned if an * attribute with the given name could not be found in this node. * * @param name the attribute name * @param defaultValue the default value * * @return the attribute value as UTC. */ public ProductData.UTC getAttributeUTC(String name, ProductData.UTC defaultValue) { try { final MetadataAttribute attribute = getAttribute(name); if (attribute != null) { return ProductData.UTC.parse(attribute.getData().getElemString()); } } catch (ParseException e) { // continue } return defaultValue; }
private static void addIDNode(final MetadataElement absRoot, final MetadataElement identNode, final String title, final String tag) { final MetadataAttribute attrib = absRoot.getAttribute(tag); if (attrib == null) return; final String value = title + ": " + attrib.getData().getElemString(); final MetadataElement newAttrib = new MetadataElement(value); identNode.addElement(newAttrib); }
/** * Parses the base parameters <ul> <li>Byte order word</li> <li>Product file name</li> <li>Instrument name</li> * </ul> */ private void parseBaseParameter() throws IOException { MetadataAttribute attribute = null; // read the byte swap word (and forget it gently :-) parseString(BYTE_ORDER_SIZE); // product file name attribute = parseStringAttribute(PRODUCT_FILE_NAME_SIZE, PRODUCT_FILE_NAME_FIELD_NAME, null, null); _fileName = attribute.getData().getElemString(); _mph.addAttribute(attribute); // instrument name attribute = parseStringAttribute(INSTRUMENT_NAME_SIZE, INSTRUMENT_NAME_FIELD_NAME, null, null); _sensor = attribute.getData().getElemString(); _mph.addAttribute(attribute); }
/** * Returns the double value of the attribute with the given name. <p>The given default value is returned if an * attribute with the given name could not be found in this node. * * @param name the attribute name * @param defaultValue the default value * * @return the attribute value as double. * * @throws NumberFormatException if the attribute type is ASCII but cannot be converted to a number */ public double getAttributeDouble(String name, double defaultValue) { final MetadataAttribute attribute = getAttribute(name); if (attribute == null) { return defaultValue; } if (attribute.getDataType() == ProductData.TYPE_ASCII) { return Double.parseDouble(attribute.getData().getElemString()); } return attribute.getData().getElemDouble(); }
static String extractProductName(MetadataElement processingGraphElement) { if (processingGraphElement != null) { final MetadataElement nodeElement = processingGraphElement.getElement("node.0"); if (nodeElement != null) { final MetadataElement sourcesElement = nodeElement.getElement("sources"); if (sourcesElement != null) { final MetadataAttribute sourceProductAttribute = sourcesElement.getAttribute("sourceProduct"); if (sourceProductAttribute != null) { return sourceProductAttribute.getData().getElemString(); } } } } return null; } }
/** * Returns the integer value of the attribute with the given name. <p>The given default value is returned if an * attribute with the given name could not be found in this node. * * @param name the attribute name * @param defaultValue the default value * * @return the attribute value as integer. * * @throws NumberFormatException if the attribute type is ASCII but cannot be converted to a number */ public int getAttributeInt(String name, int defaultValue) { final MetadataAttribute attribute = getAttribute(name); if (attribute == null) { return defaultValue; } if (attribute.getDataType() == ProductData.TYPE_ASCII) { return Integer.parseInt(attribute.getData().getElemString()); } return attribute.getData().getElemInt(); }
public LandsatReprocessedMetadata(FileReader fileReader) throws IOException { super(fileReader); landsatLegacyMetadataDelegate = new LandsatLegacyMetadata(getMetaDataElementRoot()); landsat8MetadataDelegate = new Landsat8Metadata(getMetaDataElementRoot()); sensorId = getMetaDataElementRoot().getElement("PRODUCT_METADATA").getAttribute("SENSOR_ID").getData().getElemString(); }
static void assertInputElementAt(int index, String inputName, MetadataElement metadataElement) { final MetadataElement productElement = metadataElement.getElementAt(index); assertEquals("source." + Integer.toString(index), productElement.getName()); final MetadataAttribute nameAttribute = productElement.getAttribute("name"); assertNotNull(nameAttribute); assertEquals(inputName, nameAttribute.getData().getElemString()); }
@Test public void testMultiProductsNames() throws Exception { String filePath = GPFFacadeTest.class.getResource("test-product.dim").toURI().getPath(); Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("file", new File(filePath)); Product p1 = GPF.createProduct("Read", parameters); Product p2 = GPF.createProduct("Foo", GPF.NO_PARAMS, new Product[]{p1}); Product p3 = GPF.createProduct("Foos", GPF.NO_PARAMS, new Product[]{p1, p2}); MetadataElement metadataElement = p3.getMetadataRoot().getElement("Processing_Graph"); MetadataElement sourceElement = null; for (MetadataElement element : metadataElement.getElements()) { if (element.getAttribute("operator").getData().getElemString().equals("Foos")) { sourceElement = element.getElement("sources"); break; } } assertNotNull(sourceElement); assertEquals(2, sourceElement.getNumAttributes()); assertEquals("sourceProduct.1", sourceElement.getAttributeAt(0).getName()); assertEquals("sourceProduct.2", sourceElement.getAttributeAt(1).getName()); }
public static void assertStringAttribute(MetadataElement elem, String attibuteName, String expectedValue) { final MetadataAttribute attribute = elem.getAttribute(attibuteName); assertNotNull(attribute); assertEquals(ProductData.TYPESTRING_ASCII, attribute.getData().getTypeString()); assertEquals(expectedValue, attribute.getData().getElemString()); }
@Test public void testAsMetadataElement() throws ParseException { final BinningOp binningOp = createBinningOp(); final GlobalMetadata globalMetadata = GlobalMetadata.create(binningOp); final MetadataElement processingGraphElement = globalMetadata.asMetadataElement(); assertNotNull(processingGraphElement); assertEquals("Processing_Graph", processingGraphElement.getName()); final MetadataElement node_0_Element = processingGraphElement.getElement("node.0"); assertNotNull(node_0_Element); final MetadataElement parameterElement = node_0_Element.getElement("parameters"); assertEquals(11, parameterElement.getNumAttributes()); // @todo 2 tb/tb check for other meta elements 2014-10-10 final MetadataAttribute software_qualified_name = parameterElement.getAttribute("software_qualified_name"); assertNotNull(software_qualified_name); assertEquals("org.esa.beam.binning.operator.BinningOp", software_qualified_name.getData().getElemString()); }