packageconfig.java

来自「在Struts2中的jar包xwork的源代码.版本为2.0.7」· Java 代码 · 共 512 行 · 第 1/2 页

JAVA
512
字号
    public String getFullDefaultActionRef() {        if ((defaultActionRef == null) && !parents.isEmpty()) {            for (Iterator<PackageConfig> iterator = parents.iterator(); iterator.hasNext();) {                PackageConfig parent = iterator.next();                String parentDefault = parent.getFullDefaultActionRef();                if (parentDefault != null) {                    return parentDefault;                }            }        }        return defaultActionRef;    }    /**     * Returns the default result type for this package.     * <p/>     * If there is no default result type, but this package has parents - we will try to     * look up the default result type of a parent.     */    public String getFullDefaultResultType() {        if ((defaultResultType == null) && !parents.isEmpty()) {            for (Iterator<PackageConfig> iterator = parents.iterator(); iterator.hasNext();) {                PackageConfig parent = iterator.next();                String parentDefault = parent.getFullDefaultResultType();                if (parentDefault != null) {                    return parentDefault;                }            }        }        return defaultResultType;    }    /**     * gets the global ResultConfigs local to this package     *     * @return a Map of ResultConfig objects keyed by result name     * @see ResultConfig     */    public Map<String, ResultConfig> getGlobalResultConfigs() {        return globalResultConfigs;    }    /**     * gets the InterceptorConfigs and InterceptorStackConfigs local to this package     *     * @return a Map of InterceptorConfig and InterceptorStackConfig objects keyed by ref-name     * @see InterceptorConfig     * @see InterceptorStackConfig     */    public Map getInterceptorConfigs() {        return interceptorConfigs;    }    public void setName(String name) {        this.name = name;    }    public String getName() {        return name;    }    public void setNamespace(String namespace) {        if (namespace == null) {            this.namespace = "";        } else {            this.namespace = namespace;        }    }    public String getNamespace() {        return namespace;    }    public List<PackageConfig> getParents() {        return new ArrayList<PackageConfig>(parents);    }    /**     * gets the ResultTypeConfigs local to this package     *     * @return a Map of ResultTypeConfig objects keyed by result name     * @see ResultTypeConfig     */    public Map<String, ResultTypeConfig> getResultTypeConfigs() {        return resultTypeConfigs;    }    /**     * gets the ExceptionMappingConfigs local to this package     *     * @return a Map of ExceptionMappingConfig objects keyed by result name     * @see ExceptionMappingConfig     */    public List<ExceptionMappingConfig> getGlobalExceptionMappingConfigs() {        return globalExceptionMappingConfigs;    }    public void addActionConfig(String name, ActionConfig action) {        actionConfigs.put(name, action);    }    public void addAllParents(List<PackageConfig> parents) {        for (PackageConfig config : parents) {            addParent(config);        }    }    public void addGlobalResultConfig(ResultConfig resultConfig) {        globalResultConfigs.put(resultConfig.getName(), resultConfig);    }    public void addGlobalResultConfigs(Map resultConfigs) {        globalResultConfigs.putAll(resultConfigs);    }    public void addExceptionMappingConfig(ExceptionMappingConfig exceptionMappingConfig) {        globalExceptionMappingConfigs.add(exceptionMappingConfig);    }    public void addGlobalExceptionMappingConfigs(List exceptionMappingConfigs) {        globalExceptionMappingConfigs.addAll(exceptionMappingConfigs);    }    public void addInterceptorConfig(InterceptorConfig config) {        interceptorConfigs.put(config.getName(), config);    }    public void addInterceptorStackConfig(InterceptorStackConfig config) {        interceptorConfigs.put(config.getName(), config);    }    public void addParent(PackageConfig parent) {        if (this.equals(parent)) {            LOG.error("A package cannot extend itself: " + name);        }        parents.add(0, parent);    }    public void addResultTypeConfig(ResultTypeConfig config) {        resultTypeConfigs.put(config.getName(), config);    }    public boolean isNeedsRefresh() {        return needsRefresh;    }    public void setNeedsRefresh(boolean needsRefresh) {        this.needsRefresh = needsRefresh;    }    public boolean equals(Object o) {        if (this == o) {            return true;        }        if (!(o instanceof PackageConfig)) {            return false;        }        final PackageConfig packageConfig = (PackageConfig) o;        if (isAbstract != packageConfig.isAbstract) {            return false;        }        if ((actionConfigs != null) ? (!actionConfigs.equals(packageConfig.actionConfigs)) : (packageConfig.actionConfigs != null))        {            return false;        }        if ((defaultResultType != null) ? (!defaultResultType.equals(packageConfig.defaultResultType)) : (packageConfig.defaultResultType != null))        {            return false;        }        if ((defaultClassRef != null) ? (!defaultClassRef.equals(packageConfig.defaultClassRef)) : (packageConfig.defaultClassRef != null))        {            return false;        }        if ((globalResultConfigs != null) ? (!globalResultConfigs.equals(packageConfig.globalResultConfigs)) : (packageConfig.globalResultConfigs != null))        {            return false;        }        if ((interceptorConfigs != null) ? (!interceptorConfigs.equals(packageConfig.interceptorConfigs)) : (packageConfig.interceptorConfigs != null))        {            return false;        }        if ((name != null) ? (!name.equals(packageConfig.name)) : (packageConfig.name != null)) {            return false;        }        if ((namespace != null) ? (!namespace.equals(packageConfig.namespace)) : (packageConfig.namespace != null)) {            return false;        }        if ((parents != null) ? (!parents.equals(packageConfig.parents)) : (packageConfig.parents != null)) {            return false;        }        if ((resultTypeConfigs != null) ? (!resultTypeConfigs.equals(packageConfig.resultTypeConfigs)) : (packageConfig.resultTypeConfigs != null))        {            return false;        }        if ((globalExceptionMappingConfigs != null) ? (!globalExceptionMappingConfigs.equals(packageConfig.globalExceptionMappingConfigs)) : (packageConfig.globalExceptionMappingConfigs != null))        {            return false;        }        return true;    }    public int hashCode() {        // System.out.println("hashCode() + {Name:"+name+" abstract:"+isAbstract+" namespace:"+namespace+" parents: "+parents+"}");        int result;        result = ((name != null) ? name.hashCode() : 0);        result = (29 * result) + ((parents != null) ? parents.hashCode() : 0);        result = (29 * result) + ((actionConfigs != null) ? actionConfigs.hashCode() : 0);        result = (29 * result) + ((globalResultConfigs != null) ? globalResultConfigs.hashCode() : 0);        result = (29 * result) + ((interceptorConfigs != null) ? interceptorConfigs.hashCode() : 0);        result = (29 * result) + ((resultTypeConfigs != null) ? resultTypeConfigs.hashCode() : 0);        result = (29 * result) + ((globalExceptionMappingConfigs != null) ? globalExceptionMappingConfigs.hashCode() : 0);        result = (29 * result) + ((defaultResultType != null) ? defaultResultType.hashCode() : 0);        result = (29 * result) + ((defaultClassRef != null) ? defaultClassRef.hashCode() : 0);        result = (29 * result) + ((namespace != null) ? namespace.hashCode() : 0);        result = (29 * result) + (isAbstract ? 1 : 0);        return result;    }    public void removeParent(PackageConfig parent) {        parents.remove(parent);    }    public String toString() {        return "{PackageConfig Name:" + name + " namespace:" + namespace + " abstract:" + isAbstract + " parents:" + parents + "}";    }    public int compareTo(Object o) {        PackageConfig other = (PackageConfig) o;        String full = namespace + "!" + name;        String otherFull = other.namespace + "!" + other.name;        // note, this isn't perfect (could come from different parents), but it is "good enough"        return full.compareTo(otherFull);    }}

⌨️ 快捷键说明

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