List of usage examples for org.json.simple JSONObject get
V get(Object key);
From source file:edu.rit.chrisbitler.ritcraft.slackintegration.rtm.types.MsgMessage.java
/** * Handle the 'message' type event from slack * @param object The event object passed from slack *//* ww w .j a va 2s . com*/ public static void handle(JSONObject object) { String userName = (String) object.get("user"); String text = (String) object.get("text"); String channel = (String) object.get("channel"); if (userName != null && !userName.equals("null")) { //If the text doesn't start with a !, which denotes a command, //Send users the message and username based on the mappings if //the username is not null (aka the bot), and the chhanel is the relay channel if (!text.startsWith("!")) { if (channel.equals(SlackIntegration.RELAY_CHANNEL)) { text = UserList.replaceAllUserIDs(text); Util.broadcast(UserList.getName(userName) + ": " + StringEscapeUtils.unescapeHtml(text)); } else if (channel.equals(SlackIntegration.ADMIN_CHANNEL)) { text = UserList.replaceAllUserIDs(text); Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "amsg [" + UserList.getName(userName) + "] " + StringEscapeUtils.unescapeHtml(text)); } } else { //Split the message into parts based on spaces and check the command to see //if it exists String[] parts = text.split(" "); String command = parts[0].substring(1); if (CommandRegistry.getCommand(command) != null) { Command cmd = CommandRegistry.getCommand(command); //Check to see if we are in the right channel for the command if (cmd.getApplicableChannels().contains(channel) || (cmd.getApplicableChannels().size() == 1 && cmd.getApplicableChannels().get(0).equalsIgnoreCase("all"))) { //Process it with the args shifted forward by one cmd.processCommand(channel, Util.shiftArray(parts, 1)); } } } } }
From source file:kr.co.bitnine.octopus.schema.metamodel.OctopusMetaModelDataContextFactory.java
public static DataContext createCouchDbDataContext(JSONObject jsonObject) { DataContext dc;/* w w w .j av a 2s . c o m*/ String host = (String) jsonObject.get("host"); String port = (String) jsonObject.get("port"); String userName = (String) jsonObject.get("user"); String password = (String) jsonObject.get("password"); dc = DataContextFactory.createCouchDbDataContext(host, Integer.parseInt(port), userName, password); return dc; }
From source file:kr.co.bitnine.octopus.schema.metamodel.OctopusMetaModelDataContextFactory.java
public static DataContext createCassandraDataContext(JSONObject jsonObject) { DataContext dc;// w ww. j a v a 2 s .c o m String host = (String) jsonObject.get("host"); String port = (String) jsonObject.get("port"); String database = (String) jsonObject.get("database"); Cluster cluster = Cluster.builder().withPort(Integer.parseInt(port)).addContactPoint(host).build(); dc = DataContextFactory.createCassandraDataContext(cluster, database); return dc; }
From source file:kr.co.bitnine.octopus.schema.metamodel.OctopusMetaModelDataContextFactory.java
public static DataContext createElasticSearchDataContext(JSONObject jsonObject) { DataContext dc;/* w w w .j a v a 2s .c o m*/ String host = (String) jsonObject.get("host"); String port = (String) jsonObject.get("port"); String database = (String) jsonObject.get("database"); Client client = new TransportClient() .addTransportAddress(new InetSocketTransportAddress(host, Integer.parseInt(port))); dc = DataContextFactory.createElasticSearchDataContext(client, database); return dc; }
From source file:kr.co.bitnine.octopus.schema.metamodel.OctopusMetaModelDataContextFactory.java
public static DataContext createMongoDbDataContext(JSONObject jsonObject) { DataContext dc;/*from w ww . j a va2 s . co m*/ String host = (String) jsonObject.get("host"); String port = (String) jsonObject.get("port"); String database = (String) jsonObject.get("database"); String userName = (String) jsonObject.get("user"); String password = (String) jsonObject.get("password"); dc = DataContextFactory.createMongoDbDataContext(host, Integer.parseInt(port), database, userName, password.toCharArray()); return dc; }
From source file:com.articulate.sigma.nlp.SimFloodTest.java
/** *************************************************************** *//*from w w w . j a va 2 s. co m*/ @Parameterized.Parameters(name = "<{0}> {1}") public static Collection<Object[]> prepare() { return JsonReader.transform("QA/json/IRtests.json", (JSONObject jo) -> { String fname = (String) jo.get("file"); String query = (String) jo.get("query"); String answer = (String) jo.get("answer"); return new Object[] { fname, query, answer }; }); }
From source file:biomine.bmvis2.crawling.Databases.java
public static Collection<String> getDatabases() { if (dbs != null) return dbs; try {/* ww w. j ava 2s . co m*/ String url = WebConstants.BIOMINE_URL + "stats/index.cgi?json_action=getdbs"; String cont = URLUtils.getURLContents(new URL(url)); Object arr = JSONValue.parse(cont); if (arr instanceof JSONArray) { JSONArray jarr = (JSONArray) arr; dbs = new ArrayList(); for (Object dbo : jarr) { JSONObject jdb = (JSONObject) dbo; Object no = jdb.get("name"); if (no != null) dbs.add(no.toString()); } Collections.reverse(dbs); return dbs; } } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ClassCastException e) { // TODO: handle exception } return Collections.EMPTY_LIST; }
From source file:autoancillarieslimited.action.item.DeleteFile.java
public static Item parserItem(String dataJson) { try {/* w ww. ja v a 2s . c o m*/ Item i = new Item(); JSONParser parser = new JSONParser(); Object obj = parser.parse(dataJson); JSONObject jsonObject = (JSONObject) obj; int id = Integer.parseInt((String) jsonObject.get("P0")); System.out.println(id); String file_delete = (String) jsonObject.get("P1"); i.setId(id); i.setImages(file_delete); return i; } catch (Exception ex) { return null; } }
From source file:naftoreiclag.villagefive.util.json.JSONUtil.java
public static <ConcreteJSONThingy extends JSONThingy> List<ConcreteJSONThingy> readList(JSONObject data, String key, ConcreteJSONThingy expectedType) { return readList((JSONArray) data.get(key), expectedType); }
From source file:MyTest.ParseJson.java
private static void getDetailInfo(JSONObject jstep_detail) { // System.out.println(jstep_detail); long id = (long) jstep_detail.get("id"); System.out.println("id:" + id); String name = (String) jstep_detail.get("name"); System.out.println("name:" + name); JSONArray inputs = (JSONArray) jstep_detail.get("inputs"); if (inputs.isEmpty()) { System.out.println("inputs:null"); } else {// ww w. java 2 s . co m System.out.println("inputs:"); for (int i = 0; i < inputs.size(); i++) { System.out.println(inputs.get(i) + "\n"); } } JSONArray outpus = (JSONArray) jstep_detail.get("outputs"); if (outpus.isEmpty()) { System.out.println("outpus:null"); } else { System.out.println("outpus:"); for (int i = 0; i < outpus.size(); i++) { System.out.print(outpus.get(i) + "\n"); } } JSONObject links = (JSONObject) jstep_detail.get("input_connections"); if (links.isEmpty()) { System.out.println("input_connections:null"); } else { Iterator it = links.keySet().iterator(); System.out.println("input_connections: "); while (it.hasNext()) { Object input_link = it.next(); System.out.println(links.get(input_link)); } } System.out.println("-------------------------------------------------------"); }