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

            parcel._isClone = true;
            return(parcel);
        }
コード例 #2
0
        // TODO SAM 2007-05-15
        // 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.  Cannot be null. </param>
        /// <param name="v2"> the second Vector of StateMod_ReservoirAreaCap s to check.  Cannot 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(StateCU_Parcel parcel)
        {
            if (!base.Equals(parcel))
            {
                return(false);
            }

            if (__crop.Equals(parcel.__crop) && __irrigation_method.Equals(parcel.__irrigation_method, StringComparison.OrdinalIgnoreCase) && (__area == parcel.__area) && __area_units.Equals(parcel.__area_units, StringComparison.OrdinalIgnoreCase) && (__year == parcel.__year))
            {
                return(true);
            }
            return(false);
        }
コード例 #3
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()
        {
            StateCU_Parcel parcel = (StateCU_Parcel)_original;

            base.restoreOriginal();

            __crop = parcel.__crop;
            __irrigation_method = parcel.__irrigation_method;
            __area       = parcel.__area;
            __area_units = parcel.__area_units;
            __year       = parcel.__year;
            _isClone     = false;
            _original    = null;
        }
コード例 #4
0
        /// <summary>
        /// Compares this object to another StateCU_Data object based on the sorted order from the StateCU_Data
        /// variables, and then by crop, irrigation method, area, and year,in that order. </summary>
        /// <param name="data"> the object to compare against (should be a StateCU_Parcel). </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(StateCU_Data data)
        {
            int res = base.CompareTo(data);

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

            StateCU_Parcel parcel = (StateCU_Parcel)data;

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

            res = __irrigation_method.CompareTo(parcel.getIrrigationMethod());
            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);
        }