]> _ Git - cubeextranet.git/blob
e7a25e09b54e71414e7ad68904e36aaab0008804
[cubeextranet.git] /
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements.  See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License.  You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 package org.apache.pdfbox.pdmodel.documentinterchange.logicalstructure;
18
19 import org.apache.pdfbox.cos.COSBase;
20 import org.apache.pdfbox.cos.COSDictionary;
21 import org.apache.pdfbox.cos.COSName;
22 import org.apache.pdfbox.pdmodel.PDPage;
23 import org.apache.pdfbox.pdmodel.common.COSObjectable;
24
25 /**
26  * A marked-content reference.
27  * 
28  * @author <a href="mailto:Johannes%20Koch%20%3Ckoch@apache.org%3E">Johannes Koch</a>
29  * @version $Revision: $
30  */
31 public class PDMarkedContentReference implements COSObjectable
32 {
33
34     public static final String TYPE = "MCR";
35
36     private COSDictionary dictionary;
37
38     protected COSDictionary getCOSDictionary()
39     {
40         return this.dictionary;
41     }
42
43     /**
44      * Default constructor
45      */
46     public PDMarkedContentReference()
47     {
48         this.dictionary = new COSDictionary();
49         this.dictionary.setName(COSName.TYPE, TYPE);
50     }
51
52     /**
53      * Constructor for an existing marked content reference.
54      * 
55      * @param pageDic the page dictionary
56      * @param mcid the marked content indentifier
57      */
58     public PDMarkedContentReference(COSDictionary dictionary)
59     {
60         this.dictionary = dictionary;
61     }
62
63     /**
64      * {@inheritDoc}
65      */
66     public COSBase getCOSObject()
67     {
68         return this.dictionary;
69     }
70
71     /**
72      * Gets the page.
73      * 
74      * @return the page
75      */
76     public PDPage getPage()
77     {
78         COSDictionary pg = (COSDictionary) this.getCOSDictionary()
79             .getDictionaryObject(COSName.PG);
80         if (pg != null)
81         {
82             return new PDPage(pg);
83         }
84         return null;
85     }
86
87     /**
88      * Sets the page.
89      * 
90      * @param page the page
91      */
92     public void setPage(PDPage page)
93     {
94         this.getCOSDictionary().setItem(COSName.PG, page);
95     }
96
97     /**
98      * Gets the marked content identifier.
99      * 
100      * @return the marked content identifier
101      */
102     public int getMCID()
103     {
104         return this.getCOSDictionary().getInt(COSName.MCID);
105     }
106
107     /**
108      * Sets the marked content identifier.
109      * 
110      * @param mcid the marked content identifier
111      */
112     public void setMCID(int mcid)
113     {
114         this.getCOSDictionary().setInt(COSName.MCID, mcid);
115     }
116
117
118     @Override
119     public String toString()
120     {
121         return new StringBuilder()
122             .append("mcid=").append(this.getMCID()).toString();
123     }
124
125 }