Exemple #1
0
  private static void test_das() {
    System.out.println("DAS test:");

    DAS table = new DAS();
    AttributeTable at = new AttributeTable();
    try {
      at.appendAttribute("Authors", Attribute.STRING, "jehamby");
      at.appendAttribute("Authors", Attribute.STRING, "jimg");
      at.addAlias("Creators", "Authors");
      AttributeTable cont = at.appendContainer("Container");
      cont.appendAttribute("Numbers", Attribute.INT32, "123");
      cont.appendAttribute("Floats", Attribute.FLOAT64, "456.0");
      table.addAttributeTable("table1", at);
      at = new AttributeTable();
      at.appendAttribute("another", Attribute.BYTE, "12");
      table.addAttributeTable("table2", at);
    } catch (DASException e) {
      System.out.println("Error constructing DAS: " + e);
    }

    // print the table
    table.print(System.out);

    // get a name from the table
    String author2 = table.getAttributeTable("table1").getAttribute("Creators").getValueAt(1);
    System.out.println("author2 = " + author2);

    // test Cloneable interface
    DAS table2 = (DAS) table.clone();
    System.out.println("\nCloned table:");
    table2.print(System.out);

    // add an attribute to table1 and verify it's not in table 2
    at = new AttributeTable();
    table.addAttributeTable("empty", at);
    if (table2.getAttributeTable("empty") != null) System.out.println("DAS clone failed");
    else System.out.println("DAS clone passed");
  }