KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jaspersoft > jasperserver > war > dto > RuntimeInputControlWrapper


1 /*
2  * Copyright (C) 2006 JasperSoft http://www.jaspersoft.com
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed WITHOUT ANY WARRANTY; and without the
10  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11  * See the GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
15  * or write to:
16  *
17  * Free Software Foundation, Inc.,
18  * 59 Temple Place - Suite 330,
19  * Boston, MA USA 02111-1307
20  */

21 package com.jaspersoft.jasperserver.war.dto;
22
23 import java.io.Serializable JavaDoc;
24 import java.text.Format JavaDoc;
25 import java.util.Map JavaDoc;
26 import java.util.Date JavaDoc;
27
28 import com.jaspersoft.jasperserver.api.metadata.common.domain.InputControl;
29
30 /**
31  *
32  */

33 public class RuntimeInputControlWrapper implements Serializable JavaDoc
34 {
35     private InputControl inputControl;
36     private Object JavaDoc value;
37     private String JavaDoc errorMessage;
38     private Format JavaDoc format;
39     private Map JavaDoc queryResults;
40     private Date JavaDoc clientDate;
41
42     public RuntimeInputControlWrapper(InputControl inputControl)
43     {
44         this.inputControl = inputControl;
45     }
46
47     public Object JavaDoc getValue()
48     {
49         return value;
50     }
51
52     public void setValue(Object JavaDoc value)
53     {
54         this.value = value;
55     }
56
57     public String JavaDoc getErrorMessage()
58     {
59         return errorMessage;
60     }
61
62     public void setErrorMessage(String JavaDoc errorMessage)
63     {
64         this.errorMessage = errorMessage;
65     }
66
67     public InputControl getInputControl()
68     {
69         return inputControl;
70     }
71
72     public void setInputControl(InputControl inputControl)
73     {
74         this.inputControl = inputControl;
75     }
76
77     public Format JavaDoc getFormat()
78     {
79         return format;
80     }
81
82     public void setFormat(Format JavaDoc format)
83     {
84         this.format = format;
85     }
86
87     public String JavaDoc getFormattedValue()
88     {
89         try {
90             return format.format(value);
91         } catch(Exception JavaDoc e) {
92             return value != null ? value.toString() : null;
93         }
94     }
95
96     public Map JavaDoc getQueryResults()
97     {
98         return queryResults;
99     }
100
101     public void setQueryResults(Map JavaDoc queryResults)
102     {
103         this.queryResults = queryResults;
104     }
105
106     public Date JavaDoc getClientDate()
107     {
108         return clientDate;
109     }
110
111     public void setClientDate(Date JavaDoc clientDate)
112     {
113         this.clientDate = clientDate;
114     }
115     
116     public boolean isMulti() {
117         if (inputControl == null) {
118             return false;
119         }
120
121         byte type = inputControl.getType();
122         return type == InputControl.TYPE_MULTI_VALUE
123                 || type == InputControl.TYPE_MULTI_SELECT_LIST_OF_VALUES
124                 || type == InputControl.TYPE_MULTI_SELECT_LIST_OF_VALUES_CHECKBOX
125                 || type == InputControl.TYPE_MULTI_SELECT_QUERY
126                 || type == InputControl.TYPE_MULTI_SELECT_QUERY_CHECKBOX;
127     }
128
129     public boolean isMultiDistinctValues() {
130         if (inputControl == null) {
131             return false;
132         }
133
134         byte type = inputControl.getType();
135         return
136                 type == InputControl.TYPE_MULTI_SELECT_LIST_OF_VALUES
137                 || type == InputControl.TYPE_MULTI_SELECT_LIST_OF_VALUES_CHECKBOX
138                 || type == InputControl.TYPE_MULTI_SELECT_QUERY
139                 || type == InputControl.TYPE_MULTI_SELECT_QUERY_CHECKBOX;
140     }
141 }
142
Popular Tags