Skip to content

Commit 7e9057a

Browse files
gabriele-tomassettiadamretter
authored andcommitted
[refactor] Update class InsertExpr
1 parent ba1e1c7 commit 7e9057a

File tree

1 file changed

+17
-22
lines changed

1 file changed

+17
-22
lines changed

exist-core/src/main/java/org/exist/xquery/update/InsertExpr.java

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,12 @@
2525
import org.exist.xquery.util.ExpressionDumper;
2626
import org.exist.xquery.value.Item;
2727
import org.exist.xquery.value.Sequence;
28-
import org.exist.xquery.value.Type;
2928

3029
/**
3130
* @author <a href="[email protected]">Adam Retter</a>
3231
* @author <a href="[email protected]">Gabriele Tomassetti</a>
3332
*/
34-
public class InsertExpr extends AbstractExpression {
33+
public class InsertExpr extends ModifyingExpression {
3534
public enum Choice {
3635
FIRST,
3736
LAST,
@@ -40,14 +39,12 @@ public enum Choice {
4039
BEFORE
4140
}
4241

43-
private final Expression source;
44-
private final Expression target;
42+
private final Expression sourceExpr;
4543
private final Choice choice;
4644

4745
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;
5148
this.choice = choice;
5249
}
5350

@@ -60,17 +57,6 @@ public Sequence eval(final Sequence contextSequence, final Item contextItem) thr
6057
return Sequence.EMPTY_SEQUENCE;
6158
}
6259

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-
7460
@Override
7561
public Cardinality getCardinality() {
7662
return Cardinality.ONE_OR_MORE;
@@ -80,22 +66,31 @@ public Cardinality getCardinality() {
8066
public void dump(final ExpressionDumper dumper) {
8167
dumper.display("insert").nl();
8268
dumper.startIndent();
83-
source.dump(dumper);
69+
sourceExpr.dump(dumper);
8470
dumper.endIndent();
8571
dumper.display(choice).nl();
8672
dumper.startIndent();
87-
target.dump(dumper);
73+
targetExpr.dump(dumper);
74+
dumper.endIndent();
8875
}
8976

9077
@Override
9178
public String toString() {
9279
final StringBuilder result = new StringBuilder();
9380
result.append("insert ");
94-
result.append(source.toString());
81+
result.append(sourceExpr.toString());
9582
result.append(" ");
9683
result.append(choice.toString());
9784
result.append(" ");
98-
result.append(target.toString());
85+
result.append(targetExpr.toString());
9986
return result.toString();
10087
}
88+
89+
public Choice getChoice() {
90+
return choice;
91+
}
92+
93+
public Expression getSourceExpr() {
94+
return sourceExpr;
95+
}
10196
}

0 commit comments

Comments
 (0)