01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package java.math;
19:
20: import org.apache.harmony.math.internal.nls.Messages;
21:
22: /**
23: * @author Intel Middleware Product Division
24: * @author Instituto Tecnologico de Cordoba
25: */
26: public enum RoundingMode {
27:
28: /** @ar.org.fitc.spec_ref */
29: UP(BigDecimal.ROUND_UP),
30:
31: /** @ar.org.fitc.spec_ref */
32: DOWN(BigDecimal.ROUND_DOWN),
33:
34: /** @ar.org.fitc.spec_ref */
35: CEILING(BigDecimal.ROUND_CEILING),
36:
37: /** @ar.org.fitc.spec_ref */
38: FLOOR(BigDecimal.ROUND_FLOOR),
39:
40: /** @ar.org.fitc.spec_ref */
41: HALF_UP(BigDecimal.ROUND_HALF_UP),
42:
43: /** @ar.org.fitc.spec_ref */
44: HALF_DOWN(BigDecimal.ROUND_HALF_DOWN),
45:
46: /** @ar.org.fitc.spec_ref */
47: HALF_EVEN(BigDecimal.ROUND_HALF_EVEN),
48:
49: /** @ar.org.fitc.spec_ref */
50: UNNECESSARY(BigDecimal.ROUND_UNNECESSARY);
51:
52: /** The old constant of <code>BigDecimal</code>. */
53: private final int bigDecimalRM;
54:
55: /** It sets the old constant. */
56: RoundingMode(int rm) {
57: bigDecimalRM = rm;
58: }
59:
60: /** @ar.org.fitc.spec_ref */
61: public static RoundingMode valueOf(int rM) {
62: switch (rM) {
63: case BigDecimal.ROUND_CEILING:
64: return CEILING;
65: case BigDecimal.ROUND_DOWN:
66: return DOWN;
67: case BigDecimal.ROUND_FLOOR:
68: return FLOOR;
69: case BigDecimal.ROUND_HALF_DOWN:
70: return HALF_DOWN;
71: case BigDecimal.ROUND_HALF_EVEN:
72: return HALF_EVEN;
73: case BigDecimal.ROUND_HALF_UP:
74: return HALF_UP;
75: case BigDecimal.ROUND_UNNECESSARY:
76: return UNNECESSARY;
77: case BigDecimal.ROUND_UP:
78: return UP;
79: default:
80: // math.00=Invalid rounding mode
81: throw new IllegalArgumentException(Messages
82: .getString("math.00")); //$NON-NLS-1$
83: }
84: }
85: }
|