Example usage for java.util Arrays copyOf

List of usage examples for java.util Arrays copyOf

Introduction

In this page you can find the example usage for java.util Arrays copyOf.

Prototype

public static boolean[] copyOf(boolean[] original, int newLength) 

Source Link

Document

Copies the specified array, truncating or padding with false (if necessary) so the copy has the specified length.

Usage

From source file:com.qcadoo.view.api.exception.ExceptionInfo.java

public String[] getMessageExplanationArgs() {
    return Arrays.copyOf(messageExplanationArgs, messageExplanationArgs.length);
}

From source file:de.shadowhunt.subversion.internal.PropertiesUpdateOperation.java

PropertiesUpdateOperation(final URI repository, final Resource resource, final Type type,
        @CheckForNull final String lockToken, final ResourceProperty... properties) {
    super(repository);
    this.resource = resource;
    this.type = type;
    this.lockToken = lockToken;
    this.properties = Arrays.copyOf(properties, properties.length);
}

From source file:com.opengamma.analytics.math.statistics.descriptive.PartialMomentCalculator.java

/**
 * @param x The array of data, not null or empty
 * @return The partial moment//from  w  w w .ja  v  a  2  s.  co m
 */
@Override
public Double evaluate(final double[] x) {
    Validate.notNull(x, "x");
    Validate.isTrue(x.length > 0, "x cannot be empty");
    final int n = x.length;
    final double[] copyX = Arrays.copyOf(x, n);
    Arrays.sort(copyX);
    double sum = 0;
    if (_useDownSide) {
        int i = 0;
        if (copyX[i] > _threshold) {
            return 0.;
        }
        while (i < n && copyX[i] < _threshold) {
            sum += (copyX[i] - _threshold) * (copyX[i] - _threshold);
            i++;
        }
        return Math.sqrt(sum / i);
    }
    int i = n - 1;
    int count = 0;
    if (copyX[i] < _threshold) {
        return 0.;
    }
    while (i >= 0 && copyX[i] > _threshold) {
        sum += (copyX[i] - _threshold) * (copyX[i] - _threshold);
        count++;
        i--;
    }
    return Math.sqrt(sum / count);
}

From source file:com.opengamma.analytics.math.matrix.DoubleMatrix1D.java

/**
 * Convert the vector to a double array.
 * As its elements are copied, the array is independent from the vector data.
 * @return An array containing a copy of vector elements
 *//* www.j  a  v a 2 s .  com*/
public double[] toArray() {
    return Arrays.copyOf(_data, _elements);
}

From source file:com.opengamma.analytics.math.curve.ObjectsCurve.java

/**
 * //www  . ja  va2s.c  o  m
 * @param xData An array of <i>x</i> data, not null
 * @param yData An array of <i>y</i> data, not null, contains same number of entries as <i>x</i>
 * @param isSorted Is the <i>x</i>-data sorted
 */
public ObjectsCurve(final T[] xData, final U[] yData, final boolean isSorted) {
    super();
    ArgumentChecker.notNull(xData, "x data");
    ArgumentChecker.notNull(yData, "y data");
    _n = xData.length;
    ArgumentChecker.isTrue(_n == yData.length, "size of x data {} does not match size of y data {}", _n,
            yData.length);
    _xData = Arrays.copyOf(xData, _n);
    _yData = Arrays.copyOf(yData, _n);
    for (int i = 0; i < _n; i++) {
        ArgumentChecker.notNull(xData[i], "element " + i + " of x data");
        ArgumentChecker.notNull(yData[i], "element " + i + " of y data");
    }
    if (!isSorted) {
        ParallelArrayBinarySort.parallelBinarySort(_xData, _yData);
    }
}

From source file:jenkins.plugins.publish_over.helper.InputStreamMatcher.java

public InputStreamMatcher(final byte[] expectedContents) {
    this.expectedContents = Arrays.copyOf(expectedContents, expectedContents.length);
}

From source file:io.warp10.continuum.gts.GTSOutliersHelper.java

protected static double medianAbsoluteDeviation(GeoTimeSerie gts, double median) {
    double[] copy = Arrays.copyOf(gts.doubleValues, gts.values);
    for (int i = 0; i < gts.values; i++) {
        copy[i] -= median;/*from   ww  w .  j  a  v a 2 s. co  m*/
        copy[i] = Math.abs(copy[i]);
    }
    Arrays.sort(copy);

    return gts.values % 2 == 0 ? (copy[gts.values / 2] + copy[gts.values / 2 - 1]) / 2 : copy[gts.values / 2];
}

From source file:com.smartitengineering.event.hub.spi.db.PersistentEvent.java

public void setContent(byte[] content) {
    this.content = Arrays.copyOf(content, content.length);
}

From source file:com.qcadoo.model.api.validators.ErrorMessage.java

/**
 * Return validation error message's vars.
 * 
 * @return message's vars
 */
public String[] getVars() {
    return Arrays.copyOf(vars, vars.length);
}

From source file:com.cloudera.sqoop.testutil.HsqldbTestServer.java

public static String[] getFieldNames() {
    return Arrays.copyOf(TWO_INT_TABLE_FIELDS, TWO_INT_TABLE_FIELDS.length);
}