All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.att.research.xacmlatt.pdp.policy.FunctionArgumentBag Maven / Gradle / Ivy

The newest version!
/*
 *
 *          Copyright (c) 2013,2019  AT&T Knowledge Ventures
 *                     SPDX-License-Identifier: MIT
 */
package com.att.research.xacmlatt.pdp.policy;

import java.util.Iterator;

import com.att.research.xacml.api.AttributeValue;
import com.att.research.xacml.api.Status;
import com.att.research.xacml.std.StdStatus;

/**
 * FunctionArgumentBag implements the {@link com.att.research.xacmlatt.pdp.policy.FunctionArgument} interface for
 * a {@link com.att.research.xacmlatt.pdp.policy.Bag} objects.
 * 
 * @author car
 * @version $Revision: 1.3 $
 */
public class FunctionArgumentBag implements FunctionArgument {
	private Bag	bag;
	
	/**
	 * Creates a new FunctionArgumentBag from the given Bag.
	 * 
	 * @param bagIn the Bag for the new FunctionArgumentBag.
	 */
	public FunctionArgumentBag(Bag bagIn) {
		this.bag	= bagIn;
	}
	
	@Override
	public Status getStatus() {
		return StdStatus.STATUS_OK;
	}
	
	@Override
	public boolean isOk() {
		return true;
	}

	@Override
	public boolean isBag() {
		return true;
	}

	@Override
	public AttributeValue getValue() {
		Iterator> iterAttributeValues	= this.bag.getAttributeValues();
		if (iterAttributeValues == null || !iterAttributeValues.hasNext()) {
			return null;
		} else {
			return iterAttributeValues.next();
		}
	}

	@Override
	public Bag getBag() {
		return this.bag;
	}
    
    @Override
    public String toString() {
      StringBuilder builder = new StringBuilder("[");
      builder.append("status=" + this.getStatus() + ", ");
      builder.append("isOk=" + this.isOk() + ", ");
      builder.append("isBag=" + this.isBag() + ", ");
      builder.append("attributeValue=" + this.getValue());
      builder.append("]");
      return builder.toString();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy