View Javadoc

1   /* $Id: Slider.java 1102402 2011-05-12 18:03:26Z simonetripodi $
2    *
3    * Licensed to the Apache Software Foundation (ASF) under one or more
4    * contributor license agreements.  See the NOTICE file distributed with
5    * this work for additional information regarding copyright ownership.
6    * The ASF licenses this file to You under the Apache License, Version 2.0
7    * (the "License"); you may not use this file except in compliance with
8    * the License.  You may obtain a copy of the License at
9    *
10   *      http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  package org.apache.commons.digester3.plugins;
20  
21  import org.apache.commons.digester3.Digester;
22  
23  public class Slider
24      implements Widget
25  {
26      private String label = "nolabel";
27  
28      private int min = 0;
29  
30      private int max = 0;
31  
32      // define rules on this class
33      public static void addRules( Digester digester, String pattern )
34      {
35          digester.addSetProperties( pattern );
36  
37          Class<?>[] paramtypes = { Integer.class };
38          digester.addCallMethod( pattern + "/min", "setMin", 0, paramtypes );
39          digester.addCallMethod( pattern + "/max", "setMax", 0, paramtypes );
40      }
41  
42      // define different rules on this class
43      public static void addRangeRules( Digester digester, String pattern )
44      {
45          // note: deliberately no addSetProperties rule
46          Class<?>[] paramtypes = { Integer.class, Integer.class };
47          digester.addCallMethod( pattern + "/range", "setRange", 2, paramtypes );
48          digester.addCallParam( pattern + "/range", 0, "min" );
49          digester.addCallParam( pattern + "/range", 1, "max" );
50      }
51  
52      public Slider()
53      {
54      }
55  
56      public String getLabel()
57      {
58          return label;
59      }
60  
61      public void setLabel( String label )
62      {
63          this.label = label;
64      }
65  
66      public void setMin( int min )
67      {
68          this.min = min;
69      }
70  
71      public int getMin()
72      {
73          return min;
74      }
75  
76      public void setMax( int max )
77      {
78          this.max = max;
79      }
80  
81      public int getMax()
82      {
83          return max;
84      }
85  
86      public void setRange( int min, int max )
87      {
88          this.min = min;
89          this.max = max;
90      }
91  }