alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Other links

The source code

/*
 * WebAppProxi.java
 *
 * Created on Streda, 2003, november 12, 12:58
 */

package org.netbeans.modules.web.dd.impl;

import org.netbeans.api.web.dd.WebApp;

/**
 *
 * @author  mk115033
 */
public class WebAppProxy implements WebApp {
    private WebApp webApp;
    private String version;
    private java.util.List listeners;
    public boolean writing=false;
    private OutputProvider outputProvider;
    private org.xml.sax.SAXParseException error;
    private int ddStatus;
    
    /** Creates a new instance of WebAppProxy */  
    public WebAppProxy(WebApp webApp, String version) {
        this.webApp=webApp;
        this.version = version;
        listeners = new java.util.ArrayList();
    }
    
    public void setOriginal(WebApp webApp) {
        if (this.webApp!=webApp) {
            for (int i=0;i=lenNew;i--) {
                webApp.removeFilterMapping(oldMappings[i]);
            }
        }
        }
    }
    
    public void setFilterMapping(int index, org.netbeans.api.web.dd.FilterMapping value) {
        if (webApp!=null) webApp.setFilterMapping(index, value);
    }
    
    public void setIcon(org.netbeans.api.web.dd.Icon icon) {
        if (webApp!=null) webApp.setIcon(icon);
    }
    
    public void setId(java.lang.String value) {
        if (webApp!=null) webApp.setId(value);
    }
    
    public void setJspConfig(org.netbeans.api.web.dd.JspConfig value) throws org.netbeans.api.web.dd.common.VersionNotSupportedException {
        if (webApp!=null) webApp.setJspConfig(value);
    }
    
    public void setLargeIcon(String icon) {
        if (webApp!=null) webApp.setLargeIcon(icon);
    }
    
    public void setLargeIcon(String locale, String icon) throws org.netbeans.api.web.dd.common.VersionNotSupportedException {
        if (webApp!=null) webApp.setLargeIcon(locale, icon);
    }
    
    public void setListener(org.netbeans.api.web.dd.Listener[] value) {
        if (webApp!=null) {
        org.netbeans.api.web.dd.Listener[] oldListeners = getListener();
        int lenOld = oldListeners.length;
        int lenNew = (value==null?0:value.length);
        if (lenOld<=lenNew) {
            for (int i=0;i=lenNew;i--) {
                webApp.removeListener(oldListeners[i]);
            }
        }
        }
    }
    
    public void setListener(int index, org.netbeans.api.web.dd.Listener value) {
        if (webApp!=null) webApp.setListener(index, value);
    }
    
    public void setLocaleEncodingMappingList(org.netbeans.api.web.dd.LocaleEncodingMappingList value) throws org.netbeans.api.web.dd.common.VersionNotSupportedException {
        if (webApp!=null) webApp.setLocaleEncodingMappingList(value);
    }
    
    public void setLoginConfig(org.netbeans.api.web.dd.LoginConfig value) {
        if (webApp!=null) webApp.setLoginConfig(value);
    }
    
    public void setMessageDestination(org.netbeans.api.web.dd.MessageDestination[] value) throws org.netbeans.api.web.dd.common.VersionNotSupportedException {
        if (webApp!=null) webApp.setMessageDestination(value);
    }
    
    public void setMessageDestination(int index, org.netbeans.api.web.dd.MessageDestination value) throws org.netbeans.api.web.dd.common.VersionNotSupportedException {
        if (webApp!=null) webApp.setMessageDestination(index, value);
    }
    
    public void setMessageDestinationRef(org.netbeans.api.web.dd.MessageDestinationRef[] value) throws org.netbeans.api.web.dd.common.VersionNotSupportedException {
        if (webApp!=null) webApp.setMessageDestinationRef(value);
    }
    
    public void setMessageDestinationRef(int index, org.netbeans.api.web.dd.MessageDestinationRef value) throws org.netbeans.api.web.dd.common.VersionNotSupportedException {
        if (webApp!=null) webApp.setMessageDestinationRef(index, value);
    }
    
    public void setMimeMapping(org.netbeans.api.web.dd.MimeMapping[] value) {
        if (webApp!=null) webApp.setMimeMapping(value);
    }
    
    public void setMimeMapping(int index, org.netbeans.api.web.dd.MimeMapping value) {
        if (webApp!=null) webApp.setMimeMapping(index, value);
    }
    
    public void setResourceEnvRef(org.netbeans.api.web.dd.ResourceEnvRef[] value) {
        if (webApp!=null) webApp.setResourceEnvRef(value);
    }
    
    public void setResourceEnvRef(int index, org.netbeans.api.web.dd.ResourceEnvRef value) {
        if (webApp!=null) webApp.setResourceEnvRef(index, value);
    }
    
    public void setResourceRef(org.netbeans.api.web.dd.ResourceRef[] value) {
        if (webApp!=null) webApp.setResourceRef(value);
    }
    
    public void setResourceRef(int index, org.netbeans.api.web.dd.ResourceRef value) {
        if (webApp!=null) webApp.setResourceRef(index, value);
    }
    
    public void setSecurityConstraint(org.netbeans.api.web.dd.SecurityConstraint[] value) {
        if (webApp!=null) webApp.setSecurityConstraint(value);
    }
    
    public void setSecurityConstraint(int index, org.netbeans.api.web.dd.SecurityConstraint value) {
        if (webApp!=null) webApp.setSecurityConstraint(index, value);
    }
    
    public void setSecurityRole(org.netbeans.api.web.dd.SecurityRole[] value) {
        if (webApp!=null) webApp.setSecurityRole(value);
    }
    
    public void setSecurityRole(int index, org.netbeans.api.web.dd.SecurityRole value) {
        if (webApp!=null) webApp.setSecurityRole(index, value);
    }
    
    public void setServiceRef(org.netbeans.api.web.dd.ServiceRef[] value) throws org.netbeans.api.web.dd.common.VersionNotSupportedException {
        if (webApp!=null) webApp.setServiceRef(value);
    }
    
    public void setServiceRef(int index, org.netbeans.api.web.dd.ServiceRef value) throws org.netbeans.api.web.dd.common.VersionNotSupportedException {
        if (webApp!=null) webApp.setServiceRef(index, value);
    }
    
    public void setServlet(org.netbeans.api.web.dd.Servlet[] value) {
        if (webApp!=null) webApp.setServlet(value);
    }
    
    public void setServlet(int index, org.netbeans.api.web.dd.Servlet value) {
        if (webApp!=null) webApp.setServlet(index, value);
    }
    
    public void setServletMapping(org.netbeans.api.web.dd.ServletMapping[] value) {
        if (webApp!=null) webApp.setServletMapping(value);
    }
    
    public void setServletMapping(int index, org.netbeans.api.web.dd.ServletMapping value) {
        if (webApp!=null) webApp.setServletMapping(index, value);
    }
    
    public void setSessionConfig(org.netbeans.api.web.dd.SessionConfig value) {
        if (webApp!=null) webApp.setSessionConfig(value);
    }
    
    public void setSmallIcon(String icon) {
        if (webApp!=null) webApp.setSmallIcon(icon);
    }
    
    public void setSmallIcon(String locale, String icon) throws org.netbeans.api.web.dd.common.VersionNotSupportedException {
        if (webApp!=null) webApp.setSmallIcon(locale, icon);
    }
    
    public void setTaglib(org.netbeans.api.web.dd.Taglib[] value) throws org.netbeans.api.web.dd.common.VersionNotSupportedException {
        if (webApp!=null) webApp.setTaglib(value);
    }
    
    public void setTaglib(int index, org.netbeans.api.web.dd.Taglib value) throws org.netbeans.api.web.dd.common.VersionNotSupportedException {
        if (webApp!=null) webApp.setTaglib(index, value);
    }
    
    public void setWelcomeFileList(org.netbeans.api.web.dd.WelcomeFileList value) {
        if (webApp!=null) webApp.setWelcomeFileList(value);
    }
    
    public int sizeContextParam() {
        return webApp==null?0:webApp.sizeContextParam();
    }
    
    public int sizeEjbLocalRef() {
        return webApp==null?0:webApp.sizeEjbLocalRef();
    }
    
    public int sizeEjbRef() {
        return webApp==null?0:webApp.sizeEjbRef();
    }
    
    public int sizeEnvEntry() {
        return webApp==null?0:webApp.sizeEnvEntry();
    }
    
    public int sizeErrorPage() {
        return webApp==null?0:webApp.sizeErrorPage();
    }
    
    public int sizeFilter() {
        return webApp==null?0:webApp.sizeFilter();
    }
    
    public int sizeFilterMapping() {
        return webApp==null?0:webApp.sizeFilterMapping();
    }
    
    public int sizeListener() {
        return webApp==null?0:webApp.sizeListener();
    }
    
    public int sizeMessageDestination() throws org.netbeans.api.web.dd.common.VersionNotSupportedException {
        return webApp==null?0:webApp.sizeMessageDestination();
    }
    
    public int sizeMessageDestinationRef() throws org.netbeans.api.web.dd.common.VersionNotSupportedException {
        return webApp==null?0:webApp.sizeMessageDestinationRef();
    }
    
    public int sizeMimeMapping() {
        return webApp==null?0:webApp.sizeMimeMapping();
    }
    
    public int sizeResourceEnvRef() {
        return webApp==null?0:webApp.sizeResourceEnvRef();
    }
    
    public int sizeResourceRef() {
        return webApp==null?0:webApp.sizeResourceRef();
    }
    
    public int sizeSecurityConstraint() {
        return webApp==null?0:webApp.sizeSecurityConstraint();
    }
    
    public int sizeSecurityRole() {
        return webApp==null?0:webApp.sizeSecurityRole();
    }
    
    public int sizeServiceRef() throws org.netbeans.api.web.dd.common.VersionNotSupportedException {
        return webApp==null?0:webApp.sizeServiceRef();
    }
    
    public int sizeServlet() {
        return webApp==null?0:webApp.sizeServlet();
    }
    
    public int sizeServletMapping() {
        return webApp==null?0:webApp.sizeServletMapping();
    }
    
    public int sizeTaglib() throws org.netbeans.api.web.dd.common.VersionNotSupportedException {
        return webApp==null?0:webApp.sizeTaglib();
    }
    
    public void write(java.io.OutputStream os) throws java.io.IOException {
        if (webApp!=null) {
            writing=true;
            webApp.write(os);
        }
    }
    
    public void write(org.openide.filesystems.FileObject fo) throws java.io.IOException {
        if (webApp!=null) {
            try {
                org.openide.filesystems.FileLock lock = fo.lock();
                try {
                    java.io.OutputStream os = fo.getOutputStream(lock);
                    try {
                        writing=true;
                        write(os);
                    } finally {
                        os.close();
                    }
                } 
                finally {
                    lock.releaseLock();
                }
            } catch (org.openide.filesystems.FileAlreadyLockedException ex) {
                // trying to use OutputProvider for writing changes
                org.openide.loaders.DataObject dobj = org.openide.loaders.DataObject.find(fo);
                if (dobj!=null && dobj instanceof WebAppProxy.OutputProvider)
                    ((WebAppProxy.OutputProvider)dobj).write(this);
                else throw ex;
            }
        }
    }    
    
    public Object clone() {
        WebAppProxy proxy = null;
        if (webApp==null)
            proxy = new WebAppProxy(null,version);
        else {
            WebApp clonedWebApp=(WebApp)webApp.clone();
            proxy = new WebAppProxy(clonedWebApp,version);
            if (WebApp.VERSION_2_3.equals(version)) {
                ((org.netbeans.modules.schema2beans.BaseBean)clonedWebApp).changeDocType
                    ("-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN","http://java.sun.com/dtd/web-app_2_3.dtd");
            } else {
                ((org.netbeans.modules.web.dd.impl.model_2_4.WebApp)clonedWebApp)._setSchemaLocation
                    ("http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd");
            }
        }
        proxy.setError(error);
        proxy.setStatus(ddStatus);
        return proxy;
    }
    
    public boolean isWriting() {
        return writing;
    }
    
    public void setWriting(boolean writing) {
        this.writing=writing;
    }
    
    public void setOutputProvider(OutputProvider iop) {
        this.outputProvider=iop;
    }
    
    /** Contract between friend modules that enables 
    * a specific handling of write(FileObject) method for targeted FileObject
    */
    public static interface OutputProvider {
        public void write(WebApp webApp) throws java.io.IOException;
        public org.openide.filesystems.FileObject getTarget();
    }
    
}
... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.