org.json.simple.JSONArray#iterator ( )源码实例Demo

下面列出了org.json.simple.JSONArray#iterator ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: singleton   文件: TranslationProductAction.java
private JSONObject getBundle(String component, String locale, TranslationDTO allTranslationDTO) {
    
    JSONArray array = allTranslationDTO.getBundles();
    @SuppressWarnings("unchecked")
   Iterator<JSONObject> objectIterator =  array.iterator();
    
    while(objectIterator.hasNext()) {
        JSONObject object = objectIterator.next();
        String fileLocale = (String) object.get(ConstantsKeys.lOCALE);
        String fileComponent = (String) object.get(ConstantsKeys.COMPONENT);
        if(locale.equals(fileLocale)&& component.equals(fileComponent)) {    
            return object;
        }
    }
    
   return null; 
}
 
源代码2 项目: SeaCloudsPlatform   文件: CloudHarmonyCrawler.java
private void crawlComputeOfferings() {
    /* iaas section */
    String computeQuery = "https://cloudharmony.com/api/services?"
            + "api-key=" + API_KEY + "&"
            + "serviceTypes=compute";

    JSONObject resp = (JSONObject) query(computeQuery);

    if(resp == null) {
        return;
    }

    JSONArray computes = (JSONArray) resp.get("ids");

    Iterator<String> it = computes.iterator();
    while (it.hasNext()) {
        try {
            String serviceId = it.next();
            CloudHarmonyService chService = getService(serviceId, CloudTypes.IAAS);
            if (chService != null)
                generateOfferings(chService);
        } catch(Exception ex) {
            log.warn(ex.getMessage());
        }
    }
}
 
源代码3 项目: AIDR   文件: TextClickerPybossaFormatter.java
public boolean isTaskStatusCompleted(String data) throws Exception{
    /// will do later for importing process
    boolean isCompleted = false;
    if(DataFormatValidator.isValidateJson(data)){
        JSONParser parser = new JSONParser();
        Object obj = parser.parse(data);
        JSONArray jsonObject = (JSONArray) obj;

        Iterator itr= jsonObject.iterator();

        while(itr.hasNext()){
            JSONObject featureJsonObj = (JSONObject)itr.next();
            //logger.debug("featureJsonObj : " +  featureJsonObj);
            String status = (String)featureJsonObj.get("state") ;
            //logger.debug("status : "  + status);
            if(status.equalsIgnoreCase("completed"))
            {
                isCompleted = true;
            }
        }

    }
    return isCompleted;
}
 
源代码4 项目: metron   文件: HostFromJSONListAdapter.java
public HostFromJSONListAdapter(String jsonList) {
  JSONArray jsonArray = (JSONArray) JSONValue.parse(jsonList);
  Iterator jsonArrayIterator = jsonArray.iterator();
  while(jsonArrayIterator.hasNext()) {
    JSONObject jsonObject = (JSONObject) jsonArrayIterator.next();
    String host = (String) jsonObject.remove("ip");
    _known_hosts.put(host, jsonObject);
  }
}
 
源代码5 项目: AndroTickler   文件: JsonParser.java
private void parseJsonFile() {
		try {
//			String objo = "\"squeeze\":[{\"a\":\"aa\",\"b\":\"bb\"}]}";
			String objo = "{ \"squeeze\": [{\"Title\":\"World accessible files\",\"values\":[ \"MODE_WORLD_READABLE\", \"MODE_WORLD_WRITABLE\"]},"
					+ "{\"Title\":\"WebView\",\"values\":[ \"addJavascriptInterface\", \"setAllowContentAccess\", \"setAllowFileAccess\", \"setAllowUniversalAccess\" ]}]}";
//			Object objy = parser.parse(new FileReader(this.squeezeFileLoc));
			Object objy = parser.parse(objo);
			JSONObject jsonObj = (JSONObject) objy;
			
//			JSONArray arr = (JSONArray) objy; 
			JSONArray arr = (JSONArray)jsonObj.get("squeeze");
			
			System.out.println(arr.size());
			
			Iterator itr1 = arr.iterator();
			Iterator itr2 = arr.iterator(); 
			
//	        while (itr2.hasNext())  
//	        { 
	        	
//	            itr1 = ((Map) itr2.next()).entrySet().iterator(); 
//	            while (itr1.hasNext()) { 
//	                Map.Entry pair = itr1.next(); 
//	                System.out.println(pair.getKey() + " : " + pair.getValue()); 
//	            } 
//	        } 
			String test="";
			for (int i=0;i<arr.size();i++) {
				test= arr.get(i).toString();
				System.out.println(test);
			}
			
			
		}
		catch(Exception e) {
			e.printStackTrace();
		}
	}
 
