aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com/yahoo/prelude/query/NullItem.java
blob: 98a9e242778cb5e82ed3267b4a553a3e8da88a58 (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
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.query;


import java.nio.ByteBuffer;


/**
 * A place holder for null queries to make searchers easier to write.
 *
 * @author Steinar Knutsen
 */
public class NullItem extends Item {

    public NullItem() {}

    /** Does nothing */
    public void setIndexName(String index) {}

    public int encode(ByteBuffer buffer) {
        throw new RuntimeException(
                "A NullItem was attempted encoded. "
                        + "This is probably a misbehaving " + "searcher.");
    }

    public ItemType getItemType() {
        throw new RuntimeException(
                "Packet code access attempted. "
                        + "A NullItem has no packet code. "
                        + "This is probably a misbehaving " + "searcher.");
    }

    public void appendBodyString(StringBuilder buffer) {
        // No body for this Item
        return;
    }

    public void appendHeadingString(StringBuilder buffer) {
        buffer.append(getName());
    }

    public String getName() {
        return "NULL";
    }

    @Override
    public int getTermCount() { return 0; }

}