001: /***************************************************************
002: * This file is part of the [fleXive](R) project.
003: *
004: * Copyright (c) 1999-2008
005: * UCS - unique computing solutions gmbh (http://www.ucs.at)
006: * All rights reserved
007: *
008: * The [fleXive](R) project is free software; you can redistribute
009: * it and/or modify it under the terms of the GNU General Public
010: * License as published by the Free Software Foundation;
011: * either version 2 of the License, or (at your option) any
012: * later version.
013: *
014: * The GNU General Public License can be found at
015: * http://www.gnu.org/copyleft/gpl.html.
016: * A copy is found in the textfile GPL.txt and important notices to the
017: * license from the author are found in LICENSE.txt distributed with
018: * these libraries.
019: *
020: * This library is distributed in the hope that it will be useful,
021: * but WITHOUT ANY WARRANTY; without even the implied warranty of
022: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
023: * GNU General Public License for more details.
024: *
025: * For further information about UCS - unique computing solutions gmbh,
026: * please see the company website: http://www.ucs.at
027: *
028: * For further information about [fleXive](R), please see the
029: * project website: http://www.flexive.org
030: *
031: *
032: * This copyright notice MUST APPEAR in all copies of the file!
033: ***************************************************************/package com.flexive.shared.search;
034:
035: import com.flexive.shared.FxSharedUtils;
036:
037: import java.io.Serializable;
038: import java.util.ArrayList;
039: import java.util.Collections;
040: import java.util.List;
041:
042: /**
043: * Result preferences object.
044: *
045: * @author Daniel Lichtenberger (daniel.lichtenberger@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)
046: * @version $Rev: 181 $
047: */
048: public class ResultPreferences implements Serializable {
049: private static final long serialVersionUID = -3570651021661098088L;
050:
051: protected List<ResultColumnInfo> selectedColumns = new ArrayList<ResultColumnInfo>();
052: protected List<ResultOrderByInfo> orderByColumns = new ArrayList<ResultOrderByInfo>();
053: protected int rowsPerPage = -1; // maximum rows per page
054: protected int thumbBoxSize = 100; // size of thumbnail box
055: protected long lastChecked = -1; // timestamp of last structural check
056:
057: public ResultPreferences() {
058: }
059:
060: public ResultPreferences(List<ResultColumnInfo> selectedColumns,
061: List<ResultOrderByInfo> orderByColumns, int rowsPerPage,
062: int thumbBoxSize) {
063: FxSharedUtils.checkParameterNull(selectedColumns,
064: "SELECTEDCOLUMNS");
065: FxSharedUtils.checkParameterNull(orderByColumns,
066: "ORDERBYCOLUMNS");
067: this .selectedColumns = new ArrayList<ResultColumnInfo>(
068: selectedColumns);
069: this .orderByColumns = new ArrayList<ResultOrderByInfo>(
070: orderByColumns);
071: this .rowsPerPage = rowsPerPage;
072: this .thumbBoxSize = thumbBoxSize;
073: }
074:
075: public List<ResultColumnInfo> getSelectedColumns() {
076: return Collections.unmodifiableList(selectedColumns);
077: }
078:
079: public List<ResultOrderByInfo> getOrderByColumns() {
080: return Collections.unmodifiableList(orderByColumns);
081: }
082:
083: public int getRowsPerPage() {
084: return rowsPerPage;
085: }
086:
087: public int getThumbBoxSize() {
088: return thumbBoxSize;
089: }
090:
091: public long getLastChecked() {
092: return lastChecked;
093: }
094:
095: public ResultPreferencesEdit getEditObject() {
096: return new ResultPreferencesEdit(selectedColumns,
097: orderByColumns, rowsPerPage, thumbBoxSize);
098: }
099:
100: /** {@inheritDoc} */
101: @Override
102: public boolean equals(Object o) {
103: if (this == o)
104: return true;
105: if (o == null || !(o instanceof ResultPreferences))
106: return false;
107:
108: ResultPreferences that = (ResultPreferences) o;
109:
110: if (rowsPerPage != that.rowsPerPage)
111: return false;
112: if (thumbBoxSize != that.thumbBoxSize)
113: return false;
114: if (!orderByColumns.equals(that.orderByColumns))
115: return false;
116: //noinspection RedundantIfStatement
117: if (!selectedColumns.equals(that.selectedColumns))
118: return false;
119:
120: return true;
121: }
122:
123: /** {@inheritDoc} */
124: @Override
125: public int hashCode() {
126: int result;
127: result = selectedColumns.hashCode();
128: result = 31 * result + orderByColumns.hashCode();
129: result = 31 * result + rowsPerPage;
130: result = 31 * result + thumbBoxSize;
131: return result;
132: }
133:
134: /** {@inheritDoc} */
135: @Override
136: public String toString() {
137: return "ResultPreferences{selectedColumns: " + selectedColumns
138: + ", orderByColumns:" + orderByColumns
139: + ", rowsPerPage: " + rowsPerPage + ", thumbBoxSize: "
140: + thumbBoxSize + "}";
141: }
142: }
|