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:de.uzk.hki.da.format.PublishVideoConversionStrategy.java

@Override
public List<Event> convertFile(ConversionInstruction ci) throws FileNotFoundException {
    if (pkg == null)
        throw new IllegalStateException("pkg not set");

    List<Event> results = new ArrayList<Event>();

    Path.makeFile(object.getDataPath(), pips, "public", ci.getTarget_folder()).mkdirs();
    Path.makeFile(object.getDataPath(), pips, "institution", ci.getTarget_folder()).mkdirs();

    String cmdPUBLIC[] = new String[] { "HandBrakeCLI", "-i",
            ci.getSource_file().toRegularFile().getAbsolutePath(), "-o",
            object.getDataPath() + "/" + pips.toString() + "/public/"
                    + Utilities.slashize(ci.getTarget_folder())
                    + FilenameUtils.getBaseName(ci.getSource_file().toRegularFile().getAbsolutePath()) + ".mp4",
            "-e", "x264", "-f", "mp4", "-E", "faac" };

    cmdPUBLIC = (String[]) ArrayUtils.addAll(cmdPUBLIC, getRestrictionParametersForAudience("PUBLIC"));

    DAFile pubFile = new DAFile(pkg, pips + "/public", Utilities.slashize(ci.getTarget_folder())
            + FilenameUtils.getBaseName(ci.getSource_file().toRegularFile().getAbsolutePath()) + ".mp4");

    if (!executeConversionTool(cmdPUBLIC, pubFile.toRegularFile()))
        throw new RuntimeException("command not succeeded: " + Arrays.toString(cmdPUBLIC));

    Event e = new Event();
    e.setType("CONVERT");
    e.setDetail(Utilities.createString(cmdPUBLIC));
    e.setSource_file(ci.getSource_file());
    e.setTarget_file(pubFile);/*from   w w w . j a v a  2  s  . c  o m*/
    e.setDate(new Date());

    String cmdINSTITUTION[] = new String[] { "HandBrakeCLI", "-i",
            ci.getSource_file().toRegularFile().getAbsolutePath(), "-o",
            object.getDataPath() + "/" + pips + "/institution/" + Utilities.slashize(ci.getTarget_folder())
                    + FilenameUtils.getBaseName(ci.getSource_file().toRegularFile().getAbsolutePath()) + ".mp4",
            "-e", "x264", "-f", "mp4", "-E", "faac" };

    cmdINSTITUTION = (String[]) ArrayUtils.addAll(cmdINSTITUTION,
            getRestrictionParametersForAudience("INSTITUTION"));

    DAFile instFile = new DAFile(pkg, "dip/institution", Utilities.slashize(ci.getTarget_folder())
            + FilenameUtils.getBaseName(ci.getSource_file().toRegularFile().getAbsolutePath()) + ".mp4");

    if (!executeConversionTool(cmdINSTITUTION, instFile.toRegularFile()))
        throw new RuntimeException("command not succeeded: " + Arrays.toString(cmdINSTITUTION));

    Event e2 = new Event();
    e2.setType("CONVERT");
    e2.setDetail(Utilities.createString(cmdINSTITUTION));
    e2.setSource_file(ci.getSource_file());
    e2.setTarget_file(instFile);

    results.add(e);
    results.add(e2);

    return results;
}

From source file:com.opengamma.analytics.financial.provider.sensitivity.multicurve.ParameterSensitivityMulticurveMatrixCalculator.java

/**
 * Computes the sensitivity with respect to the parameters from the point sensitivities.
 * @param sensitivity The point sensitivity.
 * @param multicurves The multi-curve provider. Not null.
 * @param curvesSet The set of curves for which the sensitivity will be computed. Not null.
 * @return The sensitivity (as a Matrix). The order of the sensitivity is by curve as provided by the curvesSet.
 *//*from   w ww .  j av  a  2s  .  co m*/
