Skip to content

Commit 5750c77

Browse files
authored
JAPI-573 Add in default support for set of (#697)
* Add in default support for set of * remove commented code * fix format
1 parent 378da89 commit 5750c77

File tree

11 files changed

+1036
-692
lines changed

11 files changed

+1036
-692
lines changed

wsclient/src/main/java/org/hpccsystems/ws/client/antlr/EclRecord.g4

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ opts:
7777
opt:
7878
maxlength
7979
| maxcount
80+
| setdefaultvalall
81+
| setdefaultval
8082
| defaultval
8183
| xpath
8284
| xmldefaultval
@@ -93,7 +95,7 @@ maxcount:
9395
;
9496

9597
defaultval:
96-
'DEFAULT' OPAREN STRING CPAREN
98+
('DEFAULT' OPAREN STRING CPAREN)
9799
;
98100

99101
xpath:
@@ -104,6 +106,13 @@ xmldefaultval:
104106
'XMLDEFAULT' OPAREN STRING CPAREN
105107
;
106108

109+
setdefaultval:
110+
'DEFAULT' OPAREN SETSTRING CPAREN
111+
;
112+
setdefaultvalall:
113+
'DEFAULT' OPAREN 'ALL' CPAREN
114+
;
115+
107116
annotation_name : ATOKEN;
108117
annotation_param : (TOKEN|UTOKEN);
109118
annotation_arguments : annotation_param (COMMA annotation_param)*;
@@ -114,6 +123,8 @@ comment:
114123
( '/*' annotation? (COMMA annotation)* .*? (.*?'*/' | '*/'))
115124
;
116125

126+
OSQUARE : '[';
127+
CSQUARE : ']';
117128
OPAREN : '(';
118129
CPAREN : ')';
119130
OCURLY : '{';
@@ -130,9 +141,11 @@ DATASET_SYM : 'DATASET';
130141
WS : [ \t\r\n] -> skip;
131142
INT : [0-9]+ ;
132143
fragment ESCAPED_QUOTE : '\\\'';
144+
SETSTRING : '[\'' ( ESCAPED_QUOTE | SETTOKEN | ('\'') | ~(']'))* '\']';
133145
STRING : '\'' ( ESCAPED_QUOTE | ~('\'') )* '\'';
134146
ATOKEN: [@][a-zA-Z0-9_-]+[a-zA-Z0-9_];
135147
TOKEN : ~[_\r\n\t; (),:={}-]~[\r\n \t;(),:={}-]* ;
136148
UTOKEN: [_]+[a-zA-Z0-9_-]+[a-zA-Z0-9_];
137149
ECL_NUMBERED_TYPE: TOKEN INT?;
150+
SETTOKEN: [a-zA-Z0-9,_-];
138151

wsclient/src/main/java/org/hpccsystems/ws/client/antlr/EclRecordReader.java

Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,72 @@ else if (currentrec != null)
396396
}
397397
}
398398

