001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: /**
019: * @author Vladimir N. Molotkov
020: * @version $Revision$
021: */package java.security.spec;
022:
023: import java.math.BigInteger;
024:
025: import org.apache.harmony.security.internal.nls.Messages;
026:
027: /**
028: * @com.intel.drl.spec_ref
029: *
030: */
031: public class ECPoint {
032: /**
033: * @com.intel.drl.spec_ref
034: */
035: public static final ECPoint POINT_INFINITY = new ECPoint();
036: // affine X coordinate of this point
037: private final BigInteger affineX;
038: // affine Y coordinate of this point
039: private final BigInteger affineY;
040:
041: // Private ctor for POINT_INFINITY
042: private ECPoint() {
043: affineX = null;
044: affineY = null;
045: }
046:
047: /**
048: * @com.intel.drl.spec_ref
049: */
050: public ECPoint(BigInteger affineX, BigInteger affineY) {
051: this .affineX = affineX;
052: if (this .affineX == null) {
053: throw new NullPointerException(Messages.getString(
054: "security.83", "X")); //$NON-NLS-1$ //$NON-NLS-2$
055: }
056: this .affineY = affineY;
057: if (this .affineY == null) {
058: throw new NullPointerException(Messages.getString(
059: "security.83", "Y")); //$NON-NLS-1$ //$NON-NLS-2$
060: }
061: }
062:
063: /**
064: * @com.intel.drl.spec_ref
065: */
066: public BigInteger getAffineX() {
067: return affineX;
068: }
069:
070: /**
071: * @com.intel.drl.spec_ref
072: */
073: public BigInteger getAffineY() {
074: return affineY;
075: }
076:
077: /**
078: * @com.intel.drl.spec_ref
079: */
080: public boolean equals(Object other) {
081: if (this == other) {
082: return true;
083: }
084: if (other instanceof ECPoint) {
085: if (this .affineX != null) {
086: ECPoint otherPoint = (ECPoint) other;
087: // no need to check for null in this case
088: return this .affineX.equals(otherPoint.affineX)
089: && this .affineY.equals(otherPoint.affineY);
090: } else {
091: return other == POINT_INFINITY;
092: }
093: }
094: return false;
095: }
096:
097: /**
098: * @com.intel.drl.spec_ref
099: */
100: public int hashCode() {
101: if (this .affineX != null) {
102: return affineX.hashCode() * 31 + affineY.hashCode();
103: }
104: return 11;
105: }
106: }
|