001: /**
002: * Copyright (c) 2004, www.pdfbox.org
003: * All rights reserved.
004: *
005: * Redistribution and use in source and binary forms, with or without
006: * modification, are permitted provided that the following conditions are met:
007: *
008: * 1. Redistributions of source code must retain the above copyright notice,
009: * this list of conditions and the following disclaimer.
010: * 2. Redistributions in binary form must reproduce the above copyright notice,
011: * this list of conditions and the following disclaimer in the documentation
012: * and/or other materials provided with the distribution.
013: * 3. Neither the name of pdfbox; nor the names of its
014: * contributors may be used to endorse or promote products derived from this
015: * software without specific prior written permission.
016: *
017: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
018: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
019: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
020: * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
021: * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
022: * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
023: * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
024: * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
025: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
026: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
027: *
028: * http://www.pdfbox.org
029: *
030: */package org.pdfbox.pdmodel.interactive.action.type;
031:
032: import org.pdfbox.cos.COSBase;
033: import org.pdfbox.cos.COSDictionary;
034:
035: /**
036: * This represents a URI action that can be executed in a PDF document.
037: *
038: * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
039: * @author Panagiotis Toumasis (ptoumasis@mail.gr)
040: * @version $Revision: 1.3 $
041: */
042: public class PDActionURI extends PDAction {
043: /**
044: * This type of action this object represents.
045: */
046: public static final String SUB_TYPE = "URI";
047:
048: /**
049: * Default constructor.
050: */
051: public PDActionURI() {
052: action = new COSDictionary();
053: setSubType(SUB_TYPE);
054: }
055:
056: /**
057: * Constructor.
058: *
059: * @param a The action dictionary.
060: */
061: public PDActionURI(COSDictionary a) {
062: super (a);
063: }
064:
065: /**
066: * Convert this standard java object to a COS object.
067: *
068: * @return The cos object that matches this Java object.
069: */
070: public COSBase getCOSObject() {
071: return action;
072: }
073:
074: /**
075: * Convert this standard java object to a COS object.
076: *
077: * @return The cos object that matches this Java object.
078: */
079: public COSDictionary getCOSDictionary() {
080: return action;
081: }
082:
083: /**
084: * This will get the type of action that the actions dictionary describes.
085: * It must be URI for a URI action.
086: *
087: * @return The S entry of the specific URI action dictionary.
088: */
089: public String getS() {
090: return action.getNameAsString("S");
091: }
092:
093: /**
094: * This will set the type of action that the actions dictionary describes.
095: * It must be URI for a URI action.
096: *
097: * @param s The URI action.
098: */
099: public void setS(String s) {
100: action.setName("S", s);
101: }
102:
103: /**
104: * This will get the uniform resource identifier to resolve, encoded in 7-bit ASCII.
105: *
106: * @return The URI entry of the specific URI action dictionary.
107: */
108: public String getURI() {
109: return action.getString("URI");
110: }
111:
112: /**
113: * This will set the uniform resource identifier to resolve, encoded in 7-bit ASCII.
114: *
115: * @param uri The uniform resource identifier.
116: */
117: public void setURI(String uri) {
118: action.setString("URI", uri);
119: }
120:
121: /**
122: * This will specify whether to track the mouse position when the URI is resolved.
123: * Default value: false.
124: * This entry applies only to actions triggered by the user's clicking an annotation;
125: * it is ignored for actions associated with outline items or with a document's OpenAction entry.
126: *
127: * @return A flag specifying whether to track the mouse position when the URI is resolved.
128: */
129: public boolean shouldTrackMousePosition() {
130: return action.getBoolean("MousePosition", true);
131: }
132:
133: /**
134: * This will specify whether to track the mouse position when the URI is resolved.
135: *
136: * @param value The flag value.
137: */
138: public void setTrackMousePosition(boolean value) {
139: action.setBoolean("MousePosition", value);
140: }
141:
142: /**
143: * This will get the base URI to be used in resolving relative URI references.
144: * URI actions within the document may specify URIs in partial form, to be interpreted
145: * relative to this base address. If no base URI is specified, such partial URIs
146: * will be interpreted relative to the location of the document itself.
147: * The use of this entry is parallel to that of the body element <BASE>, as described
148: * in the HTML 4.01 Specification.
149: *
150: * @return The URI entry of the specific URI dictionary.
151: */
152: public String getBase() {
153: return action.getString("Base");
154: }
155:
156: /**
157: * This will set the base URI to be used in resolving relative URI references.
158: * URI actions within the document may specify URIs in partial form, to be interpreted
159: * relative to this base address. If no base URI is specified, such partial URIs
160: * will be interpreted relative to the location of the document itself.
161: * The use of this entry is parallel to that of the body element <BASE>, as described
162: * in the HTML 4.01 Specification.
163: *
164: * @param base The the base URI to be used.
165: */
166: public void setBase(String base) {
167: action.setString("Base", base);
168: }
169: }
|