]> _ Git - cubeextranet.git/blob
c787f8431abf777baedf59f13b7df573613b2040
[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.taggedpdf;
18
19 import org.apache.pdfbox.cos.COSDictionary;
20 import org.apache.pdfbox.pdmodel.documentinterchange.logicalstructure.PDStructureElement;
21
22 /**
23  * A Table attribute object.
24  * 
25  * @author <a href="mailto:Johannes%20Koch%20%3Ckoch@apache.org%3E">Johannes Koch</a>
26  * @version $Revision: $
27  */
28 public class PDTableAttributeObject extends PDStandardAttributeObject
29 {
30
31     /**
32      *  standard attribute owner: Table
33      */
34     public static final String OWNER_TABLE = "Table";
35
36     protected static final String ROW_SPAN = "RowSpan";
37     protected static final String COL_SPAN = "ColSpan";
38     protected static final String HEADERS  = "Headers";
39     protected static final String SCOPE    = "Scope";
40     protected static final String SUMMARY  = "Summary";
41
42     /**
43      * Scope: Both
44      */
45     public static final String SCOPE_BOTH   = "Both";
46     /**
47      * Scope: Column
48      */
49     public static final String SCOPE_COLUMN = "Column";
50     /**
51      * Scope: Row
52      */
53     public static final String SCOPE_ROW    = "Row";
54
55
56     /**
57      * Default constructor.
58      */
59     public PDTableAttributeObject()
60     {
61         this.setOwner(OWNER_TABLE);
62     }
63
64     /**
65      * Creates a new Table attribute object with a given dictionary.
66      * 
67      * @param dictionary the dictionary
68      */
69     public PDTableAttributeObject(COSDictionary dictionary)
70     {
71         super(dictionary);
72     }
73
74
75     /**
76      * Gets the number of rows in the enclosing table that shall be spanned by
77      * the cell (RowSpan). The default value is 1.
78      * 
79      * @return the row span
80      */
81     public int getRowSpan()
82     {
83         return this.getInteger(ROW_SPAN, 1);
84     }
85
86     /**
87      * Sets the number of rows in the enclosing table that shall be spanned by
88      * the cell (RowSpan).
89      * 
90      * @param rowSpan the row span
91      */
92     public void setRowSpan(int rowSpan)
93     {
94         this.setInteger(ROW_SPAN, rowSpan);
95     }
96
97     /**
98      * Gets the number of columns in the enclosing table that shall be spanned
99      * by the cell (ColSpan). The default value is 1.
100      * 
101      * @return the column span
102      */
103     public int getColSpan()
104     {
105         return this.getInteger(COL_SPAN, 1);
106     }
107
108     /**
109      * Sets the number of columns in the enclosing table that shall be spanned
110      * by the cell (ColSpan).
111      * 
112      * @param colSpan the column span
113      */
114     public void setColSpan(int colSpan)
115     {
116         this.setInteger(COL_SPAN, colSpan);
117     }
118
119     /**
120      * Gets the headers (Headers). An array of byte strings, where each string
121      * shall be the element identifier (see the
122      * {@link PDStructureElement#getElementIdentifier()}) for a TH structure
123      * element that shall be used as a header associated with this cell.
124      * 
125      * @return the headers.
126      */
127     public String[] getHeaders()
128     {
129         return this.getArrayOfString(HEADERS);
130     }
131
132     /**
133      * Sets the headers (Headers). An array of byte strings, where each string
134      * shall be the element identifier (see the
135      * {@link PDStructureElement#getElementIdentifier()}) for a TH structure
136      * element that shall be used as a header associated with this cell.
137      * 
138      * @param headers the headers
139      */
140     public void setHeaders(String[] headers)
141     {
142         this.setArrayOfString(HEADERS, headers);
143     }
144
145     /**
146      * Gets the scope (Scope). It shall reflect whether the header cell applies
147      * to the rest of the cells in the row that contains it, the column that
148      * contains it, or both the row and the column that contain it.
149      * 
150      * @return the scope
151      */
152     public String getScope()
153     {
154         return this.getName(SCOPE);
155     }
156
157     /**
158      * Sets the scope (Scope). It shall reflect whether the header cell applies
159      * to the rest of the cells in the row that contains it, the column that
160      * contains it, or both the row and the column that contain it. The value
161      * shall be one of the following:
162      * <ul>
163      *   <li>{@link #SCOPE_ROW},</li>
164      *   <li>{@link #SCOPE_COLUMN}, or</li>
165      *   <li>{@link #SCOPE_BOTH}.</li>
166      * </ul>
167      * 
168      * @param scope the scope
169      */
170     public void setScope(String scope)
171     {
172         this.setName(SCOPE, scope);
173     }
174
175     /**
176      * Gets the summary of the table’s purpose and structure.
177      * 
178      * @return the summary
179      */
180     public String getSummary()
181     {
182         return this.getString(SUMMARY);
183     }
184
185     /**
186      * Sets the summary of the table’s purpose and structure.
187      * 
188      * @param summary the summary
189      */
190     public void setSummary(String summary)
191     {
192         this.setString(SUMMARY, summary);
193     }
194
195     @Override
196     public String toString()
197     {
198         StringBuilder sb = new StringBuilder().append(super.toString());
199         if (this.isSpecified(ROW_SPAN))
200         {
201             sb.append(", RowSpan=").append(String.valueOf(this.getRowSpan()));
202         }
203         if (this.isSpecified(COL_SPAN))
204         {
205             sb.append(", ColSpan=").append(String.valueOf(this.getColSpan()));
206         }
207         if (this.isSpecified(HEADERS))
208         {
209             sb.append(", Headers=").append(arrayToString(this.getHeaders()));
210         }
211         if (this.isSpecified(SCOPE))
212         {
213             sb.append(", Scope=").append(this.getScope());
214         }
215         if (this.isSpecified(SUMMARY))
216         {
217             sb.append(", Summary=").append(this.getSummary());
218         }
219         return sb.toString();
220     }
221
222 }