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

📄 maparraytyperule.java

📁 一个完整的XACML工程,学习XACML技术的好例子!
💻 JAVA
字号:
/*
 * MapArrayTypeRule.java
 *
 * Created on 29 May 2003, 12:18
 */

package ke.defaultimpl.utils.xml.parsing;

import java.util.*;

import org.xml.sax.Attributes;

/**
 *
 * @author  Stefan Boddy, James Cunningham
 */

public class MapArrayTypeRule extends org.apache.commons.digester.Rule
{
    /** Creates a new instance of MapArrayTypeRule */
    public MapArrayTypeRule() {}


    /* (non-Javadoc)
     * @see org.apache.commons.digester.Rule#begin(java.lang.String, java.lang.String, org.xml.sax.Attributes)
     */
    
    public void begin(String namespace, 
            		  String name, 
            		  Attributes attributes) {
        for(int i = 0; i < attributes.getLength(); i++) {
             if(attributes.getQName(i).equals("itemType")) this.type = attributes.getValue(i);
        }
    }

    
    public void end(String namespace, 
            		String name) {
        PlaceHolder ph;
        if(digester.peek() instanceof PlaceHolder) {
			ph = (PlaceHolder)digester.peek();
		}
		else {
			System.out.println("WARNING: list element found without parent simpleType element [instanceof failure on " + digester.peek().getClass().getName() + "]. Terminating parsing of this element");
			this.type = null;
			return;
		}
        if(ph.getType().equals("simpleType")) {
			String attName = "";
			if((attName = (String)ph.getAttribute("name"))!=null) {
        		HashMap mapping = (HashMap)digester.peek(digester.getCount()-1);
				if(this.type == null) {
					System.out.println("WARNING: attribute '" + attName + "' 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
					}
					this.type = this.type + "[]";
					mapping.put(attName, this.type);
				}
			}
			else {
				System.out.println("WARNING: list element found with parent that has no name attribute. Terminating parsing of this element");
				this.type = null;
				return;
			}
		}
		else {
			System.out.println("WARNING: list element found without parent simpleType element [type check failure]. Terminating parsing of this element");
			this.type = null;
			return;
		}
        this.type = null;
    }

    //------------------------------------

    private String type;
}

⌨️ 快捷键说明

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