/** * A helper methods for ingestDAS(). * * @param a * @param bt * @throws DASException * @see #ingestDAS(DAS) * @see #ingestAttribute(Attribute, BaseType) * @see #ingestAttributeTable(AttributeTable, BaseType) * @see #ingestAttributeTable(AttributeTable, DConstructor) */ private void ingestAttribute(Attribute a, BaseType bt) throws DASException { if (a.isAlias()) { // copy an alias. String name = a.getName(); String attribute = ((Alias) a).getAliasedToAttributeFieldAsClearString(); bt.addAttributeAlias(name, attribute); } else if (a.isContainer()) { AttributeTable at = a.getContainer(); ingestAttributeTable(at, bt); } else { // copy an Attribute and it's values... String name = a.getName(); int type = a.getType(); Enumeration vals = a.getValues(); while (vals.hasMoreElements()) { String value = (String) vals.nextElement(); bt.appendAttribute(name, type, value, true); } } }
/** * Returns the attribute value at <code>index</code>. * * @param index the index of the attribute value to return. * @return the attribute <code>String</code> at <code>index</code>. */ public String getValueAt(int index) throws NoSuchAttributeException { return (getMyAttribute().getValueAt(index)); }
/** * Constructs a new <code>BaseType</code> with name <code>n</code>. * * @param n the name of the variable. */ public BaseType(String n, boolean decodeName) { super(n,decodeName); _attrTbl = new AttributeTable(_name); _attr = new Attribute(_name, _attrTbl); }
/** * Append a value to this attribute. Always checks the validity of the * attribute's value. * * @param value the attribute <code>String</code> to add. * @throws AttributeBadValueException thrown if the value is not a legal * member of type */ public void appendValue(String value) throws NoSuchAttributeException, AttributeBadValueException { checkVectorUsage(); appendValue(value, true); }
/** * Returns the <code>AttributeTable</code> with the given name. * * @param name the name of the <code>AttributeTable</code> to return. * @return the <code>AttributeTable</code> with the specified name, or null * if there is no matching <code>AttributeTable</code>. * @throws NoSuchAttributeException There is no AttributeTable with the passed name. * @see AttributeTable */ public final AttributeTable getAttributeTable(String name) throws NoSuchAttributeException { AttributeTable at = null; Attribute a = getAttribute(name); if (a != null) { if (a.isContainer()) { at = a.getContainer(); } } return (at); }
Object attribute(Dapparse state, Object name, Object values, Object etype) throws ParseException { Attribute att; att = new Attribute((String) name, attributetypefor((Integer) etype)); try { for (Object o : (List<Object>) values) att.appendValue((String) o, true); } catch (Exception e) { throw new ParseException(e); } return att; }
/** * A helper methods for ingestDAS(). * * @param a * @param bt * @throws DASException * @see #ingestDAS(DAS) * @see #ingestAttribute(Attribute, BaseType) * @see #ingestAttributeTable(AttributeTable, BaseType) * @see #ingestAttributeTable(AttributeTable, DConstructor) */ private void ingestAttribute(Attribute a, BaseType bt) throws DASException { if (a.isAlias()) { // copy an alias. String name = a.getEncodedName(); String attribute = ((Alias) a).getAliasedToAttributeFieldAsClearString(); bt.addAttributeAlias(name, attribute); } else if (a.isContainer()) { AttributeTable at = a.getContainer(); ingestAttributeTable(at, bt); } else { // copy an Attribute and it's values... String name = a.getEncodedName(); int type = a.getType(); Enumeration vals = a.getValues(); while (vals.hasMoreElements()) { String value = (String) vals.nextElement(); bt.appendAttribute(name, type, value, true); } } }
if(!checkByte(value)) throw new AttributeBadValueException("`" + value + "' is not a Byte value."); break; if(!checkShort(value)) throw new AttributeBadValueException("`" + value + "' is not an Int16 value."); break; if(!checkUShort(value)) throw new AttributeBadValueException("`" + value + "' is not an UInt16 value."); break; if(!checkInt(value)) throw new AttributeBadValueException("`" + value + "' is not an Int32 value."); break; if(!checkUInt(value)) throw new AttributeBadValueException("`" + value + "' is not an UInt32 value."); break; if(!checkFloat(value)) throw new AttributeBadValueException("`" + value + "' is not a Float32 value."); break; if(!checkDouble(value)) throw new AttributeBadValueException("`" + value + "' is not a Float64 value."); break;
opendap.dap.Attribute thisA = currentAT.getAttribute(aName); if (thisA.isAlias()) { DAPNode.log.debug("Resolved Alias: '" + thisA.getEncodedName() + "'\n"); } else if (thisA.isContainer()) { resolveAliases(thisA.getContainer());
String aName = (String) e.nextElement(); Attribute a = atTbl.getAttribute(aName); String clearname = a.getClearName(); if (a.isAlias()) { // copy an alias. countLooseAttributes++; } else if (a.isContainer()) { myDAS.addAttributeTable(clearname, a.getContainer()); } else { // copy an Attribute and it's values... int type = a.getType(); Enumeration vals = a.getValues(); while (vals.hasMoreElements()) { String value = (String) vals.nextElement();
opendap.dap.Attribute thisA = currentAT.getAttribute(aName); if (thisA.isAlias()) { System.out.println("Resolved Alias: '" + thisA.getName() + "'\n"); } else if (thisA.isContainer()) { resolveAliases(thisA.getContainer());
if (a != null) { if (a.isContainer()) { vOut += summarizeAttributes(a.getContainer(), ""); } catch (NoSuchAttributeException nase) { vOut += "<li> <b> " + name + ": </b> "; try { Enumeration es = a.getValues(); while (es.hasMoreElements()) { String val = (String) es.nextElement();
if (attribute.getEncodedName().equals("units")) { assertTrue(attribute.getValueAt(0).matches("degrees_.*")); } else if (attribute.getEncodedName().equals("long_name")) { assertEquals(expectedLongName, attribute.getValueAt(0)); } else if (attribute.getEncodedName().equals("actual_range")) { assertEquals(Attribute.FLOAT32, attribute.getType()); final Iterator valuesIterator = attribute.getValuesIterator(); assertEquals(expectedMin, Float.parseFloat(valuesIterator.next().toString()), 1.0E-7); assertEquals(expectedMax, Float.parseFloat(valuesIterator.next().toString()), 1.0E-7); } else if (attribute.getEncodedName().equals("standard_name")) { assertEquals(expectedStandardName, attribute.getValueAt(0)); } else if (attribute.getEncodedName().equals("axis")) { assertEquals(expectedAxis, attribute.getValueAt(0)); } else if (attribute.getEncodedName().equals("coordinate_defines")) { assertEquals("center", attribute.getValueAt(0));
Object attributebody(Dap2Parse state, Object attrlist) throws ParseException { try { if(dasobject == null) throw new ParseException("No DAS for attributes"); for(Object o : (List<Object>) attrlist) { if(o instanceof Attribute) { Attribute a = (Attribute) o; Iterator it = a.getValuesIterator(); while(it.hasNext()) { dasobject.appendAttribute(a.getEncodedName(), a.getType(), (String) it.next()); /*UGH*/ } } else if(o instanceof AttributeTable) { AttributeTable aset = (AttributeTable) o; dasobject.addAttributeTable(aset.getEncodedName(), aset); } else throw new Exception("attribute body: unknown object: " + o); } } catch (ParseException pe) { throw pe; } catch (Exception e) { throw new ParseException(e); } return null; }
Object attributebody(Dapparse state, Object attrlist) throws ParseException { try { for (Object o : (List<Object>) attrlist) { if (o instanceof Attribute) { Attribute a = (Attribute) o; Iterator it = a.getValuesIterator(); while (it.hasNext()) dasobject.appendAttribute(a.getName(), a.getType(), (String) it.next()); /*UGH*/ } else if (o instanceof AttributeTable) { AttributeTable aset = (AttributeTable) o; dasobject.addAttributeTable(aset.getName(), aset); } else throw new Exception("attribute body: unknown object: " + o); } } catch (Exception e) { throw new ParseException(e); } return null; }
if (a != null && (type != a.getType())) { a.appendValue(value, check); a = new Attribute(type, name, value, check); _attr.put(name, a);
Object attrset(Dap2Parse state, Object name, Object attributes) throws ParseException { try { AttributeTable attset; attset = new AttributeTable(clearName((String) name)); for(Object o : (List<Object>) attributes) { if(o instanceof Attribute) { /* ugh, Attributetable needs an additional addAttribute fcn*/ Attribute a = (Attribute) o; Iterator it = a.getValuesIterator(); while(it.hasNext()) { attset.appendAttribute(a.getClearName(), a.getType(), (String) it.next()); } } else if(o instanceof AttributeTable) { AttributeTable at = (AttributeTable) o; attset.addContainer(at.getEncodedName(), at); } else throw new ParseException("attrset: unexpected object: " + o); } return attset; } catch (Exception e) { throw new ParseException(e); } }
setDODSName(DODSNetcdfFile.makeDODSName(dodsName)); DataType ncType = DODSNetcdfFile.convertToNCType(att.getType(), false); // LOOK dont know if attribute is unsigned byte Iterator iter = att.getValuesIterator(); while (iter.hasNext()) { iter.next(); iter = att.getValuesIterator(); int count = 0; while (iter.hasNext()) {
assertTrue(attributeNameSet.contains("NC_GLOBAL")); final AttributeTable attributeTableLat = das.getAttribute("lat").getContainer(); final Enumeration attributeTableLatNames = attributeTableLat.getNames(); testLatLonAttributes(attributeTableLat, attributeTableLatNames, "Latitude", 88.0f, -88.0f, "latitude_north", "y"); final AttributeTable attributeTableLon = das.getAttribute("lon").getContainer(); final Enumeration attributeTableLonNames = attributeTableLon.getNames(); testLatLonAttributes(attributeTableLon, attributeTableLonNames, "Longitude", 0.0f, 358.0f, "longitude_east", "x"); assertTrue(globalAttributesNamesSet.contains("citation")); assertEquals("NOAA Extended Reconstructed SST V3", globalAttributes.getAttribute("title").getValueAt(0));
/** * Returns the attribute type constant. * * @return the attribute type constant. */ public int getType() { return (getMyAttribute().getType()); }