@Test
public void testInitializeAdapter() {
    Map<String, JSONObject> mapKnownHosts = new HashMap<>();
    HostFromPropertiesFileAdapter hfa = new HostFromPropertiesFileAdapter(mapKnownHosts);
    assertFalse(hfa.initializeAdapter(null));
    JSONArray jsonArray = (JSONArray) JSONValue.parse(expectedKnownHostsString);
    Iterator jsonArrayIterator = jsonArray.iterator();
    while(jsonArrayIterator.hasNext()) {
        JSONObject jsonObject = (JSONObject) jsonArrayIterator.next();
        String host = (String) jsonObject.remove("ip");
        mapKnownHosts.put(host, jsonObject);
    }
    hfa = new HostFromPropertiesFileAdapter(mapKnownHosts);
    assertTrue(hfa.initializeAdapter(null));
}
 
/**
 * 
 * @param testSet
 * @param releaseID
 * @param phase
 * @param client
 * @return
 */
private int getCyclePhaseID(String testSet, int releaseID, String phase, ZephyrHttpClient client) {
	int cycleId = -1;
	try {
		String url = client.url + CYCLELIST + URLEncoder.encode(Integer.toString(releaseID), "UTF-8");
		DLogger.Log("Req CyclePhase ID ", url);
		JSONObject releaseList = client.Get(new URL(url));
		DLogger.Log("Looking for [", testSet, "] in", releaseList);
		for (Object proj : (Iterable<? extends Object>) releaseList.get("array")) {
			String id = ((Map<?, ?>) proj).get(ZephyrClient.array.NAME).toString();
			if (Objects.equals(id, testSet)) {
				JSONArray remotePhases = (JSONArray) ((Map<?, ?>) proj).get(ZephyrClient.array.REMOTE_PHASES);
				Iterator remotePhase = remotePhases.iterator();
				while (remotePhase.hasNext()) {
					JSONObject testphase = (JSONObject) remotePhase.next();
					String phaseName = testphase.get(ZephyrClient.array.NAME).toString();
					if (Objects.equals(phaseName, phase)) {
						cycleId = Integer.valueOf(testphase.get(ZephyrClient.array.ID).toString());
						break;
					}
				}
			}
		}
		if (cycleId == -1) {
			DLogger.LogE("Phase [", phase, "] not found");
		}
	} catch (Exception ex) {
		Logger.getLogger(ZephyrClient.class.getName()).log(Level.SEVERE, null, ex);
	}
	return cycleId;
}
 
源代码8 项目: setupmaker   文件: JsonSimpleReader.java
@SuppressWarnings("unchecked")
public String[] readStringArray(String name) {
    JSONArray msg = (JSONArray) obj.get(name);
    String[] arr = new String[msg.size()];
    Iterator<String> iterator = msg.iterator();
    for(int i=0;iterator.hasNext();i++) {
        arr[i] = iterator.next();
    }
    return arr;
}
 
源代码9 项目: setupmaker   文件: JsonSimpleReader.java
@SuppressWarnings("unchecked")
public List<String> readStringList(String name) {
    JSONArray msg = (JSONArray) obj.get(name);
    List<String> list = new ArrayList<String>();
    Iterator<String> iterator = msg.iterator();
    while(iterator.hasNext()) {
        list.add(iterator.next());
    }
    return list;
}
 
源代码10 项目: netphony-topology   文件: TEDUpdaterRYU.java
private void parseNodes(String response, Hashtable<String,RouterInfoPM> routerInfoList, String ip, String port)
{	
	try
	{
		JSONParser parser = new JSONParser();
		Object obj = parser.parse(response);
	
		JSONArray msg = (JSONArray) obj;
		Iterator<JSONObject> iterator = msg.iterator();
		while (iterator.hasNext()) 
		{	
			JSONObject jsonObject = (JSONObject) iterator.next();
			
			log.info("(String)jsonObject.get(dpid)::"+(String)jsonObject.get("dpid"));
			
			RouterInfoPM rInfo = new RouterInfoPM();

			rInfo.setRouterID(RYUtoFloodlight((String)jsonObject.get("dpid")));
			rInfo.setConfigurationMode("Openflow");
			rInfo.setControllerType(TEDUpdaterRYU.controllerName);
			
			rInfo.setControllerIdentifier(ip, port);
			rInfo.setControllerIP(ip);
			rInfo.setControllerPort(port);
			
			routerInfoList.put(rInfo.getRouterID(),rInfo);
							
			((SimpleTEDB)TEDB).getNetworkGraph().addVertex(rInfo);
		}
	}
	catch (Exception e)
	{
		log.info(e.toString());
	}
}
 
源代码11 项目: netphony-topology   文件: TEDUpdaterODL.java
private void parseNodes(String response, Hashtable<String,RouterInfoPM> routerInfoList, String ip, String port)
{	
	try
	{
		JSONParser parser = new JSONParser();
		Object obj = parser.parse(response);

		JSONArray msg = (JSONArray) ((JSONObject) obj).get("nodeProperties");
		Iterator<JSONObject> iterator = msg.iterator();
		while (iterator.hasNext()) 
		{
			JSONObject jsonObject = iterator.next();

			RouterInfoPM rInfo = new RouterInfoPM();

			String dpid = (String) (((JSONObject) jsonObject.get("node")).get("id"));

			rInfo.setRouterID(dpid);
			rInfo.setConfigurationMode("Openflow");
			rInfo.setControllerType(TEDUpdaterODL.controllerName);								
			rInfo.setControllerIdentifier(ip, port);
			rInfo.setControllerIP(ip);
			rInfo.setControllerPort(port);

			routerInfoList.put(rInfo.getRouterID(),rInfo);
			log.info("Adding Vertex::"+rInfo);
			((SimpleTEDB)TEDB).getNetworkGraph().addVertex(rInfo);				



		}
	}
	catch (Exception e)
	{
		log.info(e.toString());
	}
}
 
源代码12 项目: astor   文件: SimpleDiffOrderFromJSON.java
public LinkedHashMap loadFile(String path) {
	Map<String, Integer> frq = new LinkedHashMap<>();

	JSONParser parser = new JSONParser();

	try {

		Object obj = parser.parse(new FileReader(path));

		JSONObject jsonObject = (JSONObject) obj;

		// loop array
		JSONArray msg = (JSONArray) jsonObject.get(tagName());
		Iterator<JSONObject> iterator = msg.iterator();
		while (iterator.hasNext()) {
			JSONObject io = iterator.next();
			Object type = io.get("c");
			if (accept(type)) {
				Integer frequency = Integer.valueOf(io.get("f").toString());
				String key = getKeyFromJSON(type);
				frq.put(key, frequency);
			}
		}

		LinkedHashMap sorted = frq.entrySet().stream()
				.sorted(Map.Entry.<String, Integer>comparingByValue().reversed())
				.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue,
						LinkedHashMap::new));

		return sorted;

	} catch (Exception e) {
		e.printStackTrace();
		return null;
	}

}
 
源代码13 项目: fenixedu-academic   文件: ImportMessaging.java
private Collection<String> extractEmailList(JSONArray stuffArray) {
    final Iterator<String> stuffIterator = stuffArray.iterator();
    final Collection<String> stuffList = new ArrayList<>();
    while (stuffIterator.hasNext()) {
        String email = stuffIterator.next();
        stuffList.add(email);
    }
    return stuffList;
}
 
源代码14 项目: dyno   文件: AbstractTokenMapSupplier.java
List<HostToken> parseTokenListFromJson(String json) {

        List<HostToken> hostTokens = new ArrayList<HostToken>();

        JSONParser parser = new JSONParser();
        try {
            JSONArray arr = (JSONArray) parser.parse(json);

            Iterator<?> iter = arr.iterator();
            while (iter.hasNext()) {

                Object item = iter.next();
                if (!(item instanceof JSONObject)) {
                    continue;
                }
                JSONObject jItem = (JSONObject) item;
                Long token = Long.parseLong((String) jItem.get("token"));
                String hostname = (String) jItem.get("hostname");
                String ipAddress = (String) jItem.get("ip");
                String zone = (String) jItem.get("zone");
                String datacenter = (String) jItem.get("dc");
                String portStr = (String) jItem.get("port");
                String securePortStr = (String) jItem.get("secure_port");
                String hashtag = (String) jItem.get("hashtag");
                int port = Host.DEFAULT_PORT;
                if (portStr != null) {
                    port = Integer.valueOf(portStr);
                }

                int securePort = port;
                if (securePortStr != null) {
                    securePort = Integer.valueOf(securePortStr);
                }

                Host host = new HostBuilder().setHostname(hostname).setIpAddress(ipAddress).setPort(port).setSecurePort(securePort).setRack(zone).setDatacenter(datacenter).setStatus(Status.Up).setHashtag(hashtag).createHost();

                if (isLocalDatacenterHost(host)) {
                    HostToken hostToken = new HostToken(token, host);
                    hostTokens.add(hostToken);
                }
            }

        } catch (ParseException e) {
            Logger.error("Failed to parse json response: " + json, e);
            throw new RuntimeException(e);
        }

        return hostTokens;
    }
 
源代码15 项目: The-5zig-Mod   文件: InstallerNew.java
protected void updateMinecraftJson() throws ParseException, IOException {
		String json = Utils.loadJson(modJsonFile);

		JSONParser jp = new JSONParser();

		JSONObject root = (JSONObject) jp.parse(json);
		root.put("id", getVersionName());
		root.put("mainClass", "net.minecraft.launchwrapper.Launch");
		if (root.containsKey("arguments")) {
//		if (Utils.versionCompare(minecraftVersion, "1.13") >= 0) {
			JSONObject args = (JSONObject) root.get("arguments");
			JSONArray game = (JSONArray) args.get("game");
			game.add("--tweakClass");
			game.add("eu.the5zig.mod.asm.ClassTweaker");
			args.put("game", game);
		} else {
			root.put("minecraftArguments", root.get("minecraftArguments") + " --tweakClass eu.the5zig.mod.asm.ClassTweaker");
		}

		JSONArray libraries = (JSONArray) root.get("libraries");
		for (Iterator iterator = libraries.iterator(); iterator.hasNext(); ) {
			Object o = iterator.next();
			JSONObject library = (JSONObject) o;
			String name = library.get("name").toString();
			if (name.startsWith("net.minecraft:launchwrapper:") || name.startsWith("eu.the5zig:The5zigMod:") || name.startsWith("eu.the5zig:mods:")) {
				iterator.remove();
			}
		}

		JSONObject launchWrapper = new JSONObject();
		launchWrapper.put("name", "net.minecraft:launchwrapper:1.7");
		libraries.add(0, launchWrapper);
		JSONObject mod = new JSONObject();
		mod.put("name", "eu.the5zig:The5zigMod:" + minecraftVersion + "_" + modVersion);
		libraries.add(0, mod);
		if (otherMods != null && otherMods.length > 0) {
			JSONObject mods2 = new JSONObject();
			mods2.put("name", "eu.the5zig:Mods:" + minecraftVersion + "_" + modVersion);
			libraries.add(1, mods2);
		}

		root.put("libraries", libraries);

		writeToFile(root, modJsonFile);
	}
 
