org.axiondb.functions
Class SubstringFunction

java.lang.Object
  extended by org.axiondb.BaseSelectable
      extended by org.axiondb.functions.BaseFunction
          extended by org.axiondb.functions.SubstringFunction
All Implemented Interfaces:
Serializable, Function, FunctionFactory, ConcreteFunction, ScalarFunction, Selectable

public class SubstringFunction
extends BaseFunction
implements ScalarFunction, FunctionFactory

Syntax: SUBSTRING(str, m [,n]) -- m is one(1) based index.)

Version:
$Revision: 1.10 $ $Date: 2005/05/10 00:15:21 $
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.axiondb.BaseSelectable
_hash
 
Constructor Summary
SubstringFunction()
          Creates a new instance of Class
 
Method Summary
 Object evaluate(RowDecorator row)
          Returns substring of str, beginning at character m, n characters long.
 DataType getDataType()
          StringType
 boolean isValid()
           
 ConcreteFunction makeNewInstance()
           
 
Methods inherited from class org.axiondb.functions.BaseFunction
addArgument, getArgument, getArgumentCount, setArgument, setVariableContext, toString
 
Methods inherited from class org.axiondb.BaseSelectable
getAlias, getLabel, getName, setAlias, setName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.axiondb.Function
addArgument, getAlias, getArgument, getArgumentCount, getName, setAlias, setArgument
 
Methods inherited from interface org.axiondb.Selectable
getLabel, setVariableContext
 

Constructor Detail

SubstringFunction

public SubstringFunction()
Creates a new instance of Class

Method Detail

makeNewInstance

public ConcreteFunction makeNewInstance()
Specified by:
makeNewInstance in interface FunctionFactory

getDataType

public DataType getDataType()
StringType

Specified by:
getDataType in interface Selectable
Specified by:
getDataType in class BaseFunction

evaluate

public Object evaluate(RowDecorator row)
                throws AxionException
Returns substring of str, beginning at character m, n characters long.

  • If m is 0, it is treated as 1. If m is positive, it counts from the beginning of str to find the first character. If m is negative, it counts backwards from the end of str.
  • If n is omitted, it returns all characters to the end of str. If n is less than 1, a null is returned.
  • Floating-point numbers passed as arguments to substr are automatically converted to integers.
  • If m greater than length of str, return null. If m+n is bigger than length of str, ignore n. if str is null, return null.

    Specified by:
    evaluate in interface ScalarFunction
    Specified by:
    evaluate in interface Selectable
    Throws:
    AxionException

  • isValid

    public boolean isValid()
    Specified by:
    isValid in interface ConcreteFunction
    Specified by:
    isValid in class BaseFunction