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