源代码16 项目: GriefDefender   文件: GDBootstrap.java
@Override
public void onEnable() {
    // check if reload
    if (instance != null) {
        instance = this;
        GriefDefenderPlugin.getInstance().onEnable(true);
        return;
    }

    instance = this;
    final JSONParser parser = new JSONParser();
    String bukkitJsonVersion = null;
    this.getLogger().info("Loading libraries...");
    if (Bukkit.getVersion().contains("1.8.8")) {
        bukkitJsonVersion = "1.8.8";
    } else if (Bukkit.getVersion().contains("1.12.2")) {
        bukkitJsonVersion = "1.12.2";
    } else if (Bukkit.getVersion().contains("1.13.2")) {
        bukkitJsonVersion = "1.13.2";
    } else if (Bukkit.getVersion().contains("1.14.2")) {
        bukkitJsonVersion = "1.14.2";
    } else if (Bukkit.getVersion().contains("1.14.3")) {
        bukkitJsonVersion = "1.14.3";
    } else if (Bukkit.getVersion().contains("1.14.4")) {
        bukkitJsonVersion = "1.14.4";
    } else if (Bukkit.getVersion().contains("1.15.2")) {
        bukkitJsonVersion = "1.15.2";
    } else if (Bukkit.getVersion().contains("1.15")) {
        bukkitJsonVersion = "1.15";
    } else if (Bukkit.getVersion().contains("1.16.1")) {
        bukkitJsonVersion = "1.16.1";
    } else {
        this.getLogger().severe("Detected unsupported version '" + Bukkit.getVersion() + "'. GriefDefender only supports 1.8.8, 1.12.2, 1.13.2, 1.14.x, 1.15.0-1.15.2, 1.16.1. GriefDefender will NOT load.");
        return;
    }
    try {
        final InputStream in = getClass().getResourceAsStream("/" + bukkitJsonVersion + ".json");
        final BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        final JSONObject a = (JSONObject) parser.parse(reader);
        final JSONArray libraries = (JSONArray) a.get("libraries");
        if (libraries == null) {
            this.getLogger().severe("Resource " + bukkitJsonVersion + ".json is corrupted!. Please contact author for assistance.");
            return;
        }
        final Iterator<JSONObject> iterator = libraries.iterator();
        while (iterator.hasNext()) {
            JSONObject lib = iterator.next();
            final String name = (String) lib.get("name");
            final String sha1 = (String) lib.get("sha1");
            final String path = (String) lib.get("path");
            final String relocate = (String) lib.get("relocate");
            final String url = (String) lib.get("url");
            final Path libPath = Paths.get(LIB_ROOT_PATH).resolve(path);
            final File file = libPath.toFile();
            downloadLibrary(name, relocate, sha1, url, libPath);
        }
    } catch (Throwable t) {
        t.printStackTrace();
    }
    // Inject jar-relocator and asm debug
    injectRelocatorDeps();
    // Relocate all GD dependencies and inject
    GDRelocator.getInstance().relocateJars(this.jarMap);
    // Boot GD
    GriefDefenderPlugin.getInstance().onEnable();
}
 
/**
 * 
 * @param testcase
 * @param cyclePhaseId
 * @param client
 * @param status
 * @param list 
 * @return
 */
