001/* $Id: Slider.java 1102402 2011-05-12 18:03:26Z simonetripodi $ 002 * 003 * Licensed to the Apache Software Foundation (ASF) under one or more 004 * contributor license agreements. See the NOTICE file distributed with 005 * this work for additional information regarding copyright ownership. 006 * The ASF licenses this file to You under the Apache License, Version 2.0 007 * (the "License"); you may not use this file except in compliance with 008 * the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018 019package org.apache.commons.digester3.plugins; 020 021import org.apache.commons.digester3.Digester; 022 023public class Slider 024 implements Widget 025{ 026 private String label = "nolabel"; 027 028 private int min = 0; 029 030 private int max = 0; 031 032 // define rules on this class 033 public static void addRules( Digester digester, String pattern ) 034 { 035 digester.addSetProperties( pattern ); 036 037 Class<?>[] paramtypes = { Integer.class }; 038 digester.addCallMethod( pattern + "/min", "setMin", 0, paramtypes ); 039 digester.addCallMethod( pattern + "/max", "setMax", 0, paramtypes ); 040 } 041 042 // define different rules on this class 043 public static void addRangeRules( Digester digester, String pattern ) 044 { 045 // note: deliberately no addSetProperties rule 046 Class<?>[] paramtypes = { Integer.class, Integer.class }; 047 digester.addCallMethod( pattern + "/range", "setRange", 2, paramtypes ); 048 digester.addCallParam( pattern + "/range", 0, "min" ); 049 digester.addCallParam( pattern + "/range", 1, "max" ); 050 } 051 052 public Slider() 053 { 054 } 055 056 public String getLabel() 057 { 058 return label; 059 } 060 061 public void setLabel( String label ) 062 { 063 this.label = label; 064 } 065 066 public void setMin( int min ) 067 { 068 this.min = min; 069 } 070 071 public int getMin() 072 { 073 return min; 074 } 075 076 public void setMax( int max ) 077 { 078 this.max = max; 079 } 080 081 public int getMax() 082 { 083 return max; 084 } 085 086 public void setRange( int min, int max ) 087 { 088 this.min = min; 089 this.max = max; 090 } 091}