Tuesday, January 7, 2014

Data Structures

RPG has the ability to define data structures.  These definitions often involve defining overlapping fields and or redefining data types of those fields.   Java basic data types has no exact equivalence, but instead this type of behavior can be handled using a class definition which uses properties and methods to handle the overlap and type redefinition.


Example of a RPG DS.


Such might be handled in Java as follows.


public class datastruct1 {

   private StringBuffer XSGDTA = new StringBuffer();
   
 public String getXSGDTA() {
  return XSGDTA.toString();
 }
 public void setXSGDTA(String xSGDTA) {
  XSGDTA.insert(0,xSGDTA);
 }
 public String getMSGDT1() {
  return XSGDTA.substring(0, 2);
 }
 public void setMSGDT1(String mSGDT1) {
  XSGDTA.insert(0, mSGDT1);
 }
 public String getMSGDT2() {
  return XSGDTA.substring(2, 4);
 }
 public void setMSGDT2(String mSGDT2) {
  XSGDTA.insert(2, mSGDT2);
 }

No comments:

Post a Comment