| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
package net.sf.ezmorph; |
| 18 | |
|
| 19 | |
import java.math.BigDecimal; |
| 20 | |
import java.math.BigInteger; |
| 21 | |
|
| 22 | |
import net.sf.ezmorph.array.BooleanArrayMorpher; |
| 23 | |
import net.sf.ezmorph.array.ByteArrayMorpher; |
| 24 | |
import net.sf.ezmorph.array.CharArrayMorpher; |
| 25 | |
import net.sf.ezmorph.array.DoubleArrayMorpher; |
| 26 | |
import net.sf.ezmorph.array.FloatArrayMorpher; |
| 27 | |
import net.sf.ezmorph.array.IntArrayMorpher; |
| 28 | |
import net.sf.ezmorph.array.LongArrayMorpher; |
| 29 | |
import net.sf.ezmorph.array.ObjectArrayMorpher; |
| 30 | |
import net.sf.ezmorph.array.ShortArrayMorpher; |
| 31 | |
import net.sf.ezmorph.object.BooleanObjectMorpher; |
| 32 | |
import net.sf.ezmorph.object.CharacterObjectMorpher; |
| 33 | |
import net.sf.ezmorph.object.ClassMorpher; |
| 34 | |
import net.sf.ezmorph.object.NumberMorpher; |
| 35 | |
import net.sf.ezmorph.object.StringMorpher; |
| 36 | |
import net.sf.ezmorph.primitive.BooleanMorpher; |
| 37 | |
import net.sf.ezmorph.primitive.ByteMorpher; |
| 38 | |
import net.sf.ezmorph.primitive.CharMorpher; |
| 39 | |
import net.sf.ezmorph.primitive.DoubleMorpher; |
| 40 | |
import net.sf.ezmorph.primitive.FloatMorpher; |
| 41 | |
import net.sf.ezmorph.primitive.IntMorpher; |
| 42 | |
import net.sf.ezmorph.primitive.LongMorpher; |
| 43 | |
import net.sf.ezmorph.primitive.ShortMorpher; |
| 44 | |
|
| 45 | |
|
| 46 | |
|
| 47 | |
|
| 48 | |
|
| 49 | |
|
| 50 | 3 | public class MorphUtils |
| 51 | |
{ |
| 52 | |
|
| 53 | 4 | public static final BigDecimal BIGDECIMAL_ONE = new BigDecimal( "1" ); |
| 54 | |
|
| 55 | 4 | public static final BigDecimal BIGDECIMAL_ZERO = new BigDecimal( "0" ); |
| 56 | |
|
| 57 | |
|
| 58 | |
|
| 59 | |
|
| 60 | |
|
| 61 | |
|
| 62 | |
public static void registerStandardMorphers( MorpherRegistry morpherRegistry ) |
| 63 | |
{ |
| 64 | 505 | morpherRegistry.clear(); |
| 65 | 505 | registerStandardPrimitiveMorphers( morpherRegistry ); |
| 66 | 505 | registerStandardPrimitiveArrayMorphers( morpherRegistry ); |
| 67 | 505 | registerStandardObjectMorphers( morpherRegistry ); |
| 68 | 505 | registerStandardObjectArrayMorphers( morpherRegistry ); |
| 69 | 505 | } |
| 70 | |
|
| 71 | |
|
| 72 | |
|
| 73 | |
|
| 74 | |
|
| 75 | |
|
| 76 | |
|
| 77 | |
|
| 78 | |
|
| 79 | |
|
| 80 | |
|
| 81 | |
|
| 82 | |
|
| 83 | |
|
| 84 | |
|
| 85 | |
|
| 86 | |
|
| 87 | |
|
| 88 | |
|
| 89 | |
|
| 90 | |
public static void registerStandardObjectArrayMorphers( MorpherRegistry morpherRegistry ) |
| 91 | |
{ |
| 92 | 914 | morpherRegistry.registerMorpher( new ObjectArrayMorpher( new BooleanObjectMorpher( |
| 93 | 393 | Boolean.FALSE ) ) ); |
| 94 | 914 | morpherRegistry.registerMorpher( new ObjectArrayMorpher( new CharacterObjectMorpher( |
| 95 | 393 | new Character( '\0' ) ) ) ); |
| 96 | 521 | morpherRegistry.registerMorpher( new ObjectArrayMorpher( StringMorpher.getInstance() ) ); |
| 97 | 922 | morpherRegistry.registerMorpher( new ObjectArrayMorpher( new NumberMorpher( Byte.class, |
| 98 | 393 | new Byte( (byte) 0 ) ) ) ); |
| 99 | 914 | morpherRegistry.registerMorpher( new ObjectArrayMorpher( new NumberMorpher( Short.class, |
| 100 | 393 | new Short( (short) 0 ) ) ) ); |
| 101 | 914 | morpherRegistry.registerMorpher( new ObjectArrayMorpher( new NumberMorpher( Integer.class, |
| 102 | 393 | new Integer( 0 ) ) ) ); |
| 103 | 914 | morpherRegistry.registerMorpher( new ObjectArrayMorpher( new NumberMorpher( Long.class, |
| 104 | 393 | new Long( 0 ) ) ) ); |
| 105 | 914 | morpherRegistry.registerMorpher( new ObjectArrayMorpher( new NumberMorpher( Float.class, |
| 106 | 393 | new Float( 0 ) ) ) ); |
| 107 | 914 | morpherRegistry.registerMorpher( new ObjectArrayMorpher( new NumberMorpher( Double.class, |
| 108 | 393 | new Double( 0 ) ) ) ); |
| 109 | 914 | morpherRegistry.registerMorpher( new ObjectArrayMorpher( new NumberMorpher( BigInteger.class, |
| 110 | 393 | BigInteger.ZERO ) ) ); |
| 111 | 914 | morpherRegistry.registerMorpher( new ObjectArrayMorpher( new NumberMorpher( BigDecimal.class, |
| 112 | 393 | MorphUtils.BIGDECIMAL_ZERO ) ) ); |
| 113 | 521 | morpherRegistry.registerMorpher( new ObjectArrayMorpher( ClassMorpher.getInstance() ) ); |
| 114 | 521 | } |
| 115 | |
|
| 116 | |
|
| 117 | |
|
| 118 | |
|
| 119 | |
|
| 120 | |
|
| 121 | |
|
| 122 | |
|
| 123 | |
|
| 124 | |
|
| 125 | |
|
| 126 | |
|
| 127 | |
|
| 128 | |
|
| 129 | |
|
| 130 | |
|
| 131 | |
|
| 132 | |
|
| 133 | |
|
| 134 | |
public static void registerStandardObjectMorphers( MorpherRegistry morpherRegistry ) |
| 135 | |
{ |
| 136 | 521 | morpherRegistry.registerMorpher( new BooleanObjectMorpher( Boolean.FALSE ) ); |
| 137 | 521 | morpherRegistry.registerMorpher( new CharacterObjectMorpher( new Character( '\0' ) ) ); |
| 138 | 521 | morpherRegistry.registerMorpher( StringMorpher.getInstance() ); |
| 139 | 521 | morpherRegistry.registerMorpher( new NumberMorpher( Byte.class, new Byte( (byte) 0 ) ) ); |
| 140 | 521 | morpherRegistry.registerMorpher( new NumberMorpher( Short.class, new Short( (short) 0 ) ) ); |
| 141 | 521 | morpherRegistry.registerMorpher( new NumberMorpher( Integer.class, new Integer( 0 ) ) ); |
| 142 | 521 | morpherRegistry.registerMorpher( new NumberMorpher( Long.class, new Long( 0 ) ) ); |
| 143 | 521 | morpherRegistry.registerMorpher( new NumberMorpher( Float.class, new Float( 0 ) ) ); |
| 144 | 521 | morpherRegistry.registerMorpher( new NumberMorpher( Double.class, new Double( 0 ) ) ); |
| 145 | 521 | morpherRegistry.registerMorpher( new NumberMorpher( BigInteger.class, BigInteger.ZERO ) ); |
| 146 | 914 | morpherRegistry.registerMorpher( new NumberMorpher( BigDecimal.class, |
| 147 | 393 | MorphUtils.BIGDECIMAL_ZERO ) ); |
| 148 | 521 | morpherRegistry.registerMorpher( ClassMorpher.getInstance() ); |
| 149 | 521 | } |
| 150 | |
|
| 151 | |
|
| 152 | |
|
| 153 | |
|
| 154 | |
|
| 155 | |
|
| 156 | |
|
| 157 | |
|
| 158 | |
|
| 159 | |
|
| 160 | |
|
| 161 | |
|
| 162 | |
|
| 163 | |
|
| 164 | |
|
| 165 | |
|
| 166 | |
public static void registerStandardPrimitiveArrayMorphers( MorpherRegistry morpherRegistry ) |
| 167 | |
{ |
| 168 | 509 | morpherRegistry.registerMorpher( new BooleanArrayMorpher( false ) ); |
| 169 | 509 | morpherRegistry.registerMorpher( new CharArrayMorpher( '\0' ) ); |
| 170 | 509 | morpherRegistry.registerMorpher( new ByteArrayMorpher( (byte) 0 ) ); |
| 171 | 509 | morpherRegistry.registerMorpher( new ShortArrayMorpher( (short) 0 ) ); |
| 172 | 509 | morpherRegistry.registerMorpher( new IntArrayMorpher( 0 ) ); |
| 173 | 509 | morpherRegistry.registerMorpher( new LongArrayMorpher( 0 ) ); |
| 174 | 509 | morpherRegistry.registerMorpher( new FloatArrayMorpher( 0 ) ); |
| 175 | 509 | morpherRegistry.registerMorpher( new DoubleArrayMorpher( 0 ) ); |
| 176 | 509 | } |
| 177 | |
|
| 178 | |
|
| 179 | |
|
| 180 | |
|
| 181 | |
|
| 182 | |
|
| 183 | |
|
| 184 | |
|
| 185 | |
|
| 186 | |
|
| 187 | |
|
| 188 | |
|
| 189 | |
|
| 190 | |
|
| 191 | |
|
| 192 | |
|
| 193 | |
public static void registerStandardPrimitiveMorphers( MorpherRegistry morpherRegistry ) |
| 194 | |
{ |
| 195 | 509 | morpherRegistry.registerMorpher( new BooleanMorpher( false ) ); |
| 196 | 509 | morpherRegistry.registerMorpher( new CharMorpher( '\0' ) ); |
| 197 | 509 | morpherRegistry.registerMorpher( new ByteMorpher( (byte) 0 ) ); |
| 198 | 509 | morpherRegistry.registerMorpher( new ShortMorpher( (short) 0 ) ); |
| 199 | 509 | morpherRegistry.registerMorpher( new IntMorpher( 0 ) ); |
| 200 | 509 | morpherRegistry.registerMorpher( new LongMorpher( 0 ) ); |
| 201 | 509 | morpherRegistry.registerMorpher( new FloatMorpher( 0 ) ); |
| 202 | 509 | morpherRegistry.registerMorpher( new DoubleMorpher( 0 ) ); |
| 203 | 509 | } |
| 204 | |
|
| 205 | 0 | private MorphUtils() |
| 206 | 0 | { |
| 207 | |
|
| 208 | 0 | } |
| 209 | |
} |