@Override
public DoubleMatrix1D pointToParameterSensitivity(final MulticurveSensitivity sensitivity,
        final MulticurveProviderInterface multicurves, final Set<String> curvesSet) {
    SimpleParameterSensitivity ps = new SimpleParameterSensitivity();
    // YieldAndDiscount
    final Map<String, List<DoublesPair>> sensitivityDsc = sensitivity.getYieldDiscountingSensitivities();
    for (final Map.Entry<String, List<DoublesPair>> entry : sensitivityDsc.entrySet()) {
        if (curvesSet.contains(entry.getKey())) {
            ps = ps.plus(entry.getKey(),
                    new DoubleMatrix1D(multicurves.parameterSensitivity(entry.getKey(), entry.getValue())));
        }
    }
    // Forward
    final Map<String, List<ForwardSensitivity>> sensitivityFwd = sensitivity.getForwardSensitivities();
    for (final Map.Entry<String, List<ForwardSensitivity>> entry : sensitivityFwd.entrySet()) {
        if (curvesSet.contains(entry.getKey())) {
            ps = ps.plus(entry.getKey(), new DoubleMatrix1D(
                    multicurves.parameterForwardSensitivity(entry.getKey(), entry.getValue())));
        }
    }
    // By curve name in the curves set (to have the right order)
    double[] result = new double[0];
    for (final String name : curvesSet) {
        final DoubleMatrix1D sensi = ps.getSensitivity(name);
        if (sensi != null) {
            result = ArrayUtils.addAll(result, sensi.getData());
        } else {
            result = ArrayUtils.addAll(result, new double[multicurves.getNumberOfParameters(name)]);
        }
    }
    return new DoubleMatrix1D(result);
}

From source file:au.com.jwatmuff.eventmanager.export.CSVExporter.java

public static void generatePlayerList(Database database, OutputStream out) {
    Collection<Player> players = database.findAll(Player.class, PlayerDAO.ALL);
    PrintStream ps = new PrintStream(out);

    Object[] columns = new Object[] { "id", "First Name", "Last Name", "Sex", "Grade", "DOB", "Team",
            "Home Number", "Work Number", "Mobile Number", "Street", "City", "Postcode", "State", "Email",
            "Emergency Name", "Emergency Phone", "Emergency Mobile", "Medical Conditions", "Medical Info",
            "Injury Info" };

    outputRow(columns, ps);//w  w  w .  j a va2  s  . c om

    for (Player player : players) {
        Object[] fields1 = new Object[] { player.getVisibleID(), player.getFirstName(), player.getLastName(),
                player.getGender(), player.getGrade(), dateFormat.format(player.getDob()), player.getTeam() };

        PlayerDetails details = database.get(PlayerDetails.class, player.getDetailsID());
        Object[] fields2;
        if (details != null) {
            fields2 = new Object[] { details.getHomeNumber(), details.getWorkNumber(),
                    details.getMobileNumber(), details.getStreet(), details.getCity(), details.getPostcode(),
                    details.getState(), details.getEmail(), details.getEmergencyName(),
                    details.getEmergencyPhone(), details.getEmergencyMobile(), details.getMedicalConditions(),
                    details.getMedicalInfo(), details.getInjuryInfo() };
        } else {
            fields2 = new Object[14];
            Arrays.fill(fields2, null);
        }

        outputRow(ArrayUtils.addAll(fields1, fields2), ps);
    }
}

From source file:de.uzk.hki.da.format.PublishAudioConversionStrategy.java

