Skip to content

fixed-width-file/java-fwf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

java-fwf

License Java FWF Compliance QA Coverage Docs pre-commit

java-fwf is a fast, type-safe Java 17+ library for parsing, validating, hydrating, and exporting Fixed Width Files (FWF).

It is part of the Fixed Width File Ecosystem and fully implements the fwf-compliance-tests v1.0.0 specification.


🌟 Key Features

  • Type-Safe Columns: CharColumn, RightCharColumn, PositiveIntegerColumn, PositiveDecimalColumn, DateColumn, TimeColumn, and DateTimeColumn.
  • Flexible Descriptors: Structured records with HeaderRowDescriptor, DetailRowDescriptor, and FooterRowDescriptor.
  • Cross-Language Hydration: Dehydrate/Hydrate descriptors to/from JSON representations compatible with Python pyfwf and PHP php-fwf.
  • Multiple Output Renders: Export layout specifications to Markdown, ReStructuredText (RST), or HTML tables via RenderUtils.
  • Full Test Suite & Coverage: Verified line (>95%) and branch (>85%) coverage via JaCoCo and JUnit 5.
  • Git Hooks Ready: Pre-configured pre-commit and pre-push hooks.

🚀 Installation

Maven

Add the dependency to your pom.xml:

<dependency>
    <groupId>io.github.kelsoncm</groupId>
    <artifactId>fwf</artifactId>
    <version>1.0.0</version>
</dependency>

Gradle

implementation 'io.github.kelsoncm:fwf:1.0.0'

💡 Quickstart

import io.github.kelsoncm.fwf.columns.*;
import io.github.kelsoncm.fwf.descriptors.*;
import io.github.kelsoncm.fwf.readers.Reader;

import java.util.List;
import java.util.Map;

public class Quickstart {
    public static void main(String[] args) {
        // 1. Define columns
        CharColumn nameCol = new CharColumn("name", 20, "User Name");
        PositiveIntegerColumn ageCol = new PositiveIntegerColumn("age", 3, "Age in years");

        // 2. Define row and file descriptors
        DetailRowDescriptor detail = new DetailRowDescriptor(List.of(nameCol, ageCol));
        FileDescriptor fileDescriptor = new FileDescriptor(List.of(detail));

        // 3. Read fixed-width file content
        String content = "KELSON MEDEIROS     045\nMARIA SILVA         030\n";
        Reader reader = new Reader(content, fileDescriptor, "\n");

        for (Map<String, Object> row : reader) {
            System.out.println("Name: " + row.get("name") + " | Age: " + row.get("age"));
        }
    }
}

📖 Javadoc & GitHub Pages

Generated Javadoc is published to GitHub Pages:


🧪 Testing & Coverage

Run unit tests and JaCoCo coverage check:

mvn clean test

⚓ Pre-Commit & Pre-Push Setup

Set up pre-commit and pre-push hooks:

pre-commit install
pre-commit install --hook-type pre-push

Run checks manually:

pre-commit run --all-files

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

About

High-performance, type-safe Java library for parsing, validating, hydrating, and exporting Fixed Width Files (FWF).

Topics

Resources

License

Stars

0 stars

Watchers

1 watching

Forks

Packages

 
 
 

Contributors

Languages