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)
| 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. |