@Override
public List<Event> convertFile(ConversionInstruction ci) throws FileNotFoundException {
    if (object == null)
        throw new IllegalStateException("object not set");

    if (cliConnector == null)
        throw new IllegalStateException("cliConnector not set");

    Path.makeFile(object.getDataPath(), pips, "public", ci.getTarget_folder()).mkdirs();
    Path.makeFile(object.getDataPath(), pips, "institution", ci.getTarget_folder()).mkdirs();

    List<Event> results = new ArrayList<Event>();

    for (String audience : audiences) {

        Path source = Path.make(ci.getSource_file().toRegularFile().getAbsolutePath());
        Path target = Path.make(object.getDataPath(), pips, audience.toLowerCase(), ci.getTarget_folder(),
                FilenameUtils.getBaseName(ci.getSource_file().toRegularFile().getAbsolutePath()) + ".mp3");
        logger.debug(//w  w w.java2s  . c  om
                "source:" + FilenameUtils.getBaseName(ci.getSource_file().toRegularFile().getAbsolutePath()));

        String cmdPUBLIC[] = new String[] { "sox", source.toString(), target.toString() };
        logger.debug("source:" + source);
        logger.debug("target:" + target);
        if (!cliConnector.execute(
                (String[]) ArrayUtils.addAll(cmdPUBLIC, getDurationRestrictionsForAudience(audience)))) {
            throw new RuntimeException("command not succeeded");
        }

        DAFile f1 = new DAFile(object.getLatestPackage(), pips + "/" + audience.toLowerCase(),
                Utilities.slashize(ci.getTarget_folder())
                        + FilenameUtils.getBaseName(ci.getSource_file().toRegularFile().getAbsolutePath())
                        + ".mp3");

        Event e = new Event();
        e.setType("CONVERT");
        e.setSource_file(ci.getSource_file());
        e.setTarget_file(f1);
        e.setDetail(Utilities.createString(cmdPUBLIC));
        e.setDate(new Date());
        results.add(e);
    }

    return results;
}

From source file:de.uzk.hki.da.convert.PublishVideoConversionStrategy.java

@Override
public List<Event> convertFile(WorkArea wa, ConversionInstruction ci) throws FileNotFoundException {
    if (pkg == null)
        throw new IllegalStateException("pkg not set");

    List<Event> results = new ArrayList<Event>();

    Path.makeFile(wa.dataPath(), pips, "public", ci.getTarget_folder()).mkdirs();
    Path.makeFile(wa.dataPath(), pips, "institution", ci.getTarget_folder()).mkdirs();

    String cmdPUBLIC[] = new String[] { "HandBrakeCLI", "-i", wa.toFile(ci.getSource_file()).getAbsolutePath(),
            "-o",
            wa.dataPath() + "/" + pips.toString() + "/public/" + StringUtilities.slashize(ci.getTarget_folder())
                    + FilenameUtils.getBaseName(wa.toFile(ci.getSource_file()).getAbsolutePath()) + ".mp4",
            "-e", "x264", "-f", "mp4", "-E", "faac" };

    cmdPUBLIC = (String[]) ArrayUtils.addAll(cmdPUBLIC, getRestrictionParametersForAudience("PUBLIC"));

    DAFile pubFile = new DAFile(pips + "/public", StringUtilities.slashize(ci.getTarget_folder())
            + FilenameUtils.getBaseName(wa.toFile(ci.getSource_file()).getAbsolutePath()) + ".mp4");

    if (!executeConversionTool(cmdPUBLIC, wa.toFile(pubFile)))
        throw new RuntimeException("command not succeeded: " + Arrays.toString(cmdPUBLIC));

    Event e = new Event();
    e.setType("CONVERT");
    e.setDetail(StringUtilities.createString(cmdPUBLIC));
    e.setSource_file(ci.getSource_file());
    e.setTarget_file(pubFile);//from w  w w  .j  a v  a  2s.co  m
    e.setDate(new Date());

    String cmdINSTITUTION[] = new String[] { "HandBrakeCLI", "-i",
            wa.toFile(ci.getSource_file()).getAbsolutePath(), "-o",
            wa.dataPath() + "/" + pips + "/institution/" + StringUtilities.slashize(ci.getTarget_folder())
                    + FilenameUtils.getBaseName(wa.toFile(ci.getSource_file()).getAbsolutePath()) + ".mp4",
            "-e", "x264", "-f", "mp4", "-E", "faac" };

    cmdINSTITUTION = (String[]) ArrayUtils.addAll(cmdINSTITUTION,
            getRestrictionParametersForAudience("INSTITUTION"));

    DAFile instFile = new DAFile(WorkArea.TMP_PIPS + "/institution",
            StringUtilities.slashize(ci.getTarget_folder())
                    + FilenameUtils.getBaseName(wa.toFile(ci.getSource_file()).getAbsolutePath()) + ".mp4");

    if (!executeConversionTool(cmdINSTITUTION, wa.toFile(instFile)))
        throw new RuntimeException("command not succeeded: " + Arrays.toString(cmdINSTITUTION));

    Event e2 = new Event();
    e2.setType("CONVERT");
    e2.setDetail(StringUtilities.createString(cmdINSTITUTION));
    e2.setSource_file(ci.getSource_file());
    e2.setTarget_file(instFile);

    results.add(e);
    results.add(e2);

    return results;
}

