/** * This method searchs through the <code>DAS</code> * for Alias members. When an Alias is found the method attempts to * resolve it to a specific Attribute. * <p/> * This method is invoked by <code>parse(InputStream is)</code>, and is * used to search for Aliases in AttributeTables found in the DAS. * <p/> * If you are building a DAS from it's API it is important to call * this method prior to returning said DAS to an application. If * this call is not made, Aliases will not work correctly. * * @see Alias * @see DDS#resolveAliases() */ public void resolveAliases() throws MalformedAliasException, UnresolvedAliasException, NoSuchAttributeException { resolveAliases(this); // Enforce the rule that Aliases at the highest level of the DAS // must point to a container (AttributeTable) Enumeration e = getNames(); while (e.hasMoreElements()) { String aName = (String) e.nextElement(); if (Debug.isSet("DAS")) System.out.println("DAS.resolveAliases() - aName: " + aName); Attribute at = getAttribute(aName); if (at == null || !at.isContainer()) { throw new MalformedAliasException("Aliases at the top-level of a DAS MUST reference a container (AttributeTable), not a simple Attribute"); } } }
public void writeGlobalAttributes(DAS das, DDS dds) { pWrt.print("<tr>\n" + "<td align=\"right\" valign=\"top\">\n" + "<h3><a href=\"opendap_form_help.html#global_attr\">Global Attributes:</a></h3>\n" + "<td><textarea name=\"global_attr\" rows=" + _attrRows + " cols=" + _attrCols + ">\n" ); Enumeration edas = das.getNames(); while (edas.hasMoreElements()) { String name = (String) edas.nextElement(); if (!dasTools.nameInKillFile(name) && (dasTools.nameIsGlobal(name) || !dasTools.nameInDDS(name, dds))) { try { AttributeTable attr = das.getAttributeTable(name); writeAttributes(attr); } catch (NoSuchAttributeException nsae) { } } } pWrt.print("</textarea><p>\n\n"); }
public void process(InputStream is) throws DAP2Exception, ParseException { das.parse(is); } }
public void getDetailInfo(Formatter f) { super.getDetailInfo(f); f.format("DDS = %n"); ByteArrayOutputStream buffOS = new ByteArrayOutputStream(8000); dds.print(buffOS); f.format("%s%n", new String(buffOS.toByteArray(), Util.UTF8)); f.format("%nDAS = %n"); buffOS = new ByteArrayOutputStream(8000); das.print(buffOS); f.format("%s%n", new String(buffOS.toByteArray(), Util.UTF8)); }
public void testGetDAS() throws Exception { final DAS das = dConnect.getDAS(); final Enumeration attributeNames = das.getNames(); assertTrue(attributeNames.hasMoreElements()); final Set<String> attributeNameSet = new HashSet<String>(); 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"); final AttributeTable globalAttributes = das.getAttributeTable("NC_GLOBAL"); assertNotNull(globalAttributes);
DAS myDAS = new DAS(); myDAS.addAttributeTable(clearname, a.getContainer()); } else { // copy an Attribute and it's values... myDAS.addAttributeTable(looseEnds.getEncodedName(), looseEnds); myDAS.resolveAliases();
public void writeVariableAttributes(BaseType bt, DAS das) { try { AttributeTable attr = das.getAttributeTable(bt.getEncodedName()); if (attr != null) { pWrt.print("<textarea name=\"" + bt.getLongName().replace('.', '_') + "_attr" + "\" rows=" + _attrRows + " cols=" + _attrCols + ">\n" ); writeAttributes(attr); pWrt.print("</textarea>\n\n"); } } catch (NoSuchAttributeException nsae) { } }
/** * 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>. * @see AttributeTable */ public final AttributeTable getAttributeTableN(String name) { AttributeTable at = null; Attribute a = getAttribute(name); if (a != null) { if (a.isContainer()) { at = a.getContainerN(); } } return (at); }
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; }
Enumeration tableNames = das.getNames(); while (tableNames.hasMoreElements()) { String tableName = (String) tableNames.nextElement(); AttributeTable attTable = das.getAttributeTableN(tableName);
targetAT = getAliasAttribute(this, aNames);
/** * Adds an <code>AttributeTable</code> to the DAS. * * @param name the name of the <code>AttributeTable</code> to add. * @param a the <code>AttributeTable</code> to add. * @see AttributeTable */ public void addAttributeTable(String name, AttributeTable a) throws AttributeExistsException { addContainer(name, a); }
/** * Print a DAS constructed from this DDS and it's BaseType variables. * * @param pw The <code>PrintWriter</code> to print to. */ public void printDAS(PrintWriter pw) { DAS myDAS = null; try { myDAS = this.getDAS(); myDAS.print(pw); } catch (DASException dasE) { pw.println("\n\nCould not get a DAS object to print!\n" + "DDS.getDAS() threw an Exception. Message: \n" + dasE.getMessage()); } }
DAS myDAS = new DAS(); myDAS.addAttributeTable(a.getName(), a.getContainer()); } else { // copy an Attribute and it's values... myDAS.addAttributeTable(looseEnds.getName(), looseEnds); myDAS.resolveAliases();
public void writeVariableAttributes(BaseType bt, DAS das) { try { AttributeTable attr = das.getAttributeTable(bt.getName()); if (attr != null) { pWrt.print("<textarea name=\"" + bt.getLongName().replace('.', '_') + "_attr" + "\" rows=" + _attrRows + " cols=" + _attrCols + ">\n" ); writeAttributes(attr); pWrt.print("</textarea>\n\n"); } } catch (NoSuchAttributeException nsae) { } }
/** * 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 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; }