001: /**
002: * Copyright 2006 Webmedia Group Ltd.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: **/package org.araneaframework.uilib.list;
016:
017: import java.io.Serializable;
018:
019: /**
020: * This class represents information about the ordering of one list column
021: * supplied by user during UI interaction.
022: *
023: * @author Jevgeni Kabanov (ekabanov <i>at</i> araneaframework <i>dot</i> org)
024: *
025: */
026: public class OrderInfoField implements Serializable {
027:
028: protected String id;
029:
030: protected boolean ascending;
031:
032: /**
033: * Creates the class initializing its parameters.
034: *
035: * @param id
036: * order field id.
037: * @param ascending
038: * whether ordering is ascending.
039: */
040: public OrderInfoField(String id, boolean ascending) {
041: this .id = id;
042: this .ascending = ascending;
043: }
044:
045: /**
046: * Returns whether ordering is ascending.
047: *
048: * @return whether ordering is ascending.
049: */
050: public boolean isAscending() {
051: return this .ascending;
052: }
053:
054: /**
055: * Sets whether ordering is ascending.
056: *
057: * @param ascending
058: * whether ordering is ascending.
059: */
060: public void setAscending(boolean ascending) {
061: this .ascending = ascending;
062: }
063:
064: /**
065: * @return Returns the id.
066: */
067: public String getId() {
068: return this .id;
069: }
070:
071: /**
072: * Returns view model.
073: *
074: * @return view model.
075: */
076: public ViewModel getViewModel() {
077: return new ViewModel();
078: }
079:
080: /**
081: * View model.
082: *
083: * @author Jevgeni Kabanov (ekabanov <i>at</i> araneaframework <i>dot</i> org)
084: */
085: public class ViewModel {
086: private String id;
087:
088: private boolean ascending;
089:
090: /**
091: * Takes a snapshot of outer class state.
092: */
093: public ViewModel() {
094: this .id = OrderInfoField.this .id;
095: this .ascending = OrderInfoField.this .ascending;
096: }
097:
098: /**
099: * Returns whether ordering is ascending.
100: *
101: * @return whether ordering is ascending.
102: */
103: public boolean isAscending() {
104: return this .ascending;
105: }
106:
107: /**
108: * @return Returns the id.
109: */
110: public String getId() {
111: return this .id;
112: }
113: }
114:
115: public String toString() {
116: StringBuffer sb = new StringBuffer("OrderInfoField (");
117: sb.append("Id: ");
118: sb.append(getId());
119: sb.append("; ");
120: sb.append("Ascending: ");
121: sb.append(isAscending());
122: sb.append(")");
123: return sb.toString();
124: }
125:
126: }
|