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.
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
+-------------------------------------------------------------------+ | InterchangeEnvelope (1) | |-------------------------------------------------------------------| | | | +------------------------------------------------------------+ | | | GroupEnvelope (0..*) | | | |------------------------------------------------------------| | | | | | | | +-----------------------------------------------------+ | | | | | Transaction (1..*) | | | | | |-----------------------------------------------------| | | | | | +-------------------------------------------------+ | | | | | | | Segment (1..*) | | | | | | | +-------------------------------------------------+ | | | | | | ... | | | | | | ... | | | | | | .. | | | | | | .. | | | | | | . | | | | | | +-------------------------------------------------+ | | | | | | | Segment | | | | | | | +-------------------------------------------------+ | | | | | +-----------------------------------------------------+ | | | +------------------------------------------------------------+ | +-------------------------------------------------------------------+
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);
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")
}
Create cooresponding outputter and output as a string
X12Outputter outputter = new X12Outputter();
String ediOutput = outputter.outputString(doc);
That is!! Good luck!!
Apache License, Version 2