Update of 
/cvsroot/xdoclet-plugins/xdoclet-plugins/plugin-weblogic/src/main/java/org/xdoclet/plugin/weblogic
In directory 
sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv12277/plugin-weblogic/src/main/java/org/xdoclet/plugin/weblogic

Added Files:
        WebLogicVersion.java 
Log Message:
Initial Revision

--- NEW FILE: WebLogicVersion.java ---
package org.xdoclet.plugin.weblogic;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Ive Hellemans
 * @version $Revision$
 */
public class WebLogicVersion {
    public static final String WEBLOGIC_9_1_EJB = "9.1 EJB";
    public static final String WEBLOGIC_9_1_CMP_RDMBS = "9.1 CMP RDBMS";

    private static Map versionMap = new HashMap();
    private String publicId;
    private String systemId;
    private String ns;
    private String xsdLocation;
    private boolean isDtd;
    private String xsiNs;
    private double version;

    static {
        versionMap.put(WEBLOGIC_9_1_EJB,
            new WebLogicVersion(9.1, "http://www.bea.com/ns/weblogic/90";, 
                "http://www.w3.org/2001/XMLSchema-instance"; ,
                "http://www.bea.com/ns/weblogic/90/weblogic-ejb-jar.xsd";));
        versionMap.put(WEBLOGIC_9_1_CMP_RDMBS,
                new WebLogicVersion(9.1, "http://www.bea.com/ns/weblogic/90";, 
                    "http://www.w3.org/2001/XMLSchema-instance"; ,
                    
"http://www.bea.com/ns/weblogic/90/weblogic-rdbms20-persistence.xsd";));
    }

    /**
     * Usable for DTDs.
     * 
     * Not used for now, usable for DTDs when older versions are added.
     *
    private WebLogicVersion(double version, String publicId, String systemId) {
        this.version = version;
        this.publicId = publicId;
        this.systemId = systemId;
        this.isDtd = true;
    } */

    /**
     * Usable for XSDs.
     */
    private WebLogicVersion(double version, String ns, String xsiNs, String 
xsdLocation) {
        this.version = version;
        this.ns = ns;
        this.xsiNs = xsiNs;
        this.xsdLocation = xsdLocation;
        this.isDtd = false;
    }

    public static WebLogicVersion get(String version) {
        return (WebLogicVersion) versionMap.get(version);
    }

    public boolean greaterOrEquals(String ver) {
        return greaterOrEquals(Double.parseDouble(ver));
    }

    public boolean greaterOrEquals(double ver) {
        return ver <= getVersion();
    }

    public boolean equals(String ver) {
        return equals(Double.parseDouble(ver));
    }

    public boolean equals(double ver) {
        return ver == getVersion();
    }

    /**
     * Utility method to get the online reference for DTD/XSD
     */
    private static String getLocationUrl(String version) {
        WebLogicVersion ejbVer = get(version);

        if (ejbVer == null) {
            throw new IllegalStateException();
        }

        return ejbVer.isDtd() ? ejbVer.getSystemId() : ejbVer.getXsdLocation();
    }

    public String getPublicId() {
        return this.publicId;
    }

    public String getSchemaLocation() {
        if (this.ns == null || this.xsdLocation == null) {
            return null;
        }

        return this.ns + " " + this.xsdLocation;
    }

    public String getSystemId() {
        return this.systemId;
    }

    public String getNs() {
        return this.ns;
    }

    public String getXsdLocation() {
        return this.xsdLocation;
    }

    public boolean isDtd() {
        return this.isDtd;
    }

    public String getXsiNs() {
        return this.xsiNs;
    }
    
    public String getJ2eeNs() {
        return "http://java.sun.com/xml/ns/j2ee";;
    }

    public double getVersion() {
        return this.version;
    }

    public static Map fillEntityResolverMap(Map dtds) {
        Class clz = WebLogicVersion.class;

        dtds.put(getLocationUrl(WEBLOGIC_9_1_EJB), 
                clz.getResource("xsd/weblogic-ejb-jar-91.xsd"));
        
        dtds.put(getLocationUrl(WEBLOGIC_9_1_CMP_RDMBS), 
                clz.getResource("xsd/weblogic-rdbms20-persistence.xsd"));

        // Referenced by http://www.bea.com/ns/weblogic/90
        dtds.put("http://www.bea.com/ns/weblogic/90/weblogic-j2ee.xsd";, 
                clz.getResource("xsd/weblogic-j2ee.xsd"));

        dtds.put("http://java.sun.com/xml/ns/j2ee/j2ee_1_4.xsd";, 
                clz.getResource("xsd/j2ee_1_4.xsd"));
        
        dtds.put("http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd";, 
                clz.getResource("xsd/ejb-jar_2_1.xsd"));

        // Referenced by http://java.sun.com/xml/ns/j2ee/j2ee_1_4.xsd
        dtds.put("http://www.w3.org/2001/xml.xsd";, 
                clz.getResource("xsd/xml.xsd"));

        // Referenced by http://www.w3.org/2001/xml.xsd
        dtds.put("http://www.w3.org/2001/XMLSchema.dtd";, 
                clz.getResource("xsd/XMLSchema.dtd"));

        // Referenced by http://www.w3.org/2001/XMLSchema.dtd
        dtds.put("http://www.w3.org/2001/datatypes.dtd";, 
                clz.getResource("xsd/datatypes.dtd"));

        // Referenced by http://java.sun.com/xml/ns/j2ee/j2ee_1_4.xsd
        
dtds.put("http://www.ibm.com/webservices/xsd/j2ee_web_services_client_1_1.xsd";,
            clz.getResource("xsd/j2ee_web_services_client_1_1.xsd"));

        return dtds;
    }
}


_______________________________________________
xdoclet-plugins-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xdoclet-plugins-commits

Reply via email to