MCPcopy Create free account
hub / github.com/BaseXdb/basex / castable

Method castable

basex-core/src/main/java/org/basex/query/expr/Convert.java:61–72  ·  view source on GitHub ↗

Checks if the expression can be cast to the specified type. @param castType type to cast to @return result of check or null

(final SeqType castType)

Source from the content-addressed store, hash-verified

59 * @return result of check or {@code null}
60 */
61 final Boolean castable(final SeqType castType) {
62 final SeqType est = expr.seqType();
63 if(!est.mayBeWrapped()) {
64 final long es = expr.size();
65 if(es != -1 && (es < castType.occ.min || es > castType.occ.max)) return false;
66
67 final Type et = est.type;
68 if(et.instanceOf(castType.type) && est.occ.instanceOf(castType.occ) &&
69 (et.eq(castType.type) || castType.type == BasicType.NUMERIC)) return true;
70 }
71 return null;
72 }
73
74 /**
75 * Checks if the argument can be simplified.

Callers 2

optimizeMethod · 0.45
optimizeMethod · 0.45

Calls 5

mayBeWrappedMethod · 0.95
instanceOfMethod · 0.95
eqMethod · 0.95
seqTypeMethod · 0.65
sizeMethod · 0.65

Tested by

no test coverage detected