EMMA Coverage Report (generated Wed Aug 29 00:03:59 CDT 2007)
[all classes][org.fuwjax.jon.accessor]

COVERAGE SUMMARY FOR SOURCE FILE [ListWriter.java]

nameclass, %method, %block, %line, %
ListWriter.java100% (1/1)100% (5/5)100% (50/50)100% (18/18)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ListWriter100% (1/1)100% (5/5)100% (50/50)100% (18/18)
ListWriter (CachedAppendable, Token): void 100% (1/1)100% (6/6)100% (2/2)
ListWriter (CachedAppendable, Token, Symbol): void 100% (1/1)100% (15/15)100% (6/6)
write (Object, Accessor): void 100% (1/1)100% (16/16)100% (6/6)
write (Token): void 100% (1/1)100% (5/5)100% (2/2)
writeImpl (Object, Accessor): void 100% (1/1)100% (8/8)100% (2/2)

1/*
2 * This file is part of JON.
3 *
4 * JON is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * JON is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 * 
17 * Copyright 2007 Michael Doberenz
18 */
19package org.fuwjax.jon.accessor;
20 
21import org.fuwjax.jon.CachedAppendable;
22import org.fuwjax.jon.ObjectAccessException;
23import org.fuwjax.jon.SerialFormatException;
24 
25/**
26 * A closure for writing lists of items.
27 * @author michaeldoberenz
28 */
29public class ListWriter{
30        private boolean first = true;
31        private CachedAppendable writer;
32        private Token separator;
33        private Symbol symbol;
34 
35        /**
36         * Creates a new instance.
37         * @param writer the destination of the write operation
38         * @param separator the token between items on the list
39         */
40        public ListWriter(final CachedAppendable writer, final Token separator){
41                this(writer, separator, Symbol.Element);
42        }
43 
44        /**
45         * Creates a new instance.
46         * @param writer the destination of the write operation
47         * @param separator the token between items on the list
48         * @param symbol the specification to use to write items to the list
49         */
50        public ListWriter(final CachedAppendable writer, final Token separator, final Symbol symbol){
51                this.symbol = symbol;
52                this.writer = writer;
53                this.separator = separator;
54        }
55 
56        /**
57         * Writes the token to the destination.
58         * @param token the token to write
59         * @throws SerialFormatException if the JON format cannot be preserved
60         */
61        protected void write(final Token token) throws SerialFormatException{
62                token.write(writer);
63        }
64 
65        /**
66         * Writes <code>object</code> to the destination using
67         * <code>accessor</code>.
68         * @param object the object to serialize
69         * @param accessor the serialization specification for the object
70         * @throws ObjectAccessException if an object relationship cannot be followed
71         * @throws SerialFormatException if the JON format cannot be preserved
72         */
73        protected void writeImpl(final Object object, final Accessor accessor) throws ObjectAccessException,
74              SerialFormatException{
75                symbol.write(writer, object, accessor);
76        }
77 
78        /**
79         * Writes <code>object</code> to the destination using
80         * <code>accessor</code>.
81         * @param object the object to serialize
82         * @param accessor the serialization specification for the object
83         * @throws ObjectAccessException if an object relationship cannot be followed
84         * @throws SerialFormatException if the JON format cannot be preserved
85         */
86        public void write(final Object object, final Accessor accessor) throws ObjectAccessException, SerialFormatException{
87                if(!first){
88                        write(separator);
89                }else{
90                        first = false;
91                }
92                writeImpl(object, accessor);
93        }
94}

[all classes][org.fuwjax.jon.accessor]
EMMA 2.0.5312 (C) Vladimir Roubtsov