<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent changes to home</title><link href="https://sourceforge.net/p/plist/home/" rel="alternate"/><link href="https://sourceforge.net/p/plist/home/feed.atom" rel="self"/><id>https://sourceforge.net/p/plist/home/</id><updated>2012-10-30T19:27:42.107000Z</updated><subtitle>Recent changes to home</subtitle><entry><title>Discussion for synopsis page</title><link href="https://sourceforge.net/p/plist/home/_discuss/thread/fc79f608/" rel="alternate"/><published>2012-10-30T19:27:42.107000Z</published><updated>2012-10-30T19:27:42.107000Z</updated><author><name>Steven Darnell</name><uri>https://sourceforge.net/u/darnells/</uri></author><id>https://sourceforge.net21f4f63816942702daa0f2acd28d209d3ec49827</id><summary type="html">Hi Yørn,

Thanks for creating Property List Library. I am using it to read plist objects within nested NSDictionaries; however, I now need to edit an object within the same NSDictionary hierarchy. Can it be done using property-list-2.0.0? I opened a ticket on the topic: https://sourceforge.net/p/plist/tickets/1/

Thanks again!</summary></entry><entry><title>WikiPage howto modified by Yørn de Jong</title><link href="https://sourceforge.net/p/plist/home/howto/" rel="alternate"/><published>2012-09-03T20:47:48.672000Z</published><updated>2012-09-03T20:47:48.672000Z</updated><author><name>Yørn de Jong</name><uri>https://sourceforge.net/u/byorn/</uri></author><id>https://sourceforge.net580b8b61623bddf2595d10725cdc5926d5d26c3a</id><summary type="html">&lt;pre&gt;&lt;/pre&gt;</summary></entry><entry><title>WikiPage synopsis modified by Yørn de Jong</title><link href="https://sourceforge.net/p/plist/home/synopsis/" rel="alternate"/><published>2012-09-03T20:47:28.312000Z</published><updated>2012-09-03T20:47:28.312000Z</updated><author><name>Yørn de Jong</name><uri>https://sourceforge.net/u/byorn/</uri></author><id>https://sourceforge.netb8c2fd1f3dd852d435cc469b2aad12dec812e182</id><summary type="html">&lt;pre&gt;--- v15
+++ v16
@@ -1,12 +1,10 @@
 Property List Library — Synopsis
 ===
+
+This project aims to provide a Java implementation for reading and writing Property List files. It will do so by providing an API which is intuitive for Java developers. This API is not modelled after Apple's API.
 
 Property list files are mainly used by Mac OS X to store serialized objects in a key/value manner. These files usually have an .plist extension. In Mac OS X, Property List files are usually stored in a central location. This library can honour this convention and has conventions built in for *NIX and Windows as well. This makes the library a good platform independent alternative to Apple's own Defaults system or the Windows Registry. There are multiple kinds of Property List files; ASCII, XML and Binary. Read all about them on [Wikipedia](http://en.wikipedia.org/wiki/Property_list).
 
 Want to get started using the library? Then you should read the [howto](howto)
 
-In the future this project will support the JSON Property List and ASCII Property List formats. However, these are not widely used and supporting them is not a high priority.
-
-This project was born out of frustration with other Property List libraries in Java. Most of the libraries out there can only read/write the XML format, and a lot of them do a sloppy job.
-
 [[download_button]]
&lt;/pre&gt;</summary></entry><entry><title>Discussion for synopsis page</title><link href="https://sourceforge.net/p/plist/home/_discuss/thread/fc79f608/" rel="alternate"/><published>2012-09-03T20:45:21.617000Z</published><updated>2012-09-03T20:45:21.617000Z</updated><author><name>Yørn de Jong</name><uri>https://sourceforge.net/u/byorn/</uri></author><id>https://sourceforge.net1081aedb01c42d789ff3a91b11caacc66448decd</id><summary type="html">Any other examples you would like to see? Send a comment and i'll add them.
Don't be scared, I won't bite!</summary></entry><entry><title>WikiPage howto modified by Yørn de Jong</title><link href="https://sourceforge.net/p/plist/home/howto/" rel="alternate"/><published>2012-09-03T20:40:59.623000Z</published><updated>2012-09-03T20:40:59.623000Z</updated><author><name>Yørn de Jong</name><uri>https://sourceforge.net/u/byorn/</uri></author><id>https://sourceforge.net55f5b1c01ec566cf21a96cdd95d6d17dc9cb1503</id><summary type="html">&lt;pre&gt;--- v1
+++ v2
@@ -69,7 +69,7 @@
 // the result of #toMap() is immutable, by packing the map into a TreeMap it will become editable
 
 // Convert NSArray to List&lt;NSObject&gt;
