Skip to content

raycw/edidom

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

Introduction

Inspired by JDOM, edidom is both Java-centric and Java-optimized. It behaves like Java, it uses Java collections, it is completely natural API for current Java developers, and it provides a low-cost entry point for using EDI.

How to build

You need to install MAVEN, edidom is using maven to manage project build. If you using eclipse, I highly recommend you to install m2e.

mvn package

Data Structure

  +-------------------------------------------------------------------+
  |  InterchangeEnvelope (1)                                          |
  |-------------------------------------------------------------------|
  |                                                                   |
  |  +------------------------------------------------------------+   |
  |  |  GroupEnvelope (0..*)                                      |   |
  |  |------------------------------------------------------------|   |
  |  |                                                            |   |
  |  |  +-----------------------------------------------------+   |   |
  |  |  |  Transaction (1..*)                                 |   |   |
  |  |  |-----------------------------------------------------|   |   |
  |  |  | +-------------------------------------------------+ |   |   |
  |  |  | | Segment (1..*)                                  | |   |   |
  |  |  | +-------------------------------------------------+ |   |   |
  |  |  | ...                                                 |   |   |
  |  |  | ...                                                 |   |   |
  |  |  | ..                                                  |   |   |
  |  |  | ..                                                  |   |   |
  |  |  | .                                                   |   |   |
  |  |  | +-------------------------------------------------+ |   |   |
  |  |  | | Segment                                         | |   |   |
  |  |  | +-------------------------------------------------+ |   |   |
  |  |  +-----------------------------------------------------+   |   |
  |  +------------------------------------------------------------+   |
  +-------------------------------------------------------------------+

Getting Started

Read EDI

Create a Builder first. For X12, use com.github.raycw.edidom.input.X12Builder, for EDIFACT, use com.github.raycw.edidom.input.EdifactBuilder

File ediFile = new File(path);
Builder builder = new EdifactBuilder();
Document doc = builder.buildDocument(ediFile);

Modify Content

Get all Segment "N9" and change the value of field number 2

List<Segment> segments = doc.getSegments("N9);
for (Segment seg : segments) {
  seg.getField(2).setValue("AA")
}

Write EDI

Create cooresponding outputter and output as a string

X12Outputter outputter = new X12Outputter();
String ediOutput = outputter.outputString(doc);

That is!! Good luck!!

License

Apache License, Version 2

http://www.apache.org/licenses/LICENSE-2.0