~hjd/ubuntu/wily/xmlgraphics-commons/debian-merged

« back to all changes in this revision

Viewing changes to src/java/org/apache/xmlgraphics/ps/dsc/DSCCommentFactory.java

  • Committer: Bazaar Package Importer
  • Author(s): Vincent Fourmond
  • Date: 2011-02-11 14:15:14 UTC
  • mfrom: (8.1.2 experimental)
  • Revision ID: james.westby@ubuntu.com-20110211141514-h67achft6x31gju1
Tags: 1.4.dfsg-3
Uploading to unstable, hoping we won't break too many things ;-)...

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 * The ASF licenses this file to You under the Apache License, Version 2.0
6
6
 * (the "License"); you may not use this file except in compliance with
7
7
 * the License.  You may obtain a copy of the License at
8
 
 * 
 
8
 *
9
9
 *      http://www.apache.org/licenses/LICENSE-2.0
10
 
 * 
 
10
 *
11
11
 * Unless required by applicable law or agreed to in writing, software
12
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
15
 * limitations under the License.
16
16
 */
17
17
 
18
 
/* $Id$ */
 
18
/* $Id: DSCCommentFactory.java 734420 2009-01-14 15:38:32Z maxberger $ */
19
19
 
20
20
package org.apache.xmlgraphics.ps.dsc;
21
21
 
23
23
 
24
24
import org.apache.xmlgraphics.ps.DSCConstants;
25
25
import org.apache.xmlgraphics.ps.dsc.events.DSCComment;
 
26
import org.apache.xmlgraphics.ps.dsc.events.DSCCommentBeginDocument;
26
27
import org.apache.xmlgraphics.ps.dsc.events.DSCCommentBeginResource;
27
28
import org.apache.xmlgraphics.ps.dsc.events.DSCCommentBoundingBox;
28
29
import org.apache.xmlgraphics.ps.dsc.events.DSCCommentDocumentNeededResources;
30
31
import org.apache.xmlgraphics.ps.dsc.events.DSCCommentEndComments;
31
32
import org.apache.xmlgraphics.ps.dsc.events.DSCCommentEndOfFile;
32
33
import org.apache.xmlgraphics.ps.dsc.events.DSCCommentHiResBoundingBox;
 
34
import org.apache.xmlgraphics.ps.dsc.events.DSCCommentIncludeResource;
33
35
import org.apache.xmlgraphics.ps.dsc.events.DSCCommentLanguageLevel;
34
36
import org.apache.xmlgraphics.ps.dsc.events.DSCCommentPage;
35
37
import org.apache.xmlgraphics.ps.dsc.events.DSCCommentPageBoundingBox;
36
38
import org.apache.xmlgraphics.ps.dsc.events.DSCCommentPageHiResBoundingBox;
37
39
import org.apache.xmlgraphics.ps.dsc.events.DSCCommentPageResources;
38
40
import org.apache.xmlgraphics.ps.dsc.events.DSCCommentPages;
 
41
import org.apache.xmlgraphics.ps.dsc.events.DSCCommentTitle;
39
42
 
