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 javax.jcr.PropertyType;
27 import javax.jcr.RepositoryException;
28 import javax.jcr.Value;
29 import org.modeshape.graph.query.model.Literal;
30
31
32
33
34 public class JcrLiteral extends Literal implements javax.jcr.query.qom.Literal, JcrStaticOperand {
35
36 private static final long serialVersionUID = 1L;
37
38 private final Value jcrValue;
39
40 public static Object rawValue( Value value ) throws RepositoryException {
41 switch (value.getType()) {
42 case PropertyType.BINARY:
43 return value.getBinary();
44 case PropertyType.BOOLEAN:
45 return value.getBoolean();
46 case PropertyType.DATE:
47 return value.getDate();
48 case PropertyType.DECIMAL:
49 return value.getDecimal();
50 case PropertyType.DOUBLE:
51 return value.getDouble();
52 case PropertyType.LONG:
53 return value.getLong();
54 case PropertyType.NAME:
55 case PropertyType.PATH:
56 case PropertyType.REFERENCE:
57 case PropertyType.STRING:
58 case PropertyType.URI:
59 case PropertyType.WEAKREFERENCE:
60 default:
61 return value.getString();
62 }
63 }
64
65
66
67
68
69 public JcrLiteral( Value value ) throws RepositoryException {
70 super(rawValue(value));
71 this.jcrValue = value;
72 }
73
74 public JcrLiteral( Value value,
75 Object rawValue ) {
76 super(rawValue);
77 this.jcrValue = value;
78 }
79
80
81
82
83
84
85 @Override
86 public Value getLiteralValue() {
87 return jcrValue;
88 }
89 }