jtbridge.java

来自「Java Pattern Oriented Framework (Jt) 是为了」· Java 代码 · 共 106 行

JAVA
106
字号


package Jt;


/**
 * Jt Implementation of the Bridge pattern.
 */

public class JtBridge extends JtObject {

    public static final String JtCLASS_NAME = JtBridge.class.getName(); 
    private static final long serialVersionUID = 1L;
    private Object implementor;

    public JtBridge () {
    }

    /**
     * Specifies the implementor.
     *
     * @param implementor implementor
     */

    public void setImplementor (Object implementor) {
        this.implementor = implementor; 

    }

    /**
     * Returns the implementor.
     */

    public Object getImplementor () {
        return (implementor);
    }



    /**
     * Process object messages.
     * <ul>
     * </ul>
     */

    public Object processMessage (Object event) {

        String msgid = null;
        JtMessage e = (JtMessage) event;
        //Object content;
        //Object data;


        if (e == null)
            return null;

        msgid = (String) e.getMsgId ();

        if (msgid == null)
            return null;


        // Destroy this object
        //if (msgid.equals (JtObject.JtREMOVE)) {
        //    return (null);     
        //}

        if (implementor == null) {
            handleError ("JtBridge.process: the implementor attribute needs to be set");
            return (null);
        }

        // Let the implementor process the request

        return (sendMessage (implementor, event));

    }


    /**
     * Demonstrates the messages processed by JtBridge.
     */


    public static void main(String[] args) {

        JtFactory factory = new JtFactory ();
        JtBridge bridge;


        // Create an instance of JtBridge

        bridge = (JtBridge) factory.createObject (JtBridge.JtCLASS_NAME, "bridge");

        // Remove the object 

        factory.removeObject (bridge);


    }


}


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?