List of usage examples for org.apache.commons.lang ArrayUtils subarray
public static boolean[] subarray(boolean[] array, int startIndexInclusive, int endIndexExclusive)
Produces a new boolean
array containing the elements between the start and end indices.
From source file:padl.kernel.impl.Element.java
public void startCloneSession() { super.startCloneSession(); // Yann 2010/10/03: Unique ID... again! // I used to concatenate a unique number for certain element, // for example binary class relationships, because a class // could have two with the same ID, name, etc. However, when // cloning, this unique number got duplicated unnecessarily, // so I must take care of it... // TODO: It would be cleaner to have two separate "unique IDs" // one containing the invariable ID, the other the variable number. // This code is actually dumb! Because the ID of an element // can contain legitimate underscores... So, I replace such // underscore with something that only PADL would do... final int index = this.getDisplayID().indexOf(Constants.NUMBER_SEPARATOR); if (index > 0) { ((Element) this.getClone()).setID(ArrayUtils.subarray(this.getID(), 0, index)); }//from w w w . j a v a2 s. com ((Element) this.getClone()).attachedElement = null; }
From source file:padl.util.Util.java
public static char[] computeSimpleName(final char[] aFullyQualifiedName) { char[] simpleName = aFullyQualifiedName; int index;/*ww w . j ava2 s. c o m*/ // Yann 2006/08/03: Member class! // When computing the simple name of a class, I don't // forget that this class could be a member class and // that I don't want to care about its declaring class // (preceding the '$' sign). index = ArrayUtils.lastIndexOf(simpleName, '$'); if (index > 0) { simpleName = ArrayUtils.subarray(aFullyQualifiedName, index + 1, aFullyQualifiedName.length); } else { index = ArrayUtils.lastIndexOf(simpleName, '.'); if (index > 0) { simpleName = ArrayUtils.subarray(simpleName, index + 1, simpleName.length); } } return simpleName; }
From source file:pl.mwaleria.safecommunicator.core.cipher.CipherManager.java
public byte[] decrypt(byte[] input, PrivateKey privateKey) throws CryptoException { try {//from w ww . j av a 2 s . com byte[] aesKeyEncypted = ArrayUtils.subarray(input, 0, Constants.CIPHER_ASYMETRIC_SIZE_IN_BYTES); byte[] aesKeyDecrypted = this.decryptAsymetric(aesKeyEncypted, privateKey); SecretKey originalKey = new SecretKeySpec(aesKeyDecrypted, 0, aesKeyDecrypted.length, Constants.CIPHER_SYMETRIC_ALGORITHM); Cipher cipher = Cipher.getInstance(Constants.CIPHER_SYMETRIC_INSTANCE); cipher.init(Cipher.DECRYPT_MODE, originalKey); return cipher .doFinal(ArrayUtils.subarray(input, Constants.CIPHER_ASYMETRIC_SIZE_IN_BYTES, input.length)); } catch (NoSuchAlgorithmException | NoSuchPaddingException | IllegalBlockSizeException | BadPaddingException | InvalidKeyException ex) { Logger.getLogger(CipherManager.class.getName()).log(Level.SEVERE, null, ex); throw new CryptoException(ex); } }
From source file:ptidej.solver.Occurrence.java
/** * Gets the part of the solution with non-enumerated name <name>. */// www. ja va 2 s . c o m public OccurrenceComponent getComponent(final char[] aName) { final Iterator e = this.components.iterator(); while (e.hasNext()) { final OccurrenceComponent c = (OccurrenceComponent) e.next(); char[] cName = c.getName(); final int indexOfLastDash = ArrayUtils.lastIndexOf(cName, '-'); if (indexOfLastDash > 0) { try { Integer.parseInt(String.valueOf(ArrayUtils.subarray(cName, indexOfLastDash + 1, cName.length))); cName = ArrayUtils.subarray(cName, 0, indexOfLastDash); } catch (final NumberFormatException nfe) { } } if (Arrays.equals(cName, aName)) { return c; } } return null; }
From source file:ptidej.solver.OccurrenceComponent.java
public static char[] computeSimpleName(final char[] aName) { int indexOfMinusSign = ArrayUtils.indexOf(aName, '-'); if (indexOfMinusSign > 0) { return ArrayUtils.subarray(aName, 0, indexOfMinusSign); } else {/* w w w . j av a2 s .co m*/ return aName; } }
From source file:rascal.object.AbstractObjectFactory.java
private GitObject createObject(final String name, byte[] buffer, int headerSpaceIndex, int headerEndIndex) throws CorruptedObjectException, UnknownObjectTypeException, NumberFormatException { GitObjectType type = parseObjectType(ArrayUtils.subarray(buffer, 0, headerSpaceIndex)); long size = parseObjectSize(ArrayUtils.subarray(buffer, headerSpaceIndex + 1, headerEndIndex)); if (size <= 0) { throw new CorruptedObjectException(name, "Wrong object size"); }/* w w w . j a va 2 s. c o m*/ return new GitObject(name, type, size) { public ReadableByteChannel getContentChannel() throws IOException { return AbstractObjectFactory.this.getChannel(name); } }; }
From source file:rascal.object.source.FilelBlobSourceIntegrationTest.java
@Test public void testCopyTo() throws Exception { ByteArrayOutputStream output = new ByteArrayOutputStream(); fileBlobSource.copyTo(Channels.newChannel(output)); byte[] buffer = output.toByteArray(); String expectedHeaderString = String.format("%s %d", GitObjectType.BLOB, testData.length); byte[] expectedHeader = ArrayUtils.add(expectedHeaderString.getBytes(), (byte) 0); byte[] header = ArrayUtils.subarray(buffer, 0, expectedHeader.length); Assert.assertTrue("Header should be of format \"type(space)size(null byte)\"", ArrayUtils.isEquals(expectedHeader, header)); byte[] content = ArrayUtils.subarray(buffer, expectedHeader.length, buffer.length); Assert.assertTrue(ArrayUtils.isEquals(testData, content)); }
From source file:strat.mining.stratum.proxy.worker.GetworkJobTemplate.java
/** * Build the midstate of the given block header. * //from ww w . ja va 2 s.co m * @param data * @return */ private byte[] buildMidstate(byte[] data) { byte[] midstateData = ArrayUtils.subarray(data, 0, 64); return SHA256HashingUtils.midstateSHA256(midstateData); }
From source file:uk.ac.ebi.atlas.profiles.differential.microarray.MicroarrayProfileStream.java
protected String[] removeGeneIDAndNameColumns(String[] columns) { return (String[]) ArrayUtils.subarray(columns, 3, columns.length); }
From source file:uk.ac.ebi.atlas.profiles.TsvInputStream.java
protected String[] removeGeneIDAndNameColumns(String[] columns) { return (String[]) ArrayUtils.subarray(columns, 2, columns.length); }