issue 87: CON may assign a sequence to a property (which must be a List)
diff --git a/src/main/java/org/yaml/snakeyaml/extensions/compactnotation/CompactConstructor.java b/src/main/java/org/yaml/snakeyaml/extensions/compactnotation/CompactConstructor.java
index 40ea0a7..0d6fd91 100644
--- a/src/main/java/org/yaml/snakeyaml/extensions/compactnotation/CompactConstructor.java
+++ b/src/main/java/org/yaml/snakeyaml/extensions/compactnotation/CompactConstructor.java
@@ -16,9 +16,12 @@
 
 package org.yaml.snakeyaml.extensions.compactnotation;
 
+import java.beans.IntrospectionException;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -80,7 +83,12 @@
         }
         for (String key : data.keySet()) {
             Property property = getPropertyUtils().getProperty(bean.getClass(), key);
-            property.set(bean, data.get(key));
+            try {
+                property.set(bean, data.get(key));
+            } catch (IllegalArgumentException e) {
+                throw new YAMLException("Cannot set property='" + key + "' with value='"
+                        + data.get(key) + "' (" + data.get(key).getClass() + ") in " + bean);
+            }
         }
     }
 
@@ -144,19 +152,52 @@
         public Object construct(Node node) {
             Map<Object, Object> map = constructMapping((MappingNode) node);
             // Compact Object Notation may contain only one entry
-            if (map.size() != 1) {
-                throw new YAMLException("Compact Object Notation may contain only one entry: "
-                        + map.size());
-            }
             Map.Entry<Object, Object> entry = map.entrySet().iterator().next();
             Object result = entry.getKey();
-            Map<String, Object> properties = (Map<String, Object>) entry.getValue();
-            try {
-                setProperties(result, properties);
-            } catch (Exception e) {
-                throw new YAMLException(e);
+            Object value = entry.getValue();
+            if (value instanceof Map) {
+                Map<String, Object> properties = (Map<String, Object>) value;
+                try {
+                    setProperties(result, properties);
+                } catch (Exception e) {
+                    throw new YAMLException(e);
+                }
+            } else {
+                // value is a list
+                try {
+                    Property property = getPropertyUtils().getProperty(result.getClass(),
+                            getSequencePropertyName(result.getClass()));
+                    property.set(result, (List<?>) value);
+                } catch (Exception e) {
+                    throw new YAMLException(e);
+                }
             }
             return result;
         }
     }
+
+    /**
+     * Provide the name of the property which is used when the entries form a
+     * sequence. The property must be a List.
+     * 
+     * @throws IntrospectionException
+     */
+    protected String getSequencePropertyName(Class<?> bean) throws IntrospectionException {
+        Set<Property> properties = getPropertyUtils().getProperties(bean);
+        for (Iterator<Property> iterator = properties.iterator(); iterator.hasNext();) {
+            Property property = iterator.next();
+            if (!List.class.isAssignableFrom(property.getType())) {
+                iterator.remove();
+            }
+        }
+        if (properties.size() == 0) {
+            throw new YAMLException("No list property found in " + bean);
+        } else if (properties.size() > 1) {
+            throw new YAMLException(
+                    "Many list properties found in "
+                            + bean
+                            + "; Please override getSequencePropertyName() to specify which property to use.");
+        }
+        return properties.iterator().next().getName();
+    }
 }
diff --git a/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/CustomCompactConstructor.java b/src/main/java/org/yaml/snakeyaml/extensions/compactnotation/PackageCompactConstructor.java
similarity index 90%
rename from src/test/java/org/yaml/snakeyaml/extensions/compactnotation/CustomCompactConstructor.java
rename to src/main/java/org/yaml/snakeyaml/extensions/compactnotation/PackageCompactConstructor.java
index 7b53492..301e1c2 100644
--- a/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/CustomCompactConstructor.java
+++ b/src/main/java/org/yaml/snakeyaml/extensions/compactnotation/PackageCompactConstructor.java
@@ -16,10 +16,10 @@
 

 package org.yaml.snakeyaml.extensions.compactnotation;

 

