com.meyling.principia.argument
Class PatternVariable

java.lang.Object
  |
  +--com.meyling.principia.argument.AbstractArgument
        |
        +--com.meyling.principia.argument.PatternVariable
All Implemented Interfaces:
Argument, CounterMarker
Direct Known Subclasses:
BasicPatternVariable, BasicSubjectVariablePatternVariable

public class PatternVariable
extends AbstractArgument
implements CounterMarker

Pattern variable, for matching purposes.

Version:
$Revision 0.00.50$
Author:
Michael Meyling

Field Summary
private  Argument[] arguments
          remember constructor argument
private  Argument content
          assignment of pattern variable
private  Counter number
          number of pattern variable
 
Constructor Summary
PatternVariable(Argument[] arguments)
          Constructs a pattern variable.
 
Method Summary
 boolean containsPatternVariables()
          Does this argument contain any PatternVariable?
 Argument copy()
          Returns an identical object (maybe "this").
 Argument create(Argument[] arguments)
          Create a new Argument with given arguments.
 Argument getArgument(int i)
          Get the requested argument.
 int getArgumentSize()
          Get the number of arguments.
 Argument getContent()
          Sets argument of pattern variable.
 int getNumber()
          Get number of pattern variable.
 boolean isMatching(Argument argument)
          Is the argument matching the pattern variable?
 void setContent(Argument content)
          Sets argument of pattern variable.
 String toString()
          Get the argument in String form.
 
Methods inherited from class com.meyling.principia.argument.AbstractArgument
equals, getHighestNumber, getPatternVariables, getReplacementParents, getSearchParents, hashCode, matches, matches, replace, replace, replace, replaceMatches
 
Methods inherited from class java.lang.Object
, clone, finalize, getClass, notify, notifyAll, registerNatives, wait, wait, wait
 
Methods inherited from interface com.meyling.principia.argument.Argument
equals, getPatternVariables, getReplacementParents, getSearchParents, hashCode, matches, matches, replace, replace, replace, replaceMatches
 

Field Detail

number

private final Counter number
number of pattern variable

arguments

private Argument[] arguments
remember constructor argument

content

private Argument content
assignment of pattern variable
Constructor Detail

PatternVariable

public PatternVariable(Argument[] arguments)
                throws ArgumentException
Constructs a pattern variable.
Parameters:
arguments - first argument is number of this pattern variable
Throws:
ArgumentException - if there is not exactly one argument that is an instance of Counter
Method Detail

getArgumentSize

public final int getArgumentSize()
Description copied from interface: Argument
Get the number of arguments.
Specified by:
getArgumentSize in interface Argument
Overrides:
getArgumentSize in class AbstractArgument
Following copied from interface: com.meyling.principia.argument.Argument
Returns:
number of arguments

getArgument

public final Argument getArgument(int i)
                           throws IllegalArgumentException
Description copied from interface: Argument
Get the requested argument.
Specified by:
getArgument in interface Argument
Overrides:
getArgument in class AbstractArgument
Following copied from interface: com.meyling.principia.argument.Argument
Parameters:
i - number of argument (starting with 0)
Returns:
i-th part formula
Throws:
IllegalArgumentException - if i is not inbetween 0 and Argument.getArgumentSize() - 1

copy

public Argument copy()
Description copied from interface: Argument
Returns an identical object (maybe "this").
Specified by:
copy in interface Argument
Following copied from interface: com.meyling.principia.argument.Argument
Returns:
copy of this object

setContent

public final void setContent(Argument content)
Sets argument of pattern variable.
Parameters:
content - assignment of pattern variable
Throws:
IllegalArgumentException - if there is already an assignment

getContent

public final Argument getContent()
Sets argument of pattern variable.
Returns:
argument assignment of pattern variable,
Throws:
IllegalArgumentException - if no value was assigned

getNumber

public final int getNumber()
Get number of pattern variable.
Specified by:
getNumber in interface CounterMarker
Returns:
number of pattern variable

containsPatternVariables

public final boolean containsPatternVariables()
Description copied from interface: Argument
Does this argument contain any PatternVariable?
Specified by:
containsPatternVariables in interface Argument
Overrides:
containsPatternVariables in class AbstractArgument
Returns:
always returns true

create

public Argument create(Argument[] arguments)
                throws ArgumentException
Description copied from interface: Argument
Create a new Argument with given arguments.
Specified by:
create in interface Argument
Overrides:
create in class AbstractArgument
Following copied from interface: com.meyling.principia.argument.Argument
Parameters:
arguments - with these arguments the operator should be created
Returns:
new constructed Argument
Throws:
ArgumentException - if creation failed

isMatching

public boolean isMatching(Argument argument)
Is the argument matching the pattern variable? Here always true is returned.
Parameters:
argument - argument to match pattern variable
Returns:
true

toString

public String toString()
Description copied from interface: Argument
Get the argument in String form.
Specified by:
toString in interface Argument
Overrides:
toString in class AbstractArgument
Following copied from interface: com.meyling.principia.argument.Argument
Returns:
readable formula