1 23 package com.sun.enterprise.diagnostics.collect; 24 25 import java.util.List ; 26 import java.util.ArrayList ; 27 import java.util.Iterator ; 28 29 import com.sun.enterprise.diagnostics.Data; 30 31 35 public class WritableDataImpl implements WritableData { 36 37 protected List <Data> children; 38 39 protected List <String > values; 40 41 protected List <List <String >> table; 42 43 protected String source; 44 protected String type; 45 46 private static int INITIAL_CAPACITY = 5; 47 48 public WritableDataImpl() { 49 this("", DataType.CONTAINER); 50 } 51 public WritableDataImpl(String type) { 52 this("",type); 53 } 54 55 public WritableDataImpl(String source, String type) { 56 this(source,type, 5,20); 57 } 58 59 public WritableDataImpl(String source, String type, 60 int initialValuesCapacity) { 61 this(source, type, INITIAL_CAPACITY, initialValuesCapacity); 62 63 } 64 public WritableDataImpl(String source, String type, 65 int initialChildrenCapacity, int initialValuesCapacity) { 66 this(source,type, initialChildrenCapacity, 67 initialValuesCapacity,INITIAL_CAPACITY); 68 69 } 70 public WritableDataImpl(String source, String type, 71 int initialChildrenCapacity, 72 int initialValuesCapacity, int initialTableCapacity) { 73 74 this.source= source; 75 this.type = type; 76 children = new ArrayList (initialChildrenCapacity); 77 values = new ArrayList (initialValuesCapacity); 78 table = new ArrayList (initialTableCapacity); 79 80 } 81 82 public void addChild(Data dataObj) { 83 if(dataObj != null) 84 children.add(dataObj); 85 } 86 87 public void addValue(String value) { 88 values.add(value); 89 } 90 91 public void addRow(List <String > list) { 92 if(list != null) 93 table.add(list); 94 } 95 public Iterator <Data> getChildren() { 96 return children.iterator(); 97 } 98 99 100 public Iterator <String > getValues() { 101 return values.iterator(); 102 } 103 public Iterator <Iterator <String >> getTable() { 104 List <Iterator <String >> listOfIterators = new ArrayList (); 105 Iterator <List <String >> iterator = table.iterator(); 106 while(iterator.hasNext()) { 107 List row = iterator.next(); 108 listOfIterators.add(row.iterator()); 109 } 110 return listOfIterators.iterator(); 111 } 112 public String getSource() { 113 return source; 114 } 115 public String getType() { 116 return type; 117 } 118 } 119 | Popular Tags |