List of usage examples for java.util Arrays copyOf
public static boolean[] copyOf(boolean[] original, int newLength)
From source file:com.bitbreeds.webrtc.sctp.model.SCTPHeader.java
public static SCTPHeader fromBytes(byte[] bytes) { if (bytes.length != 12) { throw new IllegalArgumentException("Bytes given are incorrect length to be an SCTP header: " + " length: " + bytes.length + " data:" + Hex.encodeHexString(bytes)); }//from w w w . j a va 2s . c om return new SCTPHeader(SignalUtil.intFromTwoBytes(Arrays.copyOf(bytes, 2)), SignalUtil.intFromTwoBytes(Arrays.copyOfRange(bytes, 2, 4)), SignalUtil.bytesToLong(Arrays.copyOfRange(bytes, 4, 8)), SignalUtil.bytesToLong(Arrays.copyOfRange(bytes, 8, 12))); }
From source file:com.offbynull.voip.kademlia.internalmessages.SearchResponse.java
/** * Constructs a {@link SearchResponse} object. * @param nodes closest nodes to the ID that was searched for * @throws NullPointerException if any argument is {@code null} or contains {@code null} *//* ww w . j a v a 2 s . c om*/ public SearchResponse(Node[] nodes) { Validate.notNull(nodes); Validate.noNullElements(nodes); this.nodes = Arrays.copyOf(nodes, nodes.length); }
From source file:net.sourceforge.jencrypt.lib.Utils.java
public static byte[] hashAESKey(byte[] bytesToHash, final short keySize) { byte[] bytesToHashCopy = Arrays.copyOf(bytesToHash, bytesToHash.length); switch (keySize) { case 128://from w w w .j a v a2 s .co m // GNU crypto library hash function implementation of RipeMD128 IMessageDigest ripeMD128 = new RipeMD128(); ripeMD128.update(bytesToHashCopy, 0, bytesToHashCopy.length); return ripeMD128.digest(); case 192: // GNU crypto library hash function implementation of Tiger IMessageDigest tiger = new Tiger(); tiger.update(bytesToHashCopy, 0, bytesToHashCopy.length); return tiger.digest(); case 256: // Apache Commons Codec lib SHA-256 bytesToHashCopy = DigestUtils.sha256(bytesToHashCopy); return bytesToHashCopy; default: throw new IllegalArgumentException("Key size unkown"); } }
From source file:com.c77.androidstreamingclient.lib.video.DumpDecoder.java
@Override public void decodeFrame(BufferedSample frame) { String debugging = "Size = " + frame.getSampleSize(); debugging += " [" + new String(Hex.encodeHex(Arrays.copyOf(frame.getBuffer().array(), 16))) + "]"; Log.i("DumpDecoder", debugging); }
From source file:com.bigdata.dastor.db.RangeSliceReply.java
public Message getReply(Message originalMessage) throws IOException { DataOutputBuffer dob = new DataOutputBuffer(); dob.writeInt(rows.size());//from www .j a v a 2s . co m for (Row row : rows) { Row.serializer().serialize(row, dob); } byte[] data = Arrays.copyOf(dob.getData(), dob.getLength()); return originalMessage.getReply(FBUtilities.getLocalAddress(), data); }
From source file:com.opengamma.maths.lowlevelapi.functions.utilities.Reverse.java
/** * Reverses a vector in place// w ww. j a v a 2 s . c o m * @param v1 the vector to be reversed * @return r a reversed copy of v1 */ public static long[] stateless(long[] v1) { Validate.notNull(v1); long[] r = Arrays.copyOf(v1, v1.length); inPlace(r); return r; }
From source file:com.gzj.tulip.jade.statement.DefaultInterpreterFactory.java
public synchronized void addInterpreter(Interpreter interpreter) { if (!ArrayUtils.contains(this.interpreters, interpreter)) { Interpreter[] interpreters = Arrays.copyOf(this.interpreters, this.interpreters.length + 1); interpreters[this.interpreters.length] = interpreter; Arrays.sort(interpreters, new InterpreterComparator()); this.interpreters = interpreters; }//from w w w . j av a 2 s .co m }
From source file:com.opengamma.maths.lowlevelapi.functions.utilities.Unique.java
/** * Uniques the data, duplicates are removed based on bitwise comparison of data. * @param data float[] the data to unique * @return the float[] uniqued data// w w w . j a v a2s . c o m */ public static float[] bitwise(float[] data) { Validate.notNull(data); int n = data.length; float[] sorteddata = Sort.stateless(data); int j = 0; for (int i = 1; i < n; i++) { if (Float.floatToIntBits(sorteddata[i]) != Float.floatToIntBits(sorteddata[j])) { j++; sorteddata[j] = sorteddata[i]; } } return Arrays.copyOf(sorteddata, j + 1); }
From source file:com.opengamma.analytics.math.FunctionUtils.java
/** * Same behaviour as mathlab unique//from w ww.ja va2s .c o m * @param in input array * @return a sorted array with no duplicates values */ public static double[] unique(final double[] in) { Arrays.sort(in); final int n = in.length; final double[] temp = new double[n]; temp[0] = in[0]; int count = 1; for (int i = 1; i < n; i++) { if (Double.compare(in[i], in[i - 1]) != 0) { temp[count++] = in[i]; } } if (count == n) { return temp; } return Arrays.copyOf(temp, count); }
From source file:com.google.nigori.server.JUser.java
@Override public byte[] getPublicKey() { return Arrays.copyOf(publicKey, publicKey.length); }