当前位置: 首页>>代码示例>>Java>>正文


Java NSArray类代码示例

本文整理汇总了Java中com.dd.plist.NSArray的典型用法代码示例。如果您正苦于以下问题:Java NSArray类的具体用法?Java NSArray怎么用?Java NSArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


NSArray类属于com.dd.plist包,在下文中一共展示了NSArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: write

import com.dd.plist.NSArray; //导入依赖的package包/类
@Override
public void write(final Collection<S> collection, final Local file) throws AccessDeniedException {
    final NSArray list = new NSArray(collection.size());
    int i = 0;
    for(S bookmark : collection) {
        list.setValue(i, bookmark.<NSDictionary>serialize(SerializerFactory.get()));
        i++;
    }
    final String content = list.toXMLPropertyList();
    final OutputStream out = file.getOutputStream(false);
    try {
        IOUtils.write(content, out, Charset.forName("UTF-8"));
    }
    catch(IOException e) {
        throw new AccessDeniedException(String.format("Cannot create file %s", file.getAbsolute()), e);
    }
    finally {
        IOUtils.closeQuietly(out);
    }
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:21,代码来源:PlistWriter.java

示例2: installProfile

import com.dd.plist.NSArray; //导入依赖的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);
  }
}
 
开发者ID:google,项目名称:devtools-driver,代码行数:20,代码来源:ConfigProfiles.java

示例3: readCollection

import com.dd.plist.NSArray; //导入依赖的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;
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:22,代码来源:PlistReader.java

示例4: listConfigurationProfiles

import com.dd.plist.NSArray; //导入依赖的package包/类
@Override
public ImmutableList<ConfigurationProfile> listConfigurationProfiles() throws IosDeviceException {
  String plistXml = await(cfgutil.get("configurationProfiles"));
  NSDictionary plist = (NSDictionary) PlistParser.fromXml(plistXml);
  String ecid = ((NSArray) plist.get("Devices")).objectAtIndex(0).toString();
  NSDictionary output = (NSDictionary) ((NSDictionary) plist.get("Output")).get(ecid);
  NSArray profileArray = (NSArray) output.get("configurationProfiles");

  ImmutableList.Builder<ConfigurationProfile> profiles = ImmutableList.builder();
  for (int i = 0; i < profileArray.count(); i++) {
    NSDictionary profileDict = (NSDictionary) profileArray.objectAtIndex(i);
    profiles.add(
        ConfigurationProfile.builder()
            .displayName(((NSString) profileDict.get("displayName")).getContent())
            .identifier(((NSString) profileDict.get("identifier")).getContent())
            .version(((NSNumber) profileDict.get("version")).intValue())
            .build());
  }
  return profiles.build();
}
 
开发者ID:google,项目名称:ios-device-control,代码行数:21,代码来源:RealDeviceImpl.java

示例5: reloadBrowserList

import com.dd.plist.NSArray; //导入依赖的package包/类
static void reloadBrowserList(ArrayList<Browser> browserList) {

        NSArray root = new NSArray(browserList.size());
        for (int i = 0; i < browserList.size(); i++) {
            NSDictionary browser = new NSDictionary();
            browser.put(FIELD_NAME_BROWSER, browserList.get(i).getName());
            browser.put(FIELD_NAME_CALL, browserList.get(i).getCall());
            browser.put(FIELD_NAME_PRIVATE_CALL, browserList.get(i).getIncognitoCall());
            root.setValue(i, browser);
        }

        try {
            log.debug("Browser list location: " + ApplicationConstants.DEFAULT_LIST_LOCATION);
            File file = new File(ApplicationConstants.DEFAULT_LIST_LOCATION);
            PropertyListParser.saveAsXML(root, file);
        } catch (IOException e) {
            log.warn("Can not create .webloc file", e);
        }
    }
 
开发者ID:benchdoos,项目名称:WeblocOpener,代码行数:20,代码来源:BrowserManager.java

示例6: updateRootPlistPreferenceSpecifiersKeyDefaultValue

import com.dd.plist.NSArray; //导入依赖的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));
    }
}
 
开发者ID:ctco,项目名称:gradle-mobile-plugin,代码行数:25,代码来源:ProfilingUtil.java

示例7: parseSources

import com.dd.plist.NSArray; //导入依赖的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);
            }
        }
    }
}
 
开发者ID:die-tageszeitung,项目名称:tazapp-android,代码行数:18,代码来源:Paper.java

示例8: parseCategories

import com.dd.plist.NSArray; //导入依赖的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);
        }
    }
}
 
开发者ID:die-tageszeitung,项目名称:tazapp-android,代码行数:17,代码来源:Paper.java

示例9: putValue

