mapnametyperule.java

来自「一个完整的XACML工程,学习XACML技术的好例子!」· Java 代码 · 共 52 行

JAVA
52
字号
/*
 * MapNameTypeRule.java
 *
 * Created on 11 December 2002, 12:18
 */

package ke.defaultimpl.utils.xml.parsing;

import java.util.*;

/**
 *
 * @author  james
 */
public class MapNameTypeRule extends org.apache.commons.digester.Rule
{

    /** Creates a new instance of MapNameTypeRule */
    public MapNameTypeRule() {}

    public void begin(String namespace, String name, org.xml.sax.Attributes attributes)
    {
        for(int i = 0; i < attributes.getLength(); i++)
        {
             if(attributes.getQName(i).equals("name")) this.name = attributes.getValue(i);
             if(attributes.getQName(i).equals("type")) this.type = attributes.getValue(i);
        }
    }

    public void end(String namespace, String name)
    {
        HashMap mapping = (HashMap)digester.peek(0);
        if(this.name != null)
        {
            if(this.type == null)
                System.out.println("WARNING: attribute '" + this.name + "' without type in schema " + (String)mapping.get("Schema_Name"));
            else
            {
                if(this.type.startsWith("xsd:"))
                    this.type = this.type.substring(this.type.indexOf("xsd:")+4); // simplify the type name
                mapping.put(this.name, this.type);
            }
        }
        this.name = null;
        this.type = null;
    }


    private String name;
    private String type;
}

⌨️ 快捷键说明

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