Java Code Examples for com.dd.plist.NSDictionary#objectForKey()
The following examples show how to use
com.dd.plist.NSDictionary#objectForKey() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IOSDebugTransport.java From netbeans with Apache License 2.0 | 6 votes |
private JSONObject extractResponse(NSObject r) throws Exception { if (r == null) { return null; } if (!(r instanceof NSDictionary)) { return null; } NSDictionary root = (NSDictionary) r; NSDictionary argument = (NSDictionary) root.objectForKey("__argument"); // NOI18N if (argument == null) { return null; } NSData data = (NSData) argument.objectForKey("WIRMessageDataKey"); // NOI18N if (data == null) { return null; } byte[] bytes = data.bytes(); String s = new String(bytes); JSONObject o = (JSONObject) JSONValue.parseWithException(s); return o; }
Example 2
Source File: IOSDebugTransport.java From netbeans with Apache License 2.0 | 6 votes |
private static NSObject findInNSObject(int pos, NSObject obj, String... path) { if (obj == null) { throw new NullPointerException("obj is null"); } else if (path == null) { throw new NullPointerException("path is null"); } else if (path.length == pos) { return obj; } else if (obj instanceof NSDictionary) { NSDictionary dict = (NSDictionary) obj; NSObject next = dict.objectForKey(path[pos]); if (next == null) { return null; } else { return findInNSObject(pos + 1, next, path); } } else { return null; } }
Example 3
Source File: PBXProjectTest.java From thym with Eclipse Public License 1.0 | 6 votes |
@Test public void testAddPluginFile() throws Exception{ PBXProject project = new PBXProject(pbxFile); String testPath = "my/files/abc.h"; PBXFile file = new PBXFile(testPath); project.addPluginFile(file); NSDictionary dict = (NSDictionary)ASCIIPropertyListParser.parse(project.getContent().getBytes()); NSDictionary objects = (NSDictionary)dict.objectForKey("objects"); NSDictionary fileRef = (NSDictionary) objects.objectForKey(file.getFileRef()); assertNotNull(fileRef); NSString isa = (NSString)fileRef.get("isa"); assertEquals("PBXFileReference",isa.getContent()); NSString path = (NSString)fileRef.get("path"); assertEquals(testPath, path.getContent()); NSString lastType = (NSString)fileRef.get("lastKnownFileType"); assertEquals(HEADER_FILE, lastType.getContent()); NSString encoding = (NSString)fileRef.get("fileEncoding"); assertEquals("4", encoding.getContent()); NSString sourceTree = (NSString)fileRef.get("sourceTree"); assertEquals(DEFAULT_GROUP, sourceTree.getContent()); assertTrue("No entry found on the Plugins group",isFileEntryFoundOnPluginsGroup(file, objects)); }
Example 4
Source File: PBXProjectTest.java From thym with Eclipse Public License 1.0 | 6 votes |
@Test public void testAddFrameworkWithWeak() throws Exception{ PBXProject project = new PBXProject(pbxFile); String testPath = "libsqlite3.dylib"; PBXFile file = new PBXFile(testPath); file.setWeak(true); project.addFramework(file); NSDictionary dict = (NSDictionary)ASCIIPropertyListParser.parse(project.getContent().getBytes()); NSDictionary objects = (NSDictionary)dict.objectForKey("objects"); NSDictionary buildFile = (NSDictionary)objects.objectForKey(file.getUuid()); assertNotNull(buildFile); NSString isa = (NSString) buildFile.get("isa"); assertEquals("PBXBuildFile",isa.getContent()); NSString fRef = (NSString) buildFile.get("fileRef"); assertEquals(file.getFileRef(), fRef.getContent()); NSDictionary settings = (NSDictionary) buildFile.get("settings"); NSArray attributes = (NSArray) settings.get("ATTRIBUTES"); assertTrue(attributes.containsObject(NSObject.wrap("Weak"))); }
Example 5
Source File: PBXProject.java From thym with Eclipse Public License 1.0 | 6 votes |
public String getProductName() throws PBXProjectException { HashMap<String, NSObject> hashmap = getObjects().getHashMap(); Collection<NSObject> values = hashmap.values(); for (NSObject nsObject : values) { NSDictionary obj = (NSDictionary) nsObject; NSString isa = (NSString) obj.objectForKey("isa"); if(isa != null && isa.getContent().equals("XCBuildConfiguration")){ NSDictionary buildSettings = (NSDictionary) obj.objectForKey("buildSettings"); if( buildSettings.containsKey("PRODUCT_NAME")){ NSString name = (NSString) buildSettings.get("PRODUCT_NAME"); return name.getContent().replace('"', ' ').trim(); } } } return null; }
Example 6
Source File: PBXProjectTest.java From thym with Eclipse Public License 1.0 | 6 votes |
@Test public void testAddToLibrarySearchPaths() throws Exception{ PBXProject project = new PBXProject(pbxFile); String testPath = "my/files/abcd.h"; PBXFile file = new PBXFile(testPath); project.addToLibrarySearchPaths(file); NSDictionary dict = (NSDictionary)ASCIIPropertyListParser.parse(project.getContent().getBytes()); NSDictionary objects = (NSDictionary)dict.objectForKey("objects"); HashMap<String, NSObject> hashmap = objects.getHashMap(); Collection<NSObject> values = hashmap.values(); for (NSObject nsObject : values) { NSDictionary obj = (NSDictionary) nsObject; NSString isa = (NSString) obj.objectForKey("isa"); if(isa != null && isa.getContent().equals("XCBuildConfiguration")){ NSDictionary buildSettings = (NSDictionary) obj.objectForKey("buildSettings"); assertTrue(buildSettings.containsKey("LIBRARY_SEARCH_PATHS")); NSArray searchPaths = (NSArray) buildSettings.get("LIBRARY_SEARCH_PATHS"); assertEquals("$(SRCROOT)/Test_Application/my/files", ((NSString)searchPaths.objectAtIndex(1)).getContent()); } } }
Example 7
Source File: PBXProject.java From thym with Eclipse Public License 1.0 | 6 votes |
private NSString searchPathForFile(PBXFile pbxfile) throws PBXProjectException { String filepath = FilenameUtils.getFullPathNoEndSeparator(pbxfile.getPath()); if(filepath.equals(".")){ filepath = ""; }else{ filepath = "/"+filepath; } NSDictionary group = getGroupByName("Plugins"); if(pbxfile.isPlugin() && group.containsKey("path")){ NSString groupPath = (NSString)group.objectForKey("path"); return NSObject.wrap("$(SRCROOT)/" + groupPath.getContent().replace('"', ' ').trim()); } else{ return NSObject.wrap("$(SRCROOT)/"+ getProductName() + filepath ); } }
Example 8
Source File: PBXProject.java From thym with Eclipse Public License 1.0 | 5 votes |
private NSDictionary getGroupByName(String name) throws PBXProjectException{ NSDictionary objects = getObjects(); HashMap<String, NSObject> map = objects.getHashMap(); Collection<NSObject> values = map.values(); for (NSObject nsObject : values) { NSDictionary obj = (NSDictionary)nsObject; NSString isa = (NSString) obj.objectForKey("isa"); NSString nameString = (NSString) obj.objectForKey("name"); if(isa != null && isa.getContent().equals("PBXGroup") && nameString != null && name.equals(nameString.getContent())){ return obj; } } return null; }
Example 9
Source File: PBXProject.java From thym with Eclipse Public License 1.0 | 5 votes |
private NSDictionary getPhaseByName(String name) throws PBXProjectException{ NSDictionary objects = getObjects(); HashMap<String, NSObject> map = objects.getHashMap(); Collection<NSObject> values = map.values(); for (NSObject nsObject : values) { NSDictionary obj = (NSDictionary)nsObject; NSString isa = (NSString) obj.objectForKey("isa"); if(isa != null && isa.getContent().equals(name)){ return obj; } } return null; }
Example 10
Source File: PBXProject.java From thym with Eclipse Public License 1.0 | 5 votes |
private void addToPbxGroup(String groupName, PBXFile pbxfile) throws PBXProjectException { NSDictionary group = getGroupByName(groupName); NSArray children = (NSArray) group.objectForKey("children"); NSObject[] childs = children.getArray(); NSObject[] newChilds = new NSObject[childs.length +1]; System.arraycopy(childs, 0, newChilds, 0, childs.length); newChilds[newChilds.length-1] = new NSString(pbxfile.getFileRef()); NSArray newArray = new NSArray(newChilds); group.remove("children"); group.put("children", newArray); }
Example 11
Source File: PBXProject.java From thym with Eclipse Public License 1.0 | 5 votes |
private void addToBuildPhase(String phaseName, PBXFile pbxfile) throws PBXProjectException { NSDictionary phase = getPhaseByName(phaseName); NSArray files = (NSArray) phase.objectForKey("files"); NSObject[] current = files.getArray(); NSObject[] newArray = new NSObject[ current.length +1 ]; System.arraycopy(current, 0, newArray, 0, current.length); newArray[newArray.length-1] = new NSString(pbxfile.getUuid()); NSArray newNSArray = new NSArray(newArray); phase.remove("files"); phase.put("files", newNSArray); }
Example 12
Source File: PBXProjectTest.java From thym with Eclipse Public License 1.0 | 5 votes |
private static NSDictionary getPhase(NSDictionary objects, String name) throws PBXProjectException{ HashMap<String, NSObject> map = objects.getHashMap(); Collection<NSObject> values = map.values(); for (NSObject nsObject : values) { NSDictionary obj = (NSDictionary)nsObject; NSString isa = (NSString) obj.objectForKey("isa"); if(isa != null && isa.getContent().equals(name)){ return obj; } } return null; }
Example 13
Source File: PBXProjectTest.java From thym with Eclipse Public License 1.0 | 5 votes |
private static NSDictionary getGroupByName(NSDictionary objects, String name) throws PBXProjectException{ HashMap<String, NSObject> map = objects.getHashMap(); Collection<NSObject> values = map.values(); for (NSObject nsObject : values) { NSDictionary obj = (NSDictionary)nsObject; NSString isa = (NSString) obj.objectForKey("isa"); NSString nameString = (NSString) obj.objectForKey("name"); if(isa != null && isa.getContent().equals("PBXGroup") && nameString != null && name.equals(nameString.getContent())){ return obj; } } return null; }
Example 14
Source File: PBXProjectTest.java From thym with Eclipse Public License 1.0 | 5 votes |
@Test public void testAddHeader() throws Exception{ PBXProject project = new PBXProject(pbxFile); String testPath = "file.h"; PBXFile file = new PBXFile(testPath); project.addHeaderFile(file); NSDictionary dict = (NSDictionary)ASCIIPropertyListParser.parse(project.getContent().getBytes()); NSDictionary objects = (NSDictionary)dict.objectForKey("objects"); //Added the PBXFileReference object correctly? NSDictionary fileRef = (NSDictionary) objects.objectForKey(file.getFileRef()); assertNotNull(fileRef); NSString isa = (NSString)fileRef.get("isa"); assertEquals("PBXFileReference",isa.getContent()); NSString path = (NSString)fileRef.get("path"); assertEquals(testPath, path.getContent()); NSString lastType = (NSString)fileRef.get("lastKnownFileType"); assertEquals("sourcecode.c.h", lastType.getContent()); NSString sourceTree = (NSString)fileRef.get("sourceTree"); assertEquals(DEFAULT_GROUP, sourceTree.getContent()); NSString name = (NSString) fileRef.get("name"); assertEquals("file.h", name.getContent()); NSString encoding = (NSString) fileRef.get("fileEncoding"); assertEquals("4", encoding.getContent()); //Added to the Plugins PBXGroup group? NSDictionary group = getGroupByName(objects, "Plugins"); NSArray children = (NSArray) group.objectForKey("children"); assertTrue(children.containsObject(new NSString(file.getFileRef()))); }
Example 15
Source File: PBXProjectTest.java From thym with Eclipse Public License 1.0 | 5 votes |
@Test public void testAddResourceWithPlugin() throws Exception{ PBXProject project = new PBXProject(pbxFile); String testPath = "assets.bundle"; PBXFile file = new PBXFile(testPath); file.setPlugin(true); project.addResourceFile(file); NSDictionary dict = (NSDictionary)ASCIIPropertyListParser.parse(project.getContent().getBytes()); NSDictionary objects = (NSDictionary)dict.objectForKey("objects"); //Added the PBXFileReference object correctly? NSDictionary fileRef = (NSDictionary) objects.objectForKey(file.getFileRef()); assertNotNull(fileRef); NSString isa = (NSString)fileRef.get("isa"); assertEquals("PBXFileReference",isa.getContent()); NSString path = (NSString)fileRef.get("path"); assertEquals("assets.bundle", path.getContent()); NSString lastType = (NSString)fileRef.get("lastKnownFileType"); assertEquals("\"wrapper.plug-in\"", lastType.getContent()); NSString sourceTree = (NSString)fileRef.get("sourceTree"); assertEquals(DEFAULT_GROUP, sourceTree.getContent()); NSString name = (NSString) fileRef.get("name"); assertEquals("assets.bundle", name.getContent()); assertFalse(fileRef.containsKey("fileEncoding")); //Added to the Plugins PBXGroup group? NSDictionary group = getGroupByName(objects, "Plugins"); NSArray children = (NSArray) group.objectForKey("children"); assertTrue(children.containsObject(new NSString(file.getFileRef()))); //Added to the PBXSourcesBuildPhase NSDictionary phase = getPhase(objects, "PBXResourcesBuildPhase"); NSArray files = (NSArray) phase.get("files"); assertTrue(files.containsObject(new NSString(file.getUuid()))); }
Example 16
Source File: PBXProjectTest.java From thym with Eclipse Public License 1.0 | 5 votes |
private boolean isFileEntryFoundOnPluginsGroup(PBXFile file, NSDictionary objects) throws PBXProjectException { NSDictionary group = getGroupByName(objects, "Plugins"); NSArray children = (NSArray) group.objectForKey("children"); boolean groupFound = false; NSObject[] childs = children.getArray(); for (int i = 0; i < childs.length; i++) { NSString str = (NSString)childs[i]; if(str.getContent().equals(file.getFileRef())){ groupFound = true; break; } } return groupFound; }
Example 17
Source File: PlistTest.java From netbeans with Apache License 2.0 | 5 votes |
public void update(InputStream is) throws Exception { NSDictionary root = (NSDictionary) XMLPropertyListParser.parse(is); NSDictionary argument = (NSDictionary) root.objectForKey("__argument"); NSDictionary listing = (NSDictionary) argument.objectForKey("WIRListingKey"); for (String s : listing.allKeys()) { NSDictionary o = (NSDictionary) listing.objectForKey(s); NSObject identifier = o.objectForKey("WIRPageIdentifierKey"); NSObject url = o.objectForKey("WIRURLKey"); NSObject title = o.objectForKey("WIRTitleKey"); map.put(s, new TabDescriptor(url.toString(), title.toString(), identifier.toString())); } }
Example 18
Source File: DictionaryLicense.java From cyberduck with GNU General Public License v3.0 | 4 votes |
protected void verify(final NSDictionary dictionary, final String publicKey) throws InvalidLicenseException { if(null == dictionary) { throw new InvalidLicenseException(); } final NSData signature = (NSData) dictionary.objectForKey("Signature"); if(null == signature) { log.warn(String.format("Missing key 'Signature' in dictionary %s", dictionary)); throw new InvalidLicenseException(); } // Append all values StringBuilder values = new StringBuilder(); final ArrayList<String> keys = new ArrayList<>(dictionary.keySet()); // Sort lexicographically by key keys.sort(new DefaultLexicographicOrderComparator()); for(String key : keys) { if("Signature".equals(key)) { continue; } values.append(dictionary.objectForKey(key).toString()); } byte[] signaturebytes = signature.bytes(); byte[] plainbytes = values.toString().getBytes(StandardCharsets.UTF_8); try { final BigInteger modulus = new BigInteger(StringUtils.removeStart(publicKey, "0x"), 16); final BigInteger exponent = new BigInteger(Base64.decodeBase64("Aw==")); final KeySpec spec = new RSAPublicKeySpec(modulus, exponent); final PublicKey rsa = KeyFactory.getInstance("RSA").generatePublic(spec); final Cipher rsaCipher = Cipher.getInstance("RSA/ECB/PKCS1Padding"); rsaCipher.init(Cipher.DECRYPT_MODE, rsa); final MessageDigest sha1Digest = MessageDigest.getInstance("SHA1"); if(!Arrays.equals(rsaCipher.doFinal(signaturebytes), sha1Digest.digest(plainbytes))) { throw new InvalidLicenseException(); } } catch(NoSuchPaddingException | BadPaddingException | IllegalBlockSizeException | InvalidKeyException | InvalidKeySpecException | NoSuchAlgorithmException e) { log.warn(String.format("Signature verification failure for key %s", file)); throw new InvalidLicenseException(); } if(log.isInfoEnabled()) { log.info(String.format("Valid key in %s", file)); } }
Example 19
Source File: IOSDebugTransport.java From netbeans with Apache License 2.0 | 4 votes |
public boolean update(NSObject r) throws Exception { if (!(r instanceof NSDictionary)) { return false; } NSDictionary listing = dictInNSObject(r, "__argument", "WIRListingKey"); //NOI18N if (listing == null) { return false; } boolean wasEmpty = map.isEmpty(); boolean connectionUrlFound = false; HashMap<String, TabDescriptor> currentMap = new HashMap(); for (String s : listing.allKeys()) { NSDictionary o = (NSDictionary) listing.objectForKey(s); NSObject identifier = o.objectForKey("WIRPageIdentifierKey"); // NOI18N NSObject url = o.objectForKey("WIRURLKey"); // NOI18N if (url == null) { continue; } String urlString = url.toString().trim(); if(urlString.isEmpty()) { continue; } NSObject title = o.objectForKey("WIRTitleKey"); // NOI18N if (getConnectionURL()==null) { //auto setup for phonegap. There is always on tab setBaseUrl(url.toString()); } currentMap.put(s, new TabDescriptor(urlString, title.toString(), identifier.toString())); if (checkUrlMatchesConnectionUrl(urlString)) { connectionUrlFound = true; fixApplicationIdentifierKey(r); } } if (!connectionUrlFound) { return false; } map.clear(); map.putAll(currentMap); if (map.isEmpty()) { return !wasEmpty; // was not empty and now is empty -> updated } else { synchronized (init) { init.notifyAll(); } synchronized (monitor) { inited = true; monitor.notifyAll(); } if (getTabForUrl() == null) { WebKitDebuggingSupport.getDefault().stopDebugging(false); } return true; } }