import com.dd.plist.NSArray; //导入依赖的package包/类
private void putValue(NSDictionary dictionary, String key, String value)
{
    boolean isArray = value.charAt(0) == '[';

    if (isArray)
    {
        String[] values = value.substring(1, value.length() - 1).split(","); //$NON-NLS-1$
        NSArray array = new NSArray(values.length);
        for (int ii = 0; ii < values.length; ii++)
            array.setValue(ii, new NSString(values[ii]));
        dictionary.put(key, array);
    }
    else
    {
        dictionary.put(key, new NSString(value));
    }
}
 
开发者ID:buchen,项目名称:fix-info-plist-maven-plugin,代码行数:18,代码来源:FixInfoPlistMojo.java

示例10: testAddFrameworkWithWeak

import com.dd.plist.NSArray; //导入依赖的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")));
}
 
开发者ID:eclipse,项目名称:thym,代码行数:22,代码来源:PBXProjectTest.java

示例11: testAddToLibrarySearchPaths

import com.dd.plist.NSArray; //导入依赖的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());
		}
	}

}
 
开发者ID:eclipse,项目名称:thym,代码行数:24,代码来源:PBXProjectTest.java

示例12: addToPbxBuildFileSection

import com.dd.plist.NSArray; //导入依赖的package包/类
private void addToPbxBuildFileSection(PBXFile pbxfile) throws PBXProjectException {
	NSDictionary obj = new NSDictionary();
	obj.put("isa" , "PBXBuildFile");
	obj.put("fileRef", pbxfile.getFileRef());
	if (pbxfile.hasSettings()){
		NSDictionary settings = new NSDictionary();
		if(pbxfile.isWeak()){
			NSArray attribs = new NSArray(NSObject.wrap("Weak"));
			settings.put("ATTRIBUTES", attribs);
		}
		if(pbxfile.getCompilerFlags() != null ){
			settings.put("COMPILER_FLAGS", NSObject.wrap(pbxfile.getCompilerFlags()));
		}
		obj.put("settings", settings);
	}
	getObjects().put(pbxfile.getUuid(), obj);
}
 
开发者ID:eclipse,项目名称:thym,代码行数:18,代码来源:PBXProject.java

示例13: testHandlesNonDictionaryPlists

import com.dd.plist.NSArray; //导入依赖的package包/类
@Test
public void testHandlesNonDictionaryPlists() throws Exception {
  FakeProjectFilesystem projectFilesystem = new FakeProjectFilesystem();

  PlistProcessStep plistProcessStep =
      new PlistProcessStep(
          projectFilesystem,
          INPUT_PATH,
          Optional.empty(),
          OUTPUT_PATH,
          ImmutableMap.of(),
          ImmutableMap.of("Key1", new NSString("OverrideValue")),
          PlistProcessStep.OutputFormat.XML);

  NSArray array = new NSArray(new NSString("Value1"), new NSString("Value2"));
  projectFilesystem.writeContentsToPath(array.toXMLPropertyList(), INPUT_PATH);

  ExecutionContext executionContext = TestExecutionContext.newInstance();
  int errorCode = plistProcessStep.execute(executionContext).getExitCode();
  assertThat(errorCode, equalTo(0));

  assertThat(
      projectFilesystem.readFileIfItExists(OUTPUT_PATH),
      equalTo(Optional.of(array.toXMLPropertyList())));
}
 
开发者ID:facebook,项目名称:buck,代码行数:26,代码来源:PlistProcessStepTest.java

示例14: listForKey

import com.dd.plist.NSArray; //导入依赖的package包/类
@Override
public <T> List<T> listForKey(final String key) {
    final NSObject value = dict.objectForKey(key);
    if(null == value) {
        return null;
    }
    if(value instanceof NSArray) {
        final NSArray array = (NSArray) value;
        final List<T> list = new ArrayList<T>();
        for(int i = 0; i < array.count(); i++) {
            final NSObject next = array.objectAtIndex(i);
            if(next instanceof NSDictionary) {
                list.add((T) next);
            }
            else if(next instanceof NSString) {
                list.add((T) next.toString());
            }
            else {
                log.warn(String.format("Ignore content of type %s", next));
            }

        }
        return list;
    }
    log.warn(String.format("Unexpected value type for serialized key %s", key));
    return null;
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:28,代码来源:PlistDeserializer.java

示例15: setListForKey

import com.dd.plist.NSArray; //导入依赖的package包/类
@Override
public <T extends Serializable> void setListForKey(final List<T> value, final String key) {
    final NSArray list = new NSArray(value.size());
    int i = 0;
    for(Serializable serializable : value) {
        list.setValue(i, serializable.<NSDictionary>serialize(SerializerFactory.get()));
        i++;
    }
    dict.put(key, list);
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:11,代码来源:PlistSerializer.java


注:本文中的com.dd.plist.NSArray类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。