Pattern Language to Java Correspondence

This table shows how the entities of the Pattern Language should be translated into the corresponding Java packages and classes (beans) by the Pattern Language compiler.

Module example directory example under someprefix directory
directory event under someprefix/example directory
directory pattern under someprefix/example directory
directory impl under someprefix/example directory
package someprefix.example.pattern;
public interface ExamplePattern extends technion.pdl.PDLPattern {}
package someprefix.example.event;
public abstract class ExampleEvent extends technion.pdl.PDLEvent {
    public ExampleEvent(technion.pdl.PDLPattern source, technion.pdl.PDLEvent prevEvent) {
        super(source, prevEvent);
    }                                                                                        
}
package someprefix.example.event;
public interface ExampleEventListener extends technion.pdl.PDLEventListener {}
package someprefix.example.impl;
public abstract class ExampleImpl extends technion.pdl.PDLImpl {

    public ExampleImpl() throws technion.pdl.PDLException {
        super();
    }
}
Library Visual directory visual under someprefix/example directory
directory pattern under someprefix/example/visual directory
directory event under someprefix/example/visual directory
directory impl under someprefix/example/visual directory
package someprefix.example.visual;
interface VisualPattern extends someprefix.example.pattern.ExamplePattern {}
/**
*  Fired on table selection
*/
Event TableSelected {

    /** Selected table name */
    contains tableName : Name;
}
package someprefix.example.visual.event;

/**
*  Fired on table selection
*/

public class TableSelectedEvent extends someprefix.example.event.ExampleEvent {
   /** Selected table name */  
   protected java.lang.String _tableName;
   public TableSelectedEvent(technion.pdl.PDLPattern source, someprefix.example.event.ExampleEvent prevEvent,   java.lang.String _tableName) {
      super(source,prevEvent);
      this._tableName = _tableName;
   }
   /**

     * Returns the selected table name
    */
   public  java.lang.String getTableName() {
      return _tableName;
  }

}
package someprefix.example.visual.event;
public interface TableSelectedEventListener extends someprefix.example.event.ExampleEventListener {
   public void tableSelected(TableSelectedEvent e);
}
Request TableNamesHTML {
    in title : String;
    out html : HTML;
}
package someprefix.example.visual.event;
public class TableNamesHTMLRequest extends someprefix.example.event.ExampleEvent {
   protected java.lang.String _title;
   public TableNamesHTMLRequest(technion.pdl.PDLPattern source, someprefix.example.event.ExampleEvent prevEvent,   java.lang.String _title) {
      super(source,prevEvent);
      this._title = _title;
   }
   public  java.lang.String getTitle() {
      return _title;
  }

}
package someprefix.example.visual.event;
public interface TableNamesHTMLResponser extends someprefix.example.event.ExampleEventListener {
// returns String since out field (html) of TableNamesHTML Request is of the HTML (java.lang.String) type
   public java.lang.String responseTableNamesHTML(TableNamesHTMLRequest req);
}
Pattern Tables {
        fires TableSelected;
        listens Page;
        requests TableNames;
        responses TableNamesHTML;
    }
