Java Array Add addArray(StringBuffer RCode, String name, T[] array, boolean useEquals, boolean isString)

Here you can find the source of addArray(StringBuffer RCode, String name, T[] array, boolean useEquals, boolean isString)

Description

add Array

License

Open Source License

Declaration

public static <T> void addArray(StringBuffer RCode, String name, T[] array, boolean useEquals,
            boolean isString) 

Method Source Code

//package com.java2s;
/*/*from www  . j a v  a 2  s  . c o m*/
 *
 RCaller, A solution for calling R from Java
 Copyright (C) 2010-2015  Mehmet Hakan Satman
    
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU Lesser General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 any later version.
    
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
    
 You should have received a copy of the GNU Lesser General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 *
 * Mehmet Hakan Satman - mhsatman@yahoo.com
 * http://www.mhsatman.com
 * Google code project: https://github.com/jbytecode/rcaller
 * Please visit the blog page with rcaller label:
 * http://stdioe.blogspot.com.tr/search/label/rcaller
 */

public class Main {
    public static <T> void addArray(StringBuffer RCode, String name, T[] array, boolean useEquals,
            boolean isString) {
        if (useEquals) {
            RCode.append(name).append("=").append("c(");
        } else {
            RCode.append(name).append("<-").append("c(");
        }
        for (int i = 0; i < array.length; i++) {
            if (isString) {
                RCode.append("\"").append(array[i]).append("\"");
            } else {
                RCode.append(array[i]);
            }
            if (i < array.length - 1) {
                RCode.append(", ");
            }
        }
        if (useEquals) {
            RCode.append(")");
        } else {
            RCode.append(");").append("\n");
        }
    }
}

Related

  1. addArray(double[] array1, double[] array2)
  2. addArray(int[] a, int p)
  3. addArray(int[] a, int[] b)
  4. addArray(Object[] Old, Object[] New)
  5. addArray(Object[][] first, Object[][]... more)
  6. addArrayAll(byte[] array1, byte[] array2)
  7. addArrayElements(byte[] toArray, byte[] fromArray)
  8. addArrays(final int[] a, final int[] b)
  9. addArrays(float[] arr1, float[] arr2, float[] arr3)