001 /* 002 * $Id: Simple.java 1103095 2011-05-14 13:18:29Z simonetripodi $ 003 * Licensed to the Apache Software Foundation (ASF) under one 004 * or more contributor license agreements. See the NOTICE file 005 * distributed with this work for additional information 006 * regarding copyright ownership. The ASF licenses this file 007 * to you under the Apache License, Version 2.0 (the 008 * "License"); you may not use this file except in compliance 009 * with the License. You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, 014 * software distributed under the License is distributed on an 015 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 016 * KIND, either express or implied. See the License for the 017 * specific language governing permissions and limitations 018 * under the License. 019 */ 020 package org.apache.commons.ognl.test.objects; 021 022 import org.apache.commons.ognl.test.OgnlTestCase; 023 024 import java.math.BigDecimal; 025 import java.math.BigInteger; 026 import java.util.HashMap; 027 import java.util.Map; 028 029 public class Simple 030 extends Object 031 { 032 private String stringValue = "test"; 033 034 private float floatValue; 035 036 private int intValue; 037 038 private boolean booleanValue; 039 040 private BigInteger bigIntValue = BigInteger.valueOf( 0 ); 041 042 private BigDecimal bigDecValue = new BigDecimal( 0.0 ); 043 044 private Root root = new Root(); 045 046 private Bean3 _bean; 047 048 private Bean2 _bean2; 049 050 private Object[] _array; 051 052 private Messages _messages; 053 054 public Simple() 055 { 056 Map src = new HashMap(); 057 src.put( "test", "This is a test" ); 058 059 _messages = new Messages( src ); 060 } 061 062 public Simple( Bean3 bean ) 063 { 064 _bean = bean; 065 } 066 067 public Simple( Bean2 bean ) 068 { 069 _bean2 = bean; 070 } 071 072 public Simple( Object[] values ) 073 { 074 super(); 075 } 076 077 public Simple( String stringValue, float floatValue, int intValue ) 078 { 079 super(); 080 this.stringValue = stringValue; 081 this.floatValue = floatValue; 082 this.intValue = intValue; 083 } 084 085 public void setValues( String stringValue, float floatValue, int intValue ) 086 { 087 this.stringValue = stringValue; 088 this.floatValue = floatValue; 089 this.intValue = intValue; 090 } 091 092 public String getStringValue() 093 { 094 return stringValue; 095 } 096 097 public void setStringValue( String value ) 098 { 099 stringValue = value; 100 } 101 102 public float getFloatValue() 103 { 104 return floatValue; 105 } 106 107 public void setFloatValue( float value ) 108 { 109 floatValue = value; 110 } 111 112 public int getIntValue() 113 { 114 return intValue; 115 } 116 117 public void setIntValue( int value ) 118 { 119 intValue = value; 120 } 121 122 public boolean getValueIsTrue( Object currValue ) 123 { 124 return true; 125 } 126 127 public boolean getBooleanValue() 128 { 129 return booleanValue; 130 } 131 132 public void setBooleanValue( boolean value ) 133 { 134 booleanValue = value; 135 } 136 137 public BigInteger getBigIntValue() 138 { 139 return bigIntValue; 140 } 141 142 public void setArray( Object[] values ) 143 { 144 _array = values; 145 } 146 147 public Object[] getArray() 148 { 149 return _array; 150 } 151 152 public void setBigIntValue( BigInteger value ) 153 { 154 bigIntValue = value; 155 } 156 157 public BigDecimal getBigDecValue() 158 { 159 return bigDecValue; 160 } 161 162 public void setBigDecValue( BigDecimal value ) 163 { 164 bigDecValue = value; 165 } 166 167 public Root getRootValue() 168 { 169 return root; 170 } 171 172 public Messages getMessages() 173 { 174 return _messages; 175 } 176 177 public int getOne() 178 { 179 return 1; 180 } 181 182 public int getTwo() 183 { 184 return 2; 185 } 186 187 public int getThree() 188 { 189 return 3; 190 } 191 192 public int getTestValue( int val ) 193 { 194 return val + 1; 195 } 196 197 public boolean isEditorDisabled() 198 { 199 return false; 200 } 201 202 public boolean isDisabled() 203 { 204 return true; 205 } 206 207 public GetterMethods getMethodsTest() 208 { 209 return new GetterMethods(); 210 } 211 212 public String getDisplayValue( int val ) 213 { 214 return "test"; 215 } 216 217 public boolean equals( Object other ) 218 { 219 boolean result = false; 220 221 if ( other instanceof Simple ) 222 { 223 Simple os = (Simple) other; 224 225 result = 226 OgnlTestCase.isEqual( os.getStringValue(), getStringValue() ) && ( os.getIntValue() == getIntValue() ); 227 } 228 return result; 229 } 230 231 public boolean isThisVarArgsWorking( Object... arguments ) 232 { 233 return true; 234 } 235 }