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

Method bit

basex-core/src/main/java/org/basex/query/func/bin/BinFn.java:92–106  ·  view source on GitHub ↗

Returns bitwise operations. @param op bit operation @param qc query context @return result or null @throws QueryException query exception

(final Bit op, final QueryContext qc)

Source from the content-addressed store, hash-verified

90 * @throws QueryException query exception
91 */
92 final Item bit(final Bit op, final QueryContext qc) throws QueryException {
93 final Bin value1 = toBinOrNull(arg(0), qc), value2 = toBinOrNull(arg(1), qc);
94 if(value1 == null || value2 == null) return Empty.VALUE;
95
96 final byte[] bytes1 = value1.binary(info), bytes2 = value2.binary(info);
97 final int bl1 = bytes1.length, bl2 = bytes2.length;
98 if(bl1 != bl2) throw BIN_DLA_X_X.get(info, bl1, bl2);
99
100 // single byte
101 if(bl1 == 1) return B64.get(op.eval(bytes1[0], bytes2[0]));
102 // byte array
103 final byte[] tmp = new byte[bl1];
104 for(int b = 0; b < bl1; b++) tmp[b] = op.eval(bytes1[b], bytes2[b]);
105 return B64.get(tmp);
106 }
107
108 /**
109 * Pads an array.

Callers 3

itemMethod · 0.80
itemMethod · 0.80
itemMethod · 0.80

Calls 6

binaryMethod · 0.95
getMethod · 0.95
toBinOrNullMethod · 0.80
getMethod · 0.65
evalMethod · 0.65
argMethod · 0.45

Tested by

no test coverage detected