1 12 package org.displaytag.model; 13 14 import java.util.ArrayList ; 15 import java.util.List ; 16 import java.util.Map ; 17 18 import org.apache.commons.lang.StringUtils; 19 import org.apache.commons.lang.builder.ToStringBuilder; 20 import org.apache.commons.lang.builder.ToStringStyle; 21 import org.displaytag.util.HtmlAttributeMap; 22 import org.displaytag.util.MultipleHtmlAttribute; 23 import org.displaytag.util.TagConstants; 24 25 26 31 public class Row 32 { 33 34 37 private Object rowObject; 38 39 42 private List staticCells; 43 44 47 private int rowNumber; 48 49 52 private TableModel tableModel; 53 54 59 public Row(Object object, int number) 60 { 61 this.rowObject = object; 62 this.rowNumber = number; 63 this.staticCells = new ArrayList (); 64 } 65 66 70 public void setRowNumber(int number) 71 { 72 this.rowNumber = number; 73 } 74 75 79 public int getRowNumber() 80 { 81 return this.rowNumber; 82 } 83 84 88 public void addCell(Cell cell) 89 { 90 this.staticCells.add(cell); 91 } 92 93 97 public List getCellList() 98 { 99 return this.staticCells; 100 } 101 102 106 public Object getObject() 107 { 108 return this.rowObject; 109 } 110 111 116 public ColumnIterator getColumnIterator(List columns) 117 { 118 return new ColumnIterator(columns, this); 119 } 120 121 125 protected void setParentTable(TableModel table) 126 { 127 this.tableModel = table; 128 } 129 130 134 protected TableModel getParentTable() 135 { 136 return this.tableModel; 137 } 138 139 143 public String getOpenTag() 144 { 145 Map rowAttributes = new HtmlAttributeMap(); 146 MultipleHtmlAttribute cssAttribute = new MultipleHtmlAttribute(this.tableModel.getProperties().getCssRow( 147 this.rowNumber)); 148 149 if (this.tableModel.getTableDecorator() != null) 150 { 151 try 152 { 153 String addStyle = this.tableModel.getTableDecorator().addRowClass(); 154 155 if (StringUtils.isNotBlank(addStyle)) 156 { 157 cssAttribute.addAttributeValue(addStyle); 158 } 159 160 String id = this.tableModel.getTableDecorator().addRowId(); 161 if (StringUtils.isNotBlank(id)) 162 { 163 rowAttributes.put(TagConstants.ATTRIBUTE_ID, id); 164 } 165 } 166 catch (NoSuchMethodError e) 167 { 168 } 172 } 173 174 rowAttributes.put(TagConstants.ATTRIBUTE_CLASS, cssAttribute); 175 176 StringBuffer tag = new StringBuffer (); 177 tag.append(TagConstants.TAG_OPEN); 178 tag.append(TagConstants.TAGNAME_ROW); 179 180 tag.append(rowAttributes.toString()); 181 182 tag.append(TagConstants.TAG_CLOSE); 183 184 return tag.toString(); 185 } 186 187 191 public String getCloseTag() 192 { 193 return TagConstants.TAG_TR_CLOSE; 194 } 195 196 199 public String toString() 200 { 201 return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) .append("rowNumber", this.rowNumber) .append("rowObject", this.rowObject) .toString(); 205 } 206 } | Popular Tags |