1/*
2 * ProGuard -- shrinking, optimization, obfuscation, and preverification
3 *             of Java bytecode.
4 *
5 * Copyright (c) 2002-2009 Eric Lafortune (eric@graphics.cornell.edu)
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the Free
9 * Software Foundation; either version 2 of the License, or (at your option)
10 * any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21package proguard.evaluation.value;
22
23import proguard.classfile.ClassConstants;
24
25/**
26 * This class represents a partially evaluated integer value.
27 *
28 * @author Eric Lafortune
29 */
30public abstract class IntegerValue extends Category1Value
31{
32    /**
33     * Returns the specific integer value, if applicable.
34     */
35    public int value()
36    {
37        return 0;
38    }
39
40
41    // Basic unary methods.
42
43    /**
44     * Returns the negated value of this IntegerValue.
45     */
46    public abstract IntegerValue negate();
47
48    /**
49     * Converts this IntegerValue to a byte IntegerValue.
50     */
51    public abstract IntegerValue convertToByte();
52
53    /**
54     * Converts this IntegerValue to a character IntegerValue.
55     */
56    public abstract IntegerValue convertToCharacter();
57
58    /**
59     * Converts this IntegerValue to a short IntegerValue.
60     */
61    public abstract IntegerValue convertToShort();
62
63    /**
64     * Converts this IntegerValue to a LongValue.
65     */
66    public abstract LongValue convertToLong();
67
68    /**
69     * Converts this IntegerValue to a FloatValue.
70     */
71    public abstract FloatValue convertToFloat();
72
73    /**
74     * Converts this IntegerValue to a DoubleValue.
75     */
76    public abstract DoubleValue convertToDouble();
77
78
79    // Basic binary methods.
80
81    /**
82     * Returns the generalization of this IntegerValue and the given other
83     * IntegerValue.
84     */
85    public abstract IntegerValue generalize(IntegerValue other);
86
87    /**
88     * Returns the sum of this IntegerValue and the given IntegerValue.
89     */
90    public abstract IntegerValue add(IntegerValue other);
91
92    /**
93     * Returns the difference of this IntegerValue and the given IntegerValue.
94     */
95    public abstract IntegerValue subtract(IntegerValue other);
96
97    /**
98     * Returns the difference of the given IntegerValue and this IntegerValue.
99     */
100    public abstract IntegerValue subtractFrom(IntegerValue other);
101
102    /**
103     * Returns the product of this IntegerValue and the given IntegerValue.
104     */
105    public abstract IntegerValue multiply(IntegerValue other)
106    throws ArithmeticException;
107
108    /**
109     * Returns the quotient of this IntegerValue and the given IntegerValue.
110     */
111    public abstract IntegerValue divide(IntegerValue other)
112    throws ArithmeticException;
113
114    /**
115     * Returns the quotient of the given IntegerValue and this IntegerValue.
116     */
117    public abstract IntegerValue divideOf(IntegerValue other)
118    throws ArithmeticException;
119
120    /**
121     * Returns the remainder of this IntegerValue divided by the given
122     * IntegerValue.
123     */
124    public abstract IntegerValue remainder(IntegerValue other)
125    throws ArithmeticException;
126
127    /**
128     * Returns the remainder of the given IntegerValue divided by this
129     * IntegerValue.
130     */
131    public abstract IntegerValue remainderOf(IntegerValue other)
132    throws ArithmeticException;
133
134    /**
135     * Returns this IntegerValue, shifted left by the given IntegerValue.
136     */
137    public abstract IntegerValue shiftLeft(IntegerValue other);
138
139    /**
140     * Returns this IntegerValue, shifted right by the given IntegerValue.
141     */
142    public abstract IntegerValue shiftRight(IntegerValue other);
143
144    /**
145     * Returns this unsigned IntegerValue, shifted left by the given
146     * IntegerValue.
147     */
148    public abstract IntegerValue unsignedShiftRight(IntegerValue other);
149
150    /**
151     * Returns the given IntegerValue, shifted left by this IntegerValue.
152     */
153    public abstract IntegerValue shiftLeftOf(IntegerValue other);
154
155    /**
156     * Returns the given IntegerValue, shifted right by this IntegerValue.
157     */
158    public abstract IntegerValue shiftRightOf(IntegerValue other);
159
160    /**
161     * Returns the given unsigned IntegerValue, shifted left by this
162     * IntegerValue.
163     */
164    public abstract IntegerValue unsignedShiftRightOf(IntegerValue other);
165
166    /**
167     * Returns the given LongValue, shifted left by this IntegerValue.
168     */
169    public abstract LongValue shiftLeftOf(LongValue other);
170
171    /**
172     * Returns the given LongValue, shifted right by this IntegerValue.
173     */
174    public abstract LongValue shiftRightOf(LongValue other);
175
176    /**
177     * Returns the given unsigned LongValue, shifted right by this IntegerValue.
178     */
179    public abstract LongValue unsignedShiftRightOf(LongValue other);
180
181    /**
182     * Returns the logical <i>and</i> of this IntegerValue and the given
183     * IntegerValue.
184     */
185    public abstract IntegerValue and(IntegerValue other);
186
187    /**
188     * Returns the logical <i>or</i> of this IntegerValue and the given
189     * IntegerValue.
190     */
191    public abstract IntegerValue or(IntegerValue other);
192
193    /**
194     * Returns the logical <i>xor</i> of this IntegerValue and the given
195     * IntegerValue.
196     */
197    public abstract IntegerValue xor(IntegerValue other);
198
199    /**
200     * Returns whether this IntegerValue and the given IntegerValue are equal:
201     * <code>NEVER</code>, <code>MAYBE</code>, or <code>ALWAYS</code>.
202     */
203    public abstract int equal(IntegerValue other);
204
205    /**
206     * Returns whether this IntegerValue is less than the given IntegerValue:
207     * <code>NEVER</code>, <code>MAYBE</code>, or <code>ALWAYS</code>.
208     */
209    public abstract int lessThan(IntegerValue other);
210
211    /**
212     * Returns whether this IntegerValue is less than or equal to the given
213     * IntegerValue: <code>NEVER</code>, <code>MAYBE</code>, or
214     * <code>ALWAYS</code>.
215     */
216    public abstract int lessThanOrEqual(IntegerValue other);
217
218
219    // Derived binary methods.
220
221    /**
222     * Returns whether this IntegerValue and the given IntegerValue are different:
223     * <code>NEVER</code>, <code>MAYBE</code>, or <code>ALWAYS</code>.
224     */
225    public final int notEqual(IntegerValue other)
226    {
227        return -equal(other);
228    }
229
230    /**
231     * Returns whether this IntegerValue is greater than the given IntegerValue:
232     * <code>NEVER</code>, <code>MAYBE</code>, or <code>ALWAYS</code>.
233     */
234    public final int greaterThan(IntegerValue other)
235    {
236        return -lessThanOrEqual(other);
237    }
238
239    /**
240     * Returns whether this IntegerValue is greater than or equal to the given IntegerValue:
241     * <code>NEVER</code>, <code>MAYBE</code>, or <code>ALWAYS</code>.
242     */
243    public final int greaterThanOrEqual(IntegerValue other)
244    {
245        return -lessThan(other);
246    }
247
248
249    // Similar binary methods, but this time with unknown arguments.
250
251    /**
252     * Returns the generalization of this IntegerValue and the given other
253     * UnknownIntegerValue.
254     */
255    public IntegerValue generalize(UnknownIntegerValue other)
256    {
257        return generalize((IntegerValue)other);
258    }
259
260
261    /**
262     * Returns the sum of this IntegerValue and the given UnknownIntegerValue.
263     */
264    public IntegerValue add(UnknownIntegerValue other)
265    {
266        return add((IntegerValue)other);
267    }
268
269    /**
270     * Returns the difference of this IntegerValue and the given UnknownIntegerValue.
271     */
272    public IntegerValue subtract(UnknownIntegerValue other)
273    {
274        return subtract((IntegerValue)other);
275    }
276
277    /**
278     * Returns the difference of the given UnknownIntegerValue and this IntegerValue.
279     */
280    public IntegerValue subtractFrom(UnknownIntegerValue other)
281    {
282        return subtractFrom((IntegerValue)other);
283    }
284
285    /**
286     * Returns the product of this IntegerValue and the given UnknownIntegerValue.
287     */
288    public IntegerValue multiply(UnknownIntegerValue other)
289    {
290        return multiply((IntegerValue)other);
291    }
292
293    /**
294     * Returns the quotient of this IntegerValue and the given
295     * UnknownIntegerValue.
296     */
297    public IntegerValue divide(UnknownIntegerValue other)
298    {
299        return divide((IntegerValue)other);
300    }
301
302    /**
303     * Returns the quotient of the given UnknownIntegerValue and this
304     * IntegerValue.
305     */
306    public IntegerValue divideOf(UnknownIntegerValue other)
307    {
308        return divideOf((IntegerValue)other);
309    }
310
311    /**
312     * Returns the remainder of this IntegerValue divided by the given
313     * UnknownIntegerValue.
314     */
315    public IntegerValue remainder(UnknownIntegerValue other)
316    {
317        return remainder((IntegerValue)other);
318    }
319
320    /**
321     * Returns the remainder of the given UnknownIntegerValue divided by this
322     * IntegerValue.
323     */
324    public IntegerValue remainderOf(UnknownIntegerValue other)
325    {
326        return remainderOf((IntegerValue)other);
327    }
328
329    /**
330     * Returns this IntegerValue, shifted left by the given UnknownIntegerValue.
331     */
332    public IntegerValue shiftLeft(UnknownIntegerValue other)
333    {
334        return shiftLeft((IntegerValue)other);
335    }
336
337    /**
338     * Returns this IntegerValue, shifted right by the given UnknownIntegerValue.
339     */
340    public IntegerValue shiftRight(UnknownIntegerValue other)
341    {
342        return shiftRight((IntegerValue)other);
343    }
344
345    /**
346     * Returns this unsigned IntegerValue, shifted right by the given
347     * UnknownIntegerValue.
348     */
349    public IntegerValue unsignedShiftRight(UnknownIntegerValue other)
350    {
351        return unsignedShiftRight((IntegerValue)other);
352    }
353
354    /**
355     * Returns the given UnknownIntegerValue, shifted left by this IntegerValue.
356     */
357    public IntegerValue shiftLeftOf(UnknownIntegerValue other)
358    {
359        return shiftLeftOf((IntegerValue)other);
360    }
361
362    /**
363     * Returns the given UnknownIntegerValue, shifted right by this IntegerValue.
364     */
365    public IntegerValue shiftRightOf(UnknownIntegerValue other)
366    {
367        return shiftRightOf((IntegerValue)other);
368    }
369
370    /**
371     * Returns the given unsigned UnknownIntegerValue, shifted right by this
372     * IntegerValue.
373     */
374    public IntegerValue unsignedShiftRightOf(UnknownIntegerValue other)
375    {
376        return unsignedShiftRightOf((IntegerValue)other);
377    }
378
379    /**
380     * Returns the given UnknownLongValue, shifted left by this IntegerValue.
381     */
382    public LongValue shiftLeftOf(UnknownLongValue other)
383    {
384        return shiftLeftOf((LongValue)other);
385    }
386
387    /**
388     * Returns the given UnknownLongValue, shifted right by this IntegerValue.
389     */
390    public LongValue shiftRightOf(UnknownLongValue other)
391    {
392        return shiftRightOf((LongValue)other);
393    }
394
395    /**
396     * Returns the given unsigned UnknownLongValue, shifted right by this
397     * IntegerValue.
398     */
399    public LongValue unsignedShiftRightOf(UnknownLongValue other)
400    {
401        return unsignedShiftRightOf((LongValue)other);
402    }
403
404    /**
405     * Returns the logical <i>and</i> of this IntegerValue and the given
406     * UnknownIntegerValue.
407     */
408    public IntegerValue and(UnknownIntegerValue other)
409    {
410        return and((IntegerValue)other);
411    }
412
413    /**
414     * Returns the logical <i>or</i> of this IntegerValue and the given
415     * UnknownIntegerValue.
416     */
417    public IntegerValue or(UnknownIntegerValue other)
418    {
419        return or((IntegerValue)other);
420    }
421
422    /**
423     * Returns the logical <i>xor</i> of this IntegerValue and the given
424     * UnknownIntegerValue.
425     */
426    public IntegerValue xor(UnknownIntegerValue other)
427    {
428        return xor((IntegerValue)other);
429    }
430
431    /**
432     * Returns whether this IntegerValue and the given UnknownIntegerValue are
433     * equal: <code>NEVER</code>, <code>MAYBE</code>, or <code>ALWAYS</code>.
434     */
435    public int equal(UnknownIntegerValue other)
436    {
437        return equal((IntegerValue)other);
438    }
439
440    /**
441     * Returns whether this IntegerValue is less than the given
442     * UnknownIntegerValue: <code>NEVER</code>, <code>MAYBE</code>, or
443     * <code>ALWAYS</code>.
444     */
445    public int lessThan(UnknownIntegerValue other)
446    {
447        return lessThan((IntegerValue)other);
448    }
449
450    /**
451     * Returns whether this IntegerValue is less than or equal to the given
452     * UnknownIntegerValue: <code>NEVER</code>, <code>MAYBE</code>, or
453     * <code>ALWAYS</code>.
454     */
455    public int lessThanOrEqual(UnknownIntegerValue other)
456    {
457        return lessThanOrEqual((IntegerValue)other);
458    }
459
460
461    // Derived binary methods.
462
463    /**
464     * Returns whether this IntegerValue and the given UnknownIntegerValue are
465     * different: <code>NEVER</code>, <code>MAYBE</code>, or <code>ALWAYS</code>.
466     */
467    public final int notEqual(UnknownIntegerValue other)
468    {
469        return -equal(other);
470    }
471
472    /**
473     * Returns whether this IntegerValue is greater than the given
474     * UnknownIntegerValue: <code>NEVER</code>, <code>MAYBE</code>, or
475     * <code>ALWAYS</code>.
476     */
477    public final int greaterThan(UnknownIntegerValue other)
478    {
479        return -lessThanOrEqual(other);
480    }
481
482    /**
483     * Returns whether this IntegerValue is greater than or equal to the given
484     * UnknownIntegerValue: <code>NEVER</code>, <code>MAYBE</code>, or
485     * <code>ALWAYS</code>.
486     */
487    public final int greaterThanOrEqual(UnknownIntegerValue other)
488    {
489        return -lessThan(other);
490    }
491
492
493    // Similar binary methods, but this time with specific arguments.
494
495    /**
496     * Returns the generalization of this IntegerValue and the given other
497     * SpecificIntegerValue.
498     */
499    public IntegerValue generalize(SpecificIntegerValue other)
500    {
501        return generalize((IntegerValue)other);
502    }
503
504
505    /**
506     * Returns the sum of this IntegerValue and the given SpecificIntegerValue.
507     */
508    public IntegerValue add(SpecificIntegerValue other)
509    {
510        return add((IntegerValue)other);
511    }
512
513    /**
514     * Returns the difference of this IntegerValue and the given SpecificIntegerValue.
515     */
516    public IntegerValue subtract(SpecificIntegerValue other)
517    {
518        return subtract((IntegerValue)other);
519    }
520
521    /**
522     * Returns the difference of the given SpecificIntegerValue and this IntegerValue.
523     */
524    public IntegerValue subtractFrom(SpecificIntegerValue other)
525    {
526        return subtractFrom((IntegerValue)other);
527    }
528
529    /**
530     * Returns the product of this IntegerValue and the given SpecificIntegerValue.
531     */
532    public IntegerValue multiply(SpecificIntegerValue other)
533    {
534        return multiply((IntegerValue)other);
535    }
536
537    /**
538     * Returns the quotient of this IntegerValue and the given
539     * SpecificIntegerValue.
540     */
541    public IntegerValue divide(SpecificIntegerValue other)
542    {
543        return divide((IntegerValue)other);
544    }
545
546    /**
547     * Returns the quotient of the given SpecificIntegerValue and this
548     * IntegerValue.
549     */
550    public IntegerValue divideOf(SpecificIntegerValue other)
551    {
552        return divideOf((IntegerValue)other);
553    }
554
555    /**
556     * Returns the remainder of this IntegerValue divided by the given
557     * SpecificIntegerValue.
558     */
559    public IntegerValue remainder(SpecificIntegerValue other)
560    {
561        return remainder((IntegerValue)other);
562    }
563
564    /**
565     * Returns the remainder of the given SpecificIntegerValue divided by this
566     * IntegerValue.
567     */
568    public IntegerValue remainderOf(SpecificIntegerValue other)
569    {
570        return remainderOf((IntegerValue)other);
571    }
572
573    /**
574     * Returns this IntegerValue, shifted left by the given SpecificIntegerValue.
575     */
576    public IntegerValue shiftLeft(SpecificIntegerValue other)
577    {
578        return shiftLeft((IntegerValue)other);
579    }
580
581    /**
582     * Returns this IntegerValue, shifted right by the given SpecificIntegerValue.
583     */
584    public IntegerValue shiftRight(SpecificIntegerValue other)
585    {
586        return shiftRight((IntegerValue)other);
587    }
588
589    /**
590     * Returns this unsigned IntegerValue, shifted right by the given
591     * SpecificIntegerValue.
592     */
593    public IntegerValue unsignedShiftRight(SpecificIntegerValue other)
594    {
595        return unsignedShiftRight((IntegerValue)other);
596    }
597
598    /**
599     * Returns the given SpecificIntegerValue, shifted left by this IntegerValue.
600     */
601    public IntegerValue shiftLeftOf(SpecificIntegerValue other)
602    {
603        return shiftLeftOf((IntegerValue)other);
604    }
605
606    /**
607     * Returns the given SpecificIntegerValue, shifted right by this IntegerValue.
608     */
609    public IntegerValue shiftRightOf(SpecificIntegerValue other)
610    {
611        return shiftRightOf((IntegerValue)other);
612    }
613
614    /**
615     * Returns the given unsigned SpecificIntegerValue, shifted right by this
616     * IntegerValue.
617     */
618    public IntegerValue unsignedShiftRightOf(SpecificIntegerValue other)
619    {
620        return unsignedShiftRightOf((IntegerValue)other);
621    }
622
623    /**
624     * Returns the given SpecificLongValue, shifted left by this IntegerValue.
625     */
626    public LongValue shiftLeftOf(SpecificLongValue other)
627    {
628        return shiftLeftOf((LongValue)other);
629    }
630
631    /**
632     * Returns the given SpecificLongValue, shifted right by this IntegerValue.
633     */
634    public LongValue shiftRightOf(SpecificLongValue other)
635    {
636        return shiftRightOf((LongValue)other);
637    }
638
639    /**
640     * Returns the given unsigned SpecificLongValue, shifted right by this
641     * IntegerValue.
642     */
643    public LongValue unsignedShiftRightOf(SpecificLongValue other)
644    {
645        return unsignedShiftRightOf((LongValue)other);
646    }
647
648    /**
649     * Returns the logical <i>and</i> of this IntegerValue and the given
650     * SpecificIntegerValue.
651     */
652    public IntegerValue and(SpecificIntegerValue other)
653    {
654        return and((IntegerValue)other);
655    }
656
657    /**
658     * Returns the logical <i>or</i> of this IntegerValue and the given
659     * SpecificIntegerValue.
660     */
661    public IntegerValue or(SpecificIntegerValue other)
662    {
663        return or((IntegerValue)other);
664    }
665
666    /**
667     * Returns the logical <i>xor</i> of this IntegerValue and the given
668     * SpecificIntegerValue.
669     */
670    public IntegerValue xor(SpecificIntegerValue other)
671    {
672        return xor((IntegerValue)other);
673    }
674
675    /**
676     * Returns whether this IntegerValue and the given SpecificIntegerValue are
677     * equal: <code>NEVER</code>, <code>MAYBE</code>, or <code>ALWAYS</code>.
678     */
679    public int equal(SpecificIntegerValue other)
680    {
681        return equal((IntegerValue)other);
682    }
683
684    /**
685     * Returns whether this IntegerValue is less than the given
686     * SpecificIntegerValue: <code>NEVER</code>, <code>MAYBE</code>, or
687     * <code>ALWAYS</code>.
688     */
689    public int lessThan(SpecificIntegerValue other)
690    {
691        return lessThan((IntegerValue)other);
692    }
693
694    /**
695     * Returns whether this IntegerValue is less than or equal to the given
696     * SpecificIntegerValue: <code>NEVER</code>, <code>MAYBE</code>, or
697     * <code>ALWAYS</code>.
698     */
699    public int lessThanOrEqual(SpecificIntegerValue other)
700    {
701        return lessThanOrEqual((IntegerValue)other);
702    }
703
704
705    // Derived binary methods.
706
707    /**
708     * Returns whether this IntegerValue and the given SpecificIntegerValue are
709     * different: <code>NEVER</code>, <code>MAYBE</code>, or <code>ALWAYS</code>.
710     */
711    public final int notEqual(SpecificIntegerValue other)
712    {
713        return -equal(other);
714    }
715
716    /**
717     * Returns whether this IntegerValue is greater than the given
718     * SpecificIntegerValue: <code>NEVER</code>, <code>MAYBE</code>, or
719     * <code>ALWAYS</code>.
720     */
721    public final int greaterThan(SpecificIntegerValue other)
722    {
723        return -lessThanOrEqual(other);
724    }
725
726    /**
727     * Returns whether this IntegerValue is greater than or equal to the given
728     * SpecificIntegerValue: <code>NEVER</code>, <code>MAYBE</code>, or
729     * <code>ALWAYS</code>.
730     */
731    public final int greaterThanOrEqual(SpecificIntegerValue other)
732    {
733        return -lessThan(other);
734    }
735
736
737    // Similar binary methods, but this time with particular arguments.
738
739    /**
740     * Returns the generalization of this IntegerValue and the given other
741     * ParticularIntegerValue.
742     */
743    public IntegerValue generalize(ParticularIntegerValue other)
744    {
745        return generalize((SpecificIntegerValue)other);
746    }
747
748
749    /**
750     * Returns the sum of this IntegerValue and the given ParticularIntegerValue.
751     */
752    public IntegerValue add(ParticularIntegerValue other)
753    {
754        return add((SpecificIntegerValue)other);
755    }
756
757    /**
758     * Returns the difference of this IntegerValue and the given ParticularIntegerValue.
759     */
760    public IntegerValue subtract(ParticularIntegerValue other)
761    {
762        return subtract((SpecificIntegerValue)other);
763    }
764
765    /**
766     * Returns the difference of the given ParticularIntegerValue and this IntegerValue.
767     */
768    public IntegerValue subtractFrom(ParticularIntegerValue other)
769    {
770        return subtractFrom((SpecificIntegerValue)other);
771    }
772
773    /**
774     * Returns the product of this IntegerValue and the given ParticularIntegerValue.
775     */
776    public IntegerValue multiply(ParticularIntegerValue other)
777    {
778        return multiply((SpecificIntegerValue)other);
779    }
780
781    /**
782     * Returns the quotient of this IntegerValue and the given
783     * ParticularIntegerValue.
784     */
785    public IntegerValue divide(ParticularIntegerValue other)
786    {
787        return divide((SpecificIntegerValue)other);
788    }
789
790    /**
791     * Returns the quotient of the given ParticularIntegerValue and this
792     * IntegerValue.
793     */
794    public IntegerValue divideOf(ParticularIntegerValue other)
795    {
796        return divideOf((SpecificIntegerValue)other);
797    }
798
799    /**
800     * Returns the remainder of this IntegerValue divided by the given
801     * ParticularIntegerValue.
802     */
803    public IntegerValue remainder(ParticularIntegerValue other)
804    {
805        return remainder((SpecificIntegerValue)other);
806    }
807
808    /**
809     * Returns the remainder of the given ParticularIntegerValue divided by this
810     * IntegerValue.
811     */
812    public IntegerValue remainderOf(ParticularIntegerValue other)
813    {
814        return remainderOf((SpecificIntegerValue)other);
815    }
816
817    /**
818     * Returns this IntegerValue, shifted left by the given ParticularIntegerValue.
819     */
820    public IntegerValue shiftLeft(ParticularIntegerValue other)
821    {
822        return shiftLeft((SpecificIntegerValue)other);
823    }
824
825    /**
826     * Returns this IntegerValue, shifted right by the given ParticularIntegerValue.
827     */
828    public IntegerValue shiftRight(ParticularIntegerValue other)
829    {
830        return shiftRight((SpecificIntegerValue)other);
831    }
832
833    /**
834     * Returns this unsigned IntegerValue, shifted right by the given
835     * ParticularIntegerValue.
836     */
837    public IntegerValue unsignedShiftRight(ParticularIntegerValue other)
838    {
839        return unsignedShiftRight((SpecificIntegerValue)other);
840    }
841
842    /**
843     * Returns the given ParticularIntegerValue, shifted left by this IntegerValue.
844     */
845    public IntegerValue shiftLeftOf(ParticularIntegerValue other)
846    {
847        return shiftLeftOf((SpecificIntegerValue)other);
848    }
849
850    /**
851     * Returns the given ParticularIntegerValue, shifted right by this IntegerValue.
852     */
853    public IntegerValue shiftRightOf(ParticularIntegerValue other)
854    {
855        return shiftRightOf((SpecificIntegerValue)other);
856    }
857
858    /**
859     * Returns the given unsigned ParticularIntegerValue, shifted right by this
860     * IntegerValue.
861     */
862    public IntegerValue unsignedShiftRightOf(ParticularIntegerValue other)
863    {
864        return unsignedShiftRightOf((SpecificIntegerValue)other);
865    }
866
867    /**
868     * Returns the given ParticularLongValue, shifted left by this IntegerValue.
869     */
870    public LongValue shiftLeftOf(ParticularLongValue other)
871    {
872        return shiftLeftOf((SpecificLongValue)other);
873    }
874
875    /**
876     * Returns the given ParticularLongValue, shifted right by this IntegerValue.
877     */
878    public LongValue shiftRightOf(ParticularLongValue other)
879    {
880        return shiftRightOf((SpecificLongValue)other);
881    }
882
883    /**
884     * Returns the given unsigned ParticularLongValue, shifted right by this
885     * IntegerValue.
886     */
887    public LongValue unsignedShiftRightOf(ParticularLongValue other)
888    {
889        return unsignedShiftRightOf((SpecificLongValue)other);
890    }
891
892    /**
893     * Returns the logical <i>and</i> of this IntegerValue and the given
894     * ParticularIntegerValue.
895     */
896    public IntegerValue and(ParticularIntegerValue other)
897    {
898        return and((SpecificIntegerValue)other);
899    }
900
901    /**
902     * Returns the logical <i>or</i> of this IntegerValue and the given
903     * ParticularIntegerValue.
904     */
905    public IntegerValue or(ParticularIntegerValue other)
906    {
907        return or((SpecificIntegerValue)other);
908    }
909
910    /**
911     * Returns the logical <i>xor</i> of this IntegerValue and the given
912     * ParticularIntegerValue.
913     */
914    public IntegerValue xor(ParticularIntegerValue other)
915    {
916        return xor((SpecificIntegerValue)other);
917    }
918
919    /**
920     * Returns whether this IntegerValue and the given ParticularIntegerValue are
921     * equal: <code>NEVER</code>, <code>MAYBE</code>, or <code>ALWAYS</code>.
922     */
923    public int equal(ParticularIntegerValue other)
924    {
925        return equal((SpecificIntegerValue)other);
926    }
927
928    /**
929     * Returns whether this IntegerValue is less than the given
930     * ParticularIntegerValue: <code>NEVER</code>, <code>MAYBE</code>, or
931     * <code>ALWAYS</code>.
932     */
933    public int lessThan(ParticularIntegerValue other)
934    {
935        return lessThan((SpecificIntegerValue)other);
936    }
937
938    /**
939     * Returns whether this IntegerValue is less than or equal to the given
940     * ParticularIntegerValue: <code>NEVER</code>, <code>MAYBE</code>, or
941     * <code>ALWAYS</code>.
942     */
943    public int lessThanOrEqual(ParticularIntegerValue other)
944    {
945        return lessThanOrEqual((SpecificIntegerValue)other);
946    }
947
948
949    // Derived binary methods.
950
951    /**
952     * Returns whether this IntegerValue and the given ParticularIntegerValue are
953     * different: <code>NEVER</code>, <code>MAYBE</code>, or <code>ALWAYS</code>.
954     */
955    public final int notEqual(ParticularIntegerValue other)
956    {
957        return -equal(other);
958    }
959
960    /**
961     * Returns whether this IntegerValue is greater than the given
962     * ParticularIntegerValue: <code>NEVER</code>, <code>MAYBE</code>, or
963     * <code>ALWAYS</code>.
964     */
965    public final int greaterThan(ParticularIntegerValue other)
966    {
967        return -lessThanOrEqual(other);
968    }
969
970    /**
971     * Returns whether this IntegerValue is greater than or equal to the given
972     * ParticularIntegerValue: <code>NEVER</code>, <code>MAYBE</code>, or
973     * <code>ALWAYS</code>.
974     */
975    public final int greaterThanOrEqual(ParticularIntegerValue other)
976    {
977        return -lessThan(other);
978    }
979
980
981    // Implementations for Value.
982
983    public final IntegerValue integerValue()
984    {
985        return this;
986    }
987
988    public final Value generalize(Value other)
989    {
990        return this.generalize(other.integerValue());
991    }
992
993    public final int computationalType()
994    {
995        return TYPE_INTEGER;
996    }
997
998    public final String internalType()
999    {
1000        return String.valueOf(ClassConstants.INTERNAL_TYPE_INT);
1001    }
1002}
1003