Java Code Examples for com.dd.plist.NSArray#setValue()

The following examples show how to use com.dd.plist.NSArray#setValue() . 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: PlistWriter.java    From cyberduck with GNU General Public License v3.0 6 votes vote down vote up
@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();
    try (final OutputStream out = file.getOutputStream(false)) {
        IOUtils.write(content, out, StandardCharsets.UTF_8);
    }
    catch(IOException e) {
        throw new AccessDeniedException(String.format("Cannot create file %s", file.getAbsolute()), e);
    }
}
 
Example 2
Source File: PlistSerializer.java    From cyberduck with GNU General Public License v3.0 5 votes vote down vote up
@Override
public <T extends Serializable> void setListForKey(final Collection<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);
}
 
Example 3
Source File: PlistSerializer.java    From cyberduck with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setStringListForKey(final Collection<String> value, final String key) {
    final NSArray list = new NSArray(value.size());
    int i = 0;
    for(String serializable : value) {
        list.setValue(i, serializable);
        i++;
    }
    dict.put(key, list);
}
 
Example 4
Source File: PBXShellScriptBuildPhase.java    From buck with Apache License 2.0 5 votes vote down vote up
/** Converts List of Strings into NSArray of NSStrings */
protected NSArray serializeStringList(List<String> list) {
  NSArray result = new NSArray(list.size());
  for (int i = 0; i < list.size(); i++) {
    result.setValue(i, new NSString(list.get(i)));
  }
  return result;
}
 
Example 5
Source File: XcodeprojSerializer.java    From buck with Apache License 2.0 5 votes vote down vote up
public void addField(String name, List<? extends PBXObject> objectList) {
  NSArray array = new NSArray(objectList.size());
  for (int i = 0; i < objectList.size(); i++) {
    String gid = serializeObject(objectList.get(i));
    array.setValue(i, new NSString(gid));
  }
  Objects.requireNonNull(currentObject).put(name, array);
}