Method from org.apache.pdfbox.pdmodel.documentinterchange.logicalstructure.PDStructureElement Detail: |
public void addAttribute(PDAttributeObject attributeObject) {
COSName key = COSName.A;
attributeObject.setStructureElement(this);
COSBase a = this.getCOSDictionary().getDictionaryObject(key);
COSArray array = null;
if (a instanceof COSArray)
{
array = (COSArray) a;
}
else
{
array = new COSArray();
if (a != null)
{
array.add(a);
array.add(COSInteger.get(0));
}
}
this.getCOSDictionary().setItem(key, array);
array.add(attributeObject);
array.add(COSInteger.get(this.getRevisionNumber()));
}
Adds an attribute object. |
public void addClassName(String className) {
if (className == null)
{
return;
}
COSName key = COSName.C;
COSBase c = this.getCOSDictionary().getDictionaryObject(key);
COSArray array = null;
if (c instanceof COSArray)
{
array = (COSArray) c;
}
else
{
array = new COSArray();
if (c != null)
{
array.add(c);
array.add(COSInteger.get(0));
}
}
this.getCOSDictionary().setItem(key, array);
array.add(COSName.getPDFName(className));
array.add(COSInteger.get(this.getRevisionNumber()));
}
|
public void appendKid(PDMarkedContent markedContent) {
if (markedContent == null)
{
return;
}
this.appendKid(COSInteger.get(markedContent.getMCID()));
}
Appends a marked-content sequence kid. |
public void appendKid(PDMarkedContentReference markedContentReference) {
this.appendObjectableKid(markedContentReference);
}
Appends a marked-content reference kid. |
public void appendKid(PDObjectReference objectReference) {
this.appendObjectableKid(objectReference);
}
Appends an object reference kid. |
public void attributeChanged(PDAttributeObject attributeObject) {
COSName key = COSName.A;
COSBase a = this.getCOSDictionary().getDictionaryObject(key);
if (a instanceof COSArray)
{
COSArray array = (COSArray) a;
for (int i = 0; i < array.size(); i++)
{
COSBase entry = array.getObject(i);
if (entry.equals(attributeObject.getCOSObject()))
{
COSBase next = array.get(i + 1);
if (next instanceof COSInteger)
{
array.set(i + 1, COSInteger.get(this.getRevisionNumber()));
}
}
}
}
else
{
COSArray array = new COSArray();
array.add(a);
array.add(COSInteger.get(this.getRevisionNumber()));
this.getCOSDictionary().setItem(key, array);
}
}
Updates the revision number for the given attribute object. |
public String getActualText() {
return this.getCOSDictionary().getString(COSName.ACTUAL_TEXT);
}
Returns the actual text (ActualText). |
public String getAlternateDescription() {
return this.getCOSDictionary().getString(COSName.ALT);
}
Returns the alternate description (Alt). |
public Revisions<PDAttributeObject> getAttributes() {
Revisions< PDAttributeObject > attributes =
new Revisions< PDAttributeObject >();
COSBase a = this.getCOSDictionary().getDictionaryObject(COSName.A);
if (a instanceof COSArray)
{
COSArray aa = (COSArray) a;
Iterator< COSBase > it = aa.iterator();
PDAttributeObject ao = null;
while (it.hasNext())
{
COSBase item = it.next();
if (item instanceof COSDictionary)
{
ao = PDAttributeObject.create((COSDictionary) item);
ao.setStructureElement(this);
attributes.addObject(ao, 0);
}
else if (item instanceof COSInteger)
{
attributes.setRevisionNumber(ao,
((COSInteger) item).intValue());
}
}
}
if (a instanceof COSDictionary)
{
PDAttributeObject ao = PDAttributeObject.create((COSDictionary) a);
ao.setStructureElement(this);
attributes.addObject(ao, 0);
}
return attributes;
}
Returns the attributes together with their revision numbers (A). |
public Revisions<String> getClassNames() {
COSName key = COSName.C;
Revisions< String > classNames = new Revisions< String >();
COSBase c = this.getCOSDictionary().getDictionaryObject(key);
if (c instanceof COSName)
{
classNames.addObject(((COSName) c).getName(), 0);
}
if (c instanceof COSArray)
{
COSArray array = (COSArray) c;
Iterator< COSBase > it = array.iterator();
String className = null;
while (it.hasNext())
{
COSBase item = it.next();
if (item instanceof COSName)
{
className = ((COSName) item).getName();
classNames.addObject(className, 0);
}
else if (item instanceof COSInteger)
{
classNames.setRevisionNumber(className,
((COSInteger) item).intValue());
}
}
}
return classNames;
}
Returns the class names together with their revision numbers (C). |
public String getElementIdentifier() {
return this.getCOSDictionary().getString(COSName.ID);
}
Returns the element identifier (ID). |
public String getExpandedForm() {
return this.getCOSDictionary().getString(COSName.E);
}
Returns the expanded form (E). |
public String getLanguage() {
return this.getCOSDictionary().getString(COSName.LANG);
}
Returns the language (Lang). |
public PDPage getPage() {
COSDictionary pageDic = (COSDictionary) this.getCOSDictionary()
.getDictionaryObject(COSName.PG);
if (pageDic == null)
{
return null;
}
return new PDPage(pageDic);
}
Returns the page on which some or all of the content items designated by
the K entry shall be rendered (Pg). |
public PDStructureNode getParent() {
COSDictionary p = (COSDictionary) this.getCOSDictionary()
.getDictionaryObject(COSName.P);
if (p == null)
{
return null;
}
return PDStructureNode.create((COSDictionary) p);
}
Returns the parent in the structure hierarchy (P). |
public int getRevisionNumber() {
return this.getCOSDictionary().getInt(COSName.R, 0);
}
Returns the revision number (R). |
public String getStandardStructureType() {
String type = this.getStructureType();
String mappedType;
while (true)
{
mappedType = this.getRoleMap().get(type);
if ((mappedType == null) || type.equals(mappedType))
{
break;
}
type = mappedType;
}
return type;
}
Returns the standard structure type, the actual structure type is mapped
to in the role map. |
public String getStructureType() {
return this.getCOSDictionary().getNameAsString(COSName.S);
}
Returns the structure type (S). |
public String getTitle() {
return this.getCOSDictionary().getString(COSName.T);
}
|
public void incrementRevisionNumber() {
this.setRevisionNumber(this.getRevisionNumber() + 1);
}
Increments th revision number |
public void insertBefore(COSInteger markedContentIdentifier,
Object refKid) {
this.insertBefore((COSBase) markedContentIdentifier, refKid);
}
Inserts a marked-content identifier kid before a reference kid. |
public void insertBefore(PDMarkedContentReference markedContentReference,
Object refKid) {
this.insertObjectableBefore(markedContentReference, refKid);
}
Inserts a marked-content reference kid before a reference kid. |
public void insertBefore(PDObjectReference objectReference,
Object refKid) {
this.insertObjectableBefore(objectReference, refKid);
}
Inserts an object reference kid before a reference kid. |
public void removeAttribute(PDAttributeObject attributeObject) {
COSName key = COSName.A;
COSBase a = this.getCOSDictionary().getDictionaryObject(key);
if (a instanceof COSArray)
{
COSArray array = (COSArray) a;
array.remove(attributeObject.getCOSObject());
if ((array.size() == 2) && (array.getInt(1) == 0))
{
this.getCOSDictionary().setItem(key, array.getObject(0));
}
}
else
{
COSBase directA = a;
if (a instanceof COSObject)
{
directA = ((COSObject) a).getObject();
}
if (attributeObject.getCOSObject().equals(directA))
{
this.getCOSDictionary().setItem(key, null);
}
}
attributeObject.setStructureElement(null);
}
Removes an attribute object. |
public void removeClassName(String className) {
if (className == null)
{
return;
}
COSName key = COSName.C;
COSBase c = this.getCOSDictionary().getDictionaryObject(key);
COSName name = COSName.getPDFName(className);
if (c instanceof COSArray)
{
COSArray array = (COSArray) c;
array.remove(name);
if ((array.size() == 2) && (array.getInt(1) == 0))
{
this.getCOSDictionary().setItem(key, array.getObject(0));
}
}
else
{
COSBase directC = c;
if (c instanceof COSObject)
{
directC = ((COSObject) c).getObject();
}
if (name.equals(directC))
{
this.getCOSDictionary().setItem(key, null);
}
}
}
|
public void removeKid(COSInteger markedContentIdentifier) {
this.removeKid((COSBase) markedContentIdentifier);
}
Removes a marked-content identifier kid. |
public void removeKid(PDMarkedContentReference markedContentReference) {
this.removeObjectableKid(markedContentReference);
}
Removes a marked-content reference kid. |
public void removeKid(PDObjectReference objectReference) {
this.removeObjectableKid(objectReference);
}
Removes an object reference kid. |
public void setActualText(String actualText) {
this.getCOSDictionary().setString(COSName.ACTUAL_TEXT, actualText);
}
Sets the actual text (ActualText). |
public void setAlternateDescription(String alternateDescription) {
this.getCOSDictionary().setString(COSName.ALT, alternateDescription);
}
Sets the alternate description (Alt). |
public void setAttributes(Revisions<PDAttributeObject> attributes) {
COSName key = COSName.A;
if ((attributes.size() == 1) && (attributes.getRevisionNumber(0) == 0))
{
PDAttributeObject attributeObject = attributes.getObject(0);
attributeObject.setStructureElement(this);
this.getCOSDictionary().setItem(key, attributeObject);
return;
}
COSArray array = new COSArray();
for (int i = 0; i < attributes.size(); i++)
{
PDAttributeObject attributeObject = attributes.getObject(i);
attributeObject.setStructureElement(this);
int revisionNumber = attributes.getRevisionNumber(i);
if (revisionNumber < 0)
{
// TODO throw Exception because revision number must be > -1?
}
array.add(attributeObject);
array.add(COSInteger.get(revisionNumber));
}
this.getCOSDictionary().setItem(key, array);
}
Sets the attributes together with their revision numbers (A). |
public void setClassNames(Revisions<String> classNames) {
if (classNames == null)
{
return;
}
COSName key = COSName.C;
if ((classNames.size() == 1) && (classNames.getRevisionNumber(0) == 0))
{
String className = classNames.getObject(0);
this.getCOSDictionary().setName(key, className);
return;
}
COSArray array = new COSArray();
for (int i = 0; i < classNames.size(); i++)
{
String className = classNames.getObject(i);
int revisionNumber = classNames.getRevisionNumber(i);
if (revisionNumber < 0)
{
// TODO throw Exception because revision number must be > -1?
}
array.add(COSName.getPDFName(className));
array.add(COSInteger.get(revisionNumber));
}
this.getCOSDictionary().setItem(key, array);
}
Sets the class names together with their revision numbers (C). |
public void setElementIdentifier(String id) {
this.getCOSDictionary().setString(COSName.ID, id);
}
Sets the element identifier (ID). |
public void setExpandedForm(String expandedForm) {
this.getCOSDictionary().setString(COSName.E, expandedForm);
}
Sets the expanded form (E). |
public void setLanguage(String language) {
this.getCOSDictionary().setString(COSName.LANG, language);
}
Sets the language (Lang). |
public void setPage(PDPage page) {
this.getCOSDictionary().setItem(COSName.PG, page);
}
Sets the page on which some or all of the content items designated by
the K entry shall be rendered (Pg). |
public void setParent(PDStructureNode structureNode) {
this.getCOSDictionary().setItem(COSName.P, structureNode);
}
Sets the parent in the structure hierarchy (P). |
public void setRevisionNumber(int revisionNumber) {
if (revisionNumber < 0)
{
// TODO throw Exception because revision number must be > -1?
}
this.getCOSDictionary().setInt(COSName.R, revisionNumber);
}
Sets the revision number (R). |
public void setStructureType(String structureType) {
this.getCOSDictionary().setName(COSName.S, structureType);
}
Sets the structure type (S). |
public void setTitle(String title) {
this.getCOSDictionary().setString(COSName.T, title);
}
|