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
9
9
* http://www.apache.org/licenses/LICENSE-2.0
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.
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;
41
44
* Factory for DSCComment subclasses.
45
48
private static final Map DSC_FACTORIES = new java.util.HashMap();
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
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)
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());