diff --git a/validation-model/src/main/java/org/verapdf/gf/model/impl/operator/markedcontent/GFOpMarkedContent.java b/validation-model/src/main/java/org/verapdf/gf/model/impl/operator/markedcontent/GFOpMarkedContent.java index ba1d08c2c..e0b3e0f89 100644 --- a/validation-model/src/main/java/org/verapdf/gf/model/impl/operator/markedcontent/GFOpMarkedContent.java +++ b/validation-model/src/main/java/org/verapdf/gf/model/impl/operator/markedcontent/GFOpMarkedContent.java @@ -90,17 +90,25 @@ public List getLinkedObjects(String link) { } } - public List getTag() { - if (this.arguments.size() > 1) { - COSBase name = this.arguments.get(this.arguments.size() - 2); - if (name.getType() == COSObjType.COS_NAME) { - List list = new ArrayList<>(MAX_NUMBER_OF_ELEMENTS); - list.add(new GFCosName((COSName) name)); - return Collections.unmodifiableList(list); - } + public List getLinkTag() { + COSName tag = getTag(); + if (tag != null) { + List list = new ArrayList<>(MAX_NUMBER_OF_ELEMENTS); + list.add(new GFCosName(tag)); + return Collections.unmodifiableList(list); } return Collections.emptyList(); } + + public COSName getTag() { + if (this.arguments.size() > 1) { + COSBase name = this.arguments.get(this.arguments.size() - 2); + if (name.getType() == COSObjType.COS_NAME) { + return (COSName) name; + } + } + return null; + } protected List getPropertiesDict() { if (this.propertiesDict != null) { @@ -122,10 +130,10 @@ public List getLang() { } public String getParentsTags() { - List tagList = getTag(); + COSName tagName = getTag(); String tag = ""; - if (tagList.size() != 0) { - tag = tagList.get(0).getinternalRepresentation(); + if (tagName != null) { + tag = tagName.getString(); } String parentsTags = ""; if (markedContent != null) { @@ -241,13 +249,7 @@ public COSString getInheritedStringAttribute(ASAtom key) { if (string != null) { return string; } - if (markedContent != null) { - string = markedContent.getInheritedStringAttribute(key); - if (string != null) { - return string; - } - } - return null; + return markedContent != null ? markedContent.getInheritedStringAttribute(key) : null; } public COSString getStringAttribute(ASAtom key) { @@ -261,13 +263,7 @@ public Long getInheritedMCID() { if (mcid != null) { return mcid; } - if (markedContent != null) { - mcid = markedContent.getInheritedMCID(); - if (mcid != null) { - return mcid; - } - } - return null; + return markedContent != null ? markedContent.getInheritedMCID() : null; } } diff --git a/validation-model/src/main/java/org/verapdf/gf/model/impl/operator/markedcontent/GFOp_BDC.java b/validation-model/src/main/java/org/verapdf/gf/model/impl/operator/markedcontent/GFOp_BDC.java index 08aef48af..6fa99151c 100644 --- a/validation-model/src/main/java/org/verapdf/gf/model/impl/operator/markedcontent/GFOp_BDC.java +++ b/validation-model/src/main/java/org/verapdf/gf/model/impl/operator/markedcontent/GFOp_BDC.java @@ -60,7 +60,7 @@ public List getLinkedObjects( String link) { switch (link) { case TAG: - return this.getTag(); + return this.getLinkTag(); case PROPERTIES: return this.getPropertiesDict(); case LANG: diff --git a/validation-model/src/main/java/org/verapdf/gf/model/impl/operator/markedcontent/GFOp_BMC.java b/validation-model/src/main/java/org/verapdf/gf/model/impl/operator/markedcontent/GFOp_BMC.java index 461a9992f..e543f8a6d 100644 --- a/validation-model/src/main/java/org/verapdf/gf/model/impl/operator/markedcontent/GFOp_BMC.java +++ b/validation-model/src/main/java/org/verapdf/gf/model/impl/operator/markedcontent/GFOp_BMC.java @@ -49,7 +49,7 @@ public GFOp_BMC(List arguments, GFOpMarkedContent markedContent, String public List getLinkedObjects(String link) { switch (link) { case TAG: - return this.getTag(); + return this.getLinkTag(); case PROPERTIES: return this.getPropertiesDict(); default: @@ -58,16 +58,14 @@ public List getLinkedObjects(String link) { } @Override - public List getTag() { - if (!this.arguments.isEmpty()) { - COSBase name = this.arguments.get(this.arguments.size() - 1); - if (name.getType() == COSObjType.COS_NAME) { - List list = new ArrayList<>(MAX_NUMBER_OF_ELEMENTS); - list.add(new GFCosName((COSName) name)); - return Collections.unmodifiableList(list); - } - } - return Collections.emptyList(); - } + public COSName getTag() { + if (!this.arguments.isEmpty()) { + COSBase name = this.arguments.get(this.arguments.size() - 1); + if (name.getType() == COSObjType.COS_NAME) { + return (COSName) name; + } + } + return null; + } } diff --git a/validation-model/src/main/java/org/verapdf/gf/model/impl/operator/markedcontent/GFOp_DP.java b/validation-model/src/main/java/org/verapdf/gf/model/impl/operator/markedcontent/GFOp_DP.java index 3a3bb4fe8..a6072a2e3 100644 --- a/validation-model/src/main/java/org/verapdf/gf/model/impl/operator/markedcontent/GFOp_DP.java +++ b/validation-model/src/main/java/org/verapdf/gf/model/impl/operator/markedcontent/GFOp_DP.java @@ -45,7 +45,7 @@ public List getLinkedObjects( String link) { switch (link) { case TAG: - return this.getTag(); + return this.getLinkTag(); case PROPERTIES: return this.getPropertiesDict(); default: diff --git a/validation-model/src/main/java/org/verapdf/gf/model/impl/operator/markedcontent/GFOp_MP.java b/validation-model/src/main/java/org/verapdf/gf/model/impl/operator/markedcontent/GFOp_MP.java index c6d3c84e8..8502c50d9 100644 --- a/validation-model/src/main/java/org/verapdf/gf/model/impl/operator/markedcontent/GFOp_MP.java +++ b/validation-model/src/main/java/org/verapdf/gf/model/impl/operator/markedcontent/GFOp_MP.java @@ -45,25 +45,21 @@ public GFOp_MP(List arguments) { } @Override - public List getLinkedObjects( - String link) { + public List getLinkedObjects(String link) { if (TAG.equals(link)) { - return this.getTag(); + return this.getLinkTag(); } return super.getLinkedObjects(link); } - @Override - public List getTag() { + public COSName getTag() { if (!this.arguments.isEmpty()) { COSBase name = this.arguments.get(this.arguments.size() - 1); if (name.getType() == COSObjType.COS_NAME) { - List list = new ArrayList<>(MAX_NUMBER_OF_ELEMENTS); - list.add(new GFCosName((COSName) name)); - return Collections.unmodifiableList(list); + return (COSName) name; } } - return Collections.emptyList(); + return null; } } diff --git a/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/gfse/contents/GFSEMarkedContent.java b/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/gfse/contents/GFSEMarkedContent.java index 69ba4bce8..42eb6db1c 100644 --- a/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/gfse/contents/GFSEMarkedContent.java +++ b/validation-model/src/main/java/org/verapdf/gf/model/impl/pd/gfse/contents/GFSEMarkedContent.java @@ -21,6 +21,7 @@ package org.verapdf.gf.model.impl.pd.gfse.contents; import org.verapdf.as.ASAtom; +import org.verapdf.cos.COSName; import org.verapdf.cos.COSObject; import org.verapdf.cos.COSString; import org.verapdf.gf.model.impl.operator.inlineimage.GFOp_EI; @@ -140,11 +141,8 @@ public String getExtraContext() { @Override public String gettag() { - List tag = operator.getTag(); - if (tag != null && tag.size() != 0) { - return tag.get(0).getinternalRepresentation(); - } - return null; + COSName tag = operator.getTag(); + return tag != null ? tag.getString() : null; } @Override