org.aitools.programd.multiplexor
Class PredicateValue

java.lang.Object
  extended by org.aitools.programd.multiplexor.PredicateValue

public class PredicateValue
extends java.lang.Object

A PredicateValue is, naturally, the value of a predicate. It can either have a single String value, or a list of values.

Since:
4.5
Author:
Noel Bush

Field Summary
private  boolean multiValued
          Whether this PredicateValue has multiple values.
private  java.lang.String singleValue
          The single value (if assigned).
private  java.util.ArrayList<java.lang.String> valueList
          The list of values (if assigned).
 
Constructor Summary
PredicateValue(java.util.ArrayList<java.lang.String> values)
          Creates a new PredicateValue with the given list of values.
PredicateValue(java.lang.String value)
          Creates a new PredicateValue with the given single value.
 
Method Summary
 void add(int index, java.lang.String value)
          Adds the given value into the value list at the given index.
 void add(java.lang.String value)
          Adds the given value.
 PredicateValue becomeMultiValued()
          If this PredicateValue is multi-valued, returns itself.
 java.lang.String get(int index)
           
 java.lang.String getFirstValue()
          If this PredicateValue is single-valued, simply returns the value.
 boolean isMultiValued()
           
 void push(java.lang.String value)
          Pushes a value onto the front of a list, and pops off any values at the end of the list so that the list size is no more than PredicateMaster.MAX_INDEX.
 int size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

singleValue

private java.lang.String singleValue
The single value (if assigned).


valueList

private java.util.ArrayList<java.lang.String> valueList
The list of values (if assigned).


multiValued

private boolean multiValued
Whether this PredicateValue has multiple values.

Constructor Detail

PredicateValue

public PredicateValue(java.lang.String value)
Creates a new PredicateValue with the given single value.

Parameters:
value - the single value to assign

PredicateValue

public PredicateValue(java.util.ArrayList<java.lang.String> values)
Creates a new PredicateValue with the given list of values.

Parameters:
values - the list of values to assign
Method Detail

isMultiValued

public boolean isMultiValued()
Returns:
whether this PredicateValue is multi-valued

getFirstValue

public java.lang.String getFirstValue()
If this PredicateValue is single-valued, simply returns the value. If it is multi-valued, returns the first in the list.

Returns:
the first or only value

becomeMultiValued

public PredicateValue becomeMultiValued()
If this PredicateValue is multi-valued, returns itself. If it is single-valued, converts itself to multivalued and then returns itself.

Returns:
the list of values (or only value)

add

public void add(java.lang.String value)
Adds the given value. In all cases, this means the PredicateValue becomes multi-valued.

Parameters:
value - the value to add

add

public void add(int index,
                java.lang.String value)
Adds the given value into the value list at the given index.

Parameters:
index - the index at which to add a value
value - the new value

push

public void push(java.lang.String value)
Pushes a value onto the front of a list, and pops off any values at the end of the list so that the list size is no more than PredicateMaster.MAX_INDEX.

Parameters:
value - the value to push

get

public java.lang.String get(int index)
Parameters:
index - the index whose value is wanted
Returns:
the value at the given index

size

public int size()
Returns:
the number of values stored