Class RawChannelFunction

java.lang.Object
net.sf.basedb.util.jep.RawChannelFunction
All Implemented Interfaces:
JepExpressionFunction, JepFunction, org.nfunk.jep.function.PostfixMathCommandI

public class RawChannelFunction extends Object implements JepExpressionFunction
A JEP function class that adds a rawCh(int) function to a JEP expression parser. The function will look up the (possible transformed) intensity value for the given channel. For example: rawCh(1)

Note! This function always return the values as they are stored in the database. Use ChannelFunction if you need the untransformed intensity values.

To be able to use this function it must be registered with the JEP parser and, before the expression is evaluated, a SqlResult object must be set.

Version:
2.12
Author:
Nicklas
See Also:
Last modified
$Date: 2015-04-20 11:08:18 +0200 (må, 20 apr 2015) $
  • Field Details

    • channelToIndex

      private int[] channelToIndex
    • result

      private SqlResult result
    • numParameters

      private int numParameters
  • Constructor Details

    • RawChannelFunction

      public RawChannelFunction()
      Create a new instance of this function. The new instance cannot be used to dynamically evaluate expressions. It should only be used for converting JEP formulas to Expression:s.
      See Also:
    • RawChannelFunction

      public RawChannelFunction(int[] channelToIndex)
      Create a new instance of this function which can be used to dynamically evaluate expressions.
      Parameters:
      channelToIndex - An array that maps channel numbers to column indexes in the SqlResult, array position 0 maps the index of channel number 1, etc.
      See Also:
  • Method Details

    • getFunctionName

      public String getFunctionName()
      Description copied from interface: JepFunction
      Get the name of this function. It is used when registering the function with a JEP parser.
      Specified by:
      getFunctionName in interface JepFunction
      Returns:
      The string "rawCh"
      See Also:
    • toExpression

      public Expression toExpression(Node node)
      Use the Dynamic.column(VirtualColumn) method to create an expression referencing a channel intensity.
      Specified by:
      toExpression in interface JepExpressionFunction
      Parameters:
      node - The node representing this function
      Returns:
      An Expression object
    • getNumberOfParameters

      public int getNumberOfParameters()
      Specified by:
      getNumberOfParameters in interface org.nfunk.jep.function.PostfixMathCommandI
      Returns:
      Always 1
    • setCurNumberOfParameters

      public void setCurNumberOfParameters(int n)
      Specified by:
      setCurNumberOfParameters in interface org.nfunk.jep.function.PostfixMathCommandI
    • checkNumberOfParameters

      public boolean checkNumberOfParameters(int n)
      Specified by:
      checkNumberOfParameters in interface org.nfunk.jep.function.PostfixMathCommandI
    • run

      public void run(Stack stack) throws ParseException
      Specified by:
      run in interface org.nfunk.jep.function.PostfixMathCommandI
      Throws:
      ParseException
    • setSqlResult

      public void setSqlResult(SqlResult result)
      Set a new SqlResult object that will be used the next time the JEP expression is evaluated.
      Parameters:
      result - The result object
    • channel

      public Object channel(int channel) throws ParseException
      Get the value of the specified channel of the current sql result.
      Parameters:
      channel - The channel number
      Throws:
      ParseException - Either if it's an invalid channel number or if no result object has been specified.