本文整理汇总了Java中com.dd.plist.NSObject类的典型用法代码示例。如果您正苦于以下问题:Java NSObject类的具体用法?Java NSObject怎么用?Java NSObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NSObject类属于com.dd.plist包,在下文中一共展示了NSObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: installProfile
import com.dd.plist.NSObject; //导入依赖的package包/类
private static void installProfile(RealDevice device, String profilePath, NSDictionary newPayload)
throws IosDeviceException {
try {
String templateXml = Resources.toString(Resources.getResource(profilePath), UTF_8);
NSDictionary plistDict = (NSDictionary) PlistParser.fromXml(templateXml);
NSArray plistArray = (NSArray) plistDict.get("PayloadContent");
NSDictionary plistInnerDict = (NSDictionary) plistArray.objectAtIndex(0);
for (Map.Entry<String, NSObject> entry : newPayload.entrySet()) {
plistInnerDict.put(entry.getKey(), entry.getValue());
}
String plist = plistDict.toXMLPropertyList();
Path configFile = Files.createTempFile("modified_profile", ".mobileconfig");
Files.write(configFile, plist.getBytes(UTF_8));
device.installProfile(configFile.toAbsolutePath());
} catch (IOException e) {
throw new IosDeviceException(device, e);
}
}
示例2: readCollection
import com.dd.plist.NSObject; //导入依赖的package包/类
@Override
public Collection<S> readCollection(final Local file) throws AccessDeniedException {
final Collection<S> c = new Collection<S>();
final NSArray list = (NSArray) this.parse(file);
if(null == list) {
log.error(String.format("Invalid bookmark file %s", file));
return c;
}
for(int i = 0; i < list.count(); i++) {
NSObject next = list.objectAtIndex(i);
if(next instanceof NSDictionary) {
final NSDictionary dict = (NSDictionary) next;
final S object = this.deserialize(dict);
if(null == object) {
continue;
}
c.add(object);
}
}
return c;
}
示例3: readFromPath
import com.dd.plist.NSObject; //导入依赖的package包/类
/** Returns the application info read from either an app folder or ipa archive */
public static IosAppInfo readFromPath(Path ipaOrAppPath) throws IOException {
NSObject plistDict;
if (Files.isDirectory(ipaOrAppPath)) {
plistDict = PlistParser.fromPath(ipaOrAppPath.resolve("Info.plist"));
} else {
try (FileSystem ipaFs = FileSystems.newFileSystem(ipaOrAppPath, null)) {
Path appPath =
MoreFiles.listFiles(ipaFs.getPath("Payload"))
.stream()
// Can't use Files.isDirectory, because no entry is a "directory" in a zip.
.filter(e -> e.toString().endsWith(".app/"))
.collect(MoreCollectors.onlyElement());
plistDict = PlistParser.fromPath(appPath.resolve("Info.plist"));
}
}
return readFromPlistDictionary((NSDictionary) plistDict);
}
示例4: profileFirstLevelPlistEntries
import com.dd.plist.NSObject; //导入依赖的package包/类
public static void profileFirstLevelPlistEntries(File targetFile, File profileFile, ProfilingUtilMode mode) throws IOException {
logger.info("Profiling '"+targetFile.getAbsolutePath()+"'...");
logger.info(" initial md5={}", CommonUtil.getMD5Hex(targetFile));
BackupUtil.backupFile(targetFile);
NSDictionary baseDict = PlistUtil.getRootDictionary(targetFile);
NSDictionary profDict = PlistUtil.getRootDictionary(profileFile);
NSDictionary rsltDict = new NSDictionary();
for (Map.Entry<String, NSObject> baseEntry : baseDict.entrySet()) {
if (profDict.containsKey(baseEntry.getKey())) {
logger.info(" Replacing key '"+baseEntry.getKey()+"' with value '"+profDict.get(baseEntry.getKey())+"'");
rsltDict.put(baseEntry.getKey(), profDict.get(baseEntry.getKey()));
} else {
rsltDict.put(baseEntry.getKey(), baseEntry.getValue());
}
}
if (mode == ProfilingUtilMode.UPDATE_AND_ADD) {
for (Map.Entry<String, NSObject> profEntry : profDict.entrySet()) {
if (!rsltDict.containsKey(profEntry.getKey())) {
logger.info(" Adding key '"+profEntry.getKey()+"' with value '"+profDict.get(profEntry.getKey())+"'");
rsltDict.put(profEntry.getKey(), profEntry.getValue());
}
}
}
PropertyListParser.saveAsXML(rsltDict, targetFile.getAbsoluteFile());
logger.info(" current md5={}", CommonUtil.getMD5Hex(targetFile));
}
示例5: updateRootPlistPreferenceSpecifiersKeyDefaultValue
import com.dd.plist.NSObject; //导入依赖的package包/类
public static void updateRootPlistPreferenceSpecifiersKeyDefaultValue(File plistFile, String keyToUpdate, String valueToSet) throws IOException {
BackupUtil.backupFile(plistFile);
NSDictionary rootDict = PlistUtil.getRootDictionary(plistFile);
boolean plistModified = false;
for (Map.Entry<String, NSObject> subRootEntry : rootDict.entrySet()) {
if ("PreferenceSpecifiers".equals(subRootEntry.getKey())
&& subRootEntry.getValue() instanceof NSArray
&& "com.dd.plist.NSArray".equals(subRootEntry.getValue().getClass().getCanonicalName())) {
NSObject[] psArray = ((NSArray)subRootEntry.getValue()).getArray();
NSDictionary psDict = (NSDictionary)psArray[0];
for (Map.Entry<String, NSObject> psEntry : psDict.entrySet()) {
if (keyToUpdate.equals(psEntry.getKey())) {
psEntry.setValue(new NSString(valueToSet));
plistModified = true;
logger.info(" Replacing key '{}' with value '{}'", psEntry.getKey(), valueToSet);
}
}
}
}
if (plistModified) {
PropertyListParser.saveAsXML(rootDict, plistFile.getAbsoluteFile());
logger.info(" current md5={}", CommonUtil.getMD5Hex(plistFile));
}
}
示例6: getProfiledPreferenceSpecifiersObjectArray
import com.dd.plist.NSObject; //导入依赖的package包/类
public static List<NSObject> getProfiledPreferenceSpecifiersObjectArray(List<NSObject> originalArray, List<NSObject> profileArray) {
List<NSObject> resultArray = new ArrayList<>();
for (NSObject originalObject : originalArray) {
boolean targetProfiled = false;
NSDictionary originalDict = (NSDictionary) originalObject;
if (originalDict.get("Type") == null || updatablePreferenceSpecifiers.contains(originalDict.get("Type").toString())) {
for (NSObject profileObject : profileArray) {
NSDictionary profileDict = (NSDictionary) profileObject;
if (originalDict.get("Key").equals(profileDict.get("Key"))) {
targetProfiled = true;
logger.info(" Replacing PreferenceSpecifiers key '"+profileDict.get("Key")+"'");
resultArray.add(profileObject);
break;
}
}
}
if (!targetProfiled) {
resultArray.add(originalObject);
}
}
return resultArray;
}
示例7: parseSources
import com.dd.plist.NSObject; //导入依赖的package包/类
private void parseSources() {
sources = new ArrayList<>();
if (root.containsKey(KEY_SOURCES)) {
NSObject[] sourcesArray = ((NSArray) root.objectForKey(KEY_SOURCES)).getArray();
if (sourcesArray != null) {
// result = new Source[sources.length];
for (NSObject sourceObject : sourcesArray) {
NSDictionary sourceDict = (NSDictionary) sourceObject;
String key = sourceDict.allKeys()[0];
Source source = new Source(key, (NSArray) sourceDict.objectForKey(key));
indexMap.put(source.getKey(), source);
source.parseBooks();
sources.add(source);
}
}
}
}
示例8: parseCategories
import com.dd.plist.NSObject; //导入依赖的package包/类
private void parseCategories() {
categories = new ArrayList<>();
NSObject[] sourceBookCategories = array.getArray();
if (sourceBookCategories != null) {
for (NSObject sourceBookCategory : sourceBookCategories) {
NSDictionary sourceBookCategoryDict = (NSDictionary) sourceBookCategory;
String key = sourceBookCategoryDict.allKeys()[0];
Category category = new Category(this, key, (NSArray) sourceBookCategoryDict.objectForKey(key));
indexMap.put(category.getKey(), category);
category.parsePages();
category.parseRealPagesForArticles();
categories.add(category);
}
}
}
示例9: parsePages
import com.dd.plist.NSObject; //导入依赖的package包/类
private void parsePages() {
pages = new ArrayList<>();
NSObject[] sourceBookCategoryPages = array.getArray();
if (sourceBookCategoryPages != null) {
for (NSObject sourceBookCategoryPage : sourceBookCategoryPages) {
NSDictionary sourceBookCategoryPageDict = (NSDictionary) sourceBookCategoryPage;
String key = sourceBookCategoryPageDict.allKeys()[0];
Page page = new Page(this, key, (NSDictionary) sourceBookCategoryPageDict.objectForKey(key));
indexMap.put(page.getKey(), page);
for (Article article : page.getArticles()) {
indexMap.put(article.getKey(), article);
}
pages.add(page);
}
}
}
示例10: parseArticles
import com.dd.plist.NSObject; //导入依赖的package包/类
private void parseArticles() {
articles = new ArrayList<>();
NSObject[] sourceBookCategoryPageArticles = articleArray.getArray();
if (sourceBookCategoryPageArticles != null) {
for (NSObject sourceBookCategoryPageArticle : sourceBookCategoryPageArticles) {
NSDictionary sourceBookCategoryPageArticleDict = (NSDictionary) sourceBookCategoryPageArticle;
String key = sourceBookCategoryPageArticleDict.allKeys()[0];
Article article = new Article(key, (NSDictionary) sourceBookCategoryPageArticleDict.get(key));
// for (Geometry geometry : getGeometries()) {
// if (article.getKey()
// .equals(geometry.getLink())) {
// //geometry.article = article;
// article.geometries.add(geometry);
// }
// }
articles.add(article);
}
}
}
示例11: handleEntity
import com.dd.plist.NSObject; //导入依赖的package包/类
@Override
public T handleEntity(HttpEntity entity) throws IOException {
NSObject nsObject;
try {
// Avoiding PropertyListParser#parse(InputStream) as the current Maven build (1.16) can bug out.
nsObject = PropertyListParser.parse(EntityUtils.toByteArray(entity));
} catch (PropertyListFormatException | ParseException | ParserConfigurationException | SAXException ex) {
throw new BadDataException("failed to parse property list", ex);
}
if (to.isAssignableFrom(nsObject.getClass())) {
return to.cast(nsObject);
}
throw new BadDataException("failed to cast property list: " + nsObject.getClass());
}
示例12: testAddFrameworkWithWeak
import com.dd.plist.NSObject; //导入依赖的package包/类
@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")));
}
示例13: testAddToLibrarySearchPaths
import com.dd.plist.NSObject; //导入依赖的package包/类
@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());
}
}
}
示例14: searchPathForFile
import com.dd.plist.NSObject; //导入依赖的package包/类
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 );
}
}
示例15: getProductName
import com.dd.plist.NSObject; //导入依赖的package包/类
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;
}