1b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato/*
2b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * ProGuard -- shrinking, optimization, obfuscation, and preverification
3b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato *             of Java bytecode.
4b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato *
5b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang * Copyright (c) 2002-2013 Eric Lafortune (eric@graphics.cornell.edu)
6b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato *
7b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * This program is free software; you can redistribute it and/or modify it
8b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * under the terms of the GNU General Public License as published by the Free
9b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * Software Foundation; either version 2 of the License, or (at your option)
10b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * any later version.
11b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato *
12b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * This program is distributed in the hope that it will be useful, but WITHOUT
13b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * more details.
16b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato *
17b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * You should have received a copy of the GNU General Public License along
18b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * with this program; if not, write to the Free Software Foundation, Inc.,
19b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato */
21b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onoratopackage proguard.evaluation.value;
22b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
23b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato/**
24b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * This IntegerValue represents a specific integer value.
25b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato *
26b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * @author Eric Lafortune
27b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato */
28b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onoratoabstract class SpecificIntegerValue extends IntegerValue
29b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato{
30b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    // Implementations of unary methods of IntegerValue.
31b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
32b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public IntegerValue negate()
33b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
34b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return new NegatedIntegerValue(this);
35b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
36b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
37b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public IntegerValue convertToByte()
38b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
39b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return new ConvertedByteValue(this);
40b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
41b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
42b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public IntegerValue convertToCharacter()
43b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
44b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return new ConvertedCharacterValue(this);
45b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
46b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
47b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public IntegerValue convertToShort()
48b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
49b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return new ConvertedShortValue(this);
50b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
51b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
52b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public LongValue convertToLong()
53b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
54b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return new ConvertedLongValue(this);
55b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
56b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
57b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public FloatValue convertToFloat()
58b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
59b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return new ConvertedFloatValue(this);
60b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
61b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
62b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public DoubleValue convertToDouble()
63b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
64b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return new ConvertedDoubleValue(this);
65b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
66b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
67b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
68b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    // Implementations of binary methods of IntegerValue.
69b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
70b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public IntegerValue generalize(IntegerValue other)
71b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
72b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return other.generalize(this);
73b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
74b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
75b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public IntegerValue add(IntegerValue other)
76b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
77b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return other.add(this);
78b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
79b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
80b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public IntegerValue subtract(IntegerValue other)
81b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
82b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return other.subtractFrom(this);
83b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
84b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
85b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public IntegerValue subtractFrom(IntegerValue other)
86b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
87b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return other.subtract(this);
88b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
89b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
90b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public IntegerValue multiply(IntegerValue other)
91b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
92b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return other.multiply(this);
93b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
94b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
95b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public IntegerValue divide(IntegerValue other)
96b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    throws ArithmeticException
97b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
98b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return other.divideOf(this);
99b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
100b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
101b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public IntegerValue divideOf(IntegerValue other)
102b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    throws ArithmeticException
103b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
104b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return other.divide(this);
105b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
106b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
107b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public IntegerValue remainder(IntegerValue other)
108b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    throws ArithmeticException
109b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
110b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return other.remainderOf(this);
111b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
112b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
113b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public IntegerValue remainderOf(IntegerValue other)
114b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    throws ArithmeticException
115b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
116b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return other.remainder(this);
117b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
118b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
119b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public IntegerValue shiftLeft(IntegerValue other)
120b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
121b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return other.shiftLeftOf(this);
122b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
123b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
124b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public IntegerValue shiftLeftOf(IntegerValue other)
125b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
126b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return other.shiftLeft(this);
127b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
128b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
129b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public IntegerValue shiftRight(IntegerValue other)
130b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
131b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return other.shiftRightOf(this);
132b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
133b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
134b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public IntegerValue shiftRightOf(IntegerValue other)
135b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
136b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return other.shiftRight(this);
137b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
138b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
139b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public IntegerValue unsignedShiftRight(IntegerValue other)
140b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
141b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return other.unsignedShiftRightOf(this);
142b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
143b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
144b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public IntegerValue unsignedShiftRightOf(IntegerValue other)
145b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
146b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return other.unsignedShiftRight(this);
147b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
148b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
149b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public LongValue shiftLeftOf(LongValue other)
150b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
151b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return other.shiftLeft(this);
152b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
153b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
154b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public LongValue shiftRightOf(LongValue other)
155b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
156b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return other.shiftRight(this);
157b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
158b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
159b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public LongValue unsignedShiftRightOf(LongValue other)
160b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
161b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return other.unsignedShiftRight(this);
162b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
163b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
164b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public IntegerValue and(IntegerValue other)
165b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
166b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return other.and(this);
167b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
168b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
169b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public IntegerValue or(IntegerValue other)
170b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
171b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return other.or(this);
172b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
173b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
174b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public IntegerValue xor(IntegerValue other)
175b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
176b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return other.xor(this);
177b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
178b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
179b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public int equal(IntegerValue other)
180b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
181b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return other.equal(this);
182b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
183b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
184b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public int lessThan(IntegerValue other)
185b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
186b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return other.greaterThan(this);
187b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
188b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
189b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public int lessThanOrEqual(IntegerValue other)
190b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
191b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return other.greaterThanOrEqual(this);
192b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
193b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
194b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
195b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    // Implementations of binary IntegerValue methods with SpecificIntegerValue
196b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    // arguments.
197b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
198b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public IntegerValue generalize(SpecificIntegerValue other)
199b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
200b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return this.equals(other) ? this : ValueFactory.INTEGER_VALUE;
201b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
202b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
203b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public IntegerValue add(SpecificIntegerValue other)
204b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
205b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return new CompositeIntegerValue(this, CompositeIntegerValue.ADD, other);
206b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
207b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
208b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public IntegerValue subtract(SpecificIntegerValue other)
209b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
210b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return this.equals(other) ?
211b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato            SpecificValueFactory.INTEGER_VALUE_0 :
212b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato            new CompositeIntegerValue(this, CompositeIntegerValue.SUBTRACT, other);
213b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
214b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
215b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public IntegerValue subtractFrom(SpecificIntegerValue other)
216b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
217b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return this.equals(other) ?
218b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato            SpecificValueFactory.INTEGER_VALUE_0 :
219b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato            new CompositeIntegerValue(other, CompositeIntegerValue.SUBTRACT, this);
220b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
221b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
222b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public IntegerValue multiply(SpecificIntegerValue other)
223b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
224b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return new CompositeIntegerValue(this, CompositeIntegerValue.MULTIPLY, other);
225b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
226b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
227b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public IntegerValue divide(SpecificIntegerValue other)
228b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    throws ArithmeticException
229b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
230b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return new CompositeIntegerValue(this, CompositeIntegerValue.DIVIDE, other);
231b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
232b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
233b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public IntegerValue divideOf(SpecificIntegerValue other)
234b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    throws ArithmeticException
235b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
236b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return new CompositeIntegerValue(other, CompositeIntegerValue.DIVIDE, this);
237b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
238b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
239b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public IntegerValue remainder(SpecificIntegerValue other)
240b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    throws ArithmeticException
241b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
242b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return new CompositeIntegerValue(this, CompositeIntegerValue.REMAINDER, other);
243b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
244b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
245b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public IntegerValue remainderOf(SpecificIntegerValue other)
246b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    throws ArithmeticException
247b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
248b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return new CompositeIntegerValue(other, CompositeIntegerValue.REMAINDER, this);
249b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
250b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
251b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public IntegerValue shiftLeft(SpecificIntegerValue other)
252b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
253b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return new CompositeIntegerValue(this, CompositeIntegerValue.SHIFT_LEFT, other);
254b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
255b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
256b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public IntegerValue shiftRight(SpecificIntegerValue other)
257b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
258b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return new CompositeIntegerValue(this, CompositeIntegerValue.SHIFT_RIGHT, other);
259b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
260b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
261b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public IntegerValue unsignedShiftRight(SpecificIntegerValue other)
262b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
263b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return new CompositeIntegerValue(this, CompositeIntegerValue.UNSIGNED_SHIFT_RIGHT, other);
264b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
265b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
266b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public IntegerValue shiftLeftOf(SpecificIntegerValue other)
267b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
268b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return new CompositeIntegerValue(other, CompositeIntegerValue.SHIFT_LEFT, this);
269b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
270b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
271b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public IntegerValue shiftRightOf(SpecificIntegerValue other)
272b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
273b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return new CompositeIntegerValue(other, CompositeIntegerValue.SHIFT_RIGHT, this);
274b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
275b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
276b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public IntegerValue unsignedShiftRightOf(SpecificIntegerValue other)
277b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
278b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return new CompositeIntegerValue(other, CompositeIntegerValue.UNSIGNED_SHIFT_RIGHT, this);
279b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
280b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
281b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public LongValue shiftLeftOf(SpecificLongValue other)
282b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
283b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return new CompositeLongValue(other, CompositeLongValue.SHIFT_LEFT, this);
284b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
285b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
286b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public LongValue shiftRightOf(SpecificLongValue other)
287b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
288b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return new CompositeLongValue(other, CompositeLongValue.SHIFT_RIGHT, this);
289b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
290b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
291b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public LongValue unsignedShiftRightOf(SpecificLongValue other)
292b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
293b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return new CompositeLongValue(other, CompositeLongValue.UNSIGNED_SHIFT_RIGHT, this);
294b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
295b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
296b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public IntegerValue and(SpecificIntegerValue other)
297b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
298b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return this.equals(other) ?
299b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato            this :
300b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato            new CompositeIntegerValue(other, CompositeIntegerValue.AND, this);
301b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
302b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
303b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public IntegerValue or(SpecificIntegerValue other)
304b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
305b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return this.equals(other) ?
306b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato            this :
307b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato            new CompositeIntegerValue(other, CompositeIntegerValue.OR, this);
308b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
309b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
310b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public IntegerValue xor(SpecificIntegerValue other)
311b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
312b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return this.equals(other) ?
313b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato            SpecificValueFactory.INTEGER_VALUE_0 :
314b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato            new CompositeIntegerValue(other, CompositeIntegerValue.XOR, this);
315b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
316b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
317b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public int equal(SpecificIntegerValue other)
318b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
319b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return this.equals(other) ? ALWAYS : MAYBE;
320b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
321b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
322b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public int lessThan(SpecificIntegerValue other)
323b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
324b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return this.equals(other) ? NEVER : MAYBE;
325b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
326b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
327b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public int lessThanOrEqual(SpecificIntegerValue other)
328b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
329b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return this.equals(other) ? ALWAYS : MAYBE;
330b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
331b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
332b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
333b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    // Implementations for Value.
334b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
335b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public boolean isSpecific()
336b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
337b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return true;
338b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
339b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
340b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
341b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    // Implementations for Object.
342b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
343b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public boolean equals(Object object)
344b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
345b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return object != null &&
346b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato               this.getClass() == object.getClass();
347b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
348b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
349b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
350b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public int hashCode()
351b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
352b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return this.getClass().hashCode();
353b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
354b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato}
355