Skip to content

Commit

Permalink
Naming cleanup, version number up
Browse files Browse the repository at this point in the history
  • Loading branch information
jbtule committed Jan 24, 2019
1 parent 60a7a04 commit 09a2683
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 182 deletions.
2 changes: 1 addition & 1 deletion DotNetDBF.Enumerable/DotNetDBF.Enumerable.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<RepositoryType>gits</RepositoryType>
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Version>5.1.0</Version>
<Version>6.0.0.1</Version>
<IncludeSymbols>True</IncludeSymbols>
<IncludeSource>True</IncludeSource>
</PropertyGroup>
Expand Down
2 changes: 2 additions & 0 deletions DotNetDBF.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=DBT/@EntryIndexedValue">DBT</s:String>
<s:Boolean x:Key="/Default/CodeStyle/Naming/CSharpNaming/ApplyAutoDetectedRules/@EntryValue">False</s:Boolean>
<s:String x:Key="/Default/FilterSettingsManager/CoverageFilterXml/@EntryValue">&lt;data&gt;&lt;IncludeFilters /&gt;&lt;ExcludeFilters /&gt;&lt;/data&gt;</s:String>
<s:String x:Key="/Default/FilterSettingsManager/AttributeFilterXml/@EntryValue">&lt;data /&gt;</s:String>
<s:Boolean x:Key="/Default/UserDictionary/Words/=javadbf/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=LGPL/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=reserv/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Tuley/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
117 changes: 59 additions & 58 deletions DotNetDBF/DBFField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,30 +43,30 @@ public DBFField()
{
}

public DBFField(string aFieldName, NativeDbType aType)
public DBFField(string fieldName, NativeDbType type)
{
Name = aFieldName;
DataType = aType;
Name = fieldName;
DataType = type;
}

public DBFField(string aFieldName,
NativeDbType aType,
int aFieldLength)
public DBFField(string fieldName,
NativeDbType type,
int fieldLength)
{
Name = aFieldName;
DataType = aType;
FieldLength = aFieldLength;
Name = fieldName;
DataType = type;
FieldLength = fieldLength;
}

public DBFField(string aFieldName,
NativeDbType aType,
int aFieldLength,
int aDecimalCount)
public DBFField(string fieldName,
NativeDbType type,
int fieldLength,
int decimalCount)
{
Name = aFieldName;
DataType = aType;
FieldLength = aFieldLength;
DecimalCount = aDecimalCount;
Name = fieldName;
DataType = type;
FieldLength = fieldLength;
DecimalCount = decimalCount;
}

public int Size => SIZE;
Expand Down Expand Up @@ -162,20 +162,21 @@ @param Length of the field as int.
"Field length should be a positive number");
}

if (DataType == NativeDbType.Date || DataType == NativeDbType.Memo || DataType == NativeDbType.Logical)
switch (DataType)
{
throw new NotSupportedException(
"Cannot set length on this type of field");
}

if (DataType == NativeDbType.Char && value > 255)
{
fieldLength = value % 256;
decimalCount = (byte) (value / 256);
return;
case NativeDbType.Date:
case NativeDbType.Memo:
case NativeDbType.Logical:
throw new NotSupportedException(
"Cannot set length on this type of field");
case NativeDbType.Char when value > 255:
fieldLength = value % 256;
decimalCount = (byte) (value / 256);
return;
default:
fieldLength = value;
break;
}

fieldLength = value;
}
}

Expand Down Expand Up @@ -217,16 +218,16 @@ @param Size of the decimal field.
}
}

public bool Read(BinaryReader aReader)
public bool Read(BinaryReader reader)
{
var t_byte = aReader.ReadByte(); /* 0 */
var t_byte = reader.ReadByte(); /* 0 */
if (t_byte == DBFFieldType.EndOfField)
{
//System.out.println( "End of header found");
return false;
}

aReader.Read(fieldName, 1, 10); /* 1-10 */
reader.Read(fieldName, 1, 10); /* 1-10 */
fieldName[0] = t_byte;

for (var i = 0; i < fieldName.Length; i++)
Expand All @@ -239,16 +240,16 @@ public bool Read(BinaryReader aReader)
}
}

