1 23 24 29 30 package com.sun.enterprise.tools.common.properties; 31 32 import com.sun.enterprise.tools.common.dd.connector.ResourceAdapter; 33 import com.sun.enterprise.tools.common.dd.connector.SunConnector; 34 import java.io.FileInputStream ; 35 40 public class PropertyElements { 41 42 private ResourceAdapter ra; 43 44 45 public PropertyElements(ResourceAdapter ra) { 46 this.ra = ra; 47 } 48 49 public PropertyElements(PropertyElements source) { 50 this.ra = (ResourceAdapter) source.ra.clone(); 51 } 52 53 public ResourceAdapter getResourceAdapter() { 54 return ra; 55 } 56 57 public Object getAttributeDetail(int row, int col) { 58 return ra.getAttributeValue(ResourceAdapter.PROPERTY, row, intToAttribute(col)); } 60 61 public void setAttributeDetail(Object v, int r, int c) { 62 String input = (String ) v; 63 if (null == input || 0 == input.trim().length()) { 64 if (r >= getLength()) 66 return; 67 int otherDex = c - 1; 68 if (otherDex < 0) 69 otherDex = -otherDex; 70 String otherVal = ra.getAttributeValue(ResourceAdapter.PROPERTY, r, 71 intToAttribute(otherDex)); 72 if (null == otherVal || 0 == otherVal.trim().length()) { 73 ra.removePropertyElement(r); 74 return; 75 } 76 input = " "; } 78 while (r >= getLength()) 79 ra.addPropertyElement(true); 80 ra.setAttributeValue(ResourceAdapter.PROPERTY, r, intToAttribute(c), input); } 82 83 public int getLength() { 84 return ra.sizePropertyElement(); 85 } 86 87 public int getWidth() { 88 return 2; 89 } 90 91 private String intToAttribute(int col) { 92 if (col == 0) 93 return "name"; if (col == 1) 95 return "value"; return "error"; } 98 99 PropertyElements(String args[]) { 102 int rowCount = 0; 103 if (null != args && args.length > 0) { 104 try { 105 rowCount = Integer.parseInt(args[0]); 106 } 107 catch (Throwable t) { 108 t.printStackTrace(); 109 } 110 } 111 ra = new ResourceAdapter(); 112 for (int i = 0; i < rowCount; i++) { 113 ra.addPropertyElement(true); 114 ra.setAttributeValue(ResourceAdapter.PROPERTY,i,"name",""+i); ra.setAttributeValue(ResourceAdapter.PROPERTY,i,"value",""+(rowCount - i)); } 117 SunConnector connectorDD = SunConnector.createGraph(); 121 connectorDD.setResourceAdapter(ra); 122 } 123 124 128 String dumpIt() { 129 return ra.dumpBeanNode(); 130 } 131 132 public String toString() { 133 return ra.dumpBeanNode(); 134 } 135 } 136 | Popular Tags |