package someprefix.example.visual.pattern;
public interface Tables extends VisualPattern,
                                               someprefix.example.visual.event.PageListener,
                                               someprefix.example.visual.event.TableNamesHTMLResponser {
  // since it fires TableSelected:
  void addTableSelectedEventListener(someprefix.example.visual.event.TableSelectedEventListener listener);
  void removeTableSelectedEventListener(someprefix.example.visual.event.TableSelectedEventListener listener);
  void fireTableSelectedEvent(someprefix.example.visual.event.TableSelectedEvent ev);
  // since it requests TableNames // since it requests TableNames:
  void setTableNamesResponser(someprefix.example.event.TableNamesResponser responser);
  void removeTableNamesResponser(someprefix.example.event.TableNamesResponser responser);
  java.lang.String requestTableNames(someprefix.example.visual.event.TableNamesRequest req);
  // since it responses TableNamesHTML (_title identifier generated from in title of Request TableNamesHTML):
  java.lang.String responseTableNamesHTML(someprefix.example.visual.event.TableNamesHTMLRequest req);
}
Implementation TablesImpl
    implements Visual.Tables {
      display "Tables";
      description "This beanThis bean
                      represents the output
                     of Tables Pattern
                     of Tables Pattern
";
    property bgColor : Color {
      editor ColorEditor;
      display "Background color";
      description "Application page                           background color";

    }
}
package someprefix.example.visual.impl;
abstract public class TablesImpl extends someprefix.example.impl.ExampleImpl implements             
                                                                                                                       someprefix.example.visual.pattern.Tables {
private technion.pdl.PDLEventSource tableSelectedEventSource;
private technion.pdl.PDLEventSource tableNamesRequestSource;

public TablesImpl() throws technion.pdl.PDLException {
      super();

      tableSelectedEventSource = new technion.pdl.PDLEventSource(this,TableSelectedEventListener.class);
      tableNamesRequestSource = new technion.pdl.PDLEventSource(this,TableNamesResponser.class);
}
public void addTableSelectedEventListener(someprefix.example.visual.event.TableSelectedEventListener listener) {

  tableSelectedEventSource.addListener(listener);
}
public void removeTableSelectedEventListener(someprefix.example.visual.event.TableSelectedEventListener listener) {
  tableSelectedEventSource.removeListener(listener);
}
public void fireTableSelectedEvent(someprefix.example.visual.event.TableSelectedEvent ev) {
  tableSelectedEventSource.fireEvent(ev);
}
public void setTableNamesResponser(someprefix.example.event.TableNamesResponser responser)
                                                throws technion.pdl.PDLException {
  tableNamesRequestSource.setResponser(responser);
}
public void removeTableNamesResponser(someprefix.example.event.TableNamesResponser responser) {
  tableNamesRequestSource.removeResponser(responser);
}
public java.lang.String requestTableNames(someprefix.example.visual.event.TableNamesRequest req)
                                                throws technion.pdl.PDLException {
  return (java.lang.String)tableNamesRequestSource.request(req);
}
  // response to TableNamesHTML request.
  public abstract java.lang.String responseTableNamesHTML(someprefix.example.visual.event.TableNamesHTMLRequest req);
  // property bgColor
  protected  java.awt.Color _bgColor;
  public java.awt.Color getBgColor() { return _bgColor;}
  public void setBgColor(java.awt.Color _bgColor) { this._bgColor = _bgColor;}
}
package someprefix.example.visual.impl;
import java.beans.*;
import java.lang.reflect.*;

public class TablesImplBeanInfo extends SimpleBeanInfo {
   
    public BeanDescriptor getBeanDescriptor() {
        BeanDescriptor bd = new BeanDescriptor(TablesImplBeanInfo.class);
        bd.setDisplayName("Tables");
        bd.setShortDescription("This bean represents the output of Tables Pattern");
        return bd;
    }
   
   
    public PropertyDescriptor[] getPropertyDescriptors() {

        PropertyDescriptor result[] = new PropertyDescriptor[1];

        try {
            result[0] =
                    new PropertyDescriptor("bgColor",TablesImpl.class,"getBgColor","setBgColor");
            result[0].setDisplayName("Background color");
            result[0].setShortDescription("Application Page background color");

            result[0].setProperyEditor(somepackage.ColorEditor.class);
        }
        catch (IntrospectionException e) {
            throw new Error("Property construction problem " + e);
        }
        return result;
    }
   
   
    public EventSetDescriptor[] getEventSetDescriptors() {
        EventSetDescriptor result[] = new EventSetDescriptor[2];
       
        { // TableSelected event
           
            Class[] aListenerMethod = { someprefix.example.visual.event.TableSelectedEvent.class };
            Class[] aAddListenerMethod = { someprefix.example.visual.event.TableSelectedEventListener.class };
            Class[] aRemoveListenerMethod = { someprefix.example.visual.event.TableSelectedEventListener.class };
           
            Method mListenerMethod;
            Method mAddListenerMethod, mRemoveListenerMethod;
           
            try {
                mListenerMethod = someprefix.example.visual.event.TableSelectedEventListener.class.getMethod("tableSelected", aListenerMethod);
                mAddListenerMethod = TablesImpl.class.getMethod("addTableSelectedEventListener",aAddListenerMethod);
                mRemoveListenerMethod = TablesImpl.class.getMethod("removeTableSelectedEventListener",aRemoveListenerMethod);
            } catch (Exception ex) {
                // "should never happen"
                throw new Error("Missing method " + ex);
            }
           
            Method[] mListenerMethods = { mListenerMethod };
           
           
            try {
                result[0] =
                        new EventSetDescriptor( mListenerMethod.getName()+" method call", // event set name
                                                someprefix.example.visual.event.TableSelectedEventListener.class, // listener class
                                                mListenerMethods, // listener method names
                                                mAddListenerMethod,         // add listener method
                                                mRemoveListenerMethod);     // remove listener method
            }
            catch (IntrospectionException e) {
                throw new Error("Property construction problem " + e);
            }
        }
       
        { // TableNames request
           
            Class[] aListenerMethod = { someprefix.example.event.TableNamesRequest.class };
            Class[] aAddListenerMethod = { someprefix.example.event.TableNamesResponser.class };
            Class[] aRemoveListenerMethod = { someprefix.example.event.TableNamesResponser.class };
           
            Method mListenerMethod;
            Method mAddListenerMethod, mRemoveListenerMethod;
           
            try {
                mListenerMethod = someprefix.example.event.TableNamesResponser.class.getMethod("responseTableNames", aListenerMethod);
                mAddListenerMethod = TablesImpl.class.getMethod("setTableNamesResponser",aAddListenerMethod);
                mRemoveListenerMethod = TablesImpl.class.getMethod("removeTableNamesResponser",aRemoveListenerMethod);
            } catch (Exception ex) {
                // "should never happen"
                throw new Error("Missing method " + ex);
            }
           
            Method[] mListenerMethods = { mListenerMethod };
           
           
            try {
                result[1] =
                        new EventSetDescriptor( mListenerMethod.getName()+" method call", // event set name
                                                someprefix.example.event.TableNamesResponser.class, // listener class
                                                mListenerMethods, // listener method names
                                                mAddListenerMethod,         // add listener method
                                                mRemoveListenerMethod);     // remove listener method
            }
            catch (IntrospectionException e) {
                throw new Error("Property construction problem " + e);
            }
        }
       
       
        return result;
    }
   
}

