aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/main/java/com/yahoo/searchlib/expression/BitFunctionNode.java
blob: 4767945d5fdb911abf810d9febeacac5dc0f9688 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchlib.expression;

/**
 * This is an abstract super-class for all non-unary functions that operator on bit values.
 *
 * @author baldersheim
 * @author Simon Thoresen Hult
 */
public abstract class BitFunctionNode extends NumericFunctionNode {

    public static final int classId = registerClass(0x4000 + 47, BitFunctionNode.class);

    @Override
    protected int onGetClassId() {
        return classId;
    }

    @Override
    protected void onArgument(final ResultNode arg, ResultNode result) {
        onArgument(arg, (IntegerResultNode)result);
    }

    @Override
    protected void onPrepareResult() {
        setResult(new IntegerResultNode(0));
    }

    /**
     * Method for performing onArgument on integers, the only type supported for bit operations.
     *
     * @param arg    Argument given to the bit function.
     * @param result Place to store the result.
     */
    protected abstract void onArgument(final ResultNode arg, IntegerResultNode result);
}