From source file:fi.aalto.hacid.HAcidTxn.java

Collection<byte[]> getWriteset() {
    // Make column names for the col.family 'writeset'
    HashSet<byte[]> writesetRows = new HashSet<byte[]>(writes.size());
    for (HAcidRowOperation op : writes) {
        writesetRows.add(//from w  w w .j  ava2s  .c o  m
                ArrayUtils.addAll(ArrayUtils.addAll(op.hacidtable.getTableName(), Bytes.toBytes(":")), op.row));
    }
    return writesetRows;
}

From source file:de.uzk.hki.da.convert.PublishAudioConversionStrategy.java

@Override
public List<Event> convertFile(WorkArea wa, ConversionInstruction ci) throws FileNotFoundException {
    if (object == null)
        throw new IllegalStateException("object not set");

    if (cliConnector == null)
        throw new IllegalStateException("cliConnector not set");

    Path.makeFile(wa.dataPath(), pips, "public", ci.getTarget_folder()).mkdirs();
    Path.makeFile(wa.dataPath(), pips, "institution", ci.getTarget_folder()).mkdirs();

    List<Event> results = new ArrayList<Event>();

    for (String audience : audiences) {

        Path source = Path.make(wa.toFile(ci.getSource_file()).getAbsolutePath());
        Path target = Path.make(wa.dataPath(), pips, audience.toLowerCase(), ci.getTarget_folder(),
                FilenameUtils.getBaseName(wa.toFile(ci.getSource_file()).getAbsolutePath()) + ".mp3");
        logger.debug("source:" + FilenameUtils.getBaseName(wa.toFile(ci.getSource_file()).getAbsolutePath()));

        String cmdPUBLIC[] = new String[] { "sox", source.toString(), target.toString() };
        logger.debug("source:" + source);
        logger.debug("target:" + target);
        ProcessInformation pi = null;//from w  w  w . ja va  2 s. c  om
        try {
            pi = cliConnector.runCmdSynchronously(
                    (String[]) ArrayUtils.addAll(cmdPUBLIC, getDurationRestrictionsForAudience(audience)));
        } catch (IOException e1) {
            throw new RuntimeException("command not succeeded, not found!");
        }
        if (pi.getExitValue() != 0)
            throw new RuntimeException("command not succeeded");

        DAFile f1 = new DAFile(pips + "/" + audience.toLowerCase(),
                StringUtilities.slashize(ci.getTarget_folder())
                        + FilenameUtils.getBaseName(wa.toFile(ci.getSource_file()).getAbsolutePath()) + ".mp3");

        Event e = new Event();
        e.setType("CONVERT");
        e.setSource_file(ci.getSource_file());
        e.setTarget_file(f1);
        e.setDetail(StringUtilities.createString(cmdPUBLIC));
        e.setDate(new Date());
        results.add(e);
    }

    return results;
}

From source file:edu.jhu.pha.vospace.node.NodePath.java

public NodePath append(NodePath newPath) {
    return new NodePath((String[]) ArrayUtils.addAll(pathTokens, newPath.getNodeOuterPathArray()));
}

From source file:edu.utdallas.bigsecret.cipher.AesCtr.java

