KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opencms > defaults > CmsFilterMethod


1 /*
2 * File : $Source: /usr/local/cvs/opencms/src-modules/com/opencms/defaults/CmsFilterMethod.java,v $
3 * Date : $Date: 2005/06/27 23:22:23 $
4 * Version: $Revision: 1.2 $
5 *
6 * This library is part of OpenCms -
7 * the Open Source Content Mananagement System
8 *
9 * Copyright (C) 2001 The OpenCms Group
10 *
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2.1 of the License, or (at your option) any later version.
15 *
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
20 *
21 * For further information about OpenCms, please see the
22 * OpenCms Website: http://www.opencms.org
23 *
24 * You should have received a copy of the GNU Lesser General Public
25 * License along with this library; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 */

28
29 package com.opencms.defaults;
30
31 import org.opencms.file.CmsObject;
32
33 import java.lang.reflect.Method JavaDoc;
34
35 /**
36  * Insert the type's description here.
37  * Creation date: (08.11.00 12:02:57)
38  * @author Michael Knoll
39  *
40  * @deprecated Will not be supported past the OpenCms 6 release.
41  */

42 public class CmsFilterMethod {
43     private String JavaDoc m_filterName;
44     private Method JavaDoc m_filterMethod;
45     private Object JavaDoc [] m_defaultParameter;
46   private String JavaDoc m_defaultFilterParam = "";
47
48 /**
49  * FilterMethod constructor.<p>
50  *
51  * @param filterName name of the filter
52  * @param filterMethod the filter method
53  * @param filterParameters additional filter parameters
54  */

55 public CmsFilterMethod(String JavaDoc filterName, Method JavaDoc filterMethod, Object JavaDoc [] filterParameters) {
56   this(filterName, filterMethod, filterParameters, "");
57 }
58
59 /**
60  * FilterMethod constructor with a default value in the Selectbox.<p>
61  *
62  * @param filterName name of the filter
63  * @param filterMethod the filter method
64  * @param filterParameters additional filter parameters
65  * @param defaultFilterParam the default value of the filter
66  */

67 public CmsFilterMethod(String JavaDoc filterName, Method JavaDoc filterMethod, Object JavaDoc [] filterParameters, String JavaDoc defaultFilterParam) {
68
69     m_filterName = filterName;
70     m_filterMethod = filterMethod;
71     m_defaultParameter = filterParameters;
72   m_defaultFilterParam = defaultFilterParam;
73 }
74
75
76 /**
77  * Gets the default parameter.<p>
78  *
79  * @return the default parameters
80  */

81 public Object JavaDoc [] getDefaultParameter() {
82
83     return m_defaultParameter;
84     }
85 /**
86  * Gets the filter method.<p>
87  *
88  * @return the filter method
89  */

90 public Method JavaDoc getFilterMethod() {
91
92     return m_filterMethod;
93     }
94 /**
95  * Gets the filtername.
96  *
97  * @return the name of the filter
98  */

99 public String JavaDoc getFilterName() {
100
101     return m_filterName;
102     }
103 /**
104  * Returns, if this filter needs additional user parameter.
105  * @return true if this filter needs additional user paramet. Otherwise return false.
106  */

107 public boolean hasUserParameter() {
108
109     // check if this filter needs a user-parameter
110

111     Class JavaDoc[] paramTypes = m_filterMethod.getParameterTypes();
112
113     if ((paramTypes.length > 0) && (paramTypes[0] == CmsObject.class)) {
114         return paramTypes.length > (m_defaultParameter.length + 1);
115     } else {
116         return paramTypes.length > m_defaultParameter.length;
117     }
118 }
119 /**
120  * sets the filter parameter
121  * @param parameter the filter parameter
122  */

123 public void setDefaultParameter(Object JavaDoc [] parameter) {
124
125     m_defaultParameter = parameter;
126 }
127 /**
128  * sets the filter method
129  * @param method the filter method
130  */

131 public void setFilterMethod(Method JavaDoc method) {
132
133     m_filterMethod = method;
134 }
135 /**
136  * sets the filter name
137  * @param name the filter name
138  */

139 public void setFilterName(String JavaDoc name) {
140
141     m_filterName = name;
142 }
143
144
145 /**
146  * Gets the value of the default filter parameter.<p>
147  *
148  * @return the default value
149  */

150 public String JavaDoc getDefaultFilterParam() {
151   return m_defaultFilterParam;
152 }
153 }
154
Popular Tags