List of usage examples for org.apache.commons.lang ArrayUtils toString
public static String toString(Object array)
Outputs an array as a String, treating null
as an empty array.
From source file:gda.device.enumpositioner.EpicsValveCallback.java
@Override public void rawAsynchronousMoveTo(Object position) throws DeviceException { try {/*from ww w. jav a 2 s .c om*/ // check top ensure a correct string has been supplied if (positions.contains(position.toString())) { controller.caput(currentPositionChnl, position.toString(), putCallbackListener); positionerStatus = EnumPositionerStatus.MOVING; return; } } catch (Throwable th) { positionerStatus = EnumPositionerStatus.ERROR; throw new DeviceException("failed to move to" + position.toString(), th); } // if get here then wrong position name supplied throw new DeviceException(getName() + ": demand position " + position.toString() + " not acceptable. Should be one of: " + ArrayUtils.toString(positions)); }
From source file:com.taobao.itest.listener.ITestSpringContextListener.java
/** * modified by <a href="mailto:yufan.yq@taobao.com">yufan.yq</a>, * springbeforeTestClass/* w w w. j av a 2s. c o m*/ * Listener?beforeTestClassSpring, ???? */ @Override public void beforeTestClass(TestContext testContext) throws Exception { Class<?> testClass = testContext.getTestClass(); if (AnnotationUtil.findAnnotation(testClass, ITestSpringContext.class) == null) { return; } // spring configure file location String[] locations; // springContextManager key name String key; // The original processing logic locations = retrieveLocations(testClass); locations = ResourceLocationProcessingUtil.modifyLocations(testClass, locations); key = ArrayUtils.toString(locations); ApplicationContext applicationContext = SpringContextManager.get(key); if (applicationContext == null) { SpringContextLoader contextLoader = new GenericXmlContextLoader(); try { applicationContext = SpringContextManager.loadApplicationContext(contextLoader, locations); logger.info("Spring ??"); } catch (Exception e) { String err = "load Spring ApplicationContext faild ,locations= '" + ArrayUtils.toString(locations) + "' ,detail exception message is:" + e.getMessage(); e.printStackTrace(); logger.warn(err); throw new RuntimeException(err, e); } SpringContextManager.put(key, applicationContext); } }
From source file:com.jaspersoft.jasperserver.repository.test.RepositoryServiceDependentResourcesTest.java
@BeforeMethod public void log(Method m) { logger.info(msg("@@@ Running -> %s", m.getName())); expectedOrder = ArrayUtils.toString(uriList); expectedOrderForTopFive = ArrayUtils.toString(ArrayUtils.subarray(uriList, 0, 5)); }
From source file:com.taobao.itest.core.TestContextManager.java
private TestListener[] retrieveTestListeners(Class<?> clazz) { Class<TestListeners> annotationType = TestListeners.class; @SuppressWarnings("rawtypes") List<Class> classesAnnotationDeclared = AnnotationUtil.findClassesAnnotationDeclaredWith(clazz, annotationType);//from w w w . j av a2 s . com List<Class<? extends TestListener>> classesList = new ArrayList<Class<? extends TestListener>>(); for (Class<?> classAnnotationDeclared : classesAnnotationDeclared) { TestListeners testListeners = classAnnotationDeclared.getAnnotation(annotationType); Class<? extends TestListener>[] valueListenerClasses = testListeners.value(); Class<? extends TestListener>[] listenerClasses = testListeners.listeners(); if (!ArrayUtils.isEmpty(valueListenerClasses) && !ArrayUtils.isEmpty(listenerClasses)) { String msg = String.format( "Test class [%s] has been configured with @TestListeners' 'value' [%s] and 'listeners' [%s] attributes. Use one or the other, but not both.", classAnnotationDeclared, ArrayUtils.toString(valueListenerClasses), ArrayUtils.toString(listenerClasses)); throw new RuntimeException(msg); } else if (!ArrayUtils.isEmpty(valueListenerClasses)) { listenerClasses = valueListenerClasses; } if (listenerClasses != null) { classesList.addAll(0, Arrays.<Class<? extends TestListener>>asList(listenerClasses)); } if (!testListeners.inheritListeners()) { break; } } List<TestListener> listeners = new ArrayList<TestListener>(classesList.size()); for (Class<? extends TestListener> listenerClass : classesList) { listeners.add((TestListener) BeanUtils.instantiateClass(listenerClass)); } return listeners.toArray(new TestListener[listeners.size()]); }
From source file:br.com.autonomiccs.starthost.plugin.proxies.StartHostMethodInterceptor.java
@Override public Object invoke(MethodInvocation methodInvocation) throws Throwable { UUID uuid = UUID.randomUUID(); logger.debug(String.format(// ww w. j a v a 2 s.c o m "In proxy method before the method [%s] execution, we will use the idenfier [%s] for debug purpose.", methodInvocation.getMethod().getName(), uuid)); logger.debug(String.format("Parameters before request [%s] execution, parameters [%s]", uuid, ArrayUtils.toString(methodInvocation.getArguments()))); try { return methodInvocation.proceed(); } catch (Exception e) { logger.info(String.format("Dealing with exception [%s] for method [%s], UUID of the call [%s].", e.getClass(), methodInvocation.getMethod().getName(), uuid)); if (!hostService.isThereAnyHostOnCloudDeactivatedByOurManager() && !autonomicClusterManagementHeuristicService.getAdministrationAlgorithm() .canHeuristicShutdownHosts()) { throw e; } return synchronizedExecuteDeployVMStartingHostIfNeeded(methodInvocation); } }
From source file:ijfx.service.DefaultImagePlaneService.java
@Override public <T extends RealType<T>> Dataset extractPlane(File file, long[] dims, long[] dimLengths) throws IOException { final SCIFIOConfig config = new SCIFIOConfig(); // skip min/max computation config.imgOpenerSetComputeMinMax(false); // prefer planar array structure, for ImageJ1 and ImgSaver compatibility config.imgOpenerSetImgModes(SCIFIOConfig.ImgMode.CELL); config.parserSetLevel(MetadataLevel.ALL); long[] position = new long[dims.length + 2]; long[] dimemsions = new long[dims.length + 2]; System.arraycopy(dims, 0, position, 2, dims.length); System.arraycopy(dimLengths, 0, dimemsions, 2, dims.length); config.imgOpenerSetRange("0"); Dataset virtualDataset = datasetIoService.open(file.getAbsolutePath(), config); Dataset outputDataset = getEmptyPlaneDataset(virtualDataset); RandomAccess<T> inputCursor = (RandomAccess<T>) virtualDataset.randomAccess(); RandomAccess<T> outputCursor = (RandomAccess<T>) outputDataset.randomAccess(); System.out.println("dims before"); System.out.println(ArrayUtils.toString(dims)); System.out.println(ArrayUtils.toString(position)); System.arraycopy(dims, 0, position, 2, dims.length); System.out.println(ArrayUtils.toString(position)); long width = outputDataset.max(0); long height = outputDataset.max(1); System.out.printf("width = %d, height = %d\n", width, height); Timer lineTimer = timerService.getTimer("LineTimer"); Timer pixelTimer = timerService.getTimer("PixelTimer"); long[] outputPosition = new long[2]; for (long x = 0; x != width; x++) { for (long y = 0; y != height; y++) { pixelTimer.start();//from w ww . j a v a 2 s.c o m position[0] = x; position[1] = y; outputPosition[0] = x; outputPosition[1] = y; inputCursor.setPosition(position); outputCursor.setPosition(outputPosition); outputCursor.get().set(inputCursor.get()); pixelTimer.measure("pixel reading"); } lineTimer.measure("reading one line"); System.out.println("line " + x); } pixelTimer.logAll(); lineTimer.logAll(); System.out.println("Dataset on the track !"); return outputDataset; }
From source file:com.vmware.bdd.cli.http.HttpClientProvider.java
@Bean(name = SECURE_HTTP_CLIENT) @Qualifier(SECURE_HTTP_CLIENT)/* w w w . j av a2 s . com*/ public HttpClient secureHttpClient() throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException { SSLContext sslContext = SSLContexts.custom().useTLS().build(); sslContext.init(null, new TrustManager[] { trustManager }, null); String[] supportedProtocols = cliProperties.getSupportedProtocols(); String[] supportedCipherSuites = cliProperties.getSupportedCipherSuites(); String hostnameVerifier = cliProperties.getHostnameVerifier(); if (LOGGER.isDebugEnabled()) { LOGGER.debug("supported protocols: " + ArrayUtils.toString(supportedProtocols)); LOGGER.debug("supported cipher suites: " + ArrayUtils.toString(supportedCipherSuites)); LOGGER.debug("hostname verifier: " + hostnameVerifier); } SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(sslContext, supportedProtocols, supportedCipherSuites, getHostnameVerifier(hostnameVerifier)); Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create() .register("http", PlainConnectionSocketFactory.getSocketFactory()).register("https", socketFactory) .build(); PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(socketFactoryRegistry); cm.setMaxTotal(20); cm.setDefaultMaxPerRoute(10); // HttpHost proxy = new HttpHost("127.0.0.1", 8810, "http"); // HttpClient client1 = HttpClients.custom().setSSLSocketFactory(socketFactory).setProxy(proxy).build(); HttpClient client1 = HttpClients.custom().setSSLSocketFactory(socketFactory).build(); return client1; }
From source file:com.opengamma.install.launch.MainRunner.java
protected String[] getParameters(String args) { s_logger.debug("processing args [{}]", args); args = StringUtils.trimToNull(args); final String[] tokens = StringUtils.split(args); String[] result = null;//from ww w . j a v a2 s. com if (tokens != null) { List<String> argList = Lists.newArrayList(); StringBuilder strBuilder = new StringBuilder(); for (String token : tokens) { boolean processed = false; if (token.startsWith("'")) { strBuilder.append(token); processed = true; } if (token.endsWith("'")) { if (strBuilder.length() != 0) { if (!processed) { strBuilder.append(" ").append(token); } argList.add(strBuilder.substring(1, strBuilder.length() - 1)); } else { argList.add(token); } strBuilder = new StringBuilder(); processed = true; } if (!processed) { if (strBuilder.length() == 0) { argList.add(token); } else { strBuilder.append(" ").append(token); } } } if (strBuilder.length() != 0) { argList.addAll(Arrays.asList(StringUtils.split(strBuilder.toString()))); } result = argList.toArray(new String[] {}); } s_logger.debug("processed args {}", ArrayUtils.toString(result)); return result; }
From source file:edu.cornell.med.icb.learning.libsvm.LibSvmClassifier.java
public double predict(final ClassificationModel trainingModel, final ClassificationProblem problem, final int instanceIndex, final double[] probabilities) { final svm_model model = getNativeModel(trainingModel); if (svm.svm_check_probability_model(model) == 1) { LOG.debug("estimating probabilities"); final svm_problem nativeProblem = getNativeProblem(problem); if (LOG.isTraceEnabled()) { printNodes(instanceIndex, nativeProblem); }// www.j a v a 2s .c o m // the SVM was trained to estimate probabilities. Return estimated probabilities. final double decision = svm.svm_predict_probability(getNativeModel(trainingModel), nativeProblem.x[instanceIndex], probabilities); if (LOG.isDebugEnabled()) { LOG.debug("decision values: " + ArrayUtils.toString(probabilities)); } return decision; } else { // Regular SVM was not trained to estimate probability. Report the decision function in place of estimated // probabilities. LOG.debug( "substituting decision values for probabilities. The SVM was not trained to estimate probabilities."); final svm_problem nativeProblem = getNativeProblem(problem); if (LOG.isTraceEnabled()) { printNodes(instanceIndex, nativeProblem); } svm.svm_predict_values(getNativeModel(trainingModel), nativeProblem.x[instanceIndex], probabilities); probabilities[0] = Math.abs(probabilities[0]); probabilities[1] = Double.NEGATIVE_INFINITY; // make sure probs[0] is max of the two values. if (LOG.isDebugEnabled()) { LOG.debug("decision values: " + ArrayUtils.toString(probabilities)); } final double decision = svm.svm_predict(getNativeModel(trainingModel), getNativeProblem(problem).x[instanceIndex]); if (LOG.isDebugEnabled()) { LOG.debug("decision: " + decision); } return decision; } }
From source file:com.graphaware.module.algo.generator.BarabasiAlbertGeneratorTest.java
@Test public void shouldGeneratePowerLawDistribution() { GraphDatabaseService database = new TestGraphDatabaseFactory().newImpermanentDatabase(); new Neo4jGraphGenerator(database).generateGraph(getGeneratorConfiguration(100, 2)); List<Integer> degrees = new LinkedList<>(); try (Transaction tx = database.beginTx()) { for (Node node : GlobalGraphOperations.at(database).getAllNodes()) { degrees.add(node.getDegree()); }//from ww w .jav a 2s .com tx.success(); } Collections.sort(degrees, Collections.reverseOrder()); //todo make this an automated test System.out.println(ArrayUtils.toString(degrees.toArray(new Integer[degrees.size()]))); database.shutdown(); }