001: // .//GEN-BEGIN:_1_be
002: package org.jaffa.applications.test.modules.material.components.itemfinder.dto;
003:
004: import java.util.*;
005: import org.jaffa.components.finder.*;
006:
007: // .//GEN-END:_1_be
008: // Add additional imports//GEN-FIRST:_imports
009:
010: // .//GEN-LAST:_imports
011: // .//GEN-BEGIN:_2_be
012: /** The output for the ItemFinder.
013: */
014: public class ItemFinderOutDto extends FinderOutDto {
015:
016: /** Holds an array of rows to be returned. */
017: private List rows;
018:
019: /** Default Constructor.*/
020: public ItemFinderOutDto() {
021: rows = new ArrayList();
022: }
023:
024: /** Add rows.
025: * @param rows Rows.
026: */
027: public void addRows(ItemFinderOutRowDto rows) {
028: this .rows.add(rows);
029: }
030:
031: /** Add rows at the specified position.
032: * @param rows Rows.
033: * @param index The position at which the rows is to be added.
034: */
035: public void setRows(ItemFinderOutRowDto rows, int index) {
036: //-- check bounds for index
037: if ((index < 0) || (index > this .rows.size()))
038: throw new IndexOutOfBoundsException();
039:
040: this .rows.set(index, rows);
041: }
042:
043: /** Add an array of rows. This will overwrite existing rows.
044: * @param rows An array of rows.
045: */
046: public void setRows(ItemFinderOutRowDto[] rows) {
047: this .rows = Arrays.asList(rows);
048: }
049:
050: /** Clear existing rows.
051: */
052: public void clearRows() {
053: rows.clear();
054: }
055:
056: /** Remove rows.
057: * @param rows Rows.
058: * @return A true indicates a rows was removed. A false indicates, the rows was not found.
059: */
060: public boolean removeRows(ItemFinderOutRowDto rows) {
061: return this .rows.remove(rows);
062: }
063:
064: /** Returns a rows from the specified position.
065: * @param index The position index.
066: * @return Rows.
067: */
068: public ItemFinderOutRowDto getRows(int index) {
069: //-- check bounds for index
070: if ((index < 0) || (index > rows.size()))
071: throw new IndexOutOfBoundsException();
072:
073: return (ItemFinderOutRowDto) rows.get(index);
074: }
075:
076: /** Returns an array of rows.
077: * @return An array of rows.
078: */
079: public ItemFinderOutRowDto[] getRows() {
080: return (ItemFinderOutRowDto[]) rows
081: .toArray(new ItemFinderOutRowDto[0]);
082: }
083:
084: /** Returns a count of rows.
085: * @return The count of rows.
086: */
087: public int getRowsCount() {
088: return rows.size();
089: }
090:
091: /** Returns the debug information
092: * @return The debug information
093: */
094: public String toString() {
095: StringBuffer buf = new StringBuffer();
096: buf.append("<ItemFinderOutDto>");
097: buf.append("<moreRecordsExist>");
098: if (getMoreRecordsExist() != null)
099: buf.append(getMoreRecordsExist());
100: buf.append("</moreRecordsExist>");
101:
102: buf.append("<rows>");
103: ItemFinderOutRowDto[] rows = getRows();
104: for (int i = 0; i < rows.length; i++) {
105: buf.append(rows[i].toString());
106: }
107: buf.append("</rows>");
108:
109: buf.append("</ItemFinderOutDto>");
110: return buf.toString();
111: }
112:
113: // .//GEN-END:_2_be
114: // All the custom code goes here //GEN-FIRST:_custom
115:
116: // .//GEN-LAST:_custom
117: }
|