|
Imports System.Xml.XPath
Imports System.Xml
''' <summary>
''' Represents the column in the fixed position flat file.
''' </summary>
''' <remarks></remarks>
Public Class FixedPositionFileColumn
Inherits FileColumn
Private _position As Integer ' Start of the value in the string
<Xml.Serialization.XmlAttribute("Length")> _
Private _length As Integer ' Length of the value in fixed position file
Public Sub New(ByVal definition As IXPathNavigable, ByVal file As FlatFile)
MyBase.New(definition, file)
Dim navigator As XPathNavigator = definition.CreateNavigator
Dim isInteger As Boolean
Dim start As String = navigator.GetAttribute("StartAt", "")
If String.IsNullOrEmpty(start) Then
Throw New XmlException("StartAt attribute in Column element is required for fixed position files.")
Else
isINteger = Integer.TryParse(start, _position)
If Not isInteger Then
Throw New XmlException("StartAt attribute in Column element should be numeric.")
End If
End If
Dim len As String = navigator.GetAttribute("Length", "")
If String.IsNullOrEmpty(len) Then
Throw New XmlException("Length attribute in Column element is required for fixed position file.")
Else
isInteger = Integer.TryParse(len, _length)
If Not isInteger Then
Throw New XmlException("Length attribute in Column element should be numeric.")
End If
End If
End Sub
Public Property Length() As Integer
Get
Return _length
End Get
Set(ByVal value As Integer)
_length = value
End Set
End Property
''' <summary>
''' Starting position of the value in the line of the file
''' </summary>
''' <value>Position of the first charechter of the string</value>
''' <returns></returns>
''' <remarks>Only used in fixed position files</remarks>
Public Property StartAt() As Integer
Get
Return Me._position
End Get
Set(ByVal value As Integer)
_position = value
End Set
End Property
End Class
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.