Skip to content

Commit

Permalink
Added missing documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
fubar-coder committed Jul 10, 2015
1 parent eb70926 commit a05564e
Show file tree
Hide file tree
Showing 65 changed files with 699 additions and 13 deletions.
3 changes: 3 additions & 0 deletions BeanIO/Annotation/SegmentAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace BeanIO.Annotation
{
/// <summary>
/// Segment annotation applied to class members or methods
/// </summary>
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Method)]
public class SegmentAttribute : Attribute
{
Expand Down
1 change: 1 addition & 0 deletions BeanIO/BeanIO.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\BeanIO.XML</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Compile Include="Annotation\FieldAttribute.cs" />
Expand Down
52 changes: 52 additions & 0 deletions BeanIO/BeanReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,74 @@

namespace BeanIO
{
/// <summary>
/// Abstract basic bean reader implementation
/// </summary>
public abstract class BeanReader : IBeanReader
{
/// <summary>
/// Error handler to handle exceptions thrown by <see cref="IBeanReader.Read"/>.
/// </summary>
public event BeanReaderErrorHandlerDelegate Error;

/// <summary>
/// Gets or sets the record or group name of the most recent bean object read from this reader,
/// or null if the end of the stream was reached.
/// </summary>
public string RecordName { get; protected set; }

/// <summary>
/// Gets or sets the starting line number of the first record for the most recent bean
/// object read from this reader, or -1 when the end of the stream is reached.
/// The line number may be zero if new lines are not used to separate characters.
/// </summary>
public int LineNumber { get; protected set; }

/// <summary>
/// Gets the number of records read from the underlying input stream for the
/// most recent bean object read from this reader. This typically returns 1
/// unless a bean object was mapped to a record group which may span
/// multiple records.
/// </summary>
public abstract int RecordCount { get; }

/// <summary>
/// Gets the record information for all bean objects read from this reader.
/// If a bean object can span multiple records, <see cref="IBeanReader.RecordCount"/> can be used
/// to determine how many records were read from the stream.
/// </summary>
/// <param name="index">the index of the record, starting at 0</param>
/// <returns>the <see cref="IRecordContext"/></returns>
public abstract IRecordContext GetRecordContext(int index);

/// <summary>
/// Reads a single bean from the input stream.
/// </summary>
/// <remarks>
/// If the end of the stream is reached, null is returned.
/// </remarks>
/// <returns>The bean read, or null if the end of the stream was reached.</returns>
public abstract object Read();

/// <summary>
/// Skips ahead in the input stream.
/// </summary>
/// <remarks>
/// Record validation errors are ignored, but a malformed record, unidentified
/// record, or record out of sequence, will cause an exception that halts stream
/// reading. Exceptions thrown by this method are not passed to the error handler.
/// </remarks>
/// <param name="count">The number of bean objects to skip over that would have been
/// returned by calling <see cref="IBeanReader.Read"/>.
/// </param>
/// <returns>the number of skipped bean objects, which may be less than <paramref name="count"/>
/// if the end of the stream was reached
/// </returns>
public abstract int Skip(int count);

/// <summary>
/// Closes the underlying input stream.
/// </summary>
public abstract void Close();

/// <summary>
Expand Down
10 changes: 10 additions & 0 deletions BeanIO/BeanReaderErrorEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,23 @@

namespace BeanIO
{
/// <summary>
/// The event arguments for the bean reader error
/// </summary>
public class BeanReaderErrorEventArgs : EventArgs
{
/// <summary>
/// Initializes a new instance of the <see cref="BeanReaderErrorEventArgs"/> class.
/// </summary>
/// <param name="exception">The exception to pass to the event handler</param>
public BeanReaderErrorEventArgs(BeanReaderException exception)
{
Exception = exception;
}

/// <summary>
/// Gets the exception that occurred while reading a bean.
/// </summary>
public BeanReaderException Exception { get; private set; }
}
}
3 changes: 3 additions & 0 deletions BeanIO/Builder/Align.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace BeanIO.Builder
{
/// <summary>
/// The text alignment
/// </summary>
public enum Align
{
/// <summary>
Expand Down
45 changes: 45 additions & 0 deletions BeanIO/Builder/CsvParserBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,60 +11,105 @@ public class CsvParserBuilder : IParserBuilder
{
private readonly CsvRecordParserFactory _parser = new CsvRecordParserFactory();

/// <summary>
/// Sets the delimiter character
/// </summary>
/// <param name="delimiter">The delimiter to set</param>
/// <returns>the <see cref="CsvParserBuilder"/></returns>
public CsvParserBuilder Delimiter(char delimiter)
{
_parser.Delimiter = delimiter;
return this;
}

/// <summary>
/// Sets the quote character
/// </summary>
/// <param name="quote">The quote character to set</param>
/// <returns>the <see cref="CsvParserBuilder"/></returns>
public CsvParserBuilder Quote(char quote)
{
_parser.Quote = quote;
return this;
}

/// <summary>
/// Sets the escape character
/// </summary>
/// <param name="escape">The escape character to set</param>
/// <returns>the <see cref="CsvParserBuilder"/></returns>
public CsvParserBuilder Escape(char escape)
{
_parser.Escape = escape;
return this;
}

/// <summary>
/// Sets the record terminator
/// </summary>
/// <param name="terminator">The record terminator to set</param>
/// <returns>the <see cref="CsvParserBuilder"/></returns>
public CsvParserBuilder RecordTerminator(string terminator)
{
_parser.RecordTerminator = terminator;
return this;
}

/// <summary>
/// Enables the detection of comments using the following comment indicators
/// </summary>
/// <param name="comments">The comment indicators to set</param>
/// <returns>the <see cref="CsvParserBuilder"/></returns>
public CsvParserBuilder EnableComments(params string[] comments)
{
_parser.Comments = comments;
return this;
}

/// <summary>
/// Enables multi line records
/// </summary>
/// <returns>the <see cref="CsvParserBuilder"/></returns>
public CsvParserBuilder EnableMultiline()
{
_parser.IsMultilineEnabled = true;
return this;
}

/// <summary>
/// Allow unquoted whitespace characters
/// </summary>
/// <returns>the <see cref="CsvParserBuilder"/></returns>
public CsvParserBuilder AllowUnquotedWhitespace()
{
_parser.IsWhitespaceAllowed = true;
return this;
}

/// <summary>
/// Allow unquoted quotes
/// </summary>
/// <returns>the <see cref="CsvParserBuilder"/></returns>
public CsvParserBuilder AllowUnquotedQuotes()
{
_parser.UnquotedQuotesAllowed = true;
return this;
}

/// <summary>
/// Always quote all field values
/// </summary>
/// <returns>the <see cref="CsvParserBuilder"/></returns>
public CsvParserBuilder AlwaysQuote()
{
_parser.AlwaysQuote = true;
return this;
}

/// <summary>
/// Builds the configuration about the record parser factory.
/// </summary>
/// <returns>The configuration for the record parser factory.</returns>
public BeanConfig<IRecordParserFactory> Build()
{
var config = new BeanConfig<IRecordParserFactory>(() => _parser);
Expand Down
36 changes: 36 additions & 0 deletions BeanIO/Builder/DelimitedParserBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,45 +11,81 @@ public class DelimitedParserBuilder : IParserBuilder
{
private readonly DelimitedRecordParserFactory _parser = new DelimitedRecordParserFactory();

/// <summary>
/// Initializes a new instance of the <see cref="DelimitedParserBuilder"/> class.
/// </summary>
public DelimitedParserBuilder()
{
}

/// <summary>
/// Initializes a new instance of the <see cref="DelimitedParserBuilder"/> class.
/// </summary>
/// <param name="delimiter">The field delimiter to use</param>
public DelimitedParserBuilder(char delimiter)
{
_parser.Delimiter = delimiter;
}

/// <summary>
/// Sets the field delimiter character
/// </summary>
/// <param name="delimiter">The field delimiter character to set</param>
/// <returns>the <see cref="DelimitedParserBuilder"/></returns>
public DelimitedParserBuilder Delimiter(char delimiter)
{
_parser.Delimiter = delimiter;
return this;
}

/// <summary>
/// Sets the record terminator string
/// </summary>
/// <param name="terminator">The record terminator to set</param>
/// <returns>the <see cref="DelimitedParserBuilder"/></returns>
public DelimitedParserBuilder RecordTerminator(string terminator)
{
_parser.RecordTerminator = terminator;
return this;
}

/// <summary>
/// Sets the escape character.
/// </summary>
/// <param name="escape">The escape character to use</param>
/// <returns>the <see cref="DelimitedParserBuilder"/></returns>
public DelimitedParserBuilder EnableEscape(char escape)
{
_parser.Escape = escape;
return this;
}

/// <summary>
/// Enable line continuation using the following escape character
/// </summary>
/// <param name="c">The line continuation escape character to use</param>
/// <returns>the <see cref="DelimitedParserBuilder"/></returns>
public DelimitedParserBuilder EnableLineContinuation(char c)
{
_parser.LineContinuationCharacter = c;
return this;
}

/// <summary>
/// Enables the detection of comments using the following comment indicators
/// </summary>
/// <param name="comments">The comment indicators to set</param>
/// <returns>the <see cref="DelimitedParserBuilder"/></returns>
public DelimitedParserBuilder EnableComments(params string[] comments)
{
_parser.Comments = comments;
return this;
}

/// <summary>
/// Builds the configuration about the record parser factory.
/// </summary>
/// <returns>The configuration for the record parser factory.</returns>
public BeanConfig<IRecordParserFactory> Build()
{
var config = new BeanConfig<IRecordParserFactory>(() => _parser);
Expand Down
7 changes: 7 additions & 0 deletions BeanIO/Builder/FieldBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,17 @@

namespace BeanIO.Builder
{
/// <summary>
/// Builds the field configuration
/// </summary>
public class FieldBuilder : PropertyBuilderSupport<FieldBuilder, FieldConfig>
{
private FieldConfig _config;

/// <summary>
/// Initializes a new instance of the <see cref="FieldBuilder"/> class.
/// </summary>
/// <param name="name">The field name</param>
public FieldBuilder(string name)
{
_config = new FieldConfig()
Expand Down
4 changes: 4 additions & 0 deletions BeanIO/Builder/FixedLengthParserBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ public FixedLengthParserBuilder EnableComments(params string[] comments)
return this;
}

/// <summary>
/// Builds the configuration about the record parser factory.
/// </summary>
/// <returns>The configuration for the record parser factory.</returns>
public BeanConfig<IRecordParserFactory> Build()
{
var config = new BeanConfig<IRecordParserFactory>(() => _parser);
Expand Down
3 changes: 3 additions & 0 deletions BeanIO/Builder/GroupBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace BeanIO.Builder
{
/// <summary>
/// Builds a new group configuration
/// </summary>
public class GroupBuilder : GroupBuilderSupport<GroupBuilder, GroupConfig>
{
private GroupConfig _config;
Expand Down
7 changes: 7 additions & 0 deletions BeanIO/Builder/IParserBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@

namespace BeanIO.Builder
{
/// <summary>
/// The basic parser builder interface
/// </summary>
public interface IParserBuilder
{
/// <summary>
/// Builds the configuration about the record parser factory.
/// </summary>
/// <returns>The configuration for the record parser factory.</returns>
BeanConfig<IRecordParserFactory> Build();
}
}
3 changes: 3 additions & 0 deletions BeanIO/Builder/RecordBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

namespace BeanIO.Builder
{
/// <summary>
/// Builds a new record configuration
/// </summary>
public class RecordBuilder : SegmentBuilderSupport<RecordBuilder, RecordConfig>
{
private RecordConfig _config;
Expand Down
Loading

0 comments on commit a05564e

Please sign in to comment.