Skip to content

Instantly share code, notes, and snippets.

@jamalsa
Last active December 17, 2015 20:29
Show Gist options
  • Save jamalsa/5668404 to your computer and use it in GitHub Desktop.
Save jamalsa/5668404 to your computer and use it in GitHub Desktop.
Contoh sintaks sederhana parsing rule common message baru. Fitur yang sudah ada baru parse object ke string sederhana.
@Entity(fieldOrder={"switcherId", "idpel"})
class TestObject
{
@Element(length=7)
public String switcherId;
@Element(length=15, padding=AdditionalFieldPadLocation.LEFT, paddingChar='0')
protected String idpel;
public String getIdpel() {
return idpel;
}
public void setIdpel(String idpel) {
this.idpel = idpel;
}
}
// Contoh Inheritance
@Entity(fieldOrder={"switcherId", "kodeArea", "idpel"})
class TestObject2 extends TestObject1
{
@Element(length=7)
public String kodeArea;
}
ObjectParser tParser = new ObjectParser();
TestObject tObject = new TestObject();
tObject.switcherId = "VI105V3";
tObject.setIdpel("5300000001");
System.out.println("Parsed object:" + tParser.parseObject(tObject)); // Menampilkan "VI105V3 5300000001"
@jamalsa
Copy link
Author

jamalsa commented May 29, 2013

Tipe class property yang sudah disupport:

  • Tipe dasar: String, Integer, Long, Float, Double, Boolean, Character
  • Tipe number: BigInteger, BigDecimal

Mensupport public property dan private/protected property (dengan setter dan getter).

To Do:

  • String to Object
  • Support Date
  • RepeatElement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment