package org.apache.xmlgraphics.ps.dsc;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;
import org.apache.xmlgraphics.ps.DSCConstants;
import org.apache.xmlgraphics.ps.dsc.events.DSCComment;
import org.apache.xmlgraphics.ps.dsc.events.DSCCommentBeginDocument;
import org.apache.xmlgraphics.ps.dsc.events.DSCCommentBeginResource;
import org.apache.xmlgraphics.ps.dsc.events.DSCCommentBoundingBox;
import org.apache.xmlgraphics.ps.dsc.events.DSCCommentDocumentNeededResources;
import org.apache.xmlgraphics.ps.dsc.events.DSCCommentDocumentSuppliedResources;
import org.apache.xmlgraphics.ps.dsc.events.DSCCommentEndComments;
import org.apache.xmlgraphics.ps.dsc.events.DSCCommentEndOfFile;
import org.apache.xmlgraphics.ps.dsc.events.DSCCommentHiResBoundingBox;
import org.apache.xmlgraphics.ps.dsc.events.DSCCommentIncludeResource;
import org.apache.xmlgraphics.ps.dsc.events.DSCCommentLanguageLevel;
import org.apache.xmlgraphics.ps.dsc.events.DSCCommentPage;
import org.apache.xmlgraphics.ps.dsc.events.DSCCommentPageBoundingBox;
import org.apache.xmlgraphics.ps.dsc.events.DSCCommentPageHiResBoundingBox;
import org.apache.xmlgraphics.ps.dsc.events.DSCCommentPageResources;
import org.apache.xmlgraphics.ps.dsc.events.DSCCommentPages;
import org.apache.xmlgraphics.ps.dsc.events.DSCCommentTitle;
public final class {
private () {
}
private static final Map = new java.util.HashMap();
static {
DSC_FACTORIES.put(DSCConstants.END_COMMENTS,
DSCCommentEndComments.class);
DSC_FACTORIES.put(DSCConstants.BEGIN_RESOURCE,
DSCCommentBeginResource.class);
DSC_FACTORIES.put(DSCConstants.INCLUDE_RESOURCE,
DSCCommentIncludeResource.class);
DSC_FACTORIES.put(DSCConstants.PAGE_RESOURCES,
DSCCommentPageResources.class);
DSC_FACTORIES.put(DSCConstants.BEGIN_DOCUMENT,
DSCCommentBeginDocument.class);
DSC_FACTORIES.put(DSCConstants.PAGE,
DSCCommentPage.class);
DSC_FACTORIES.put(DSCConstants.PAGES,
DSCCommentPages.class);
DSC_FACTORIES.put(DSCConstants.BBOX,
DSCCommentBoundingBox.class);
DSC_FACTORIES.put(DSCConstants.HIRES_BBOX,
DSCCommentHiResBoundingBox.class);
DSC_FACTORIES.put(DSCConstants.PAGE_BBOX,
DSCCommentPageBoundingBox.class);
DSC_FACTORIES.put(DSCConstants.PAGE_HIRES_BBOX,
DSCCommentPageHiResBoundingBox.class);
DSC_FACTORIES.put(DSCConstants.LANGUAGE_LEVEL,
DSCCommentLanguageLevel.class);
DSC_FACTORIES.put(DSCConstants.DOCUMENT_NEEDED_RESOURCES,
DSCCommentDocumentNeededResources.class);
DSC_FACTORIES.put(DSCConstants.DOCUMENT_SUPPLIED_RESOURCES,
DSCCommentDocumentSuppliedResources.class);
DSC_FACTORIES.put(DSCConstants.TITLE,
DSCCommentTitle.class);
DSC_FACTORIES.put(DSCConstants.EOF,
DSCCommentEndOfFile.class);
}
public static DSCComment (String name) {
Class clazz = (Class)DSC_FACTORIES.get(name);
if (clazz == null) {
return null;
}
try {
return (DSCComment)clazz.getDeclaredConstructor().newInstance();
} catch (InstantiationException e) {
throw new RuntimeException("Error instantiating instance for '" + name + "': "
+ e.getMessage());
} catch (IllegalAccessException e) {
throw new RuntimeException("Illegal Access error while instantiating instance for '"
+ name + "': " + e.getMessage());
} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
} catch (InvocationTargetException e) {
throw new RuntimeException(e);
}
}
}