blob: 09c1a4d0cc08828ae2902dfa7b9e264c925c2dd9 (
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
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.query.profile.types;
import com.yahoo.language.process.Encoder;
import com.yahoo.search.query.profile.QueryProfileRegistry;
import com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry;
import com.yahoo.search.yql.YqlQuery;
/**
* A YQL query template field type in a query profile
*
* @author bratseth
*/
public class QueryFieldType extends FieldType {
@Override
public Class getValueClass() { return YqlQuery.class; }
@Override
public String stringValue() { return "query"; }
@Override
public String toString() { return "field type " + stringValue(); }
@Override
public String toInstanceDescription() { return "a YQL query template"; }
@Override
public Object convertFrom(Object o, QueryProfileRegistry registry) {
if (o instanceof YqlQuery) return o;
if (o instanceof String) return YqlQuery.from((String)o);
return null;
}
@Override
public Object convertFrom(Object o, ConversionContext context) {
return convertFrom(o, (QueryProfileRegistry)null);
}
}
|