Example usage for org.apache.commons.lang ArrayUtils addAll

List of usage examples for org.apache.commons.lang ArrayUtils addAll

Introduction

In this page you can find the example usage for org.apache.commons.lang ArrayUtils addAll.

Prototype

public static double[] addAll(double[] array1, double[] array2) 

Source Link

Document

Adds all the elements of the given arrays into a new array.

Usage

From source file:com.kstenschke.copypastestack.ToolWindow.java

/**
 * Refresh listed items from distinct merged sum of:
 * 0. option to preview the current clipboard contents
 * 1. previous clipboard items still in prefs
 * 2. current clipboard items/*from   w  ww  . ja v  a  2  s .  c  om*/
 */
private void refreshClipboardList() {
    Transferable[] copiedItems = CopyPasteManager.getInstance().getAllContents();
    int amountItems = UtilsClipboard.getAmountStringItemsInTransferables(copiedItems);
    String[] itemsUnique = null;
    boolean hasClipboardContent = UtilsClipboard.hasContent();

    String[] copyItemsList = new String[amountItems];
    if (amountItems > 0 || hasClipboardContent) {
        // Add copied string items, historic and current
        int index = 0;
        for (Transferable currentItem : copiedItems) {
            if (currentItem.isDataFlavorSupported(DataFlavor.stringFlavor)) {
                try {
                    String itemStr = currentItem.getTransferData(DataFlavor.stringFlavor).toString();
                    if (!itemStr.trim().isEmpty()) {
                        copyItemsList[index] = itemStr;
                        index++;
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }

        // Tidy items: distinct items, none empty
        String[] copyItemsPref = Preferences.getItems();
        Object[] allItems = (copyItemsPref.length > 0) ? ArrayUtils.addAll(copyItemsList, copyItemsPref)
                : copyItemsList;
        itemsUnique = UtilsArray.tidy(allItems);
        if (itemsUnique.length > 0) {
            this.setClipboardListData(itemsUnique, false);
            this.sortClipboardListByTags(this.form.checkboxKeepSorted.isSelected());

            Preferences.saveCopyItems(itemsUnique);
        }
    }

    initStatusLabel(itemsUnique == null ? 0 : itemsUnique.length);
}

From source file:de.cismet.cids.custom.objectrenderer.utils.alkis.AlkisUtils.java

/**
 * DOCUMENT ME!//from w  ww .  jav a2s.c  om
 *
 * @param   a  DOCUMENT ME!
 * @param   b  DOCUMENT ME!
 *
 * @return  DOCUMENT ME!
 */
public static LandParcel[] concatArrays(LandParcel[] a, LandParcel[] b) {
    if (a == null) {
        a = new LandParcel[0];
    }
    if (b == null) {
        b = new LandParcel[0];
    }
    return (LandParcel[]) ArrayUtils.addAll(a, b);
}

From source file:com.rapidminer.operator.generator.ExampleSetGenerator.java

@Override
public List<ParameterType> getParameterTypes() {
    List<ParameterType> types = super.getParameterTypes();
    ParameterType type = new ParameterTypeStringCategory(PARAMETER_TARGET_FUNCTION,
            "Specifies the target function of this example set", KNOWN_FUNCTION_NAMES, KNOWN_FUNCTION_NAMES[0]);
    type.setExpert(false);/*from   w w w. jav a 2s  .c o  m*/
    types.add(type);
    type = new ParameterTypeInt(PARAMETER_NUMBER_EXAMPLES, "The number of generated examples.", 1,
            Integer.MAX_VALUE, 100);
    type.setExpert(false);
    types.add(type);
    type = new ParameterTypeInt(PARAMETER_NUMBER_OF_ATTRIBUTES, "The number of attributes.", 1,
            Integer.MAX_VALUE, 5);
    type.setExpert(false);
    types.add(type);

    NonEqualStringCondition useTwoBounds = new NonEqualStringCondition(this, PARAMETER_TARGET_FUNCTION, false,
            (String[]) ArrayUtils.addAll(FUCTIONS_IGNORING_BOUND, FUNCTIONS_USING_SINGLE_BOUND));

    type = new ParameterTypeDouble(PARAMETER_ATTRIBUTES_LOWER_BOUND,
            "The minimum value for the attributes. In case of target functions using Gaussian distribution, the attribute values may exceed this value.",
            Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, -10);
    type.registerDependencyCondition(new OrParameterCondition(this, false,
            new BelowOrEqualOperatorVersionCondition(this, VERSION_TARGET_PARAMETERS_CHANGED), useTwoBounds));
    types.add(type);
    type = new ParameterTypeDouble(PARAMETER_ATTRIBUTES_UPPER_BOUND,
            "The maximum value for the attributes. In case of target functions using Gaussian distribution, the attribute values may exceed this value.",
            Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, 10);
    type.registerDependencyCondition(new OrParameterCondition(this, false,
            new BelowOrEqualOperatorVersionCondition(this, VERSION_TARGET_PARAMETERS_CHANGED), useTwoBounds));
    types.add(type);

    type = new ParameterTypeDouble(PARAMETER_ATTRIBUTES_GAUSSIAN_STDDEV,
            "Standard deviation of the Gaussian distribution used for generating attributes.", Double.MIN_VALUE,
            Double.POSITIVE_INFINITY, 10);
    type.registerDependencyCondition(
            new AboveOperatorVersionCondition(this, VERSION_TARGET_PARAMETERS_CHANGED));
    type.registerDependencyCondition(
            new EqualStringCondition(this, PARAMETER_TARGET_FUNCTION, false, FUNCTIONS_USING_GAUSSIAN_STDDEV));
    types.add(type);

    type = new ParameterTypeDouble(PARAMETER_ATTRIBUTES_LARGEST_RADIUS,
            "The radius of the outermost ring cluster.", 10.0, Double.POSITIVE_INFINITY, 10);
    type.registerDependencyCondition(
            new AboveOperatorVersionCondition(this, VERSION_TARGET_PARAMETERS_CHANGED));
    type.registerDependencyCondition(
            new EqualStringCondition(this, PARAMETER_TARGET_FUNCTION, false, FUNCTIONS_USING_LARGEST_RADIUS));
    types.add(type);

    types.addAll(RandomGenerator.getRandomGeneratorParameters(this));

    DataManagementParameterHelper.addParameterTypes(types, this);
    return types;
}

From source file:gda.device.scannable.scannablegroup.ScannableGroup.java

@Override
public String[] getExtraNames() {
    // recalculate every time as these attributes may be dynamic
    String[] extraNames = new String[0];
    for (Scannable member : groupMembers) {
        extraNames = (String[]) ArrayUtils.addAll(extraNames, member.getExtraNames());
    }/* w w  w .ja  v  a 2 s. c o  m*/
    return extraNames;
}

From source file:marytts.unitselection.analysis.Phone.java

/**
 * Get the target F0 values for this phone, with one value per Datagram in the phone's left and right units
 * /*from w w w  .  ja va 2s.com*/
 * @return the target F0 values with one value per Datagram in an array
 */
public double[] getTargetF0Values() {
    double[] f0Targets = ArrayUtils.addAll(leftF0Targets, rightF0Targets);
    return f0Targets;
}

From source file:gda.device.scannable.scannablegroup.ScannableGroup.java

@Override
public String[] getInputNames() {
    // recalculate every time as these attributes may be dynamic
    String[] inputNames = new String[0];
    for (Scannable member : groupMembers) {
        inputNames = (String[]) ArrayUtils.addAll(inputNames, member.getInputNames());
    }/*w w  w .j a v  a  2  s  .  co  m*/
    return inputNames;
}

From source file:io.fabric8.kubernetes.api.KubernetesFactory.java

private void configureClientCert(WebClient webClient) {
    try (InputStream certInputStream = getInputStreamFromDataOrFile(clientCertData, clientCertFile)) {
        CertificateFactory certFactory = CertificateFactory.getInstance("X509");
        X509Certificate cert = (X509Certificate) certFactory.generateCertificate(certInputStream);

        InputStream keyInputStream = getInputStreamFromDataOrFile(clientKeyData, clientKeyFile);
        PEMReader reader = new PEMReader(keyInputStream);
        RSAPrivateCrtKeySpec keySpec = new PKCS1EncodedKeySpec(reader.getDerBytes()).getKeySpec();
        KeyFactory kf = KeyFactory.getInstance(clientKeyAlgo);
        RSAPrivateKey privKey = (RSAPrivateKey) kf.generatePrivate(keySpec);

        KeyStore keyStore = KeyStore.getInstance("JKS");
        keyStore.load(null);//  ww  w  . ja  va 2s .  co  m

        String alias = cert.getSubjectX500Principal().getName();
        keyStore.setKeyEntry(alias, privKey, clientKeyPassword, new Certificate[] { cert });

        KeyManagerFactory keyManagerFactory = KeyManagerFactory
                .getInstance(KeyManagerFactory.getDefaultAlgorithm());
        keyManagerFactory.init(keyStore, clientKeyPassword);

        HTTPConduit conduit = WebClient.getConfig(webClient).getHttpConduit();

        TLSClientParameters params = conduit.getTlsClientParameters();

        if (params == null) {
            params = new TLSClientParameters();
            conduit.setTlsClientParameters(params);
        }

        KeyManager[] existingKeyManagers = params.getKeyManagers();
        KeyManager[] keyManagers;

        if (existingKeyManagers == null || ArrayUtils.isEmpty(existingKeyManagers)) {
            keyManagers = keyManagerFactory.getKeyManagers();
        } else {
            keyManagers = (KeyManager[]) ArrayUtils.addAll(existingKeyManagers,
                    keyManagerFactory.getKeyManagers());
        }

        params.setKeyManagers(keyManagers);

    } catch (Exception e) {
        log.error("Could not create key manager for " + clientCertFile + " (" + clientKeyFile + ")", e);
    }
}

From source file:cz.zeno.miner.stratum.StratumClient.java

private byte[] buildCoinbase(byte[] extranonce2) throws NoSuchAlgorithmException {
    SHA2 sha1 = new SHA2("SHA-256");
    SHA2 sha2 = new SHA2("SHA-256");
    //            System.out.println("coinb1: " + Utils.byteArrayToHexString(coinb1));
    //            System.out.println("enonce1: " + Utils.byteArrayToHexString(extranonce1));
    //            System.out.println("enonce2: " + Utils.byteArrayToHexString(extranonce2));
    //            System.out.println("coinb2: " + Utils.byteArrayToHexString(coinb2));

    byte[] coinbase_hash_bin = ArrayUtils.addAll(ArrayUtils.addAll(coinb1, extranonce1),
            ArrayUtils.addAll(extranonce2, coinb2));
    //            System.out.println("length: " + coinbase_hash_bin.length);
    return sha2.digest(sha1.digest(coinbase_hash_bin));
}

From source file:com.facebook.presto.accumulo.index.Indexer.java

/**
 * Gets the column family of the index table based on the given column family and qualifier.
 *
 * @param columnFamily Presto column family
 * @param columnQualifier Presto column qualifier
 * @return ByteBuffer of the given index column family
 *///from w  w w .  j  ava  2s  .c  o m
public static ByteBuffer getIndexColumnFamily(byte[] columnFamily, byte[] columnQualifier) {
    return wrap(ArrayUtils.addAll(ArrayUtils.add(columnFamily, UNDERSCORE), columnQualifier));
}

From source file:cz.zeno.miner.stratum.StratumClient.java

private byte[] buildMerkleRoot(byte[] extranonce2) throws NoSuchAlgorithmException {
    SHA2 sha1 = new SHA2("SHA-256");
    SHA2 sha2 = new SHA2("SHA-256");

    byte[] merkleRoot = buildCoinbase(extranonce2);
    for (byte[] branch : merkle_branch) {
        //                System.out.println("branch: " + Utils.byteArrayToHexString(branch));
        merkleRoot = sha2.digest(sha1.digest(ArrayUtils.addAll(merkleRoot, branch)));
    }// www .j a v a2  s .c  o m

    return merkleRoot;
}