1 19 package org.netbeans.tax.test; 20 21 import org.netbeans.tax.*; 22 import java.util.Iterator ; 23 24 public class Attribute { 25 26 public static void main (String args[]) throws Exception { 27 TreeElement element = new TreeElement ("element"); 28 element.addAttribute ("a", "a"); 29 30 print ("New attribute 'a'.", element); 31 32 element.addAttribute ("b", "b"); 34 35 print ("New attribute 'b'.", element); 36 37 TreeAttribute attr = element.getAttribute ("b"); 38 attr.setQName ("a"); 39 40 print ("Change atribute 'b' name to 'a'!", element); 41 42 System.out.println ("Attribute 'b'!"); 44 print (element.getAttribute ("b")); 45 } 46 47 private static void print (String title, TreeElement element) { 48 System.out.println ("-> " + title); 49 50 Iterator it = element.getAttributes().iterator(); 51 while (it.hasNext()) { 52 print ((TreeAttribute)it.next()); 53 } 54 55 System.out.println (""); 56 } 57 58 private static void print (TreeAttribute a) { 59 if ( a == null ) { 60 System.out.println (a); 61 } else { 62 System.out.println (a.getQName() + " = \"" + a.getValue() + "\""); 63 } 64 } 65 66 } 67 | Popular Tags |