download
dydoc
dynam
lua
nanoki
pl
support
zoe

PL — What Is It?


PL provides a simple format to serialize object graphs into a textual representation, coupled with a set of standard data types as well as a free and open source implementation.

Source and binary download available.

Comment [6]

* * *


PL — The Format

PL is a simple text format to represent the structure and interrelationships of data.

PL supports four primary data types.

String

A string is enclosed in double quotation marks, for example:

"This is a string"

Binary

Binary data is enclosed in angle brackets and encoded in hexadecimal ASCII. For example:

<0FBD7771C2735AE>

Collection

A collection is enclosed in parentheses, with the elements separated by commas. For example:

( "Sydney", "New York", "Shanghai", "London" )

Map

A map is enclosed in curly braces, and contains a list of keys with their values. Each key-value pair ends with a semicolon. For example:

{ "user" = "wshakesp"; "birth" = "1564"; }

PL’s file extension is .plist and its MIME type application/x-plist.

PL’s character set encoding is UTF-8.

Formal Syntax

PL is mostly backward compatible with the Old-Style ASCII Property Lists (aka plist) introduced over a decade ago by NeXT alongside their OPENSTEP specification. More information here, here, and there.

Comment [2]

* * *


PL — The Types

In addition to the four primary data types defined by the PL format, PL provides an extended set of standard types.

boolean

A boolean is enclosed in double quotation marks and prefixed with the literal boolean:. For example:

"boolean:true"

Valid boolean values are true and false.

double

A double is enclosed in double quotation marks and prefixed with the literal double:. For example:

"double:0.05314161768595449"

Valid double values range from 4.940656458412465e-324 to 1.797693134862316e+308.

float

A float is enclosed in double quotation marks and prefixed with the literal float:. For example:

"float:0.8220202"

Valid float values range from 1.401298e-45 to 3.402823e+38.

int

An int is enclosed in double quotation marks and prefixed with the literal int:. For example:

"int:-1029390112"

Valid int values range from -2,147,483,648 to 2,147,483,647.

long

A long is enclosed in double quotation marks and prefixed with the literal long:. For example:

"long:8005790835096650374"

Valid long values range from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.

short

A short is enclosed in double quotation marks and prefixed with the literal short:. For example:

"short:12500"

Valid short values range from -32,768 to 32,767.

address

An address is enclosed in double quotation marks and prefixed with the literal address:. For example:

"address:127.0.0.1"

"address:::1"

"address:localhost"

Valid address values are IPv4 address, IPv6 address or a host name.

uri

An uri is enclosed in double quotation marks and prefixed with the literal uri:. For example:

"uri:http://alt.textdrive.com/pl/"

Valid uri values are any Uniform Resource Identifiers.

charset

A charset is enclosed in double quotation marks and prefixed with the literal charset:. For example:

"charset:UTF-8"

Valid charset values are those registed with IANA.

currency

A currency is enclosed in double quotation marks and prefixed with the literal currency:. For example:

"currency:USD"

Valid currency values are those defined by ISO 4217.

date

A date is enclosed in double quotation marks and prefixed with the literal date:. For example:

"date:2004-12-23 11:06:54.10 +0100"

Valid date formats are derived from the W3C profile of ISO 8601 and includes the following patterns:

yyyy-MM-dd HH:mm:ss.S Z
Complete date plus hours, minutes, seconds, a decimal fraction of a second and time zone

yyyy-MM-dd HH:mm:ss Z
Complete date plus hours, minutes, seconds and time zone

yyyy-MM-dd HH:mm Z
Complete date plus hours, minutes and time zone

yyyy-MM-dd
Complete date

yyyy-MM
Year and month

yyyy
Year

locale

A locale is enclosed in double quotation marks and prefixed with the literal locale:. For example:

"locale:en-US"

Valid locale values follow the notation of the HTTP/1.1 Accept-Language header and are composed of a valid two-letter language code as defined by ISO 639, optionally followed by a separator and a two-letter country codes as defined by ISO 3166.

timezone

A timezone is enclosed in double quotation marks and prefixed with the literal timezone:. For example:

"timezone:US/Eastern"

Valid timezone values are those defined in the public-domain time zone database.

alias address

An alias address is enclosed in double quotation marks and prefixed with the literal &:. For example:

"&:123"

Valid alias address values are any alphanumeric combinations. The only requirement is for the alias address to be unique in the scope of a PL document.

alias pointer

An alias pointer is enclosed in double quotation marks and prefixed with the literal *:. For example:

"*:123"

Valid alias pointer values are any alphanumerics combinations. The only requirement is for the alias pointer to refer to a previously declared alias address.

null