private int getExecutionID(String testcase, int cyclePhaseId, ZephyrHttpClient client, int status, List<File> list) {
	Long executionId = (long) -1;
	Long tcrCatalogueId = (long) -1;
	Long testerId = (long) -1;
	try {
		String url = client.url + EXELIST + "?cyclephaseid="
				+ URLEncoder.encode(Integer.toString(cyclePhaseId), "UTF-8");
		DLogger.Log("Req Execution ID ", url);
		JSONObject releaseList = client.Get(new URL(url));
		DLogger.Log("Looking for [", cyclePhaseId, "] in", releaseList);
		JSONArray exeList = (JSONArray) releaseList.get("results");
		Iterator testcases = exeList.iterator();
		while (testcases.hasNext()) {
			JSONObject tc = (JSONObject) testcases.next();
			testerId = (Long) tc.get("testerId");
			JSONObject tcrtc = (JSONObject) tc.get("tcrTreeTestcase");
			tcrCatalogueId = (Long) tcrtc.get("tcrCatalogTreeId");
			JSONObject actualTC = (JSONObject) tcrtc.get("testcase");
			String testname = (String) actualTC.get("name");
			if (testname.equals(testcase)) {
				executionId = (long) tc.get("id");
				break;
			}
		}
		if (executionId > 0) {
			/*JSONObject payload = new JSONObject();
			payload.put("createRTSList", null);
			payload.put("updateRTSList", null);
			payload.put("unassignedRtsIds", null);
			payload.put("notes", null);
			payload.put("tcrCatalogTreeId", tcrCatalogueId.intValue());
			payload.put("selectedAll", null);
			payload.put("unselectedIds", null);
			payload.put("executedOn", null);
			payload.put("testerId", testerId.intValue());
			payload.put("cyclePhaseId", cyclePhaseId);
			String statusurl = client.url + EXELIST
					+ URLEncoder.encode(Integer.toString(executionId.intValue()), "UTF-8") + "?status=" + status
					+ "&testerid=" + testerId.intValue();
			JSONObject response = client.put(new URL(statusurl), payload.toJSONString());
			if (response != null) {
				JSONObject lastRes = (JSONObject) response.get("lastTestResult");
				int updatedStatus = Integer.parseInt((String) lastRes.get("executionStatus"));
				if (status == updatedStatus) {
					DLogger.LogE("Status updated successfully");
				}
			}*/
			
			///Upload the files
			String uploadURL = client.url+UPLOAD+ URLEncoder.encode(Integer.toString(executionId.intValue()), "UTF-8") + "?status=" + status
					+ "&testerid=" + testerId.intValue();
			for (File file : list) {
				JSONObject upload = client.put(new URL(uploadURL), file);
			}
		}
		
	} catch (Exception ex) {
		Logger.getLogger(ZephyrClient.class.getName()).log(Level.SEVERE, null, ex);
	}
	return executionId.intValue();
}
 
源代码18 项目: atrium-odl   文件: ConfigReaderTest.java
/**
 * Tests whether the bgp speakers are read properly from the config file
 */
