Defining Java domains for z/OS rule projects

You define the domains in a Java™ project, which you want to use in your z/OS® rule project (a COBOL project or PL/I project).

About this task

You create a Java project and then define all the domain classes that you want to use in your z/OS rule project.

Procedure

  1. Click Window > Open perspective > Other > Java (default) and click OK to open the Java perspective.
  2. Create a Java project:
    1. On the File menu, click New > Java project.
    2. On the Create a Java Project page, type a name for the domain project and then click Finish.
  3. Right-click the src folder in the new project and then click New > Package.
  4. On the New Java Package page, type a name for the package and then click Finish.
  5. Right-click the new package and then click New > Class.
  6. On the New Java Class page, type a name for the domain class and then click Finish.

    Start the name with an uppercase letter so that it conforms to the conventions of class names.

  7. In the Java Class Editor, define the domain class by using either a constructor or a factory method.

    You can create a domain object for data conversion from z/OS data (COBOL data or PL/I data) to Java by using a constructor or a factory method. The following sample code defines a domain class named Country, by using a constructor:

    public class Country {
      
    	  private String value; 
    
    	  public Country(String country) {
    	  	this.value = country;
    	  } 
    	  public String getValue(){return value;}
    }
    

    The following sample code defines a domain class named Color, by using a factory method.

    public class Color {
    
        private int value;
        private Color(int color) {this.value = color;}
    
        public static Color createColor(int color){
        	return new Color(color);
        }
        public int getValue(){return value;}
    }

    The getValue method gets the domain value for data conversion from Java to z/OS data.

    Important:

    The signature for the constructor, factory method, and the getValue must match the Java type for the z/OS data item. For example, in the first sample code, the default Java type for the z/OS data item country PIC X(2) is String, so the constructor and method signature of the Country domain class must also be String.

  8. Save your work.

Results

When you defined all the domains that you want, you can create your rule project and reference the domains project from it.