示例#1
0
        /// <summary>
        /// Clones the data object. </summary>
        /// <returns> a cloned object. </returns>
        public override object clone()
        {
            StateMod_Parcel parcel = (StateMod_Parcel)base.clone();

            parcel._isClone = true;
            return(parcel);
        }
示例#2
0
        /// <summary>
        /// Cancels any changes made to this object within a GUI since createBackup()
        /// was called and sets _original to null.
        /// </summary>
        public override void restoreOriginal()
        {
            StateMod_Parcel parcel = (StateMod_Parcel)_original;

            base.restoreOriginal();

            _crop     = parcel._crop;
            _area     = parcel._area;
            _year     = parcel._year;
            _isClone  = false;
            _original = null;
        }
示例#3
0
        // REVISIT SAM 2006-04-09
        // Not sure if something like this is needed.
        /// <summary>
        /// Compare two rights Vectors and see if they are the same. </summary>
        /// <param name="v1"> the first Vector of StateMod_ReservoirAreaCap s to check.  Can not
        /// be null. </param>
        /// <param name="v2"> the second Vector of StateMod_ReservoirAreaCap s to check.  Can not
        /// be null. </param>
        /// <returns> true if they are the same, false if not. </returns>

        /*
         * public static boolean equals(Vector v1, Vector v2) {
         *      String routine = "StateMod_ReservoirAreaCap.equals(Vector, Vector)";
         *      StateMod_ReservoirAreaCap r1;
         *      StateMod_ReservoirAreaCap r2;
         *      if (v1.size() != v2.size()) {
         *              Message.printStatus(1, routine, "Vectors are different sizes");
         *              return false;
         *      }
         *      else {
         *              // sort the Vectors and compare item-by-item.  Any differences
         *              // and data will need to be saved back into the dataset.
         *              int size = v1.size();
         *              Message.printStatus(1, routine, "Vectors are of size: " + size);
         *              Vector v1Sort = StateMod_Util.sortStateMod_DataVector(v1);
         *              Vector v2Sort = StateMod_Util.sortStateMod_DataVector(v2);
         *              Message.printStatus(1, routine, "Vectors have been sorted");
         *
         *              for (int i = 0; i < size; i++) {
         *                      r1 = (StateMod_ReservoirAreaCap)v1Sort.elementAt(i);
         *                      r2 = (StateMod_ReservoirAreaCap)v2Sort.elementAt(i);
         *                      Message.printStatus(1, routine, r1.toString());
         *                      Message.printStatus(1, routine, r2.toString());
         *                      Message.printStatus(1, routine, "Element " + i
         + " comparison: " + r1.compareTo(r2));
         +                      if (r1.compareTo(r2) != 0) {
         +                              return false;
         +                      }
         +              }
         +      }
         +      return true;
         + }
         */

        /// <summary>
        /// Tests to see if two parcels equal.  Strings are compared with case sensitivity. </summary>
        /// <param name="ac"> the ac to compare. </param>
        /// <returns> true if they are equal, false otherwise. </returns>
        public virtual bool Equals(StateMod_Parcel parcel)
        {
            if (!base.Equals(parcel))
            {
                return(false);
            }

            if (_crop.Equals(parcel._crop) && (_area == parcel._area) && (_year == parcel._year))
            {
                return(true);
            }
            return(false);
        }
示例#4
0
        /// <summary>
        /// Compares this object to another StateMod_Data object based on the sorted
        /// order from the StateMod_Data variables, and then by crop, area, and year,
        /// in that order. </summary>
        /// <param name="data"> the object to compare against. </param>
        /// <returns> 0 if they are the same, 1 if this object is greater than the other
        /// object, or -1 if it is less. </returns>
        public virtual int CompareTo(StateMod_Data data)
        {
            int res = base.CompareTo(data);

            if (res != 0)
            {
                return(res);
            }

            StateMod_Parcel parcel = (StateMod_Parcel)data;

            res = _crop.CompareTo(parcel.getCrop());
            if (res != 0)
            {
                return(res);
            }

            if (_area < parcel._area)
            {
                return(-1);
            }
            else if (_area > parcel._area)
            {
                return(1);
            }

            if (_year < parcel._year)
            {
                return(-1);
            }
            else if (_year > parcel._year)
            {
                return(1);
            }

            return(0);
        }