399+
400+
@Override
401+
public void enterSetdefaultvalall(EclRecordParser.SetdefaultvalallContext ctx)
402+
{
403+
String val = ctx.getChild(2).getText();
404+
val = val.replace("'", "");
405+
406+
if (currentfield != null)
407+
{
408+
currentfield.setColumnValue(val);
409+
}
410+
else if (currentrec != null)
411+
{
412+
currentrec.setColumnValue(val);
413+
}
414+
}
415+
416+
417+
/**
418+
* {@inheritDoc}
419+
*
420+
* <p>
421+
* When entering a DEFAULT option for Set Of, set the columnvalue of the current field/rec to its value
422+
* </p>
423+
*/
424+
@Override
425+
public void enterSetdefaultval(EclRecordParser.SetdefaultvalContext ctx)
426+
{
427+
String val = ctx.getChild(2).getText();
428+
if(val.length() >= 2)
429+
{
430+
if(val.substring(0, 2).equals("['"))
431+
{
432+
val = val.substring(2, val.length());
433+
}
434+
}
435+
if(val.length() >= 2)
436+
{
437+
if(val.substring(val.length()-2, val.length()).equals("']"))
438+
{
439+
val = val.substring(0, val.length() - 2);
440+
}
441+
}
442+
val = val.replace("']", "");
443+
444+
if(val.contains("','"))
445+
{
446+
if(!val.startsWith("'"))
447+
{
448+
val = "'" + val;
449+
}
450+
if(!val.endsWith("'"))
451+
{
452+
val = val + "'";
453+
}
454+
}
455+
if (currentfield != null)
456+
{
457+
currentfield.setColumnValue(val);
458+
}
459+
else if (currentrec != null)
460+
{
461+
currentrec.setColumnValue(val);
462+
}
463+
}
464+
399465
/**
400466
* {@inheritDoc}
401467
*
@@ -407,10 +473,12 @@ else if (currentrec != null)
407473
public void enterXpath(EclRecordParser.XpathContext ctx)
408474
{
409475
String val = ctx.getChild(2).getText();
410-
if (val.startsWith("'")) {
476+
if (val.startsWith("'"))
477+
{
411478
val=val.substring(1);
412479
}
413-
if (val.endsWith("'")) {
480+
if (val.endsWith("'"))
481+
{
414482
val=val.substring(0,val.length()-1);
415483
}
416484
if (currentfield != null)

wsclient/src/main/java/org/hpccsystems/ws/client/antlr/gen/EclRecord.interp

Lines changed: 13 additions & 1 deletion
Large diffs are not rendered by default.

wsclient/src/main/java/org/hpccsystems/ws/client/antlr/gen/EclRecord.tokens

Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,29 @@ T__11=12
1313
T__12=13
1414
T__13=14
1515
T__14=15
16-
OPAREN=16
17-
CPAREN=17
18-
OCURLY=18
19-
CCURLY=19
20-
COMMA=20
21-
SEMI=21
22-
EQ=22
23-
ASSING_SYM=23
24-
REC_SYM=24
25-
END_SYM=25
26-
DATASET_SYM=26
27-
WS=27
28-
INT=28
29-
STRING=29
30-
ATOKEN=30
31-
TOKEN=31
32-
UTOKEN=32
33-
ECL_NUMBERED_TYPE=33
16+
T__15=16
17+
OSQUARE=17
18+
CSQUARE=18
19+
OPAREN=19
20+
CPAREN=20
21+
OCURLY=21
22+
CCURLY=22
23+
COMMA=23
24+
SEMI=24
25+
EQ=25
26+
ASSING_SYM=26
27+
REC_SYM=27
28+
END_SYM=28
29+
DATASET_SYM=29
30+
WS=30
31+
INT=31
32+
SETSTRING=32
33+
STRING=33
34+
ATOKEN=34
35+
TOKEN=35
36+
UTOKEN=36
37+
ECL_NUMBERED_TYPE=37
38+
SETTOKEN=38
3439
'SET OF'=1
3540
'set of'=2
3641
'MAXLENGTH'=3
@@ -43,16 +48,19 @@ ECL_NUMBERED_TYPE=33
4348
'DEFAULT'=10
4449
'XPATH'=11
4550
'XMLDEFAULT'=12
46-
'//'=13
47-
'/*'=14
48-
'*/'=15
49-
'('=16
50-
')'=17
51-
'{'=18
52-
'}'=19
53-
','=20
54-
'='=22
55-
':='=23
56-
'RECORD'=24
57-
'END'=25
58-
'DATASET'=26
51+
'ALL'=13
52+
'//'=14
53+
'/*'=15
54+
'*/'=16
55+
'['=17
56+
']'=18
57+
'('=19
58+
')'=20
59+
'{'=21
60+
'}'=22
61+
','=23
62+
'='=25
63+
':='=26
64+
'RECORD'=27
65+
'END'=28
66+
'DATASET'=29

wsclient/src/main/java/org/hpccsystems/ws/client/antlr/gen/EclRecordBaseListener.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,30 @@ public class EclRecordBaseListener implements EclRecordListener {
335335
* <p>The default implementation does nothing.</p>
336336
*/
337337
@Override public void exitXmldefaultval(EclRecordParser.XmldefaultvalContext ctx) { }
338+
/**
339+
* {@inheritDoc}
340+
*
341+
* <p>The default implementation does nothing.</p>
342+
*/
343+
@Override public void enterSetdefaultval(EclRecordParser.SetdefaultvalContext ctx) { }
344+
/**
345+
* {@inheritDoc}
346+
*
347+
* <p>The default implementation does nothing.</p>
348+
*/
349+
@Override public void exitSetdefaultval(EclRecordParser.SetdefaultvalContext ctx) { }
350+
/**
351+
* {@inheritDoc}
352+
*
353+
* <p>The default implementation does nothing.</p>
354+
*/
355+
@Override public void enterSetdefaultvalall(EclRecordParser.SetdefaultvalallContext ctx) { }
356+
/**
357+
* {@inheritDoc}
358+
*
359+
* <p>The default implementation does nothing.</p>
360+
*/
361+
@Override public void exitSetdefaultvalall(EclRecordParser.SetdefaultvalallContext ctx) { }
338362
/**
339363
* {@inheritDoc}
340364
*

wsclient/src/main/java/org/hpccsystems/ws/client/antlr/gen/EclRecordLexer.interp

Lines changed: 16 additions & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)