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:com.mg.framework.service.ApplicationDictionaryImpl.java
private com.mg.framework.api.ui.Form loadWindow(String windowName) { if (log.isDebugEnabled()) log.debug("load UI window: " + windowName); DetachedCriteria dc = DetachedCriteria.forEntityName("com.mg.merp.core.model.Window", "wLayer") .setProjection(Projections.max("wLayer.ApplicationLayer")) .add(Restrictions.eqProperty("wLayer.Name", "w.Name")); List<String> windowControllerImplNames = OrmTemplate.getInstance() .findByCriteria(OrmTemplate.createCriteria("com.mg.merp.core.model.Window", "w") .setProjection(Projections.property("w.Implementation")) .add(Restrictions.eq("w.Name", windowName)) .add(Restrictions.or(Restrictions.isNull("w.Role"), Restrictions.in("w.Role.Id", (Object[]) ArrayUtils.toObject(ServerUtils.getUserProfile().getGroups())))) .add(Restrictions.or(Restrictions.isNull("w.User"), Restrictions.eq("w.User.Id", ServerUtils.getUserProfile().getIdentificator()))) .add(Subqueries.propertyEq("w.ApplicationLayer", dc)).setCacheable(true) .setCacheRegion("com/mg/jet/ui/windows/").setFlushMode(FlushMode.MANUAL)); String windowControllerImplName = windowName; if (windowControllerImplNames.size() == 0) { log.warn("Window implementation is not found, use window name as implementation: ".concat(windowName)); } else {//from w ww . ja v a 2 s .c o m if (windowControllerImplNames.get(0) != null) windowControllerImplName = windowControllerImplNames.get(0); else log.warn("Window implementation is null, use window name as implementation: ".concat(windowName)); } return UIProducer.produceForm(windowControllerImplName); }
From source file:com.github.kuben.realshopping.Shop.java
public int addChestItem(Location l, int[][] id) { int j = -1;/*from w w w. j av a 2 s. com*/ if (chests.containsKey(l)) { j++; for (int[] i : id) { if (chests.get(l).size() < 27) { if (Material.getMaterial(i[0]) != null) { chests.get(l).add(ArrayUtils.toObject(i)); j++; } } } } return j; }
From source file:cern.c2mon.client.core.jms.impl.RequestHandlerImplTest.java
/** * Tests that a request is split into bunches of 500 and results are gathered in the correct way. * @throws JMSException //from w ww .jav a 2 s . com */ @Test public void getManyTags() throws JMSException { Collection<ClientRequestResult> returnCollection = Arrays.asList(new TagConfigImpl(1), new TagConfigImpl(1)); EasyMock.expect(jmsProxy.sendRequest(EasyMock.isA(JsonRequest.class), EasyMock.eq("c2mon.client.request"), EasyMock.eq(10000), //10000 is timeout (ClientRequestReportListener) EasyMock.isNull())).andReturn(returnCollection).times(20); EasyMock.replay(jmsProxy); LongRange range = new LongRange(1, 10000); long[] arrayRange = range.toArray(); Collection<Long> ids = Arrays.asList(ArrayUtils.toObject(arrayRange)); Collection result = requestHandlerImpl.requestTags(ids); Assert.assertEquals(40, result.size()); //each request for 500 tags returns 2 objects (faked list back) EasyMock.verify(jmsProxy); }
From source file:com.opengamma.analytics.financial.provider.curve.multicurve.MulticurveProviderForwardBuildingRepository.java
/** * Build a unit of curves.// w ww .j a va 2s . c o m * @param instruments The instruments used for the unit calibration. * @param initGuess The initial parameters guess. * @param knownData The known data (fx rates, other curves, model parameters, ...) * @param discountingMap The discounting curves names map. * @param forwardIborMap The forward curves names map. * @param forwardONMap The forward curves names map. * @param generatorsMap The generators map. * @param calculator The calculator of the value on which the calibration is done (usually ParSpreadMarketQuoteCalculator (recommended) or converted present value). * @param sensitivityCalculator The parameter sensitivity calculator. * @return The new curves and the calibrated parameters. */ private Pair<MulticurveProviderForward, Double[]> makeUnit(final InstrumentDerivative[] instruments, final double[] initGuess, final MulticurveProviderForward knownData, final LinkedHashMap<String, Currency> discountingMap, final LinkedHashMap<String, IborIndex> forwardIborMap, final LinkedHashMap<String, IndexON> forwardONMap, final LinkedHashMap<String, GeneratorYDCurve> generatorsMap, final InstrumentDerivativeVisitor<MulticurveProviderInterface, Double> calculator, final InstrumentDerivativeVisitor<MulticurveProviderInterface, MulticurveSensitivity> sensitivityCalculator) { final GeneratorMulticurveProviderForward generator = new GeneratorMulticurveProviderForward(knownData, discountingMap, forwardIborMap, forwardONMap, generatorsMap); final MulticurveProviderForwardBuildingData data = new MulticurveProviderForwardBuildingData(instruments, generator); final Function1D<DoubleMatrix1D, DoubleMatrix1D> curveCalculator = new MulticurveProviderForwardFinderFunction( calculator, data); final Function1D<DoubleMatrix1D, DoubleMatrix2D> jacobianCalculator = new MulticurveProviderForwardFinderJacobian( new ParameterSensitivityMulticurveMatrixCalculator(sensitivityCalculator), data); final double[] parameters = _rootFinder .getRoot(curveCalculator, jacobianCalculator, new DoubleMatrix1D(initGuess)).getData(); final MulticurveProviderForward newCurves = data.getGeneratorMarket() .evaluate(new DoubleMatrix1D(parameters)); return new ObjectsPair<>(newCurves, ArrayUtils.toObject(parameters)); }
From source file:ch.epfl.data.squall.operators.AggregateCountOperator.java
@Override public AggregateCountOperator setGroupByColumns(int... hashIndexes) { return setGroupByColumns(Arrays.asList(ArrayUtils.toObject(hashIndexes))); }
From source file:de.alpharogroup.file.checksum.ChecksumUtilsTest.java
/** * Test for {@link ChecksumUtils#getChecksum(Byte[], Algorithm)} * /*from w w w . j av a2 s.co m*/ * @throws UnsupportedEncodingException * If the named charset is not supported * @throws NoSuchAlgorithmException * Is thrown if the algorithm is not supported or does not exists. * {@link java.security.MessageDigest} object. */ @Test public void testGetChecksumByteObjectArrayAlgorithm() throws NoSuchAlgorithmException, UnsupportedEncodingException { final String secretMessage = "secret Message"; final byte[] sbytes = secretMessage.getBytes("UTF-8"); final Byte[] secretMessageBytes = ArrayUtils.toObject(sbytes); String expected = "5cc16e663491726545c13ec2012f4601"; String actual = ChecksumUtils.getChecksum(secretMessageBytes, Algorithm.MD2); Assert.assertEquals(expected, actual); expected = "25659bd9db98ecc3c2077d44e69607b8"; actual = ChecksumUtils.getChecksum(secretMessageBytes, Algorithm.MD5); Assert.assertEquals(expected, actual); expected = "874026e54b67d4f9aaf87cb14a683fb51de6f9cb"; actual = ChecksumUtils.getChecksum(secretMessageBytes, Algorithm.SHA_1); Assert.assertEquals(expected, actual); expected = "8a3b3c92a8b0eb00da917c23201a9407ef7963373464076aec4c54c066e8b7aa"; actual = ChecksumUtils.getChecksum(secretMessageBytes, Algorithm.SHA_256); Assert.assertEquals(expected, actual); expected = "b58a362687ab42b9bf0d8af0b4860ed262d1fd128e16ab0082723e7785a862cd129b03577312452cc24aecdb36d5406d"; actual = ChecksumUtils.getChecksum(secretMessageBytes, Algorithm.SHA_384); Assert.assertEquals(expected, actual); expected = "ab29b34a26547ca4ce517d776885a5642929d9ed571a990fc764f7d0b854d6546276ca9aa45b3d88db3dc3dbf3c2f2152017d3e3e054ed6cd7a38a1f7925a746"; actual = ChecksumUtils.getChecksum(secretMessageBytes, Algorithm.SHA_512); Assert.assertEquals(expected, actual); }
From source file:de.alpharogroup.file.checksum.ChecksumExtensionsTest.java
/** * Test for {@link ChecksumExtensions#getChecksum(Byte[], Algorithm)} * /* w w w .j av a 2 s .c o m*/ * @throws UnsupportedEncodingException * If the named charset is not supported * @throws NoSuchAlgorithmException * Is thrown if the algorithm is not supported or does not exists. * {@link java.security.MessageDigest} object. */ @Test public void testGetChecksumByteObjectArrayAlgorithm() throws NoSuchAlgorithmException, UnsupportedEncodingException { final String secretMessage = "secret Message"; final byte[] sbytes = secretMessage.getBytes("UTF-8"); final Byte[] secretMessageBytes = ArrayUtils.toObject(sbytes); String expected = "5cc16e663491726545c13ec2012f4601"; String actual = ChecksumExtensions.getChecksum(secretMessageBytes, Algorithm.MD2); Assert.assertEquals(expected, actual); expected = "25659bd9db98ecc3c2077d44e69607b8"; actual = ChecksumExtensions.getChecksum(secretMessageBytes, Algorithm.MD5); Assert.assertEquals(expected, actual); expected = "874026e54b67d4f9aaf87cb14a683fb51de6f9cb"; actual = ChecksumExtensions.getChecksum(secretMessageBytes, Algorithm.SHA_1); Assert.assertEquals(expected, actual); expected = "8a3b3c92a8b0eb00da917c23201a9407ef7963373464076aec4c54c066e8b7aa"; actual = ChecksumExtensions.getChecksum(secretMessageBytes, Algorithm.SHA_256); Assert.assertEquals(expected, actual); expected = "b58a362687ab42b9bf0d8af0b4860ed262d1fd128e16ab0082723e7785a862cd129b03577312452cc24aecdb36d5406d"; actual = ChecksumExtensions.getChecksum(secretMessageBytes, Algorithm.SHA_384); Assert.assertEquals(expected, actual); expected = "ab29b34a26547ca4ce517d776885a5642929d9ed571a990fc764f7d0b854d6546276ca9aa45b3d88db3dc3dbf3c2f2152017d3e3e054ed6cd7a38a1f7925a746"; actual = ChecksumExtensions.getChecksum(secretMessageBytes, Algorithm.SHA_512); Assert.assertEquals(expected, actual); }
From source file:com.opengamma.analytics.financial.provider.curve.multicurve.MulticurveDiscountBuildingRepository.java
/** * Build a unit of curves.//from w ww . j av a 2s . co m * @param instruments The instruments used for the unit calibration. * @param initGuess The initial parameters guess. * @param knownData The known data (fx rates, other curves, model parameters, ...) * @param discountingMap The discounting curves names map. * @param forwardIborMap The forward curves names map. * @param forwardONMap The forward curves names map. * @param generatorsMap The generators map. * @param calculator The calculator of the value on which the calibration is done (usually ParSpreadMarketQuoteCalculator (recommended) or converted present value). * @param sensitivityCalculator The parameter sensitivity calculator. * @return The new curves and the calibrated parameters. */ private Pair<MulticurveProviderDiscount, Double[]> makeUnit(final InstrumentDerivative[] instruments, final double[] initGuess, final MulticurveProviderDiscount knownData, final LinkedHashMap<String, Currency> discountingMap, final LinkedHashMap<String, IborIndex[]> forwardIborMap, final LinkedHashMap<String, IndexON[]> forwardONMap, final LinkedHashMap<String, GeneratorYDCurve> generatorsMap, final InstrumentDerivativeVisitor<MulticurveProviderInterface, Double> calculator, final InstrumentDerivativeVisitor<MulticurveProviderInterface, MulticurveSensitivity> sensitivityCalculator) { final GeneratorMulticurveProviderDiscount generator = new GeneratorMulticurveProviderDiscount(knownData, discountingMap, forwardIborMap, forwardONMap, generatorsMap); final MulticurveDiscountBuildingData data = new MulticurveDiscountBuildingData(instruments, generator); final Function1D<DoubleMatrix1D, DoubleMatrix1D> curveCalculator = new MulticurveDiscountFinderFunction( calculator, data); final Function1D<DoubleMatrix1D, DoubleMatrix2D> jacobianCalculator = new MulticurveDiscountFinderJacobian( new ParameterSensitivityMulticurveUnderlyingMatrixCalculator(sensitivityCalculator), data); final double[] parameters = _rootFinder .getRoot(curveCalculator, jacobianCalculator, new DoubleMatrix1D(initGuess)).getData(); final MulticurveProviderDiscount newCurves = data.getGeneratorMarket() .evaluate(new DoubleMatrix1D(parameters)); return new ObjectsPair<>(newCurves, ArrayUtils.toObject(parameters)); }
From source file:com.opengamma.analytics.financial.provider.curve.hullwhite.HullWhiteProviderDiscountBuildingRepository.java
/** * Build a unit of curves./*from w w w . j a v a2 s.com*/ * @param instruments The instruments used for the unit calibration. * @param initGuess The initial parameters guess. * @param knownData The known data (fx rates, other curves, model parameters, ...) * @param discountingMap The discounting curves names map. * @param forwardIborMap The forward curves names map. * @param forwardONMap The forward curves names map. * @param generatorsMap The generators map. * @param calculator The calculator of the value on which the calibration is done (usually ParSpreadMarketQuoteCalculator (recommended) or converted present value). * @param sensitivityCalculator The parameter sensitivity calculator. * @return The new curves and the calibrated parameters. */ private Pair<HullWhiteOneFactorProviderDiscount, Double[]> makeUnit(final InstrumentDerivative[] instruments, final double[] initGuess, final HullWhiteOneFactorProviderDiscount knownData, final LinkedHashMap<String, Currency> discountingMap, final LinkedHashMap<String, IborIndex[]> forwardIborMap, final LinkedHashMap<String, IndexON[]> forwardONMap, final LinkedHashMap<String, GeneratorYDCurve> generatorsMap, final InstrumentDerivativeVisitor<HullWhiteOneFactorProviderInterface, Double> calculator, final InstrumentDerivativeVisitor<HullWhiteOneFactorProviderInterface, MulticurveSensitivity> sensitivityCalculator) { final GeneratorHullWhiteProviderDiscount generator = new GeneratorHullWhiteProviderDiscount(knownData, discountingMap, forwardIborMap, forwardONMap, generatorsMap); final HullWhiteProviderDiscountBuildingData data = new HullWhiteProviderDiscountBuildingData(instruments, generator); final Function1D<DoubleMatrix1D, DoubleMatrix1D> curveCalculator = new HullWhiteProviderDiscountFinderFunction( calculator, data); final Function1D<DoubleMatrix1D, DoubleMatrix2D> jacobianCalculator = new HullWhiteProviderDiscountFinderJacobian( new ParameterSensitivityHullWhiteMatrixCalculator(sensitivityCalculator), data); final double[] parameters = _rootFinder .getRoot(curveCalculator, jacobianCalculator, new DoubleMatrix1D(initGuess)).getData(); final HullWhiteOneFactorProviderDiscount newCurves = data.getGeneratorMarket() .evaluate(new DoubleMatrix1D(parameters)); return new ObjectsPair<>(newCurves, ArrayUtils.toObject(parameters)); }
From source file:com.alibaba.otter.manager.web.home.module.action.PipelineAction.java
public void doEdit(@FormGroup("pipelineInfo") Group pipelineInfo, @FormGroup("pipelineParameterInfo") Group pipelineParameterInfo, @FormField(name = "formPipelineError", group = "pipelineInfo") CustomErrors err, HttpSession session, Navigator nav) {/* ww w.j a va 2 s . co m*/ Pipeline pipeline = new Pipeline(); PipelineParameter parameters = new PipelineParameter(); pipelineInfo.setProperties(pipeline); pipelineParameterInfo.setProperties(parameters); // if (parameters.getLoadPoolSize() < 1) { // parameters.setLoadPoolSize(PipelineParameter.DEFAULT_LOAD_POOL_SIZE); // } List<Long> selectNodeIds = Arrays .asList(ArrayUtils.toObject(pipelineInfo.getField("selectNodeIds").getLongValues())); List<Node> selectNodes = new ArrayList<Node>(); for (Long selectNodeId : selectNodeIds) { Node node = new Node(); node.setId(selectNodeId); selectNodes.add(node); } // select/extract???? List<Long> extractNodeIds = Arrays .asList(ArrayUtils.toObject(pipelineInfo.getField("selectNodeIds").getLongValues())); // List<Long> extractNodeIds = // Arrays.asList(ArrayUtils.toObject(pipelineInfo.getField("extractNodeIds").getLongValues())); List<Node> extractNodes = new ArrayList<Node>(); for (Long extractNodeId : extractNodeIds) { Node node = new Node(); node.setId(extractNodeId); extractNodes.add(node); } List<Long> loadNodeIds = Arrays .asList(ArrayUtils.toObject(pipelineInfo.getField("loadNodeIds").getLongValues())); List<Node> loadNodes = new ArrayList<Node>(); for (Long loadNodeId : loadNodeIds) { Node node = new Node(); node.setId(loadNodeId); loadNodes.add(node); } pipeline.setSelectNodes(selectNodes); pipeline.setExtractNodes(extractNodes); pipeline.setLoadNodes(loadNodes); pipeline.setParameters(parameters); List<Pipeline> values = pipelineService .listByDestinationWithoutOther(pipeline.getParameters().getDestinationName()); if (!values.isEmpty()) { if (values.size() > 1 || !values.get(0).getId().equals(pipeline.getId())) { err.setMessage("invalidDestinationName"); return; } } try { pipelineService.modify(pipeline); } catch (RepeatConfigureException rce) { err.setMessage("invalidPipelineName"); return; } nav.redirectToLocation("pipelineList.htm?channelId=" + pipeline.getChannelId()); }