List of usage examples for org.apache.commons.lang ArrayUtils clone
public static boolean[] clone(boolean[] array)
Clones an array returning a typecast result and handling null
.
From source file:ArrayUtilsExampleV1.java
public static void main(String args[]) { long[] longArray = new long[] { 10000, 30, 99 }; String[] stringArray = new String[] { "abc", "def", "fgh" }; long[] clonedArray = ArrayUtils.clone(longArray); System.err.println(ArrayUtils.toString((ArrayUtils.toObject(clonedArray)))); System.err.println(ArrayUtils.indexOf(stringArray, "def")); ArrayUtils.reverse(stringArray);/*from ww w . j a va 2s.co m*/ System.err.println(ArrayUtils.toString(stringArray)); }
From source file:jp.co.opentone.bsol.framework.core.util.CloneUtil.java
/** * int???./*from w w w .j a va2 s . c om*/ * @param array * @return ??. array?null???????. */ public static int[] cloneArray(int[] array) { if (array == null) { return new int[0]; } return ArrayUtils.clone(array); }
From source file:de.csdev.ebus.command.datatypes.std.AbstractEBusTypeUnsignedNumber.java
@Override public BigDecimal decodeInt(byte[] data) throws EBusTypeException { byte[] clone = ArrayUtils.clone(data); ArrayUtils.reverse(clone);//w ww . j a v a 2s. c o m return new BigDecimal(new BigInteger(1, clone)); }
From source file:jp.co.opentone.bsol.framework.core.util.CloneUtil.java
/** * ??????./*from w w w. j a va 2s .c om*/ * @param <T> ?? * @param clazz ?? * @param array * @return ??. array?null???????. */ @SuppressWarnings("unchecked") public static <T> T[] cloneArray(Class<T> clazz, T[] array) { if (array == null) { return (T[]) Array.newInstance(clazz, 0); } return (T[]) ArrayUtils.clone(array); }
From source file:com.supermap.desktop.icloud.commontypes.LicenseInfo.java
public LicenseInfo(LicenseInfo licenseInfo) { this.id = licenseInfo.id; this.days = licenseInfo.days; this.remainDays = licenseInfo.remainDays; this.snId = licenseInfo.snId; this.moduleCode = ((Module[]) ArrayUtils.clone(licenseInfo.moduleCode)); this.productId = licenseInfo.productId; this.productType = licenseInfo.productType; this.allocationUserId = licenseInfo.allocationUserId; this.permanent = licenseInfo.permanent; this.lockMacAddr = licenseInfo.lockMacAddr; this.unlockNumber = licenseInfo.unlockNumber; this.status = licenseInfo.status; this.time = licenseInfo.time; this.version = licenseInfo.version; }
From source file:de.csdev.ebus.command.datatypes.EBusAbstractType.java
/** * Create a clone of the input array and reverse the byte order if set * * @param data//from w ww .j av a 2s . c o m * @return */ protected byte[] applyByteOrder(byte[] data) { data = ArrayUtils.clone(data); // reverse the byte order immutable if (reverseByteOrder) { ArrayUtils.reverse(data); } return data; }
From source file:com.marc.lastweek.web.util.behaviours.JavaScriptAlertConfirmBehaviour.java
/** * Class constructor.//ww w . java2 s. c o m * * @param key key which contains the message to show in the confirm window. * @param parameters value of parameters the message has (if it has any). */ public JavaScriptAlertConfirmBehaviour(final String key, final Object... parameters) { super(EVENT_NAME, true, new Model(key)); Validate.notEmpty(key, "Key cannot be null"); Validate.notNull(parameters, "Parameters cannot be null"); this.parameters = ArrayUtils.clone(parameters); }
From source file:com.jaeksoft.searchlib.result.collector.DocIdCollector.java
private DocIdCollector(final DocIdCollector source) { this.maxDoc = source.maxDoc; this.ids = ArrayUtils.clone(source.ids); this.currentPos = source.currentPos; this.bitSet = (OpenBitSet) source.bitSet.clone(); }
From source file:io.cloudslang.engine.queue.entities.Payload.java
@SuppressWarnings("CloneDoesntDeclareCloneNotSupportedException") @Override/*from w w w . java 2 s .c o m*/ public Object clone() { try { Payload cloned = (Payload) super.clone(); cloned.data = ArrayUtils.clone(data); return cloned; } catch (CloneNotSupportedException e) { System.out.println(e); return null; } }
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])); }//from w w w .j a va 2 s . c o m 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); }