@Test
public void testGetBgpSpeakers() throws FileNotFoundException, IOException, ParseException {
	testInitialize();

	BgpSpeakers actualBgpSpeakers = null;
	BgpSpeakers expectedBgpSpeakers = null;

	BgpSpeakerBuilder bgpSpeakerBuilder = new BgpSpeakerBuilder();
	BgpSpeakersBuilder bgpSpeakersBuilder = new BgpSpeakersBuilder();
	InterfaceAddressesBuilder intfAddressBuilder = new InterfaceAddressesBuilder();
	List<InterfaceAddresses> intfAddressesList = new ArrayList<InterfaceAddresses>();
	List<BgpSpeaker> bgpSpeakerList = new ArrayList<BgpSpeaker>();

	JSONArray bgpSpeakers = (JSONArray) jsonObject.get("bgpSpeakers");
	Iterator<JSONObject> bgpIterator = bgpSpeakers.iterator();

	while (bgpIterator.hasNext()) {
		JSONObject bgp = (JSONObject) bgpIterator.next();
		bgpSpeakerBuilder.setSpeakerName((String) bgp.get("name"));
		String attachmentDpid = AtriumUtils.hexDpidStringToOpenFlowDpid((String) bgp.get("attachmentDpid"));
		bgpSpeakerBuilder.setAttachmentDpId(NodeId.getDefaultInstance(attachmentDpid));
		String attachmentPort = (String) bgp.get("attachmentPort");
		bgpSpeakerBuilder.setAttachmentPort(Long.valueOf(attachmentPort));
		String macAddress = (String) bgp.get("macAddress");
		bgpSpeakerBuilder.setMacAddress(MacAddress.getDefaultInstance(macAddress));
		JSONArray intfList = (JSONArray) bgp.get("interfaceAddresses");
		Iterator<JSONObject> intfIterator = intfList.iterator();

		while (intfIterator.hasNext()) {
			JSONObject intfAddress = (JSONObject) intfIterator.next();
			String ipAddress = (String) intfAddress.get("ipAddress");
			intfAddressBuilder.setIpAddress(new IpAddress(Ipv4Address.getDefaultInstance(ipAddress)));
			String interfaceDpid = AtriumUtils
					.hexDpidStringToOpenFlowDpid((String) intfAddress.get("interfaceDpid"));
			String interfacePort = (String) intfAddress.get("interfacePort");
			NodeConnectorId ncId = NodeConnectorId.getDefaultInstance(interfaceDpid + ":" + interfacePort);
			intfAddressBuilder.setOfPortId(ncId);
			intfAddressBuilder.setKey(new InterfaceAddressesKey(ncId));
			intfAddressesList.add(intfAddressBuilder.build());
		}
		bgpSpeakerBuilder.setInterfaceAddresses(intfAddressesList);
		bgpSpeakerList.add(bgpSpeakerBuilder.build());
	}

	bgpSpeakersBuilder.setBgpSpeaker(bgpSpeakerList);

	expectedBgpSpeakers = bgpSpeakersBuilder.build();
	actualBgpSpeakers = ConfigReader.getBgpSpeakers();

	assertEquals(expectedBgpSpeakers, actualBgpSpeakers);
}
 
源代码19 项目: netphony-topology   文件: TEDUpdaterFloodlight.java
private void parseNodes(String response, Hashtable<String,RouterInfoPM> routerInfoList, String ip, String port)
{	
	try
	{
		JSONParser parser = new JSONParser();
		Object obj = parser.parse(response);
	
		JSONArray msg = (JSONArray) obj;
		Iterator<JSONObject> iterator = msg.iterator();
		while (iterator.hasNext()) 
		{
			JSONObject jsonObject = (JSONObject) iterator.next();
			
			RouterInfoPM rInfo = new RouterInfoPM();
			rInfo.setMacAddress((String)jsonObject.get("mac"));
			rInfo.setRouterID((String)jsonObject.get("dpid"));
			rInfo.setControllerType(TEDUpdaterFloodlight.controllerName);
			
			
			JSONArray ports = (JSONArray) jsonObject.get("ports");
			Iterator<JSONObject> portIterator = ports.iterator();
			while (portIterator.hasNext()) 
			{
				JSONObject jsonPortObject = (JSONObject) portIterator.next();
				rInfo.setMacAddress((String)jsonPortObject.get("hardwareAddress"));
			}
			
			log.info("(String)((JSONObject)jsonObject.get(description)).get(manufacturer)::"+(String)((JSONObject)jsonObject.get("description")).get("manufacturer"));
			rInfo.setRouterType((String)((JSONObject)jsonObject.get("description")).get("manufacturer"));
			rInfo.setConfigurationMode("Openflow");
			
			rInfo.setControllerIdentifier(ip, port);
			rInfo.setControllerIP(ip);
			rInfo.setControllerPort(port);
			rInfo.setHardware((String)((JSONObject)jsonObject.get("description")).get("hardware"));
			
			routerInfoList.put(rInfo.getRouterID(),rInfo);
			
			
			log.info("Adding Vertex::"+rInfo);
			((SimpleTEDB)TEDB).getNetworkGraph().addVertex(rInfo);
		}
	}
	catch (Exception e)
	{
		log.info(e.toString());
	}
}
 
