private List<ApplicationInfo> extractApplications(String rawXML) { List<ApplicationInfo> infos = new ArrayList<ApplicationInfo>(); NSArray apps = null; try { apps = (NSArray) XMLPropertyListParser.parse(rawXML.getBytes("UTF-8")); } catch (Exception e) { log.warning("Error parsing the xml returned : " + e.getMessage() + " , xml=\n" + rawXML); return infos; } for (int i = 0; i < apps.count(); i++) { NSObject app = apps.objectAtIndex(i); ApplicationInfo info = new ApplicationInfo(app); infos.add(info); } return infos; }
public static Optional<AppleSimulatorProfile> parseProfilePlistStream(InputStream inputStream) throws IOException { NSDictionary profile; try (BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream)) { try { profile = (NSDictionary) PropertyListParser.parse(bufferedInputStream); } catch (Exception e) { throw new IOException(e); } } NSObject supportedProductFamilyIDsObject = profile.objectForKey("supportedProductFamilyIDs"); if (!(supportedProductFamilyIDsObject instanceof NSArray)) { LOG.warn( "Invalid simulator profile.plist (supportedProductFamilyIDs missing or not an array)"); return Optional.absent(); } NSArray supportedProductFamilyIDs = (NSArray) supportedProductFamilyIDsObject; AppleSimulatorProfile.Builder profileBuilder = AppleSimulatorProfile.builder(); for (NSObject supportedProductFamilyID : supportedProductFamilyIDs.getArray()) { if (supportedProductFamilyID instanceof NSNumber) { profileBuilder.addSupportedProductFamilyIDs( ((NSNumber) supportedProductFamilyID).intValue()); } else { LOG.warn( "Invalid simulator profile.plist (supportedProductFamilyIDs contains non-number %s)", supportedProductFamilyID); return Optional.absent(); } } NSObject supportedArchsObject = profile.objectForKey("supportedArchs"); if (!(supportedArchsObject instanceof NSArray)) { LOG.warn("Invalid simulator profile.plist (supportedArchs missing or not an array)"); return Optional.absent(); } NSArray supportedArchs = (NSArray) supportedArchsObject; for (NSObject supportedArch : supportedArchs.getArray()) { profileBuilder.addSupportedArchitectures(supportedArch.toString()); } return Optional.of(profileBuilder.build()); }