#region Disclaimer / License
// Copyright (C) 2010, Jackie Ng
// http://trac.osgeo.org/mapguide/wiki/maestro, jumpinjackie@gmail.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library 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
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//
#endregion
using System;
using System.Collections.Generic;
using System.Text;
using GeoAPI.Geometries;
namespace OSGeo.MapGuide.MaestroAPI.Feature
{
///
/// Base implementation of the
/// interface
///
public abstract class ReaderBase : IReader
{
///
/// Gets the current iterated record
///
public IRecord Current { get; private set; }
///
/// Gets the type of the reader.
///
///
/// The type of the reader.
///
public abstract ReaderType ReaderType { get; }
///
/// Gets the number of fields in this record
///
public int FieldCount
{
get;
protected set;
}
///
/// Gets the name of the field at the specified index
///
///
///
public abstract string GetName(int index);
///
/// Advances the reader to the next item and determines whether there is another object to read.
///
///
public bool ReadNext()
{
this.Current = ReadNextRecord();
return this.Current != null;
}
///
/// Reads the next record.
///
///
protected abstract IRecord ReadNextRecord();
///
/// Closes the object, freeing any resources it may be holding.
///
public virtual void Close() { }
///
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
///
public virtual void Dispose() { }
///
/// Gets the CLR type of the field at the specified index
///
///
///
public abstract Type GetFieldType(int i);
///
/// Gets whether the specified property name has a null property value
///
///
///
public bool IsNull(string name)
{
return this.Current.IsNull(name);
}
///
/// Gets whether the property value at the specified index has a null property value. You must
/// call this method first to determine if it is safe to call the corresponding GetXXX() methods
///
///
///
public bool IsNull(int index)
{
return this.Current.IsNull(index);
}
///
/// Gets the boolean value of the specified property
///
///
///
public bool GetBoolean(string name)
{
return this.Current.GetBoolean(name);
}
///
/// Gets the byte value of the specified property
///
///
///
public byte GetByte(string name)
{
return this.Current.GetByte(name);
}
///
/// Gets the blob value of the specified property
///
///
///
public byte[] GetBlob(string name)
{
return this.Current.GetBlob(name);
}
///
/// Gets the clob value of the specified property
///
///
///
public char[] GetClob(string name)
{
return this.Current.GetClob(name);
}
///
/// Gets the double value of the specified property
///
///
///
public double GetDouble(string name)
{
return this.Current.GetDouble(name);
}
///
/// Gets the datetime value of the specified property
///
///
///
public DateTime GetDateTime(string name)
{
return this.Current.GetDateTime(name);
}
///
/// Gets the int16 value of the specified property
///
///
///
public short GetInt16(string name)
{
return this.Current.GetInt16(name);
}
///
/// Gets the int32 value of the specified property
///
///
///
public int GetInt32(string name)
{
return this.Current.GetInt32(name);
}
///
/// Gets the int64 value of the specified property
///
///
///
public long GetInt64(string name)
{
return this.Current.GetInt64(name);
}
///
/// Gets the single value of the specified property
///
///
///
public float GetSingle(string name)
{
return this.Current.GetSingle(name);
}
///
/// Gets the string value of the specified property
///
///
///
public string GetString(string name)
{
return this.Current.GetString(name);
}
///
/// Gets the geometry value of the specified property
///
///
///
public IGeometry GetGeometry(string name)
{
return this.Current.GetGeometry(name);
}
///
/// Gets the boolean value at the specified index
///
///
///
public bool GetBoolean(int index)
{
return this.Current.GetBoolean(index);
}
///
/// Gets the byte value at the specified index
///
///
///
public byte GetByte(int index)
{
return this.Current.GetByte(index);
}
///
/// Gets the blob value at the specified index
///
///
///
public byte[] GetBlob(int index)
{
return this.Current.GetBlob(index);
}
///
/// Gets the clob value at the specified index
///
///
///
public char[] GetClob(int index)
{
return this.Current.GetClob(index);
}
///
/// Gets the double value at the specified index
///
///
///
public double GetDouble(int index)
{
return this.Current.GetDouble(index);
}
///
/// Gets the datetime value at the specified index
///
///
///
public DateTime GetDateTime(int index)
{
return this.Current.GetDateTime(index);
}
///
/// Gets the int16 value at the specified index
///
///
///
public short GetInt16(int index)
{
return this.Current.GetInt16(index);
}
///
/// Gets the int32 value at the specified index
///
///
///
public int GetInt32(int index)
{
return this.Current.GetInt32(index);
}
///
/// Gets the int64 value at the specified index
///
///
///
public long GetInt64(int index)
{
return this.Current.GetInt64(index);
}
///
/// Gets the single value at the specified index
///
///
///
public float GetSingle(int index)
{
return this.Current.GetSingle(index);
}
///
/// Gets the string value at the specified index
///
///
///
public string GetString(int index)
{
return this.Current.GetString(index);
}
///
/// Gets the geometry value at the specified index
///
///
///
public IGeometry GetGeometry(int index)
{
return this.Current.GetGeometry(index);
}
///
/// Gets the at the specified index.
///
public object this[int index]
{
get { return this.Current[index]; }
}
///
/// Gets the with the specified name.
///
public object this[string name]
{
get { return this.Current[name]; }
}
///
/// Gets the type of the property.
///
/// The name.
///
public abstract OSGeo.MapGuide.MaestroAPI.Schema.PropertyValueType GetPropertyType(string name);
///
/// Gets the type of the property at the specified index.
///
/// The index.
///
public abstract OSGeo.MapGuide.MaestroAPI.Schema.PropertyValueType GetPropertyType(int index);
}
}