#region License Information
/* HeuristicLab
* Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
*
* This file is part of HeuristicLab.
*
* HeuristicLab is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HeuristicLab is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HeuristicLab. If not, see .
*/
#endregion
using System;
using System.Collections;
using System.Collections.Generic;
using HEAL.Attic;
namespace HeuristicLab.DataImporter.Data.Model {
[StorableType("D07567B3-743A-4104-A443-BE048B37BBEB")]
public class StringColumn : ColumnBase {
[Storable]
private List values;
[StorableConstructor]
protected StringColumn(StorableConstructorFlag _) : base(_) { }
public StringColumn(string columnName)
: base(columnName) {
this.values = new List();
}
public StringColumn(string columnName, int capacity)
: this(columnName) {
this.values.Capacity = capacity;
}
public override Type DataType {
get { return typeof(string); }
}
public override string ToString() {
return base.ToString() + " ";
}
protected override IList Values {
get { return this.values; }
}
public override void AddValue(IComparable value) {
this.values.Add(CheckInput(value));
}
public override void AddValueOrNull(IComparable value) {
if (value == null)
this.values.Add(null);
else
this.values.Add(CheckInput(value.ToString()));
}
public override void InsertValue(int position, IComparable value) {
this.values.Insert(position, CheckInput(value));
}
public override void ChangeValue(int position, IComparable value) {
this.values[position] = CheckInput(value);
}
public override void ChangeValueOrNull(int position, IComparable value) {
this.values[position] = CheckInput(value);
}
public override void ChangeValueOrLeaveOldValue(int position, IComparable value) {
this.values[position] = CheckInput(value);
}
public override ColumnBase CreateCopyOfColumnWithoutValues() {
return CreateCopyOfColumnWithoutValues(this.values.Capacity);
}
public override ColumnBase CreateCopyOfColumnWithoutValues(int capacity) {
return new StringColumn(this.Name, capacity);
}
private string CheckInput(IComparable value) {
if (value == null)
return null;
string tmp = value.ToString().Trim();
if (string.IsNullOrEmpty(tmp))
tmp = null;
return tmp;
}
}
}