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

📄 defaultrelationship.java

📁 一个完整的XACML工程,学习XACML技术的好例子!
💻 JAVA
字号:
/*
 * Created on 12-Apr-2005
 *
 * TODO All
 */
package ke.defaultimpl.core;

import java.util.HashMap;
import java.util.Set;

import ke.core.ConceptType;
import ke.core.CoreException;
import ke.core.Relationship;

/**
 * @author James Cunningham
 * 
 * @version
 *
 * TODO All
 */
public class DefaultRelationship extends Relationship
{

    /**
     * @param id
     * @param type
     * @param sourceId
     * @param destinationId
     */
    public DefaultRelationship(String id, 
            				   ConceptType type, 
            				   String sourceId,
            				   String destinationId,
            				   HashMap propertyValues)
    {
        super(id, type, sourceId, destinationId);
        this.propertyValues = propertyValues;
    }
    
    public DefaultRelationship(String id,
            				   ConceptType type, 
            				   HashMap propertyValues) {
        this(id, type, "", "", propertyValues);
    }

    /**
     * @param property
     * @return
     * @see ke.core.ConceptInstance#getPropertyValue(java.lang.String)
     */
    public Object getPropertyValue(String property) {
        if(!this.hasProperty(property))
            return null; //TODO is this correct behaviour?
        return this.propertyValues.get(property);
    }


    /**
     * @param property
     * @param value
     * @return
     * @see ke.core.ConceptInstance#setPropertyValue(java.lang.String, java.lang.Object)
     */
    
    public boolean setPropertyValue(String property, 
            						Object value) throws CoreException{
        if(!this.hasProperty(property))
            throw new CoreException("Error: invalid property name");
        Class valueClass = this.getType().getPropertyClass(property);
        if(!valueClass.isAssignableFrom(value.getClass()))
            throw new CoreException("Error: value has invalid class type");
        this.propertyValues.put(property, value);
        return false;
    }

    /**
     * @return
     * @see ke.core.ConceptInstance#getPropertyNames()
     */
    public String[] getPropertyNames() {
        Set names = this.propertyValues.keySet();
        return (String[])names.toArray(new String[names.size()]);
    }
    
    /**
     * @param propertyName
     * @return
     */
    
    private boolean hasProperty(String propertyName) {
        return this.propertyValues.keySet().contains(propertyName);
    }
    
    //------------------------------------

    private HashMap propertyValues;

}

⌨️ 快捷键说明

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