List of usage examples for org.apache.commons.lang ArrayUtils addAll
public static double[] addAll(double[] array1, double[] array2)
Adds all the elements of the given arrays into a new array.
From source file:app.Des.java
public void doDesFile(int[][] content, String location, String name) throws IOException { List<int[]> keys = doKey(); RWBinaryFile file = new RWBinaryFile(); int[][] ciphered = new int[content.length / 8][]; int[][] deciphered = new int[content.length][]; int contentRow = 0; int outputRow = 0; while (contentRow < content.length) { int[] contentCopy = new int[0]; for (int i = 0; i < 8; i++, contentRow++) { contentCopy = ArrayUtils.addAll(contentCopy, ArrayUtils.clone(content[contentRow])); }/*ww w . jav a2 s . com*/ String out = cipher(contentCopy, keys); int[] temp = this.binMath.fromHexStringToBin(out, B_64); ciphered[outputRow] = ArrayUtils.clone(temp); outputRow++; } int[][] cipheredToWrite = new int[content.length][]; int index = 0; for (int[] tab : ciphered) { for (int i = 0; i < tab.length; i = i + 8) { cipheredToWrite[index] = ArrayUtils.subarray(tab, i, i + 8); index++; } } file.write(cipheredToWrite, location + "ciphered_" + name); keys = reverseList(keys); int output2Row = 0; int cipheredRow = 0; while (output2Row < ciphered.length) { String out = ""; out = cipher(ciphered[cipheredRow], keys); int[] temp = binMath.fromHexStringToBin(out, B_64); for (int indexTemp = 0; indexTemp < 64; indexTemp = indexTemp + 8) { deciphered[output2Row] = ArrayUtils.subarray(temp, indexTemp, indexTemp + 8); output2Row++; } cipheredRow++; } file.write(deciphered, location + "deciphered_" + name); }
From source file:edu.cornell.med.icb.goby.util.dynoptions.DynamicOptionClient.java
public DynamicOptionClient(final Class enclosingClass, final String[] otherDefinitions, final String... optionDefinition) { this(enclosingClass, (String[]) ArrayUtils.addAll(otherDefinitions, optionDefinition)); }
From source file:net.jselby.pc.network.packets.mcplay.PacketOutMapChunkBulk.java
@Override public void write(Client cl, StandardOutput out) throws IOException { byte[] dataArray = new byte[0]; boolean skylight = true; ArrayList<NetworkedChunk> networkedChunks = new ArrayList<>(); for (Chunk chunk : chunks) { NetworkedChunk compiledChunk = new NetworkedChunk(chunk); networkedChunks.add(compiledChunk); dataArray = ArrayUtils.addAll(dataArray, compiledChunk.getData()); }//w w w. j av a2s . c om out.writeShort(chunks.size()); out.writeInt(dataArray.length); out.writeBoolean(skylight); out.writeBytes(dataArray); for (NetworkedChunk chunk : networkedChunks) { out.writeInt(chunk.getX()); out.writeInt(chunk.getZ()); int bitmap = chunk.getPrimaryMap(); out.writeByte((byte) (bitmap & 0xff)); out.writeByte((byte) ((bitmap >> 8) & 0xff)); chunk.clear(); } // Clear this packet, remove unneeded data chunks.clear(); }
From source file:com.google.cloud.bigtable.hbase.TestAppend.java
/** * Requirement 5.1 - Append values to one or more columns within a single row. *//* w w w . j a v a 2 s .c o m*/ @Test public void testAppend() throws Exception { // Initialize Table table = getConnection().getTable(TABLE_NAME); byte[] rowKey = dataHelper.randomData("rowKey-"); byte[] qualifier = dataHelper.randomData("qualifier-"); byte[] value1 = dataHelper.randomData("value1-"); byte[] value2 = dataHelper.randomData("value1-"); byte[] value1And2 = ArrayUtils.addAll(value1, value2); // Put then append Put put = new Put(rowKey).addColumn(COLUMN_FAMILY, qualifier, value1); table.put(put); Append append = new Append(rowKey).add(COLUMN_FAMILY, qualifier, value2); Result result = table.append(append); Cell cell = result.getColumnLatestCell(COLUMN_FAMILY, qualifier); Assert.assertArrayEquals("Expect concatenated byte array", value1And2, CellUtil.cloneValue(cell)); // Test result Get get = new Get(rowKey).addColumn(COLUMN_FAMILY, qualifier); get.setMaxVersions(5); result = table.get(get); Assert.assertEquals("There should be two versions now", 2, result.size()); List<Cell> cells = result.getColumnCells(COLUMN_FAMILY, qualifier); Assert.assertArrayEquals("Expect concatenated byte array", value1And2, CellUtil.cloneValue(cells.get(0))); Assert.assertArrayEquals("Expect original value still there", value1, CellUtil.cloneValue(cells.get(1))); }
From source file:com.github.kuben.realshopping.RSPlayerInventory.java
public RSPlayerInventory(Player player, Shop shop) {//Use when player is entering store this.shop = shop; this.player = player.getName(); //Special Inv to PInv Object[] obj = ArrayUtils.addAll(player.getInventory().getContents(), player.getInventory().getArmorContents()); ItemStack[] IS = new ItemStack[obj.length]; for (int i = 0; i < obj.length; i++) IS[i] = (ItemStack) obj[i];/*from w w w. j a va2 s. c o m*/ items = invToPInv(IS);//Item - amount/dur bought = new HashMap<>(); }
From source file:cz.zeno.miner.FpgaWork.java
@Override public byte[] getWork() { //original header is extended with custom target and jobid (for miner internals) //initial nonce, target, jobID try {/* w ww .j a va2s. com*/ byte[] adder; //scrypt fpga needs different four bytes from target if (isScrypt) adder = ArrayUtils.addAll(ArrayUtils.addAll(Utils.hexStringToByteArray("00000000"), ArrayUtils.subarray(target, 2, 6)), jobID); else adder = ArrayUtils.addAll(ArrayUtils.addAll(Utils.hexStringToByteArray("00000000"), ArrayUtils.subarray(target, 4, 8)), jobID); byte[] work = ArrayUtils.addAll(ArrayUtils.addAll( ArrayUtils.addAll(Utils.swapEndian(ArrayUtils.addAll(version, prevhash)), merkleRoot), Utils.swapEndian(ArrayUtils.addAll(ntime, nbits))), adder); return work; } catch (DecoderException ex) { Logger.getLogger(FpgaWork.class.getName()).log(Level.SEVERE, null, ex); } return null; }
From source file:edu.illinois.cs.cogcomp.annotation.TextAnnotationFromTokenizationTest.java
private Tokenizer.Tokenization getTokenization(String rawText) { String[] sentences = this.rawText.split("\\n"); String[] tokens = new String[0]; List<IntPair> characterOffsets = new ArrayList<>(); int[] sentenceEndArray = new int[sentences.length]; int sentenceCharOffset = 0; int lastTokenCount = 0; for (int iSentence = 0; iSentence < sentences.length; iSentence++) { String sentence = sentences[iSentence]; String[] sentenceTokens = sentence.split("\\s"); tokens = (String[]) ArrayUtils.addAll(tokens, sentenceTokens); int charOffsetBegin = sentenceCharOffset; int charOffsetEnd = sentenceCharOffset; for (int i = 0; i < sentence.length(); i++) { char c = sentence.charAt(i); if (Character.isWhitespace(c)) { charOffsetEnd = sentenceCharOffset + i; IntPair tokenOffsets = new IntPair(charOffsetBegin, charOffsetEnd); characterOffsets.add(tokenOffsets); charOffsetBegin = charOffsetEnd + 1; }// ww w.j av a 2s . c o m } charOffsetEnd = sentenceCharOffset + sentence.length(); IntPair tokenOffsets = new IntPair(charOffsetBegin, charOffsetEnd); characterOffsets.add(tokenOffsets); sentenceCharOffset = charOffsetEnd + 1; lastTokenCount += sentenceTokens.length; sentenceEndArray[iSentence] = lastTokenCount; } IntPair[] charOffsetArray = new IntPair[characterOffsets.size()]; for (int i = 0; i < characterOffsets.size(); i++) { charOffsetArray[i] = characterOffsets.get(i); } Tokenizer.Tokenization tokenization = new Tokenizer.Tokenization(tokens, charOffsetArray, sentenceEndArray); return tokenization; }
From source file:eu.databata.engine.spring.PropagatorSpringFileHandler.java
@Override public File[] findSupplementFiles(File directory, String fileSearchRegexp, String dbCode) { if (!directory.isDirectory()) { return new File[] {}; }// w w w.j ava 2 s . co m FilesByRegexpFilter regexpFileFilter = new FilesByRegexpFilter(fileSearchRegexp); File[] directorySqlFiles = directory.listFiles(regexpFileFilter); File[] databaseSpecificDirectories = directory.listFiles(new DatabaseSpecificFilenameFilter(dbCode)); if (databaseSpecificDirectories.length > 0) { File[] databaseSpecificFiles = databaseSpecificDirectories[0].listFiles(regexpFileFilter); LOG.debug(databaseSpecificFiles.length + " specific files for database with code '" + dbCode + "' will be loaded."); directorySqlFiles = (File[]) ArrayUtils.addAll(directorySqlFiles, databaseSpecificFiles); } return directorySqlFiles; }
From source file:be.i8c.codequality.sonar.plugins.sag.webmethods.flow.FlowLanguage.java
@Override public String[] getFileSuffixes() { String[] suffixes = (String[]) ArrayUtils.addAll(getFlowFileSuffixes(), getNodeFileSuffixes()); return suffixes; }
From source file:net.onrc.openvirtex.util.OVXFlowManager.java
public Integer storeFlowValues(final byte[] srcMac, final byte[] dstMac) throws IndexOutOfBoundException { // TODO: Optimize flow numbers final BigInteger dualMac = new BigInteger(ArrayUtils.addAll(srcMac, dstMac)); Integer flowId = this.flowValues.inverse().get(dualMac); if (flowId == null) { flowId = this.flowCounter.getNewIndex(); log.debug("virtual net = {}: save flowId = {} that is associated to {} {}", this.tenantId, flowId, MACAddress.valueOf(srcMac).toString(), MACAddress.valueOf(dstMac).toString()); this.flowValues.put(flowId, dualMac); }/*from w w w . j ava2s . c om*/ return flowId; }