@@ -13,6 +13,9 @@ var XSD = 'http://www.w3.org/2001/XMLSchema#',
13
13
var evaluators , operators ,
14
14
UnsupportedExpressionError , UnsupportedOperatorError , InvalidArgumentsNumberError ;
15
15
16
+ var isLiteral = N3Util . isLiteral ,
17
+ literalValue = N3Util . getLiteralValue ;
18
+
16
19
/**
17
20
* Creates a function that evaluates the given SPARQL expression.
18
21
* @constructor
@@ -87,11 +90,11 @@ evaluators = {
87
90
// Convert the arguments if necessary
88
91
switch ( operator . type ) {
89
92
case 'numeric' :
90
- args [ i ] = parseFloat ( N3Util . getLiteralValue ( arg ) ) ;
93
+ args [ i ] = parseFloat ( literalValue ( arg ) ) ;
91
94
break ;
92
95
case 'boolean' :
93
96
args [ i ] = arg !== XSD_FALSE &&
94
- ( ! N3Util . isLiteral ( arg ) || N3Util . getLiteralValue ( arg ) !== '0' ) ;
97
+ ( ! isLiteral ( arg ) || literalValue ( arg ) !== '0' ) ;
95
98
break ;
96
99
}
97
100
}
@@ -136,17 +139,17 @@ operators = {
136
139
return a . toLowerCase ( ) === b . toLowerCase ( ) ;
137
140
} ,
138
141
'contains' : function ( string , substring ) {
139
- substring = N3Util . getLiteralValue ( substring ) ;
140
- string = N3Util . getLiteralValue ( string ) ;
142
+ substring = literalValue ( substring ) ;
143
+ string = literalValue ( string ) ;
141
144
return string . indexOf ( substring ) >= 0 ;
142
145
} ,
143
146
'regex' : function ( subject , pattern ) {
144
- if ( N3Util . isLiteral ( subject ) )
145
- subject = N3Util . getLiteralValue ( subject ) ;
146
- return new RegExp ( N3Util . getLiteralValue ( pattern ) ) . test ( subject ) ;
147
+ if ( isLiteral ( subject ) )
148
+ subject = literalValue ( subject ) ;
149
+ return new RegExp ( literalValue ( pattern ) ) . test ( subject ) ;
147
150
} ,
148
151
'str' : function ( a ) {
149
- return N3Util . isLiteral ( a ) ? a : '"' + a + '"' ;
152
+ return isLiteral ( a ) ? a : '"' + a + '"' ;
150
153
} ,
151
154
'http://www.w3.org/2001/XMLSchema#integer' : function ( a ) {
152
155
return '"' + Math . floor ( a ) + '"^^http://www.w3.org/2001/XMLSchema#integer' ;
0 commit comments