Esempio n. 1
0
        /// <param name="other">"expected" set to match against</param>
        /// <returns>a formatted string listing which fields are set in this, with the
        /// comparison made agaainst those fields in other, or, 'null' if
        /// there is no difference.</returns>
        public String DiffFrom(FieldsSet other)
        {
            StringBuilder str = new StringBuilder();

            if (!IsSameType(other))
            {
                throw new ArgumentException(
                          "U_ILLEGAL_ARGUMENT_ERROR: FieldsSet of a different type!");
            }
            for (int i = 0; i < FieldCount(); i++)
            {
                if (IsSet(i))
                {
                    int myVal    = Get(i);
                    int theirVal = other.Get(i);

                    if (fEnum != NO_ENUM)
                    {
                        String fieldName = IBM.ICU.Charset.DebugUtilities.EnumString(fEnum, i);

                        String aval = ILOG.J2CsMapping.Util.IlNumber.ToString(myVal);
                        String bval = ILOG.J2CsMapping.Util.IlNumber.ToString(theirVal);

                        str.Append(fieldName + "=" + aval + " not " + bval + ", ");
                    }
                    else
                    {
                        str.Append(ILOG.J2CsMapping.Util.IlNumber.ToString(i) + "=" + myVal + " not "
                                   + theirVal + ", ");
                    }
                }
            }
            if (str.Length == 0)
            {
                return(null);
            }
            return(str.ToString());
        }
Esempio n. 2
0
 /// <summary>
 /// the default implementation for handleParseValue. Base implementation is
 /// to parse a decimal integer value, or inherit from inheritFrom if the
 /// string is 0-length. Implementations of this function should call
 /// set(field,...) on successful parse.
 /// </summary>
 ///
 /// <seealso cref="null"/>
 protected internal void ParseValueDefault(FieldsSet inheritFrom, int field,
                                           String substr)
 {
     if (substr.Length == 0)
     {
         if (inheritFrom == null)
         {
             throw new Exception("Trying to inherit from field " + field
                                 + " but inheritFrom is null");
         }
         if (!inheritFrom.IsSet(field))
         {
             throw new Exception("Trying to inherit from field " + field
                                 + " but inheritFrom[" + field + "] is  not set");
         }
         Set(field, inheritFrom.Get(field));
     }
     else
     {
         int value_ren = Int32.Parse(substr);
         Set(field, value_ren);
     }
 }