-List&lt;String,NSObject&gt; list = new ArrayList&lt;NSObject&gt;(prefs.get("quotes").toList());
+List&lt;NSObject&gt; list = new ArrayList&lt;NSObject&gt;(prefs.get("quotes").toList());
 // the result of #toList() is immutable, by packing the list into an ArrayList it will become editable
 
 // Convert NSArray to NSObject[]
&lt;/pre&gt;</summary></entry><entry><title>WikiPage howto modified by Yørn de Jong</title><link href="https://sourceforge.net/p/plist/home/howto/" rel="alternate"/><published>2012-09-03T20:39:30.677000Z</published><updated>2012-09-03T20:39:30.677000Z</updated><author><name>Yørn de Jong</name><uri>https://sourceforge.net/u/byorn/</uri></author><id>https://sourceforge.net0b5da24f786795604b5038f65f98a0593e5557a8</id><summary type="html">#How to use the Property List Library#
Hi, since you've found this library and intend to use it you probably already know what Property Lists are. But just in case, here's a short introduction:

## Introduction ##
Property List files are primarily used in Apple's operating systems such as iOS and Mac OS X, as well as the predecessors of these systems like NeXT. They are key/value data-stores primarily used to store user preferences but can also be found in a lot of [bundles](http://en.wikipedia.org/wiki/Application_bundle). Property List files can be found in different flavours, the Binary format being the one most used. Legacy systems can still use the ASCII format which resembles JSON but has some key differences. The ASCII format is not supported at this time.

In a typical Mac OS X installation, the Property List files containing preferences can be found in ~/Library/Preferences for user preferences and in /Library/Preferences for system preferences. Additionally, in ~/Library/Preferences/ByHost, one can find Property List files which are intended to be used in one host only. This is useful when a user has a home directory which is shared among multiple computers, like a home directory on removeable store or network storage. The filename of these files contains an ID which is unique for one computer right before the file extension.

#Using NSDefaults#
Probably the easiest way to use the library is by using NSDefaults. NSDefaults knows about the locations where Property List files are supposed to be stored and handles this for you. Property List filenames contain an so-called identifier which reminds a Java developer of a package name. Another reason for choosing NSDefaults is that it implements SortedMap&lt;String,NSObject&gt; which makes it extremely easy to use; you as a Java developer probably already had the pleasure of working with maps. An instance of NSDefaults can be obtained by running the following code:

~~~~~~
:::java
package org.example.plist;

import net.sf.plist.defaults.NSDefaults;
import net.sf.plist.defaults.Scope;

/* class and method declaration go here */

// Get the user preferences for our local
NSDefaults prefs = NSDefaults.getInstance(this, Scope.USER);
~~~~~~

By giving ‘this’ as the first parameter, NSDefaults will detect that the current package is “org.example.plist” and will as such look for the file org.example.plist.plist (2nd .plist is the file extension) and read it, or start empty if it doesn't exist yet. If the package name is longer than 3 segments it will only use the first three, except when a longer package matches an identifier earlier used. You can force a specific identifier by using the following code:

~~~~~~
:::java
NSDefaults prefs = NSDefaults.getInstance("org.example.other", Scope.USER);
~~~~~~

If you are in a static context, instead of using ‘this’ you can also use a class as the first parameter, for example:

~~~~~~
:::java
NSDefaults prefs = NSDefaults.getInstance(TestClass.class, Scope.USER);
~~~~~~

