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:org.opennms.netmgt.dao.hibernate.AlarmRepositoryHibernate.java
/** * {@inheritDoc}//from w ww .ja v a 2s . c o m */ @Transactional @Override public void unacknowledgeAlarms(int[] alarmIds, String user) { OnmsCriteria criteria = new OnmsCriteria(OnmsAlarm.class); criteria.add(Restrictions.in("id", Arrays.asList(ArrayUtils.toObject(alarmIds)))); unacknowledgeMatchingAlarms(criteria, user); }
From source file:org.ossie.properties.AnyUtils.java
/** * Internal function used to extract a sequence from an any. * /*from ww w.j av a 2 s .c om*/ * @param theAny the Any to convert * @param contentType the TypeCode of the desired value * @return an array of Java objects from theAny that corresponds to the typeCode */ private static Object[] extractSequence(final Any theAny, final TypeCode contentType) { try { final TCKind kind = contentType.kind(); switch (kind.value()) { case TCKind._tk_any: return AnySeqHelper.extract(theAny); case TCKind._tk_boolean: return ArrayUtils.toObject(BooleanSeqHelper.extract(theAny)); case TCKind._tk_char: return ArrayUtils.toObject(CharSeqHelper.extract(theAny)); case TCKind._tk_double: return ArrayUtils.toObject(DoubleSeqHelper.extract(theAny)); case TCKind._tk_float: return ArrayUtils.toObject(FloatSeqHelper.extract(theAny)); case TCKind._tk_long: return ArrayUtils.toObject(LongSeqHelper.extract(theAny)); case TCKind._tk_longlong: return ArrayUtils.toObject(LongLongSeqHelper.extract(theAny)); case TCKind._tk_octet: return ArrayUtils.toObject(OctetSeqHelper.extract(theAny)); case TCKind._tk_short: return ArrayUtils.toObject(ShortSeqHelper.extract(theAny)); case TCKind._tk_string: return StringSeqHelper.extract(theAny); case TCKind._tk_ulong: return ArrayUtils.toObject(UnsignedUtils.toSigned(ULongSeqHelper.extract(theAny))); case TCKind._tk_ulonglong: return UnsignedUtils.toSigned(ULongLongSeqHelper.extract(theAny)); case TCKind._tk_ushort: return ArrayUtils.toObject(UnsignedUtils.toSigned(UShortSeqHelper.extract(theAny))); case TCKind._tk_wchar: return ArrayUtils.toObject(WCharSeqHelper.extract(theAny)); case TCKind._tk_wstring: return WStringSeqHelper.extract(theAny); case TCKind._tk_null: return null; case TCKind._tk_sequence: if (PropertiesHelper.type().equivalent(contentType)) { return PropertiesHelper.extract(theAny); } else { return AnyUtils.extractSequence(theAny, contentType.content_type()); } case TCKind._tk_alias: final TypeCode innerContentType = contentType.content_type(); if (innerContentType.kind().value() == TCKind._tk_sequence) { return AnyUtils.extractSequence(theAny, innerContentType); } else { throw new IllegalArgumentException("Unsupported alias content type: " + innerContentType); } case TCKind._tk_struct: if (DataTypeHelper.type().equivalent(contentType)) { return PropertiesHelper.extract(theAny); } else { throw new IllegalArgumentException("Unsupported struct content type: " + contentType); } default: throw new IllegalArgumentException( "Only primitive sequence types supported, unknown conversion: " + contentType); } } catch (final BAD_OPERATION ex) { return null; } catch (final BadKind e) { return null; } }
From source file:org.parosproxy.paros.db.paros.ParosTableHistory.java
/** * Gets all the history record IDs of the given session and with the given history types. * * @param sessionId the ID of session of the history records * @param histTypes the history types of the history records that should be returned * @return a {@code List} with all the history IDs of the given session and history types, never {@code null} * @throws DatabaseException if an error occurred while getting the history IDs * @since 2.3.0/*from w w w . ja v a2 s . com*/ * @see #getHistoryIds(long) * @see #getHistoryIdsExceptOfHistType(long, int...) */ @Override public List<Integer> getHistoryIdsOfHistType(long sessionId, int... histTypes) throws DatabaseException { try { boolean hasHistTypes = histTypes != null && histTypes.length > 0; int strLength = hasHistTypes ? 97 : 68; StringBuilder strBuilder = new StringBuilder(strLength); strBuilder.append("SELECT ").append(HISTORYID); strBuilder.append(" FROM ").append(TABLE_NAME).append(" WHERE ").append(SESSIONID).append(" = ?"); if (hasHistTypes) { strBuilder.append(" AND ").append(HISTTYPE).append(" IN ( UNNEST(?) )"); } strBuilder.append(" ORDER BY ").append(HISTORYID); try (PreparedStatement psReadSession = getConnection().prepareStatement(strBuilder.toString())) { psReadSession.setLong(1, sessionId); if (hasHistTypes) { Array arrayHistTypes = getConnection().createArrayOf("INTEGER", ArrayUtils.toObject(histTypes)); psReadSession.setArray(2, arrayHistTypes); } try (ResultSet rs = psReadSession.executeQuery()) { ArrayList<Integer> ids = new ArrayList<>(); while (rs.next()) { ids.add(Integer.valueOf(rs.getInt(HISTORYID))); } ids.trimToSize(); return ids; } } } catch (SQLException e) { throw new DatabaseException(e); } }
From source file:org.parosproxy.paros.db.paros.ParosTableHistory.java
/** * Returns all the history record IDs of the given session except the ones with the given history types. ** /*from w w w.ja va 2 s.c o m*/ * @param sessionId the ID of session of the history records * @param histTypes the history types of the history records that should be excluded * @return a {@code List} with all the history IDs of the given session and history types, never {@code null} * @throws DatabaseException if an error occurred while getting the history IDs * @since 2.3.0 * @see #getHistoryIdsOfHistType(long, int...) */ @Override public List<Integer> getHistoryIdsExceptOfHistType(long sessionId, int... histTypes) throws DatabaseException { try { boolean hasHistTypes = histTypes != null && histTypes.length > 0; int strLength = hasHistTypes ? 102 : 68; StringBuilder sb = new StringBuilder(strLength); sb.append("SELECT ").append(HISTORYID); sb.append(" FROM ").append(TABLE_NAME).append(" WHERE ").append(SESSIONID).append(" = ?"); if (hasHistTypes) { sb.append(" AND ").append(HISTTYPE).append(" NOT IN ( UNNEST(?) )"); } sb.append(" ORDER BY ").append(HISTORYID); try (PreparedStatement psReadSession = getConnection().prepareStatement(sb.toString())) { psReadSession.setLong(1, sessionId); if (hasHistTypes) { Array arrayHistTypes = getConnection().createArrayOf("INTEGER", ArrayUtils.toObject(histTypes)); psReadSession.setArray(2, arrayHistTypes); } try (ResultSet rs = psReadSession.executeQuery()) { ArrayList<Integer> ids = new ArrayList<>(); while (rs.next()) { ids.add(Integer.valueOf(rs.getInt(HISTORYID))); } ids.trimToSize(); return ids; } } } catch (SQLException e) { throw new DatabaseException(e); } }
From source file:org.parosproxy.paros.db.paros.ParosTableHistory.java
/** * Deletes all records whose history type was marked as temporary (by calling {@code setHistoryTypeTemporary(int)}). * <p>/*www. j a va2 s .c o m*/ * By default the only temporary history type is {@code HistoryReference#TYPE_TEMPORARY}. * * @throws DatabaseException if an error occurred while deleting the temporary history records * @see #setHistoryTypeAsTemporary(int) * @see #unsetHistoryTypeAsTemporary(int) * @see HistoryReference#TYPE_TEMPORARY */ @Override public void deleteTemporary() throws DatabaseException { try { Integer[] ids = new Integer[temporaryHistoryTypes.size()]; ids = temporaryHistoryTypes.toArray(ids); Array arrayHistTypes = getConnection().createArrayOf("INTEGER", ArrayUtils.toObject(ArrayUtils.toPrimitive(ids))); psDeleteTemp.setArray(1, arrayHistTypes); psDeleteTemp.execute(); } catch (SQLException e) { throw new DatabaseException(e); } }
From source file:org.parosproxy.paros.db.TableHistory.java
/** * Gets all the history record IDs of the given session and with the given history types. * * @param sessionId the ID of session of the history records * @param histTypes the history types of the history records that should be returned * @return a {@code List} with all the history IDs of the given session and history types, never {@code null} * @throws SQLException if an error occurred while getting the history IDs * @since 2.3.0/*from w w w . j ava 2s . c om*/ * @see #getHistoryIds(long) * @see #getHistoryIdsExceptOfHistType(long, int...) */ public List<Integer> getHistoryIdsOfHistType(long sessionId, int... histTypes) throws SQLException { boolean hasHistTypes = histTypes != null && histTypes.length > 0; int strLength = hasHistTypes ? 97 : 68; StringBuilder strBuilder = new StringBuilder(strLength); strBuilder.append("SELECT ").append(HISTORYID); strBuilder.append(" FROM ").append(TABLE_NAME).append(" WHERE ").append(SESSIONID).append(" = ?"); if (hasHistTypes) { strBuilder.append(" AND ").append(HISTTYPE).append(" IN ( UNNEST(?) )"); } strBuilder.append(" ORDER BY ").append(HISTORYID); try (PreparedStatement psReadSession = getConnection().prepareStatement(strBuilder.toString())) { psReadSession.setLong(1, sessionId); if (hasHistTypes) { Array arrayHistTypes = getConnection().createArrayOf("INTEGER", ArrayUtils.toObject(histTypes)); psReadSession.setArray(2, arrayHistTypes); } try (ResultSet rs = psReadSession.executeQuery()) { ArrayList<Integer> ids = new ArrayList<>(); while (rs.next()) { ids.add(Integer.valueOf(rs.getInt(HISTORYID))); } ids.trimToSize(); return ids; } } }
From source file:org.parosproxy.paros.db.TableHistory.java
/** * Returns all the history record IDs of the given session except the ones with the given history types. ** /*w w w .ja v a 2 s .c o m*/ * @param sessionId the ID of session of the history records * @param histTypes the history types of the history records that should be excluded * @return a {@code List} with all the history IDs of the given session and history types, never {@code null} * @throws SQLException if an error occurred while getting the history IDs * @since 2.3.0 * @see #getHistoryIdsOfHistType(long, int...) */ public List<Integer> getHistoryIdsExceptOfHistType(long sessionId, int... histTypes) throws SQLException { boolean hasHistTypes = histTypes != null && histTypes.length > 0; int strLength = hasHistTypes ? 102 : 68; StringBuilder sb = new StringBuilder(strLength); sb.append("SELECT ").append(HISTORYID); sb.append(" FROM ").append(TABLE_NAME).append(" WHERE ").append(SESSIONID).append(" = ?"); if (hasHistTypes) { sb.append(" AND ").append(HISTTYPE).append(" NOT IN ( UNNEST(?) )"); } sb.append(" ORDER BY ").append(HISTORYID); try (PreparedStatement psReadSession = getConnection().prepareStatement(sb.toString())) { psReadSession.setLong(1, sessionId); if (hasHistTypes) { Array arrayHistTypes = getConnection().createArrayOf("INTEGER", ArrayUtils.toObject(histTypes)); psReadSession.setArray(2, arrayHistTypes); } try (ResultSet rs = psReadSession.executeQuery()) { ArrayList<Integer> ids = new ArrayList<>(); while (rs.next()) { ids.add(Integer.valueOf(rs.getInt(HISTORYID))); } ids.trimToSize(); return ids; } } }
From source file:org.parosproxy.paros.db.TableHistory.java
/** * Deletes all records whose history type was marked as temporary (by calling {@code setHistoryTypeTemporary(int)}). * <p>//w w w . j a v a 2s .co m * By default the only temporary history type is {@code HistoryReference#TYPE_TEMPORARY}. * * @throws SQLException if an error occurred while deleting the temporary history records * @see #setHistoryTypeAsTemporary(int) * @see #unsetHistoryTypeAsTemporary(int) * @see HistoryReference#TYPE_TEMPORARY */ public void deleteTemporary() throws SQLException { Integer[] ids = new Integer[temporaryHistoryTypes.size()]; ids = temporaryHistoryTypes.toArray(ids); Array arrayHistTypes = getConnection().createArrayOf("INTEGER", ArrayUtils.toObject(ArrayUtils.toPrimitive(ids))); psDeleteTemp.setArray(1, arrayHistTypes); psDeleteTemp.execute(); }
From source file:org.pentaho.di.trans.steps.rowgenerator.RowGeneratorMeta.java
public Object[][] getFieldsDGValues() { Object[][] vals = new Object[10][]; vals[0] = fieldName;//from w w w.java2 s .c o m vals[1] = fieldType; vals[2] = fieldFormat; vals[3] = ArrayUtils.toObject(fieldLength); vals[4] = ArrayUtils.toObject(fieldPrecision); vals[5] = currency; vals[6] = decimal; vals[7] = group; vals[8] = value; vals[9] = ArrayUtils.toObject(setEmptyString); return vals; }
From source file:org.pivot4j.ui.command.BasicDrillThroughCommand.java
/** * @see org.pivot4j.ui.command.UICommand#execute(org.pivot4j.PivotModel , * org.pivot4j.ui.command.UICommandParameters) */// w ww.ja v a 2s . c om @Override public ResultSet execute(PivotModel model, UICommandParameters parameters) { int[] array = parameters.getCellCoordinate(); List<Integer> coords = Arrays.asList(ArrayUtils.toObject(array)); Cell cell = model.getCellSet().getCell(coords); try { return cell.drillThrough(); } catch (OlapException e) { throw new PivotException(e); } }