List of usage examples for org.apache.commons.lang3 ArrayUtils toPrimitive
public static boolean[] toPrimitive(final Boolean[] array)
Converts an array of object Booleans to primitives.
This method returns null for a null input array.
From source file:edu.pitt.csb.stability.StabilitySearch.java
public void saveSubsampledData(String dir, String prefix) { if (prefix.length() != 0) { prefix = prefix + "_"; }//from ww w . j av a2 s .com for (int s = 0; s < samps.size(); s++) { DataSet dataSubSamp = data.subsetRows(ArrayUtils.toPrimitive(samps.get(s).toArray(new Integer[0]))); } }
From source file:net.sf.mzmine.modules.peaklistmethods.peakpicking.adap3decompositionV1_5.ADAP3DecompositionV1_5SetupDialog.java
@Override public void actionPerformed(ActionEvent e) { super.actionPerformed(e); final Object source = e.getSource(); if (source.equals(preview)) { if (preview.isSelected()) { // Set the height of the preview to 200 cells, so it will span // the whole vertical length of the dialog (buttons are at row // no 100). Also, we set the weight to 10, so the preview // component will consume most of the extra available space. mainPanel.add(pnlTabs, 3, 0, 1, 200, 10, 10, GridBagConstraints.BOTH); pnlVisible.add(pnlLabelsFields, BorderLayout.CENTER); comboPeakList.setSelectedIndex(0); } else {//from ww w .ja va2 s . c o m mainPanel.remove(pnlTabs); pnlVisible.remove(pnlLabelsFields); } updateMinimumSize(); pack(); setLocationRelativeTo(MZmineCore.getDesktop().getMainWindow()); } else if (source.equals(comboPeakList)) { // ------------------------- // Retrieve current PeakList // ------------------------- final PeakList peakList = (PeakList) comboPeakList.getSelectedItem(); final List<Peak> peaks = ADAP3DecompositionV1_5Task.getPeaks(peakList, parameterSet.getParameter(ADAP3DecompositionV1_5Parameters.EDGE_TO_HEIGHT_RATIO).getValue(), parameterSet.getParameter(ADAP3DecompositionV1_5Parameters.DELTA_TO_HEIGHT_RATIO).getValue()); // --------------------------------- // Calculate retention time clusters // --------------------------------- List<Double> retTimeValues = new ArrayList<>(); List<Double> mzValues = new ArrayList<>(); List<Double> colorValues = new ArrayList<>(); retTimeCluster(peaks, retTimeValues, mzValues, colorValues); final int size = retTimeValues.size(); retTimeMZPlot.updateData(ArrayUtils.toPrimitive(retTimeValues.toArray(new Double[size])), ArrayUtils.toPrimitive(mzValues.toArray(new Double[size])), ArrayUtils.toPrimitive(colorValues.toArray(new Double[size]))); // ------------------------ // Calculate shape clusters // ------------------------ final ComboClustersItem item = (ComboClustersItem) comboClusters.getSelectedItem(); if (item != null) { final List<List<NavigableMap<Double, Double>>> shapeClusters = new ArrayList<>(); final List<List<String>> texts = new ArrayList<>(); final List<Double> colors = new ArrayList<>(); shapeCluster(item.cluster, shapeClusters, texts, colors); retTimeIntensityPlot.updateData(shapeClusters, colors, texts, null); } } else if (source.equals(comboClusters)) { // ------------------------ // Calculate shape clusters // ------------------------ final ComboClustersItem item = (ComboClustersItem) comboClusters.getSelectedItem(); if (item != null) { final List<List<NavigableMap<Double, Double>>> shapeClusters = new ArrayList<>(); final List<List<String>> texts = new ArrayList<>(); final List<Double> colors = new ArrayList<>(); shapeCluster(item.cluster, shapeClusters, texts, colors); retTimeIntensityPlot.updateData(shapeClusters, colors, texts, null); } } }
From source file:dk.dma.ais.packet.AisPacketFiltersStateful.java
/** * Return false if this message is known to be related to a target with a navstat outside the given list. *//*from w ww .j av a2s .c o m*/ public Predicate<AisPacket> filterOnTargetNavigationalStatus(Integer[] navstats) { final int[] list = ArrayUtils.toPrimitive(navstats); Arrays.sort(list); return new Predicate<AisPacket>() { public boolean test(AisPacket p) { aisPacketStream.add(p); // Update state final int mmsi = getMmsi(p); // Get MMSI in question final int navstat = getNavstat(mmsi); // Extract navstat no. - if we know it return navstat < 0 ? false : Arrays.binarySearch(list, navstat) >= 0; } public String toString() { return "navstat in " + skipBrackets(Arrays.toString(list)); } }; }
From source file:com.github.jessemull.microflex.util.DoubleUtil.java
/** * Converts a list of doubles to an array of longs. * @param List<Double> list of longs * @return array of longs *//* w w w . j a v a 2s .c o m*/ public static long[] toLongArray(List<Double> list) { for (Double val : list) { if (!OverFlowUtil.longOverflow(val)) { OverFlowUtil.overflowError(val); } } return ArrayUtils.toPrimitive(list.toArray(new Long[list.size()])); }
From source file:com.plotsquared.iserver.core.Worker.java
private void handle() { final RequestHandler requestHandler = server.router.match(request); String textContent = ""; byte[] bytes = empty; final Optional<Session> session = server.sessionManager.getSession(request, output); if (session.isPresent()) { request.setSession(session.get()); } else {//from ww w . j a v a2s. c o m request.setSession(server.sessionManager.createSession(request, output)); } boolean shouldCache = false; boolean cache = false; ResponseBody body; try { if (!requestHandler.getValidationManager().isEmpty()) { // Validate post requests if (request.getQuery().getMethod() == HttpMethod.POST) { for (final RequestValidation<PostRequest> validator : requestHandler.getValidationManager() .getValidators(RequestValidation.ValidationStage.POST_PARAMETERS)) { final RequestValidation.ValidationResult result = validator .validate(request.getPostRequest()); if (!result.isSuccess()) { throw new ValidationException(result); } } } else { for (final RequestValidation<Request.Query> validator : requestHandler.getValidationManager() .getValidators(RequestValidation.ValidationStage.GET_PARAMETERS)) { final RequestValidation.ValidationResult result = validator.validate(request.getQuery()); if (!result.isSuccess()) { throw new ValidationException(result); } } } } if (CoreConfig.Cache.enabled && requestHandler instanceof CacheApplicable && ((CacheApplicable) requestHandler).isApplicable(request)) { cache = true; if (!server.cacheManager.hasCache(requestHandler)) { shouldCache = true; } } if (!cache || shouldCache) { // Either it's a non-cached view, or there is no cache stored body = requestHandler.handle(request); } else { // Just read from memory body = server.cacheManager.getCache(requestHandler); } boolean skip = false; if (body == null) { final Object redirect = request.getMeta("internalRedirect"); if (redirect != null && redirect instanceof Request) { this.request = (Request) redirect; this.request.removeMeta("internalRedirect"); handle(); return; } else { skip = true; } } if (skip) { return; } if (shouldCache) { server.cacheManager.setCache(requestHandler, body); } if (body.isText()) { textContent = body.getContent(); } else { bytes = body.getBytes(); } for (final Map.Entry<String, String> postponedCookie : request.postponedCookies.entrySet()) { body.getHeader().setCookie(postponedCookie.getKey(), postponedCookie.getValue()); } // Start: CTYPE // Desc: To allow worker procedures to filter based on content type final Optional<String> contentType = body.getHeader().get(Header.HEADER_CONTENT_TYPE); if (contentType.isPresent()) { request.addMeta("content_type", contentType.get()); } else { request.addMeta("content_type", null); } // End: CTYPE if (body.isText()) { for (final WorkerProcedure.Handler<String> handler : workerProcedureInstance.getStringHandlers()) { textContent = handler.act(requestHandler, request, textContent); } bytes = textContent.getBytes(); } if (!workerProcedureInstance.getByteHandlers().isEmpty()) { Byte[] wrapper = ArrayUtils.toObject(bytes); for (final WorkerProcedure.Handler<Byte[]> handler : workerProcedureInstance.getByteHandlers()) { wrapper = handler.act(requestHandler, request, wrapper); } bytes = ArrayUtils.toPrimitive(wrapper); } } catch (final Exception e) { body = new ViewException(e).generate(request); bytes = body.getContent().getBytes(); if (CoreConfig.verbose) { e.printStackTrace(); } } boolean gzip = false; if (CoreConfig.gzip) { if (request.getHeader("Accept-Encoding").contains("gzip")) { gzip = true; body.getHeader().set(Header.HEADER_CONTENT_ENCODING, "gzip"); } else { Message.CLIENT_NOT_ACCEPTING_GZIP.log(request.getHeaders()); } } if (CoreConfig.contentMd5) { body.getHeader().set(Header.HEADER_CONTENT_MD5, md5Checksum(bytes)); } body.getHeader().apply(output); try { if (gzip) { try { bytes = compress(bytes); } catch (final IOException e) { new RuntimeException("( GZIP ) Failed to compress the bytes").printStackTrace(); } } output.write(bytes); } catch (final Exception e) { new RuntimeException("Failed to write to the client", e).printStackTrace(); } try { output.flush(); } catch (final Exception e) { new RuntimeException("Failed to flush to the client", e).printStackTrace(); } if (!server.silent) { server.log("Request was served by '%s', with the type '%s'. The total length of the content was '%s'", requestHandler.getName(), body.isText() ? "text" : "bytes", bytes.length); } request.setValid(false); }
From source file:net.larry1123.elec.util.test.config.AbstractConfigTest.java
public void LongArrayTest(String fieldName, Field testField) { try {// w w w . ja v a 2 s.co m long[] testFieldValue = ArrayUtils.toPrimitive((Long[]) testField.get(getConfigBase())); Assert.assertTrue(ArrayUtils.isEquals(getPropertiesFile().getLongArray(fieldName), testFieldValue)); } catch (IllegalAccessException e) { assertFailFieldError(fieldName); } }
From source file:com.github.jessemull.microflex.util.IntegerUtil.java
/** * Converts a list of integers to an array of longs. * @param List<Integer> list of longs * @return array of longs *//*from w w w . ja v a 2 s . co m*/ public static long[] toLongArray(List<Integer> list) { return ArrayUtils.toPrimitive(list.toArray(new Long[list.size()])); }
From source file:com.money.manager.ex.reports.IncomeVsExpensesListFragment.java
@Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); ArrayList<Integer> years = new ArrayList<Integer>(); for (int i = 0; i < mYearsSelected.size(); i++) { if (mYearsSelected.get(mYearsSelected.keyAt(i))) { years.add(mYearsSelected.keyAt(i)); }/*www .j av a 2 s. co m*/ } outState.putIntArray(KEY_BUNDLE_YEAR, ArrayUtils.toPrimitive(years.toArray(new Integer[0]))); }
From source file:com.github.jessemull.microflex.util.BigIntegerUtil.java
/** * Converts a list of BigIntegers to an array of floats. * @param List<BigInteger> list of BigIntegers * @return array of floats *//*from w ww .j a v a 2s . c o m*/ public static float[] toFloatArray(List<BigInteger> list) { for (BigInteger val : list) { if (!OverFlowUtil.floatOverflow(val)) { OverFlowUtil.overflowError(val); } } return ArrayUtils.toPrimitive(list.toArray(new Float[list.size()])); }
From source file:com.github.jessemull.microflex.util.BigDecimalUtil.java
/** * Converts a list of BigDecimals to an array of floats. * @param List<BigDecimal> list of BigDecimals * @return array of floats *//*from ww w . j a v a2 s.c o m*/ public static float[] toFloatArray(List<BigDecimal> list) { for (BigDecimal val : list) { if (!OverFlowUtil.floatOverflow(val)) { OverFlowUtil.overflowError(val); } } return ArrayUtils.toPrimitive(list.toArray(new Float[list.size()])); }