Example #1
0
		/// <summary> Sets a value of a nominal attribute or string attribute.
		/// Creates a fresh list of attribute values before it is set.
		/// 
		/// </summary>
		/// <param name="index">the value's index
		/// </param>
		/// <param name="string">the value
		/// </param>
		/// <exception cref="IllegalArgumentException">if the attribute is not nominal or 
		/// string.
		/// </exception>
		//@ requires string != null;
		//@ requires isNominal() || isString();
		//@ requires 0 <= index && index < m_Values.size();
		internal void  setValue(int index, System.String string_Renamed)
		{
			
			switch (m_Type)
			{
				
				case NOMINAL: 
				case STRING: 
					m_Values = (FastVector) m_Values.copy();
					m_Hashtable = (System.Collections.Hashtable) m_Hashtable.Clone();
					System.Object store = string_Renamed;
					if (string_Renamed.Length > STRING_COMPRESS_THRESHOLD)
					{
						try
						{
							store = string_Renamed;
						}
						catch (System.Exception ex)
						{
                            System.Console.Error.WriteLine("Couldn't compress string attribute value -" + " storing uncompressed." + " " + ex.ToString());
						}
					}
					m_Hashtable.Remove(m_Values.elementAt(index));					
					m_Values.setXmlElementAt(store, index);
					m_Hashtable.Add(store, (System.Int32) index);
					
					break;
				
				default: 
					throw new System.ArgumentException("Can only set values for nominal" + " or string attributes!");
				
			}
		}