Example usage for org.apache.commons.lang3 ArrayUtils toPrimitive

List of usage examples for org.apache.commons.lang3 ArrayUtils toPrimitive

Introduction

In this page you can find the example usage for org.apache.commons.lang3 ArrayUtils toPrimitive.

Prototype

public static boolean[] toPrimitive(final Boolean[] array) 

Source Link

Document

Converts an array of object Booleans to primitives.

This method returns null for a null input array.

Usage

From source file:org.hawkular.datamining.forecast.utils.Utils.java

public static double standardDeviation(Double[] residuals) {
    double[] primitiveResiduals = ArrayUtils.toPrimitive(residuals);
    StandardDeviation standardDeviation = new StandardDeviation();
    return standardDeviation.evaluate(primitiveResiduals);
}

From source file:org.jnbt.ByteArrayTag.java

@Override
public void add(int index, Byte b) {
    byte[] value = getValue();
    Byte[] bytes = ArrayUtils.toObject(value);
    List<Byte> list = new ArrayList<Byte>(Arrays.asList(bytes));
    list.add(index, (byte) 0);
    bytes = list.toArray(bytes);/*from   w w w  .  j  a v a  2s  . c o m*/
    value = ArrayUtils.toPrimitive(bytes);
    setValue(value);
}

From source file:org.jnbt.ByteArrayTag.java

@Override
public void remove(int index) {
    byte[] value = getValue();
    Byte[] bytes = ArrayUtils.toObject(value);
    List<Byte> list = new ArrayList<Byte>(Arrays.asList(bytes));
    list.remove(index);/*  w ww.  ja  v  a2  s.c om*/
    bytes = new Byte[list.size()];
    list.toArray(bytes);
    value = ArrayUtils.toPrimitive(bytes);
    setValue(value);
}

From source file:org.jodconverter.boot.autoconfigure.JodConverterLocalAutoConfiguration.java

private OfficeManager createOfficeManager() {

    final LocalOfficeManager.Builder builder = LocalOfficeManager.builder();

    if (!StringUtils.isBlank(properties.getPortNumbers())) {
        builder.portNumbers(//from   w  ww .j av a  2  s.  c om
                ArrayUtils.toPrimitive(Stream.of(StringUtils.split(properties.getPortNumbers(), ", "))
                        .map(str -> NumberUtils.toInt(str, 2002)).toArray(Integer[]::new)));
    }

    builder.officeHome(properties.getOfficeHome());
    builder.workingDir(properties.getWorkingDir());
    builder.templateProfileDir(properties.getTemplateProfileDir());
    builder.killExistingProcess(properties.isKillExistingProcess());
    builder.processTimeout(properties.getProcessTimeout());
    builder.processRetryInterval(properties.getProcessRetryInterval());
    builder.taskExecutionTimeout(properties.getTaskExecutionTimeout());
    builder.maxTasksPerProcess(properties.getMaxTasksPerProcess());
    builder.taskQueueTimeout(properties.getTaskQueueTimeout());

    // Starts the manager
    return builder.build();
}

From source file:org.jodconverter.spring.JodConverterBean.java

@Override
public void afterPropertiesSet() throws OfficeException { // NOSONAR

    final LocalOfficeManager.Builder builder = LocalOfficeManager.builder();

    if (!StringUtils.isBlank(portNumbers)) {
        builder.portNumbers(ArrayUtils.toPrimitive(Stream.of(StringUtils.split(portNumbers, ", "))
                .map(str -> NumberUtils.toInt(str, 2002)).toArray(Integer[]::new)));
    }//from ww  w  . j  av a2  s .co m

    builder.officeHome(officeHome);
    builder.workingDir(workingDir);
    builder.templateProfileDir(templateProfileDir);
    builder.killExistingProcess(killExistingProcess);
    builder.processTimeout(processTimeout);
    builder.processRetryInterval(processRetryInterval);
    builder.taskExecutionTimeout(taskExecutionTimeout);
    builder.maxTasksPerProcess(maxTasksPerProcess);
    builder.taskQueueTimeout(taskQueueTimeout);

    // Starts the manager
    officeManager = builder.build();
    documentConverter = LocalConverter.make(officeManager);
    officeManager.start();
}

From source file:org.kalypso.core.layoutwizard.LayoutParser.java

private ILayoutContainer createContainer(final AbstractContainerType containerType) {
    final String id = containerType.getId();
    // final int style = SWTUtilities.createStyleFromString( containerType.getStyle() );

    if (containerType instanceof net.sourceforge.projects.kalypsobase.layout.SashContainer) {
        final net.sourceforge.projects.kalypsobase.layout.SashContainer sashContainer = (net.sourceforge.projects.kalypsobase.layout.SashContainer) containerType;
        final List<Integer> weights = sashContainer.getWeights();
        final AbstractPartType maximizedChild = (AbstractPartType) sashContainer.getMaximizedChild();
        final String maximizedChildId = maximizedChild == null ? null : maximizedChild.getId();

        final int[] sashWeights = ArrayUtils.toPrimitive(weights.toArray(new Integer[weights.size()]));
        return new SashContainer(id, new SashConfiguration(sashWeights, maximizedChildId));
    }//from w w w .  j  av  a 2 s  .  c  om

    if (containerType instanceof GridContainer) {
        final GridContainer gridContainer = (GridContainer) containerType;
        final GridLayout gridLayout = new GridLayout(gridContainer.getNumColumns(),
                gridContainer.isMakeColumnsEqualWidth());
        gridLayout.marginWidth = gridContainer.getMarginWidth();
        gridLayout.marginHeight = gridContainer.getMarginHeight();

        gridLayout.marginLeft = gridContainer.getMarginLeft();
        gridLayout.marginRight = gridContainer.getMarginRight();
        gridLayout.marginTop = gridContainer.getMarginTop();
        gridLayout.marginBottom = gridContainer.getMarginBottom();

        gridLayout.horizontalSpacing = gridContainer.getHorizontalSpacing();
        gridLayout.verticalSpacing = gridContainer.getVerticalSpacing();

        final String groupText = gridContainer.getText();
        return new GridLayoutContainer(id, gridLayout, groupText);
    }

    if (containerType instanceof TabFolder) {
        return new TabFolderContainer(id);
    }

    if (containerType instanceof TabItem) {
        final TabItem tabItem = (TabItem) containerType;
        final String text = tabItem.getText();
        final String tooltip = tabItem.getTooltip();
        final String image = tabItem.getImage();
        return new TabItemContainer(id, text, tooltip, image);
    }

    throw new UnsupportedOperationException(
            String.format(Messages.getString("LayoutParser_5"), containerType.getClass().getName())); //$NON-NLS-1$
}

