List of usage examples for org.apache.commons.lang3 ArrayUtils toPrimitive
public static boolean[] toPrimitive(final Boolean[] array)
Converts an array of object Booleans to primitives.
This method returns null for a null input array.
From source file:org.apache.hadoop.hive.serde2.compression.SnappyCompDe.java
private int writeBoxedDoubles(List<Double> boxedVals, ByteBuffer output) throws IOException { return writePrimitives(ArrayUtils.toPrimitive(boxedVals.toArray(new Double[0])), output); }
From source file:org.apache.nifi.processors.standard.util.TestPutTCPCommon.java
private void checkReceivedAllData(final ArrayBlockingQueue<List<Byte>> recvQueue, final String[] sentData, final int iterations) throws Exception { // check each sent FlowFile was successfully sent and received. for (int i = 0; i < iterations; i++) { for (String item : sentData) { List<Byte> message = recvQueue.take(); assertNotNull(message);// www .j av a 2s. c om Byte[] messageBytes = new Byte[message.size()]; assertArrayEquals(item.getBytes(), ArrayUtils.toPrimitive(message.toArray(messageBytes))); } } runner.assertTransferCount(PutTCP.REL_SUCCESS, sentData.length * iterations); runner.clearTransferState(); // Check that we have no unexpected extra data. assertNull(recvQueue.poll()); }
From source file:org.apache.syncope.core.persistence.beans.ReportExec.java
public byte[] getExecResult() { return execResult == null ? null : ArrayUtils.toPrimitive(execResult); }
From source file:org.apache.syncope.core.persistence.jpa.entity.JPAReportExec.java
@Override public byte[] getExecResult() { return execResult == null ? null : ArrayUtils.toPrimitive(execResult); }
From source file:org.apache.syncope.core.persistence.jpa.entity.JPASAML2IdP.java
@Override public byte[] getMetadata() { return metadata == null ? null : ArrayUtils.toPrimitive(metadata); }
From source file:org.apache.sysml.runtime.instructions.mr.TernaryInstruction.java
@Override public byte[] getAllIndexes() { return ArrayUtils.toPrimitive(Arrays.stream(new CPOperand[] { input1, input2, input3, output }) .filter(in -> in.isMatrix()).map(in -> Byte.parseByte(in.getName())).toArray(Byte[]::new)); }
From source file:org.apache.vxquery.jsonparser.JSONParser.java
public JSONParser(List<Byte[]> valueSeq) { factory = new JsonFactory(); this.valueSeq = valueSeq; atomic = new ArrayBackedValueStorage(); tvp = new TaggedValuePointable(); abStack = new ArrayList<ArrayBuilder>(); obStack = new ArrayList<ObjectBuilder>(); abvsStack = new ArrayList<ArrayBackedValueStorage>(); keyStack = new ArrayList<ArrayBackedValueStorage>(); spStack = new ArrayList<UTF8StringPointable>(); itemStack = new ArrayList<itemType>(); svb = new StringValueBuilder(); sb = new SequenceBuilder(); bp = new BooleanPointable(); allKeys = new ArrayList<Byte[]>(); abvsStack.add(atomic);//from w w w . j a v a2 s . c o m out = abvsStack.get(abvsStack.size() - 1).getDataOutput(); tempABVS = new ArrayBackedValueStorage(); this.objectMatchLevel = 1; this.arrayMatchLevel = 0; matched = false; literal = false; arrayCounters = new ArrayList<Integer>(); outputStream = new ByteArrayOutputStream(); prefixStream = new ByteArrayOutputStream(); pathStream = new ByteArrayOutputStream(); this.keysOrMembers = new ArrayList<Boolean>(); outputStream.reset(); pathStream.reset(); if (valueSeq != null) { for (int i = 0; i < this.valueSeq.size(); i++) { tvp.set(ArrayUtils.toPrimitive(valueSeq.get(i)), 0, ArrayUtils.toPrimitive(valueSeq.get(i)).length); //access an item of an array if (tvp.getTag() == ValueTag.XS_INTEGER_TAG) { pathStream.write(tvp.getByteArray(), 0, tvp.getLength()); this.arrayMatchLevel++; this.keysOrMembers.add(Boolean.valueOf(true)); //access all the items of an array or //all the keys of an object } else if (tvp.getTag() == ValueTag.XS_BOOLEAN_TAG) { pathStream.write(tvp.getByteArray(), 0, tvp.getLength()); this.arrayMatchLevel++; this.keysOrMembers.add(Boolean.valueOf(false)); //access an object } else { pathStream.write(tvp.getByteArray(), 1, tvp.getLength() - 1); } } } }
From source file:org.apache.vxquery.jsonparser.JSONParser.java
private boolean pathMatch() { outputStream.reset();// w w w. j a v a 2 s .co m for (Byte[] bb : allKeys) { outputStream.write(ArrayUtils.toPrimitive(bb), 0, ArrayUtils.toPrimitive(bb).length); } //the path of values created by parsing the file boolean contains = false; this.matched = false; prefixStream.reset(); if (pathStream.size() < outputStream.size()) { prefixStream.write(outputStream.toByteArray(), 0, pathStream.size()); contains = Arrays.equals(prefixStream.toByteArray(), pathStream.toByteArray()); } else { prefixStream.write(pathStream.toByteArray(), 0, outputStream.size()); contains = Arrays.equals(prefixStream.toByteArray(), outputStream.toByteArray()); } if (pathStream.size() == outputStream.size() && contains) { this.objectMatchLevel = this.levelObject; this.matched = true; this.literal = false; } return contains; }
From source file:org.apache.vxquery.jsonparser.JSONParser.java
public void startFieldName(JsonParser parser) throws HyracksDataException { if (levelObject > spStack.size()) { keyStack.add(new ArrayBackedValueStorage()); spStack.add(new UTF8StringPointable()); }/*from www . ja va2 s . c o m*/ keyStack.get(levelObject - 1).reset(); DataOutput outk = keyStack.get(levelObject - 1).getDataOutput(); try { svb.write(parser.getText(), outk); spStack.get(levelObject - 1).set(keyStack.get(levelObject - 1)); if (this.valueSeq != null) { int length = 0; byte[] barr = spStack.get(levelObject - 1).getByteArray(); outputStream.reset(); outputStream.write(barr, 0, spStack.get(levelObject - 1).getLength()); allKeys.add(ArrayUtils.toObject(outputStream.toByteArray())); for (int i = 0; i < allKeys.size() - 1; i++) { tvp.set(ArrayUtils.toPrimitive(allKeys.get(i)), 0, ArrayUtils.toPrimitive(allKeys.get(i)).length); length += ArrayUtils.toPrimitive(allKeys.get(i)).length; } //if the next two bytes represent a boolean (boolean has only two bytes), //it means that query asks for all the keys of the object if (length <= pathStream.size() && (length + 2) <= pathStream.size()) { tvp.set(pathStream.toByteArray(), length, length + 2); if (tvp.getTag() == ValueTag.XS_BOOLEAN_TAG) { abvsStack.get(0).reset(); out.write(ValueTag.XS_STRING_TAG); svb.write(parser.getText(), out); writeElement(abvsStack.get(0)); } } } } catch (Exception e) { throw new HyracksDataException("Writing in out of bounds space", e); } }
From source file:org.apache.vxquery.runtime.functions.index.VXQueryIndexReader.java
public void addValue(StringBuilder stb) { byte[] indexBytes = new byte[indexSeq.get(0).length]; int i = 0;/*from ww w .ja va 2s . c o m*/ for (Byte b : indexSeq.get(0)) { indexBytes[i++] = b.byteValue(); } TaggedValuePointable tvp = new TaggedValuePointable(); tvp.set(ArrayUtils.toPrimitive(indexSeq.get(0)), 0, ArrayUtils.toPrimitive(indexSeq.get(0)).length); if (tvp.getTag() == ValueTag.XS_STRING_TAG) { childLocalName[childLocalName.length - 1] = FunctionHelper .getStringFromBytes(Arrays.copyOfRange(indexBytes, 1, indexBytes.length)); } else { LongPointable intPoint = (LongPointable) LongPointable.FACTORY.createPointable(); intPoint.set(indexBytes, 1, indexBytes.length); childLocalName[childLocalName.length - 1] = String.valueOf(intPoint.longValue()); } stb.append(childLocalName[childLocalName.length - 1]); }