⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ibmpk4j.java

📁 使用方法: 实例程序的运行: 每个实例下都有本实例的.xml文件或.html文件或.xsl文件
💻 JAVA
字号:
/*
    Copyright (c) 1999 Bruce Martin, a contributor to the Xbean project.
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to
    deal in the Software without restriction, including without limitation the
    rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
    sell copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:

        The above copyright notice and this permission notice shall be included
        in all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    DEALINGS IN THE SOFTWARE.
*/

package org.xbeans.adapters;

import org.xbeans.*;

// This class adapts a ibmpk4j bean to work with xbeans.  To
// use it, simply call setDelegate() passing the ibmpk4j bean to it.
// Then use the adapter as if it were the ibmpk4j bean.

// This class handles three cases.
//      The ibmpk4j bean is a DOMSource and a DOMListener.
//      The ibmpk4j bean is just a DOMListener.
//      The ibmpk4j bean is just a DOMSource.

// The setDelegate method figures out which case applies.
// When the ibmpk4j bean is a DOMSource, the setDelegate() method registers
// the adapter as a listener.
// When the ibmpk4j bean is a DOMListener, the documentReady() method calls the
// documentReady() method on the ibmpk4j.


public class ibmpk4j implements DOMListener,
                                com.ibm.xml.xpk4j.dom.DOMListener,
                                DOMSource {

        // the next on the chain
    private DOMListener DOMListener;
        // may be called to do the actual processing
    private com.ibm.xml.xpk4j.dom.DOMListener delegate;
	private boolean delegateCalled=false;
    private com.ibm.xml.xpk4j.dom.DOMEvent resultEvent=null;

    // wrapper method to set delegate
    public void setDelegate(Object delegate) {
        // System.err.println("Set delegate for "+this+" to be "+delegate);
        if (delegate instanceof com.ibm.xml.xpk4j.dom.DOMListener) {
            this.delegate=(com.ibm.xml.xpk4j.dom.DOMListener)delegate;
        }
        if (delegate instanceof com.ibm.xml.xpk4j.dom.DOMSource) {
            ((com.ibm.xml.xpk4j.dom.DOMSource)delegate).setDOMListener(this);
        }
    }

    public Object getDelegate() {
        return delegate;
    }

    // DomSource methods

    /** Sets the target listener for the DOM events. */
    public void setDOMListener(DOMListener newDomListener) {
        //System.err.println("Setting dom listener for "+this+" to be "+newDomListener);
        DOMListener = newDomListener;
    }

    /** Returns the target listener for the DOM events. */
    public DOMListener getDOMListener(){
        return DOMListener;
    }


    // Xbeans DomListener method
    public void documentReady(DOMEvent evt) throws XbeansException {
        //System.err.println("Xbeans("+this+") documentReady. DOMListener is "+DOMListener);
        if (delegate==null) {
            throw new XbeansException(
                        evt.getDocument().getNodeName(),
                        "ibmpk4j",
                        "IBM Productivity Kit For Java listener delegate not established",
                        "The component needs to be configured using its editor."
                        );
        }
        // delegate the processing to the ibmpk4j component
		delegateCalled=true;
        delegate.documentReady(
            new com.ibm.xml.xpk4j.dom.DOMEvent(evt.getSource(),evt.getDocument())
        );
        if ((resultEvent!=null) && (DOMListener!=null))
            DOMListener.documentReady(
                new DOMEvent(resultEvent.getSource(),resultEvent.getDocument())
            );
		delegateCalled=false;
    }


    // IBMxpk4j DomListener method
    public void documentReady(com.ibm.xml.xpk4j.dom.DOMEvent evt) {

        resultEvent = evt;
			// If there is not a next component, just return
        if (DOMListener==null) return;
            // If delegate is not under the control of this adapter,
            // i.e. it was called externally, translate the event and
            // pass it on to the next xbean
		if (!delegateCalled) {
        	try {
            	DOMListener.documentReady(
                	new DOMEvent(resultEvent.getSource(),resultEvent.getDocument())
            	);
        	} catch (Throwable e) {
            	e.printStackTrace(System.err);
        	}
		}
    }
}

⌨️ 快捷键说明

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