aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/render/intermediate/extensions/NamedDestination.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/org/apache/fop/render/intermediate/extensions/NamedDestination.java')
-rw-r--r--src/java/org/apache/fop/render/intermediate/extensions/NamedDestination.java85
1 files changed, 85 insertions, 0 deletions
diff --git a/src/java/org/apache/fop/render/intermediate/extensions/NamedDestination.java b/src/java/org/apache/fop/render/intermediate/extensions/NamedDestination.java
new file mode 100644
index 000000000..85b6aca19
--- /dev/null
+++ b/src/java/org/apache/fop/render/intermediate/extensions/NamedDestination.java
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.render.intermediate.extensions;
+
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
+
+import org.apache.xmlgraphics.util.XMLizable;
+
+import org.apache.fop.util.XMLConstants;
+
+/**
+ * This class is a named destination element for use in the intermediate format.
+ */
+public class NamedDestination implements XMLizable, DocumentNavigationExtensionConstants {
+
+ private String name;
+ private AbstractAction action;
+
+ /**
+ * Creates a new named destination.
+ * @param name the destination's name
+ * @param action the action performed when the destination is selected
+ */
+ public NamedDestination(String name, AbstractAction action) {
+ this.name = name;
+ this.action = action;
+ }
+
+ /**
+ * Returns the destination's name.
+ * @return the name
+ */
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * Returns the action performed when the destination is selected.
+ * @return the action
+ */
+ public AbstractAction getAction() {
+ return this.action;
+ }
+
+ /**
+ * Sets the action performed when the destination is selected.
+ * @param action the action
+ */
+ public void setAction(AbstractAction action) {
+ this.action = action;
+ }
+
+ /** {@inheritDoc} */
+ public void toSAX(ContentHandler handler) throws SAXException {
+ AttributesImpl atts = new AttributesImpl();
+ atts.addAttribute(null, "name", "name", XMLConstants.CDATA, getName());
+ handler.startElement(NAMED_DESTINATION.getNamespaceURI(),
+ NAMED_DESTINATION.getLocalName(), NAMED_DESTINATION.getQName(), atts);
+ if (getAction() != null) {
+ getAction().toSAX(handler);
+ }
+ handler.endElement(NAMED_DESTINATION.getNamespaceURI(),
+ NAMED_DESTINATION.getLocalName(), NAMED_DESTINATION.getQName());
+ }
+
+}