Reading and writing values in and from the Property List is also quite easy;

~~~~~~
:::java
// Write example
prefs.put("name", new NSString("Yørn"));
prefs.put("age", new NSInteger(25));
prefs.save();
~~~~~~

Please remember to save when you're done making modifications.

~~~~~~
:::java
// Read example
String name = prefs.containsKey("name") ? prefs.get("name").toString() : "";
int age = prefs.containsKey("age") ? prefs.get("age").toInteger() : 0;
~~~~~~

OK, those were the simple things.

#Using dictionaries and arrays#
First of all, in this Java implementation, all NSObjects are immutable (they are not immutable in the Apple Objective-C implementation). That means they cannot be changed themselves; you will need to assign another one to change it. Also, every NSObject represents a Java class. In most cases you won't even notice that NSObjects are immutable, since this is also the behavior of the Strings, Integers and Booleans in Java. This is however different for Collections; you can change the contents of a List or Map in Java. Even though you can edit the NSDefaults (which in this Java implementation does not extend from NSObject), you cannot edit the NSDictionary or NSArray. This is because Property List files are key/value stores. Even though a NSDictionary does store key/values itself, the NSDictionary itself is just a value which has to be replaced in it's entirely. This suddenly becomes a lot easier when you realize that an NSDictionary can easily convert from/to an SortedMap&lt;String,NSObject&gt; which can be editable. Also, an NSArray can be converted from/to an List&lt;NSObject&gt; or even NSObject[].

Examples:

~~~~~~
:::java
// Convert NSDictionary to SortedMap&lt;String,NSObject&gt;
SortedMap&lt;String,NSObject&gt; map = new TreeMap&lt;String,NSObject&gt;(prefs.get("studies").toMap());
// the result of #toMap() is immutable, by packing the map into a TreeMap it will become editable

// Convert NSArray to List&lt;NSObject&gt;
List&lt;String,NSObject&gt; list = new ArrayList&lt;NSObject&gt;(prefs.get("quotes").toList());
// the result of #toList() is immutable, by packing the list into an ArrayList it will become editable

// Convert NSArray to NSObject[]
NSObject[] arr = prefs.get("quotes").toArray();
// the array arr is editable but the edits will not appear in the original NSObject

list.put("Well that was easy!");
studies.put("BSc", new NSDate(new Date(1345413600)));

// Convert List&lt;NSObject&gt; to NSArray
NSArray nsArray = new NSArray(list);
// changes made to list after this will not appear in nsArray
prefs.put("quotes", nsArray);

// Convert SortedMap&lt;String,NSObject&gt; to NSDictionary
NSDictionary nsDictionary = new NSArray(list);
// changes made to map after this will not appear in nsDictionary
prefs.put("studies", nsDictionary);
~~~~~~
</summary></entry><entry><title>WikiPage synopsis modified by Yørn de Jong</title><link href="https://sourceforge.net/p/plist/home/synopsis/" rel="alternate"/><published>2012-09-03T20:35:05.787000Z</published><updated>2012-09-03T20:35:05.787000Z</updated><author><name>Yørn de Jong</name><uri>https://sourceforge.net/u/byorn/</uri></author><id>https://sourceforge.net10093447f7543a0561dd3966a415079095f1733b</id><summary type="html">&lt;pre&gt;--- v14
+++ v15
@@ -3,7 +3,7 @@
 
 Property list files are mainly used by Mac OS X to store serialized objects in a key/value manner. These files usually have an .plist extension. In Mac OS X, Property List files are usually stored in a central location. This library can honour this convention and has conventions built in for *NIX and Windows as well. This makes the library a good platform independent alternative to Apple's own Defaults system or the Windows Registry. There are multiple kinds of Property List files; ASCII, XML and Binary. Read all about them on [Wikipedia](http://en.wikipedia.org/wiki/Property_list).
 
