blob: d95b8e456276ed4ec67c2aa2b884d237339fb2cf (
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchlib.expression;
/**
* This function is an instruction to negate its argument.
*
* @author baldersheim
* @author Simon Thoresen Hult
*/
public class NormalizeSubjectFunctionNode extends UnaryFunctionNode {
public static final int classId = registerClass(0x4000 + 143, NormalizeSubjectFunctionNode.class, NormalizeSubjectFunctionNode::new);
/**
* Constructs an empty result node. <b>NOTE:</b> This instance is broken until non-optional member data is set.
*/
public NormalizeSubjectFunctionNode() {
}
/**
* Constructs an instance of this class with given argument.
*
* @param arg The argument for this function.
*/
public NormalizeSubjectFunctionNode(ExpressionNode arg) {
addArg(arg);
}
@Override
public void onPrepareResult() {
setResult(new StringResultNode());
}
@Override
public void onPrepare() {
super.onPrepare();
}
@Override
public boolean onExecute() {
String result = getArg().getResult().getString();
if (result.startsWith("Re: ") || result.startsWith("RE: ") || result.startsWith("Fw: ") ||
result.startsWith("FW: "))
{
result = result.substring(4);
} else if (result.startsWith("Fwd: ")) {
result = result.substring(5);
}
((StringResultNode)getResult()).setValue(result);
return true;
}
@Override
protected int onGetClassId() {
return classId;
}
@Override
protected boolean equalsUnaryFunction(UnaryFunctionNode obj) {
return true;
}
}
|