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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package org.apache.pdfbox.pdmodel.documentinterchange.taggedpdf;
19 import org.apache.pdfbox.cos.COSDictionary;
20 import org.apache.pdfbox.pdmodel.documentinterchange.logicalstructure.PDStructureElement;
23 * A Table attribute object.
25 * @author <a href="mailto:Johannes%20Koch%20%3Ckoch@apache.org%3E">Johannes Koch</a>
26 * @version $Revision: $
28 public class PDTableAttributeObject extends PDStandardAttributeObject
32 * standard attribute owner: Table
34 public static final String OWNER_TABLE = "Table";
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";
45 public static final String SCOPE_BOTH = "Both";
49 public static final String SCOPE_COLUMN = "Column";
53 public static final String SCOPE_ROW = "Row";
57 * Default constructor.
59 public PDTableAttributeObject()
61 this.setOwner(OWNER_TABLE);
65 * Creates a new Table attribute object with a given dictionary.
67 * @param dictionary the dictionary
69 public PDTableAttributeObject(COSDictionary dictionary)
76 * Gets the number of rows in the enclosing table that shall be spanned by
77 * the cell (RowSpan). The default value is 1.
79 * @return the row span
81 public int getRowSpan()
83 return this.getInteger(ROW_SPAN, 1);
87 * Sets the number of rows in the enclosing table that shall be spanned by
90 * @param rowSpan the row span
92 public void setRowSpan(int rowSpan)
94 this.setInteger(ROW_SPAN, rowSpan);
98 * Gets the number of columns in the enclosing table that shall be spanned
99 * by the cell (ColSpan). The default value is 1.
101 * @return the column span
103 public int getColSpan()
105 return this.getInteger(COL_SPAN, 1);
109 * Sets the number of columns in the enclosing table that shall be spanned
110 * by the cell (ColSpan).
112 * @param colSpan the column span
114 public void setColSpan(int colSpan)
116 this.setInteger(COL_SPAN, colSpan);
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.
125 * @return the headers.
127 public String[] getHeaders()
129 return this.getArrayOfString(HEADERS);
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.
138 * @param headers the headers
140 public void setHeaders(String[] headers)
142 this.setArrayOfString(HEADERS, headers);
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.
152 public String getScope()
154 return this.getName(SCOPE);
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:
163 * <li>{@link #SCOPE_ROW},</li>
164 * <li>{@link #SCOPE_COLUMN}, or</li>
165 * <li>{@link #SCOPE_BOTH}.</li>
168 * @param scope the scope
170 public void setScope(String scope)
172 this.setName(SCOPE, scope);
176 * Gets the summary of the table’s purpose and structure.
178 * @return the summary
180 public String getSummary()
182 return this.getString(SUMMARY);
186 * Sets the summary of the table’s purpose and structure.
188 * @param summary the summary
190 public void setSummary(String summary)
192 this.setString(SUMMARY, summary);
196 public String toString()
198 StringBuilder sb = new StringBuilder().append(super.toString());
199 if (this.isSpecified(ROW_SPAN))
201 sb.append(", RowSpan=").append(String.valueOf(this.getRowSpan()));
203 if (this.isSpecified(COL_SPAN))
205 sb.append(", ColSpan=").append(String.valueOf(this.getColSpan()));
207 if (this.isSpecified(HEADERS))
209 sb.append(", Headers=").append(arrayToString(this.getHeaders()));
211 if (this.isSpecified(SCOPE))
213 sb.append(", Scope=").append(this.getScope());
215 if (this.isSpecified(SUMMARY))
217 sb.append(", Summary=").append(this.getSummary());
219 return sb.toString();