dataType = aReader.ReadByte(); /* 11 */
reserv1 = aReader.ReadInt32(); /* 12-15 */
fieldLength = aReader.ReadByte(); /* 16 */
decimalCount = aReader.ReadByte(); /* 17 */
reserv2 = aReader.ReadInt16(); /* 18-19 */
workAreaId = aReader.ReadByte(); /* 20 */
reserv3 = aReader.ReadInt16(); /* 21-22 */
setFieldsFlag = aReader.ReadByte(); /* 23 */
aReader.Read(reserv4, 0, 7); /* 24-30 */
indexFieldFlag = aReader.ReadByte(); /* 31 */
dataType = reader.ReadByte(); /* 11 */
reserv1 = reader.ReadInt32(); /* 12-15 */
fieldLength = reader.ReadByte(); /* 16 */
decimalCount = reader.ReadByte(); /* 17 */
reserv2 = reader.ReadInt16(); /* 18-19 */
workAreaId = reader.ReadByte(); /* 20 */
reserv3 = reader.ReadInt16(); /* 21-22 */
setFieldsFlag = reader.ReadByte(); /* 23 */
reader.Read(reserv4, 0, 7); /* 24-30 */
indexFieldFlag = reader.ReadByte(); /* 31 */
return true;
}

Expand All @@ -260,25 +261,25 @@ @param os OutputStream
@throws IOException if any stream related issues occur.
*/

public void Write(BinaryWriter aWriter)
public void Write(BinaryWriter writer)
{
// Field Name
aWriter.Write(fieldName); /* 0-10 */
aWriter.Write(new byte[11 - fieldName.Length],
writer.Write(fieldName); /* 0-10 */
writer.Write(new byte[11 - fieldName.Length],
0,
11 - fieldName.Length);

// data type
aWriter.Write(dataType); /* 11 */
aWriter.Write(reserv1); /* 12-15 */
aWriter.Write((byte) fieldLength); /* 16 */
aWriter.Write(decimalCount); /* 17 */
aWriter.Write(reserv2); /* 18-19 */
aWriter.Write(workAreaId); /* 20 */
aWriter.Write(reserv3); /* 21-22 */
aWriter.Write(setFieldsFlag); /* 23 */
aWriter.Write(reserv4); /* 24-30*/
aWriter.Write(indexFieldFlag); /* 31 */
writer.Write(dataType); /* 11 */
writer.Write(reserv1); /* 12-15 */
writer.Write((byte) fieldLength); /* 16 */
writer.Write(decimalCount); /* 17 */
writer.Write(reserv2); /* 18-19 */
writer.Write(workAreaId); /* 20 */
writer.Write(reserv3); /* 21-22 */
writer.Write(setFieldsFlag); /* 23 */
writer.Write(reserv4); /* 24-30*/
writer.Write(indexFieldFlag); /* 31 */
}

/**
Expand All @@ -289,13 +290,13 @@ and the stream "pointer" is supposed to be positioned properly.
@param in DataInputStream
@return Returns the created DBFField object.
@throws IOException If any stream reading problems occures.
@throws IOException If any stream reading problems occurs.
*/

internal static DBFField CreateField(BinaryReader aReader)
internal static DBFField CreateField(BinaryReader reader)
{
var field = new DBFField();
if (field.Read(aReader))
if (field.Read(reader))
{
return field;
}
Expand Down
8 changes: 4 additions & 4 deletions DotNetDBF/DBFFieldType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ public static class DBFFieldType
{
public const byte EndOfData = 0x1A; //^Z End of File
public const byte EndOfField = 0x0D; //End of Field
public const byte False = 0x46; //F in Ascci
public const byte False = 0x46; //F in Ascii
public const byte Space = 0x20; //Space in ascii
public const byte True = 0x54; //T in ascii
public const byte UnknownByte = 0x3F; //Unknown Bool value
public const string Unknown = "?"; //Unknown value

public static DbType FromNative(NativeDbType aByte)
public static DbType FromNative(NativeDbType @byte)
{
switch (aByte)
switch (@byte)
{
case NativeDbType.Char:
return DbType.AnsiStringFixedLength;
Expand All @@ -60,7 +60,7 @@ public static DbType FromNative(NativeDbType aByte)
return DbType.AnsiString;
default:
throw new DBFException(
$"Unsupported Native Type {aByte}");
$"Unsupported Native Type {@byte}");
}
}

Expand Down
Loading

0 comments on commit 09a2683

Please sign in to comment.