源代码20 项目: netphony-topology   文件: TEDUpdaterODL.java
private void parseLinks(String links,Hashtable<String,RouterInfoPM> nodes)
{
	try {
		JSONParser parser = new JSONParser();
		Object obj = parser.parse(links);

		JSONArray msg = (JSONArray) ((JSONObject) obj).get("edgeProperties");
		Iterator<JSONObject> iterator = msg.iterator();
		while (iterator.hasNext()) 
		{
			JSONObject jsonObject = (JSONObject) iterator.next().get("edge");
			JSONObject jSrc = (JSONObject) jsonObject.get("headNodeConnector");
			JSONObject jDst = (JSONObject) jsonObject.get("tailNodeConnector");



			IntraDomainEdge edge= new IntraDomainEdge();

			RouterInfoPM source = nodes.get(((JSONObject) jSrc.get("node")).get("id"));//            jsonObject.get("src-switch"));
			RouterInfoPM dest = nodes.get(((JSONObject) jDst.get("node")).get("id"));//				jsonObject.get("dst-switch"));



			edge.setSrc_if_id(Long.parseLong((String)jSrc.get("id")));				//jsonObject.get("src-port"));
			edge.setDst_if_id(Long.parseLong((String)jDst.get("id")));				//jsonObject.get("dst-port"));

			// This is a big problem because info is not initialized from file
			// and the controller doesn't give information about how many wlans
			// the are

			TE_Information tE_info = new TE_Information();
			tE_info.setNumberWLANs(15);
			tE_info.initWLANs();

			if (interDomainFile != null)
			{
				completeTE_Information(tE_info, source.getRouterID(), dest.getRouterID());
			}

			edge.setTE_info(tE_info);

			String isBidirectional = (String)jsonObject.get("direction");



			//log.info("isBidirectional::"+isBidirectional);

			if ((1==1)||(isBidirectional != null) && (isBidirectional.equals("bidirectional")))
			{
				//((SimpleTEDB)TEDB).getNetworkGraph().addEdge(source, dest, edge);

				TE_Information tE_infoOtherWay = new TE_Information();
				tE_infoOtherWay.setNumberWLANs(15);
				tE_infoOtherWay.initWLANs();
				IntraDomainEdge edgeOtherWay= new IntraDomainEdge();

				edgeOtherWay.setSrc_if_id(Long.parseLong((String)jDst.get("id")));
				edgeOtherWay.setDst_if_id(Long.parseLong((String)jSrc.get("id")));
				edgeOtherWay.setTE_info(tE_infoOtherWay);

				((SimpleTEDB)TEDB).getNetworkGraph().addEdge(source, dest, edge);
				((SimpleTEDB)TEDB).getNetworkGraph().addEdge(dest, source, edgeOtherWay);

				completeTE_Information(tE_info, dest.getRouterID(), source.getRouterID());

				log.info("________EDGE_____");
				log.info("source::"+source);
				log.info("dest::"+dest);
				log.info("edgeOtherWay::"+edgeOtherWay);
				log.info("edge::"+edge);
				log.info("--------EDGE-----");
			}
			else
			{
				((SimpleTEDB)TEDB).getNetworkGraph().addEdge(source, dest, edge);
			}

			//log.info("Edge added:"+edge);
			//log.info(((SimpleTEDB)TEDB).getIntraDomainLinks().toString());
		}
		//parseRemainingLinksFromXML(nodes);

	} 
	catch (Exception e)
	{
		log.info(e.toString());
	}
}