1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package org.modeshape.jcr.query.qom;
25
26 import java.io.InputStream;
27 import java.math.BigDecimal;
28 import java.util.Calendar;
29 import javax.jcr.Binary;
30 import javax.jcr.PropertyType;
31 import javax.jcr.RepositoryException;
32 import javax.jcr.Value;
33 import javax.jcr.ValueFormatException;
34 import javax.jcr.query.qom.Literal;
35 import javax.jcr.query.qom.StaticOperand;
36 import org.modeshape.graph.query.model.FullTextSearch;
37 import org.modeshape.graph.query.model.SelectorName;
38
39
40
41
42 public class JcrFullTextSearch extends FullTextSearch implements javax.jcr.query.qom.FullTextSearch, JcrConstraint {
43
44 private static final long serialVersionUID = 1L;
45
46 private final StaticOperand fullTextSearchOperand;
47
48 protected static String toString( StaticOperand operand ) throws RepositoryException {
49 if (operand instanceof Literal) {
50 return ((Literal)operand).getLiteralValue().getString();
51 }
52 return operand.toString();
53 }
54
55
56
57
58
59
60
61
62
63 public JcrFullTextSearch( SelectorName selectorName,
64 String propertyName,
65 StaticOperand fullTextSearchExpression ) throws RepositoryException {
66 super(selectorName, propertyName, toString(fullTextSearchExpression));
67 this.fullTextSearchOperand = fullTextSearchExpression;
68 }
69
70
71
72
73
74
75
76
77
78 public JcrFullTextSearch( SelectorName selectorName,
79 String propertyName,
80 final String fullTextSearchExpression,
81 Term term ) {
82 super(selectorName, propertyName, fullTextSearchExpression, term);
83 this.fullTextSearchOperand = new JcrLiteral(new Value() {
84
85 @Override
86 public int getType() {
87 return PropertyType.STRING;
88 }
89
90 @Override
91 public String getString() {
92 return fullTextSearchExpression;
93 }
94
95 @Override
96 public InputStream getStream() throws RepositoryException {
97 throw new ValueFormatException();
98 }
99
100 @Override
101 public long getLong() throws ValueFormatException, RepositoryException {
102 throw new ValueFormatException();
103 }
104
105 @Override
106 public double getDouble() throws ValueFormatException, RepositoryException {
107 throw new ValueFormatException();
108 }
109
110 @Override
111 public BigDecimal getDecimal() throws ValueFormatException, RepositoryException {
112 throw new ValueFormatException();
113 }
114
115 @Override
116 public Calendar getDate() throws ValueFormatException, RepositoryException {
117 throw new ValueFormatException();
118 }
119
120 @Override
121 public boolean getBoolean() throws ValueFormatException, RepositoryException {
122 throw new ValueFormatException();
123 }
124
125 @Override
126 public Binary getBinary() throws RepositoryException {
127 throw new ValueFormatException();
128 }
129 }, fullTextSearchExpression);
130 }
131
132
133
134
135
136
137 @Override
138 public String getPropertyName() {
139 return propertyName();
140 }
141
142
143
144
145
146
147 @Override
148 public StaticOperand getFullTextSearchExpression() {
149 return fullTextSearchOperand;
150 }
151
152
153
154
155
156
157 @Override
158 public String getSelectorName() {
159 return selectorName().name();
160 }
161 }