From source file:org.kalypso.kalypsomodel1d2d.conv.DiscretisationModel1d2dHandler.java

@Override
public void handle1dSplittedPolynomialsInformation(final String line, final String pStrPolyKind,
        final int pIntNodeId, final int pIntActRangeNr, final List<Double> pListPolyCoeffs,
        final Double pDoubleSlope) {
    if (m_mapQResults == null) {
        initMapsPolynoms();//from w w  w  .j  a v  a  2  s  .c o m
    }
    final IPolynomial1D poly1d = getPolynomial(pIntNodeId, pIntActRangeNr, m_charDomain);

    final String description = pStrPolyKind + pIntActRangeNr;
    poly1d.setName(description);
    poly1d.setDescription(description);
    poly1d.setCoefficients(ArrayUtils.toPrimitive(pListPolyCoeffs.toArray(new Double[pListPolyCoeffs.size()])));
    poly1d.setRange(m_listPolyRanges.get(pIntActRangeNr - 1), m_listPolyRanges.get(pIntActRangeNr));
    m_set1dFlowNodes.add(pIntNodeId);
    if (pDoubleSlope != null) {
        final QIntervallResult lQResult = getOrCreateQResult(pIntNodeId);
        lQResult.setSlope(new BigDecimal(pDoubleSlope));
    }
}

From source file:org.kalypso.kalypsomodel1d2d.ui.map.ElementGeometryHelper.java

/**
 * returns a points array of a polygon specified as an array of {@link GM_Point}
 *//*from   w  w w  .  j  av  a  2s.  c o  m*/
public static int[][] getPolygonAsPointArrays(final GeoTransform projection, final GM_Point[] nodes) {
    final List<Integer> xArray = new ArrayList<>();
    final List<Integer> yArray = new ArrayList<>();

    for (final GM_Point node : nodes) {
        final int x = (int) projection.getDestX(node.getX());
        final int y = (int) projection.getDestY(node.getY());

        xArray.add(x);
        yArray.add(y);

    }

    final int x = (int) projection.getDestX(nodes[0].getX());
    final int y = (int) projection.getDestY(nodes[0].getY());

    xArray.add(x);
    yArray.add(y);

    final int[] xs = ArrayUtils.toPrimitive(xArray.toArray(new Integer[xArray.size()]));
    final int[] ys = ArrayUtils.toPrimitive(yArray.toArray(new Integer[yArray.size()]));

    return new int[][] { xs, ys };
}

From source file:org.kalypso.kalypsomodel1d2d.ui.map.ElementGeometryHelper.java

/**
 * returns a points array of a line specified by two {@link GM_Point}
 *///from   ww w .j  a  va2s .  com
public static int[][] getLineAsPointArrays(final GeoTransform projection, final GM_Point node1,
        final Point currentPos) {
    final List<Integer> xArray = new ArrayList<>();
    final List<Integer> yArray = new ArrayList<>();

    final int x = (int) projection.getDestX(node1.getX());
    final int y = (int) projection.getDestY(node1.getY());

    xArray.add(x);
    yArray.add(y);

    xArray.add(currentPos.x);
    yArray.add(currentPos.y);

    final int[] xs = ArrayUtils.toPrimitive(xArray.toArray(new Integer[xArray.size()]));
    final int[] ys = ArrayUtils.toPrimitive(yArray.toArray(new Integer[yArray.size()]));

    return new int[][] { xs, ys };
}

From source file:org.kalypso.kalypsomodel1d2d.ui.map.grid.LinePointCollector.java

private int[][] getPointArrays(final GeoTransform projection, final GM_Point currentPoint) {
    final List<Integer> xArray = new ArrayList<>();
    final List<Integer> yArray = new ArrayList<>();

    for (int i = 0; i < m_points.size(); i++) {
        final GM_Point point = m_points.get(i);

        final int x = (int) projection.getDestX(point.getX());
        final int y = (int) projection.getDestY(point.getY());

        xArray.add(new Integer(x));
        yArray.add(new Integer(y));
    }/*from   w w  w  . j av a2 s . c o m*/

    if (currentPoint != null) {
        final int x = (int) projection.getDestX(currentPoint.getX());
        final int y = (int) projection.getDestY(currentPoint.getY());

        xArray.add(new Integer(x));
        yArray.add(new Integer(y));
    }

    final int[] xs = ArrayUtils.toPrimitive(xArray.toArray(new Integer[xArray.size()]));
    final int[] ys = ArrayUtils.toPrimitive(yArray.toArray(new Integer[yArray.size()]));

    return new int[][] { xs, ys };
}