-public class CustomCompactConstructor extends CompactConstructor {

+public class PackageCompactConstructor extends CompactConstructor {

     private String packageName;

 

-    public CustomCompactConstructor(String packageName) {

+    public PackageCompactConstructor(String packageName) {

         this.packageName = packageName;

     }

 

diff --git a/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/CompactConstructorErrorsTest.java b/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/CompactConstructorErrorsTest.java
new file mode 100644
index 0000000..f70e18e
--- /dev/null
+++ b/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/CompactConstructorErrorsTest.java
@@ -0,0 +1,137 @@
+/**

+ * Copyright (c) 2008-2010, http://code.google.com/p/snakeyaml/

+ *

+ * Licensed under the Apache License, Version 2.0 (the "License");

+ * you may not use this file except in compliance with the License.

+ * You may obtain a copy of the License at

+ *

+ *     http://www.apache.org/licenses/LICENSE-2.0

+ *

+ * Unless required by applicable law or agreed to in writing, software

+ * distributed under the License is distributed on an "AS IS" BASIS,

+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

+ * See the License for the specific language governing permissions and

+ * limitations under the License.

+ */

+

+package org.yaml.snakeyaml.extensions.compactnotation;

+

+import java.util.List;

+import java.util.Map;

+

+import junit.framework.TestCase;

+

+import org.yaml.snakeyaml.Util;

+import org.yaml.snakeyaml.Yaml;

+import org.yaml.snakeyaml.constructor.BaseConstructor;

+

+public class CompactConstructorErrorsTest extends TestCase {

+

+    public void test1() {

+        BaseConstructor compact = new CompactConstructor();

+        Yaml yaml = new Yaml(compact);

+        String doc = Util.getLocalResource("compactnotation/error1.yaml");

+        try {

+            yaml.load(doc);

+            fail("Package is not specified.");

+        } catch (Exception e) {

+            assertEquals("java.lang.ClassNotFoundException: Table", e.getMessage());

+        }

+    }

+

+    private Object load(String fileName) {

+        CompactConstructor compact = new PackageCompactConstructor(

+                "org.yaml.snakeyaml.extensions.compactnotation");

+        Yaml yaml = new Yaml(compact);

+        String doc = Util.getLocalResource("compactnotation/" + fileName);

+        Object obj = yaml.load(doc);

+        assertNotNull(obj);

+        return obj;

+    }

+

+    private void failLoad(String fileName, String failure) {

+        load(fileName);

+        fail(failure);

+    }

+

+    private void check(String fileName, String failure, String message) {

+        try {

+            failLoad(fileName, failure);

+        } catch (Exception e) {

+            assertEquals(message, e.getMessage());

+        }

+    }

+

+    public void test2() {

+        check(

+                "error2.yaml",

+                "No single argument constructor provided.",

+                "java.lang.NoSuchMethodException: org.yaml.snakeyaml.extensions.compactnotation.Table.<init>(java.lang.String)");

+    }

+

+    public void test3() {

+        check(

+                "error3.yaml",

+                "In-line parameters can only be Strings.",

+                "org.yaml.snakeyaml.error.YAMLException: Cannot set property='size' with value='17' (class java.lang.String) in Row id=id111");

+    }

+

+    /**

+     * Created Map instead of Row

+     */

+    @SuppressWarnings("unchecked")

+    public void test4() {

+        Table table = (Table) load("error4.yaml");

+        List<Row> rows = table.getRows();

+        assertEquals(1, rows.size());

+        assertFalse("Row should not be created.", rows.get(0) instanceof Row);

+        Map<String, String> map = (Map<String, String>) rows.get(0);

+        assertEquals(1, map.size());

+        assertEquals("15}", map.get("Row(id111, description = text) {size"));

+    }

+

+    /**

+     * Wrong indent

+     */

+    @SuppressWarnings("unchecked")

+    public void test5() {

+        Table table = (Table) load("error5.yaml");

+        List<Row> rows = table.getRows();

+        assertEquals(1, rows.size());

+        assertFalse("Row should not be created.", rows.get(0) instanceof Row);

+        Map<String, String> map = (Map<String, String>) rows.get(0);

+        assertEquals(4, map.size());

+        // System.out.println(map);

+        assertNull(map.get(new Row("id222")));

+        assertTrue(map.containsKey(new Row("id222")));

+        assertEquals(17, map.get("size"));

+    }

+

+    public void test6() {

+        check(

+                "error6.yaml",

+                "Invalid property.",

+                "org.yaml.snakeyaml.error.YAMLException: Unable to find property 'foo' on class: org.yaml.snakeyaml.extensions.compactnotation.Table");

+    }

+

+    public void test7() {

+        check(

+                "error7.yaml",

+                "Invalid property.",

+                "org.yaml.snakeyaml.error.YAMLException: Unable to find property 'foo' on class: org.yaml.snakeyaml.extensions.compactnotation.Table");

+    }

+

+    public void test8() {

+        check(

+                "error8.yaml",

+                "No list property",

+                "org.yaml.snakeyaml.error.YAMLException: No list property found in class org.yaml.snakeyaml.extensions.compactnotation.Row");

+    }

+

+    public void test9() {

+        check(

+                "error9.yaml",

+                "Many list properties found",

+                "org.yaml.snakeyaml.error.YAMLException: Many list properties found in class org.yaml.snakeyaml.extensions.compactnotation.ManyListsTable; Please override getSequencePropertyName() to specify which property to use.");

+    }

+}

diff --git a/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/CompactConstructorExampleTest.java b/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/CompactConstructorExampleTest.java
index 62c5a05..835c3b8 100644
--- a/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/CompactConstructorExampleTest.java
+++ b/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/CompactConstructorExampleTest.java
@@ -16,6 +16,7 @@
 

 package org.yaml.snakeyaml.extensions.compactnotation;

 

+import java.util.Iterator;

 import java.util.List;

 import java.util.Map;

 

@@ -27,30 +28,27 @@
 

 public class CompactConstructorExampleTest extends TestCase {

 

-    public void test1() {

+    private Object load(String fileName) {

         CompactConstructor compact = new CompactConstructor();

         Yaml yaml = new Yaml(compact);

-        String doc = Util.getLocalResource("compactnotation/container1.yaml");

+        String doc = Util.getLocalResource("compactnotation/" + fileName);

         Object obj = yaml.load(doc);

         assertNotNull(obj);

+        return obj;

+    }

+

+    public void test1() {

+        Object obj = load("example1.yaml");

         assertEquals(new Container(), obj);

     }

 

     public void test2() {

-        CompactConstructor compact = new CompactConstructor();

-        Yaml yaml = new Yaml(compact);

-        String doc = Util.getLocalResource("compactnotation/container2.yaml");

-        Object obj = yaml.load(doc);

-        assertNotNull(obj);

+        Object obj = load("example2.yaml");

         assertEquals(new Container("title"), obj);

     }

 

     public void test3() {

-        CompactConstructor compact = new CompactConstructor();

-        Yaml yaml = new Yaml(compact);

-        String doc = Util.getLocalResource("compactnotation/container3.yaml");

-        Container obj = (Container) yaml.load(doc);

-        assertNotNull(obj);

+        Container obj = (Container) load("example3.yaml");

         assertEquals(new Container("title3"), obj);

         assertEquals("title3", obj.getTitle());

         assertEquals("parent", obj.getName());

@@ -58,10 +56,7 @@
     }

 

     public void test4() {

-        CompactConstructor compact = new CompactConstructor();

-        Yaml yaml = new Yaml(compact);

-        String doc = Util.getLocalResource("compactnotation/container4.yaml");

-        Object obj = yaml.load(doc);

+        Object obj = load("example4.yaml");

         // System.out.println(obj);

         Container container = (Container) obj;

         assertNotNull(obj);

@@ -72,10 +67,7 @@
     }

 

     public void test5() {

-        CompactConstructor compact = new CompactConstructor();

-        Yaml yaml = new Yaml(compact);

-        String doc = Util.getLocalResource("compactnotation/container5.yaml");

-        Object obj = yaml.load(doc);

+        Object obj = load("example5.yaml");

         // System.out.println(obj);

         Container container = (Container) obj;

         assertNotNull(obj);

@@ -86,10 +78,7 @@
     }

 

     public void test6() {

-        CompactConstructor compact = new CompactConstructor();

-        Yaml yaml = new Yaml(compact);

-        String doc = Util.getLocalResource("compactnotation/container6.yaml");

-        Object obj = yaml.load(doc);

+        Object obj = load("example6.yaml");

         // System.out.println(obj);

         Container container = (Container) obj;

         assertNotNull(obj);

@@ -100,10 +89,7 @@
     }

 

     public void test7() {

-        CompactConstructor compact = new CompactConstructor();

-        Yaml yaml = new Yaml(compact);

-        String doc = Util.getLocalResource("compactnotation/container7.yaml");

-        Object obj = yaml.load(doc);

+        Object obj = load("example7.yaml");

         // System.out.println(obj);

         Container container = (Container) obj;

         assertNotNull(obj);

@@ -113,27 +99,10 @@
         assertEquals("id7", container.getId());

     }

 

-    public void test8() {

-        CompactConstructor compact = new CompactConstructor();

-        Yaml yaml = new Yaml(compact);

-        String doc = Util.getLocalResource("compactnotation/container8.yaml");

-        try {

-            yaml.load(doc);

-            fail();

-        } catch (Exception e) {

-            assertEquals(

-                    "org.yaml.snakeyaml.error.YAMLException: Unable to find property 'nonsense' on class: org.yaml.snakeyaml.extensions.compactnotation.Container",

-                    e.getMessage());

-        }

-    }

-

     @SuppressWarnings("unchecked")

     // TODO it is unclear how the result should look like for CON

     public void test9() {

-        CompactConstructor compact = new CompactConstructor();

-        Yaml yaml = new Yaml(compact);

-        String doc = Util.getLocalResource("compactnotation/container9.yaml");

-        Map<String, Object> map = (Map<String, Object>) yaml.load(doc);

+        Map<String, Object> map = (Map<String, Object>) load("example9.yaml");

         assertEquals(1, map.size());

         Map<Container, Map<String, String>> containers = (Map<Container, Map<String, String>>) map

                 .get("something");

@@ -147,10 +116,7 @@
 

     @SuppressWarnings("unchecked")

     public void test10() {

-        CompactConstructor compact = new CompactConstructor();

-        Yaml yaml = new Yaml(compact);

-        String doc = Util.getLocalResource("compactnotation/container10.yaml");

-        Map<String, Object> map = (Map<String, Object>) yaml.load(doc);

+        Map<String, Object> map = (Map<String, Object>) load("example10.yaml");

         assertEquals(1, map.size());

         List<Container> containers = (List<Container>) map.get("something");

         // System.out.println(obj);

@@ -163,10 +129,10 @@
     }

 

     public void test11withoutPackageNames() {

-        Constructor compact = new CustomCompactConstructor(

+        Constructor compact = new PackageCompactConstructor(

                 "org.yaml.snakeyaml.extensions.compactnotation");

         Yaml yaml = new Yaml(compact);

-        String doc = Util.getLocalResource("compactnotation/container11.yaml");

+        String doc = Util.getLocalResource("compactnotation/example11.yaml");

         Box box = (Box) yaml.load(doc);

         assertNotNull(box);

         assertEquals("id11", box.getId());

@@ -180,4 +146,36 @@
         assertEquals("3.5", bottom.getPrice());

         assertEquals("sweet", bottom.getName());

     }

+

+    public void test12withList() {

+        Constructor compact = new TableCompactConstructor(

+                "org.yaml.snakeyaml.extensions.compactnotation");

+        Yaml yaml = new Yaml(compact);

+        String doc = Util.getLocalResource("compactnotation/example12.yaml");

+        Table table = (Table) yaml.load(doc);

+        assertNotNull(table);

+        assertEquals("id12", table.getId());

+        assertEquals("A table", table.getName());

+        List<Row> rows = table.getRows();

+        assertEquals(3, rows.size());

+        Iterator<Row> iter = rows.iterator();

+        Row first = iter.next();

+        assertEquals("id111", first.getId());

+        assertEquals("I think; therefore I am.", first.getDescription());

+        assertEquals(0.125, first.getRatio(), 0.000000001);

+        assertEquals(15, first.getSize());

+        Row second = iter.next();

+        assertEquals("id222", second.getId());

+        assertEquals("We do not need new lines here, just replace them all with spaces\n", second

+                .getDescription());

+        assertEquals(0.333, second.getRatio(), 0.000000001);

+        assertEquals(17, second.getSize());

+        Row third = iter.next();

+        assertEquals("id333", third.getId());

+        assertEquals(

+                "Please preserve all\nthe lines because they may be\nimportant, but do not include the last one !!!",

+                third.getDescription());

+        assertEquals(0.88, third.getRatio(), 0.000000001);

+        assertEquals(52, third.getSize());

+    }

 }

diff --git a/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/ManyListsTable.java b/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/ManyListsTable.java
new file mode 100644
index 0000000..2f39d53
--- /dev/null
+++ b/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/ManyListsTable.java
@@ -0,0 +1,49 @@
+/**

+ * Copyright (c) 2008-2010, http://code.google.com/p/snakeyaml/

+ *

+ * Licensed under the Apache License, Version 2.0 (the "License");

+ * you may not use this file except in compliance with the License.

+ * You may obtain a copy of the License at

+ *

+ *     http://www.apache.org/licenses/LICENSE-2.0

+ *

+ * Unless required by applicable law or agreed to in writing, software

+ * distributed under the License is distributed on an "AS IS" BASIS,

+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

+ * See the License for the specific language governing permissions and

+ * limitations under the License.

+ */

+

+package org.yaml.snakeyaml.extensions.compactnotation;

+

+import java.util.List;

+

+public class ManyListsTable {

+    private String id;

+    private List<Row> rows;

+    private List<String> names;

+

+    public ManyListsTable(String id) {

+        this.id = id;

+    }

+

+    public List<Row> getRows() {

+        return rows;

+    }

+

+    public void setRows(List<Row> rows) {

+        this.rows = rows;

+    }

+

+    public String getId() {

+        return id;

+    }

+

+    public List<String> getNames() {

+        return names;

+    }

+

+    public void setNames(List<String> names) {

+        this.names = names;

+    }

+}

diff --git a/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/PackageCompactConstructorTest.java b/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/PackageCompactConstructorTest.java
new file mode 100644
index 0000000..e4993de
--- /dev/null
+++ b/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/PackageCompactConstructorTest.java
@@ -0,0 +1,51 @@
+/**

+ * Copyright (c) 2008-2010, http://code.google.com/p/snakeyaml/

+ *

+ * Licensed under the Apache License, Version 2.0 (the "License");

+ * you may not use this file except in compliance with the License.

+ * You may obtain a copy of the License at

+ *

+ *     http://www.apache.org/licenses/LICENSE-2.0

+ *

+ * Unless required by applicable law or agreed to in writing, software

+ * distributed under the License is distributed on an "AS IS" BASIS,

+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

+ * See the License for the specific language governing permissions and

+ * limitations under the License.

+ */

+

+package org.yaml.snakeyaml.extensions.compactnotation;

+

+import junit.framework.TestCase;

+

+public class PackageCompactConstructorTest extends TestCase {

+

+    public void testGetClassForName() throws ClassNotFoundException {

+        assertEquals(Table.class, check("Table"));

+        assertEquals(Table.class, check("org.yaml.snakeyaml.extensions.compactnotation.Table"));

+        assertEquals(String.class, check("java.lang.String"));

+    }

+

+    public void testException1() throws ClassNotFoundException {

+        try {

+            check("foo.Bar");

+            fail();

+        } catch (ClassNotFoundException e) {

+            assertEquals("foo.Bar", e.getMessage());

+        }

+    }

+

+    public void testException2() throws ClassNotFoundException {

+        try {

+            check("FooBar");

+            fail();

+        } catch (ClassNotFoundException e) {

+            assertEquals("FooBar", e.getMessage());

+        }

+    }

+

+    private Class<?> check(String name) throws ClassNotFoundException {

+        return new PackageCompactConstructor("org.yaml.snakeyaml.extensions.compactnotation")

+                .getClassForName(name);

+    }

+}

diff --git a/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/Row.java b/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/Row.java
new file mode 100644
index 0000000..29fd4bb
--- /dev/null
+++ b/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/Row.java
@@ -0,0 +1,72 @@
+/**

+ * Copyright (c) 2008-2010, http://code.google.com/p/snakeyaml/

+ *

+ * Licensed under the Apache License, Version 2.0 (the "License");

+ * you may not use this file except in compliance with the License.

+ * You may obtain a copy of the License at

+ *

+ *     http://www.apache.org/licenses/LICENSE-2.0

+ *

+ * Unless required by applicable law or agreed to in writing, software

+ * distributed under the License is distributed on an "AS IS" BASIS,

+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

+ * See the License for the specific language governing permissions and

+ * limitations under the License.

+ */

+

+package org.yaml.snakeyaml.extensions.compactnotation;

+

+public class Row {

+    private String id;

+    private int size;

+    private double ratio;

+    private String description;

+

+    public Row(String id) {

+        super();

+        this.id = id;

+    }

+

+    public int getSize() {

+        return size;

+    }

+

+    public void setSize(int size) {

+        this.size = size;

+    }

+

+    public double getRatio() {

+        return ratio;

+    }

+

+    public void setRatio(double ratio) {

+        this.ratio = ratio;

+    }

+

+    public String getDescription() {

+        return description;

+    }

+

+    public void setDescription(String description) {

+        this.description = description;

+    }

+

+    public String getId() {

+        return id;

+    }

+

+    @Override

+    public boolean equals(Object obj) {

+        return toString().equals(obj.toString());

+    }

+

+    @Override

+    public int hashCode() {

+        return id.hashCode();

+    }

+

+    @Override

+    public String toString() {

+        return "Row id=" + id;

+    }

+}

diff --git a/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/Table.java b/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/Table.java
new file mode 100644
index 0000000..82486e5
--- /dev/null
+++ b/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/Table.java
@@ -0,0 +1,47 @@
+/**

+ * Copyright (c) 2008-2010, http://code.google.com/p/snakeyaml/

+ *

+ * Licensed under the Apache License, Version 2.0 (the "License");

+ * you may not use this file except in compliance with the License.

+ * You may obtain a copy of the License at

+ *

+ *     http://www.apache.org/licenses/LICENSE-2.0

+ *

+ * Unless required by applicable law or agreed to in writing, software

+ * distributed under the License is distributed on an "AS IS" BASIS,

+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

+ * See the License for the specific language governing permissions and

+ * limitations under the License.

+ */

+

+package org.yaml.snakeyaml.extensions.compactnotation;

+

+import java.util.List;

+

+public class Table {

+    private String id;

+    private String name;

+    private List<Row> rows;

+

+    public Table(String id, String name) {

+        super();

+        this.id = id;

+        this.name = name;

+    }

+

+    public List<Row> getRows() {

+        return rows;

+    }

+

+    public void setRows(List<Row> rows) {

+        this.rows = rows;

+    }

+

+    public String getId() {

+        return id;

+    }

+

+    public String getName() {

+        return name;

+    }

+}

diff --git a/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/TableCompactConstructor.java b/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/TableCompactConstructor.java
new file mode 100644
index 0000000..c3f2eb7
--- /dev/null
+++ b/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/TableCompactConstructor.java
@@ -0,0 +1,25 @@
+/**

+ * Copyright (c) 2008-2010, http://code.google.com/p/snakeyaml/

+ *

+ * Licensed under the Apache License, Version 2.0 (the "License");

+ * you may not use this file except in compliance with the License.

+ * You may obtain a copy of the License at

+ *

+ *     http://www.apache.org/licenses/LICENSE-2.0

+ *

+ * Unless required by applicable law or agreed to in writing, software

+ * distributed under the License is distributed on an "AS IS" BASIS,

+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

+ * See the License for the specific language governing permissions and

+ * limitations under the License.

+ */

+

+package org.yaml.snakeyaml.extensions.compactnotation;

+

+public class TableCompactConstructor extends PackageCompactConstructor {

+

+    public TableCompactConstructor(String packageName) {

+        super(packageName);

+    }

+

+}

diff --git a/src/test/resources/compactnotation/container8.yaml b/src/test/resources/compactnotation/container8.yaml
deleted file mode 100644
index 5d3cec3..0000000
--- a/src/test/resources/compactnotation/container8.yaml
+++ /dev/null
@@ -1,4 +0,0 @@
-org.yaml.snakeyaml.extensions.compactnotation.Container(title4):

-  nonsense: child5

-  id: ID555

-

diff --git a/src/test/resources/compactnotation/error1.yaml b/src/test/resources/compactnotation/error1.yaml
new file mode 100644
index 0000000..d3edca0
--- /dev/null
+++ b/src/test/resources/compactnotation/error1.yaml
@@ -0,0 +1,2 @@
+Table(id12, A table)

+

diff --git a/src/test/resources/compactnotation/error2.yaml b/src/test/resources/compactnotation/error2.yaml
new file mode 100644
index 0000000..a43b6cb
--- /dev/null
+++ b/src/test/resources/compactnotation/error2.yaml
@@ -0,0 +1,2 @@
+Table(id12)

+

diff --git a/src/test/resources/compactnotation/error3.yaml b/src/test/resources/compactnotation/error3.yaml
new file mode 100644
index 0000000..17d3a7a
--- /dev/null
+++ b/src/test/resources/compactnotation/error3.yaml
@@ -0,0 +1,2 @@
+Table(id12, orders): 

+  - Row(id111, size=17, description=text)

diff --git a/src/test/resources/compactnotation/error4.yaml b/src/test/resources/compactnotation/error4.yaml
new file mode 100644
index 0000000..ff29937
--- /dev/null
+++ b/src/test/resources/compactnotation/error4.yaml
@@ -0,0 +1,4 @@
+Table(id12, table): 

+  - Row(id111, description = text) {size: 15}

+

+

diff --git a/src/test/resources/compactnotation/error5.yaml b/src/test/resources/compactnotation/error5.yaml
new file mode 100644
index 0000000..a5e82a1
--- /dev/null
+++ b/src/test/resources/compactnotation/error5.yaml
@@ -0,0 +1,11 @@
+Table(id12, table): 

+  - Row(id222):

+    size: 17

+    ratio: 0.333

+    description: >

+        We do not need new lines

+        here, just replace them

+        all with spaces

+

+

+

diff --git a/src/test/resources/compactnotation/error6.yaml b/src/test/resources/compactnotation/error6.yaml
new file mode 100644
index 0000000..897db39
--- /dev/null
+++ b/src/test/resources/compactnotation/error6.yaml
@@ -0,0 +1,4 @@
+Table(id12, table, foo=bar)

+

+

+

diff --git a/src/test/resources/compactnotation/error7.yaml b/src/test/resources/compactnotation/error7.yaml
new file mode 100644
index 0000000..521fc59
--- /dev/null
+++ b/src/test/resources/compactnotation/error7.yaml
@@ -0,0 +1,5 @@
+Table(id12, table):

+  foo: bar

+

+

+

diff --git a/src/test/resources/compactnotation/error8.yaml b/src/test/resources/compactnotation/error8.yaml
new file mode 100644
index 0000000..9a84ab9
--- /dev/null
+++ b/src/test/resources/compactnotation/error8.yaml
@@ -0,0 +1,11 @@
+Row(id12): 

+  - Row(id222):

+      size: 17

+      ratio: 0.333

+      description: >

+        We do not need new lines

+        here, just replace them

+        all with spaces

+

+

+

diff --git a/src/test/resources/compactnotation/error9.yaml b/src/test/resources/compactnotation/error9.yaml
new file mode 100644
index 0000000..241c2fa
--- /dev/null
+++ b/src/test/resources/compactnotation/error9.yaml
@@ -0,0 +1,11 @@
+ManyListsTable(id12): 

+  - Row(id111, description = text)

+  - Row(id222):

+      size: 17

+      ratio: 0.333

+      description: >

+        We do not need new lines

+        here, just replace them

+        all with spaces

+

+

diff --git a/src/test/resources/compactnotation/container1.yaml b/src/test/resources/compactnotation/example1.yaml
similarity index 100%
rename from src/test/resources/compactnotation/container1.yaml
rename to src/test/resources/compactnotation/example1.yaml
diff --git a/src/test/resources/compactnotation/container10.yaml b/src/test/resources/compactnotation/example10.yaml
similarity index 100%
rename from src/test/resources/compactnotation/container10.yaml
rename to src/test/resources/compactnotation/example10.yaml
diff --git a/src/test/resources/compactnotation/container11.yaml b/src/test/resources/compactnotation/example11.yaml
similarity index 100%
rename from src/test/resources/compactnotation/container11.yaml
rename to src/test/resources/compactnotation/example11.yaml
diff --git a/src/test/resources/compactnotation/example12.yaml b/src/test/resources/compactnotation/example12.yaml
new file mode 100644
index 0000000..737c0df
--- /dev/null
+++ b/src/test/resources/compactnotation/example12.yaml
@@ -0,0 +1,17 @@
+Table(id12, A table): 

+  - Row(id111, description = I think; therefore I am.): {size: 15, ratio: 0.125}

+  - Row(id222):

+      size: 17

+      ratio: 0.333

+      description: >

+        We do not need new lines

+        here, just replace them

+        all with spaces

+  - Row(id333):

+      size: 52

+      ratio: 0.88

+      description: |-

+        Please preserve all

+        the lines because they may be

+        important, but do not include the last one !!!

+

diff --git a/src/test/resources/compactnotation/container2.yaml b/src/test/resources/compactnotation/example2.yaml
similarity index 100%
rename from src/test/resources/compactnotation/container2.yaml
rename to src/test/resources/compactnotation/example2.yaml
diff --git a/src/test/resources/compactnotation/container3.yaml b/src/test/resources/compactnotation/example3.yaml
similarity index 100%
rename from src/test/resources/compactnotation/container3.yaml
rename to src/test/resources/compactnotation/example3.yaml
diff --git a/src/test/resources/compactnotation/container4.yaml b/src/test/resources/compactnotation/example4.yaml
similarity index 100%
rename from src/test/resources/compactnotation/container4.yaml
rename to src/test/resources/compactnotation/example4.yaml
diff --git a/src/test/resources/compactnotation/container5.yaml b/src/test/resources/compactnotation/example5.yaml
similarity index 100%
rename from src/test/resources/compactnotation/container5.yaml
rename to src/test/resources/compactnotation/example5.yaml
diff --git a/src/test/resources/compactnotation/container6.yaml b/src/test/resources/compactnotation/example6.yaml
similarity index 100%
rename from src/test/resources/compactnotation/container6.yaml
rename to src/test/resources/compactnotation/example6.yaml
diff --git a/src/test/resources/compactnotation/container7.yaml b/src/test/resources/compactnotation/example7.yaml
similarity index 100%
rename from src/test/resources/compactnotation/container7.yaml
rename to src/test/resources/compactnotation/example7.yaml
diff --git a/src/test/resources/compactnotation/container9.yaml b/src/test/resources/compactnotation/example9.yaml
similarity index 100%
rename from src/test/resources/compactnotation/container9.yaml
rename to src/test/resources/compactnotation/example9.yaml