~ubuntu-branches/ubuntu/precise/libjcommon-java/precise

« back to all changes in this revision

Viewing changes to source/org/jfree/xml/parser/coretypes/RenderingHintsReadHandler.java

  • Committer: Bazaar Package Importer
  • Author(s): Wolfgang Baer
  • Date: 2006-02-09 15:58:13 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060209155813-fzi9zwh2rzedbllq
Tags: 1.0.0-1
* New stable upstream release (closes: #328574)
* Move to main - build with kaffe
* Use cdbs build system - added cdbs build-dependency
* Move package to pkg-java-maintainers for comaintenance, 
  added Christian Bayle and myself as uploaders
* Removed unneeded README.Debian
* Added README.Debian-source how the upstream tarball was cleaned
* Move big documentation in an own -doc package
* Register javadoc api with doc-base
* Standards-Version 3.6.2 (no changes)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ========================================================================
 
2
 * JCommon : a free general purpose class library for the Java(tm) platform
 
3
 * ========================================================================
 
4
 *
 
5
 * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
 
6
 * 
 
7
 * Project Info:  http://www.jfree.org/jcommon/index.html
 
8
 *
 
9
 * This library is free software; you can redistribute it and/or modify it 
 
10
 * under the terms of the GNU Lesser General Public License as published by 
 
11
 * the Free Software Foundation; either version 2.1 of the License, or 
 
12
 * (at your option) any later version.
 
13
 *
 
14
 * This library is distributed in the hope that it will be useful, but 
 
15
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
 
16
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 
 
17
 * License for more details.
 
18
 *
 
19
 * You should have received a copy of the GNU Lesser General Public
 
20
 * License along with this library; if not, write to the Free Software
 
21
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
 
22
 * USA.  
 
23
 *
 
24
 * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 
 
25
 * in the United States and other countries.]
 
26
 * 
 
27
 * ------------------------------
 
28
 * RenderingHintsReadHandler.java
 
29
 * ------------------------------
 
30
 * (C)opyright 2003, 2004, by Thomas Morgner and Contributors.
 
31
 *
 
32
 * Original Author:  Thomas Morgner;
 
33
 * Contributor(s):   David Gilbert (for Object Refinery Limited);
 
34
 *
 
35
 * $Id: RenderingHintsReadHandler.java,v 1.3 2005/10/18 13:33:32 mungady Exp $
 
36
 *
 
37
 * Changes
 
38
 * -------
 
39
 * 03-Dec-2003 : Initial version
 
40
 * 11-Feb-2004 : Added missing Javadocs (DG);
 
41
 * 
 
42
 */
 
43
 
 
44
package org.jfree.xml.parser.coretypes;
 
45
 
 
46
import java.awt.RenderingHints;
 
47
import java.util.ArrayList;
 
48
 
 
49
import org.jfree.xml.parser.AbstractXmlReadHandler;
 
50
import org.jfree.xml.parser.XmlReadHandler;
 
51
import org.jfree.xml.parser.XmlReaderException;
 
52
import org.xml.sax.Attributes;
 
53
import org.xml.sax.SAXException;
 
54
 
 
55
/**
 
56
 * A read handler that can parse the XML element for a {@link RenderingHints} collection.
 
57
 */
 
58
public class RenderingHintsReadHandler extends AbstractXmlReadHandler {
 
59
 
 
60
    /** The subhandlers. */
 
61
    private ArrayList handlers;
 
62
    
 
63
    /** The rendering hints under construction. */
 
64
    private RenderingHints renderingHints;
 
65
 
 
66
    /**
 
67
     * Creates a new read handler.
 
68
     */
 
69
    public RenderingHintsReadHandler() {
 
70
        super();
 
71
    }
 
72
 
 
73
    /**
 
74
     * Starts parsing.
 
75
     *
 
76
     * @param attrs  the attributes.
 
77
     *
 
78
     * @throws SAXException never.
 
79
     */
 
80
    protected void startParsing(final Attributes attrs) throws SAXException {
 
81
        this.handlers = new ArrayList();
 
82
    }
 
83
 
 
84
    /**
 
85
     * Returns the handler for a child element.
 
86
     *
 
87
     * @param tagName  the tag name.
 
88
     * @param atts  the attributes.
 
89
     *
 
90
     * @return the handler.
 
91
     *
 
92
     * @throws SAXException  if there is a parsing error.
 
93
     * @throws XmlReaderException if there is a reader error.
 
94
     */
 
95
    protected XmlReadHandler getHandlerForChild(final String tagName, final Attributes atts)
 
96
        throws XmlReaderException, SAXException {
 
97
 
 
98
        if (!tagName.equals("entry")) {
 
99
            throw new SAXException("Expected 'entry' tag.");
 
100
        }
 
101
 
 
102
        final XmlReadHandler handler = new RenderingHintValueReadHandler();
 
103
        this.handlers.add(handler);
 
104
        return handler;
 
105
    }
 
106
 
 
107
    /**
 
108
     * Done parsing.
 
109
     *
 
110
     * @throws SAXException if there is a parsing error.
 
111
     * @throws XmlReaderException if there is a reader error.
 
112
     */
 
113
    protected void doneParsing() throws SAXException, XmlReaderException {
 
114
        this.renderingHints = new RenderingHints(null);
 
115
 
 
116
        for (int i = 0; i < this.handlers.size(); i++) {
 
117
            final RenderingHintValueReadHandler rh =
 
118
                (RenderingHintValueReadHandler) this.handlers.get(i);
 
119
            this.renderingHints.put(rh.getKey(), rh.getValue());
 
120
        }
 
121
    }
 
122
 
 
123
    /**
 
124
     * Returns the object for this element.
 
125
     *
 
126
     * @return the object.
 
127
     *
 
128
     * @throws XmlReaderException if there is a parsing error.
 
129
     */
 
130
    public Object getObject() throws XmlReaderException {
 
131
        return this.renderingHints;
 
132
    }
 
133
}