40
43
/**
41
44
 * Factory for DSCComment subclasses.
45
48
    private static final Map DSC_FACTORIES = new java.util.HashMap();
46
49
 
47
50
    static {
48
 
        DSC_FACTORIES.put(DSCConstants.END_COMMENTS, 
 
51
        DSC_FACTORIES.put(DSCConstants.END_COMMENTS,
49
52
                DSCCommentEndComments.class);
50
 
        DSC_FACTORIES.put(DSCConstants.BEGIN_RESOURCE, 
 
53
        DSC_FACTORIES.put(DSCConstants.BEGIN_RESOURCE,
51
54
                DSCCommentBeginResource.class);
52
 
        DSC_FACTORIES.put(DSCConstants.PAGE_RESOURCES, 
 
55
        DSC_FACTORIES.put(DSCConstants.INCLUDE_RESOURCE,
 
56
                DSCCommentIncludeResource.class);
 
57
        DSC_FACTORIES.put(DSCConstants.PAGE_RESOURCES,
53
58
                DSCCommentPageResources.class);
54
 
        DSC_FACTORIES.put(DSCConstants.PAGE, 
 
59
        DSC_FACTORIES.put(DSCConstants.BEGIN_DOCUMENT,
 
60
                DSCCommentBeginDocument.class);
 
61
        DSC_FACTORIES.put(DSCConstants.PAGE,
55
62
                DSCCommentPage.class);
56
 
        DSC_FACTORIES.put(DSCConstants.PAGES, 
 
63
        DSC_FACTORIES.put(DSCConstants.PAGES,
57
64
                DSCCommentPages.class);
58
 
        DSC_FACTORIES.put(DSCConstants.BBOX, 
 
65
        DSC_FACTORIES.put(DSCConstants.BBOX,
59
66
                DSCCommentBoundingBox.class);
60
 
        DSC_FACTORIES.put(DSCConstants.HIRES_BBOX, 
 
67
        DSC_FACTORIES.put(DSCConstants.HIRES_BBOX,
61
68
                DSCCommentHiResBoundingBox.class);
62
 
        DSC_FACTORIES.put(DSCConstants.PAGE_BBOX, 
 
69
        DSC_FACTORIES.put(DSCConstants.PAGE_BBOX,
63
70
                DSCCommentPageBoundingBox.class);
64
 
        DSC_FACTORIES.put(DSCConstants.PAGE_HIRES_BBOX, 
 
71
        DSC_FACTORIES.put(DSCConstants.PAGE_HIRES_BBOX,
65
72
                DSCCommentPageHiResBoundingBox.class);
66
 
        DSC_FACTORIES.put(DSCConstants.LANGUAGE_LEVEL, 
 
73
        DSC_FACTORIES.put(DSCConstants.LANGUAGE_LEVEL,
67
74
                DSCCommentLanguageLevel.class);
68
 
        DSC_FACTORIES.put(DSCConstants.DOCUMENT_NEEDED_RESOURCES, 
 
75
        DSC_FACTORIES.put(DSCConstants.DOCUMENT_NEEDED_RESOURCES,
69
76
                DSCCommentDocumentNeededResources.class);
70
 
        DSC_FACTORIES.put(DSCConstants.DOCUMENT_SUPPLIED_RESOURCES, 
 
77
        DSC_FACTORIES.put(DSCConstants.DOCUMENT_SUPPLIED_RESOURCES,
71
78
                DSCCommentDocumentSuppliedResources.class);
72
 
        DSC_FACTORIES.put(DSCConstants.EOF, 
 
79
        DSC_FACTORIES.put(DSCConstants.TITLE,
 
80
                DSCCommentTitle.class);
 
81
        DSC_FACTORIES.put(DSCConstants.EOF,
73
82
                DSCCommentEndOfFile.class);
74
83
        //TODO Add additional implementations as needed
75
84
    }
76
 
    
 
85
 
77
86
    /**
78
87
     * Creates and returns new instances for DSC comments with a given name.
79
88
     * @param name the name of the DSCComment (without the "%%" prefix)
88
97
        try {
89
98
            return (DSCComment)clazz.newInstance();
90
99
        } catch (InstantiationException e) {
91
 
            throw new RuntimeException("Error instantiating instance for '" + name + "': " 
 
100
            throw new RuntimeException("Error instantiating instance for '" + name + "': "
92
101
                    + e.getMessage());
93
102
        } catch (IllegalAccessException e) {
94
 
            throw new RuntimeException("Illegal Access error while instantiating instance for '" 
 
103
            throw new RuntimeException("Illegal Access error while instantiating instance for '"
95
104
                    + name + "': " + e.getMessage());
96
105
        }
97
106
    }
98
 
    
 
107
 
99
108
}