A null is represented by an empty String. For example:

""

custom

A custom type is prefixed with the literal x-. For example:

"x-bigdecimal:0.087861441879128365783913068"

"x-biginteger:43040341172496725022114701021"

{

":" = "x-proxy"; "handler" = { ":" = "x-object"; "class" = "x-class:PLTestTool"; "values" = (); }; "interfaces" = ( "x-class:java.lang.Comparable", "x-class:java.util.Iterator", "x-class:java.lang.Runnable" ); }

Valid custom types must be prefixed with x-.

Comment [2]

* * *


PL — The Implementation

PL provides a free and open source implementation to demonstrate the usage of its format and types. The implementation is in the Java programming language. Source and binary download available.

The implementation can be used at 3 levels:

reading a property list

import alt.dev.pl.PLReader;

new PLReader( anInputStream ).readObject();

writing a property list

import alt.dev.pl.PLWriter;

new PLWriter( anOutputStream ).writeObject( anObject );

properties

import alt.dev.pl.PL;

PL someProperties = new PL();

someProperties.load( anInputStream );

someProperties.store( anOutputStream );

serializing an object to PL

import alt.dev.pl.PLObjectOutput;

PLObjectOutput.toString( anObject );

// Alternatively

new PLObjectOutput( anOutputStream ).writeObject( anObject );

deserializing an object back from PL

import alt.dev.pl.PLObjectInput;

PLObjectInput.valueOf( aString );

// Alternatively

new PLObjectInput( anInputStream ).readObject();

custom serialization

To overwrite the default serialization mechanism, you can register your own PLObjectInputReader and PLObjectOutputWriter.

PLObjectOutputWriter.registerWriter( aWriter );

PLObjectInputReader.registerReader( aReader );

Here is an example of a custom java.lang.StringBuffer reader and writer.

custom types

The Java implementation provides several custom types tailored for object serialization.

x-bigdecimal

A x-bigdecimal is enclosed in double quotation marks and prefixed with the literal x-bigdecimal:. For example:

"x-bigdecimal:8.539734222673565966488240519"

Valid x-bigdecimal values are the one returned by java.math.BigDecimal.

x-biginteger

A x-biginteger is enclosed in double quotation marks and prefixed with the literal x-biginteger:. For example:

"x-biginteger:88004293940654845815221765739"

Valid x-biginteger values are the one returned by java.math.BigInteger.

x-class

A x-class is enclosed in double quotation marks and prefixed with the literal x-class:. For example:

"x-class:java.lang.Runnable"

Valid x-class values are language specific. In Java, they reflect the value returned by java.lang.Class.

x-field

A x-field is a Map structure. For example:

{

":" = "x-field"; "name" = "serialVersionUID"; "class" = "x-class:java.util.HashMap"; "type" = "x-class:long"; }

Valid x-field values are language specific. In Java, they reflect the information provided by java.lang.reflect.Field.

x-method

A x-method is a Map structure. For example:

{

":" = "x-method"; "name" = "put"; "class" = "x-class:java.util.HashMap"; "types" = ( "x-class:java.lang.Object", "x-class:java.lang.Object" ); "return" = "x-class:java.lang.Object"; }

Valid x-method values are language specific. In Java, they reflect the information provided by java.lang.reflect.Method and java.lang.reflect.Constructor.

x-proxy

A x-proxy is a Map structure. For example:

{

":" = "x-proxy"; "handler" = { ":" = "x-object"; "class" = "x-class:PLTestTool"; "values" = ""; }; "interfaces" = ( "x-class:java.lang.Comparable", "x-class:java.util.Iterator", "x-class:java.lang.Runnable" ); }

Valid x-proxy values are language specific. In Java, they reflect the information provided by java.lang.reflect.Proxy.

x-object

A x-object is a Map structure. For example:

{

":" = "x-object"; "class" = "x-class:java.util.BitSet"; "values" = { "bits" = ( "long:0" ); }; }

Valid x-object values are language specific. In Java, they reflect the information provided by java.lang.reflect.

x-java-serialized-object

A x-java-serialized-object is a Map structure. For example:

{

":" = "x-java-serialized-object"; "class" = "x-class:java.util.Date"; "value" = <ACED00057>; }

Valid x-java-serialized-object values are specific to java.io.ObjectOutputStream.

Comment

* * *


PL — The License

PL is licensed under a OSI certified zlib/libpng type license.


Copyright (C) 2004 Raphaël Szwarc


This software is provided ‘as-is’, without any express or implied warranty. In no event will the author be held liable for any damages arising from the use of this software.


Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:


1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.


2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.


3. This notice may not be removed or altered from any source distribution.

Comment

* * *