25
25
import org .exist .xquery .util .ExpressionDumper ;
26
26
import org .exist .xquery .value .Item ;
27
27
import org .exist .xquery .value .Sequence ;
28
- import org .exist .xquery .value .Type ;
29
28
30
29
/**
31
30
* @author <a href="[email protected] ">Adam Retter</a>
32
31
* @author <a href="[email protected] ">Gabriele Tomassetti</a>
33
32
*/
34
- public class InsertExpr extends AbstractExpression {
33
+ public class InsertExpr extends ModifyingExpression {
35
34
public enum Choice {
36
35
FIRST ,
37
36
LAST ,
@@ -40,14 +39,12 @@ public enum Choice {
40
39
BEFORE
41
40
}
42
41
43
- private final Expression source ;
44
- private final Expression target ;
42
+ private final Expression sourceExpr ;
45
43
private final Choice choice ;
46
44
47
45
public InsertExpr (final XQueryContext context , final Expression source , final Expression target , final Choice choice ) {
48
- super (context );
49
- this .source = source ;
50
- this .target = target ;
46
+ super (context , target );
47
+ this .sourceExpr = source ;
51
48
this .choice = choice ;
52
49
}
53
50
@@ -60,17 +57,6 @@ public Sequence eval(final Sequence contextSequence, final Item contextItem) thr
60
57
return Sequence .EMPTY_SEQUENCE ;
61
58
}
62
59
63
- @ Override
64
- public int returnsType () {
65
- // placeholder implementation
66
- return Type .EMPTY ;
67
- }
68
-
69
- public Category getCategory () {
70
- // placeholder implementation
71
- return Category .UPDATING ;
72
- }
73
-
74
60
@ Override
75
61
public Cardinality getCardinality () {
76
62
return Cardinality .ONE_OR_MORE ;
@@ -80,22 +66,31 @@ public Cardinality getCardinality() {
80
66
public void dump (final ExpressionDumper dumper ) {
81
67
dumper .display ("insert" ).nl ();
82
68
dumper .startIndent ();
83
- source .dump (dumper );
69
+ sourceExpr .dump (dumper );
84
70
dumper .endIndent ();
85
71
dumper .display (choice ).nl ();
86
72
dumper .startIndent ();
87
- target .dump (dumper );
73
+ targetExpr .dump (dumper );
74
+ dumper .endIndent ();
88
75
}
89
76
90
77
@ Override
91
78
public String toString () {
92
79
final StringBuilder result = new StringBuilder ();
93
80
result .append ("insert " );
94
- result .append (source .toString ());
81
+ result .append (sourceExpr .toString ());
95
82
result .append (" " );
96
83
result .append (choice .toString ());
97
84
result .append (" " );
98
- result .append (target .toString ());
85
+ result .append (targetExpr .toString ());
99
86
return result .toString ();
100
87
}
88
+
89
+ public Choice getChoice () {
90
+ return choice ;
91
+ }
92
+
93
+ public Expression getSourceExpr () {
94
+ return sourceExpr ;
95
+ }
101
96
}
0 commit comments