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:org.wikidata.wdtk.storage.datastructures.CountBitsArray.java
/** * This method updates the internal array only if the bit vector has been * changed since the last update or creation of this class. *//*from w w w .j a v a 2 s . c o m*/ void updateCount() { if (this.hasChanged) { this.countArray = ArrayUtils.toPrimitive(getCountList().toArray(new Long[0])); this.hasChanged = false; } }
From source file:org.wikidata.wdtk.storage.datastructures.FindPositionArray.java
/** * This method updates the internal array only if the bit vector has been * changed since the last update or creation of this class. *///from w w w . j a v a 2s . c o m void updateCount() { if (this.hasChanged) { this.positionArray = ArrayUtils.toPrimitive(getPositionList().toArray(new Long[0])); this.hasChanged = false; } }
From source file:pt.lsts.neptus.util.tid.TidReader.java
/** * Writes the date, time and each value passed into a line entry. * @param timeMillis/* w w w. j a v a2 s . co m*/ * @param vals * @throws Exception */ public Data readData() { try { while (true) { String line = reader.readLine(); if (isCommentLine(line)) { processComment(line); continue; } try { line = line.trim(); String[] tokens = line.split(" "); if (tokens.length < 3) continue; Date date; try { date = dateTimeFormatterUTC.parse(tokens[0] + " " + tokens[1]); } catch (Exception e) { try { date = dateTimeFormatterUTC2.parse(tokens[0] + " " + tokens[1]); } catch (Exception e1) { e1.printStackTrace(); continue; } } double height = Double.parseDouble(tokens[2]); ArrayList<Double> others = new ArrayList<>(); if (tokens.length > 3) { for (int i = 3; i < tokens.length; i++) { double val = Double.parseDouble(tokens[i]); others.add(val); } } Data data = new Data(); data.timeMillis = date.getTime(); data.height = height; Double[] othersArrD = others.toArray(new Double[others.size()]); data.other = ArrayUtils.toPrimitive(othersArrD); return data; } catch (Exception e) { continue; } } } catch (Exception e) { return null; } }
From source file:se.inera.intyg.rehabstod.service.export.pdf.PdfExportServiceImpl.java
private PdfPTable createTableColumns(Urval urval, boolean showPatientId, boolean showSrsRisk) { List<Float> tempHeaders = new ArrayList<>(); tempHeaders.add(0.5f); // # radnr if (showPatientId) { tempHeaders.add(1.3f); // personnr }/*www. jav a2 s.co m*/ tempHeaders.add(0.5f); // # lder if (showPatientId) { tempHeaders.add(2f); // namn } tempHeaders.add(0.7f); // Kn if (showPatientId) { tempHeaders.add(2.1f); // Diagnos } else { tempHeaders.add(3.4f); // Diagnos extra bred eftersom vi inte visar patientinfo } tempHeaders.add(1.1f); // Startdatum tempHeaders.add(1.1f); // Slutdatum tempHeaders.add(1.0f); // Lngd tempHeaders.add(0.45f); // Antal tempHeaders.add(2f); // Grader if (Urval.ALL.equals(urval)) { tempHeaders.add(2f); // Lkare } if (showSrsRisk) { tempHeaders.add(1f); // Srs Risk } return new PdfPTable(ArrayUtils.toPrimitive(tempHeaders.toArray(new Float[tempHeaders.size()]))); }
From source file:sg.fxl.topeka.helper.AnswerHelper.java
public static int[] getSelectedIndexes(SparseBooleanArray checkedItems) { List<Integer> selectedIndexes = new ArrayList<>(); if (checkedItems != null) { for (int i = 0; i < checkedItems.size(); i++) { if (checkedItems.valueAt(i)) { selectedIndexes.add(checkedItems.keyAt(i)); }/*from ww w. j a va2 s . c o m*/ } } return ArrayUtils.toPrimitive(selectedIndexes.toArray(new Integer[selectedIndexes.size()])); }
From source file:solidbase.core.plugins.DBWriter.java
private PreparedStatement createStatement(Object[] line) throws SQLException { String[] fieldNames = this.fieldNames; String[] values = this.values; String sql;// w w w .jav a 2s.c om List<Integer> parameterMap = new ArrayList<Integer>(); if (this.sql != null) { sql = this.sql; sql = translateArgument(sql, parameterMap); } else { StringBuilder sql1 = new StringBuilder("INSERT INTO "); sql1.append(this.tableName); // TODO Where else do we need the quotes? if (fieldNames != null) { sql1.append(" ("); for (int i = 0; i < fieldNames.length; i++) { if (i > 0) sql1.append(','); sql1.append(fieldNames[i]); } sql1.append(')'); } if (values != null) { sql1.append(" VALUES ("); for (int i = 0; i < values.length; i++) { if (i > 0) sql1.append(","); String value = values[i]; value = translateArgument(value, parameterMap); sql1.append(value); } sql1.append(')'); } else { int count = line.length; if (fieldNames != null) count = fieldNames.length; // if( prependLineNumber ) // count++; int par = 1; sql1.append(" VALUES (?"); parameterMap.add(par++); while (par <= count) { sql1.append(",?"); parameterMap.add(par++); } sql1.append(')'); } sql = sql1.toString(); } // TODO Google Guava has a Ints.toArray() ? this.parameterMap = ArrayUtils.toPrimitive(parameterMap.toArray(new Integer[parameterMap.size()])); this.sql = sql; return this.processor.prepareStatement(sql); }
From source file:solidbase.core.plugins.SelectProcessor.java
@Override public void init(Column[] columns) { // TODO Error when deselect contains an incorrect columnname List<Integer> temp = new ArrayList<Integer>(); for (int i = 0; i < columns.length; i++) if (!this.deselect.contains(columns[i].getName())) temp.add(i);//from ww w. j av a 2 s. c o m // TODO Google Guava has a Ints.toArray() ? int[] mapping = this.mapping = ArrayUtils.toPrimitive(temp.toArray(new Integer[temp.size()])); this.outColumns = new Column[mapping.length]; for (int i = 0; i < mapping.length; i++) this.outColumns[i] = columns[mapping[i]]; this.sink.init(this.outColumns); }
From source file:sturesy.items.vote.MultipleVote.java
/** * Creates a new Vote with multiple answers * /*from w w w. ja va2 s .co m*/ * @param id * id of Voter * @param timediffMilliseconds * time difference from beginning * @param votes * arraylist of votes */ public MultipleVote(String id, long timediffMilliseconds, ArrayList<Short> votes) { super(id, timediffMilliseconds); _votes = ArrayUtils.toPrimitive(votes.toArray(new Short[0])); }
From source file:thaumic.tinkerer.common.block.tile.TileEnchanter.java
public void writeCustomNBT(NBTTagCompound par1NBTTagCompound) { par1NBTTagCompound.setIntArray(TAG_LEVELS, ArrayUtils.toPrimitive(levels.toArray(new Integer[levels.size()]))); par1NBTTagCompound.setIntArray(TAG_ENCHANTS, ArrayUtils.toPrimitive(enchantments.toArray(new Integer[enchantments.size()]))); NBTTagCompound totalAspectsCmp = new NBTTagCompound(); totalAspects.writeToNBT(totalAspectsCmp); NBTTagCompound currentAspectsCmp = new NBTTagCompound(); currentAspects.writeToNBT(currentAspectsCmp); par1NBTTagCompound.setBoolean(TAG_WORKING, working); par1NBTTagCompound.setTag(TAG_TOTAL_ASPECTS, totalAspectsCmp); par1NBTTagCompound.setTag(TAG_CURRENT_ASPECTS, currentAspectsCmp); NBTTagList var2 = new NBTTagList(); for (int var3 = 0; var3 < inventorySlots.length; ++var3) { if (inventorySlots[var3] != null) { NBTTagCompound var4 = new NBTTagCompound(); var4.setByte("Slot", (byte) var3); inventorySlots[var3].writeToNBT(var4); var2.appendTag(var4); }//from ww w . j a v a2 s . c om } par1NBTTagCompound.setTag("Items", var2); }
From source file:tranvicep.tools.StatsProvider.java
public static void generate() throws Exception { double[] tSellsArray = new double[nTotalValues]; double[] tValidationsArray = new double[nTotalValues]; PrintWriter writer = new PrintWriter(ConfigProvider.getOutputPath() + File.separator + "sell_val.txt"); int i = 0;/*from ww w . ja va 2s . c om*/ for (String trainId : totalValidations.keySet()) { List<Double> validations = totalValidations.get(trainId); Double[] val = new Double[validations.size()]; val = validations.toArray(val); double[] valPrim = ArrayUtils.toPrimitive(val); System.arraycopy(valPrim, 0, tValidationsArray, i, val.length); List<Double> sells = totalSells.get(trainId); Double[] sell = new Double[sells.size()]; sell = sells.toArray(sell); double[] sellPrim = ArrayUtils.toPrimitive(sell); System.arraycopy(sellPrim, 0, tSellsArray, i, sell.length); i += sell.length; StringBuilder sb = new StringBuilder(); sb.append("trainId="); sb.append(trainId); sb.append("\n"); for (int j = 0; j < sell.length; j++) { sb.append(val[j]); sb.append("\t"); sb.append(sell[j]); sb.append("\n"); } // LOG.debug(sb.toString()); List<String[]> fileContent = fileContentForTrain.get(trainId); for (String[] content : fileContent) { String c = content[0] + "\t" + content[1] + "\t" + content[2]; writer.println(c); } writer.flush(); } writer.close(); PearsonsCorrelation corr = new PearsonsCorrelation(); double corrValue = corr.correlation(tSellsArray, tValidationsArray); LOG.debug("Correlation: " + corrValue); }