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:dylemator.UserList.java

private void filenameComboActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_filenameComboActionPerformed
    Object item = this.filenameCombo.getSelectedItem();
    exportData = new ArrayList<String[]>();
    File file = new File(item.toString());
    if (file.exists()) {
        String datePattern = "(\\d+-\\d+-\\d+)";
        Pattern r = Pattern.compile(datePattern);
        Matcher m = r.matcher(file.getName());
        String fileDate;/* w ww .  j  a  v  a  2 s  .c  o  m*/
        if (m.find()) {
            fileDate = m.group(0);
        } else
            fileDate = new Date(file.lastModified()).toString();

        DefaultTableModel model = (DefaultTableModel) this.personsTable.getModel();
        model.setRowCount(0);
        model.setColumnCount(0);
        try {
            InputStreamReader input = new FileReader(file);
            BufferedReader bufferReader;
            bufferReader = new BufferedReader(input);
            // headers
            String headerLine = bufferReader.readLine();
            String[] headers = headerLine.split(";");
            // kod osoby i data badania
            String[] userHeaders = new String[] { headers[0], headers[1] };
            String[] valueHeaders = Arrays.copyOfRange(headers, 4, headers.length);
            Object[] allHeaders = ArrayUtils.addAll(userHeaders, valueHeaders);

            for (int header = 0; header < allHeaders.length; header++) {
                model.addColumn(allHeaders[header]);

            }
            exportData.add((String[]) allHeaders);

            String line;
            while ((line = bufferReader.readLine()) != null) {
                String[] fields = line.split(";");
                String[] userFields = new String[] { fields[0], fileDate };
                String[] valueFields = Arrays.copyOfRange(fields, 4, fields.length);
                Object[] allValues = ArrayUtils.addAll(userFields, valueFields);
                model.addRow(allValues);
                exportData.add((String[]) allValues);
            }
        } catch (FileNotFoundException ex) {
            Logger.getLogger(FindDialog.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(FindDialog.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

From source file:gda.device.detector.countertimer.BufferedScaler.java

public void setReturnCountRates(Boolean returnCountRates) {
    if (!timeChannelRequired && returnCountRates) {
        timeChannelRequired = true;// ww w  . j  a  v a 2 s.com
        extraNames = (String[]) ArrayUtils.addAll(new String[] { "time" }, this.extraNames);
        outputFormat = (String[]) ArrayUtils.addAll(new String[] { this.outputFormat[0] }, this.outputFormat);
    } else if (timeChannelRequired && this.returnCountRates && !returnCountRates) {
        timeChannelRequired = false;
        extraNames = (String[]) ArrayUtils.remove(this.extraNames, 0);
        outputFormat = (String[]) ArrayUtils.remove(this.outputFormat, 0);
    }
    this.returnCountRates = returnCountRates;
}

From source file:hydrograph.ui.propertywindow.utils.Utils.java

/**
 * //  w  w w  .  j  a  v  a2 s  .  co m
 * loading the properties files
 */
public void loadProperties() {
    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    if (page.getActiveEditor().getEditorInput() instanceof IFileEditorInput) {
        IFileEditorInput input = (IFileEditorInput) page.getActiveEditor().getEditorInput();
        List<File> paramNameList = null;
        IFile file = input.getFile();
        IProject activeProject = file.getProject();
        final File globalparamFilesPath = new File(
                activeProject.getLocation().toString() + "/" + "globalparam");
        final File localParamFilePath = new File(activeProject.getLocation().toString() + "/" + "param");
        File[] files = (File[]) ArrayUtils.addAll(listFilesForFolder(globalparamFilesPath),
                listFilesForFolder(localParamFilePath));
        if (files != null) {
            paramNameList = Arrays.asList(files);
            getParamMap(paramNameList);
        }
    }
}

From source file:com.tesora.dve.server.connectionmanager.loaddata.LoadDataBlockExecutor.java

static byte[] appendPartialBlockData(MyLoadDataInfileContext loadDataInfileContext, byte[] dataBlock) {
    byte[] prevDataBlock = loadDataInfileContext.readPartialInfileDataBlock();
    if (prevDataBlock == null) {
        return dataBlock;
    }/*from  ww  w . j  a v a  2  s.c om*/
    return ArrayUtils.addAll(prevDataBlock, dataBlock);
}

From source file:hydrograph.ui.common.property.util.Utils.java

/**
 * /*from w w  w .j a v a  2  s. c om*/
 * loading the properties files
 */
public void loadProperties() {
    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    if (page.getActiveEditor().getEditorInput() instanceof IFileEditorInput) {
        IFileEditorInput input = (IFileEditorInput) page.getActiveEditor().getEditorInput();
        List<File> paramNameList = null;
        IFile file = input.getFile();
        IProject activeProject = file.getProject();
        final File globalparamFilesPath = new File(
                activeProject.getLocation().toString() + "/" + "globalparam");
        final File localParamFilePath = new File(
                activeProject.getLocation().toString() + "/" + Constants.PARAM_FOLDER);
        File[] files = (File[]) ArrayUtils.addAll(listFilesForFolder(globalparamFilesPath),
                getJobsPropertyFile(localParamFilePath, file));
        if (files != null) {
            paramNameList = Arrays.asList(files);
            getParamMap(paramNameList, null);
        }
    }
}

From source file:gda.device.detector.addetector.ADDetectorTest.java

@Test
public void testGetExtraNamesCentroid() {
    enableStatsAndCentroid(false, true);
    assertArrayEquals(ArrayUtils.addAll(new String[] { "count_time" }, CENTROID_NAMES), det().getExtraNames());
}

From source file:com.ephesoft.dcma.encryption.core.EncryptorDecryptor.java

/**
 * This method encrypts the string provided.
 * @param decryptedString {@link String}
 * @return {@link String}//  w w w. j  a  v  a 2 s  . c o m
 * @throws CryptographyException {@link CryptographyException}
 */
public String encryptString(String decryptedString) throws CryptographyException {
    byte[] salt = generateSalt(EncryptionConstants.SALT_LENGTH);
    byte[] decryptedStringInBytes;
    try {
        decryptedStringInBytes = decryptedString.getBytes("UTF8");
    } catch (UnsupportedEncodingException e) {
        LOGGER.error("Could not encode string using UTF-8", e);
        throw new CryptographyException("Could not encode string using UTF-8", e);
    }
    byte[] encryptedByte = startCrypting(decryptedStringInBytes, salt, true);
    byte[] result = ArrayUtils.addAll(salt, encryptedByte);
    result = Base64.encodeBase64(result);
    return new String(result);
}

From source file:gda.device.detector.addetector.ADDetectorTest.java

@Test
public void testGetExtraNamesStats() {
    enableStatsAndCentroid(true, false);
    assertArrayEquals(ArrayUtils.addAll(new String[] { "count_time" }, STATS_NAMES), det().getExtraNames());
}

From source file:info.magnolia.templating.functions.TemplatingFunctionsTest.java

@Test
public void testChildrenFromNode() throws RepositoryException {
    // GIVEN//from w w  w  .  j av a  2 s  .  c  o  m
    String[] expectedNamesDepth1 = (String[]) ArrayUtils.addAll(DEPTH_2_COMPONENT_NAMES, DEPTH_2_PAGE_NAMES);

    // WHEN
    List<Node> resultChildNodes = functions.children(topPage);

    // THEN
    assertNodesListEqualStringDefinitions(expectedNamesDepth1, resultChildNodes);
}

From source file:net.itransformers.utils.graphmlmerge.GraphmlMergeTestCase.java

@Test
public void testMerge4() throws IOException, URISyntaxException {

    File f1 = new File(getClass().getResource("/graphmlmerge/1.graphml").toURI());
    File f2 = new File(getClass().getResource("/graphmlmerge/2.graphml").toURI());
    File f3 = new File(getClass().getResource("/graphmlmerge/5.graphml").toURI());
    File f3Actual = File.createTempFile("graphml_merge", ".xml");

    Map<String, MergeConflictResolver> edgeConflictResolver = new HashMap<String, MergeConflictResolver>();
    Map<String, MergeConflictResolver> vertexConflictResolver = new HashMap<String, MergeConflictResolver>();
    vertexConflictResolver.put("name", new MergeConflictResolver() {
        @Override/*from   www .  j  a va  2 s .  com*/
        public Object resolveConflict(Object srcValue, Object targetValue) {
            return srcValue + "-" + targetValue;
        }
    });

    edgeConflictResolver.put("method", new MergeConflictResolver() {
        @Override
        public Object resolveConflict(Object srcValue, Object targetValue) {
            // if (srcValue instanceof String && targetValue instanceof String) {
            String[] srcArray = ((String) srcValue).split(",");
            String[] targetArray = ((String) targetValue).split(",");

            String[] both = (String[]) ArrayUtils.addAll(srcArray, targetArray);
            Arrays.sort(both);
            LinkedHashSet<String> m = new LinkedHashSet<String>();
            Collections.addAll(m, both);

            return StringUtils.join(m, ',');

        }
    });

    Map<String, String> edgesTypes = null;
    Map<String, String> vertexTypes = null;
    new GrahmlMerge(edgeConflictResolver, vertexConflictResolver).merge(new File[] { f1, f2 }, f3Actual,
            vertexTypes, edgesTypes, "undirected");
    String xml3 = FileUtils.readFileToString(f3).replaceAll("\r", "");
    String xml3Actual = FileUtils.readFileToString(f3Actual).replaceAll("&#xd;", "");
    xml3Actual = xml3Actual.replaceAll("\r", "");
    Assert.assertEquals(xml3, xml3Actual);
}