-Want to get started using the library? Then you should read the [quickguide](quickguide) (Not updated for 2.0.0 yet!).
+Want to get started using the library? Then you should read the [howto](howto)
 
 In the future this project will support the JSON Property List and ASCII Property List formats. However, these are not widely used and supporting them is not a high priority.
 
&lt;/pre&gt;</summary></entry><entry><title>WikiPage synopsis modified by Yørn de Jong</title><link href="https://sourceforge.net/p/plist/home/synopsis/" rel="alternate"/><published>2012-07-19T11:09:45.200000Z</published><updated>2012-07-19T11:09:45.200000Z</updated><author><name>Yørn de Jong</name><uri>https://sourceforge.net/u/byorn/</uri></author><id>https://sourceforge.neta9689a0a8a73ea12229eedda1c171e8b701ee4dc</id><summary type="html">&lt;pre&gt;--- v13
+++ v14
@@ -1,11 +1,11 @@
 Property List Library — Synopsis
 ===
 
-Property list files are mainly used by Mac OS X to store serialized objects in a key/value manner. These files usually have an .plist extension. There are multiple kinds of Property List files; ASCII, XML and Binary. Read all about them on [Wikipedia](http://en.wikipedia.org/wiki/Property_list).
+Property list files are mainly used by Mac OS X to store serialized objects in a key/value manner. These files usually have an .plist extension. In Mac OS X, Property List files are usually stored in a central location. This library can honour this convention and has conventions built in for *NIX and Windows as well. This makes the library a good platform independent alternative to Apple's own Defaults system or the Windows Registry. There are multiple kinds of Property List files; ASCII, XML and Binary. Read all about them on [Wikipedia](http://en.wikipedia.org/wiki/Property_list).
 
-Want to get started using the library? Then you should read the [quickguide](quickguide).
+Want to get started using the library? Then you should read the [quickguide](quickguide) (Not updated for 2.0.0 yet!).
 
-The first focus of this project is to create a library that supports reading and writing of XML property list files as those are still the most common. The second focus is reading and writing of the binary property list format, as that's what Mac OS X uses these days. Supporting ASCII property lists has the lowest priority, since those are no longer used and rare to spot in the wild.
+In the future this project will support the JSON Property List and ASCII Property List formats. However, these are not widely used and supporting them is not a high priority.
 
 This project was born out of frustration with other Property List libraries in Java. Most of the libraries out there can only read/write the XML format, and a lot of them do a sloppy job.
 
&lt;/pre&gt;</summary></entry><entry><title>Discussion for synopsis page</title><link href="https://sourceforge.net/p/plist/home/_discuss/thread/fc79f608/" rel="alternate"/><published>2012-05-25T12:51:44.659000Z</published><updated>2012-05-25T12:51:44.659000Z</updated><author><name>Yørn de Jong</name><uri>https://sourceforge.net/u/byorn/</uri></author><id>https://sourceforge.netd04b1ade1133e0e9e73c6a66bfb64e87f521f361</id><summary type="html">Dear Kalem
The tag release-1.0.1 should have the same code as the jar. The trunk contains the newest version which has a couple of improvements and new features. There is no jar available of this version because it is subject to change. I intend to release a jar of this code in about a month. It will probably become a 2.0 release as I have changed the API a bit.

An exception when using the InputStream is indeed one of the bugs I fixed. The stream got closed by the code which was not the intended behavior. This bug is fixed in the trunk and you'll have to close the stream yourself after using it.</summary></entry><entry><title>Discussion for synopsis page</title><link href="https://sourceforge.net/p/plist/home/_discuss/thread/fc79f608/" rel="alternate"/><published>2012-05-25T00:43:53.526000Z</published><updated>2012-05-25T00:43:53.526000Z</updated><author><name>Kalem</name><uri>https://sourceforge.net/u/kalemontes/</uri></author><id>https://sourceforge.net782eda9a7afb4509d0e747eafb93cddacc8bac02</id><summary type="html">Is the PropertyList.jar-1.0.1 download jar upto date with your code? I was having a no implementation Exception in PropertyListParser.java when using a InputStream with the download jar but gone when i created my own jar from the checkout project.</summary></entry></feed>