List of usage examples for org.apache.commons.lang ArrayUtils toObject
public static Boolean[] toObject(boolean[] array)
Converts an array of primitive booleans to objects.
From source file:edu.harvard.iq.dvn.ingest.statdataio.impl.plugins.por.PORFileReader.java
private void decodeSec2(BufferedReader reader) throws IOException { dbgLog.fine("***** decodeSec2(): start *****"); if (reader == null) { throw new IllegalArgumentException("decodeSec2: stream == null!"); }// w w w . j av a2 s . c om // Because a 64-bit machine may not save the first 40 // bytes of a POR file in a way as a 32-bit machine does, // the first 5 lines of a POR file is excluded from the read-back // file and the new 1st line contains the format mark "SPSSPORT" // somewhere in it. // mark the start position for the later rewind if (reader.markSupported()) { reader.mark(100000); } char[] sixthLineCharArray = new char[80]; int nbytes_sixthLine = reader.read(sixthLineCharArray); String sixthLine = new String(sixthLineCharArray); dbgLog.info("sixthLineCharArray=" + Arrays.deepToString(ArrayUtils.toObject(sixthLineCharArray))); int signatureLocation = sixthLine.indexOf(POR_MARK); if (signatureLocation >= 0) { dbgLog.info("format signature was found at:" + signatureLocation); } else { dbgLog.severe("signature string was not found"); throw new IOException("signature string was not found"); } // rewind the position to the beginning reader.reset(); // skip bytes up to the signature string long skippedBytes = reader.skip(signatureLocation); char[] sec2_leader = new char[POR_MARK.length()]; int nbytes_sec2_leader = reader.read(sec2_leader); String leader_string = new String(sec2_leader); dbgLog.info("format signature [SPSSPORT] detected=" + leader_string); if (leader_string.equals("SPSSPORT")) { dbgLog.info("signature was correctly detected"); } else { dbgLog.severe("the format signature is not found at the previously located column"); throw new IOException("decodeSec2: failed to find the signature string"); } int length_section_2 = LENGTH_SECTION_2; char[] Sec2_bytes = new char[length_section_2]; int nbytes_sec2 = reader.read(Sec2_bytes); if (nbytes_sec2 == 0) { dbgLog.severe("decodeSec2: reading error"); throw new IOException("decodeSec2: reading error"); } else { dbgLog.fine("bytes read=" + nbytes_sec2); } String sec2 = new String(Sec2_bytes); dbgLog.fine("sec2[creation date/time]=" + sec2); // sec2 // 0123456789012345678 // A8/YYYYMMDD6/HHMMSS // thus // section2 should has 3 elements String[] section2 = StringUtils.split(sec2, '/'); dbgLog.fine("section2=" + StringUtils.join(section2, "|")); String fileCreationDate = null; String fileCreationTime = null; if ((section2.length == 3) && (section2[0].startsWith("A"))) { fileCreationDate = section2[1].substring(0, 7); fileCreationTime = section2[2]; } else { dbgLog.severe("decodeSec2: file creation date/time were not correctly detected"); throw new IOException("decodeSec2: file creation date/time were not correctly detected"); } dbgLog.fine("fileCreationDate=" + fileCreationDate); dbgLog.fine("fileCreationTime=" + fileCreationTime); smd.getFileInformation().put("fileCreationDate", fileCreationDate); smd.getFileInformation().put("fileCreationTime", fileCreationTime); smd.getFileInformation().put("varFormat_schema", "SPSS"); }
From source file:com.opengamma.analytics.math.curve.InterpolatedDoublesCurve.java
@Override public Double[] getYValueParameterSensitivity(final Double x) { Validate.notNull(x, "x"); return ArrayUtils.toObject(_interpolator.getNodeSensitivitiesForValue(_dataBundle, x)); }
From source file:eionet.meta.dao.mysql.DataElementDAOImpl.java
/** * {@inheritDoc}/*from w w w . j a v a 2s . c o m*/ */ @Override public Map<Integer, List<List<DataElement>>> getVocabularyConceptsDataElementValues(int vocabularyFolderId, int[] vocabularyConceptIds, boolean emptyAttributes) { // this does not work for IN type, although it is recommended!!!! // final MapSqlParameterSource params = new MapSqlParameterSource(); // // params.addValue("vocabularyFolderId", vocabularyFolderId); // params.addValue("vocabularyConceptIds", vocabularyConceptIds); final Map<String, Object> params = new HashMap<String, Object>(); params.put("vocabularyFolderId", vocabularyFolderId); // to work in "IN" clause, it should be list of Integer objects. params.put("vocabularyConceptIds", Arrays.asList(ArrayUtils.toObject(vocabularyConceptIds))); StringBuilder sql = new StringBuilder(); sql.append("select * from VOCABULARY_CONCEPT_ELEMENT v "); if (emptyAttributes) { sql.append("RIGHT OUTER JOIN DATAELEM d "); } else { sql.append("LEFT JOIN DATAELEM d "); } sql.append("ON (v.DATAELEM_ID = d.DATAELEM_ID and v.VOCABULARY_CONCEPT_ID in (:vocabularyConceptIds)) "); sql.append("LEFT JOIN VOCABULARY2ELEM ve on ve.DATAELEM_ID = d.DATAELEM_ID "); sql.append("LEFT JOIN VOCABULARY_CONCEPT rc on v.RELATED_CONCEPT_ID = rc.VOCABULARY_CONCEPT_ID "); sql.append("LEFT JOIN VOCABULARY rcv ON rc.VOCABULARY_ID = rcv.VOCABULARY_ID "); sql.append("LEFT JOIN VOCABULARY_SET rcvs ON rcv.FOLDER_ID = rcvs.ID "); sql.append("where ve.VOCABULARY_ID = :vocabularyFolderId "); sql.append("order by v.VOCABULARY_CONCEPT_ID, ve.DATAELEM_ID, v.ELEMENT_VALUE, rc.IDENTIFIER"); final Map<Integer, List<List<DataElement>>> result = new HashMap<Integer, List<List<DataElement>>>(); getNamedParameterJdbcTemplate().query(sql.toString(), params, new RowCallbackHandler() { List<List<DataElement>> listOfValues = null; List<DataElement> values = null; int previousDataElemId = -1; int previousConceptId = -1; @Override public void processRow(ResultSet rs) throws SQLException { int conceptId = rs.getInt("v.VOCABULARY_CONCEPT_ID"); int dataElemId = rs.getInt("d.DATAELEM_ID"); if (previousConceptId != conceptId) { listOfValues = new ArrayList<List<DataElement>>(); result.put(conceptId, listOfValues); values = new ArrayList<DataElement>(); listOfValues.add(values); } else if (previousDataElemId != dataElemId) { values = new ArrayList<DataElement>(); listOfValues.add(values); } previousConceptId = conceptId; previousDataElemId = dataElemId; DataElement de = new DataElement(); de.setId(dataElemId); de.setShortName(rs.getString("d.SHORT_NAME")); de.setStatus(rs.getString("d.REG_STATUS")); de.setType(rs.getString("d.TYPE")); de.setModified(new Date(rs.getLong("d.DATE"))); de.setWorkingUser(rs.getString("d.WORKING_USER")); de.setIdentifier(rs.getString("d.identifier")); de.setAttributeValue(rs.getString("v.ELEMENT_VALUE")); de.setAttributeLanguage(rs.getString("v.LANGUAGE")); de.setRelatedConceptId(rs.getInt("v.RELATED_CONCEPT_ID")); de.setRelatedConceptIdentifier(rs.getString("rc.IDENTIFIER")); de.setRelatedConceptLabel(rs.getString("rc.LABEL")); de.setRelatedConceptVocabulary(rs.getString("rcv.IDENTIFIER")); de.setRelatedConceptBaseURI(rs.getString("rcv.BASE_URI")); de.setRelatedConceptVocSet(rs.getString("rcvs.IDENTIFIER")); de.setVocabularyId(rs.getInt("d.VOCABULARY_ID")); de.setRelatedConceptOriginalId(rs.getInt("rc.ORIGINAL_CONCEPT_ID")); de.setRelatedVocabularyStatus(rs.getString("rcv.REG_STATUS")); de.setRelatedVocabularyWorkingCopy(rs.getInt("rcv.WORKING_COPY") == 1); List<FixedValue> fxvs = getFixedValues(de.getId()); de.setFixedValues(fxvs); de.setElemAttributeValues(getDataElementAttributeValues(dataElemId)); values.add(de); } }); if (emptyAttributes && result.get(0) != null) { if (result.containsKey(vocabularyConceptIds[0])) { result.get(vocabularyConceptIds[0]).addAll(result.get(0)); } else { result.put(vocabularyConceptIds[0], result.get(0)); } } // fill empty lists for not found concepts for (int conceptId : vocabularyConceptIds) { if (!result.containsKey(conceptId)) { result.put(conceptId, new ArrayList<List<DataElement>>()); } } return result; }
From source file:edu.harvard.iq.dataverse.ingest.tabulardata.impl.plugins.por.PORFileReader.java
private void decodeSec2(BufferedReader reader) throws IOException { dbgLog.fine("decodeSec2(): start"); if (reader == null) { throw new IllegalArgumentException("decodeSec2: stream == null!"); }/*from w ww . jav a2 s .c o m*/ // Because a 64-bit machine may not save the first 40 // bytes of a POR file in a way as a 32-bit machine does, // the first 5 lines of a POR file is excluded from the read-back // file and the new 1st line contains the format mark "SPSSPORT" // somewhere in it. // mark the start position for the later rewind if (reader.markSupported()) { reader.mark(100000); } char[] sixthLineCharArray = new char[80]; int nbytes_sixthLine = reader.read(sixthLineCharArray); String sixthLine = new String(sixthLineCharArray); dbgLog.fine("sixthLineCharArray=" + Arrays.deepToString(ArrayUtils.toObject(sixthLineCharArray))); int signatureLocation = sixthLine.indexOf(POR_MARK); if (signatureLocation >= 0) { dbgLog.fine("format signature was found at:" + signatureLocation); } else { dbgLog.severe("signature string was not found"); throw new IOException("signature string was not found"); } // rewind the position to the beginning reader.reset(); // skip bytes up to the signature string long skippedBytes = reader.skip(signatureLocation); char[] sec2_leader = new char[POR_MARK.length()]; int nbytes_sec2_leader = reader.read(sec2_leader); String leader_string = new String(sec2_leader); dbgLog.fine("format signature [SPSSPORT] detected=" + leader_string); if (leader_string.equals("SPSSPORT")) { dbgLog.fine("signature was correctly detected"); } else { dbgLog.severe("the format signature is not found at the previously located column"); throw new IOException("decodeSec2: failed to find the signature string"); } int length_section_2 = LENGTH_SECTION_2; char[] Sec2_bytes = new char[length_section_2]; int nbytes_sec2 = reader.read(Sec2_bytes); if (nbytes_sec2 == 0) { dbgLog.severe("decodeSec2: reading error"); throw new IOException("decodeSec2: reading error"); } else { dbgLog.fine("bytes read=" + nbytes_sec2); } String sec2 = new String(Sec2_bytes); dbgLog.fine("sec2[creation date/time]=" + sec2); // sec2 // 0123456789012345678 // A8/YYYYMMDD6/HHMMSS // thus // section2 should has 3 elements String[] section2 = StringUtils.split(sec2, '/'); dbgLog.fine("section2=" + StringUtils.join(section2, "|")); String fileCreationDate = null; String fileCreationTime = null; if ((section2.length == 3) && (section2[0].startsWith("A"))) { fileCreationDate = section2[1].substring(0, 7); fileCreationTime = section2[2]; } else { dbgLog.severe("decodeSec2: file creation date/time were not correctly detected"); throw new IOException("decodeSec2: file creation date/time were not correctly detected"); } dbgLog.fine("fileCreationDate=" + fileCreationDate); dbgLog.fine("fileCreationTime=" + fileCreationTime); ///smd.getFileInformation().put("fileCreationDate", fileCreationDate); ///smd.getFileInformation().put("fileCreationTime", fileCreationTime); ///smd.getFileInformation().put("varFormat_schema", "SPSS"); dbgLog.fine("decodeSec2(): end"); }
From source file:com.senseidb.svc.impl.HttpRestSenseiServiceImpl.java
public static String join(boolean[] arr, String delimiter) { return join(Arrays.asList(ArrayUtils.toObject(arr)), delimiter); }
From source file:com.senseidb.svc.impl.HttpRestSenseiServiceImpl.java
public static String join(byte[] arr, String delimiter) { return join(Arrays.asList(ArrayUtils.toObject(arr)), delimiter); }
From source file:com.senseidb.svc.impl.HttpRestSenseiServiceImpl.java
public static String join(int[] arr, String delimiter) { return join(Arrays.asList(ArrayUtils.toObject(arr)), delimiter); }
From source file:com.senseidb.svc.impl.HttpRestSenseiServiceImpl.java
public static String join(long[] arr, String delimiter) { return join(Arrays.asList(ArrayUtils.toObject(arr)), delimiter); }
From source file:com.senseidb.svc.impl.HttpRestSenseiServiceImpl.java
public static String join(double[] arr, String delimiter) { return join(Arrays.asList(ArrayUtils.toObject(arr)), delimiter); }
From source file:com.flexive.war.beans.admin.main.AccountBean.java
/** * Retrieves all users, filtering by loginName, userName, email, active, vaidated and mandatorFilter. * * @return all users matching the filter criterias. *//* w w w .j a v a 2 s . c o m*/ public List<Account> getList() { final UserTicket ticket = FxContext.getUserTicket(); try { long _mandatorFilter = getMandatorFilter(); // If not supervisor fallback to the own mandator if (!ticket.isGlobalSupervisor()) { _mandatorFilter = ticket.getMandatorId(); } long[] userGroupIds = new long[1]; if (groupFilter != -1) { userGroupIds[0] = groupFilter; } else { userGroupIds = null; } // Load list if needed, and cache within the request String cacheKey = account.getName() + "_" + account.getLoginName() + "_" + account.getEmail() + "_" + isActiveFilter() + "_" + isValidatedFilter() + "_" + _mandatorFilter + "_" + StringUtils.join(ArrayUtils.toObject(userGroupIds), ','); List<Account> result = listCache.get(cacheKey); if (result == null) { result = getAccountEngine().loadAll(null, null, null, isActiveFilter() ? true : null, isValidatedFilter() ? true : null, _mandatorFilter, null, userGroupIds, 0, -1); listCache.put(cacheKey, result); } return result; } catch (Exception exc) { new FxFacesMsgErr(exc).addToContext(); return new ArrayList<Account>(0); } }