List of usage examples for java.lang String toString
public String toString()
From source file:cc.kave.episodes.export.StreamFrequencies.java
public void frequencies() throws ZipException, IOException { EventStreamGenerator generator = new EventStreamGenerator(); for (String zip : findZips()) { Logger.log("Reading zip file %s", zip.toString()); ReadingArchive ra = rootDir.getReadingArchive(zip); while (ra.hasNext()) { Context ctx = ra.getNext(Context.class); if (ctx == null) { continue; }/*from ww w . ja va2 s . c o m*/ generator.add(ctx); } ra.close(); } List<Event> es = generator.getEventStream(); Map<Event, Integer> freqs = statistics.getFrequencies(es); getOutlierEvent(freqs); // Map<Integer, Integer> distr = statistics.getFreqDistr(freqs); // storeFreqs(freqs); // storeDistr(distr); }
From source file:com.couchbase.sqoop.mapreduce.db.CouchbaseRecordReadSerializeTest.java
@Before @Override/*w ww. ja v a2s. c o m*/ public void setUp() throws Exception { super.setUp(); tappedStuff = new HashMap<String, ResponseMessage>(); URI uri = new URI(CouchbaseUtils.CONNECT_STRING); String user = CouchbaseUtils.COUCHBASE_USER_NAME; String pass = CouchbaseUtils.COUCHBASE_USER_PASS; try { cb = new CouchbaseClient(Arrays.asList(uri), user, pass); } catch (IOException e) { LOG.error("Couldn't connect to server" + e.getMessage()); fail(e.toString()); } this.client = new TapClient(Arrays.asList(uri), user, pass); cb.flush(); Thread.sleep(500); // set up the items we're going to deserialize Integer anint = new Integer(Integer.MIN_VALUE); cb.set(anint.toString(), 0x300, anint).get(); Long along = new Long(Long.MAX_VALUE); cb.set(along.toString(), 0, along).get(); Float afloat = new Float(Float.MAX_VALUE); cb.set(afloat.toString(), 0, afloat).get(); Double doubleBase = new Double(Double.NEGATIVE_INFINITY); cb.set(doubleBase.toString(), 0, doubleBase).get(); Boolean booleanBase = true; cb.set(booleanBase.toString(), 0, booleanBase).get(); rightnow = new Date(); // instance, needed later dateText = rightnow.toString().replaceAll(" ", "_"); cb.set(dateText, 0, rightnow).get(); Byte byteMeSix = new Byte("6"); cb.set(byteMeSix.toString(), 0, byteMeSix).get(); String ourString = "hi,there"; cb.set(ourString.toString(), 0, ourString).get(); client.tapDump("tester"); while (client.hasMoreMessages()) { ResponseMessage m = client.getNextMessage(); if (m == null) { continue; } tappedStuff.put(m.getKey(), m); } }
From source file:com.mobiquitynetworks.statsutilspig.keysCombinations.java
@Override /* /* w ww . ja va 2s.c o m*/ * Method that is executed when a UDF is called * Recieves a tuple of the following form: * ([device.idDev#9B5C0249-4F61-4A8F-9591-994625197C6E,app#dbf158bc74de36e5a7ebec145d1524887fc9313b,event.value.beacon#539850be6375f9c787ff07ce,event.value.notification#,event.type#MOB,device.idFA#,event.localtime#2015-01-24T14:36:04.466+01:00,device.os#iOS,event.extType#BCN,event.timestamp#2015-01-24T19:36:04.466+01:00,event.action#ENT,clientId#53b19a6b0af550e07817962f], [venue.type#mall,venue.country#us,beaconId#539850be6375f9c787ff07ce,venue.id#5476cfd1a20d45dd20e8dd0a,venue.location.state#NY,venue.name#Smith Haven Mall,venue.metrics.dma#1], venue.id|venue.location.state|event.value.notification|app|clientId|venue.name,*|venue.location.state|event.value.notification|app|clientId|venue.name,venue.id|*|event.value.notification|app|clientId|venue.name,venue.id|venue.location.state|*|app|clientId|venue.name,venue.id|venue.location.state|event.value.notification|*|clientId|venue.name,venue.id|venue.location.state|event.value.notification|app|*|venue.name,venue.id|venue.location.state|event.value.notification|app|clientId|*,*|*|event.value.notification|app|clientId|venue.name,*|venue.location.state|*|app|clientId|venue.name,*|venue.location.state|event.value.notification|*|clientId|venue.name,*|venue.location.state|event.value.notification|app|*|venue.name,*|venue.location.state|event.value.notification|app|clientId|*,venue.id|*|*|app|clientId|venue.name,venue.id|*|event.value.notification|*|clientId|venue.name,venue.id|*|event.value.notification|app|*|venue.name,venue.id|*|event.value.notification|app|clientId|*,venue.id|venue.location.state|*|*|clientId|venue.name,venue.id|venue.location.state|*|app|*|venue.name,venue.id|venue.location.state|*|app|clientId|*,venue.id|venue.location.state|event.value.notification|*|*|venue.name,venue.id|venue.location.state|event.value.notification|*|clientId|*,venue.id|venue.location.state|event.value.notification|app|*|*,*|*|*|app|clientId|venue.name,*|*|event.value.notification|*|clientId|venue.name,*|*|event.value.notification|app|*|venue.name,*|*|event.value.notification|app|clientId|*,*|venue.location.state|*|*|clientId|venue.name,*|venue.location.state|*|app|*|venue.name,*|venue.location.state|*|app|clientId|*,*|venue.location.state|event.value.notification|*|*|venue.name,*|venue.location.state|event.value.notification|*|clientId|*,*|venue.location.state|event.value.notification|app|*|*,venue.id|*|*|*|clientId|venue.name,venue.id|*|*|app|*|venue.name,venue.id|*|*|app|clientId|*,venue.id|*|event.value.notification|*|*|venue.name,venue.id|*|event.value.notification|*|clientId|*,venue.id|*|event.value.notification|app|*|*,venue.id|venue.location.state|*|*|*|venue.name,venue.id|venue.location.state|*|*|clientId|*,venue.id|venue.location.state|*|app|*|*,venue.id|venue.location.state|event.value.notification|*|*|*,*|*|*|*|clientId|venue.name,*|*|*|app|*|venue.name,*|*|*|app|clientId|*,*|*|event.value.notification|*|*|venue.name,*|*|event.value.notification|*|clientId|*,*|*|event.value.notification|app|*|*,*|venue.location.state|*|*|*|venue.name,*|venue.location.state|*|*|clientId|*,*|venue.location.state|*|app|*|*,*|venue.location.state|event.value.notification|*|*|*,venue.id|*|*|*|*|venue.name,venue.id|*|*|*|clientId|*,venue.id|*|*|app|*|*,venue.id|*|event.value.notification|*|*|*,venue.id|venue.location.state|*|*|*|*,*|*|*|*|*|venue.name,*|*|*|*|clientId|*,*|*|*|app|*|*,*|*|event.value.notification|*|*|*,*|venue.location.state|*|*|*|*,venue.id|*|*|*|*|*,*|*|*|*|*|*)) * The input is formed by 3 fields, is a tuple that contains 2 tuples and a string, the first 2 tuples correspond to the event info and * the venue info respectively and the string is the possible combinations we can get with the features to get metrics from * * @param input Is the Tuple that pig passes to the UDF * @return statistics Returns a map structure that pig can read and later save as a JSON in mongoDB. * */ public DataBag exec(Tuple tuple) throws IOException { // Bag to return DataBag bagToReturn = mBagFactory.newDefaultBag(); // getting input data // event info Map<String, Object> event = (Map<String, Object>) tuple.get(0); // venue info Map<String, Object> venue = (Map<String, Object>) tuple.get(1); // combinations String dimensions = (String) tuple.get(2); // combinations as array String[] dimensionsArray = dimensions.split(","); event.putAll(venue); for (String combination : dimensionsArray) { String key = ""; String[] combinationDimension = combination.split("\\|"); Tuple finalEvent = mTupleFactory.newTuple(); //finalEvent.append(tuple.get(0)); //finalEvent.append(tuple.get(1)); for (String field : combinationDimension) { if (field.toString().equals("*")) { key = key + "*|"; } else { Object value = event.get(field); if (value != null) { key = key + value.toString() + "|"; } else { key = key + "|"; } } } key = key.substring(0, key.length() - 1); finalEvent.append(key); finalEvent.append(event.get("event.localtime")); finalEvent.append(event.get("device.idFA")); finalEvent.append(event.get("device.idDev")); bagToReturn.add(finalEvent); } return bagToReturn; }
From source file:uk.co.threeonefour.ifictionary.web.user.dao.JpaUserDao.java
@Transactional @Override/*from ww w . j ava2s . c o m*/ public User findUser(String userId) { String query = "SELECT u FROM User AS u WHERE userId=:userId"; EntityManager em = entityManager; Query q = em.createQuery(query.toString()); q.setParameter("userId", userId); try { return (User) q.getSingleResult(); } catch (NoResultException e) { return null; } }
From source file:genepi.db.JdbcDataAccessObject.java
public int update(String sql) throws SQLException { return runner.update(sql.toString()); }
From source file:org.jasig.portlet.cms.controller.ConfigController.java
@ActionMapping protected void handleAction(final ActionRequest request, final ActionResponse response) throws Exception { final PortletPreferencesWrapper pref = new PortletPreferencesWrapper(request); final Object[] keys = pref.getKeys(); final Map<String, ?> params = request.getParameterMap(); ScheduledPostsManager.getInstance().removeRepositoryRoot(pref.getPortletRepositoryRoot()); for (final Object keyObj : keys) { String key = keyObj.toString(); final String value = request.getParameter(key); if (params.containsKey(key.toString())) pref.setProperty(key.toString(), value); else if (value == null) pref.setProperty(key, false); }/*from w w w. ja v a 2s . c o m*/ logDebug("Saving portlet preferences..."); pref.save(); ScheduledPostsManager.getInstance().addRepositoryRoot(pref.getPortletRepositoryRoot()); response.setPortletMode(PortletMode.VIEW); }
From source file:cc.osint.graphd.client.handlers.WebsocketEventHandler.java
public void onMessageEvent(String channel, String message) { try {//from ww w . j a v a2 s. co m JSONObject obj = new JSONObject(message); ctx.getChannel().write(new DefaultWebSocketFrame("! " + channel + " " + message.toString().trim())); log.info("onMessageEvent: <" + channel + "> " + obj.toString(4)); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:com.taobao.tddl.common.sync.RowBasedReplicationExecutor.java
/** * jdbcdelete//from w w w.j av a2 s .c o m */ public static void batchDeleteSyncLog(Collection<RowBasedReplicationContext> contexts) { long timeused, time0 = System.currentTimeMillis(); String sqlpattern = "delete from sync_log_{0} where id = ?"; /** * RowBasedReplicationContextupdateSql */ Map<JdbcTemplate, Map<String/*logSQL*/, List<RowBasedReplicationContext>>> sortedContexts = buildSortedContexts( contexts, sqlpattern.toString()); for (Map.Entry<JdbcTemplate, Map<String, List<RowBasedReplicationContext>>> e0 : sortedContexts .entrySet()) { JdbcTemplate jt = e0.getKey(); for (Map.Entry<String, List<RowBasedReplicationContext>> e : e0.getValue().entrySet()) { final List<RowBasedReplicationContext> endContexts = e.getValue(); BatchPreparedStatementSetter setter = new BatchPreparedStatementSetter() { public int getBatchSize() { return endContexts.size(); } public void setValues(PreparedStatement ps, int i) throws SQLException { RowBasedReplicationContext context = endContexts.get(i); ps.setString(1, context.getSyncLogId()); } }; jt.batchUpdate(e.getKey(), setter); if (log.isDebugEnabled()) { log.debug("[batchDeleteSyncLog], sql = [" + e.getKey() + "], batch size=" + endContexts.size()); } } } timeused = System.currentTimeMillis() - time0; log.warn(contexts.size() + " replication logs deleted, time used:" + timeused); Monitor.add(Monitor.KEY1, Monitor.KEY2_SYNC, Monitor.KEY3_BatchDeleteSyncLog, contexts.size(), timeused); }
From source file:mina.UnsyncClientSupport.java
/** * ?'0'??/*from w ww.j a v a2 s.com*/ * * @param msg * @return */ public String getMessageStrLen(String msg) { int len = msg.toString().getBytes().length; String slen = String.valueOf(len); int n = slen.toCharArray().length; char[] c = { '0', '0', '0', '0' }; for (int i = 0; i < n; ++i) { c[4 - i - 1] = slen.toCharArray()[n - i - 1]; } slen = new String(c); return slen; }
From source file:io.fabric8.profiles.containers.wildfly.YamlTransformer.java
public YamlTransformer(Properties properties) { Enumeration<?> names = properties.propertyNames(); while (names.hasMoreElements()) { String key = (String) names.nextElement(); if (key.toString().startsWith("namespace.")) { String value = properties.getProperty(key); namespaces.put(key.substring(10), Namespace.getNamespace(value)); }//from w w w. j ava2 s. com } }