本文整理汇总了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);
}
}
示例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);
}
}
示例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;
}
示例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();
}
示例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);
}
}
示例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));
}
}
示例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);
}
}
}
}
示例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);
}
}
}
示例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));
}
}
示例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")));
}
示例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());
}
}
}
示例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);
}
示例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())));
}
示例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;
}
示例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);
}