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