forked from iryndin/jdbf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
1,364 additions
and
1,294 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>net.iryndin</groupId> | ||
<artifactId>jdbf</artifactId> | ||
<version>1.1</version> | ||
<packaging>jar</packaging> | ||
|
||
<name>jdbf</name> | ||
<url>http://github.com/iryndin/jdbf</url> | ||
<description>jdbf - Java library to write/read DBF files</description> | ||
|
||
|
||
<scm> | ||
<url>https://github.com/iryndin/jdbf</url> | ||
</scm> | ||
|
||
<licenses> | ||
<license> | ||
<distribution>repo</distribution> | ||
<name>Apache License, Version 2.0</name> | ||
<url>http://apache.org/licenses/LICENSE-2.0.txt</url> | ||
</license> | ||
</licenses> | ||
|
||
<dependencies/> | ||
|
||
<developers> | ||
<developer> | ||
<name>Ivan Ryndin</name> | ||
<id>iryndin</id> | ||
<roles> | ||
<role>Project Owner</role> | ||
<role>Developer</role> | ||
</roles> | ||
</developer> | ||
<developer> | ||
<name>bugy</name> | ||
<id>bugy</id> | ||
<roles> | ||
<role>Developer</role> | ||
</roles> | ||
</developer> | ||
</developers> | ||
<contributors> | ||
<contributor> | ||
<name>bugy</name> | ||
</contributor> | ||
</contributors> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<maven.compiler.source>1.7</maven.compiler.source> | ||
<maven.compiler.target>1.7</maven.compiler.target> | ||
|
||
<maven.compiler.version>3.1</maven.compiler.version> | ||
</properties> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>${maven.compiler.version}</version> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
Large diffs are not rendered by default.
Oops, something went wrong.
322 changes: 161 additions & 161 deletions
322
src/net/iryndin/jdbf/core/DbfField.java → .../java/net/iryndin/jdbf/core/DbfField.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,161 +1,161 @@ | ||
package net.iryndin.jdbf.core; | ||
|
||
|
||
public class DbfField { | ||
|
||
private String name; | ||
private DbfFieldTypeEnum type; | ||
private int length; | ||
private int numberOfDecimalPlaces; | ||
private int offset; | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
public DbfFieldTypeEnum getType() { | ||
return type; | ||
} | ||
public void setType(DbfFieldTypeEnum type) { | ||
this.type = type; | ||
} | ||
public int getLength() { | ||
return length; | ||
} | ||
public void setLength(int length) { | ||
this.length = length; | ||
} | ||
public int getNumberOfDecimalPlaces() { | ||
return numberOfDecimalPlaces; | ||
} | ||
public void setNumberOfDecimalPlaces(int numberOfDecimalPlaces) { | ||
this.numberOfDecimalPlaces = numberOfDecimalPlaces; | ||
} | ||
public int getOffset() { | ||
return offset; | ||
} | ||
public void setOffset(int offset) { | ||
this.offset = offset; | ||
} | ||
@Override | ||
public String toString() { | ||
return "DbfField [\n name=" + name + ", \n type=" + type | ||
+ ", \n length=" + length + ", \n numberOfDecimalPlaces=" | ||
+ numberOfDecimalPlaces + ", \n offset=" + offset + "\n]"; | ||
} | ||
|
||
public String getStringRepresentation() { | ||
StringBuilder sb = new StringBuilder(); | ||
sb.append(name).append(","); | ||
sb.append(type.getType()).append(","); | ||
sb.append(length).append(","); | ||
sb.append(numberOfDecimalPlaces); | ||
return sb.toString(); | ||
} | ||
|
||
public static DbfField fromStringRepresentation(String s) { | ||
String[] a = s.split(","); | ||
|
||
DbfField f = new DbfField(); | ||
f.setName(a[0]); | ||
f.setType(DbfFieldTypeEnum.fromChar(a[1].charAt(0))); | ||
f.setLength(Integer.parseInt(a[2])); | ||
f.setNumberOfDecimalPlaces(Integer.parseInt(a[3])); | ||
return f; | ||
} | ||
|
||
/* | ||
public DbfField(byte[] fieldBytes) { | ||
if (fieldBytes.length < FIELD_RECORD_LENGTH) { | ||
throw new IllegalArgumentException("fieldBytes length is less than " + FIELD_RECORD_LENGTH); | ||
} else { | ||
this.fieldBytes = new byte[FIELD_RECORD_LENGTH]; | ||
System.arraycopy(fieldBytes, 0, this.fieldBytes, 0, FIELD_RECORD_LENGTH); | ||
init(); | ||
} | ||
} | ||
//Look at | ||
//http://www.autopark.ru/ASBProgrammerGuide/DBFSTRUC.HTM | ||
@SuppressWarnings("deprecation") | ||
private void init() { | ||
int i = 0; | ||
for (i=0; i<11 && fieldBytes[i]>0; i++); | ||
this.name = new String(fieldBytes, 0, i); | ||
this.type = DbfFieldTypeEnum.fromChar((char)fieldBytes[11]); | ||
this.length = fieldBytes[16]; | ||
if (this.length < 0) { | ||
this.length = 256+this.length; | ||
} | ||
this.numberOfDecimalPlaces = fieldBytes[17]; | ||
} | ||
@Override | ||
public String toString() { | ||
return "DbfField [\n name=" + name + ", \n type=" + type | ||
+ ", \n length=" + length | ||
+ ", \n numberOfDecimalPlaces=" + numberOfDecimalPlaces | ||
+ "\n]"; | ||
} | ||
public byte[] getFieldBytes() { | ||
return fieldBytes; | ||
} | ||
public String getName() { | ||
return name; | ||
} | ||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
public void setType(DbfFieldTypeEnum type) { | ||
this.type = type; | ||
} | ||
public void setLength(int length) { | ||
this.length = length; | ||
} | ||
public DbfFieldTypeEnum getType() { | ||
return type; | ||
} | ||
public int getLength() { | ||
return length; | ||
} | ||
public int getNumberOfDecimalPlaces() { | ||
return numberOfDecimalPlaces; | ||
} | ||
public void setNumberOfDecimalPlaces(int numberOfDecimalPlaces) { | ||
this.numberOfDecimalPlaces = numberOfDecimalPlaces; | ||
} | ||
public String toStringRep() { | ||
StringBuilder sb = new StringBuilder(); | ||
sb.append(name).append(","); | ||
sb.append(type.getType()).append(","); | ||
sb.append(length).append(","); | ||
sb.append(numberOfDecimalPlaces); | ||
return sb.toString(); | ||
} | ||
public static DbfField fromStringRep(String s) { | ||
String[] a = s.split(","); | ||
DbfField f = new DbfField(); | ||
f.setName(a[0]); | ||
f.setType(DbfFieldTypeEnum.fromChar(a[1].charAt(0))); | ||
f.setLength(Integer.parseInt(a[2])); | ||
f.setNumberOfDecimalPlaces(Integer.parseInt(a[3])); | ||
return f; | ||
} | ||
*/ | ||
} | ||
package net.iryndin.jdbf.core; | ||
|
||
|
||
public class DbfField { | ||
|
||
private String name; | ||
private DbfFieldTypeEnum type; | ||
private int length; | ||
private int numberOfDecimalPlaces; | ||
private int offset; | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
public DbfFieldTypeEnum getType() { | ||
return type; | ||
} | ||
public void setType(DbfFieldTypeEnum type) { | ||
this.type = type; | ||
} | ||
public int getLength() { | ||
return length; | ||
} | ||
public void setLength(int length) { | ||
this.length = length; | ||
} | ||
public int getNumberOfDecimalPlaces() { | ||
return numberOfDecimalPlaces; | ||
} | ||
public void setNumberOfDecimalPlaces(int numberOfDecimalPlaces) { | ||
this.numberOfDecimalPlaces = numberOfDecimalPlaces; | ||
} | ||
public int getOffset() { | ||
return offset; | ||
} | ||
public void setOffset(int offset) { | ||
this.offset = offset; | ||
} | ||
@Override | ||
public String toString() { | ||
return "DbfField [\n name=" + name + ", \n type=" + type | ||
+ ", \n length=" + length + ", \n numberOfDecimalPlaces=" | ||
+ numberOfDecimalPlaces + ", \n offset=" + offset + "\n]"; | ||
} | ||
|
||
public String getStringRepresentation() { | ||
StringBuilder sb = new StringBuilder(); | ||
sb.append(name).append(","); | ||
sb.append(type.getType()).append(","); | ||
sb.append(length).append(","); | ||
sb.append(numberOfDecimalPlaces); | ||
return sb.toString(); | ||
} | ||
|
||
public static DbfField fromStringRepresentation(String s) { | ||
String[] a = s.split(","); | ||
|
||
DbfField f = new DbfField(); | ||
f.setName(a[0]); | ||
f.setType(DbfFieldTypeEnum.fromChar(a[1].charAt(0))); | ||
f.setLength(Integer.parseInt(a[2])); | ||
f.setNumberOfDecimalPlaces(Integer.parseInt(a[3])); | ||
return f; | ||
} | ||
|
||
/* | ||
public DbfField(byte[] fieldBytes) { | ||
if (fieldBytes.length < FIELD_RECORD_LENGTH) { | ||
throw new IllegalArgumentException("fieldBytes length is less than " + FIELD_RECORD_LENGTH); | ||
} else { | ||
this.fieldBytes = new byte[FIELD_RECORD_LENGTH]; | ||
System.arraycopy(fieldBytes, 0, this.fieldBytes, 0, FIELD_RECORD_LENGTH); | ||
init(); | ||
} | ||
} | ||
//Look at | ||
//http://www.autopark.ru/ASBProgrammerGuide/DBFSTRUC.HTM | ||
@SuppressWarnings("deprecation") | ||
private void init() { | ||
int i = 0; | ||
for (i=0; i<11 && fieldBytes[i]>0; i++); | ||
this.name = new String(fieldBytes, 0, i); | ||
this.type = DbfFieldTypeEnum.fromChar((char)fieldBytes[11]); | ||
this.length = fieldBytes[16]; | ||
if (this.length < 0) { | ||
this.length = 256+this.length; | ||
} | ||
this.numberOfDecimalPlaces = fieldBytes[17]; | ||
} | ||
@Override | ||
public String toString() { | ||
return "DbfField [\n name=" + name + ", \n type=" + type | ||
+ ", \n length=" + length | ||
+ ", \n numberOfDecimalPlaces=" + numberOfDecimalPlaces | ||
+ "\n]"; | ||
} | ||
public byte[] getFieldBytes() { | ||
return fieldBytes; | ||
} | ||
public String getName() { | ||
return name; | ||
} | ||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
public void setType(DbfFieldTypeEnum type) { | ||
this.type = type; | ||
} | ||
public void setLength(int length) { | ||
this.length = length; | ||
} | ||
public DbfFieldTypeEnum getType() { | ||
return type; | ||
} | ||
public int getLength() { | ||
return length; | ||
} | ||
public int getNumberOfDecimalPlaces() { | ||
return numberOfDecimalPlaces; | ||
} | ||
public void setNumberOfDecimalPlaces(int numberOfDecimalPlaces) { | ||
this.numberOfDecimalPlaces = numberOfDecimalPlaces; | ||
} | ||
public String toStringRep() { | ||
StringBuilder sb = new StringBuilder(); | ||
sb.append(name).append(","); | ||
sb.append(type.getType()).append(","); | ||
sb.append(length).append(","); | ||
sb.append(numberOfDecimalPlaces); | ||
return sb.toString(); | ||
} | ||
public static DbfField fromStringRep(String s) { | ||
String[] a = s.split(","); | ||
DbfField f = new DbfField(); | ||
f.setName(a[0]); | ||
f.setType(DbfFieldTypeEnum.fromChar(a[1].charAt(0))); | ||
f.setLength(Integer.parseInt(a[2])); | ||
f.setNumberOfDecimalPlaces(Integer.parseInt(a[3])); | ||
return f; | ||
} | ||
*/ | ||
} |
Oops, something went wrong.