/**
 * Encrypts input data with AES CTR mode.
 * @param data Input byte array.//w w w .ja  va 2  s  .  c o  m
 * @return Encryption result.
 * @throws Exception Throws exception if there is no data to encrypt.<br>
 *                 May throw exception based on Javax.Crypto.Cipher class
 */
public byte[] encrypt(byte[] data) throws Exception {
    //check if there is data to encrypt
    if (data.length == 0) {
        throw new Exception("No data to encrypt");
    }

    //create iv
    byte[] iv = new byte[BLOCK_SIZE_BYTES];
    byte[] randomNumber = (new BigInteger(BLOCK_SIZE_BITS, m_secureRandom)).toByteArray();
    int a;
    for (a = 0; a < randomNumber.length && a < BLOCK_SIZE_BYTES; a++)
        iv[a] = randomNumber[a];
    for (; a < BLOCK_SIZE_BYTES; a++)
        iv[a] = 0;

    //init cipher instance
    m_cipher.init(javax.crypto.Cipher.ENCRYPT_MODE, m_keySpec, new IvParameterSpec(iv));

    //return concatenation of iv + encrypted data      
    return ArrayUtils.addAll(iv, m_cipher.doFinal(data));
}

From source file:com.opengamma.analytics.financial.provider.sensitivity.inflation.ParameterSensitivityInflationMatrixCalculator.java

/**
 * Computes the sensitivity with respect to the parameters from the point sensitivities.
 * @param sensitivity The point sensitivity.
 * @param inflation The inflation provider. Not null.
 * @param curvesSet The set of curves for which the sensitivity will be computed. Not null.
 * @return The sensitivity (as a Matrix). The order of the sensitivity is by curve as provided by the curvesSet.
 *///from  w w  w .  j  a  v a  2s. c om
@Override
public DoubleMatrix1D pointToParameterSensitivity(final InflationSensitivity sensitivity,
        final InflationProviderInterface inflation, final Set<String> curvesSet) {
    SimpleParameterSensitivity ps = new SimpleParameterSensitivity();

    final Map<String, List<DoublesPair>> sensitivityPriceCurve = sensitivity.getPriceCurveSensitivities();
    for (final Map.Entry<String, List<DoublesPair>> entry : sensitivityPriceCurve.entrySet()) {
        if (curvesSet.contains(entry.getKey())) {
            ps = ps.plus(entry.getKey(), new DoubleMatrix1D(
                    inflation.parameterInflationSensitivity(entry.getKey(), entry.getValue())));
        }
    }

    // YieldAndDiscount
    final Map<String, List<DoublesPair>> sensitivityDsc = sensitivity.getYieldDiscountingSensitivities();
    for (final Map.Entry<String, List<DoublesPair>> entry : sensitivityDsc.entrySet()) {
        if (curvesSet.contains(entry.getKey())) {
            ps = ps.plus(entry.getKey(), new DoubleMatrix1D(
                    inflation.getMulticurveProvider().parameterSensitivity(entry.getKey(), entry.getValue())));
        }
    }
    // Forward
    final Map<String, List<ForwardSensitivity>> sensitivityFwd = sensitivity.getForwardSensitivities();
    for (final Map.Entry<String, List<ForwardSensitivity>> entry : sensitivityFwd.entrySet()) {
        if (curvesSet.contains(entry.getKey())) {
            ps = ps.plus(entry.getKey(), new DoubleMatrix1D(inflation.getMulticurveProvider()
                    .parameterForwardSensitivity(entry.getKey(), entry.getValue())));
        }
    }

    // By curve name in the curves set (to have the right order)
    double[] result = new double[0];
    for (final String name : curvesSet) {
        final DoubleMatrix1D sensi = ps.getSensitivity(name);
        if (sensi != null) {
            result = ArrayUtils.addAll(result, sensi.getData());
        } else {
            result = ArrayUtils.addAll(result, new double[inflation.getNumberOfParameters(name)]);
        }
    }
    return new DoubleMatrix1D(result);
}