List of usage examples for java.util Arrays copyOf
public static boolean[] copyOf(boolean[] original, int newLength)
From source file:com.opengamma.analytics.math.linearalgebra.TridiagonalMatrix.java
/** * @return An array of the values of the diagonal */ public double[] getDiagonal() { return Arrays.copyOf(_a, _a.length); }
From source file:com.github.horrorho.inflatabledonkey.cloud.cloudkit.CKInit.java
@JsonCreator public CKInit(@JsonProperty("cloudKitDeviceUrl") String cloudKitDeviceUrl, @JsonProperty("cloudKitDatabaseUrl") String cloudKitDatabaseUrl, @JsonProperty("values") CKContainer[] containers, @JsonProperty("cloudKitShareUrl") String cloudKitShareUrl, @JsonProperty("cloudKitUserId") String cloudKitUserId) { this.cloudKitDeviceUrl = cloudKitDeviceUrl; this.cloudKitDatabaseUrl = cloudKitDatabaseUrl; this.containers = Arrays.copyOf(containers, containers.length); this.cloudKitShareUrl = cloudKitShareUrl; this.cloudKitUserId = cloudKitUserId; }
From source file:ar.gob.ambiente.servicios.gestionpersonas.entidades.util.CriptPass.java
/** * Mtodo para desencriptar una contrasea encriptada * @param textoEncriptado/* ww w.jav a 2 s . c om*/ * @return * @throws Exception */ public static String desencriptar(String textoEncriptado) throws Exception { String secretKey = "zorbazorbas"; //llave para encriptar datos String base64EncryptedString = ""; try { byte[] message = Base64.decodeBase64(textoEncriptado.getBytes("utf-8")); MessageDigest md = MessageDigest.getInstance("MD5"); byte[] digestOfPassword = md.digest(secretKey.getBytes("utf-8")); byte[] keyBytes = Arrays.copyOf(digestOfPassword, 24); SecretKey key = new SecretKeySpec(keyBytes, "DESede"); Cipher decipher = Cipher.getInstance("DESede"); decipher.init(Cipher.DECRYPT_MODE, key); byte[] plainText = decipher.doFinal(message); base64EncryptedString = new String(plainText, "UTF-8"); } catch (UnsupportedEncodingException | NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | IllegalBlockSizeException | BadPaddingException ex) { System.out.println(ex.getMessage()); } return base64EncryptedString; }
From source file:it.unibo.alchemist.model.implementations.actions.LsaChangeArgument.java
/** * Builds a new action that test neighbors which contain in their lsaSpace * an lsaMolecule matching <target,Type>. The effect of this Action is to * add to the matches map the variable PreferredType (the most present type * in neighborhood). The execution has no effect on influenced molecule of * reaction./*w w w.j a va 2 s .c o m*/ * * * @param environment * The environment to use * @param node * The source node * @param listTarget * Gradients list * @param targetVariab * Variable name * @param random * Random engine */ public LsaChangeArgument(final Environment<List<ILsaMolecule>> environment, final ILsaNode node, final String[] listTarget, final String targetVariab, final RandomGenerator random) { super(node); rnd = random; env = environment; newTargetVar = new HashString(targetVariab); listT = Arrays.copyOf(listTarget, listTarget.length); }
From source file:hivemall.common.DenseModel.java
private void ensureCapacity(final int index) { if (index >= size) { int bits = MathUtils.bitsRequired(index); int newSize = (1 << bits) + 1; int oldSize = size; logger.info("Expands internal array size from " + oldSize + " to " + newSize + " (" + bits + " bits)"); this.size = newSize; this.weights = Arrays.copyOf(weights, newSize); if (covars != null) { this.covars = Arrays.copyOf(covars, newSize); Arrays.fill(covars, oldSize, newSize, 1f); }/* w w w .j a va 2 s .com*/ } }
From source file:com.opencsv.ResultSetColumnNameHelperService.java
/** * Set the JDBC column names to use, and the header-text for the CSV file * @param columnNames the JDBC column names to export, in the desired order * @param columnHeaders the column headers of the CSV file, in the desired order * @throws UnsupportedOperationException if the number of headers is different than the number of columns, or if any * of the columns or headers is blank or null. *//*from w w w . j ava 2 s. c o m*/ public void setColumnNames(String[] columnNames, String[] columnHeaders) { if (columnHeaders.length != columnNames.length) { throw new UnsupportedOperationException( "The number of column names must be the same as the number of header names."); } if (hasInvalidValue(columnNames)) { throw new UnsupportedOperationException("Column names cannot be null, empty, or blank"); } if (hasInvalidValue(columnHeaders)) { throw new UnsupportedOperationException("Column header names cannot be null, empty, or blank"); } this.columnNames = Arrays.copyOf(columnNames, columnNames.length); this.columnHeaders = Arrays.copyOf(columnHeaders, columnHeaders.length); }
From source file:com.ktds.ldap.populator.AttributeCheckAttributesMapper.java
public void setExpectedValues(String[] expectedValues) { this.expectedValues = Arrays.copyOf(expectedValues, expectedValues.length); }
From source file:com.opengamma.analytics.math.curve.InterpolatedCurveShiftFunction.java
/** * {@inheritDoc}//from ww w .j a v a 2 s . c om */ @Override public InterpolatedDoublesCurve evaluate(final InterpolatedDoublesCurve curve, final double x, final double shift, final String newName) { Validate.notNull(curve, "curve"); final double[] xData = curve.getXDataAsPrimitive(); final double[] yData = curve.getYDataAsPrimitive(); final int n = xData.length; final int index = Arrays.binarySearch(xData, x); if (index >= 0) { final double[] shiftedY = Arrays.copyOf(curve.getYDataAsPrimitive(), n); shiftedY[index] += shift; return InterpolatedDoublesCurve.fromSorted(xData, shiftedY, curve.getInterpolator(), newName); } final double[] newX = new double[n + 1]; final double[] newY = new double[n + 1]; for (int i = 0; i < n; i++) { newX[i] = xData[i]; newY[i] = yData[i]; } newX[n] = x; newY[n] = curve.getYValue(x) + shift; return InterpolatedDoublesCurve.from(newX, newY, curve.getInterpolator(), newName); }
From source file:com.aionemu.gameserver.model.gameobjects.player.PlayerScripts.java
public boolean addScript(int position, String scriptXML) { PlayerScript script = scripts.get(position); if (scriptXML == null) { script.setData(null, -1);/*ww w . j a v a 2 s . co m*/ } else if (StringUtils.EMPTY.equals(scriptXML)) { script.setData(new byte[0], 0); } try { byte[] bytes = CompressUtil.Compress(scriptXML); int oldLength = bytes.length; bytes = Arrays.copyOf(bytes, bytes.length + 8); for (int i = oldLength; i < bytes.length; i++) { bytes[i] = -51; // Add NC shit bytes, without which fails to load :) } script.setData(bytes, scriptXML.length() * 2); } catch (Exception ex) { logger.error("Script compression failed: " + ex); return false; } return script == null; }
From source file:com.cloudera.sqoop.lib.BlobRef.java
@Override protected byte[] getInternalData(BytesWritable data) { return Arrays.copyOf(data.getBytes(), data.getLength()); }