List of usage examples for org.apache.commons.lang3 ArrayUtils toString
public static String toString(final Object array)
Outputs an array as a String, treating null as an empty array.
Multi-dimensional arrays are handled correctly, including multi-dimensional primitive arrays.
The format is that of Java source code, for example {a,b}.
From source file:com.precioustech.fxtrading.oanda.restapi.marketdata.historic.HistoricMarketDataOnDemandDemo.java
public static void main(String[] args) throws Exception { usage(args);//from ww w .ja v a 2 s. c om final String url = args[0]; final String accessToken = args[1]; HistoricMarketDataProvider<String> historicMarketDataProvider = new OandaHistoricMarketDataProvider(url, accessToken); Scanner scanner = new Scanner(System.in); scanner.useDelimiter(System.getProperty("line.separator")); System.out.print("Instrument" + TradingConstants.COLON); String ccyPair = scanner.next(); TradeableInstrument<String> instrument = new TradeableInstrument<>(ccyPair.toUpperCase()); System.out.print( "Granularity" + ArrayUtils.toString(CandleStickGranularity.values()) + TradingConstants.COLON); CandleStickGranularity granularity = CandleStickGranularity.valueOf(scanner.next().toUpperCase()); System.out.print("Time Range Candles(t) or Last N Candles(n)?:"); String choice = scanner.next(); List<CandleStick<String>> candles = null; if ("t".equalsIgnoreCase(choice)) { System.out.print("Start Time(" + datefmtLabel + ")" + TradingConstants.COLON); String startStr = scanner.next(); Date startDt = sdf.parse(startStr); System.out.print(" End Time(" + datefmtLabel + ")" + TradingConstants.COLON); String endStr = scanner.next(); Date endDt = sdf.parse(endStr); candles = historicMarketDataProvider.getCandleSticks(instrument, granularity, new DateTime(startDt.getTime()), new DateTime(endDt.getTime())); } else { System.out.print("Last how many candles?" + TradingConstants.COLON); int n = scanner.nextInt(); candles = historicMarketDataProvider.getCandleSticks(instrument, granularity, n); } System.out.println(center("Time", timeColLen) + center("Open", priceColLen) + center("Close", priceColLen) + center("High", priceColLen) + center("Low", priceColLen)); System.out.println(repeat("=", timeColLen + priceColLen * 4)); for (CandleStick<String> candle : candles) { System.out.println(center(sdf.format(candle.getEventDate().toDate()), timeColLen) + formatPrice(candle.getOpenPrice()) + formatPrice(candle.getClosePrice()) + formatPrice(candle.getHighPrice()) + formatPrice(candle.getLowPrice())); } scanner.close(); }
From source file:com.github.liyp.test.TestMain.java
@SuppressWarnings("unchecked") public static void main(String[] args) { // add a shutdown hook to stop the server Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { @Override/*from w ww .j a v a 2 s.c o m*/ public void run() { System.out.println("########### shoutdown begin...."); try { Thread.sleep(10000); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("########### shoutdown end...."); } })); System.out.println(args.length); Iterator<String> iterator1 = IteratorUtils .arrayIterator(new String[] { "one", "two", "three", "11", "22", "AB" }); Iterator<String> iterator2 = IteratorUtils.arrayIterator(new String[] { "a", "b", "c", "33", "ab", "aB" }); Iterator<String> chainedIter = IteratorUtils.chainedIterator(iterator1, iterator2); System.out.println("=================="); Iterator<String> iter = IteratorUtils.filteredIterator(chainedIter, new Predicate() { @Override public boolean evaluate(Object arg0) { System.out.println("xx:" + arg0.toString()); String str = (String) arg0; return str.matches("([a-z]|[A-Z]){2}"); } }); while (iter.hasNext()) { System.out.println(iter.next()); } System.out.println("==================="); System.out.println("asas".matches("[a-z]{4}")); System.out.println("Y".equals(null)); System.out.println(String.format("%02d", 1000L)); System.out.println(ArrayUtils.toString(splitAndTrim(" 11, 21,12 ,", ","))); System.out.println(new ArrayList<String>().toString()); JSONObject json = new JSONObject("{\"keynull\":null}"); json.put("bool", false); json.put("keya", "as"); json.put("key2", 2212222222222222222L); System.out.println(json); System.out.println(json.get("keynull").equals(null)); String a = String.format("{\"id\":%d,\"method\":\"testCrossSync\"," + "\"circle\":%d},\"isEnd\":true", 1, 1); System.out.println(a.getBytes().length); System.out.println(new String[] { "a", "b" }); System.out.println(new JSONArray("[\"aa\",\"\"]")); String data = String.format("%9d %s", 1, RandomStringUtils.randomAlphanumeric(10)); System.out.println(data.getBytes().length); System.out.println(ArrayUtils.toString("1|2| 3| 333||| 3".split("\\|"))); JSONObject j1 = new JSONObject("{\"a\":\"11111\"}"); JSONObject j2 = new JSONObject(j1.toString()); j2.put("b", "22222"); System.out.println(j1 + " | " + j2); System.out.println("======================"); String regex = "\\d+(\\-\\d+){2} \\d+(:\\d+){2}"; Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher("2015-12-28 15:46:14 _NC250_MD:motion de\n"); String eventDate = matcher.find() ? matcher.group() : ""; System.out.println(eventDate); }
From source file:com.pushtechnology.consulting.Benchmarker.java
public static void main(String[] args) throws InterruptedException { LOG.info("Starting Java Benchmark Suite v{}", Benchmarker.class.getPackage().getImplementationVersion()); final Arguments arguments = Arguments.parse(args); try {/*from www . j a va 2 s . c o m*/ LOG.debug("Trying to set client InboundThreadPool queue size to '{}'", CLIENT_INBOUND_QUEUE_QUEUE_SIZE); final ThreadsConfig threadsConfig = ConfigManager.getConfig().getThreads(); final ThreadPoolConfig inboundPool = threadsConfig.addPool(CLIENT_INBOUND_THREAD_POOL_NAME); inboundPool.setQueueSize(CLIENT_INBOUND_QUEUE_QUEUE_SIZE); inboundPool.setCoreSize(CLIENT_INBOUND_QUEUE_CORE_SIZE); inboundPool.setMaximumSize(CLIENT_INBOUND_QUEUE_MAX_SIZE); threadsConfig.setInboundPool(CLIENT_INBOUND_THREAD_POOL_NAME); LOG.debug("Successfully set client InboundThreadPool queue size to '{}'", CLIENT_INBOUND_QUEUE_QUEUE_SIZE); } catch (APIException ex) { LOG.error("Failed to set client inbound pool size to '{}'", CLIENT_INBOUND_QUEUE_QUEUE_SIZE); ex.printStackTrace(); } connectThreadPool = Executors.newScheduledThreadPool(arguments.connectThreadPoolSize); final Publisher publisher; if (arguments.doPublish) { LOG.info("Creating Publisher with connection string: '{}'", arguments.publisherConnectionString); publisher = new Publisher(arguments.publisherConnectionString, arguments.publisherUsername, arguments.publisherPassword, arguments.topics, arguments.topicType); publisher.start(); publisherMonitor = globalThreadPool.scheduleAtFixedRate(new Runnable() { @Override public void run() { LOG.trace("publisherMonitor fired"); LOG.info("There are {} publishers running for topics: '{}'", publisher.getUpdaterFuturessByTopic().size(), ArrayUtils.toString(publisher.getUpdaterFuturessByTopic().keySet())); for (ScheduledFuture<?> svc : publisher.getUpdaterFuturessByTopic().values()) { if (svc.isCancelled()) { LOG.debug("Service is cancelled..."); } if (svc.isDone()) { LOG.debug("Service is done..."); } } LOG.trace("Done publisherMonitor fired"); } }, 2L, 5L, SECONDS); } else { publisher = null; } /* Create subscribing sessions. Finite or churning */ if (arguments.doCreateSessions) { if (arguments.maxNumSessions > 0) { LOG.info("Creating {} Sessions with connection string: '{}'", arguments.maxNumSessions, arguments.sessionConnectionString); } else { LOG.info("Creating Sessions with connection string: '{}s'", arguments.sessionConnectionString); LOG.info("Creating Sessions at {}/second, disconnecting after {} seconds", arguments.sessionRate, arguments.sessionDuration); } sessionCreator = new SessionCreator(arguments.sessionConnectionString, arguments.myTopics, arguments.topicType); LOG.info( "Sessions: [Connected] [Started] [Recovering] [Closed] [Ended] [Failed] | Messages: [Number] [Bytes]"); sessionsCounter = globalThreadPool.scheduleAtFixedRate(new Runnable() { @Override public void run() { LOG.trace("sessionsCounter fired"); LOG.info("Sessions: {} {} {} {} {} {} | Messages: {} {}", sessionCreator.getConnectedSessions().get(), sessionCreator.getStartedSessions().get(), sessionCreator.getRecoveringSessions().get(), sessionCreator.getClosedSessions().get(), sessionCreator.getEndedSessions().get(), sessionCreator.getConnectionFailures().get(), sessionCreator.getMessageCount().getAndSet(0), sessionCreator.getMessageByteCount().getAndSet(0)); LOG.trace("Done sessionsCounter fired"); } }, 0L, 5L, SECONDS); if (arguments.maxNumSessions > 0) { sessionCreator.start(arguments.maxNumSessions); } else { sessionCreator.start(arguments.sessionRate, arguments.sessionDuration); } } RUNNING_LATCH.await(); if (arguments.doPublish) { if (publisher != null) { publisher.shutdown(); } publisherMonitor.cancel(false); } if (arguments.doCreateSessions) { sessionCreator.shutdown(); sessionsCounter.cancel(false); } if (!globalThreadPool.isTerminated()) { try { globalThreadPool.awaitTermination(1L, SECONDS); } catch (InterruptedException e) { e.printStackTrace(); } } }
From source file:net.sf.sessionAnalysis.SessionAnalyzer.java
public static void main(String[] args) throws IOException { final SessionDatReader sessionDatReader = new SessionDatReader(INPUT_SESSIONS_DAT_FN); final SessionVisitorSessionLengthNumActionsStatistics sessionVisitorSessionLengthStatistics = new SessionVisitorSessionLengthNumActionsStatistics(); sessionDatReader.registerVisitor(sessionVisitorSessionLengthStatistics); final SessionVisitorSessionLengthNanosStatistics sessionVisitorSessionLengthNanosStatistics = new SessionVisitorSessionLengthNanosStatistics(); sessionDatReader.registerVisitor(sessionVisitorSessionLengthNanosStatistics); final SessionVisitorMinMaxTimeStamp sessionVisitorMinMaxTimeStamp = new SessionVisitorMinMaxTimeStamp(); sessionDatReader.registerVisitor(sessionVisitorMinMaxTimeStamp); final SessionVisitorResponseTimes sessionVisitorResponseTimes = new SessionVisitorResponseTimes(); sessionDatReader.registerVisitor(sessionVisitorResponseTimes); final SessionVisitorArrivalAndCompletionRate sessionVisitorArrivalAndCompletionRate = new SessionVisitorArrivalAndCompletionRate( 1, TimeUnit.MINUTES); sessionDatReader.registerVisitor(sessionVisitorArrivalAndCompletionRate); SessionVisitorRequestTypeCounter sessionVisitorRequestTypeCounter = new SessionVisitorRequestTypeCounter(); sessionDatReader.registerVisitor(sessionVisitorRequestTypeCounter); final SessionVisitorDistinctSessions sessionVisitorDistinctSessions = new SessionVisitorDistinctSessions(); sessionDatReader.registerVisitor(sessionVisitorDistinctSessions); final SessionVisitorBehaviorMix sessionVisitorBehaviorMix = new SessionVisitorBehaviorMix(); sessionDatReader.registerVisitor(sessionVisitorBehaviorMix); sessionDatReader.read();/*from w w w .j a v a2 s .com*/ /* * Session length histogram. Results can be compared analysis on raw * data: cat * ../evaluation/SPECjEnterprise-data/kieker-20110929-14382537- * UTC-blade3-KIEKER-SPECjEnterprise2010-20-min-excerpt-sessions.dat | * awk -F ";" '{print NF-1}' | sort -n | uniq -c | wc -l */ System.out.println( "Num sessions: " + sessionVisitorArrivalAndCompletionRate.getCompletionTimestamps().length); System.out.println("Num distinct sessions: " + sessionVisitorDistinctSessions.numDistinctSessions()); System.out .println("Length histogram: " + sessionVisitorSessionLengthStatistics.getSessionLengthHistogram()); sessionVisitorSessionLengthStatistics.writeSessionsOverTime(OUTPUT_DIR); //System.out.println("Length vector: " + ArrayUtils.toString(sessionVisitorSessionLengthStatistics.computeLengthVector())); System.out.println("Mean length (# user actions): " + sessionVisitorSessionLengthStatistics.computeSessionLengthMean()); System.out.println("Standard dev (# user actions): " + sessionVisitorSessionLengthStatistics.computeSessionLengthStdDev()); sessionVisitorSessionLengthNanosStatistics.writeSessionsOverTime(OUTPUT_DIR); System.out.println("Mean length (milliseconds): " + TimeUnit.MILLISECONDS.convert( (long) sessionVisitorSessionLengthNanosStatistics.computeSessionLengthMean(), TimeUnit.NANOSECONDS)); System.out.println("Standard dev (milliseconds): " + TimeUnit.MILLISECONDS.convert( (long) sessionVisitorSessionLengthNanosStatistics.computeSessionLengthStdDev(), TimeUnit.NANOSECONDS)); System.out.println( "Average Session Duration: " + sessionVisitorMinMaxTimeStamp.getAverageSessionTimeLength()); System.out.println("Timespan (nanos since epoche): " + sessionVisitorMinMaxTimeStamp.getMinTimeStamp() + " - " + sessionVisitorMinMaxTimeStamp.getMaxTimeStamp()); System.out.println("Timespan (local date/time): " + sessionVisitorMinMaxTimeStamp.getMinDateTime() + " - " + sessionVisitorMinMaxTimeStamp.getMaxDateTime()); { System.out.println("Arrival rates: " + ArrayUtils.toString(sessionVisitorArrivalAndCompletionRate.getArrivalRates())); System.out.println("Session duration rates: " + ArrayUtils.toString(sessionVisitorArrivalAndCompletionRate.getSessionDuration())); System.out.println("User action rates: " + ArrayUtils.toString(sessionVisitorArrivalAndCompletionRate.getUserActionRates())); System.out.println("Completion rates: " + ArrayUtils.toString(sessionVisitorArrivalAndCompletionRate.getCompletionRates())); System.out.println("Max number of sessions per time interval: " + ArrayUtils.toString(sessionVisitorArrivalAndCompletionRate.getMaxNumSessionsPerInterval())); sessionVisitorArrivalAndCompletionRate.writeArrivalCompletionRatesAndMaxNumSessions(OUTPUT_DIR); } { //System.out.println("Concurrent number of sessions over time" + sessionVisitorArrivalAndCompletionRate.getNumConcurrentSessionsOverTime()); sessionVisitorArrivalAndCompletionRate.writeSessionsOverTime(OUTPUT_DIR); } { sessionVisitorRequestTypeCounter.writeCallFrequencies(OUTPUT_DIR); } { sessionVisitorDistinctSessions.writeDistinctSessions(OUTPUT_DIR); } sessionVisitorResponseTimes.printResponseTimes(); sessionVisitorBehaviorMix.printRequestTypes(); }
From source file:com.rockhoppertech.music.examples.PatternFactoryExample.java
/** * @param patterns//from ww w . j a v a 2 s. c o m */ private static void printArray(List<int[]> patterns) { int num = 0; for (int[] a : patterns) { System.out.printf("%d:\t%s%n", num++, ArrayUtils.toString(a)); } }
From source file:io.netty.handler.codec.mqtt.MqttUnsubscribePayload.java
@Override public String toString() { return StringUtil.simpleClassName(this) + '[' + "topics=" + ArrayUtils.toString(topics) + ']'; }
From source file:io.netty.handler.codec.mqtt.MqttSubscribePayload.java
@Override public String toString() { return StringUtil.simpleClassName(this) + '[' + "subscriptions=" + ArrayUtils.toString(subscriptions) + ']'; }
From source file:be.pendragon.j2s.seventhcontinent.stats.Statistics.java
@Override public String toString() { return String.format("Avg=%f, Min=%d, Max=%d, Count=%d, Pct25=%f, Pct50=%f, Pct75=%f, Pct=%s", average, min, max, count, percentiles[24], percentiles[49], percentiles[74], ArrayUtils.toString(percentiles)); }
From source file:com.joptimizer.solvers.DiagonalKKTSolver.java
/** * Returns two vectors v and w.//from w ww . j a va 2 s . c om */ @Override public double[][] solve() throws Exception { RealVector v = null; RealVector w = null; if (Log.isLoggable(MainActivity.JOPTIMIZER_LOGTAG, Log.DEBUG)) { Log.d(MainActivity.JOPTIMIZER_LOGTAG, "H: " + ArrayUtils.toString(H.getData())); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "g: " + ArrayUtils.toString(g.toArray())); } v = new ArrayRealVector(g.getDimension()); for (int i = 0; i < v.getDimension(); i++) { v.setEntry(i, -g.getEntry(i) / H.getEntry(i, i)); } // solution checking if (this.checkKKTSolutionAccuracy && !this.checkKKTSolutionAccuracy(v, w)) { Log.e(MainActivity.JOPTIMIZER_LOGTAG, "KKT solution failed"); throw new Exception("KKT solution failed"); } double[][] ret = new double[2][]; ret[0] = v.toArray(); ret[1] = (w != null) ? w.toArray() : null; return ret; }
From source file:com.baidu.unbiz.easymapper.metadata.PropertyResolverTestCase.java
@Test public void test() { PropertyResolver propertyResolver = new IntrospectorPropertyResolver(true); Map<String, Property> propertyMap = propertyResolver.getProperties(TypeFactory.valueOf(PersonDto.class)); System.out.println(propertyMap); System.out.println(ArrayUtils.toString(Child.class.getInterfaces())); System.out.println(Child.class.getGenericSuperclass()); System.out.println(ArrayUtils.toString(Child.class.getGenericInterfaces())); }