org.mmbase.storage.search.implementation
Class BasicStepField

java.lang.Object
  extended by org.mmbase.storage.search.implementation.BasicStepField
All Implemented Interfaces:
Serializable, StepField, SizeMeasurable
Direct Known Subclasses:
BasicAggregatedField

public class BasicStepField
extends Object
implements StepField, SizeMeasurable, Serializable

Basic implementation. The field alias is not set on default.

Since:
MMBase-1.7
Version:
$Id: BasicStepField.java 42075 2010-04-29 11:50:14Z michiel $
Author:
Rob van Maris
See Also:
Serialized Form

Field Summary
protected  boolean modifiable
           
 
Constructor Summary
BasicStepField(Step step, Field f)
          Constructor.
 
Method Summary
(package private) static boolean compareSteps(Step step1, Step step2)
          Utility method, compares steps by their alias or table name.
(package private) static boolean equalFieldValues(Object value1, Object value2)
          Compares two field values for equality.
 boolean equals(Object obj)
          Compares this stepfield to the specified object.
 String getAlias()
          Gets the alias for the associated field.
 int getByteSize()
          Determines the byte-size of this object
 int getByteSize(SizeOf sizeof)
          Determines the byte-size of this object using the given SizeOf instance.
 Field getField()
          Gets the associated field.
 String getFieldName()
          Gets the name of the associated field (without prefix).
static String getFieldName(StepField field)
          Returns the field's fieldname, possibly extended with the step's name if known.
 Step getStep()
          Gets the step associated with this fieldstep.
 int getType()
          Gets the type of the associated field.
 int hashCode()
           
 BasicStepField setAlias(String alias)
          Sets alias property.
 void setUnmodifiable()
           
(package private) static void testValue(Object value, StepField field)
          Tests if a value is acceptable for comparison with a certain field.
 String toString()
          Returns a string representation of this StepField.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

modifiable

protected boolean modifiable
Constructor Detail

BasicStepField

public BasicStepField(Step step,
                      Field f)
Constructor.

Parameters:
step - The associated step.
field - The associated field.
Throws:
IllegalArgumentException - when an invalid argument is supplied.
Method Detail

testValue

static void testValue(Object value,
                      StepField field)
Tests if a value is acceptable for comparison with a certain field.

Parameters:
value - The value to be tested.
field - The non-null field.
Throws:
IllegalArgumentException - when the value is not acceptable for this field.

equalFieldValues

static boolean equalFieldValues(Object value1,
                                Object value2)
Compares two field values for equality. Numerical fields are compared based on their numerical value, as they may be of different type.

Parameters:
value1 - The first value, either a String or a Number
value2 - The second value, either a String or a Number
Returns:
True if both values represent the same string or numerical value.

setUnmodifiable

public void setUnmodifiable()
Specified by:
setUnmodifiable in interface StepField
Since:
MMBase-1.9.2

setAlias

public BasicStepField setAlias(String alias)
Sets alias property.

Parameters:
alias - The alias property.
Returns:
This BasicStepField instance.
Throws:
IllegalArgumentException - when an invalid argument is supplied.

getField

public Field getField()
Gets the associated field.

Returns:
The field.

getFieldName

public final String getFieldName()
Description copied from interface: StepField
Gets the name of the associated field (without prefix).

This corresponds to the fieldname in SQL SELECT-syntax.

Specified by:
getFieldName in interface StepField

getAlias

public String getAlias()
Description copied from interface: StepField
Gets the alias for the associated field.

This corresponds to the field alias in SQL SELECT-syntax.

Specified by:
getAlias in interface StepField

getStep

public Step getStep()
Description copied from interface: StepField
Gets the step associated with this fieldstep.

Specified by:
getStep in interface StepField

getType

public int getType()
Description copied from interface: StepField
Gets the type of the associated field. This is one of the values defined in Field.

Specified by:
getType in interface StepField

equals

public boolean equals(Object obj)
Description copied from interface: StepField
Compares this stepfield to the specified object. The result is true if and only if the argument is a non-null StepField object associated with the same field, using the same alias.

Specified by:
equals in interface StepField
Overrides:
equals in class Object
Parameters:
obj - The object to compare with.
Returns:
true if the objects are equal, false otherwise.

hashCode

public int hashCode()
Specified by:
hashCode in interface StepField
Overrides:
hashCode in class Object

compareSteps

static boolean compareSteps(Step step1,
                            Step step2)
Utility method, compares steps by their alias or table name. Steps are considered equal if their aliases are equal. When their aliases are null, the steps are considered equal if their tablenames are equal as well.

This can be used to verify that both steps refer to the same step in a SearchQuery object. Note that this differs from the equality defined by their equals() method.

Parameters:
step1 - The first step.
step2 - The second step.
Returns:
true when the steps are considered equal, false otherwise.

getFieldName

public static String getFieldName(StepField field)
Returns the field's fieldname, possibly extended with the step's name if known. May return null or partial fieldnames if not all data is available (for use in debugging).

Parameters:
field - the fieldname whose name to return

toString

public String toString()
Description copied from interface: StepField
Returns a string representation of this StepField. The string representation has the form "StepField(step:<step>, fieldname:<fieldname>, alias:<alias>)" where

Specified by:
toString in interface StepField
Overrides:
toString in class Object
Returns:
A string representation of this StepField.

getByteSize

public int getByteSize()
Description copied from interface: SizeMeasurable
Determines the byte-size of this object

Specified by:
getByteSize in interface SizeMeasurable

getByteSize

public int getByteSize(SizeOf sizeof)
Description copied from interface: SizeMeasurable
Determines the byte-size of this object using the given SizeOf instance. A SizeOf instance stores a Set already counted objects. So this method is typically called by SizeOf itself (recursion).

Specified by:
getByteSize in interface SizeMeasurable


MMBase 2.0-SNAPSHOT - null