The Resulting Hierarchy

  • someprefix/example
    • pattern
      • ExamplePattern.java
    • event
      • ExampleEvent.java
      • ExampleEventListener.java
      • InitPageEvent.java
      • InitPageEventListener.java
      • ...
    • impl
      • ExampleImpl.java
    • visual
      • pattern
        • VisualPattern.java
        • Tables.java
      • event
        • TableSelectedEvent.java
        • TableSelectedEventListener.java
        • TableNamesHTMLRequest.java
        • TableNamesHTMLResponser.java
      • impl
        • TablesImpl.java
        • TablesImplBeanInfo.java

The Makefile generated (located exactly above someprefix directory)


COMPILER = <javac location>
JAVADOC = <javadoc location>
JAR = <jar location>

CLASSPATH = .;<Classpath dir>;<PDL jar file location>

JAVADOCDIR = <API directory>

DOC_PACKAGES = someprefix.example.pattern \
someprefix.example.event \
someprefix.example.impl \
someprefix.example.visual.pattern \
someprefix.example.visual.event \
someprefix.example.visual.impl

default: all

doc:     all
    $(JAVADOC) -classpath . -d $(JAVADOCDIR) -version -author $(DOC_PACKAGES)
   
DIR=someprefix\example

CLASSFILES= \
    $(DIR)\pattern\ExamplePattern.class \
    $(DIR)\event\ExampleEvent.class \
    $(DIR)\event\ExampleEventListener.class \

    $(DIR)\event\InitPageEvent.class \
    $(DIR)\event\InitPageEventListener.class \
    ...
    $(DIR)\impl\ExampleImpl.class \
    $(DIR)\visual\pattern\VisualPattern.class \
    $(DIR)\visual\pattern\Tables.class \
    $(DIR)\visual\event\TableSelectedEvent.class \
    $(DIR)\visual\event\TableSelectedEventListener.class \
    $(DIR)\visual\event\TableNamesHTMLRequest.class \
    $(DIR)\visual\event\TableNamesHTMLResponser.class \
    $(DIR)\visual\impl\TablesImpl.class \
    $(DIR)\visual\impl\TablesImplBeanInfo.class

   
all: $(CLASSFILES)

.SUFFIXES: .java .class

.java.class :
    $(COMPILER) -classpath $(CLASSPATH) $<

clean:
    -del $(CLASSFILES)